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:

r2946 - in /java/trunk/analysis/src/main/java/org/hps/analysis/dataquality: FinalStateMonitoring.java PlotAndFitUtilities.java SVTOpeningStudies.java TrackingMonitoring.java V0Monitoring.java

From:

[log in to unmask]

Reply-To:

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

Date:

Mon, 11 May 2015 16:36:32 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (1245 lines)

Author: [log in to unmask]
Date: Mon May 11 09:36:24 2015
New Revision: 2946

Log:
Additions to DQM analysis 

Added:
    java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/PlotAndFitUtilities.java
      - copied, changed from r2846, java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/PlotAndFitUtilities.java
    java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/SVTOpeningStudies.java
      - copied, changed from r2846, java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/SVTOpeningAlignment.java
Modified:
    java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/FinalStateMonitoring.java
    java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TrackingMonitoring.java
    java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/V0Monitoring.java

Modified: java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/FinalStateMonitoring.java
 =============================================================================
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/FinalStateMonitoring.java	(original)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/FinalStateMonitoring.java	Mon May 11 09:36:24 2015
@@ -59,7 +59,6 @@
     double beamEnergy = 1.05; //GeV
     double maxFactor = 1.5;
     double feeMomentumCut = 0.8; //GeV
-   
 
     @Override
     protected void detectorChanged(Detector detector) {
@@ -111,7 +110,7 @@
                     if (!matchTriggerType(triggerData))//only process singles0 triggers...
                         return;
                 }
-        } else
+        } else if (debug)
             System.out.println(this.getClass().getSimpleName() + ":  No trigger bank found...running over all trigger types");
 
         nRecoEvents++;
@@ -228,10 +227,13 @@
         IFitter fitter = fitFactory.createFitter("chi2");
         IHistogram1D beamE = aida.histogram1D(plotDir + triggerType + "/" + "Beam Electrons Pz (GeV)");
         IFitResult result = fitBeamEnergyPeak(beamE, fitter, "range=\"(-10.0,10.0)\"");
-        double[] pars = result.fittedParameters();
-        for (int i = 0; i < 5; i++)
-            System.out.println("Beam Energy Peak:  " + result.fittedParameterNames()[i] + " = " + pars[i]);
-
+        if (result != null) {
+            double[] pars = result.fittedParameters();
+            for (int i = 0; i < 5; i++)
+                System.out.println("Beam Energy Peak:  " + result.fittedParameterNames()[i] + " = " + pars[i]);
+            monitoredQuantityMap.put(fpQuantNames[7], (double) pars[1]);
+            monitoredQuantityMap.put(fpQuantNames[8], (double) pars[2]);
+        }
         monitoredQuantityMap.put(fpQuantNames[0], (double) nTotEle / nRecoEvents);
         monitoredQuantityMap.put(fpQuantNames[1], (double) nTotPos / nRecoEvents);
         monitoredQuantityMap.put(fpQuantNames[2], (double) nTotPhotons / nRecoEvents);
@@ -239,8 +241,7 @@
         monitoredQuantityMap.put(fpQuantNames[4], (double) sumdelX / nTotAss);
         monitoredQuantityMap.put(fpQuantNames[5], (double) sumdelY / nTotAss);
         monitoredQuantityMap.put(fpQuantNames[6], (double) sumEoverP / nTotAss);
-        monitoredQuantityMap.put(fpQuantNames[7], (double) pars[1]);
-        monitoredQuantityMap.put(fpQuantNames[8], (double) pars[2]);
+
         IPlotter plotter = analysisFactory.createPlotterFactory().create("Beam Energy Electrons");
 
         IPlotterStyle pstyle = plotter.style();
@@ -248,7 +249,7 @@
         pstyle.dataStyle().fillStyle().setColor("green");
         pstyle.dataStyle().lineStyle().setColor("black");
         plotter.region(0).plot(beamE);
-        plotter.region(0).plot(result.fittedFunction());
+//        plotter.region(0).plot(result.fittedFunction());
         if (outputPlots)
             try {
                 plotter.writeToFile(outputPlotDir + "beamEnergyElectrons.png");
@@ -269,9 +270,14 @@
 //        return fitter.fit(h1d, "g+p1", init, range);
         double[] init = {20.0, 2.2, 0.12, 10, 0.0};
 //        double[] init = {20.0, 2.2, 0.1};
-        return fitter.fit(h1d, "g+p1", init);
-    }
-
-  
+        IFitResult ifr = null;
+        try {
+            ifr = fitter.fit(h1d, "g+p1", init);
+        } catch (RuntimeException ex) {
+            System.out.println(this.getClass().getSimpleName() + ":  caught exception in fitGaussian");
+        }
+
+        return ifr;
+    }
 
 }

Copied: java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/PlotAndFitUtilities.java (from r2846, java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/PlotAndFitUtilities.java)
 =============================================================================
--- java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/PlotAndFitUtilities.java	(original)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/PlotAndFitUtilities.java	Mon May 11 09:36:24 2015
@@ -1,4 +1,4 @@
-package org.hps.monitoring.drivers.trackrecon;
+package org.hps.analysis.dataquality;
 
 import hep.aida.IBaseHistogram;
 import hep.aida.ICloud1D;

Copied: java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/SVTOpeningStudies.java (from r2846, java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/SVTOpeningAlignment.java)
 =============================================================================
--- java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/SVTOpeningAlignment.java	(original)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/SVTOpeningStudies.java	Mon May 11 09:36:24 2015
@@ -1,36 +1,22 @@
-package org.hps.monitoring.drivers.trackrecon;
-
-import hep.aida.IAnalysisFactory;
-import hep.aida.IFitFactory;
-import hep.aida.IFitResult;
-import hep.aida.IFitter;
-import hep.aida.IFunction;
-import hep.aida.IFunctionFactory;
+package org.hps.analysis.dataquality;
+
 import hep.aida.IHistogram1D;
-import hep.aida.IPlotter;
-import hep.aida.IPlotterFactory;
-import hep.aida.IPlotterStyle;
-import java.io.IOException;
+import hep.aida.IHistogram2D;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import static org.hps.monitoring.drivers.trackrecon.PlotAndFitUtilities.fitAndPutParameters;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.Track;
 import org.lcsim.event.TrackState;
 import org.lcsim.event.TrackerHit;
 import org.lcsim.fit.helicaltrack.HelicalTrackHit;
 import org.lcsim.geometry.Detector;
-import org.lcsim.util.Driver;
 import org.lcsim.util.aida.AIDA;
-import static org.hps.monitoring.drivers.trackrecon.PlotAndFitUtilities.performGaussianFit;
 
 /**
  *
  * @author mgraham
  */
