@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
final MonteCarloSS mcss = (MonteCarloSS) e.getSource();
Trajectory trajectory;
switch (e.getID()) {
case MonteCarloSS.TrajectoryStartEvent:
trajectory = new Trajectory(true, -1);
saveTrajectoryInteraction(trajectory, mcss.getElectron());
cachedTrajectories.push(trajectory);
break;
case MonteCarloSS.StartSecondaryEvent:
trajectory = new Trajectory(false, 3); // Hard inelastic
saveTrajectoryInteraction(trajectory, mcss.getElectron());
cachedTrajectories.push(trajectory);
break;
case MonteCarloSS.EndSecondaryEvent:
case MonteCarloSS.TrajectoryEndEvent:
trajectory = cachedTrajectories.pop();
if (!trajectory.primary && !secondary) // Do not record secondary
break;
if (trajectory.exitState < 0)
trajectory.exitState = 3; // Absorbed
trajectories.add(trajectory);
break;
case MonteCarloSS.ScatterEvent:
trajectory = cachedTrajectories.peek();
saveTrajectoryInteraction(trajectory, mcss.getElectron());
break;
case MonteCarloSS.BackscatterEvent:
trajectory = cachedTrajectories.peek();
trajectory.exitState = 2; // Backscattered
// TODO: Should also check for transmitted