lcsim/src/org/lcsim/recon/tracking/seedtracker/analysis
diff -u -r1.2 -r1.3
--- AnalysisUtils.java 11 Sep 2008 23:41:41 -0000 1.2
+++ AnalysisUtils.java 16 Sep 2008 01:03:10 -0000 1.3
@@ -98,7 +98,7 @@
* @return a double purity
*/
public static double FindTrackPurity(Track trk){
- double purity=0;
+ double purity=0.;
//MCParticle and Int map, int will be the number of times this mcparticle shows up in the track
Map<MCParticle,Integer> occurrences = new HashMap<MCParticle,Integer>();
double mostoccured;
@@ -190,7 +190,7 @@
Map<MCParticle,List<String>> hitlayermap = new HashMap<MCParticle,List<String>>();
List<HelicalTrackHit> listjmk = event.get(HelicalTrackHit.class,"HelicalTrackHits");
- //Sort the list of hits in order of there time of impact
+ //Sort the list of hits in order of their time of impact
Collections.sort(listjmk, new Comparator() {
public int compare(Object o1, Object o2) {
HelicalTrackHit h1 = (HelicalTrackHit) o1;
@@ -213,8 +213,6 @@
ArrayList<String> layers = new ArrayList<String>();
layers.add(hito.getLayerIdentifier());
hitlayermap.put(mp, layers);
- ArrayList<HelicalTrackHit> trackhits = new ArrayList<HelicalTrackHit>();
- trackhits.add(hito);
}
}
}
@@ -235,7 +233,7 @@
effimap.put(mcp, wgt);
}
//if no track was found, but meets all the parameters put it into the map with wgt=0
- else if(pt>ptmin && Math.abs(dca) < dcamax && Math.abs(z0) < z0max && Math.cos(theta) < costhetamax ){
+ else if(pt>ptmin && Math.abs(dca) < dcamax && Math.abs(z0) < z0max && Math.abs(Math.cos(theta)) < costhetamax ){
effimap.put(mcp, wgt);
}
}
@@ -283,8 +281,14 @@
mcmatch = me.getKey();
}
}
- //if the track already is in the map...thats bad, otherwise add the mcmatch (MCParticle) key and its track
- if (trkmap.containsKey(mcmatch)) System.out.println("more than one track associated with an MCParticle!!");
+ //if the track already is in the map, save the track with the highest purity
+ if (trkmap.containsKey(mcmatch)) {
+ double purityold = FindTrackPurity(trkmap.get(mcmatch));
+ double puritynew = FindTrackPurity(track);
+ if (puritynew > purityold) {
+ trkmap.put(mcmatch, track);
+ }
+ }
else trkmap.put(mcmatch, track);
}
}