-public class SVTOpeningAlignment extends Driver {
+public class SVTOpeningStudies extends DataQualityMonitor {
 
     static private AIDA aida = AIDA.defaultInstance();
     private String helicalTrackHitCollectionName = "HelicalTrackHits";
@@ -38,8 +24,7 @@
     private String l1to3CollectionName = "L1to3Tracks";
     private String l4to6CollectionName = "L4to6Tracks";
     private String outputPlots = null;
-    IPlotter plotterTop;
-    IPlotter plotterBot;
+
     IHistogram1D nTracks46Top;
     IHistogram1D nTracks13Top;
     IHistogram1D nTracks46Bot;
@@ -55,23 +40,47 @@
     IHistogram1D dellambdaBot;
     IHistogram1D delz0Bot;
 
-    IPlotterFactory plotterFactory;
-    IFunctionFactory functionFactory;
-    IFitFactory fitFactory;
-    IFunction fd0Top;
-    IFunction fphi0Top;
-    IFunction fz0Top;
-    IFunction flambdaTop;
-    IFunction fwTop;
-    IFunction fd0Bot;
-    IFunction fphi0Bot;
-    IFunction fz0Bot;
-    IFunction flambdaBot;
-    IFunction fwBot;
-
-    IFitter jminChisq;
-
-    public SVTOpeningAlignment() {
+    IHistogram1D nTracks46Pos;
+    IHistogram1D nTracks13Pos;
+    IHistogram1D nTracks46Ele;
+    IHistogram1D nTracks13Ele;
+    IHistogram1D deld0Pos;
+    IHistogram1D delphiPos;
+    IHistogram1D delwPos;
+    IHistogram1D dellambdaPos;
+    IHistogram1D delz0Pos;
+    IHistogram1D deld0Ele;
+    IHistogram1D delphiEle;
+    IHistogram1D delwEle;
+    IHistogram1D dellambdaEle;
+    IHistogram1D delz0Ele;
+
+    IHistogram2D d0Ele;
+    IHistogram2D phiEle;
+    IHistogram2D wEle;
+    IHistogram2D lambdaEle;
+    IHistogram2D z0Ele;
+
+    IHistogram2D d0Pos;
+    IHistogram2D phiPos;
+    IHistogram2D wPos;
+    IHistogram2D lambdaPos;
+    IHistogram2D z0Pos;
+
+    IHistogram1D nCombosTop;
+    IHistogram1D nCombosBot;
+
+    double rangeD0 = 50;
+    double rangePhi0 = 0.25;
+    double rangeOmega = 0.00025;
+    double rangeSlope = 0.01;
+    double rangeZ0 = 10;
+
+    double pcut = 0.8;
+
+    private final String plotDir = "SVTOpening/";
+
+    public SVTOpeningStudies() {
     }
 
     public void setOutputPlots(String output) {
@@ -94,93 +103,57 @@
     protected void detectorChanged(Detector detector) {
         aida.tree().cd("/");
 
-        IAnalysisFactory fac = aida.analysisFactory();
-        IPlotterFactory pfac = fac.createPlotterFactory("SVT Alignment");
-        functionFactory = aida.analysisFactory().createFunctionFactory(null);
-        fitFactory = aida.analysisFactory().createFitFactory();
-        jminChisq = fitFactory.createFitter("chi2", "jminuit");
-
-        plotterTop = pfac.create("Top Layers");
-        IPlotterStyle style = plotterTop.style();
-        style.dataStyle().fillStyle().setColor("yellow");
-        style.dataStyle().errorBarStyle().setVisible(false);
-        style.legendBoxStyle().setVisible(false);
-        style.dataStyle().outlineStyle().setVisible(false);
-        plotterTop.createRegions(3, 3);
-        //plotterFrame.addPlotter(plotter);
-
-        IPlotterStyle functionStyle = pfac.createPlotterStyle();
-        functionStyle.dataStyle().lineStyle().setColor("red");
-        functionStyle.dataStyle().markerStyle().setVisible(true);
-        functionStyle.dataStyle().markerStyle().setColor("black");
-        functionStyle.dataStyle().markerStyle().setShape("dot");
-        functionStyle.dataStyle().markerStyle().setSize(2);
-
-        nTracks13Top = aida.histogram1D("Number of L1-3 Tracks: Top ", 7, 0, 7.0);
-        nTracks46Top = aida.histogram1D("Number of L4-6 Tracks: Top ", 7, 0, 7.0);
-
-        deld0Top = aida.histogram1D("Delta d0: Top", 50, -20.0, 20.0);
-        delphiTop = aida.histogram1D("Delta sin(phi): Top", 50, -0.1, 0.1);
-        delwTop = aida.histogram1D("Delta curvature: Top", 50, -0.0002, 0.0002);
-        dellambdaTop = aida.histogram1D("Delta slope: Top", 50, -0.02, 0.02);
-        delz0Top = aida.histogram1D("Delta y0: Top", 50, -5, 5.0);
-
-        fd0Top = functionFactory.createFunctionByName("Gaussian", "G");
-        fphi0Top = functionFactory.createFunctionByName("Gaussian", "G");
-        fwTop = functionFactory.createFunctionByName("Gaussian", "G");
-        flambdaTop = functionFactory.createFunctionByName("Gaussian", "G");
-        fz0Top = functionFactory.createFunctionByName("Gaussian", "G");
-
-        plotterTop.region(0).plot(deld0Top);
-        plotterTop.region(3).plot(delphiTop);
-        plotterTop.region(6).plot(delwTop);
-        plotterTop.region(1).plot(dellambdaTop);
-        plotterTop.region(4).plot(delz0Top);
-        plotterTop.region(2).plot(nTracks13Top);
-        plotterTop.region(5).plot(nTracks46Top);
-        plotterTop.region(0).plot(fd0Top, functionStyle);
-        plotterTop.region(3).plot(fphi0Top, functionStyle);
-        plotterTop.region(6).plot(fwTop, functionStyle);
-        plotterTop.region(1).plot(flambdaTop, functionStyle);
-        plotterTop.region(4).plot(fz0Top, functionStyle);
-        plotterTop.show();
-
-        plotterBot = pfac.create("Bottom Layers");
-        IPlotterStyle styleBot = plotterBot.style();
-        styleBot.legendBoxStyle().setVisible(false);
-        styleBot.dataStyle().fillStyle().setColor("yellow");
-        styleBot.dataStyle().errorBarStyle().setVisible(false);
-        styleBot.dataStyle().outlineStyle().setVisible(false);
-        plotterBot.createRegions(3, 3);
-
-        nTracks13Bot = aida.histogram1D("Number of L1-3 Tracks: Bot ", 7, 0, 7.0);
-        nTracks46Bot = aida.histogram1D("Number of L4-6 Tracks: Bot ", 7, 0, 7.0);
-
-        deld0Bot = aida.histogram1D("Delta d0: Bot", 50, -20.0, 20.0);
-        delphiBot = aida.histogram1D("Delta sin(phi): Bot", 50, -0.1, 0.1);
-        delwBot = aida.histogram1D("Delta curvature: Bot", 50, -0.0002, 0.0002);
-        dellambdaBot = aida.histogram1D("Delta slope: Bot", 50, -0.02, 0.02);
-        delz0Bot = aida.histogram1D("Delta y0: Bot", 50, -5, 5.0);
-
-        fd0Bot = functionFactory.createFunctionByName("Gaussian", "G");
-        fphi0Bot = functionFactory.createFunctionByName("Gaussian", "G");
-        fwBot = functionFactory.createFunctionByName("Gaussian", "G");
-        flambdaBot = functionFactory.createFunctionByName("Gaussian", "G");
-        fz0Bot = functionFactory.createFunctionByName("Gaussian", "G");
-
-        plotterBot.region(0).plot(deld0Bot);
-        plotterBot.region(3).plot(delphiBot);
-        plotterBot.region(6).plot(delwBot);
-        plotterBot.region(1).plot(dellambdaBot);
-        plotterBot.region(4).plot(delz0Bot);
-        plotterBot.region(2).plot(nTracks13Bot);
-        plotterBot.region(5).plot(nTracks46Bot);
-        plotterBot.region(0).plot(fd0Bot, functionStyle);
-        plotterBot.region(3).plot(fphi0Bot, functionStyle);
-        plotterBot.region(6).plot(fwBot, functionStyle);
-        plotterBot.region(1).plot(flambdaBot, functionStyle);
-        plotterBot.region(4).plot(fz0Bot, functionStyle);
-        plotterBot.show();
+        nTracks13Top = aida.histogram1D(plotDir + "Number of L1-3 Tracks: Top ", 7, 0, 7.0);
+        nTracks46Top = aida.histogram1D(plotDir + "Number of L4-6 Tracks: Top ", 7, 0, 7.0);
+
+        deld0Top = aida.histogram1D(plotDir + "Delta d0: Top", 50, -rangeD0, rangeD0);
+        delphiTop = aida.histogram1D(plotDir + "Delta sin(phi): Top", 50, -rangePhi0, rangePhi0);
+        delwTop = aida.histogram1D(plotDir + "Delta curvature: Top", 50, -rangeOmega, rangeOmega);
+        dellambdaTop = aida.histogram1D(plotDir + "Delta slope: Top", 50, -rangeSlope, rangeSlope);
+        delz0Top = aida.histogram1D(plotDir + "Delta y0: Top", 50, -rangeZ0, rangeZ0);
+
+        nTracks13Bot = aida.histogram1D(plotDir + "Number of L1-3 Tracks: Bot ", 7, 0, 7.0);
+        nTracks46Bot = aida.histogram1D(plotDir + "Number of L4-6 Tracks: Bot ", 7, 0, 7.0);
+
+        deld0Bot = aida.histogram1D(plotDir + "Delta d0: Bot", 50, -rangeD0, rangeD0);
+        delphiBot = aida.histogram1D(plotDir + "Delta sin(phi): Bot", 50, -rangePhi0, rangePhi0);
+        delwBot = aida.histogram1D(plotDir + "Delta curvature: Bot", 50, -rangeOmega, rangeOmega);
+        dellambdaBot = aida.histogram1D(plotDir + "Delta slope: Bot", 50, -rangeSlope, rangeSlope);
+        delz0Bot = aida.histogram1D(plotDir + "Delta y0: Bot", 50, -rangeZ0, rangeZ0);
+
+        nTracks13Ele = aida.histogram1D(plotDir + "Number of L1-3 Tracks: Ele ", 7, 0, 7.0);
+        nTracks46Ele = aida.histogram1D(plotDir + "Number of L4-6 Tracks: Ele ", 7, 0, 7.0);
+
+        deld0Ele = aida.histogram1D(plotDir + "Delta d0: Ele", 50, -rangeD0, rangeD0);
+        delphiEle = aida.histogram1D(plotDir + "Delta sin(phi): Ele", 50, -rangePhi0, rangePhi0);
+        delwEle = aida.histogram1D(plotDir + "Delta curvature: Ele", 50, -rangeOmega, rangeOmega);
+        dellambdaEle = aida.histogram1D(plotDir + "Delta slope: Ele", 50, -rangeSlope, rangeSlope);
+        delz0Ele = aida.histogram1D(plotDir + "Delta y0: Ele", 50, -rangeZ0, rangeZ0);
+
+        nTracks13Pos = aida.histogram1D(plotDir + "Number of L1-3 Tracks: Pos ", 7, 0, 7.0);
+        nTracks46Pos = aida.histogram1D(plotDir + "Number of L4-6 Tracks: Pos ", 7, 0, 7.0);
+
+        deld0Pos = aida.histogram1D(plotDir + "Delta d0: Pos", 50, -rangeD0, rangeD0);
+        delphiPos = aida.histogram1D(plotDir + "Delta sin(phi): Pos", 50, -rangePhi0, rangePhi0);
+        delwPos = aida.histogram1D(plotDir + "Delta curvature: Pos", 50, -rangeOmega, rangeOmega);
+        dellambdaPos = aida.histogram1D(plotDir + "Delta slope: Pos", 50, -rangeSlope, rangeSlope);
+        delz0Pos = aida.histogram1D(plotDir + "Delta y0: Pos", 50, -rangeZ0, rangeZ0);
+
+        d0Ele = aida.histogram2D(plotDir + "electrons d0: L46vs L13", 50, -rangeD0, rangeD0, 50, -rangeD0, rangeD0);
+        phiEle = aida.histogram2D(plotDir + "electrons sin(phi): L46vs L13", 50, -rangePhi0, rangePhi0, 50, -rangePhi0, rangePhi0);
+        wEle = aida.histogram2D(plotDir + "electrons curvature: L46vs L13", 50, -rangeOmega, rangeOmega, 50, -rangeOmega, rangeOmega);
+        lambdaEle = aida.histogram2D(plotDir + "electrons slope: L46vs L13", 50, -10 * rangeSlope, 10 * rangeSlope, 50, -10 * rangeSlope, 10 * rangeSlope);
+        z0Ele = aida.histogram2D(plotDir + "electrons y0: L46vs L13", 50, -rangeZ0, rangeZ0, 50, -rangeZ0, rangeZ0);
+
+        d0Pos = aida.histogram2D(plotDir + "positrons d0: L46vs L13", 50, -rangeD0, rangeD0, 50, -rangeD0, rangeD0);
+        phiPos = aida.histogram2D(plotDir + "positrons sin(phi): L46vs L13", 50, -rangePhi0, rangePhi0, 50, -rangePhi0, rangePhi0);
+        wPos = aida.histogram2D(plotDir + "positrons curvature: L46vs L13", 50, -rangeOmega, rangeOmega, 50, -rangeOmega, rangeOmega);
+        lambdaPos = aida.histogram2D(plotDir + "positrons slope: L46vs L13", 50, -10 * rangeSlope, 10 * rangeSlope, 50, -10 * rangeSlope, 10 * rangeSlope);
+        z0Pos = aida.histogram2D(plotDir + "positrons y0: L46vs L13", 50, -rangeZ0, rangeZ0, 50, -rangeZ0, rangeZ0);
+
+        nCombosTop = aida.histogram1D(plotDir + "Number of Combinations: Top", 7, 0, 7.0);
+        nCombosBot = aida.histogram1D(plotDir + "Number of Combinations: Bot", 7, 0, 7.0);
+
     }
 
     @Override
@@ -203,59 +176,106 @@
         List<Track> l4to6tracksTop = splitTrackList(l4to6tracks, true);
         List<Track> l4to6tracksBot = splitTrackList(l4to6tracks, false);
 
+        List<Track> l1to3tracksEle = splitByCharge(l1to3tracks, -1);
+        List<Track> l1to3tracksPos = splitByCharge(l1to3tracks, 1);
+        List<Track> l4to6tracksEle = splitByCharge(l4to6tracks, -1);
+        List<Track> l4to6tracksPos = splitByCharge(l4to6tracks, 1);
+
         nTracks13Top.fill(l1to3tracksTop.size());
         nTracks13Bot.fill(l1to3tracksBot.size());
         nTracks46Top.fill(l4to6tracksTop.size());
         nTracks46Bot.fill(l4to6tracksBot.size());
 
+        nTracks13Ele.fill(l1to3tracksEle.size());
+        nTracks13Pos.fill(l1to3tracksPos.size());
+        nTracks46Ele.fill(l4to6tracksEle.size());
+        nTracks46Pos.fill(l4to6tracksPos.size());
+
+        int ncombotop = 0;
+        int ncombobot = 0;
+
         for (Track trk46 : l4to6tracksTop) {
             TrackState ts46 = trk46.getTrackStates().get(0);
-            for (Track trk13 : l1to3tracksTop) {
-                TrackState ts13 = trk13.getTrackStates().get(0);
-                deld0Top.fill(ts46.getD0() - ts13.getD0());
-                delphiTop.fill(Math.sin(ts46.getPhi()) - Math.sin(ts13.getPhi()));
-                delwTop.fill(ts46.getOmega() - ts13.getOmega());
-                delz0Top.fill(ts46.getZ0() - ts13.getZ0());
-                dellambdaTop.fill(ts46.getTanLambda() - ts13.getTanLambda());
-            }
-        }
-        fitAndPutParameters(deld0Top, fd0Top);
-        fitAndPutParameters(delphiTop, fphi0Top);
-        fitAndPutParameters(delwTop, fwTop);
-        fitAndPutParameters(delz0Top, fz0Top);
-        fitAndPutParameters(dellambdaTop, flambdaTop);
+            for (Track trk13 : l1to3tracksTop)
+                if (trk46.getMomentum()[0] > pcut && trk13.getMomentum()[0] > pcut) {
+                    TrackState ts13 = trk13.getTrackStates().get(0);
+                    deld0Top.fill(ts46.getD0() - ts13.getD0());
+                    delphiTop.fill(Math.sin(ts46.getPhi()) - Math.sin(ts13.getPhi()));
+                    delwTop.fill(ts46.getOmega() - ts13.getOmega());
+                    delz0Top.fill(ts46.getZ0() - ts13.getZ0());
+                    dellambdaTop.fill(ts46.getTanLambda() - ts13.getTanLambda());
+                    ncombotop++;
+                }
+        }
 
         for (Track trk46 : l4to6tracksBot) {
             TrackState ts46 = trk46.getTrackStates().get(0);
-            for (Track trk13 : l1to3tracksBot) {
+            for (Track trk13 : l1to3tracksBot)
+                if (trk46.getMomentum()[0] > pcut && trk13.getMomentum()[0] > pcut) {
+                    TrackState ts13 = trk13.getTrackStates().get(0);
+                    deld0Bot.fill(ts46.getD0() - ts13.getD0());
+                    delphiBot.fill(Math.sin(ts46.getPhi()) - Math.sin(ts13.getPhi()));
+                    delwBot.fill(ts46.getOmega() - ts13.getOmega());
+                    delz0Bot.fill(ts46.getZ0() - ts13.getZ0());
+                    dellambdaBot.fill(ts46.getTanLambda() - ts13.getTanLambda());
+                    ncombobot++;
+                }
+        }
+
+        nCombosTop.fill(ncombotop);
+        nCombosBot.fill(ncombobot);
+
+        for (Track trk46 : l4to6tracksEle) {
+            TrackState ts46 = trk46.getTrackStates().get(0);
+            for (Track trk13 : l1to3tracksEle) {
                 TrackState ts13 = trk13.getTrackStates().get(0);
-                deld0Bot.fill(ts46.getD0() - ts13.getD0());
-                delphiBot.fill(Math.sin(ts46.getPhi()) - Math.sin(ts13.getPhi()));
-                delwBot.fill(ts46.getOmega() - ts13.getOmega());
-                delz0Bot.fill(ts46.getZ0() - ts13.getZ0());
-                dellambdaBot.fill(ts46.getTanLambda() - ts13.getTanLambda());
+                deld0Ele.fill(ts46.getD0() - ts13.getD0());
+                delphiEle.fill(Math.sin(ts46.getPhi()) - Math.sin(ts13.getPhi()));
+                delwEle.fill(ts46.getOmega() - ts13.getOmega());
+                delz0Ele.fill(ts46.getZ0() - ts13.getZ0());
+                dellambdaEle.fill(ts46.getTanLambda() - ts13.getTanLambda());
+                d0Ele.fill(ts46.getD0(), ts13.getD0());
+                phiEle.fill(Math.sin(ts46.getPhi()), Math.sin(ts13.getPhi()));
+                wEle.fill(ts46.getOmega(), ts13.getOmega());
+                lambdaEle.fill(ts46.getTanLambda(), ts13.getTanLambda());
+                z0Ele.fill(ts46.getZ0(), ts13.getZ0());
+
             }
         }
 
-//        IFunction currentFitFunction = performGaussianFit(deld0Bot, fd0Bot, jminChisq).fittedFunction();;
-//         fd0Bot.setParameters(currentFitFunction.parameters());
-        fitAndPutParameters(deld0Bot, fd0Bot);
-        fitAndPutParameters(delphiBot, fphi0Bot);
-        fitAndPutParameters(delwBot, fwBot);
-        fitAndPutParameters(delz0Bot, fz0Bot);
-        fitAndPutParameters(dellambdaBot, flambdaBot);
-
+        for (Track trk46 : l4to6tracksPos) {
+            TrackState ts46 = trk46.getTrackStates().get(0);
+            for (Track trk13 : l1to3tracksPos) {
+                TrackState ts13 = trk13.getTrackStates().get(0);
+                deld0Pos.fill(ts46.getD0() - ts13.getD0());
+                delphiPos.fill(Math.sin(ts46.getPhi()) - Math.sin(ts13.getPhi()));
+                delwPos.fill(ts46.getOmega() - ts13.getOmega());
+                delz0Pos.fill(ts46.getZ0() - ts13.getZ0());
+                dellambdaPos.fill(ts46.getTanLambda() - ts13.getTanLambda());
+                d0Pos.fill(ts46.getD0(), ts13.getD0());
+                phiPos.fill(Math.sin(ts46.getPhi()), Math.sin(ts13.getPhi()));
+                wPos.fill(ts46.getOmega(), ts13.getOmega());
+                lambdaPos.fill(ts46.getTanLambda(), ts13.getTanLambda());
+                z0Pos.fill(ts46.getZ0(), ts13.getZ0());
+            }
+        }
+
+        /*
+         l1to3tracksPos = null;
+         l1to3tracksEle = null;
+         l1to3tracksTop = null;
+         l1to3tracksBot = null;
+
+         l4to6tracksPos = null;
+         l4to6tracksEle = null;
+         l4to6tracksTop = null;
+         l4to6tracksBot = null;
+         */
     }
 
     @Override
     public void endOfData() {
-        if (outputPlots != null)
-            try {
-                plotterTop.writeToFile(outputPlots + "-deltasTop.gif");
-                plotterBot.writeToFile(outputPlots + "-deltasBottom.gif");
-            } catch (IOException ex) {
-                Logger.getLogger(TrackingReconPlots.class.getName()).log(Level.SEVERE, null, ex);
-            }
+
     }
 
     private List<Track> splitTrackList(List<Track> trks, boolean doTop) {
@@ -277,4 +297,26 @@
         }
         return tracksHalf;
     }
+
+    private List<Track> splitByCharge(List<Track> trks, int charge) {
+        List<Track> tracksHalf = new ArrayList<>();
+        boolean isTop = false;
+        boolean isBot = false;
+        for (Track trk : trks) {
+            isTop = false;
+            isBot = false;
+            if (!(trk.getCharge() == charge)) { //XNOR but remember that the track charge is opposite because of B-field definition...
+                for (TrackerHit hit : trk.getTrackerHits())
+                    if (hit.getPosition()[2] > 0)//remember, non-bend in tracking frame is z-direction
+                        isTop = true;
+                    else
+                        isBot = true;
+                if (isTop == true && isBot != true)  //if  all hits are in top
+                    tracksHalf.add(trk);
+                if (isBot == true && isTop != true) //if all hits are in bottom
+                    tracksHalf.add(trk);
+            }
+        }
+        return tracksHalf;
+    }
 }

Modified: java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TrackingMonitoring.java
 =============================================================================
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TrackingMonitoring.java	(original)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TrackingMonitoring.java	Mon May 11 09:36:24 2015
@@ -5,11 +5,13 @@
 import hep.aida.IFitter;
 import hep.aida.IHistogram1D;
 import hep.aida.IHistogram2D;
+import hep.physics.vec.Hep3Vector;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import org.hps.recon.ecal.triggerbank.AbstractIntData;
 import org.hps.recon.ecal.triggerbank.TIData;
+import org.hps.recon.tracking.TrackUtils;
 import org.lcsim.detector.tracker.silicon.HpsSiSensor;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.GenericObject;
@@ -65,6 +67,9 @@
     IHistogram2D[] xvsyTop = new IHistogram2D[nmodules];
     IHistogram2D[] xvsyBot = new IHistogram2D[nmodules];
 
+    IHistogram1D trkYAtECALTop;
+    IHistogram1D trkYAtECALBot;
+
     IHistogram1D trkChi2Pos;
     IHistogram1D trkChi2Ele;
     IHistogram1D trkChi2Top;
@@ -118,18 +123,20 @@
         this.detector = detector;
         aida.tree().cd("/");
 
-        IHistogram1D trkChi2 = aida.histogram1D(plotDir + triggerType + "/" + "Track Chi2", 25, 0, 25.0);
-        IHistogram1D nTracks = aida.histogram1D(plotDir + triggerType + "/" + "Tracks per Event", 6, 0, 6);
-        IHistogram1D trkd0 = aida.histogram1D(plotDir + triggerType + "/" + "d0 ", 25, -5.0, 5.0);
-        IHistogram1D trkphi = aida.histogram1D(plotDir + triggerType + "/" + "sinphi ", 25, -0.2, 0.2);
-        IHistogram1D trkomega = aida.histogram1D(plotDir + triggerType + "/" + "omega ", 25, -0.0005, 0.0005);
-        IHistogram1D trklam = aida.histogram1D(plotDir + triggerType + "/" + "tan(lambda) ", 25, -0.1, 0.1);
-        IHistogram1D trkz0 = aida.histogram1D(plotDir + triggerType + "/" + "z0 ", 25, -1.0, 1.0);
-        IHistogram1D nHits = aida.histogram1D(plotDir + triggerType + "/" + "Hits per Track", 2, 5, 7);
-        IHistogram1D trackMeanTime = aida.histogram1D(plotDir + triggerType + "/" + "Mean time of hits on track", 100, -10., 100.);
-        IHistogram1D trackRMSTime = aida.histogram1D(plotDir + triggerType + "/" + "RMS time of hits on track", 100, 0., 15.);
-        IHistogram2D trackChi2RMSTime = aida.histogram2D(plotDir + triggerType + "/" + "Track chi2 vs. RMS time of hits", 100, 0., 15., 25, 0, 25.0);
-        IHistogram1D seedRMSTime = aida.histogram1D(plotDir + triggerType + "/" + "RMS time of hits on seed layers", 100, 0., 15.);
+        IHistogram1D trkChi2 = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Track Chi2", 25, 0, 25.0);
+        IHistogram1D nTracks = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Tracks per Event", 6, 0, 6);
+        IHistogram1D trkd0 = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "d0 ", 25, -5.0, 5.0);
+        IHistogram1D trkphi = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "sinphi ", 25, -0.2, 0.2);
+        IHistogram1D trkomega = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "omega ", 25, -0.0005, 0.0005);
+        IHistogram1D trklam = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "tan(lambda) ", 25, -0.1, 0.1);
+        IHistogram1D trkz0 = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "z0 ", 25, -1.0, 1.0);
+        IHistogram1D nHits = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Hits per Track", 4, 3, 7);
+        IHistogram1D trackMeanTime = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Mean time of hits on track", 100, -10., 100.);
+        IHistogram1D trackRMSTime = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "RMS time of hits on track", 100, 0., 15.);
+        IHistogram2D trackChi2RMSTime = aida.histogram2D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Track chi2 vs. RMS time of hits", 100, 0., 15., 25, 0, 25.0);
+        IHistogram1D seedRMSTime = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "RMS time of hits on seed layers", 100, 0., 15.);
+        trkYAtECALTop = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Track Y at ECAL: Top", 100, 0, 100);
+        trkYAtECALBot = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Track Y at ECAL: Bot", 100, 0, 100);
         for (int i = 1; i <= nmodules; i++) {
             xvsyTop[i - 1] = aida.histogram2D(hthplotDir + "Module " + i + " Top", 50, -100, 100, 50, 0, 40);
             xvsyBot[i - 1] = aida.histogram2D(hthplotDir + "Module " + i + " Bottom", 50, -100, 100, 50, 0, 40);
@@ -137,41 +144,41 @@
             hthBot[i - 1] = aida.histogram1D(hthplotDir + "Module " + i + "Bot: Track Hits", 25, 0, 25);
         }
 
