lcsim/src/org/lcsim/recon/ztracking/cheater
diff -u -r1.5 -r1.6
--- TrackingCheater.java 26 Sep 2005 22:48:16 -0000 1.5
+++ TrackingCheater.java 19 Oct 2005 16:54:36 -0000 1.6
@@ -17,6 +17,8 @@
import org.lcsim.util.aida.AIDA;
import org.lcsim.util.loop.LCSimLoop;
+import hep.physics.particle.*; // Particle,...
+
import java.io.File;
import java.text.DecimalFormat;
import java.util.ArrayList;
@@ -35,7 +37,7 @@
{
public static boolean INITIALIZED = false;
//static int MAXPoints=25000;
- boolean useFinalStateParticles = true;
+ boolean useFinalStateParticles = false;
int NTracks = 0, NCombinedTracks = 0;
@@ -50,6 +52,9 @@
INITIALIZED = true;
}
+ public boolean getUseFinalStateParticles() { return useFinalStateParticles; }
+ public void setUseFinalStateParticles(boolean set) { useFinalStateParticles = set; }
+
public void process(EventHeader event)
{
nEvt++;
@@ -59,6 +64,9 @@
//if (first) System.out.println(ClassName+"\n"+" Find Tracker tracks.");
if (first) System.out.println(" Find charged tracks.");
+ // Get MCParticle mapping from event.
+ map = getMCParticleMapping(event);
+
// Find tracks in each detector system.
List<List<SimTrackerHit>> collections = event.get(SimTrackerHit.class);
for (List<SimTrackerHit> collection : collections)
@@ -88,10 +96,14 @@
{
double x[] = hit.getPoint();
MCParticle mcp = hit.getMCParticle(); String statusCode = getStatusCode(mcp);
- while (useFinalStateParticles && !statusCode.equals("GEN_FINAL_STATE")) {
+ while (useFinalStateParticles && !(statusCode.equals("GEN_FINAL_STATE")||statusCode.equals("GEN_PREDECAY"))) {
List<MCParticle> parents = mcp.getParents();
MCParticle parent = null; if (!parents.isEmpty()) parent = parents.get(0);
if (parent!=null) { mcp = parent; statusCode = getStatusCode(mcp); } else break;
+ if (statusCode.equals("GEN_INITIAL")) {
+ String text = " Traced back to initial state for hits from MCParticle #"+map.get(mcp);
+ System.out.println(text); System.err.println(text);
+ }
}
CheatTrack ct = result.get(mcp);
if (ct == null) { result.put(mcp,ct = new CheatTrack(mcp)); NTracks++; }
@@ -108,6 +120,23 @@
return code;
}
+ Map<MCParticle,Integer> map = null;
+
+ /** Get ... */
+ Map<MCParticle,Integer> getMCParticleMapping(EventHeader event)
+ {
+ Map<MCParticle,Integer> map = new HashMap<MCParticle,Integer>();
+
+ // Get Monte Carlo particles from LCSIM event
+ List<MCParticle> particleList = event.getMCParticles();
+ int n=-1;
+ for (MCParticle mcp : particleList) {
+ Particle particle = (Particle) mcp; n++;
+ map.put(mcp,n);
+ }
+ return map;
+ }
+
private Map<MCParticle, CombinedTrack> findCombinedTracks(List<List<CheatTrack>> collections)
{
Map<MCParticle,CombinedTrack> result = new HashMap<MCParticle,CombinedTrack>();