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  May 2015

HPS-SVN May 2015

Subject:

r2878 - /java/trunk/users/src/main/java/org/hps/users/phansson/TrackingReconstructionPlots.java

From:

[log in to unmask]

Reply-To:

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

Date:

Sat, 2 May 2015 00:15:41 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (1195 lines)

Author: [log in to unmask]
Date: Fri May  1 17:15:34 2015
New Revision: 2878

Log:
new plots

Modified:
    java/trunk/users/src/main/java/org/hps/users/phansson/TrackingReconstructionPlots.java

Modified: java/trunk/users/src/main/java/org/hps/users/phansson/TrackingReconstructionPlots.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/phansson/TrackingReconstructionPlots.java	(original)
+++ java/trunk/users/src/main/java/org/hps/users/phansson/TrackingReconstructionPlots.java	Fri May  1 17:15:34 2015
@@ -8,14 +8,20 @@
 import hep.aida.IProfile;
 import hep.physics.matrix.SymmetricMatrix;
 import hep.physics.vec.Hep3Vector;
+
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+
+import org.apache.commons.lang3.tuple.Pair;
+import org.hps.readout.ecal.FADCEcalReadoutDriver.PulseShape;
 import org.hps.recon.tracking.BeamlineConstants;
 import org.hps.recon.tracking.DumbShaperFit;
+import org.hps.recon.tracking.FittedRawTrackerHit;
 import org.hps.recon.tracking.HelixConverter;
-import org.hps.recon.tracking.PulseShape;
 import org.hps.recon.tracking.ShapeFitParameters;
 import org.hps.recon.tracking.ShaperFitAlgorithm;
 import org.hps.recon.tracking.StraightLineTrack;
@@ -25,6 +31,7 @@
 import org.lcsim.event.Cluster;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.LCIOParameters.ParameterName;
+import org.lcsim.event.LCRelation;
 import org.lcsim.event.RawTrackerHit;
 import org.lcsim.event.Track;
 import org.lcsim.event.TrackerHit;