-        trkChi2Pos = aida.histogram1D(plotDir + triggerType + "/" + positronDir + "Track Chi2", 25, 0, 25.0);
-        nTracksPos = aida.histogram1D(plotDir + triggerType + "/" + positronDir + "Tracks per Event", 6, 0, 6);
-        trkd0Pos = aida.histogram1D(plotDir + triggerType + "/" + positronDir + "d0 ", 25, -5.0, 5.0);
-        trkphiPos = aida.histogram1D(plotDir + triggerType + "/" + positronDir + "sinphi ", 25, -0.2, 0.2);
-        trkomegaPos = aida.histogram1D(plotDir + triggerType + "/" + positronDir + "omega ", 25, -0.0005, 0.0005);
-        trklamPos = aida.histogram1D(plotDir + triggerType + "/" + positronDir + "tan(lambda) ", 25, -0.1, 0.1);
-        trkz0Pos = aida.histogram1D(plotDir + triggerType + "/" + positronDir + "z0 ", 25, -1.0, 1.0);
-        nHitsPos = aida.histogram1D(plotDir + triggerType + "/" + positronDir + "Hits per Track", 2, 5, 7);
-
-        trkChi2Ele = aida.histogram1D(plotDir + triggerType + "/" + electronDir + "Track Chi2", 25, 0, 25.0);
-        nTracksEle = aida.histogram1D(plotDir + triggerType + "/" + electronDir + "Tracks per Event", 6, 0, 6);
-        trkd0Ele = aida.histogram1D(plotDir + triggerType + "/" + electronDir + "d0 ", 25, -5.0, 5.0);
-        trkphiEle = aida.histogram1D(plotDir + triggerType + "/" + electronDir + "sinphi ", 25, -0.2, 0.2);
-        trkomegaEle = aida.histogram1D(plotDir + triggerType + "/" + electronDir + "omega ", 25, -0.0005, 0.0005);
-        trklamEle = aida.histogram1D(plotDir + triggerType + "/" + electronDir + "tan(lambda) ", 25, -0.1, 0.1);
-        trkz0Ele = aida.histogram1D(plotDir + triggerType + "/" + electronDir + "z0 ", 25, -1.0, 1.0);
-        nHitsEle = aida.histogram1D(plotDir + triggerType + "/" + electronDir + "Hits per Track", 2, 5, 7);
-
-        trkChi2Top = aida.histogram1D(plotDir + triggerType + "/" + topDir + "Track Chi2", 25, 0, 25.0);
-        nTracksTop = aida.histogram1D(plotDir + triggerType + "/" + topDir + "Tracks per Event", 6, 0, 6);
-        trkd0Top = aida.histogram1D(plotDir + triggerType + "/" + topDir + "d0 ", 25, -5.0, 5.0);
-        trkphiTop = aida.histogram1D(plotDir + triggerType + "/" + topDir + "sinphi ", 25, -0.2, 0.2);
-        trkomegaTop = aida.histogram1D(plotDir + triggerType + "/" + topDir + "omega ", 25, -0.0005, 0.0005);
-        trklamTop = aida.histogram1D(plotDir + triggerType + "/" + topDir + "tan(lambda) ", 25, -0.1, 0.1);
-        trkz0Top = aida.histogram1D(plotDir + triggerType + "/" + topDir + "z0 ", 25, -1.0, 1.0);
-        nHitsTop = aida.histogram1D(plotDir + triggerType + "/" + topDir + "Hits per Track", 2, 5, 7);
-
-        trkChi2Bot = aida.histogram1D(plotDir + triggerType + "/" + botDir + "Track Chi2", 25, 0, 25.0);
-        nTracksBot = aida.histogram1D(plotDir + triggerType + "/" + botDir + "Tracks per Event", 6, 0, 6);
-        trkd0Bot = aida.histogram1D(plotDir + triggerType + "/" + botDir + "d0 ", 25, -5.0, 5.0);
-        trkphiBot = aida.histogram1D(plotDir + triggerType + "/" + botDir + "sinphi ", 25, -0.2, 0.2);
-        trkomegaBot = aida.histogram1D(plotDir + triggerType + "/" + botDir + "omega ", 25, -0.0005, 0.0005);
-        trklamBot = aida.histogram1D(plotDir + triggerType + "/" + botDir + "tan(lambda) ", 25, -0.1, 0.1);
-        trkz0Bot = aida.histogram1D(plotDir + triggerType + "/" + botDir + "z0 ", 25, -1.0, 1.0);
-        nHitsBot = aida.histogram1D(plotDir + triggerType + "/" + botDir + "Hits per Track", 2, 5, 7);
+        trkChi2Pos = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + positronDir + "Track Chi2", 25, 0, 25.0);
+        nTracksPos = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + positronDir + "Tracks per Event", 6, 0, 6);
+        trkd0Pos = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + positronDir + "d0 ", 25, -5.0, 5.0);
+        trkphiPos = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + positronDir + "sinphi ", 25, -0.2, 0.2);
+        trkomegaPos = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + positronDir + "omega ", 25, -0.0005, 0.0005);
+        trklamPos = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + positronDir + "tan(lambda) ", 25, -0.1, 0.1);
+        trkz0Pos = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + positronDir + "z0 ", 25, -1.0, 1.0);
+        nHitsPos = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + positronDir + "Hits per Track", 4, 3, 7);
+
+        trkChi2Ele = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + electronDir + "Track Chi2", 25, 0, 25.0);
+        nTracksEle = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + electronDir + "Tracks per Event", 6, 0, 6);
+        trkd0Ele = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + electronDir + "d0 ", 25, -5.0, 5.0);
+        trkphiEle = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + electronDir + "sinphi ", 25, -0.2, 0.2);
+        trkomegaEle = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + electronDir + "omega ", 25, -0.0005, 0.0005);
+        trklamEle = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + electronDir + "tan(lambda) ", 25, -0.1, 0.1);
+        trkz0Ele = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + electronDir + "z0 ", 25, -1.0, 1.0);
+        nHitsEle = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + electronDir + "Hits per Track", 4, 3, 7);
+
+        trkChi2Top = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + topDir + "Track Chi2", 25, 0, 25.0);
+        nTracksTop = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + topDir + "Tracks per Event", 6, 0, 6);
+        trkd0Top = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + topDir + "d0 ", 25, -5.0, 5.0);
+        trkphiTop = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + topDir + "sinphi ", 25, -0.2, 0.2);
+        trkomegaTop = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + topDir + "omega ", 25, -0.0005, 0.0005);
+        trklamTop = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + topDir + "tan(lambda) ", 50, 0.0, 0.1);
+        trkz0Top = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + topDir + "z0 ", 25, -1.0, 1.0);
+        nHitsTop = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + topDir + "Hits per Track", 4, 3, 7);
+
+        trkChi2Bot = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + botDir + "Track Chi2", 25, 0, 25.0);
+        nTracksBot = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + botDir + "Tracks per Event", 6, 0, 6);
+        trkd0Bot = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + botDir + "d0 ", 25, -5.0, 5.0);
+        trkphiBot = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + botDir + "sinphi ", 25, -0.2, 0.2);
+        trkomegaBot = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + botDir + "omega ", 25, -0.0005, 0.0005);
+        trklamBot = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + botDir + "tan(lambda) ", 50, 0, 0.1);
+        trkz0Bot = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + botDir + "z0 ", 25, -1.0, 1.0);
+        nHitsBot = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + botDir + "Hits per Track", 4, 3, 7);
 
         // Make a list of SiSensors in the SVT.
         sensors = this.detector.getSubdetector(trackerName).getDetectorElement().findDescendants(HpsSiSensor.class);
