Print

Print


Commit in lcsim/src/org/lcsim/contrib/Partridge/TrackingTest on MAIN
ResolutionAnalysis.java+65added 1.1
ReconTest.java+11.1 -> 1.2
TrackAnalysis.java+13-121.1 -> 1.2
+79-12
1 added + 2 modified, total 3 files
Save momentum resolution code

lcsim/src/org/lcsim/contrib/Partridge/TrackingTest
ResolutionAnalysis.java added at 1.1
diff -N ResolutionAnalysis.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ResolutionAnalysis.java	8 Nov 2008 02:33:40 -0000	1.1
@@ -0,0 +1,65 @@
+/*
+ * ResolutionAnalysis.java
+ *
+ * Created on November 7, 2008, 5:37 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package org.lcsim.contrib.Partridge.TrackingTest;
+
+import hep.physics.vec.BasicHep3Vector;
+import java.util.List;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.LCRelation;
+import org.lcsim.event.MCParticle;
+import org.lcsim.event.RelationalTable;
+import org.lcsim.event.Track;
+import org.lcsim.event.base.BaseRelationalTable;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+/**
+ *
+ * @author richp
+ */
+public class ResolutionAnalysis extends Driver {
+    private AIDA aida = AIDA.defaultInstance();
+    
+    /** Creates a new instance of ResolutionAnalysis */
+    public ResolutionAnalysis() {
+    }
+    
+    public void process(EventHeader event) {
+        
+        //  Create a relational table that maps TrackerHits to MCParticles
+        RelationalTable hittomc = new BaseRelationalTable(RelationalTable.Mode.MANY_TO_MANY, RelationalTable.Weighting.UNWEIGHTED);
+        List<LCRelation> mcrelations = event.get(LCRelation.class, "HelicalTrackMCRelations");
+        for (LCRelation relation : mcrelations) {
+            hittomc.add(relation.getFrom(), relation.getTo());
+        }
+        
+        List<Track> tracklist = event.getTracks();
+        if (tracklist.size() > 1) System.out.println("Found "+tracklist.size()+" Tracks!");
+        for (Track track : tracklist) {
+            TrackAnalysis tkanal = new TrackAnalysis(track, hittomc);
+            MCParticle mcp = tkanal.getMCParticle();
+            if (mcp != null) {
+                double ptrk = (new BasicHep3Vector(track.getMomentum())).magnitude();
+                double pmc = mcp.getMomentum().magnitude();
+                double pdif = ptrk - pmc;
+                if (mcp.getCharge() > 0.) {
+                    aida.cloud1D("Momentum error for positive tracks").fill(pdif);
+                } else {
+                    aida.cloud1D("Momentum error for negative tracks").fill(pdif);
+                }
+                aida.cloud1D("Momentum error for all tracks").fill(pdif);
+                aida.cloud1D("Track momentum for all tracks").fill(ptrk);
+                aida.cloud1D("MC momentum for all tracks").fill(pmc);
+                aida.cloud1D("Momentum resolution for all tracks").fill(pdif/pmc);
+            }
+            
+        }
+    }
+}
\ No newline at end of file

lcsim/src/org/lcsim/contrib/Partridge/TrackingTest
ReconTest.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- ReconTest.java	16 Oct 2008 21:45:53 -0000	1.1
+++ ReconTest.java	8 Nov 2008 02:33:40 -0000	1.2
@@ -21,6 +21,7 @@
     /** Creates a new instance of ReconTest */
     public ReconTest() {
         add(new SiD02ReconTrackingDriver());
+        add(new ResolutionAnalysis());
     }
     
 }

lcsim/src/org/lcsim/contrib/Partridge/TrackingTest
TrackAnalysis.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- TrackAnalysis.java	18 Oct 2008 01:36:01 -0000	1.1
+++ TrackAnalysis.java	8 Nov 2008 02:33:40 -0000	1.2
@@ -9,11 +9,12 @@
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 
 import org.lcsim.event.MCParticle;
+import org.lcsim.event.RelationalTable;
 import org.lcsim.event.Track;
 import org.lcsim.event.TrackerHit;
-import org.lcsim.fit.helicaltrack.HelicalTrackHit;
 
 /**
  *
@@ -21,13 +22,13 @@
  */
 public class TrackAnalysis {
     private enum HelixPar {Curvature, Phi0, DCA, Z0, Slope};
-    private MCParticle _mcp;
+    private MCParticle _mcp = null;
     private int _nhits;
     private int _nbadhits;
     private double _purity;
     
     /** Creates a new instance of TrackAnalysis */
-    public TrackAnalysis(Track trk) {
+    public TrackAnalysis(Track trk, RelationalTable hittomc) {
         
         //  Get the number of hits on the track
         _nhits = trk.getTrackerHits().size();
@@ -37,27 +38,30 @@
         
         //  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()) {
+    
+            //  get the set of MCParticles associated with this hit and update the hit count for each MCParticle
+            Set<MCParticle> mclist = hittomc.allFrom(hit);
+            for (MCParticle mcp : mclist) {
                 Integer mchits = 0;
                 if (mcmap.containsKey(mcp)) mchits = mcmap.get(mcp);
-                mcmap.put(mcp,  mchits++);
+                mchits++;
+                mcmap.put(mcp,  mchits);
             }
         }
         
         //  Find the MCParticle that has the most hits on the track
         
         int nbest = 0;
+        MCParticle mcbest = null;
         for (MCParticle mcp : mcmap.keySet()) {
             int count = mcmap.get(mcp);
             if (count > nbest) {
                 nbest = count;
-                _mcp = mcp;
+                mcbest = mcp;
             }
         }
         
+        if (nbest > 1) _mcp = mcbest;
         _purity = (double) nbest / (double) _nhits;
         _nbadhits = _nhits - nbest;
         
@@ -79,7 +83,4 @@
         return _purity;
     }
     
-//    public double getHelixResidual(HelixPar par) {
-//        if (par == HelixPar.Curvature) return 
-//    }
 }
CVSspam 0.2.8