@@ -44,13 +51,10 @@
 
 /**
  *
- * @author mgraham
+ * @author phansson
  */
 public class TrackingReconstructionPlots extends Driver {
 
-    //private AIDAFrame plotterFrame;
-    //private AIDAFrame topFrame;
-    //private AIDAFrame bottomFrame;
     private AIDA aida = AIDA.defaultInstance();
     private String rawTrackerHitCollectionName = "SVTRawTrackerHits";
     private String fittedTrackerHitCollectionName = "SVTFittedRawTrackerHits";
@@ -62,15 +66,16 @@
     private String trackerName = "Tracker";
     String ecalSubdetectorName = "Ecal";
     String ecalCollectionName = "EcalClusters";
-    private Detector detector = null;
     IDDecoder dec;
-    private int eventCount;
-    private List<SiSensor> sensors;
     private String outputPlots = null;
     IPlotter plotter;
     IPlotter plotter2;
     IPlotter plotter22;
+    IPlotter plotter2221;
+    IPlotter plotter2222;
     IPlotter plotter222;
+    IPlotter plotter2224;
+    IPlotter plotter2223;
     IPlotter plotter3;
     IPlotter plotter3_1;
     IPlotter plotter3_2;
@@ -79,34 +84,27 @@
     IPlotter plotter5_1;
     IPlotter plotter55;
     IPlotter plotter6;
+    IPlotter plotter66;
     IPlotter plotter7;
     IPlotter top1;
     IPlotter top2;
     IPlotter top3;
     IPlotter top4;
+    IPlotter top44;
     IPlotter bot1;
     IPlotter bot2;
     IPlotter bot3;
     IPlotter bot4;
-    double zEcal = 1500;
-    double zAtDownStrPairSpec = 914.0; //mm
     double zAtColl = -1500;
     IHistogram1D trkPx;
     IHistogram1D nTracks;
     ShaperFitAlgorithm _shaper = new DumbShaperFit();
+    private boolean showPlots = true;
 
     @Override
     protected void detectorChanged(Detector detector) {
-        this.detector = detector;
         aida.tree().cd("/");
-        //plotterFrame = new AIDAFrame();
-        //plotterFrame.setTitle("HPS Tracking Plots");
-
-        //topFrame = new AIDAFrame();
-        //topFrame.setTitle("Top Tracking Plots");
-        //bottomFrame = new AIDAFrame();
-        //bottomFrame.setTitle("Bottom Tracking Plots");
-        sensors = detector.getSubdetector(trackerName).getDetectorElement().findDescendants(SiSensor.class);
+        //sensors = detector.getSubdetector(trackerName).getDetectorElement().findDescendants(SiSensor.class);
 
         IAnalysisFactory fac = aida.analysisFactory();
         plotter = fac.createPlotterFactory().create("HPS Tracking Plots");
@@ -119,7 +117,7 @@
 
         trkPx = aida.histogram1D("Track Momentum (Px)", 25, -0.25, 0.25);
         IHistogram1D trkPy = aida.histogram1D("Track Momentum (Py)", 25, -0.5, 0.5);
-        IHistogram1D trkPz = aida.histogram1D("Track Momentum (Pz)", 25, 0, 3.5);
+        IHistogram1D trkPz = aida.histogram1D("Track Momentum (Pz)", 25, 0, 1.5);
         IHistogram1D trkChi2 = aida.histogram1D("Track Chi2", 25, 0, 25.0);
 
         plotter.region(0).plot(trkPx);
@@ -127,7 +125,7 @@
         plotter.region(2).plot(trkPz);
         plotter.region(3).plot(trkChi2);
 
-        plotter.show();
+        if(showPlots) plotter.show();
 
 //   ******************************************************************
         top1 = fac.createPlotterFactory().create("Top Tracking Plots");
@@ -140,7 +138,7 @@
 
         IHistogram1D toptrkPx = aida.histogram1D("Top Track Momentum (Px)", 25, -0.25, 0.25);
         IHistogram1D toptrkPy = aida.histogram1D("Top Track Momentum (Py)", 25, -0.5, 0.5);
-        IHistogram1D toptrkPz = aida.histogram1D("Top Track Momentum (Pz)", 25, 0, 3.5);
+        IHistogram1D toptrkPz = aida.histogram1D("Top Track Momentum (Pz)", 25, 0, 1.5);
         IHistogram1D toptrkChi2 = aida.histogram1D("Top Track Chi2", 25, 0, 25.0);
 
         top1.region(0).plot(toptrkPx);
@@ -148,7 +146,7 @@
         top1.region(2).plot(toptrkPz);
         top1.region(3).plot(toptrkChi2);
 
-        top1.show();
+        if(showPlots) top1.show();
 
         bot1 = fac.createPlotterFactory().create("Bottom Tracking Plots");
         bot1.setTitle("Bottom Momentum");
@@ -160,7 +158,7 @@
 
         IHistogram1D bottrkPx = aida.histogram1D("Bottom Track Momentum (Px)", 25, -0.25, 0.25);
         IHistogram1D bottrkPy = aida.histogram1D("Bottom Track Momentum (Py)", 25, -0.5, 0.5);
-        IHistogram1D bottrkPz = aida.histogram1D("Bottom Track Momentum (Pz)", 25, 0, 3.5);
+        IHistogram1D bottrkPz = aida.histogram1D("Bottom Track Momentum (Pz)", 25, 0, 1.5);
         IHistogram1D bottrkChi2 = aida.histogram1D("Bottom Track Chi2", 25, 0, 25.0);
 
         bot1.region(0).plot(bottrkPx);
@@ -168,14 +166,14 @@
         bot1.region(2).plot(bottrkPz);
         bot1.region(3).plot(bottrkChi2);
 
-        bot1.show();
+        if(showPlots) bot1.show();
 
 //   ******************************************************************
-        IHistogram1D trkd0 = aida.histogram1D("d0 ", 25, -100.0, 100.0);
+        IHistogram1D trkd0 = aida.histogram1D("d0 ", 25, -10.0, 10.0);
         IHistogram1D trkphi = aida.histogram1D("sinphi ", 25, -0.2, 0.2);
         IHistogram1D trkomega = aida.histogram1D("omega ", 25, -0.0025, 0.0025);
         IHistogram1D trklam = aida.histogram1D("tan(lambda) ", 25, -0.1, 0.1);
-        IHistogram1D trkz0 = aida.histogram1D("z0 ", 25, -100.0, 100.0);
+        IHistogram1D trkz0 = aida.histogram1D("z0 ", 25, -6.0, 6.0);
 
         plotter22 = fac.createPlotterFactory().create("HPS Track Params");
         plotter22.setTitle("Track parameters");
@@ -189,7 +187,63 @@
         plotter22.region(2).plot(trkomega);
         plotter22.region(3).plot(trklam);
         plotter22.region(4).plot(trkz0);
-
+        
+        if(showPlots) plotter22.show();
+
+ //   ******************************************************************
+
+        
+         trkd0 = aida.histogram1D("d0 Top", 25, -10.0, 10.0);
+         trkphi = aida.histogram1D("sinphi Top", 25, -0.2, 0.2);
+         trkomega = aida.histogram1D("omega Top", 25, -0.0025, 0.0025);
+         trklam = aida.histogram1D("tan(lambda) Top", 25, -0.1, 0.1);
+         trkz0 = aida.histogram1D("z0 Top", 25, -6.0, 6.0);
+
+        plotter2221 = fac.createPlotterFactory().create("HPS Track Params");
+        plotter2221.setTitle("Track parameters");
+        //plotterFrame.addPlotter(plotter22);
+        IPlotterStyle style2221 = plotter2221.style();
+        style2221.dataStyle().fillStyle().setColor("yellow");
+        style2221.dataStyle().errorBarStyle().setVisible(false);
+        plotter2221.createRegions(2, 3);
+        plotter2221.region(0).plot(trkd0);
+        plotter2221.region(1).plot(trkphi);
+        plotter2221.region(2).plot(trkomega);
+        plotter2221.region(3).plot(trklam);
+        plotter2221.region(4).plot(trkz0);
+        
+        if(showPlots) plotter2221.show();
+        
+        
+   //   ******************************************************************
+
+        
+        trkd0 = aida.histogram1D("d0 Bottom", 25, -10.0, 10.0);
+        trkphi = aida.histogram1D("sinphi Bottom", 25, -0.2, 0.2);
+        trkomega = aida.histogram1D("omega Bottom", 25, -0.0025, 0.0025);
+        trklam = aida.histogram1D("tan(lambda) Bottom", 25, -0.1, 0.1);
+        trkz0 = aida.histogram1D("z0 Bottom", 25, -6.0, 6.0);
+
+       plotter2222 = fac.createPlotterFactory().create("HPS Track Params");
+       plotter2222.setTitle("Track parameters");
+       //plotterFrame.addPlotter(plotter22);
+       IPlotterStyle style2222 = plotter2222.style();
+       style2222.dataStyle().fillStyle().setColor("yellow");
+       style2222.dataStyle().errorBarStyle().setVisible(false);
+       plotter2222.createRegions(2, 3);
+       plotter2222.region(0).plot(trkd0);
+       plotter2222.region(1).plot(trkphi);
+       plotter2222.region(2).plot(trkomega);
+       plotter2222.region(3).plot(trklam);
+       plotter2222.region(4).plot(trkz0);
+       
+       if(showPlots) plotter2222.show();
+        
+        
+        
+   //   ******************************************************************
+
+        
         plotter2 = fac.createPlotterFactory().create("HPS Tracking Plots");
         plotter2.setTitle("Track extrapolation");
         //plotterFrame.addPlotter(plotter2);
@@ -214,29 +268,81 @@
         plotter2.region(6).plot(yAtEcal);
         plotter2.region(3).plot(xAtEcal2);
         plotter2.region(7).plot(yAtEcal2);
-
+        
+        if(showPlots) plotter2.show();
+
+   //   ******************************************************************
+        
         plotter222 = fac.createPlotterFactory().create("HPS Tracking Plots");
         plotter222.setTitle("Other");
         //plotterFrame.addPlotter(plotter222);
         IPlotterStyle style222 = plotter222.style();
         style222.dataStyle().fillStyle().setColor("yellow");
         style222.dataStyle().errorBarStyle().setVisible(false);
-        plotter222.createRegions(2, 3);
-
-        IHistogram1D nHits = aida.histogram1D("Hits per Track", 2, 4, 6);
+        plotter222.createRegions(2, 2);
+        
+        IHistogram1D nHits = aida.histogram1D("Hits per Track", 4, 3, 7);
+        nTracks = aida.histogram1D("Tracks per Event", 3, 0, 3);
+        IHistogram1D nHitsCluster = aida.histogram1D("Hits in Cluster (HitOnTrack)", 4, 0, 4);
+
+       
+        plotter222.region(0).plot(nHits);
+        plotter222.region(1).plot(nTracks);
+        plotter222.region(1).plot(nHitsCluster);
+        
+        if(showPlots) plotter222.show();
+        
+        //   ******************************************************************
+        
+        
+        plotter2223 = fac.createPlotterFactory().create("Cluster Amp Plots");
+        plotter2223.setTitle("Other");
+        //plotterFrame.addPlotter(plotter222);
+        IPlotterStyle style2223 = plotter2223.style();
+        style2223.dataStyle().fillStyle().setColor("yellow");
+        style2223.dataStyle().errorBarStyle().setVisible(false);
+        plotter2223.createRegions(2, 2);
+        
+       
+
         IHistogram1D amp = aida.histogram1D("Amp (HitOnTrack)", 50, 0, 5000);
-        IHistogram1D ampcl = aida.histogram1D("Amp (CluOnTrack)", 50, 0, 5000);
-        IHistogram1D amp2 = aida.histogram1D("Amp Pz>1000 (HitOnTrack)", 50, 0, 5000);
-        IHistogram1D ampcl2 = aida.histogram1D("Amp Pz>1000 (CluOnTrack)", 50, 0, 5000);
-        nTracks = aida.histogram1D("Tracks per Event", 3, 0, 3);
-
-        plotter222.region(0).plot(nHits);
-        plotter222.region(3).plot(nTracks);
-        plotter222.region(1).plot(amp);
-        plotter222.region(4).plot(amp2);
-        plotter222.region(2).plot(ampcl);
-        plotter222.region(5).plot(ampcl2);
-
+        IHistogram1D ampcl = aida.histogram1D("Cluster Amp (HitOnTrack)", 50, 0, 5000);
+        IHistogram1D amp2 = aida.histogram1D("Amp Pz>0.8 (HitOnTrack)", 50, 0, 5000);
+        IHistogram1D ampcl2 = aida.histogram1D("Cluster Amp Pz>0.8 (HitOnTrack)", 50, 0, 5000);
+      
+        
+        plotter2223.region(0).plot(amp);
+        plotter2223.region(1).plot(amp2);
+        plotter2223.region(2).plot(ampcl);
+        plotter2223.region(3).plot(ampcl2);
+        
+        if(showPlots) plotter2223.show();
+   
+//   ******************************************************************
+        
+        
+        plotter2224 = fac.createPlotterFactory().create("t0 Plots");
+        plotter2224.setTitle("Other");
+        IPlotterStyle style2224 = plotter2224.style();
+        style2224.dataStyle().fillStyle().setColor("yellow");
+        style2224.dataStyle().errorBarStyle().setVisible(false);
+        plotter2224.createRegions(2, 2);
+                
+        IHistogram1D t0 = aida.histogram1D("t0 (HitOnTrack)", 50, -100, 100);
+        IHistogram1D t0cl = aida.histogram1D("Cluster t0 (HitOnTrack)", 50, -100, 100);
+        IHistogram1D t02 = aida.histogram1D("t0 Pz>0.8 (HitOnTrack)", 50, -100, 100);
+        IHistogram1D t0cl2 = aida.histogram1D("Cluster t0 Pz>0.8 (HitOnTrack)", 50, -100, 100);
+        
+        plotter2224.region(0).plot(t0);
+        plotter2224.region(1).plot(t0cl);
+        plotter2224.region(2).plot(t02);
+        plotter2224.region(3).plot(t0cl2);
+
+        if(showPlots) plotter2224.show();
+   
+        
+        //   ******************************************************************
+          
         plotter3 = fac.createPlotterFactory().create("HPS Residual Plots");
         plotter3.setTitle("Residuals");
         //plotterFrame.addPlotter(plotter3);
@@ -266,6 +372,9 @@
         IHistogram1D mod5ResX = aida.histogram1D("Module 5 Residual X(mm)", 25, minResidX, maxResidX);
         IHistogram1D mod5ResY = aida.histogram1D("Module 5 Residual Y(mm)", 25, minResidY, maxResidY);
 
+        IHistogram1D mod6ResX = aida.histogram1D("Module 6 Residual X(mm)", 25, minResidX, maxResidX);
+        IHistogram1D mod6ResY = aida.histogram1D("Module 6 Residual Y(mm)", 25, minResidY, maxResidY);
+
         plotter3.region(0).plot(mod1ResX);
         plotter3.region(2).plot(mod2ResX);
         plotter3.region(4).plot(mod3ResX);
@@ -277,6 +386,8 @@
         plotter3.region(5).plot(mod3ResY);
         plotter3.region(7).plot(mod4ResY);
         plotter3.region(9).plot(mod5ResY);
+        
+        if(showPlots) plotter3.show();
 
         plotter3_1 = fac.createPlotterFactory().create("HPS Residual Plots (Single hit per layer)");
         plotter3_1.setTitle("Residuals (Top)");
@@ -284,7 +395,7 @@
         IPlotterStyle style3_1 = plotter3_1.style();
         style3_1.dataStyle().fillStyle().setColor("yellow");
         style3_1.dataStyle().errorBarStyle().setVisible(false);
-        plotter3_1.createRegions(5, 2);
+        plotter3_1.createRegions(6, 2);
 
         IHistogram1D mod1ResX_Top = aida.histogram1D("Module 1 Residual X(mm) Top", 25, minResidX, maxResidX);
         IHistogram1D mod1ResY_Top = aida.histogram1D("Module 1 Residual Y(mm) Top", 25, minResidY, maxResidY);
@@ -300,26 +411,33 @@
 
         IHistogram1D mod5ResX_Top = aida.histogram1D("Module 5 Residual X(mm) Top", 25, minResidX, maxResidX);
         IHistogram1D mod5ResY_Top = aida.histogram1D("Module 5 Residual Y(mm) Top", 25, minResidY, maxResidY);
+
+        IHistogram1D mod6ResX_Top = aida.histogram1D("Module 6 Residual X(mm) Top", 25, minResidX, maxResidX);
+        IHistogram1D mod6ResY_Top = aida.histogram1D("Module 6 Residual Y(mm) Top", 25, minResidY, maxResidY);
 
         plotter3_1.region(0).plot(mod1ResX_Top);
         plotter3_1.region(2).plot(mod2ResX_Top);
         plotter3_1.region(4).plot(mod3ResX_Top);
         plotter3_1.region(6).plot(mod4ResX_Top);
         plotter3_1.region(8).plot(mod5ResX_Top);
+        plotter3_1.region(10).plot(mod6ResX_Top);
 
         plotter3_1.region(1).plot(mod1ResY_Top);
         plotter3_1.region(3).plot(mod2ResY_Top);
         plotter3_1.region(5).plot(mod3ResY_Top);
         plotter3_1.region(7).plot(mod4ResY_Top);
         plotter3_1.region(9).plot(mod5ResY_Top);
-
+        plotter3_1.region(11).plot(mod6ResY_Top);
+
+        if(showPlots) plotter3_1.show();
+        
         plotter3_2 = fac.createPlotterFactory().create("HPS Residual Plots (Single strip cluster per layer)");
         plotter3_2.setTitle("Residuals (Bottom)");
         //plotterFrame.addPlotter(plotter3_2);
         IPlotterStyle style3_2 = plotter3_2.style();
         style3_2.dataStyle().fillStyle().setColor("yellow");
         style3_2.dataStyle().errorBarStyle().setVisible(false);
-        plotter3_2.createRegions(5, 2);
+        plotter3_2.createRegions(6, 2);
 
         IHistogram1D mod1ResX_Bottom = aida.histogram1D("Module 1 Residual X(mm) Bottom", 25, minResidX, maxResidX);
         IHistogram1D mod1ResY_Bottom = aida.histogram1D("Module 1 Residual Y(mm) Bottom", 25, minResidY, maxResidY);
@@ -335,18 +453,25 @@
 
         IHistogram1D mod5ResX_Bottom = aida.histogram1D("Module 5 Residual X(mm) Bottom", 25, minResidX, maxResidX);
         IHistogram1D mod5ResY_Bottom = aida.histogram1D("Module 5 Residual Y(mm) Bottom", 25, minResidY, maxResidY);
+
+        IHistogram1D mod6ResX_Bottom = aida.histogram1D("Module 6 Residual X(mm) Bottom", 25, minResidX, maxResidX);
+        IHistogram1D mod6ResY_Bottom = aida.histogram1D("Module 6 Residual Y(mm) Bottom", 25, minResidY, maxResidY);
 
         plotter3_2.region(0).plot(mod1ResX_Bottom);
         plotter3_2.region(2).plot(mod2ResX_Bottom);
         plotter3_2.region(4).plot(mod3ResX_Bottom);
         plotter3_2.region(6).plot(mod4ResX_Bottom);
         plotter3_2.region(8).plot(mod5ResX_Bottom);
+        plotter3_2.region(10).plot(mod6ResX_Bottom);
 
         plotter3_2.region(1).plot(mod1ResY_Bottom);
         plotter3_2.region(3).plot(mod2ResY_Bottom);
         plotter3_2.region(5).plot(mod3ResY_Bottom);
         plotter3_2.region(7).plot(mod4ResY_Bottom);
         plotter3_2.region(9).plot(mod5ResY_Bottom);
+        plotter3_2.region(11).plot(mod6ResY_Bottom);
+        
+        if(showPlots) plotter3_2.show();
 
         plotter4 = fac.createPlotterFactory().create("HPS Track and ECal Plots");
         plotter4.setTitle("Track and ECal Correlations");
@@ -358,14 +483,12 @@
         style4.dataStyle().errorBarStyle().setVisible(false);
         plotter4.createRegions(2, 3);
 
-        IHistogram2D eVsP = aida.histogram2D("Energy Vs Momentum", 50, 0, 500, 50, 0, 3000);
+        IHistogram2D eVsP = aida.histogram2D("Energy Vs Momentum", 50, 0, 0.50, 50, 0, 1.5);
         IHistogram1D eOverP = aida.histogram1D("Energy Over Momentum", 50, 0, 2);
 
-        IHistogram1D distX = aida.histogram1D("deltaX", 50, -400, 400);
+        IHistogram1D distX = aida.histogram1D("deltaX", 50, -100, 100);
         IHistogram1D distY = aida.histogram1D("deltaY", 50, -40, 40);
 
-//        IHistogram1D distX2 = aida.histogram1D("deltaX (Pz>1)", 50, -400, 400);
-//        IHistogram1D distY2 = aida.histogram1D("deltaY (Pz>1)", 50, -40, 40);
         IHistogram2D xEcalVsTrk = aida.histogram2D("X ECal Vs Track", 100, -400, 400, 100, -400, 400);
         IHistogram2D yEcalVsTrk = aida.histogram2D("Y ECal Vs Track", 100, -100, 100, 100, -100, 100);
 
@@ -375,6 +498,8 @@
         plotter4.region(4).plot(distY);
         plotter4.region(2).plot(xEcalVsTrk);
         plotter4.region(5).plot(yEcalVsTrk);
+
+        if(showPlots) plotter4.show();
 
         //   ******************************************************************
         top2 = fac.createPlotterFactory().create("Top ECal Plots");
@@ -387,13 +512,13 @@
         top2.createRegions(2, 3);
         //topFrame.addPlotter(top2);
 
-        IHistogram2D topeVsP = aida.histogram2D("Top Energy Vs Momentum", 50, 0, 500, 50, 0, 3000);
+        IHistogram2D topeVsP = aida.histogram2D("Top Energy Vs Momentum", 50, 0, 0.500, 50, 0, 1.5);
         IHistogram1D topeOverP = aida.histogram1D("Top Energy Over Momentum", 50, 0, 2);
 
-        IHistogram1D topdistX = aida.histogram1D("Top deltaX", 50, -400, 400);
+        IHistogram1D topdistX = aida.histogram1D("Top deltaX", 50, -100, 100);
         IHistogram1D topdistY = aida.histogram1D("Top deltaY", 50, -40, 40);
 
-        IHistogram2D topxEcalVsTrk = aida.histogram2D("Top X ECal Vs Track", 100, -400, 400, 100, -400, 400);
+        IHistogram2D topxEcalVsTrk = aida.histogram2D("Top X ECal Vs Track", 100, -400, 400, 100, -100, 100);
         IHistogram2D topyEcalVsTrk = aida.histogram2D("Top Y ECal Vs Track", 100, 0, 100, 100, 0, 100);
 
         top2.region(0).plot(topeVsP);
@@ -403,6 +528,8 @@
         top2.region(2).plot(topxEcalVsTrk);
         top2.region(5).plot(topyEcalVsTrk);
 
+        if(showPlots) top2.show();
+        
         bot2 = fac.createPlotterFactory().create("Bottom ECal Plots");
         bot2.setTitle("Bottom ECal Correlations");
         IPlotterStyle sbot2 = bot2.style();
@@ -413,10 +540,10 @@
         bot2.createRegions(2, 3);
         //bottomFrame.addPlotter(bot2);
 
-        IHistogram2D BottomeVsP = aida.histogram2D("Bottom Energy Vs Momentum", 50, 0, 500, 50, 0, 3000);
+        IHistogram2D BottomeVsP = aida.histogram2D("Bottom Energy Vs Momentum", 50, 0, 0.500, 50, 0, 1.5);
         IHistogram1D BottomeOverP = aida.histogram1D("Bottom Energy Over Momentum", 50, 0, 2);
 
-        IHistogram1D BottomdistX = aida.histogram1D("Bottom deltaX", 50, -400, 400);
+        IHistogram1D BottomdistX = aida.histogram1D("Bottom deltaX", 50, -100, 100);
         IHistogram1D BottomdistY = aida.histogram1D("Bottom deltaY", 50, -40, 40);
 
         IHistogram2D BottomxEcalVsTrk = aida.histogram2D("Bottom X ECal Vs Track", 100, -400, 400, 100, -400, 400);
@@ -429,7 +556,10 @@
         bot2.region(2).plot(BottomxEcalVsTrk);
         bot2.region(5).plot(BottomyEcalVsTrk);
 
-//   ******************************************************************
+        if(showPlots) bot2.show();
+        
+        
+        //   ******************************************************************
         top3 = fac.createPlotterFactory().create("Top ECal Plots");
         top3.setTitle("Top ECal More Correlations");
         IPlotterStyle stop3 = top3.style();
@@ -440,12 +570,14 @@
         top3.createRegions(1, 2);
         //topFrame.addPlotter(top3);
 
-        IHistogram2D topdistXvsX = aida.histogram2D("Top deltaX vs X", 51, -400, 400, 25, -400, 400);
+        IHistogram2D topdistXvsX = aida.histogram2D("Top deltaX vs X", 51, -400, 400, 25, -100, 100);
         IHistogram2D topdistYvsY = aida.histogram2D("Top deltaY vs Y", 51, 0, 100, 25, -40, 40);
 
         top3.region(0).plot(topdistXvsX);
         top3.region(1).plot(topdistYvsY);
 
+        if(showPlots) top3.show();
+        
         bot3 = fac.createPlotterFactory().create("Bottom ECal Plots");
         bot3.setTitle("Bottom ECal More Correlations");
         IPlotterStyle sbot3 = bot3.style();
@@ -456,12 +588,72 @@
         bot3.createRegions(1, 2);
         //bottomFrame.addPlotter(bot3);
 
-        IHistogram2D botdistXvsX = aida.histogram2D("Bottom deltaX vs X", 51, -400, 400, 25, -400, 400);
+        IHistogram2D botdistXvsX = aida.histogram2D("Bottom deltaX vs X", 51, -400, 400, 25, -100, 100);
         IHistogram2D botdistYvsY = aida.histogram2D("Bottom deltaY vs Y", 51, -100, 0, 25, -40, 40);
 
         bot3.region(0).plot(botdistXvsX);
         bot3.region(1).plot(botdistYvsY);
 
+        if(showPlots) bot3.show();
+        
+        //   ******************************************************************
+        top4 = fac.createPlotterFactory().create("Track Matching Plots");
+        top4.setTitle("Track Matching Plots");
+        IPlotterStyle stop4 = top4.style();
+        stop4.dataStyle().fillStyle().setColor("green");
+        stop4.dataStyle().errorBarStyle().setVisible(false);
+        stop4.setParameter("hist2DStyle", "colorMap");
+        stop4.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+        top4.createRegions(2, 3);
+        //topFrame.addPlotter(top4);
+
+        IHistogram1D trackmatchN = aida.histogram1D("Tracks matched", 3, 0, 3);
+        IHistogram1D toptrackmatchN = aida.histogram1D("Tracks matched Top", 3, 0, 3);
+        IHistogram1D bottrackmatchN = aida.histogram1D("Tracks matched Bottom", 3, 0, 3);
+        IHistogram1D trackmatchN2 = aida.histogram1D("Tracks matched (Pz>0.8)", 3, 0, 3);
+        IHistogram1D toptrackmatchN2 = aida.histogram1D("Tracks matched Top (Pz>0.8)", 3, 0, 3);
+        IHistogram1D bottrackmatchN2 = aida.histogram1D("Tracks matched Bottom (Pz>0.8)", 3, 0, 3);
+        
+        top4.region(0).plot(trackmatchN);
+        top4.region(1).plot(toptrackmatchN);
+        top4.region(2).plot(bottrackmatchN);
+        top4.region(3).plot(trackmatchN2);
+        top4.region(4).plot(toptrackmatchN2);
+        top4.region(5).plot(bottrackmatchN2);
+
+        if(showPlots) top4.show();
+        
+        //   ******************************************************************
+        top44 = fac.createPlotterFactory().create("e+e- Plots");
+        top44.setTitle("e+e- Plots");
+        IPlotterStyle stop44 = top44.style();
+        stop44.dataStyle().fillStyle().setColor("green");
+        stop44.dataStyle().errorBarStyle().setVisible(false);
+        stop44.setParameter("hist2DStyle", "colorMap");
+        stop44.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+        top44.createRegions(2,4);
+        //topFrame.addPlotter(top44);
+
+        IHistogram2D trackPCorr = aida.histogram2D("p(e-) vs p(e+) max", 25, 0, 1.2, 25, 0, 1.2);
+        IHistogram1D ne = aida.histogram1D("n(e-)", 3, 0, 3);
+        IHistogram1D np = aida.histogram1D("n(e+)", 3, 0, 3);
+        IHistogram1D pem = aida.histogram1D("p(e-) max", 25, 0, 1.5);
+        IHistogram1D pe = aida.histogram1D("p(e-)", 25, 0, 1.5);
+        IHistogram1D ppm = aida.histogram1D("p(e+) max", 25, 0, 1.5);
+        IHistogram1D pp = aida.histogram1D("p(e+)", 25, 0, 1.5);
+        
+        top44.region(0).plot(trackPCorr);
+        top44.region(1).plot(ne);
+        top44.region(2).plot(np);
+        top44.region(3).plot(pe);
+        top44.region(4).plot(pp);
+        top44.region(5).plot(pem);
+        top44.region(6).plot(ppm);
+        
+        if(showPlots) top44.show();
+        
+        
+        
 //   ******************************************************************
         plotter5 = fac.createPlotterFactory().create("HPS Hit Positions");
         plotter5.setTitle("Hit Positions:  Top");
@@ -480,7 +672,9 @@
 
         plotter5.region(0).plot(l1Pos);
         plotter5.region(1).plot(l7Pos);
-
+        
+        if(showPlots) plotter5.show();
+        
         plotter5_1 = fac.createPlotterFactory().create("HPS Hit Positions");
         plotter5_1.setTitle("Hit Positions:  Bottom");
         //plotterFrame.addPlotter(plotter5_1);
@@ -491,10 +685,13 @@
         style5_1.dataStyle().errorBarStyle().setVisible(false);
         plotter5_1.createRegions(1, 2);
 
+        
         IHistogram2D l1PosBot = aida.histogram2D("Layer 1 HTH Position:  Bottom", 50, -55, 55, 55, -25, 25);
         IHistogram2D l7PosBot = aida.histogram2D("Layer 7 HTH Position:  Bottom", 50, -55, 55, 55, -25, 25);
         plotter5_1.region(0).plot(l1PosBot);
         plotter5_1.region(1).plot(l7PosBot);
+
+        if(showPlots) plotter5_1.show();
 
         plotter55 = fac.createPlotterFactory().create("HPS Hit Positions");
         plotter55.setTitle("Helical Track Hits");
@@ -510,6 +707,8 @@
 
         plotter55.region(0).plot(avgLayersTopPlot);
         plotter55.region(1).plot(avgLayersBottomPlot);
+
+        if(showPlots) plotter55.show();
 
         plotter6 = fac.createPlotterFactory().create("HPS ECAL Hit Positions");
         plotter6.setTitle("ECAL Positions");
@@ -525,10 +724,10 @@
         IHistogram2D botECal = aida.histogram2D("Bottom ECal Cluster Position", 50, -400, 400, 10, -100, 0);
         IHistogram2D topECal1 = aida.histogram2D("Top ECal Cluster Position (>0 tracks)", 50, -400, 400, 10, 0, 100);
         IHistogram2D botECal1 = aida.histogram2D("Bottom ECal Cluster Position (>0 tracks)", 50, -400, 400, 10, -100, 0);
-        IHistogram2D topECal2 = aida.histogram2D("Top ECal Cluster Position (E>100,>0 tracks)", 50, -400, 400, 10, 0, 100);
-        IHistogram2D botECal2 = aida.histogram2D("Bottom ECal Cluster Position (E>100,>0 tracks)", 50, -400, 400, 10, -100, 0);
-        IHistogram2D topECal3 = aida.histogram2D("Top ECal Cluster Position w_E (E>100,>0 tracks)", 50, -400, 400, 10, 0, 100);
-        IHistogram2D botECal3 = aida.histogram2D("Bottom ECal Cluster Position w_E (E>100,>0 tracks)", 50, -400, 400, 10, -100, 0);
+        IHistogram2D topECal2 = aida.histogram2D("Top ECal Cluster Position (E>0.1,>0 tracks)", 50, -400, 400, 10, 0, 100);
+        IHistogram2D botECal2 = aida.histogram2D("Bottom ECal Cluster Position (E>0.1,>0 tracks)", 50, -400, 400, 10, -100, 0);
+        IHistogram2D topECal3 = aida.histogram2D("Top ECal Cluster Position w_E (E>0.1,>0 tracks)", 50, -400, 400, 10, 0, 100);
+        IHistogram2D botECal3 = aida.histogram2D("Bottom ECal Cluster Position w_E (E>0.1,>0 tracks)", 50, -400, 400, 10, -100, 0);
 
         plotter6.region(0).plot(topECal);
         plotter6.region(1).plot(botECal);
@@ -538,13 +737,31 @@
         plotter6.region(5).plot(botECal2);
         plotter6.region(6).plot(topECal3);
         plotter6.region(7).plot(botECal3);
-
-        //plotterFrame.pack();
-        //plotterFrame.setVisible(true);
-        //topFrame.pack();
-        //topFrame.setVisible(true);
-        //bottomFrame.pack();
-        //bottomFrame.setVisible(true);
+        
+        if(showPlots) plotter6.show();
+        
+        
+        plotter66 = fac.createPlotterFactory().create("HPS ECAL Basic Plots");
+        plotter66.setTitle("ECAL Basic Plots");
+        //plotterFrame.addPlotter(plotter6);
+        IPlotterStyle style66 = plotter66.style();
+        style66.dataStyle().fillStyle().setColor("yellow");
+        style66.dataStyle().errorBarStyle().setVisible(false);
+        plotter66.createRegions(2, 2);
+
+        IHistogram1D topECalE = aida.histogram1D("Top ECal Cluster Energy", 50, 0, 2);
+        IHistogram1D botECalE = aida.histogram1D("Bottom ECal Cluster Energy", 50, 0, 2);
+        IHistogram1D topECalN = aida.histogram1D("Number of Clusters Top", 6, 0, 6);
+        IHistogram1D botECalN = aida.histogram1D("Number of Clusters Bot", 6, 0, 6);
+        
+        plotter66.region(0).plot(topECalE);
+        plotter66.region(1).plot(botECalE);
+        plotter66.region(2).plot(botECalN);
+        plotter66.region(3).plot(topECalN);
+        
+        if(showPlots) plotter66.show();
+        
+        
         plotter7 = fac.createPlotterFactory().create("HPS ECAL Hit Positions");
         plotter7.setTitle("Basic Misc Stuff");
         //plotterFrame.addPlotter(plotter7);
@@ -557,6 +774,9 @@
 
         IHistogram2D quadrants = aida.histogram2D("Charge vs Slope", 2, -1, 1, 2, -1, 1);
         plotter7.region(0).plot(quadrants);
+        
+        if(showPlots) plotter7.show();
+
 
     }
 
@@ -566,7 +786,13 @@
     public void setOutputPlots(String output) {
         this.outputPlots = output;
     }
-
+    
+    public void setShowPlots(boolean show) {
+        this.showPlots  = show;
+    }
+
+    
+    
     public void setRawTrackerHitCollectionName(String rawTrackerHitCollectionName) {
         this.rawTrackerHitCollectionName = rawTrackerHitCollectionName;
     }
@@ -602,8 +828,8 @@
 //            System.out.println("TrackingReconstructionPlots::corrected helical track position = "+htc.getCorrectedPosition().toString());
         }
         List<HelicalTrackHit> hthList = event.get(HelicalTrackHit.class, helicalTrackHitCollectionName);