@@ -190,99 +197,97 @@
 
         aida.tree().cd("/");
 
-        if (!event.hasCollection(LCRelation.class, helicalTrackHitRelationsCollectionName) || !event.hasCollection(LCRelation.class, rotatedHelicalTrackHitRelationsCollectionName)) {
+        if (!event.hasCollection(LCRelation.class, helicalTrackHitRelationsCollectionName) || !event.hasCollection(LCRelation.class, rotatedHelicalTrackHitRelationsCollectionName))
             return;
-        }
         RelationalTable hittostrip = new BaseRelationalTable(RelationalTable.Mode.MANY_TO_MANY, RelationalTable.Weighting.UNWEIGHTED);
         List<LCRelation> hitrelations = event.get(LCRelation.class, helicalTrackHitRelationsCollectionName);
-        for (LCRelation relation : hitrelations) {
-            if (relation != null && relation.getFrom() != null && relation.getTo() != null) {
+        for (LCRelation relation : hitrelations)
+            if (relation != null && relation.getFrom() != null && relation.getTo() != null)
                 hittostrip.add(relation.getFrom(), relation.getTo());
-            }
-        }
 
         RelationalTable hittorotated = new BaseRelationalTable(RelationalTable.Mode.ONE_TO_ONE, RelationalTable.Weighting.UNWEIGHTED);
         List<LCRelation> rotaterelations = event.get(LCRelation.class, rotatedHelicalTrackHitRelationsCollectionName);
