LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  June 2015

HPS-SVN June 2015

Subject:

r3179 - /java/trunk/users/src/main/java/org/hps/users/omoreno/SvtClusterAnalysis.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Mon, 22 Jun 2015 20:27:24 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (520 lines)

Author: [log in to unmask]
Date: Mon Jun 22 13:27:11 2015
New Revision: 3179

Log:
Add plots of cluster charge vs momentum/cos(theta)/sin(phi0).

Modified:
    java/trunk/users/src/main/java/org/hps/users/omoreno/SvtClusterAnalysis.java

Modified: java/trunk/users/src/main/java/org/hps/users/omoreno/SvtClusterAnalysis.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/omoreno/SvtClusterAnalysis.java	(original)
+++ java/trunk/users/src/main/java/org/hps/users/omoreno/SvtClusterAnalysis.java	Mon Jun 22 13:27:11 2015
@@ -4,6 +4,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.HashMap;
+import java.util.Set;
 
 import hep.aida.IAnalysisFactory;
 import hep.aida.IHistogram2D;
@@ -15,17 +16,19 @@
 import hep.aida.ITree;
 import hep.aida.ref.rootwriter.RootFileStore;
 
-import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHitStrip1D;
 import org.lcsim.util.Driver; 
-import org.lcsim.fit.helicaltrack.HelicalTrackCross;
-import org.lcsim.fit.helicaltrack.HelicalTrackStrip;
 import org.lcsim.geometry.Detector;
 import org.lcsim.detector.tracker.silicon.HpsSiSensor;
 import org.lcsim.event.EventHeader;
+import org.lcsim.event.LCRelation;
 import org.lcsim.event.RawTrackerHit;
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.RelationalTable;
 import org.lcsim.event.Track;
 import org.lcsim.event.TrackerHit;
+import org.lcsim.event.base.BaseRelationalTable;
 import org.hps.recon.tracking.FittedRawTrackerHit;
