lcsim/src/org/lcsim/contrib/Partridge/TrackingTest
diff -N TrackAnalysis.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TrackAnalysis.java 18 Oct 2008 01:36:01 -0000 1.1
@@ -0,0 +1,85 @@
+/*
+ * TrackAnalysis.java
+ *
+ * Created on October 16, 2008, 6:09 PM
+ *
+ */
+
+package org.lcsim.contrib.Partridge.TrackingTest;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.lcsim.event.MCParticle;
+import org.lcsim.event.Track;
+import org.lcsim.event.TrackerHit;
+import org.lcsim.fit.helicaltrack.HelicalTrackHit;
+
+/**
+ *
+ * @author Richard Partridge
+ */
+public class TrackAnalysis {
+ private enum HelixPar {Curvature, Phi0, DCA, Z0, Slope};
+ private MCParticle _mcp;
+ private int _nhits;
+ private int _nbadhits;
+ private double _purity;
+
+ /** Creates a new instance of TrackAnalysis */
+ public TrackAnalysis(Track trk) {
+
+ // Get the number of hits on the track
+ _nhits = trk.getTrackerHits().size();
+
+ // Create a map containing the number of hits for each MCParticle associated with the track
+ Map<MCParticle,Integer> mcmap = new HashMap<MCParticle,Integer>();
+
+ // Loop over the hits on the track and make sure we have HelicalTrackHits (which contain the MC particle)
+ for (TrackerHit hit : trk.getTrackerHits()) {
+ if (!(hit instanceof HelicalTrackHit)) throw new RuntimeException("AnalysisUtils found track with non-HelicalTrackHits");
+
+ // Loop over the MCParticles for this hit and update their hit count
+ for (MCParticle mcp : ((HelicalTrackHit) hit).getMCParticles()) {
+ Integer mchits = 0;
+ if (mcmap.containsKey(mcp)) mchits = mcmap.get(mcp);
+ mcmap.put(mcp, mchits++);
+ }
+ }
+
+ // Find the MCParticle that has the most hits on the track
+
+ int nbest = 0;
+ for (MCParticle mcp : mcmap.keySet()) {
+ int count = mcmap.get(mcp);
+ if (count > nbest) {
+ nbest = count;
+ _mcp = mcp;
+ }
+ }
+
+ _purity = (double) nbest / (double) _nhits;
+ _nbadhits = _nhits - nbest;
+
+ }
+
+ public MCParticle getMCParticle() {
+ return _mcp;
+ }
+
+ public int getNHits() {
+ return _nhits;
+ }
+
+ public int getNBadHits() {
+ return _nbadhits;
+ }
+
+ public double getPurity() {
+ return _purity;
+ }
+
+// public double getHelixResidual(HelixPar par) {
+// if (par == HelixPar.Curvature) return
+// }
+}
lcsim/src/org/lcsim/contrib/Partridge/TrackingTest
diff -u -r1.6 -r1.7
--- AnalysisDriver.java 16 Oct 2008 22:15:56 -0000 1.6
+++ AnalysisDriver.java 18 Oct 2008 01:36:01 -0000 1.7
@@ -37,14 +37,21 @@
*/
public class AnalysisDriver extends Driver {
private AIDA aida = AIDA.defaultInstance();
- private IHistogram1D h1;
- private IHistogram1D h2;
+ private IHistogram1D pTeff1;
+ private IHistogram1D pTeff2;
+ private IHistogram1D thetaeff;
+ private IHistogram1D ctheff;
+ private IHistogram1D d0eff;
+ private IHistogram1D z0eff;
/** Creates a new instance of AnalysisDriver */
public AnalysisDriver() {
- h1 = aida.histogramFactory().createHistogram1D("pT Efficiency", "", 100, 0., 5., "type=efficiency");
- h2 = aida.histogramFactory().createHistogram1D("theta Efficiency", "", 360, 0., 180., "type=efficiency");
-
+ pTeff1 = aida.histogramFactory().createHistogram1D("Efficiency vs pT", "", 100, 0., 5., "type=efficiency");
+ pTeff2 = aida.histogramFactory().createHistogram1D("Efficiency vs pT full", "", 100, 0., 50., "type=efficiency");
+ thetaeff = aida.histogramFactory().createHistogram1D("Efficiency vs theta", "", 360, 0., 180., "type=efficiency");
+ ctheff = aida.histogramFactory().createHistogram1D("Efficiency vs cos(theta)", "", 200, -1., 1., "type=efficiency");
+ d0eff = aida.histogramFactory().createHistogram1D("Efficiency vs d0", "", 360, -20., 20., "type=efficiency");
+ z0eff = aida.histogramFactory().createHistogram1D("Efficiency vs z0", "", 360, -20., 20., "type=efficiency");
}
/**
@@ -70,17 +77,6 @@
// List<LCRelation> hitrelations = event.get(LCRelation.class, "HelicalTrackHitRelations");
for (Track track : tracklist) {
-// List<TrackerHit> hitlist = track.getTrackerHits();
-// for (TrackerHit hit : hitlist) {
-// for (LCRelation relate : hitrelations) {
-// if (relate.getFrom().equals(hit)) {
-// org.lcsim.contrib.onoprien.tracking.hit.TrackerHit hit2 =
-// (org.lcsim.contrib.onoprien.tracking.hit.TrackerHit) relate.getTo();
-// System.out.println(" Relation for hit type: "+hit.getType()+" x1: "
-// +hit.getPosition()[0]+" x2: "+hit2.getPosition().x());
-// }
-// }
-// }
Map<MCParticle, Integer> mcmap = new HashMap<MCParticle, Integer>();
if (track instanceof SeedTrack) {
SeedCandidate seed = ((SeedTrack) track).getSeedCandidate();
@@ -150,12 +146,12 @@
if (trkmap.containsKey(mcp)) wgt = 1.;
if (pt > 1.1) {
aida.profile1D("Efficiency vs theta", 90, 0., 180.).fill(theta, wgt);
- h2.fill(theta, wgt);
+// h2.fill(theta, wgt);
aida.histogram1D("MC angle", 90, 0., 180.).fill(theta);
}
if (Math.abs(cth) < 0.985) {
aida.profile1D("Efficiency vs pT", 100, 0., 50.).fill(pt, wgt);
- h1.fill(pt,wgt);
+// h1.fill(pt,wgt);
aida.histogram1D("MC pT", 100, 0., 50.).fill(pt);
}
if (!trkmap.containsKey(mcp)) {