-        for (LCRelation relation : rotaterelations) {
-            if (relation != null && relation.getFrom() != null && relation.getTo() != null) {
+        for (LCRelation relation : rotaterelations)
+            if (relation != null && relation.getFrom() != null && relation.getTo() != null)
                 hittorotated.add(relation.getFrom(), relation.getTo());
-            }
-        }
-
-        if (!event.hasCollection(TrackerHit.class, helicalTrackHitCollectionName)) {
+
+        if (!event.hasCollection(TrackerHit.class, helicalTrackHitCollectionName))
             return;
-        }
 
         if (event.hasCollection(GenericObject.class, "TriggerBank")) {
             List<GenericObject> triggerList = event.get(GenericObject.class, "TriggerBank");
-            for (GenericObject data : triggerList) {
+            for (GenericObject data : triggerList)
                 if (AbstractIntData.getTag(data) == TIData.BANK_TAG) {
                     TIData triggerData = new TIData(data);
                     if (!matchTriggerType(triggerData))//only process singles0 triggers...
-                    {
+
                         return;
-                    }
                 }
-            }
-        } else {
+        } else if (debug)
             System.out.println(this.getClass().getSimpleName() + ":  No trigger bank found...running over all trigger types");
-        }
-
-        int[] topHits = {0, 0, 0, 0, 0, 0};
-        int[] botHits = {0, 0, 0, 0, 0, 0};
-        List<TrackerHit> hth = event.get(TrackerHit.class, helicalTrackHitCollectionName);
-        for (TrackerHit hit : hth) {
-            int module = -99;
-            int layer = ((RawTrackerHit) hit.getRawHits().get(0)).getLayerNumber();
-            if (layer < 2) {
-                module = 1;
-            } else if (layer < 4) {
-                module = 2;
-            } else if (layer < 6) {
-                module = 3;
-            } else if (layer < 8) {
-                module = 4;
-            } else if (layer < 10) {
-                module = 5;
-            } else {
-                module = 6;
-            }
-
-            if (hit.getPosition()[1] > 0) {
-                topHits[module - 1]++;
-                xvsyTop[module - 1].fill(hit.getPosition()[0], hit.getPosition()[1]);
-            } else {
-                botHits[module - 1]++;
-                xvsyBot[module - 1].fill(hit.getPosition()[0], Math.abs(hit.getPosition()[1]));
-            }
-        }
-
-        for (int i = 0; i < nmodules; i++) {
-            hthTop[i].fill(topHits[i]);
-            hthBot[i].fill(botHits[i]);
-        }
-
+        /*  This doesn't work on reco'ed files...fix me!
+         int[] topHits = {0, 0, 0, 0, 0, 0};
+         int[] botHits = {0, 0, 0, 0, 0, 0};
+         List<TrackerHit> hth = event.get(TrackerHit.class, helicalTrackHitCollectionName);
+         for (TrackerHit hit : hth) {           
+         int module = -99;
+         int layer = ((RawTrackerHit) hit.getRawHits().get(0)).getLayerNumber();
+         if (layer < 2) {
+         module = 1;
+         } else if (layer < 4) {
+         module = 2;
+         } else if (layer < 6) {
+         module = 3;
+         } else if (layer < 8) {
+         module = 4;
+         } else if (layer < 10) {
+         module = 5;
+         } else {
+         module = 6;
+         }
+
+         if (hit.getPosition()[1] > 0) {
+         topHits[module - 1]++;
+         xvsyTop[module - 1].fill(hit.getPosition()[0], hit.getPosition()[1]);
+         } else {
+         botHits[module - 1]++;
+         xvsyBot[module - 1].fill(hit.getPosition()[0], Math.abs(hit.getPosition()[1]));
+         }
+         }
+
+         for (int i = 0; i < nmodules; i++) {
+         hthTop[i].fill(topHits[i]);
+         hthBot[i].fill(botHits[i]);
+         }
+         */
         if (!event.hasCollection(Track.class, trackCollectionName)) {
-            aida.histogram1D(plotDir + triggerType + "/" + "Tracks per Event").fill(0);
+            aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Tracks per Event").fill(0);
             return;
         }
         nEvents++;
         List<Track> tracks = event.get(Track.class, trackCollectionName);
         nTotTracks += tracks.size();