+import org.hps.recon.tracking.TrackUtils;
 
 /**
  * 
@@ -41,8 +44,8 @@
     }
 
     private List<HpsSiSensor> sensors;
-    private Map<RawTrackerHit, FittedRawTrackerHit> fittedRawTrackerHitMap 
-        = new HashMap<RawTrackerHit, FittedRawTrackerHit>();
+    private Map<RawTrackerHit, LCRelation> fittedRawTrackerHitMap = new HashMap<RawTrackerHit, LCRelation>();
+    private Map<Track, ReconstructedParticle> reconParticleMap = new HashMap<Track, ReconstructedParticle>();
   
     // Plotting
     ITree tree; 
@@ -50,18 +53,24 @@
 	IPlotterFactory plotterFactory = IAnalysisFactory.create().createPlotterFactory();
 	protected Map<String, IPlotter> plotters = new HashMap<String, IPlotter>(); 
 	
-	private Map<HpsSiSensor, IHistogram1D> clusterChargePlots = new HashMap<HpsSiSensor, IHistogram1D>();
-	private Map<HpsSiSensor, IHistogram1D> singleHitClusterChargePlots = new HashMap<HpsSiSensor, IHistogram1D>();
-	private Map<HpsSiSensor, IHistogram1D> multHitClusterChargePlots = new HashMap<HpsSiSensor, IHistogram1D>();
-	private Map<HpsSiSensor, IHistogram1D> trackClusterChargePlots = new HashMap<HpsSiSensor, IHistogram1D>();
-	private Map<HpsSiSensor, IHistogram1D> signalToNoisePlots = new HashMap<HpsSiSensor, IHistogram1D>();
-	private Map<HpsSiSensor, IHistogram1D> singleHitSignalToNoisePlots = new HashMap<HpsSiSensor, IHistogram1D>();
-	private Map<HpsSiSensor, IHistogram1D> multHitSignalToNoisePlots = new HashMap<HpsSiSensor, IHistogram1D>();
-	private Map<HpsSiSensor, IHistogram1D> trackHitSignalToNoisePlots = new HashMap<HpsSiSensor, IHistogram1D>();
-	private Map<HpsSiSensor, IHistogram1D> clusterMultiplicityPlots = new HashMap<HpsSiSensor, IHistogram1D>();
-	private Map<HpsSiSensor, IHistogram1D> clusterTimePlots = new HashMap<HpsSiSensor, IHistogram1D>();
-	private Map<HpsSiSensor, IHistogram1D> trackClusterTimePlots = new HashMap<HpsSiSensor, IHistogram1D>();
-	private Map<HpsSiSensor, IHistogram2D> clusterChargeVsTimePlots = new HashMap<HpsSiSensor, IHistogram2D>();
+	// All clusters
+	private Map<String, IHistogram1D> clusterChargePlots = new HashMap<String, IHistogram1D>();
+	private Map<String, IHistogram1D> singleHitClusterChargePlots = new HashMap<String, IHistogram1D>();
+	private Map<String, IHistogram1D> multHitClusterChargePlots = new HashMap<String, IHistogram1D>();
+	private Map<String, IHistogram1D> signalToNoisePlots = new HashMap<String, IHistogram1D>();
+	private Map<String, IHistogram1D> singleHitSignalToNoisePlots = new HashMap<String, IHistogram1D>();
+	private Map<String, IHistogram1D> multHitSignalToNoisePlots = new HashMap<String, IHistogram1D>();
+	private Map<String, IHistogram1D> clusterSizePlots = new HashMap<String, IHistogram1D>();
+	private Map<String, IHistogram1D> clusterTimePlots = new HashMap<String, IHistogram1D>();
+	private Map<String, IHistogram2D> clusterChargeVsTimePlots = new HashMap<String, IHistogram2D>();
+
+	// Clusters on track
+	private Map<String, IHistogram1D> trackClusterChargePlots = new HashMap<String, IHistogram1D>();
+	private Map<String, IHistogram1D> trackHitSignalToNoisePlots = new HashMap<String, IHistogram1D>();
+	private Map<String, IHistogram1D> trackClusterTimePlots = new HashMap<String, IHistogram1D>();
+	private Map<String, IHistogram2D> trackClusterChargeVsMomentum = new HashMap<String, IHistogram2D>();
+	private Map<String, IHistogram2D> trackClusterChargeVsCosTheta = new HashMap<String, IHistogram2D>();
+	private Map<String, IHistogram2D> trackClusterChargeVsSinPhi = new HashMap<String, IHistogram2D>();
 	
     // Detector name
     private static final String SUBDETECTOR_NAME = "Tracker";
@@ -69,6 +78,9 @@
     // Collections
     private String clusterCollectionName = "StripClusterer_SiTrackerHitStrip1D";
     private String fittedHitsCollectionName = "SVTFittedRawTrackerHits";
+    private String stereoHitRelationsColName = "HelicalTrackHitRelations";
+    private String rotatedHthRelationsColName = "RotatedHelicalTrackHitRelations";
+    private String fsParticlesCollectionName = "FinalStateParticles";
     
     private int runNumber = -1; 
         
@@ -135,67 +147,106 @@
         plotters.put("Cluster Amplitude vs Cluster Time", plotterFactory.create("Cluster Amplitude vs Cluster Time"));
         plotters.get("Cluster Amplitude vs Cluster Time").createRegions(6, 6);
         
+        plotters.put("Cluster Amplitude vs Momentum", plotterFactory.create("Cluster Amplitude vs Momentum"));
+        plotters.get("Cluster Amplitude vs Momentum").createRegions(6, 6);
+        
+        plotters.put("Cluster Amplitude vs cos(theta)", plotterFactory.create("Cluster Amplitude vs cos(theta)"));
+        plotters.get("Cluster Amplitude vs cos(theta)").createRegions(6, 6);
+        
+        plotters.put("Cluster Amplitude vs sin(phi0)", plotterFactory.create("Cluster Amplitude vs sin(phi0)"));
+        plotters.get("Cluster Amplitude vs sin(phi0)").createRegions(6, 6);
+
         for (HpsSiSensor sensor : sensors) { 
             
-            clusterChargePlots.put(sensor, 
+            clusterChargePlots.put(sensor.getName(), 
                     histogramFactory.createHistogram1D(sensor.getName() + " - Cluster Charge", 100, 0, 5000));
             plotters.get("Cluster Amplitude").region(this.computePlotterRegion(sensor))
-                                             .plot(clusterChargePlots.get(sensor), this.createStyle(1, "Cluster Amplitude [ADC Counts]", ""));
-       
-            singleHitClusterChargePlots.put(sensor, 
+                                             .plot(clusterChargePlots
+                                             .get(sensor.getName()), this.createStyle(1, "Cluster Amplitude [ADC Counts]", ""));
+       
+            singleHitClusterChargePlots.put(sensor.getName(), 
                     histogramFactory.createHistogram1D(sensor.getName() + " - Single Hit Cluster Charge", 100, 0, 5000));
             plotters.get("Cluster Amplitude").region(this.computePlotterRegion(sensor))
-                                             .plot(singleHitClusterChargePlots.get(sensor), this.createStyle(2, "Cluster Amplitude [ADC Counts]", ""));
-
-            multHitClusterChargePlots.put(sensor, 
+                                             .plot(singleHitClusterChargePlots
+                                             .get(sensor.getName()), this.createStyle(2, "Cluster Amplitude [ADC Counts]", ""));
+
+            multHitClusterChargePlots.put(sensor.getName(), 
                     histogramFactory.createHistogram1D(sensor.getName() + " - Multiple Hit Cluster Charge", 100, 0, 5000));
             plotters.get("Cluster Amplitude").region(this.computePlotterRegion(sensor))
-                                             .plot(multHitClusterChargePlots.get(sensor), this.createStyle(2, "Cluster Amplitude [ADC Counts]", ""));
-
-            trackClusterChargePlots.put(sensor, 
+                                             .plot(multHitClusterChargePlots
+                                             .get(sensor.getName()), this.createStyle(2, "Cluster Amplitude [ADC Counts]", ""));
+
+            signalToNoisePlots.put(sensor.getName(), 
+                    histogramFactory.createHistogram1D(sensor.getName() + " - Signal to Noise", 50, 0, 50));
+            plotters.get("Signal to Noise").region(this.computePlotterRegion(sensor))
+                                           .plot(signalToNoisePlots
+                                           .get(sensor.getName()), this.createStyle(1, "Signal to Noise", ""));
+
+            singleHitSignalToNoisePlots.put(sensor.getName(), 
+                    histogramFactory.createHistogram1D(sensor.getName() + " - Single Hit Signal to Noise", 50, 0, 50));
+            plotters.get("Signal to Noise").region(this.computePlotterRegion(sensor))
+                                           .plot(singleHitSignalToNoisePlots
+                                           .get(sensor.getName()), this.createStyle(2, "Signal to Noise", ""));
+        
+            multHitSignalToNoisePlots.put(sensor.getName(), 
+                    histogramFactory.createHistogram1D(sensor.getName() + " - Multiple Hit Signal to Noise", 50, 0, 50));
+            plotters.get("Signal to Noise").region(this.computePlotterRegion(sensor))
+                                           .plot(multHitSignalToNoisePlots
+                                           .get(sensor.getName()), this.createStyle(2, "Signal to Noise", ""));
+
+            clusterSizePlots.put(sensor.getName(),
+                    histogramFactory.createHistogram1D(sensor.getName() + " - Cluster Multiplicity", 10, 0, 10));
+            plotters.get("Cluster Multiplicity").region(this.computePlotterRegion(sensor))
+                                                .plot(clusterSizePlots
+                                                .get(sensor.getName()), this.createStyle(1, "Cluster Multiplicity", ""));
+            
+            clusterTimePlots.put(sensor.getName(),
+                    histogramFactory.createHistogram1D(sensor.getName() + " - Cluster Time", 100, -100, 100));
+            plotters.get("Cluster Time").region(this.computePlotterRegion(sensor))
+                                        .plot(clusterTimePlots
+                                        .get(sensor.getName()), this.createStyle(1, "Cluster Time [ns]", ""));
+
+            trackClusterTimePlots.put(sensor.getName(),
+                    histogramFactory.createHistogram1D(sensor.getName() + " - Track Cluster Time", 100, -100, 100));
+            plotters.get("Cluster Time").region(this.computePlotterRegion(sensor))
+                                        .plot(trackClusterTimePlots
+                                        .get(sensor.getName()), this.createStyle(3, "Cluster Time [ns]", ""));
+            
+            clusterChargeVsTimePlots.put(sensor.getName(),
+                    histogramFactory.createHistogram2D(sensor.getName() + " - Cluster Amplitude vs Time", 100, 0, 5000, 100, -100, 100));
+            plotters.get("Cluster Amplitude vs Cluster Time").region(this.computePlotterRegion(sensor))
+                                                             .plot(clusterChargeVsTimePlots
+                                                             .get(sensor.getName()));
+        
+            trackClusterChargePlots.put(sensor.getName(), 
                     histogramFactory.createHistogram1D(sensor.getName() + " - Tracker Cluster Charge", 100, 0, 5000));
             plotters.get("Cluster Amplitude").region(this.computePlotterRegion(sensor))
-                                             .plot(trackClusterChargePlots.get(sensor), this.createStyle(3, "Cluster Amplitude [ADC Counts]", ""));
-            
-            signalToNoisePlots.put(sensor, 
-                    histogramFactory.createHistogram1D(sensor.getName() + " - Signal to Noise", 50, 0, 50));
-            plotters.get("Signal to Noise").region(this.computePlotterRegion(sensor))
-                                           .plot(signalToNoisePlots.get(sensor), this.createStyle(1, "Signal to Noise", ""));
-
-            singleHitSignalToNoisePlots.put(sensor, 
-                    histogramFactory.createHistogram1D(sensor.getName() + " - Single Hit Signal to Noise", 50, 0, 50));
-            plotters.get("Signal to Noise").region(this.computePlotterRegion(sensor))
-                                           .plot(singleHitSignalToNoisePlots.get(sensor), this.createStyle(2, "Signal to Noise", ""));
-        
-            multHitSignalToNoisePlots.put(sensor, 
-                    histogramFactory.createHistogram1D(sensor.getName() + " - Multiple Hit Signal to Noise", 50, 0, 50));
-            plotters.get("Signal to Noise").region(this.computePlotterRegion(sensor))
-                                           .plot(multHitSignalToNoisePlots.get(sensor), this.createStyle(2, "Signal to Noise", ""));
-
-            trackHitSignalToNoisePlots.put(sensor, 
+                                             .plot(trackClusterChargePlots
+                                             .get(sensor.getName()), this.createStyle(3, "Cluster Amplitude [ADC Counts]", ""));
+        
+            trackHitSignalToNoisePlots.put(sensor.getName(), 
                     histogramFactory.createHistogram1D(sensor.getName() + " - Track Signal to Noise", 50, 0, 50));
             plotters.get("Signal to Noise").region(this.computePlotterRegion(sensor))
-                                           .plot(trackHitSignalToNoisePlots.get(sensor), this.createStyle(3, "Signal to Noise", ""));
-            
-            clusterMultiplicityPlots.put(sensor,
-                    histogramFactory.createHistogram1D(sensor.getName() + " - Cluster Multiplicity", 10, 0, 10));
-            plotters.get("Cluster Multiplicity").region(this.computePlotterRegion(sensor))
-                                                .plot(clusterMultiplicityPlots.get(sensor), this.createStyle(1, "Cluster Multiplicity", ""));
-            
-            clusterTimePlots.put(sensor,
-                    histogramFactory.createHistogram1D(sensor.getName() + " - Cluster Time", 100, -100, 100));
-            plotters.get("Cluster Time").region(this.computePlotterRegion(sensor))
-                                        .plot(clusterTimePlots.get(sensor), this.createStyle(1, "Cluster Time [ns]", ""));
-
-            trackClusterTimePlots.put(sensor,
-                    histogramFactory.createHistogram1D(sensor.getName() + " - Track Cluster Time", 100, -100, 100));
-            plotters.get("Cluster Time").region(this.computePlotterRegion(sensor))
-                                        .plot(trackClusterTimePlots.get(sensor), this.createStyle(3, "Cluster Time [ns]", ""));
-            
-            clusterChargeVsTimePlots.put(sensor,
-                    histogramFactory.createHistogram2D(sensor.getName() + " - Cluster Amplitude vs Time", 100, 0, 5000, 100, -100, 100));
-            plotters.get("Cluster Amplitude vs Cluster Time").region(this.computePlotterRegion(sensor))
-                                                             .plot(clusterChargeVsTimePlots.get(sensor));
+                                           .plot(trackHitSignalToNoisePlots
+                                           .get(sensor.getName()), this.createStyle(3, "Signal to Noise", ""));
+        
+            trackClusterChargeVsMomentum.put(sensor.getName(),
+                    histogramFactory.createHistogram2D(sensor.getName() + " - Cluster Amplitude vs Momentum", 100, 0, 1.5, 100, 0, 5000));
+            plotters.get("Cluster Amplitude vs Momentum").region(this.computePlotterRegion(sensor))
+                                                         .plot(trackClusterChargeVsMomentum
+                                                         .get(sensor.getName()));
+        
+            trackClusterChargeVsCosTheta.put(sensor.getName(),
+                    histogramFactory.createHistogram2D(sensor.getName() + " - Cluster Amplitude vs cos(theta)", 100, -0.1, 0.1, 100, 0, 5000));
+            plotters.get("Cluster Amplitude vs cos(theta)").region(this.computePlotterRegion(sensor))
+                                                         .plot(trackClusterChargeVsCosTheta
+                                                         .get(sensor.getName()));
+
+            trackClusterChargeVsSinPhi.put(sensor.getName(),
+                    histogramFactory.createHistogram2D(sensor.getName() + " - Cluster Amplitude vs sin(phi0)", 100, -0.2, 0.2, 100, 0, 5000));
+            plotters.get("Cluster Amplitude vs sin(phi0)").region(this.computePlotterRegion(sensor))
+                                                          .plot(trackClusterChargeVsSinPhi
+                                                          .get(sensor.getName()));
         }
         
 		for (IPlotter plotter : plotters.values()) { 
@@ -203,41 +254,45 @@
 		}
     }
 
+	@SuppressWarnings({ "unchecked", "rawtypes" })
     public void process(EventHeader event) { 
      
         if (runNumber == -1) runNumber = event.getRunNumber();
         
         // If the event doesn't contain fitted raw hits, skip it
-        if (!event.hasCollection(FittedRawTrackerHit.class, fittedHitsCollectionName)) return;
+        if (!event.hasCollection(LCRelation.class, fittedHitsCollectionName)) return;
         
         // Get the list of fitted hits from the event
-        List<FittedRawTrackerHit> fittedHits = event.get(FittedRawTrackerHit.class, fittedHitsCollectionName);
+        List<LCRelation> fittedHits = event.get(LCRelation.class, fittedHitsCollectionName);
         
         // Map the fitted hits to their corresponding raw hits
         this.mapFittedRawHits(fittedHits);
         
         // If the event doesn't contain any clusters, skip it
-        if (!event.hasCollection(SiTrackerHitStrip1D.class, clusterCollectionName)) return;
+        if (!event.hasCollection(TrackerHit.class, clusterCollectionName)) return;
         
         // Get the list of clusters in the event
-        List<SiTrackerHitStrip1D> clusters = event.get(SiTrackerHitStrip1D.class, clusterCollectionName);
+        List<TrackerHit> clusters = event.get(TrackerHit.class, clusterCollectionName);
         System.out.println("Number of clusters: " + clusters.size()); 
        
-        for (SiTrackerHitStrip1D cluster : clusters) { 
+        for (TrackerHit cluster : clusters) { 
            
             // Get the sensor associated with this cluster
-            HpsSiSensor sensor = (HpsSiSensor) cluster.getSensor();
+            HpsSiSensor sensor = (HpsSiSensor) ((RawTrackerHit) cluster.getRawHits().get(0)).getDetectorElement();
             
             // Get the raw hits composing this cluster and use them to calculate the amplitude of the hit
-            double amplitude = 0;
+            double amplitudeSum = 0;
             double noise = 0;
-            for (RawTrackerHit rawHit : cluster.getRawHits()) {
+            for (Object rawHitObject : cluster.getRawHits()) {
+
+                RawTrackerHit rawHit = (RawTrackerHit) rawHitObject; 
                 
                 // Get the channel of the raw hit
                 int channel = rawHit.getIdentifierFieldValue("strip");
                 
                 // Add the amplitude of that channel to the total amplitude
-                amplitude += this.getFittedHit(rawHit).getAmp();
+                double amplitude = FittedRawTrackerHit.getAmp(this.getFittedHit(rawHit));
+                amplitudeSum += FittedRawTrackerHit.getAmp(this.getFittedHit(rawHit));
                 
                 // Calculate the mean noise for the channel
                 double channelNoise = 0;
@@ -246,53 +301,88 @@
                 }
                 channelNoise = channelNoise/6;
                 
-                noise += channelNoise * this.getFittedHit(rawHit).getAmp();
+                noise += channelNoise * amplitude;
             }
       
-            clusterMultiplicityPlots.get(sensor).fill(cluster.getRawHits().size());
+            clusterSizePlots.get(sensor.getName()).fill(cluster.getRawHits().size());
             
             // Calculate the signal weighted noise
-            noise = noise/amplitude;
+            noise = noise/amplitudeSum;
             
             // Fill all plots
-            clusterChargePlots.get(sensor).fill(amplitude);
-            signalToNoisePlots.get(sensor).fill(amplitude/noise);
-            clusterTimePlots.get(sensor).fill(cluster.getTime());
-            clusterChargeVsTimePlots.get(sensor).fill(amplitude, cluster.getTime());
+            clusterChargePlots.get(sensor.getName()).fill(amplitudeSum);
+            signalToNoisePlots.get(sensor.getName()).fill(amplitudeSum/noise);
+            clusterTimePlots.get(sensor.getName()).fill(cluster.getTime());
+            clusterChargeVsTimePlots.get(sensor.getName()).fill(amplitudeSum, cluster.getTime());
             
             if (cluster.getRawHits().size() == 1) { 
-                singleHitClusterChargePlots.get(sensor).fill(amplitude);
-                singleHitSignalToNoisePlots.get(sensor).fill(amplitude/noise);
+                singleHitClusterChargePlots.get(sensor.getName()).fill(amplitudeSum);
+                singleHitSignalToNoisePlots.get(sensor.getName()).fill(amplitudeSum/noise);
             } else { 
-                multHitClusterChargePlots.get(sensor).fill(amplitude);
-                multHitSignalToNoisePlots.get(sensor).fill(amplitude/noise);
+                multHitClusterChargePlots.get(sensor.getName()).fill(amplitudeSum);
+                multHitSignalToNoisePlots.get(sensor.getName()).fill(amplitudeSum/noise);
             }
         }
-        
+       
         if (!event.hasCollection(Track.class, "MatchedTracks")) return;
         
         List<Track> tracks = event.get(Track.class, "MatchedTracks");
         
-        for (Track track : tracks) { 
-            
-            for (TrackerHit stereoHit : track.getTrackerHits()) { 
-               
-                for (HelicalTrackStrip cluster : ((HelicalTrackCross) stereoHit).getStrips()) {
-                    
+        // Get the collection of LCRelations between a stereo hit and the strips making it up
+        List<LCRelation> stereoHitRelations = event.get(LCRelation.class, stereoHitRelationsColName);
+        BaseRelationalTable stereoHitToClusters = new BaseRelationalTable(RelationalTable.Mode.MANY_TO_MANY, RelationalTable.Weighting.UNWEIGHTED);
+        for (LCRelation relation : stereoHitRelations) { 
+            if (relation != null && relation.getFrom() != null && relation.getTo() != null) {
+                stereoHitToClusters.add(relation.getFrom(), relation.getTo());
+            }
+        }
+        
+        // Get the collection of LCRelations relating RotatedHelicalTrackHits to
+        // HelicalTrackHits
+        List<LCRelation> rotatedHthToHthRelations = event.get(LCRelation.class, rotatedHthRelationsColName);
+        BaseRelationalTable hthToRotatedHth = new BaseRelationalTable(RelationalTable.Mode.ONE_TO_ONE, RelationalTable.Weighting.UNWEIGHTED);
+        for (LCRelation relation : rotatedHthToHthRelations) {
+            if (relation != null && relation.getFrom() != null && relation.getTo() != null) {
+                hthToRotatedHth.add(relation.getFrom(), relation.getTo());
+            }
+        }
+        
+        // Get the list of final state particles from the event.  These will
+        // be used to obtain the track momentum.
+        List<ReconstructedParticle> fsParticles = event.get(ReconstructedParticle.class, fsParticlesCollectionName);
+      
+        this.mapReconstructedParticlesToTracks(tracks, fsParticles);
+       
+        // Loop over all of the tracks in the event
+    	for(Track track : tracks){
+
+            // Calculate the momentum of the track
+            double p = this.getReconstructedParticle(track).getMomentum().magnitude();
+    	    
+    	    for (TrackerHit rotatedStereoHit : track.getTrackerHits()) { 
+    	    
+    	        // Get the HelicalTrackHit corresponding to the RotatedHelicalTrackHit
+    	        // associated with a track
+                Set<TrackerHit> trackClusters = stereoHitToClusters.allFrom(hthToRotatedHth.from(rotatedStereoHit));
+    	        
+    	        for (TrackerHit trackCluster : trackClusters) { 
+                
                     // Get the raw hits composing this cluster and use them to calculate the amplitude of the hit
-                    double amplitude = 0;
+                    double amplitudeSum = 0;
                     double noise = 0;
                     HpsSiSensor sensor = null;
-                    for (Object hit : cluster.rawhits()) { 
-                        RawTrackerHit rawHit = (RawTrackerHit) hit;
-                   
+
+                    for (Object rawHitObject : trackCluster.getRawHits()) {
+                        RawTrackerHit rawHit = (RawTrackerHit) rawHitObject; 
+                        
                         sensor = (HpsSiSensor) rawHit.getDetectorElement();
-                        
+                       
                         // Get the channel of the raw hit
                         int channel = rawHit.getIdentifierFieldValue("strip");
                 
                         // Add the amplitude of that channel to the total amplitude
-                        amplitude += this.getFittedHit(rawHit).getAmp();
+                        double amplitude = FittedRawTrackerHit.getAmp(this.getFittedHit(rawHit));
+                        amplitudeSum += FittedRawTrackerHit.getAmp(this.getFittedHit(rawHit));
                 
                         // Calculate the mean noise for the channel
                         double channelNoise = 0;
@@ -301,19 +391,23 @@
                         }
                         channelNoise = channelNoise/6;
                 
-                        noise += channelNoise * this.getFittedHit(rawHit).getAmp();
+                        noise += channelNoise * amplitude;
+                        
                     }
-                    
+
                     // Calculate the signal weighted noise
-                    noise = noise/amplitude;
+                    noise = noise/amplitudeSum;
                    
                     // Fill all plots
-                    trackClusterChargePlots.get(sensor).fill(amplitude);
-                    trackHitSignalToNoisePlots.get(sensor).fill(amplitude/noise);
-                    trackClusterTimePlots.get(sensor).fill(cluster.time());
-                }
-            }
-        }
+                    trackClusterChargePlots.get(sensor.getName()).fill(amplitudeSum);
+                    trackHitSignalToNoisePlots.get(sensor.getName()).fill(amplitudeSum/noise);
+                    trackClusterChargeVsMomentum.get(sensor.getName()).fill(p, amplitudeSum);
+                    trackClusterChargeVsCosTheta.get(sensor.getName()).fill(TrackUtils.getCosTheta(track), amplitudeSum);
+                    trackClusterChargeVsSinPhi.get(sensor.getName()).fill(Math.sin(TrackUtils.getPhi0(track)), amplitudeSum);
+                    //trackClusterTimePlots.get(sensor.getName()).fill(trackCluster.time());
+    	        }
+    	    }
+    	}
     }
     
     public void endOfData() { 
@@ -327,6 +421,8 @@
         } catch (IOException e) {
             e.printStackTrace();
         }
+    
+    
     }
     
     /**
@@ -334,26 +430,42 @@
      *  
      * @param fittedHits : List of fitted hits to map
      */
