1 package org.lcsim.mc.fast.util; 2 3 import java.util.List; 4 import org.lcsim.event.MCParticle; 5 6 /** 7 * MCParticleClassifier has a single method, getClassification(MCParticle), that returns an enum classifying the particle. 8 * 9 * Possible return values are: 10 * 11 * GEN_INITIAL -> Generator particle the simulator never saw 12 * 13 * GEN_PREDECAY -> Generator particle passed to the simulator along with a predecay, and the simulator generated the decay products. 14 * 15 * GEN_FINAL_STATE -> Generator final state particle: either FinalState in the input file, or intermediate passed to the Simulator with a predecay that never happened. 16 * 17 * SIM_BACKSCATTER -> Simulator particle produced as a result of backscatter from a non-tracking region. 18 * 19 * SIM_VERTEX_NOT_PARENT_ENDPOINT -> Simulator particle produced without destroying parent. 20 * 21 * SIM_INTERACTED_OR_DECAYED -> Simulator particle produced as a result of an interaction or decay in a tracking region. 22 * @version $Id: MCParticleClassifier.java,v 1.5 2006/06/28 04:48:33 jstrube Exp $ 23 */ 24 public class MCParticleClassifier { 25 public enum MCPClass { 26 GEN_INITIAL, GEN_PREDECAY, GEN_FINAL_STATE, SIM_BACKSCATTER, SIM_VERTEX_NOT_PARENT_ENDPOINT, SIM_INTERACTED_OR_DECAYED 27 }; 28 29 public static MCPClass getClassification(MCParticle p) { 30 // 31 // Check if particle existed in Generator 32 // 33 if (p.getGeneratorStatus() > 0) { 34 // 35 // Remove the documentation particles in case the generator left them floating 36 // 37 if (p.getGeneratorStatus() == MCParticle.DOCUMENTATION) 38 return MCPClass.GEN_INITIAL; 39 // 40 // Check if the generator particle has daughters in the generator 41 // 42 boolean hasGeneratorDaughters = false; 43 List<MCParticle> daughters = p.getDaughters(); 44 for (MCParticle d : daughters) { 45 if (d.getGeneratorStatus() > 0) 46 hasGeneratorDaughters = true; 47 } 48 // 49 // If no generator daughters return final state 50 // 51 if (!hasGeneratorDaughters) { 52 // 53 // Trap for strange generator problem: Hanging quark with INTERMEDIATE status 54 // Therefore must check that Simulator saw this particle, otherwise return 55 // GEN_INITIAL 56 // 57 boolean inSim = p.getSimulatorStatus().isDecayedInTracker() || p.getSimulatorStatus().isDecayedInCalorimeter() || p.getSimulatorStatus().hasLeftDetector() || p.getSimulatorStatus().isStopped(); 58 if (inSim) { 59 return MCPClass.GEN_FINAL_STATE; 60 } else { 61 return MCPClass.GEN_INITIAL; 62 } 63 } 64 // 65 // A generator particle with gerenrator daughters: 66 // if the simulator saw it must be a predecay 67 // 68 if (p.getSimulatorStatus().isDecayedInTracker() | p.getSimulatorStatus().isDecayedInCalorimeter()) { 69 return MCPClass.GEN_PREDECAY; 70 } 71 // 72 // simulator never saw it: initial 73 // 74 return MCPClass.GEN_INITIAL; 75 } else { 76 // 77 // Particle didn't exist in generator: choices are backscatter, production without killing parent, 78 // or the result of an interaction or decay( killing parent) 79 // 80 if (p.getSimulatorStatus().isBackscatter()) { 81 return MCPClass.SIM_BACKSCATTER; 82 } 83 84 if (p.getSimulatorStatus().vertexIsNotEndpointOfParent()) { 85 return MCPClass.SIM_VERTEX_NOT_PARENT_ENDPOINT; 86 } 87 88 return MCPClass.SIM_INTERACTED_OR_DECAYED; 89 } 90 } 91 }