-        aida.histogram1D(plotDir + triggerType + "/" + "Tracks per Event").fill(tracks.size());
+        aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Tracks per Event").fill(tracks.size());
         int cntEle = 0;
         int cntPos = 0;
         int cntTop = 0;
         int cntBot = 0;
+        double ecalFace = 1393.0;//mm
         for (Track trk : tracks) {
+            Hep3Vector trackPosAtEcalFace = TrackUtils.extrapolateTrack(trk, ecalFace);
+            double yAtECal = trackPosAtEcalFace.y();
+            if (yAtECal > 0)
+                trkYAtECALTop.fill(yAtECal);
+            else
+                trkYAtECALBot.fill(Math.abs(yAtECal));
             nTotHits += trk.getTrackerHits().size();
-            aida.histogram1D(plotDir + triggerType + "/" + "Track Chi2").fill(trk.getChi2());
-            aida.histogram1D(plotDir + triggerType + "/" + "Hits per Track").fill(trk.getTrackerHits().size());
-            aida.histogram1D(plotDir + triggerType + "/" + "d0 ").fill(trk.getTrackStates().get(0).getD0());
-            aida.histogram1D(plotDir + triggerType + "/" + "sinphi ").fill(Math.sin(trk.getTrackStates().get(0).getPhi()));
-            aida.histogram1D(plotDir + triggerType + "/" + "omega ").fill(trk.getTrackStates().get(0).getOmega());
-            aida.histogram1D(plotDir + triggerType + "/" + "tan(lambda) ").fill(trk.getTrackStates().get(0).getTanLambda());
-            aida.histogram1D(plotDir + triggerType + "/" + "z0 ").fill(trk.getTrackStates().get(0).getZ0());
+            aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Track Chi2").fill(trk.getChi2());
+            aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Hits per Track").fill(trk.getTrackerHits().size());
+            aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "d0 ").fill(trk.getTrackStates().get(0).getD0());
+            aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "sinphi ").fill(Math.sin(trk.getTrackStates().get(0).getPhi()));
+            aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "omega ").fill(trk.getTrackStates().get(0).getOmega());
+            aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "tan(lambda) ").fill(trk.getTrackStates().get(0).getTanLambda());
+            aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "z0 ").fill(trk.getTrackStates().get(0).getZ0());
             if (trk.getTrackStates().get(0).getOmega() < 0) {//positrons
                 trkChi2Pos.fill(trk.getChi2());
                 nHitsPos.fill(trk.getTrackerHits().size());
@@ -309,7 +314,7 @@
                 trkd0Bot.fill(trk.getTrackStates().get(0).getD0());
                 trkphiBot.fill(Math.sin(trk.getTrackStates().get(0).getPhi()));
                 trkomegaBot.fill(trk.getTrackStates().get(0).getOmega());
-                trklamBot.fill(trk.getTrackStates().get(0).getTanLambda());
+                trklamBot.fill(Math.abs(trk.getTrackStates().get(0).getTanLambda()));
                 trkz0Bot.fill(trk.getTrackStates().get(0).getZ0());
                 cntBot++;
             } else {
@@ -318,7 +323,7 @@
                 trkd0Top.fill(trk.getTrackStates().get(0).getD0());
                 trkphiTop.fill(Math.sin(trk.getTrackStates().get(0).getPhi()));
                 trkomegaTop.fill(trk.getTrackStates().get(0).getOmega());
-                trklamTop.fill(trk.getTrackStates().get(0).getTanLambda());
+                trklamTop.fill(Math.abs(trk.getTrackStates().get(0).getTanLambda()));
                 trkz0Top.fill(trk.getTrackStates().get(0).getZ0());
                 cntTop++;
             }
@@ -327,48 +332,49 @@
             sumz0 += trk.getTrackStates().get(0).getZ0();
             sumslope += Math.abs(trk.getTrackStates().get(0).getTanLambda());
             sumchisq += trk.getChi2();
-
-            int nStrips = 0;
-            int nSeedStrips = 0;
-            double meanTime = 0;
-            double meanSeedTime = 0;
-            for (TrackerHit hit : trk.getTrackerHits()) {
-                Collection<TrackerHit> htsList = hittostrip.allFrom(hittorotated.from(hit));
-                for (TrackerHit hts : htsList) {
-                    nStrips++;
-                    meanTime += hts.getTime();
-                    int layer = ((HpsSiSensor) ((RawTrackerHit) hts.getRawHits().get(0)).getDetectorElement()).getLayerNumber();
-                    if (layer <= 6) {
-                        nSeedStrips++;
-                        meanSeedTime += hts.getTime();
-                    }
-                }
-            }
-            meanTime /= nStrips;
-            meanSeedTime /= nSeedStrips;
-
-            double rmsTime = 0;
-            double rmsSeedTime = 0;
-            for (TrackerHit hit : trk.getTrackerHits()) {
-                Collection<TrackerHit> htsList = hittostrip.allFrom(hittorotated.from(hit));
-                for (TrackerHit hts : htsList) {
-                    rmsTime += Math.pow(hts.getTime() - meanTime, 2);
-                    HpsSiSensor sensor = (HpsSiSensor) ((RawTrackerHit) hts.getRawHits().get(0)).getDetectorElement();
-                    int layer = sensor.getLayerNumber();
-                    if (layer <= 6) {
-                        rmsSeedTime += Math.pow(hts.getTime() - meanSeedTime, 2);
-                    }
-                    String sensorName = getNiceSensorName(sensor);
-                    getSensorPlot(plotDir + "hitTimeResidual_", sensorName).fill((hts.getTime() - meanTime) * nStrips / (nStrips - 1)); //correct residual for bias
-                }
-            }
-            rmsTime = Math.sqrt(rmsTime / nStrips);
-            aida.histogram1D(plotDir + triggerType + "/" + "Mean time of hits on track").fill(meanTime);
-            aida.histogram1D(plotDir + triggerType + "/" + "RMS time of hits on track").fill(rmsTime);
-            aida.histogram2D(plotDir + triggerType + "/" + "Track chi2 vs. RMS time of hits").fill(rmsTime, trk.getChi2());
-
-            rmsSeedTime = Math.sqrt(rmsSeedTime / nSeedStrips);
-            aida.histogram1D(plotDir + triggerType + "/" + "RMS time of hits on seed layers").fill(rmsSeedTime);
+//below does not work on recon'ed files            
+//
+//            int nStrips = 0;
+//            int nSeedStrips = 0;
+//            double meanTime = 0;
+//            double meanSeedTime = 0;
+//            for (TrackerHit hit : trk.getTrackerHits()) {
+//                Collection<TrackerHit> htsList = hittostrip.allFrom(hittorotated.from(hit));
+//                for (TrackerHit hts : htsList) {
+//                    nStrips++;
+//                    meanTime += hts.getTime();
+//                    int layer = ((HpsSiSensor) ((RawTrackerHit) hts.getRawHits().get(0)).getDetectorElement()).getLayerNumber();
+//                    if (layer <= 6) {
+//                        nSeedStrips++;
+//                        meanSeedTime += hts.getTime();
+//                    }
+//                }
+//            }
+//            meanTime /= nStrips;
+//            meanSeedTime /= nSeedStrips;
+//
+//            double rmsTime = 0;
+//            double rmsSeedTime = 0;
+//            for (TrackerHit hit : trk.getTrackerHits()) {
+//                Collection<TrackerHit> htsList = hittostrip.allFrom(hittorotated.from(hit));
+//                for (TrackerHit hts : htsList) {
+//                    rmsTime += Math.pow(hts.getTime() - meanTime, 2);
+//                    HpsSiSensor sensor = (HpsSiSensor) ((RawTrackerHit) hts.getRawHits().get(0)).getDetectorElement();
+//                    int layer = sensor.getLayerNumber();
+//                    if (layer <= 6) {
+//                        rmsSeedTime += Math.pow(hts.getTime() - meanSeedTime, 2);
+//                    }
+//                    String sensorName = getNiceSensorName(sensor);
+//                    getSensorPlot(plotDir + "hitTimeResidual_", sensorName).fill((hts.getTime() - meanTime) * nStrips / (nStrips - 1)); //correct residual for bias
+//                }
+//            }
+//            rmsTime = Math.sqrt(rmsTime / nStrips);
+//            aida.histogram1D(plotDir + trackCollectionName+ "/"+ triggerType + "/" + "Mean time of hits on track").fill(meanTime);
+//            aida.histogram1D(plotDir + trackCollectionName+ "/"+ triggerType + "/" + "RMS time of hits on track").fill(rmsTime);
+//            aida.histogram2D(plotDir + trackCollectionName+ "/"+ triggerType + "/" + "Track chi2 vs. RMS time of hits").fill(rmsTime, trk.getChi2());
+//
+//            rmsSeedTime = Math.sqrt(rmsSeedTime / nSeedStrips);
+//            aida.histogram1D(plotDir + trackCollectionName+ "/"+ triggerType + "/" + "RMS time of hits on seed layers").fill(rmsSeedTime);
 
 //            System.out.format("%d seed strips, RMS time %f\n", nSeedStrips, rmsSeedTime);
 //            System.out.format("%d strips, mean time %f, RMS time %f\n", nStrips, meanTime, rmsTime);