-        int[] layersTop = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-        int[] layersBot = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+        int[] layersTop = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+        int[] layersBot = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
         for (HelicalTrackHit hth : hthList) {
             HelicalTrackCross htc = (HelicalTrackCross) hth;
 //            System.out.println("TrackingReconstructionPlots::original helical track position = "+hth.getPosition()[0]+","+hth.getPosition()[1]+","+hth.getPosition()[2]);
@@ -635,7 +861,7 @@
 //                    aida.histogram2D("Layer 7 HTH Position:  Bottom").fill(x - sensorPos.x(), y - sensorPos.y());
             }
         }
-        for (int i = 0; i < 10; i++) {
+        for (int i = 0; i < 12; i++) {
             aida.profile1D("Number of Stereo Hits per layer in Top Half").fill(i + 1, layersTop[i]);
             aida.profile1D("Number of Stereo Hits per layer in Bottom Half").fill(i + 1, layersBot[i]);
         }
@@ -647,15 +873,26 @@
 
         List<Track> tracks = event.get(Track.class, trackCollectionName);
         nTracks.fill(tracks.size());
+        int nBotClusters = 0;
+        int nTopClusters = 0;
         if (event.hasCollection(Cluster.class, ecalCollectionName)) {
             List<Cluster> clusters = event.get(Cluster.class, ecalCollectionName);
             for (Cluster cluster : clusters) {
+             // Get the ix and iy indices for the seed.
+                final int ix = cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("ix");
+                final int iy = cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("iy");
+ 
                 //System.out.println("cluser position = ("+cluster.getPosition()[0]+","+cluster.getPosition()[1]+") with energy = "+cluster.getEnergy());
                 if (cluster.getPosition()[1] > 0) {
+                    nTopClusters++;
+                    //System.out.println("cl " + cluster.getPosition()[0] + " " + cluster.getPosition()[1] + "  ix  " + ix + " iy " + iy);
                     aida.histogram2D("Top ECal Cluster Position").fill(cluster.getPosition()[0], cluster.getPosition()[1]);
+                    aida.histogram1D("Top ECal Cluster Energy").fill(cluster.getEnergy());
                 }
                 if (cluster.getPosition()[1] < 0) {
+                    nBotClusters++;
                     aida.histogram2D("Bottom ECal Cluster Position").fill(cluster.getPosition()[0], cluster.getPosition()[1]);
+                    aida.histogram1D("Bottom ECal Cluster Energy").fill(cluster.getEnergy());
                 }
 
                 if (tracks.size() > 0) {
@@ -666,30 +903,40 @@
                         aida.histogram2D("Bottom ECal Cluster Position (>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1]);
                     }
 
-                    if (cluster.getEnergy() > 100) {
+                    if (cluster.getEnergy() > 0.1) {
                         if (cluster.getPosition()[1] > 0) {
-                            aida.histogram2D("Top ECal Cluster Position (E>100,>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1]);
-                            aida.histogram2D("Top ECal Cluster Position w_E (E>100,>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1], cluster.getEnergy());
+                            aida.histogram2D("Top ECal Cluster Position (E>0.1,>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1]);
+                            aida.histogram2D("Top ECal Cluster Position w_E (E>0.1,>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1], cluster.getEnergy());
                         }
                         if (cluster.getPosition()[1] < 0) {
-                            aida.histogram2D("Bottom ECal Cluster Position (E>100,>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1]);
-                            aida.histogram2D("Bottom ECal Cluster Position w_E (E>100,>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1], cluster.getEnergy());
+                            aida.histogram2D("Bottom ECal Cluster Position (E>0.1,>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1]);
+                            aida.histogram2D("Bottom ECal Cluster Position w_E (E>0.1,>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1], cluster.getEnergy());
                         }
                     }
                 }
 
             }
         }
-
-        List<SiTrackerHitStrip1D> stripHits = event.get(SiTrackerHitStrip1D.class, "StripClusterer_SiTrackerHitStrip1D");
-        int stripClustersPerLayerTop[] = getStripClustersPerLayer(stripHits, "up");
+        
+        aida.histogram1D("Number of Clusters Top").fill(nTopClusters);
+        aida.histogram1D("Number of Clusters Bot").fill(nBotClusters);
+        
+
+            
+        
+
+        //List<SiTrackerHitStrip1D> stripHits = event.get(SiTrackerHitStrip1D.class, "StripClusterer_SiTrackerHitStrip1D");
+        //int stripClustersPerLayerTop[] = getStripClustersPerLayer(stripHits, "up");
         //int stripClustersPerLayerBottom[] = getStripClustersPerLayer(stripHits,"down");
 
-        boolean hasSingleStripClusterPerLayer = singleStripClusterPerLayer(stripClustersPerLayerTop);
-
+        //boolean hasSingleStripClusterPerLayer = singleStripClusterPerLayer(stripClustersPerLayerTop);
+
+        Map<Track, Cluster> eCanditates = new HashMap<Track, Cluster>();
+        Map<Track, Cluster> pCanditates = new HashMap<Track, Cluster>();
+        
         for (Track trk : tracks) {
 
-            boolean isSingleHitPerLayerTrack = singleTrackHitPerLayer(trk);
+            //boolean isSingleHitPerLayerTrack = singleTrackHitPerLayer(trk);
 
             aida.histogram1D("Track Momentum (Px)").fill(trk.getTrackStates().get(0).getMomentum()[1]);
             aida.histogram1D("Track Momentum (Py)").fill(trk.getTrackStates().get(0).getMomentum()[2]);
@@ -704,18 +951,12 @@
             StraightLineTrack slt = converter.Convert(ht);
 
             Hep3Vector posAtEcal = TrackUtils.getTrackPositionAtEcal(trk);
-
+            
             aida.histogram1D("X (mm) @ Z=-60cm").fill(slt.getYZAtX(BeamlineConstants.HARP_POSITION_TESTRUN)[0]);  //this is y in the tracker frame
             aida.histogram1D("Y (mm) @ Z=-60cm").fill(slt.getYZAtX(BeamlineConstants.HARP_POSITION_TESTRUN)[1]);  //this is z in the tracker frame
-            //double sECAL = HelixUtils.PathToXPlane(ht, zEcal, 3000, 1).get(0);
             aida.histogram1D("X (mm) @ Z=-150cm").fill(slt.getYZAtX(zAtColl)[0]);
             aida.histogram1D("Y (mm) @ Z=-150cm").fill(slt.getYZAtX(zAtColl)[1]);
 
-            //Straight line after field-region???
-            //HelixConverter converterEcal = new HelixConverter(zAtDownStrPairSpec);
-            //StraightLineTrack sltEcal = converterEcal.Convert(ht);
-//            double sECAL = HelixUtils.PathToXPlane(ht, zEcal, 3000, 1).get(0);
-//            Hep3Vector posonhelix = HelixUtils.PointOnHelix(ht, sECAL);//position in tracker coordinates!
             aida.histogram1D("X (mm) @ ECAL").fill(posAtEcal.x());
             aida.histogram1D("Y (mm) @ ECAL").fill(posAtEcal.y());
             if (trk.getTrackStates().get(0).getMomentum()[0] > 1.0) {
@@ -742,11 +983,25 @@
                 aida.histogram1D("Top Track Momentum (Py)").fill(trk.getTrackStates().get(0).getMomentum()[2]);
                 aida.histogram1D("Top Track Momentum (Pz)").fill(trk.getTrackStates().get(0).getMomentum()[0]);
                 aida.histogram1D("Top Track Chi2").fill(trk.getChi2());
+                
+                aida.histogram1D("d0 Top").fill(trk.getTrackStates().get(0).getParameter(ParameterName.d0.ordinal()));
+                aida.histogram1D("sinphi Top").fill(Math.sin(trk.getTrackStates().get(0).getParameter(ParameterName.phi0.ordinal())));
+                aida.histogram1D("omega Top").fill(trk.getTrackStates().get(0).getParameter(ParameterName.omega.ordinal()));
+                aida.histogram1D("tan(lambda) Top").fill(trk.getTrackStates().get(0).getParameter(ParameterName.tanLambda.ordinal()));
+                aida.histogram1D("z0 Top").fill(trk.getTrackStates().get(0).getParameter(ParameterName.z0.ordinal()));
+
             } else {
                 aida.histogram1D("Bottom Track Momentum (Px)").fill(trk.getTrackStates().get(0).getMomentum()[1]);
                 aida.histogram1D("Bottom Track Momentum (Py)").fill(trk.getTrackStates().get(0).getMomentum()[2]);
                 aida.histogram1D("Bottom Track Momentum (Pz)").fill(trk.getTrackStates().get(0).getMomentum()[0]);
                 aida.histogram1D("Bottom Track Chi2").fill(trk.getChi2());
+
+                aida.histogram1D("d0 Bottom").fill(trk.getTrackStates().get(0).getParameter(ParameterName.d0.ordinal()));
+                aida.histogram1D("sinphi Bottom").fill(Math.sin(trk.getTrackStates().get(0).getParameter(ParameterName.phi0.ordinal())));
+                aida.histogram1D("omega Bottom").fill(trk.getTrackStates().get(0).getParameter(ParameterName.omega.ordinal()));
+                aida.histogram1D("tan(lambda) Bottom").fill(trk.getTrackStates().get(0).getParameter(ParameterName.tanLambda.ordinal()));
+                aida.histogram1D("z0 Bottom").fill(trk.getTrackStates().get(0).getParameter(ParameterName.z0.ordinal()));
+
             }
             List<TrackerHit> hitsOnTrack = trk.getTrackerHits();
             for (TrackerHit hit : hitsOnTrack) {
@@ -773,6 +1028,9 @@
                 }
                 if (layer == 9) {
                     modNum = "Module 5 ";
+                }
+                if (layer == 11) {
+                    modNum = "Module 6 ";
                 }
                 SymmetricMatrix cov = htc.getCorrectedCovMatrix();
 
@@ -814,87 +1072,206 @@
                         aida.histogram2D("Layer 7 HTH Position:  Bottom").fill(x - sensorPos.x(), y - sensorPos.y());
                     }
                 }
-                /*
-                 List<RawTrackerHit> rawHits = hit.getRawHits();                
-                 for (RawTrackerHit rawHit : rawHits) {
-                 ChannelConstants constants = HPSSVTCalibrationConstants.getChannelConstants((SiSensor) rawHit.getDetectorElement(), rawHit.getIdentifierFieldValue("strip"));
-                 HPSShapeFitParameters fit = _shaper.fitShape(rawHit, constants);
-                 double amp = fit.getAmp();
-                    
-                 aida.histogram1D("Amp (HitOnTrack)").fill(amp);
-                 if (trk.getTrackStates().get(0).getMomentum()[0] > 1)
-                 aida.histogram1D("Amp Pz>1000 (HitOnTrack)").fill(amp);
-                 }                
-                 */
-                boolean doAmplitudePlots = false;
+                
+                boolean doAmplitudePlots = true;
                 if(doAmplitudePlots) {
                     for (HelicalTrackStrip hts : htcross.getStrips()) {
                         double clusterSum = 0;
+                        double clusterT0 = 0;
+                        int nHitsCluster = 0;
+                                
                         for (RawTrackerHit rawHit : (List<RawTrackerHit>) hts.rawhits()) {
-                            for (ShapeFitParameters fit : _shaper.fitShape(rawHit,new PulseShape.CRRC())) {
-                                double amp = fit.getAmp();
-                                clusterSum += amp;
-                                aida.histogram1D("Amp (HitOnTrack)").fill(amp);
-                                if (trk.getTrackStates().get(0).getMomentum()[0] > 1) {
-                                    aida.histogram1D("Amp Pz>1000 (HitOnTrack)").fill(amp);
+                            if(event.hasCollection(LCRelation.class, "SVTFittedRawTrackerHits")) {
+                                List<LCRelation> fittedHits = event.get(LCRelation.class, "SVTFittedRawTrackerHits");
+                                for(LCRelation fittedHit : fittedHits) {
+                                    if(rawHit.equals((RawTrackerHit)fittedHit.getFrom())) {
+                                        double amp = FittedRawTrackerHit.getAmp(fittedHit);
+                                        double t0 = FittedRawTrackerHit.getT0(fittedHit);
+                                        //System.out.println("to="+t0 + " amp=" + amp);
+                                        aida.histogram1D("Amp (HitOnTrack)").fill(amp);
+                                        if (trk.getTrackStates().get(0).getMomentum()[0] > 0.8) {
+                                            aida.histogram1D("Amp Pz>0.8 (HitOnTrack)").fill(amp);
+                                        }
+                                        aida.histogram1D("t0 (HitOnTrack)").fill(t0);
+                                        if (trk.getTrackStates().get(0).getMomentum()[0] > 0.8) {
+                                            aida.histogram1D("t0 Pz>0.8 (HitOnTrack)").fill(t0);
+                                        }
+                                        clusterSum += amp;
+                                        clusterT0 += t0;
+                                        nHitsCluster++;
+                                    }
+                                }     
                                 }
+                        }
+                           
+                        aida.histogram1D("Hits in Cluster (HitOnTrack)").fill(nHitsCluster);
+                        aida.histogram1D("Cluster Amp (HitOnTrack)").fill(clusterSum);
+                        if (trk.getTrackStates().get(0).getMomentum()[0] > 0.8) {
+                            aida.histogram1D("Cluster Amp Pz>0.8 (HitOnTrack)").fill(clusterSum);
+                        }
+                        if(nHitsCluster>0) {
+                            aida.histogram1D("Cluster t0 (HitOnTrack)").fill(clusterT0/nHitsCluster);
+                            if (trk.getTrackStates().get(0).getMomentum()[0] > 0.8) {
+                                aida.histogram1D("Cluster t0 Pz>0.8 (HitOnTrack)").fill(clusterT0/nHitsCluster);
                             }
                         }
-                        aida.histogram1D("Amp (CluOnTrack)").fill(clusterSum);
-                        if (trk.getTrackStates().get(0).getMomentum()[0] > 1) {
-                            aida.histogram1D("Amp Pz>1000 (CluOnTrack)").fill(clusterSum);
-                        }
-                    }
-                }
-            }
+                    
+                    }
+                }
+            }
+            Cluster clust = null;
             if(event.hasCollection(Cluster.class,ecalCollectionName)) {
                 List<Cluster> clusters = event.get(Cluster.class, ecalCollectionName);
 
-                Cluster clust = findClosestCluster(posAtEcal, clusters);
-
-                //           if (clust != null) {
-                if (clust != null) {
-
-                    posAtEcal = TrackUtils.extrapolateTrack(trk, clust.getPosition()[2]);//.positionAtEcal();
-
-                    aida.histogram2D("Energy Vs Momentum").fill(clust.getEnergy(), trk.getTrackStates().get(0).getMomentum()[0] * 1000.0);
-                    aida.histogram1D("Energy Over Momentum").fill(clust.getEnergy() / (trk.getTrackStates().get(0).getMomentum()[0] * 1000.0));
-                    aida.histogram1D("deltaX").fill(clust.getPosition()[0] - posAtEcal.x());
-                    aida.histogram1D("deltaY").fill(clust.getPosition()[1] - posAtEcal.y());
-                    //                if (trk.getTrackStates().get(0).getMomentum()[0] > 1.0) {
-                    //                    aida.histogram1D("deltaX (Pz>1)").fill(clust.getPosition()[0] - posAtEcal.y());
-                    //                    aida.histogram1D("deltaY (Pz>1)").fill(clust.getPosition()[1] - posAtEcal.z());
-                    //                }
-                    aida.histogram2D("X ECal Vs Track").fill(clust.getPosition()[0], posAtEcal.x());
-                    aida.histogram2D("Y ECal Vs Track").fill(clust.getPosition()[1], posAtEcal.y());
-                    if (isTop == 0) {
-                        aida.histogram2D("Top Energy Vs Momentum").fill(clust.getEnergy(), trk.getTrackStates().get(0).getMomentum()[0] * 1000.0);
-                        //                    aida.histogram2D("Top Energy Vs Momentum").fill(posAtEcal.y(), trk.getTrackStates().get(0).getMomentum()[0] * 1000.0);
-                        aida.histogram1D("Top Energy Over Momentum").fill(clust.getEnergy() / (trk.getTrackStates().get(0).getMomentum()[0] * 1000.0));
-                        aida.histogram1D("Top deltaX").fill(clust.getPosition()[0] - posAtEcal.x());
-                        aida.histogram1D("Top deltaY").fill(clust.getPosition()[1] - posAtEcal.y());
-                        aida.histogram2D("Top deltaX vs X").fill(clust.getPosition()[0], clust.getPosition()[0] - posAtEcal.x());
-                        aida.histogram2D("Top deltaY vs Y").fill(clust.getPosition()[1], clust.getPosition()[1] - posAtEcal.y());
-                        aida.histogram2D("Top X ECal Vs Track").fill(clust.getPosition()[0], posAtEcal.x());
-                        aida.histogram2D("Top Y ECal Vs Track").fill(clust.getPosition()[1], posAtEcal.y());
-                    } else {
-                        aida.histogram2D("Bottom Energy Vs Momentum").fill(clust.getEnergy(), trk.getTrackStates().get(0).getMomentum()[0] * 1000.0);
-                        aida.histogram1D("Bottom Energy Over Momentum").fill(clust.getEnergy() / (trk.getTrackStates().get(0).getMomentum()[0] * 1000.0));
-                        aida.histogram1D("Bottom deltaX").fill(clust.getPosition()[0] - posAtEcal.x());
-                        aida.histogram1D("Bottom deltaY").fill(clust.getPosition()[1] - posAtEcal.y());
-                        aida.histogram2D("Bottom deltaX vs X").fill(clust.getPosition()[0], clust.getPosition()[0] - posAtEcal.x());
-                        aida.histogram2D("Bottom deltaY vs Y").fill(clust.getPosition()[1], clust.getPosition()[1] - posAtEcal.y());
-                        aida.histogram2D("Bottom X ECal Vs Track").fill(clust.getPosition()[0], posAtEcal.x());
-                        aida.histogram2D("Bottom Y ECal Vs Track").fill(clust.getPosition()[1], posAtEcal.y());
-                    }
-
-                }
-            }
-        }
+                Cluster cand_clust = findClosestCluster(posAtEcal, clusters);
+
+                if (cand_clust != null) {
+
+                    // track matching requirement
+                    if(Math.abs( posAtEcal.x() - cand_clust.getPosition()[0])<30.0 && 
+                            Math.abs( posAtEcal.y() - cand_clust.getPosition()[1])<30.0) 
+                    {
+                        clust = cand_clust;
+                        if(trk.getCharge()<0) pCanditates.put(trk, clust);
+                        else                  eCanditates.put(trk, clust);
+
+                        posAtEcal = TrackUtils.extrapolateTrack(trk, clust.getPosition()[2]);//.positionAtEcal();
+
+                        aida.histogram2D("Energy Vs Momentum").fill(clust.getEnergy(), trk.getTrackStates().get(0).getMomentum()[0]);
+                        aida.histogram1D("Energy Over Momentum").fill(clust.getEnergy() / (trk.getTrackStates().get(0).getMomentum()[0] ));
+                        aida.histogram1D("deltaX").fill(clust.getPosition()[0] - posAtEcal.x());
+                        aida.histogram1D("deltaY").fill(clust.getPosition()[1] - posAtEcal.y());
+                        aida.histogram2D("X ECal Vs Track").fill(clust.getPosition()[0], posAtEcal.x());
+                        aida.histogram2D("Y ECal Vs Track").fill(clust.getPosition()[1], posAtEcal.y());
+
+                        if (isTop == 0) {
+                            aida.histogram1D("Tracks matched Top").fill(1);
+                            if(trk.getTrackStates().get(0).getMomentum()[0] > 0.8){
+                                aida.histogram1D("Tracks matched Top (Pz>0.8)").fill(1);
+                            }
+
+                            aida.histogram2D("Top Energy Vs Momentum").fill(clust.getEnergy(), trk.getTrackStates().get(0).getMomentum()[0] );
+                            //                    aida.histogram2D("Top Energy Vs Momentum").fill(posAtEcal.y(), trk.getTrackStates().get(0).getMomentum()[0]);
+                            aida.histogram1D("Top Energy Over Momentum").fill(clust.getEnergy() / (trk.getTrackStates().get(0).getMomentum()[0]));
+                            aida.histogram1D("Top deltaX").fill(clust.getPosition()[0] - posAtEcal.x());
+                            aida.histogram1D("Top deltaY").fill(clust.getPosition()[1] - posAtEcal.y());
+                            aida.histogram2D("Top deltaX vs X").fill(clust.getPosition()[0], clust.getPosition()[0] - posAtEcal.x());
+                            aida.histogram2D("Top deltaY vs Y").fill(clust.getPosition()[1], clust.getPosition()[1] - posAtEcal.y());
+                            aida.histogram2D("Top X ECal Vs Track").fill(clust.getPosition()[0], posAtEcal.x());
+                            aida.histogram2D("Top Y ECal Vs Track").fill(clust.getPosition()[1], posAtEcal.y());
+                        } else {
+                            aida.histogram1D("Tracks matched Bottom").fill(1);
+                            if(trk.getTrackStates().get(0).getMomentum()[0] > 0.8){
+                                aida.histogram1D("Tracks matched Bottom (Pz>0.8)").fill(1);
+                            }
+                            aida.histogram2D("Bottom Energy Vs Momentum").fill(clust.getEnergy(), trk.getTrackStates().get(0).getMomentum()[0] );
+                            aida.histogram1D("Bottom Energy Over Momentum").fill(clust.getEnergy() / (trk.getTrackStates().get(0).getMomentum()[0]));
+                            aida.histogram1D("Bottom deltaX").fill(clust.getPosition()[0] - posAtEcal.x());
+                            aida.histogram1D("Bottom deltaY").fill(clust.getPosition()[1] - posAtEcal.y());
+                            aida.histogram2D("Bottom deltaX vs X").fill(clust.getPosition()[0], clust.getPosition()[0] - posAtEcal.x());
+                            aida.histogram2D("Bottom deltaY vs Y").fill(clust.getPosition()[1], clust.getPosition()[1] - posAtEcal.y());
+                            aida.histogram2D("Bottom X ECal Vs Track").fill(clust.getPosition()[0], posAtEcal.x());
+                            aida.histogram2D("Bottom Y ECal Vs Track").fill(clust.getPosition()[1], posAtEcal.y());
+                        }
+                    }
+                } 
+            }
+
+            if (clust != null) {
+                aida.histogram1D("Tracks matched").fill(0);
+                if(trk.getTrackStates().get(0).getMomentum()[0] > 0.8){
+                    aida.histogram1D("Tracks matched (Pz>0.8)").fill(0);
+                }
+                if(isTop == 0) {
+                    aida.histogram1D("Tracks matched Top").fill(0);
+                    if(trk.getTrackStates().get(0).getMomentum()[0] > 0.8){
+                        aida.histogram1D("Tracks matched Top (Pz>0.8)").fill(0);
+                    }
+                } else {
+                    aida.histogram1D("Tracks matched Bottom").fill(0);    
+                    if(trk.getTrackStates().get(0).getMomentum()[0] > 0.8){
+                        aida.histogram1D("Tracks matched Bottom (Pz>0.8)").fill(0);
+                    }
+                }
+            } else {
+                aida.histogram1D("Tracks matched").fill(1);
+                if(trk.getTrackStates().get(0).getMomentum()[0] > 0.8){
+                    aida.histogram1D("Tracks matched (Pz>0.8)").fill(1);
+                }
+
+                if (isTop == 0) {
+                    aida.histogram1D("Tracks matched Top").fill(1);
+                    if(trk.getTrackStates().get(0).getMomentum()[0] > 0.8){
+                        aida.histogram1D("Tracks matched Top (Pz>0.8)").fill(1);
+                    }
+                } else {
+                    aida.histogram1D("Tracks matched Bottom").fill(1);
+                    if(trk.getTrackStates().get(0).getMomentum()[0] > 0.8){
+                        aida.histogram1D("Tracks matched Bottom (Pz>0.8)").fill(1);
+                    }
+                }
+
+            }
+
+        }
+
+        // e+/e-
+        Map.Entry<Track, Cluster> ecand_highestP = null;
+        double e_pmax = -1;
+        Map.Entry<Track, Cluster> pcand_highestP = null;
+        double p_pmax = -1;
+        for(Map.Entry<Track, Cluster> ecand : eCanditates.entrySet()) {
+            double p = getMomentum(ecand.getKey());
+            aida.histogram1D("p(e-)").fill(p);
+            if(ecand_highestP == null ) {
+                ecand_highestP = ecand;
+                e_pmax = getMomentum(ecand_highestP.getKey());
+             } else {
+                if(p > e_pmax) {
+                    ecand_highestP = ecand;
+                    e_pmax = getMomentum(ecand_highestP.getKey());
+                }
+             }
+        }
+        
+        for(Map.Entry<Track, Cluster> pcand : pCanditates.entrySet()) {
+            double p = getMomentum(pcand.getKey());
+            aida.histogram1D("p(e+)").fill(p);
+            if(pcand_highestP == null ) {
+                pcand_highestP = pcand;
+                p_pmax = getMomentum(pcand_highestP.getKey());
+             } else {
+                if(p > p_pmax) {
+                    pcand_highestP = pcand;
+                    p_pmax = getMomentum(pcand_highestP.getKey());
+                }
+             }
+        }
+        
+        aida.histogram1D("n(e-)").fill(eCanditates.size());
+        aida.histogram1D("n(e+)").fill(pCanditates.size());
+        if(ecand_highestP!=null) {
+            aida.histogram1D("p(e-) max").fill(e_pmax);
+        }
+        if(pcand_highestP!=null) {
+            aida.histogram1D("p(e+) max").fill(p_pmax);
+        }
+        if(ecand_highestP!=null && pcand_highestP!=null) {
+            aida.histogram2D("p(e-) vs p(e+) max").fill(e_pmax, p_pmax);
+        }
+        
+        
+    }
+    
+    private double getMomentum(Track trk) {
+        double p = Math.sqrt(trk.getTrackStates().get(0).getMomentum()[0]*trk.getTrackStates().get(0).getMomentum()[0] +
+                trk.getTrackStates().get(0).getMomentum()[1]*trk.getTrackStates().get(0).getMomentum()[1] +
+             trk.getTrackStates().get(0).getMomentum()[2]*trk.getTrackStates().get(0).getMomentum()[2]);
+        return p;
     }
 
     public int[] getTrackHitsPerLayer(Track trk) {
-        int n[] = {0, 0, 0, 0, 0};
+        int n[] = {0, 0, 0, 0, 0, 0};
         List<TrackerHit> hitsOnTrack = trk.getTrackerHits();
         int layer;
         for (TrackerHit hit : hitsOnTrack) {
@@ -935,8 +1312,8 @@
         String name;
         int l;
         int i;
-        int n[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-        boolean ddd = true;
+        int n[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+        boolean ddd = false;
 
         if (ddd) {
             System.out.println("Get # hits per layer on side \"" + side + "\"");
@@ -1001,7 +1378,7 @@
                 System.out.println("sensor name  " + name + " --> layer " + l);
             }
 
-            if (l < 1 || l > 10) {
+            if (l < 1 || l > 12) {
                 System.out.println("This layer doesn't exist?");
                 throw new RuntimeException("SiSensor name " + name + " is invalid?");
             }
@@ -1027,6 +1404,8 @@
         //bottomFrame.dispose();
     }
 
+
+    
     private Cluster findClosestCluster(Hep3Vector posonhelix, List<Cluster> clusters) {
         Cluster closest = null;
         double minDist = 9999;
@@ -1034,16 +1413,13 @@
             double[] clPos = cluster.getPosition();
             double clEne = cluster.getEnergy();
             double dist = Math.sqrt(Math.pow(clPos[0] - posonhelix.x(), 2) + Math.pow(clPos[1] - posonhelix.y(), 2)); //coordinates!!!
-//            double dist = Math.sqrt(Math.pow(clPos[1] - posonhelix.z(), 2)); //coordinates!!!
-            if (dist < minDist && clEne > 50) {
+            double distX = Math.abs(clPos[0] - posonhelix.x());
+            double distY = Math.abs(clPos[1] - posonhelix.y());
+            if (dist < minDist && clEne > 0.4) {
                 closest = cluster;
                 minDist = dist;
             }
-//                    if(cluster.getEnergy()/10>500)
-        }
-//        System.out.println("Found a cluster..." + minDist);
-
+        }
         return closest;
-
     }
 }

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