-    private void mapFittedRawHits(List<FittedRawTrackerHit> fittedHits) { 
+    private void mapFittedRawHits(List<LCRelation> fittedHits) { 
         
         // Clear the fitted raw hit map of old values
         fittedRawTrackerHitMap.clear();
        
         // Loop through all fitted hits and map them to their corresponding raw hits
-        for (FittedRawTrackerHit fittedHit : fittedHits) { 
-            fittedRawTrackerHitMap.put(fittedHit.getRawTrackerHit(), fittedHit);
-        }
-    }
-  
+        for (LCRelation fittedHit : fittedHits) { 
+            fittedRawTrackerHitMap.put(FittedRawTrackerHit.getRawTrackerHit(fittedHit), fittedHit);
+        }
+    }
+    
     /**
      * 
      * @param rawHit
      * @return
      */
-    private FittedRawTrackerHit getFittedHit(RawTrackerHit rawHit) { 
+    private LCRelation getFittedHit(RawTrackerHit rawHit) { 
         return fittedRawTrackerHitMap.get(rawHit);
     }
     
+    private void mapReconstructedParticlesToTracks(List<Track> tracks, List<ReconstructedParticle> particles) {
+        
+       reconParticleMap.clear();
+       for (ReconstructedParticle particle : particles) {
+           for (Track track : tracks) {
+               if (!particle.getTracks().isEmpty() && particle.getTracks().get(0) == track) {
+                   reconParticleMap.put(track, particle);
+               }
+           }
+       }
+    }
+    
+    private ReconstructedParticle getReconstructedParticle(Track track) {
+        return reconParticleMap.get(track);
+    }
+   
     IPlotterStyle createStyle(int color, String xAxisTitle, String yAxisTitle) { 
        
         // Create a default style

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use