@@ -388,7 +394,7 @@
             //IHistogram1D occupancyPlot = aida.histogram1D(sensor.getName().replaceAll("Tracker_TestRunModule_", ""), 640, 0, 639);
             IHistogram1D hitTimeResidual = getSensorPlot(plotDir + "hitTimeResidual_", getNiceSensorName(sensor));
             IFitResult result = fitGaussian(hitTimeResidual, fitter, "range=\"(-20.0,20.0)\"");
-            System.out.format("%s\t%f\t%f\t%d\t%d\n",getNiceSensorName(sensor), result.fittedParameters()[1], result.fittedParameters()[2], sensor.getFebID(), sensor.getFebHybridID());
+            System.out.format("%s\t%f\t%f\t%d\t%d\n", getNiceSensorName(sensor), result.fittedParameters()[1], result.fittedParameters()[2], sensor.getFebID(), sensor.getFebHybridID());
         }
 
         monitoredQuantityMap.put(trackingQuantNames[0], (double) nTotTracks / nEvents);
@@ -415,17 +421,15 @@
     @Override
     public void printDQMData() {
         System.out.println("ReconMonitoring::printDQMData");
-        for (Map.Entry<String, Double> entry : monitoredQuantityMap.entrySet()) {
+        for (Map.Entry<String, Double> entry : monitoredQuantityMap.entrySet())
             System.out.println(entry.getKey() + " = " + entry.getValue());
-        }
         System.out.println("*******************************");
     }
 
     @Override
     public void printDQMStrings() {
-        for (Map.Entry<String, Double> entry : monitoredQuantityMap.entrySet()) {
+        for (Map.Entry<String, Double> entry : monitoredQuantityMap.entrySet())
             System.out.println("ALTER TABLE dqm ADD " + entry.getKey() + " double;");
-        }
     }
 
     private IHistogram1D getSensorPlot(String prefix, HpsSiSensor sensor) {

Modified: java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/V0Monitoring.java
 =============================================================================
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/V0Monitoring.java	(original)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/V0Monitoring.java	Mon May 11 09:36:24 2015
@@ -41,6 +41,7 @@
     //some counters
     int nRecoEvents = 0;
     int nTotV0 = 0;
+    int nTot2Ele = 0;
     //some summers
     double sumMass = 0.0;
     double sumVx = 0.0;
@@ -49,17 +50,31 @@
     double sumChi2 = 0.0;
 
     IHistogram2D pEleVspPos;
+    IHistogram2D pEleVspPosWithCut;
     IHistogram2D pyEleVspyPos;
     IHistogram2D pxEleVspxPos;
+    IHistogram2D pEleVspEle;
+    IHistogram2D pyEleVspyEle;
+    IHistogram2D pxEleVspxEle;
     IHistogram2D massVsVtxZ;
+    IHistogram2D VtxYVsVtxZ;
+    IHistogram2D VtxXVsVtxZ;
+    IHistogram2D VtxXVsVtxY;
+
+    IHistogram1D sumChargeHisto;
+    IHistogram1D numChargeHisto;
 
     boolean debug = false;
     private String plotDir = "V0Monitoring/";
 
-      double beamEnergy = 1.05; //GeV
-    double maxFactor = 1.5;
+    double beamEnergy = 1.05; //GeV
+    double maxFactor = 1.25;
     double feeMomentumCut = 0.8; //GeV
-    
+
+    double v0ESumMinCut = 0.8 * beamEnergy;
+     double v0ESumMaxCut = 1.1 * beamEnergy;
+    double v0MaxPCut = 1.1;//GeV
+
     @Override
     protected void detectorChanged(Detector detector) {
         System.out.println("V0Monitoring::detectorChanged  Setting up the plotter");
@@ -87,11 +102,19 @@
         IHistogram1D tarconVy = aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Vy (mm)", 50, -1, 1);
         IHistogram1D tarconVz = aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Vz (mm)", 50, -10, 10);
         IHistogram1D tarconChi2 = aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Chi2", 25, 0, 25);
-        pEleVspPos = aida.histogram2D(plotDir + triggerType + "/" + "P(e) vs P(p)", 50, 0, beamEnergy * maxFactor, 50, 0,beamEnergy * maxFactor);
+        pEleVspPos = aida.histogram2D(plotDir + triggerType + "/" + "P(e) vs P(p)", 50, 0, beamEnergy * maxFactor, 50, 0, beamEnergy * maxFactor);
+        pEleVspPosWithCut = aida.histogram2D(plotDir + triggerType + "/" + "P(e) vs P(p): Radiative", 50, 0, beamEnergy * maxFactor, 50, 0, beamEnergy * maxFactor);
         pyEleVspyPos = aida.histogram2D(plotDir + triggerType + "/" + "Py(e) vs Py(p)", 50, -0.1, 0.1, 50, -0.1, 0.1);
         pxEleVspxPos = aida.histogram2D(plotDir + triggerType + "/" + "Px(e) vs Px(p)", 50, -0.1, 0.1, 50, -0.1, 0.1);
-        massVsVtxZ = aida.histogram2D(plotDir + triggerType + "/" + "Mass vs Vz", 50, 0, 0.15, 50, -50, 50);
-
+        massVsVtxZ = aida.histogram2D(plotDir + triggerType + "/" + "Mass vs Vz", 50, 0, 0.15, 50, -50, 80);
+        VtxXVsVtxZ = aida.histogram2D(plotDir + triggerType + "/" + "Vx vs Vz", 100, -10, 10, 100, -50, 80);
+        VtxYVsVtxZ = aida.histogram2D(plotDir + triggerType + "/" + "Vy vs Vz", 100, -5, 5, 100, -50, 80);
+        VtxXVsVtxY = aida.histogram2D(plotDir + triggerType + "/" + "Vx vs Vy", 100, -10, 10, 100, -5, 5);
+        pEleVspEle = aida.histogram2D(plotDir + triggerType + "/" + "2 Electron: P(e) vs P(p)", 50, 0, beamEnergy * maxFactor, 50, 0, beamEnergy * maxFactor);
+        pyEleVspyEle = aida.histogram2D(plotDir + triggerType + "/" + "2 Electron:Py(e) vs Py(p)", 50, -0.1, 0.1, 50, -0.1, 0.1);
+        pxEleVspxEle = aida.histogram2D(plotDir + triggerType + "/" + "2 Electron:Px(e) vs Px(p)", 50, -0.1, 0.1, 50, -0.1, 0.1);
+        sumChargeHisto = aida.histogram1D(plotDir + triggerType + "/" + "Total Charge of  Event", 5, -2, 3);
+        numChargeHisto = aida.histogram1D(plotDir + triggerType + "/" + "Number of Charged Particles", 6, 0, 6);
     }
 
     @Override
@@ -114,7 +137,7 @@
                     if (!matchTriggerType(triggerData))//only process singles0 triggers...
                         return;
                 }
-        } else
+        } else if (debug)
             System.out.println(this.getClass().getSimpleName() + ":  No trigger bank found...running over all trigger types");
 
         nRecoEvents++;
@@ -129,20 +152,37 @@
             aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Chi2").fill(uncVert.getChi2());
 
             aida.histogram2D(plotDir + triggerType + "/" + "Mass vs Vz").fill(uncV0.getMass(), uncVert.getPosition().z());
+            VtxXVsVtxZ.fill(uncVert.getPosition().x(), uncVert.getPosition().z());
+            VtxYVsVtxZ.fill(uncVert.getPosition().y(), uncVert.getPosition().z());
+            VtxXVsVtxY.fill(uncVert.getPosition().x(), uncVert.getPosition().y());
+
             //this always has 2 tracks. 
             List<ReconstructedParticle> trks = uncV0.getParticles();
-            Track ele = trks.get(0).getTracks().get(0);
-            Track pos = trks.get(1).getTracks().get(0);
-            //if track #0 has charge>0 it's the electron!  This seems mixed up, but remember the track 
-            //charge is assigned assuming a positive B-field, while ours is negative
-            if (trks.get(0).getCharge() > 0) {
-                pos = trks.get(0).getTracks().get(0);
-                ele = trks.get(1).getTracks().get(0);
+//            Track ele = trks.get(0).getTracks().get(0);
+//            Track pos = trks.get(1).getTracks().get(0);
+//            //if track #0 has charge>0 it's the electron!  This seems mixed up, but remember the track 
+//            //charge is assigned assuming a positive B-field, while ours is negative
+//            if (trks.get(0).getCharge() > 0) {
+//                pos = trks.get(0).getTracks().get(0);
+//                ele = trks.get(1).getTracks().get(0);
+//            }
+//            aida.histogram2D(plotDir + triggerType + "/" + "P(e) vs P(p)").fill(getMomentum(ele), getMomentum(pos));
+//            aida.histogram2D(plotDir + triggerType + "/" + "Px(e) vs Px(p)").fill(ele.getTrackStates().get(0).getMomentum()[1], pos.getTrackStates().get(0).getMomentum()[1]);
+//            aida.histogram2D(plotDir + triggerType + "/" + "Py(e) vs Py(p)").fill(ele.getTrackStates().get(0).getMomentum()[2], pos.getTrackStates().get(0).getMomentum()[2]);
+            ReconstructedParticle ele = trks.get(0);
+            ReconstructedParticle pos = trks.get(1);
+            //ReconParticles have the charge correct. 
+            if (trks.get(0).getCharge() < 0) {
+                pos = trks.get(0);
+                ele = trks.get(1);
             }
-            aida.histogram2D(plotDir + triggerType + "/" + "P(e) vs P(p)").fill(getMomentum(ele), getMomentum(pos));
-            aida.histogram2D(plotDir + triggerType + "/" + "Px(e) vs Px(p)").fill(ele.getTrackStates().get(0).getMomentum()[1], pos.getTrackStates().get(0).getMomentum()[1]);
-            aida.histogram2D(plotDir + triggerType + "/" + "Py(e) vs Py(p)").fill(ele.getTrackStates().get(0).getMomentum()[2], pos.getTrackStates().get(0).getMomentum()[2]);
-
+            double pe = ele.getMomentum().magnitude();
+            double pp = pos.getMomentum().magnitude();
+            aida.histogram2D(plotDir + triggerType + "/" + "P(e) vs P(p)").fill(pe, pp);
+            aida.histogram2D(plotDir + triggerType + "/" + "Px(e) vs Px(p)").fill(ele.getMomentum().x(), pos.getMomentum().x());
+            aida.histogram2D(plotDir + triggerType + "/" + "Py(e) vs Py(p)").fill(ele.getMomentum().y(), pos.getMomentum().y());
+            if (pe < v0MaxPCut && pp < v0MaxPCut && (pe + pp) > v0ESumMinCut&&(pe + pp)<v0ESumMaxCut)//enrich radiative-like events
+                aida.histogram2D(plotDir + triggerType + "/" + "P(e) vs P(p): Radiative").fill(pe, pp);
         }
 
         List<ReconstructedParticle> beamConstrainedV0List = event.get(ReconstructedParticle.class, beamConV0CandidatesColName);
@@ -171,6 +211,36 @@
             aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Mass (GeV)").fill(tarV0.getMass());
             aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Chi2").fill(tarVert.getChi2());
         }
+        List<ReconstructedParticle> finalStateParticles = event.get(ReconstructedParticle.class, finalStateParticlesColName);
+        if (debug)
+            System.out.println("This events has " + finalStateParticles.size() + " final state particles");
+
+        ReconstructedParticle ele1 = null;
+        ReconstructedParticle ele2 = null;
+        int sumCharge = 0;
+        int numChargedParticles = 0;
+        for (ReconstructedParticle fsPart : finalStateParticles) {
+            if (debug)
+                System.out.println("PDGID = " + fsPart.getParticleIDUsed() + "; charge = " + fsPart.getCharge() + "; pz = " + fsPart.getMomentum().x());
+            double charge = fsPart.getCharge();
+            sumCharge += charge;
+            if (charge != 0) {
+                numChargedParticles++;
+                if (charge < 1)
+                    if (ele1 == null)
+                        ele1 = fsPart;
+                    else
+                        ele2 = fsPart;
+            }
+        }
+        sumChargeHisto.fill(sumCharge);
+        numChargeHisto.fill(numChargedParticles);
+
+        if (ele1 != null && ele2 != null) {
+            pEleVspEle.fill(ele1.getMomentum().magnitude(), ele2.getMomentum().magnitude());
+            pyEleVspyEle.fill(ele1.getMomentum().y(), ele2.getMomentum().y());
+            pxEleVspxEle.fill(ele1.getMomentum().x(), ele2.getMomentum().x());
+        }
     }
 
     @Override
@@ -200,44 +270,45 @@
         double[] init3 = {50.0, 0.0, 3.0, 1.0, 0.0};
         IFitResult resVz = fitVertexPosition(bsconVz, fitter, init3, "range=\"(-6,6)\"");
 
-        double[] parsVx = resVx.fittedParameters();
-        double[] parsVy = resVy.fittedParameters();
-        double[] parsVz = resVz.fittedParameters();
-
-        for (int i = 0; i < 5; i++)
-            System.out.println("Vertex Fit Parameters:  " + resVx.fittedParameterNames()[i] + " = " + parsVx[i] + "; " + parsVy[i] + "; " + parsVz[i]);
-
-        IPlotter plotter = analysisFactory.createPlotterFactory().create("Vertex Position");
-        plotter.createRegions(1, 3);
-        IPlotterStyle pstyle = plotter.style();
-        pstyle.legendBoxStyle().setVisible(false);
-        pstyle.dataStyle().fillStyle().setColor("green");
-        pstyle.dataStyle().lineStyle().setColor("black");
-        plotter.region(0).plot(bsconVx);
-        plotter.region(0).plot(resVx.fittedFunction());
-        plotter.region(1).plot(bsconVy);
-        plotter.region(1).plot(resVy.fittedFunction());
-        plotter.region(2).plot(bsconVz);
-        plotter.region(2).plot(resVz.fittedFunction());
-        if (outputPlots)
-            try {
-                plotter.writeToFile(outputPlotDir + "vertex.png");
-            } catch (IOException ex) {
-                Logger.getLogger(V0Monitoring.class.getName()).log(Level.SEVERE, null, ex);
-            }
-
-        monitoredQuantityMap.put(fpQuantNames[0], (double) nTotV0 / nRecoEvents);
-        monitoredQuantityMap.put(fpQuantNames[1], sumMass / nTotV0);
+        if (resVx != null && resVy != null & resVz != null) {
+            double[] parsVx = resVx.fittedParameters();
+            double[] parsVy = resVy.fittedParameters();
+            double[] parsVz = resVz.fittedParameters();
+
+            for (int i = 0; i < 5; i++)
+                System.out.println("Vertex Fit Parameters:  " + resVx.fittedParameterNames()[i] + " = " + parsVx[i] + "; " + parsVy[i] + "; " + parsVz[i]);
+
+            IPlotter plotter = analysisFactory.createPlotterFactory().create("Vertex Position");
+            plotter.createRegions(1, 3);
+            IPlotterStyle pstyle = plotter.style();
+            pstyle.legendBoxStyle().setVisible(false);
+            pstyle.dataStyle().fillStyle().setColor("green");
+            pstyle.dataStyle().lineStyle().setColor("black");
+            plotter.region(0).plot(bsconVx);
+            plotter.region(0).plot(resVx.fittedFunction());
+            plotter.region(1).plot(bsconVy);
+            plotter.region(1).plot(resVy.fittedFunction());
+            plotter.region(2).plot(bsconVz);
+            plotter.region(2).plot(resVz.fittedFunction());
+            if (outputPlots)
+                try {
+                    plotter.writeToFile(outputPlotDir + "vertex.png");
+                } catch (IOException ex) {
+                    Logger.getLogger(V0Monitoring.class.getName()).log(Level.SEVERE, null, ex);
+                }
+
 //        monitoredQuantityMap.put(fpQuantNames[2], sumVx / nTotV0);
 //        monitoredQuantityMap.put(fpQuantNames[3], sumVy / nTotV0);
 //        monitoredQuantityMap.put(fpQuantNames[4], sumVz / nTotV0);
-        monitoredQuantityMap.put(fpQuantNames[2], parsVx[1]);
-        monitoredQuantityMap.put(fpQuantNames[3], parsVy[1]);
-        monitoredQuantityMap.put(fpQuantNames[4], parsVz[1]);
-        monitoredQuantityMap.put(fpQuantNames[5], parsVx[2]);
-        monitoredQuantityMap.put(fpQuantNames[6], parsVy[2]);
-        monitoredQuantityMap.put(fpQuantNames[7], parsVz[2]);
-
+            monitoredQuantityMap.put(fpQuantNames[2], parsVx[1]);
+            monitoredQuantityMap.put(fpQuantNames[3], parsVy[1]);
+            monitoredQuantityMap.put(fpQuantNames[4], parsVz[1]);
+            monitoredQuantityMap.put(fpQuantNames[5], parsVx[2]);
+            monitoredQuantityMap.put(fpQuantNames[6], parsVy[2]);
+            monitoredQuantityMap.put(fpQuantNames[7], parsVz[2]);
+        }
+        monitoredQuantityMap.put(fpQuantNames[0], (double) nTotV0 / nRecoEvents);
+        monitoredQuantityMap.put(fpQuantNames[1], sumMass / nTotV0);
         monitoredQuantityMap.put(fpQuantNames[8], sumChi2 / nTotV0);
 
     }
@@ -248,8 +319,15 @@
             System.out.println("ALTER TABLE dqm ADD " + fpQuantNames[i] + " double;");
     }
 
-    IFitResult fitVertexPosition(IHistogram1D h1d, IFitter fitter, double[] init, String range) {
-        return fitter.fit(h1d, "g+p1", init, range);
+    IFitResult fitVertexPosition(IHistogram1D h1d, IFitter fitter, double[] init, String range
+    ) {
+        IFitResult ifr = null;
+        try {
+            ifr = fitter.fit(h1d, "g+p1", init, range);
+        } catch (RuntimeException ex) {
+            System.out.println(this.getClass().getSimpleName() + ":  caught exception in fitGaussian");
+        }
+        return ifr;
     }
 
     private double getMomentum(Track trk) {

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