Print

Print


Author: [log in to unmask]
Date: Mon Apr 27 21:31:07 2015
New Revision: 2842

Log:
Add lots of new plots to DQM routines; add methods to select on specific trigger types; open up L1-3 & L4-6 tracking cuts

Added:
    java/trunk/users/src/main/java/org/hps/users/mgraham/PositronDebug.java
Modified:
    java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/DataQualityMonitor.java
    java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/EcalMonitoring.java
    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/TrackingResiduals.java
    java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TridentMonitoring.java
    java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/V0Monitoring.java
    java/trunk/tracking/src/main/resources/org/hps/recon/tracking/strategies/HPS-Full-L1-3.xml
    java/trunk/tracking/src/main/resources/org/hps/recon/tracking/strategies/HPS-Full-L4-6.xml

Modified: java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/DataQualityMonitor.java
 =============================================================================
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/DataQualityMonitor.java	(original)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/DataQualityMonitor.java	Mon Apr 27 21:31:07 2015
@@ -6,6 +6,7 @@
 import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import org.hps.recon.ecal.triggerbank.TIData;
 import org.lcsim.util.Driver;
 import org.lcsim.util.aida.AIDA;
 
@@ -29,6 +30,12 @@
     protected boolean debug=false;
     protected boolean outputPlots = false;
     protected String outputPlotDir = "DQMOutputPlots/";
+    
+     String triggerType = "";//allowed types are "" (blank) or "all", singles0, singles1, pairs0,pairs1
+
+    public void setTriggerType(String type) {
+        this.triggerType = type;
+    }
     
     public void setRecoVersion(String recoVersion) {
         this.recoVersion = recoVersion;
@@ -159,6 +166,21 @@
            
         }
     }
+    
+      public boolean matchTriggerType(TIData triggerData) {
+        if (triggerType.contentEquals("") || triggerType.contentEquals("all"))
+            return true;
+        if (triggerData.isSingle0Trigger() && triggerType.contentEquals("singles0"))
+            return true;
+        if (triggerData.isSingle1Trigger() && triggerType.contentEquals("singles1"))
+            return true;
+        if (triggerData.isPair0Trigger() && triggerType.contentEquals("pairs0"))
+            return true;
+        if (triggerData.isPair1Trigger() && triggerType.contentEquals("pairs1"))
+            return true;
+        return false;
+
+    }
 
     //override this method to do something interesting   
     //like print the DQM data log file

Modified: java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/EcalMonitoring.java
 =============================================================================
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/EcalMonitoring.java	(original)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/EcalMonitoring.java	Mon Apr 27 21:31:07 2015
@@ -6,9 +6,13 @@
 import java.util.List;
 import java.util.Map;
 import org.apache.commons.math.stat.StatUtils;
+import org.hps.recon.ecal.triggerbank.AbstractIntData;
+import org.hps.recon.ecal.triggerbank.TIData;
+import org.hps.recon.ecal.triggerbank.TestRunTriggerData;
 import org.lcsim.event.CalorimeterHit;
 import org.lcsim.event.Cluster;
 import org.lcsim.event.EventHeader;
+import org.lcsim.event.GenericObject;
 import org.lcsim.geometry.Detector;
 
 /**
@@ -51,21 +55,24 @@
     IHistogram2D fiducialenergyVsX;
     IHistogram2D energyVsY;
     IHistogram2D energyVsX;
-
-     int nEvents = 0;
+    IHistogram2D xVsY;
+    IHistogram2D pairsE1vsE2;
+
+    int nEvents = 0;
     int nTotHits = 0;
-    int nTotClusters = 0; 
-    double sumHitE = 0;   
+    int nTotClusters = 0;
+    double sumHitE = 0;
     double sumHitPerCluster = 0;
     double sumClusterEnergy = 0;
-    double sumClusterTime=0;
+    double sumClusterTime = 0;
     boolean fillHitPlots = true;
     private Map<String, Double> monitoredQuantityMap = new HashMap<>();
-    String[] ecalQuantNames = {"avg_N_hits","avg_Hit_Energy",
-           "avg_N_clusters", "avg_N_hitsPerCluster","avg_Cluster_Energy","avg_ClusterTime"};
+    String[] ecalQuantNames = {"avg_N_hits", "avg_Hit_Energy",
+        "avg_N_clusters", "avg_N_hitsPerCluster", "avg_Cluster_Energy", "avg_ClusterTime"};
     double maxE = 2.5;
     private final String plotHitsDir = "EcalHits/";
     private final String plotClustersDir = "EcalClusters/";
+    private final String plotFidCutDir = "EcalClusters/FiducialCut/";
 
     public void setReadoutHitCollectionName(String readoutHitCollectionName) {
         this.readoutHitCollectionName = readoutHitCollectionName;
@@ -102,14 +109,16 @@
         clusterTimeSigma = aida.histogram1D(plotClustersDir + clusterCollectionName + " Cluster Time Sigma", 100, 0, 10);
         twoclusterTotEnergy = aida.histogram1D(plotClustersDir + clusterCollectionName + " Two Cluster Energy Sum", 100, 0, maxE);
         twoclusterEnergyAsymmetry = aida.histogram1D(plotClustersDir + clusterCollectionName + " Two Cluster Energy Asymmetry", 100, 0, 1.0);
+        xVsY = aida.histogram2D(plotClustersDir + clusterCollectionName + "X vs Y (NHits >1)", 200, -200.0, 200.0, 85, -85.0, 85.0);
         energyVsX = aida.histogram2D(plotClustersDir + clusterCollectionName + " Energy vs X", 50, 0, 1.6, 50, .0, 200.0);
         energyVsY = aida.histogram2D(plotClustersDir + clusterCollectionName + " Energy vs Y", 50, 0, 1.6, 50, 20.0, 85.0);
-
-        fiducialClusterCountPlot = aida.histogram1D(plotClustersDir + clusterCollectionName + " Cluster Count with Fiducal Cut", 10, -0.5, 9.5);
-        fiducialClusterSizePlot = aida.histogram1D(plotClustersDir + clusterCollectionName + " Cluster Size with Fiducal Cut", 10, -0.5, 9.5);
-        fiducialClusterEnergyPlot = aida.histogram1D(plotClustersDir + clusterCollectionName + " Cluster Energy with Fiducal Cut", 100, -0.1, maxE);
-        fiducialenergyVsY = aida.histogram2D(plotClustersDir + clusterCollectionName + " Energy vs Y with Fiducial Cuts", 50, 0, 1.6, 50, 45.0, 85.0);
-        fiducialenergyVsX = aida.histogram2D(plotClustersDir + clusterCollectionName + " Energy vs X with Fiducial Cuts", 50, 0, 1.6, 50, 0.0, 200.0);
+        pairsE1vsE2 = aida.histogram2D(plotClustersDir + clusterCollectionName + "Pair E1 vs E2", 50, 0, 2, 50, 0, 2);
+
+        fiducialClusterCountPlot = aida.histogram1D(plotFidCutDir + clusterCollectionName + " Cluster Count with Fiducal Cut", 10, -0.5, 9.5);
+        fiducialClusterSizePlot = aida.histogram1D(plotFidCutDir + clusterCollectionName + " Cluster Size with Fiducal Cut", 10, -0.5, 9.5);
+        fiducialClusterEnergyPlot = aida.histogram1D(plotFidCutDir + clusterCollectionName + " Cluster Energy with Fiducal Cut", 100, -0.1, maxE);
+        fiducialenergyVsY = aida.histogram2D(plotFidCutDir + clusterCollectionName + " Energy vs Y with Fiducial Cuts", 50, 0, 1.6, 50, 45.0, 85.0);
+        fiducialenergyVsX = aida.histogram2D(plotFidCutDir + clusterCollectionName + " Energy vs X with Fiducial Cuts", 50, 0, 1.6, 50, 0.0, 200.0);
 
     }
 
@@ -121,6 +130,16 @@
             hits = event.get(CalorimeterHit.class, calibratedHitCollectionName);
         else
             return; //this might be a non-data event
+
+        if (event.hasCollection(GenericObject.class, "TriggerBank")) {
+            List<GenericObject> triggerList = event.get(GenericObject.class, "TriggerBank");
+            for (GenericObject data : triggerList)
+                if (AbstractIntData.getTag(data) == TIData.BANK_TAG) {
+                    TIData triggerData = new TIData(data);
+                    if(!triggerData.isSingle0Trigger())//only process singles0 triggers...
+                        return;
+                }
+        }
 
         if (fillHitPlots) {
             hitCountPlot.fill(hits.size());
@@ -136,9 +155,9 @@
                     fiducialEnergyPlot.fill(hit.getCorrectedEnergy());
                 }
                 fiducialHitCountPlot.fill(fidHitCount);
-                sumHitE+=hit.getCorrectedEnergy();
-            }
-            nTotHits+=hits.size();
+                sumHitE += hit.getCorrectedEnergy();
+            }
+            nTotHits += hits.size();
 
         }
 
@@ -155,11 +174,11 @@
         }
         nEvents++;
         clusterCountPlot.fill(clusters.size());
-        nTotClusters+=clusters.size();
+        nTotClusters += clusters.size();
         int fidcnt = 0;
         for (Cluster cluster : clusters) {
             clusterEnergyPlot.fill(cluster.getEnergy());
-            sumClusterEnergy+=cluster.getEnergy();
+            sumClusterEnergy += cluster.getEnergy();
             double[] times = new double[cluster.getCalorimeterHits().size()];
             double[] energies = new double[cluster.getCalorimeterHits().size()];
             CalorimeterHit seed = cluster.getCalorimeterHits().get(0);
@@ -168,13 +187,16 @@
             if (cluster.getCalorimeterHits().size() > 1) {
                 energyVsX.fill(cluster.getEnergy(), Math.abs(cluster.getPosition()[0]));
                 energyVsY.fill(cluster.getEnergy(), Math.abs(cluster.getPosition()[1]));
+                xVsY.fill(cluster.getPosition()[0], cluster.getPosition()[1]);
             }
             if (Math.abs(iy) > 2 && cluster.getCalorimeterHits().size() > 1) {
                 fidcnt++;
                 fiducialClusterSizePlot.fill(cluster.getCalorimeterHits().size());
                 fiducialClusterEnergyPlot.fill(cluster.getEnergy());
-                if (cluster.getCalorimeterHits().size() > 1)
+                if (cluster.getCalorimeterHits().size() > 1) {
                     fiducialenergyVsY.fill(cluster.getEnergy(), Math.abs(cluster.getPosition()[1]));
+                    fiducialenergyVsX.fill(cluster.getEnergy(), Math.abs(cluster.getPosition()[0]));
+                }
             }
 
             int size = 0;
@@ -186,9 +208,9 @@
             clusterTimes.fill(StatUtils.mean(times, 0, size));
             clusterSizePlot.fill(size); //The number of "hits" in a "cluster"
             clusterTimeSigma.fill(Math.sqrt(StatUtils.variance(times, 0, size)));
-            sumHitPerCluster+=size;
-            sumClusterTime+=StatUtils.mean(times, 0, size);
-            
+            sumHitPerCluster += size;
+            sumClusterTime += StatUtils.mean(times, 0, size);
+
         }
         fiducialClusterCountPlot.fill(fidcnt);
         //make some interesting 2-cluster plots
@@ -201,6 +223,8 @@
             double e2 = cl2.getEnergy();
             twoclusterTotEnergy.fill(e1 + e2);
             twoclusterEnergyAsymmetry.fill(Math.abs(e1 - e2) / (e1 + e2));
+            pairsE1vsE2.fill(e1, e2);
+
         }
 
     }
@@ -213,9 +237,8 @@
     @Override
     public void printDQMData() {
         System.out.println("EcalMonitoring::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("*******************************");
     }
 
@@ -224,14 +247,14 @@
      */
     @Override
     public void calculateEndOfRunQuantities() {
-         if(fillHitPlots){
-            monitoredQuantityMap.put(calibratedHitCollectionName+" " +ecalQuantNames[0], (double) nTotHits / nEvents);
-            monitoredQuantityMap.put(calibratedHitCollectionName+" " +ecalQuantNames[1], (double) sumHitE / nTotHits);
-         }
-         monitoredQuantityMap.put(clusterCollectionName+" " +ecalQuantNames[2], (double) nTotClusters / nEvents);
-         monitoredQuantityMap.put(clusterCollectionName+" " +ecalQuantNames[3], (double) sumHitPerCluster / nTotClusters);
-         monitoredQuantityMap.put(clusterCollectionName+" " +ecalQuantNames[4], (double) sumClusterEnergy / nTotClusters);
-         monitoredQuantityMap.put(clusterCollectionName+" " +ecalQuantNames[5], (double) sumClusterTime / nTotClusters);                 
+        if (fillHitPlots) {
+            monitoredQuantityMap.put(calibratedHitCollectionName + " " + ecalQuantNames[0], (double) nTotHits / nEvents);
+            monitoredQuantityMap.put(calibratedHitCollectionName + " " + ecalQuantNames[1], (double) sumHitE / nTotHits);
+        }
+        monitoredQuantityMap.put(clusterCollectionName + " " + ecalQuantNames[2], (double) nTotClusters / nEvents);
+        monitoredQuantityMap.put(clusterCollectionName + " " + ecalQuantNames[3], (double) sumHitPerCluster / nTotClusters);
+        monitoredQuantityMap.put(clusterCollectionName + " " + ecalQuantNames[4], (double) sumClusterEnergy / nTotClusters);
+        monitoredQuantityMap.put(clusterCollectionName + " " + ecalQuantNames[5], (double) sumClusterTime / nTotClusters);
     }
 
     @Override

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 Apr 27 21:31:07 2015
@@ -15,9 +15,12 @@
 import java.util.Map.Entry;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import org.hps.recon.ecal.triggerbank.AbstractIntData;
+import org.hps.recon.ecal.triggerbank.TIData;
 import org.hps.recon.tracking.TrackUtils;
 import org.lcsim.event.Cluster;
 import org.lcsim.event.EventHeader;
+import org.lcsim.event.GenericObject;
 import org.lcsim.event.ReconstructedParticle;
 import org.lcsim.event.Track;
 import org.lcsim.geometry.Detector;
@@ -51,8 +54,12 @@
     //some summers
     double sumdelX = 0.0;
     double sumdelY = 0.0;
-    double sumEoverP = 0.0;   
+    double sumEoverP = 0.0;
     private String plotDir = "FinalStateParticles/";
+    double beamEnergy = 1.05; //GeV
+    double maxFactor = 1.5;
+    double feeMomentumCut = 0.8; //GeV
+   
 
     @Override
     protected void detectorChanged(Detector detector) {
@@ -61,39 +68,52 @@
 
         /*  Final State Particle Quantities   */
         /*  plot electron & positron momentum separately  */
-        IHistogram1D elePx = aida.histogram1D(plotDir + "Electron Px (GeV)", 50, -0.1, 0.200);
-        IHistogram1D elePy = aida.histogram1D(plotDir + "Electron Py (GeV)", 50, -0.1, 0.1);
-        IHistogram1D elePz = aida.histogram1D(plotDir + "Electron Pz (GeV)", 50, 0, 2.5);
-        IHistogram1D elePzBeam = aida.histogram1D(plotDir + "Beam Electrons Pz (GeV)", 50, 1.8, 2.5);
-
-        IHistogram1D posPx = aida.histogram1D(plotDir + "Positron Px (GeV)", 50, -0.1, 0.200);
-        IHistogram1D posPy = aida.histogram1D(plotDir + "Positron Py (GeV)", 50, -0.1, 0.1);
-        IHistogram1D posPz = aida.histogram1D(plotDir + "Positron Pz (GeV)", 50, 0, 2.5);
+        IHistogram1D elePx = aida.histogram1D(plotDir + triggerType + "/" + "Electron Px (GeV)", 50, -0.1, 0.200);
+        IHistogram1D elePy = aida.histogram1D(plotDir + triggerType + "/" + "Electron Py (GeV)", 50, -0.1, 0.1);
+        IHistogram1D elePz = aida.histogram1D(plotDir + triggerType + "/" + "Electron Pz (GeV)", 50, 0, beamEnergy * maxFactor);
+        IHistogram1D elePzBeam = aida.histogram1D(plotDir + triggerType + "/" + "Beam Electrons Pz (GeV)", 50, feeMomentumCut, beamEnergy * maxFactor);
+
+        IHistogram1D posPx = aida.histogram1D(plotDir + triggerType + "/" + "Positron Px (GeV)", 50, -0.1, 0.200);
+        IHistogram1D posPy = aida.histogram1D(plotDir + triggerType + "/" + "Positron Py (GeV)", 50, -0.1, 0.1);
+        IHistogram1D posPz = aida.histogram1D(plotDir + triggerType + "/" + "Positron Pz (GeV)", 50, 0, beamEnergy * maxFactor);
         /*  photon quanties (...right now, just unassociated clusters) */
-        IHistogram1D nPhotonsHisto = aida.histogram1D(plotDir + "Number of photons per event", 15, 0, 15);
-        IHistogram1D enePhoton = aida.histogram1D(plotDir + "Photon Energy (GeV)", 50, 0, 2.4);
-        IHistogram1D xPhoton = aida.histogram1D(plotDir + "Photon X position (mm)", 50, -100, 100);
-        IHistogram1D yPhoton = aida.histogram1D(plotDir + "Photon Y position (mm)", 50, -100, 100);
+        IHistogram1D nPhotonsHisto = aida.histogram1D(plotDir + triggerType + "/" + "Number of photons per event", 15, 0, 15);
+        IHistogram1D enePhoton = aida.histogram1D(plotDir + triggerType + "/" + "Photon Energy (GeV)", 50, 0, 2.4);
+        IHistogram1D xPhoton = aida.histogram1D(plotDir + triggerType + "/" + "Photon X position (mm)", 50, -200, 200);
+        IHistogram1D yPhoton = aida.histogram1D(plotDir + triggerType + "/" + "Photon Y position (mm)", 50, -100, 100);
 
         /*  tracks with associated clusters */
-        IHistogram1D eneOverp = aida.histogram1D(plotDir + "Cluster Energy Over TrackMomentum", 50, 0, 2.0);
-        IHistogram1D deltaXAtCal = aida.histogram1D(plotDir + "delta X @ ECal (mm)", 50, -100, 100.0);
-        IHistogram1D deltaYAtCal = aida.histogram1D(plotDir + "delta Y @ ECal (mm)", 50, -100, 100.0);
-        //IHistogram2D trackXvsECalX = aida.histogram2D(plotDir + "track X vs ECal X", 50, -300, 300.0, 50, -300, 300.0);
-        //IHistogram2D trackYvsECalY = aida.histogram2D(plotDir + "track Y vs ECal Y", 50, -100, 100.0, 50, -100, 100.0);
-        IHistogram2D trackPvsECalE = aida.histogram2D(plotDir + "track mom vs ECal E", 50, 0, 2.5, 50, 0, 2.5);
+        IHistogram1D eneOverp = aida.histogram1D(plotDir + triggerType + "/" + "Cluster Energy Over TrackMomentum", 50, 0, 2.0);
+        IHistogram1D deltaXAtCal = aida.histogram1D(plotDir + triggerType + "/" + "delta X @ ECal (mm)", 50, -50, 50.0);
+        IHistogram1D deltaYAtCal = aida.histogram1D(plotDir + triggerType + "/" + "delta Y @ ECal (mm)", 50, -50, 50.0);
+        //IHistogram2D trackXvsECalX = aida.histogram2D(plotDir + triggerType + "/" + "track X vs ECal X", 50, -300, 300.0, 50, -300, 300.0);
+        //IHistogram2D trackYvsECalY = aida.histogram2D(plotDir + triggerType + "/" + "track Y vs ECal Y", 50, -100, 100.0, 50, -100, 100.0);
+        IHistogram2D trackPvsECalE = aida.histogram2D(plotDir + triggerType + "/" + "track mom vs ECal E", 50, 0.1, beamEnergy * maxFactor, 50, 0.1, beamEnergy * maxFactor);
         /* number of unassocaited tracks/event */
-        IHistogram1D nUnAssTracksHisto = aida.histogram1D(plotDir + "Number of unassociated tracks per event", 5, 0, 5);
+        IHistogram1D nUnAssTracksHisto = aida.histogram1D(plotDir + triggerType + "/" + "Number of unassociated tracks per event", 5, 0, 5);
     }
 
     @Override
     public void process(EventHeader event) {
         /*  make sure everything is there */
-        if (!event.hasCollection(ReconstructedParticle.class, finalStateParticlesColName)){
-            if(debug)
-                    System.out.println(finalStateParticlesColName+" collection not found???");
+
+        if (!event.hasCollection(ReconstructedParticle.class, finalStateParticlesColName)) {
+            if (debug)
+                System.out.println(finalStateParticlesColName + " collection not found???");
             return;
         }
+
+        if (event.hasCollection(GenericObject.class, "TriggerBank")) {
+            List<GenericObject> triggerList = event.get(GenericObject.class, "TriggerBank");
+            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
+            System.out.println(this.getClass().getSimpleName() + ":  No trigger bank found...running over all trigger types");
+
         nRecoEvents++;
         int nPhotons = 0;  //number of photons 
         int nUnAssTracks = 0; //number of tracks w/o clusters
@@ -127,15 +147,15 @@
                 Hep3Vector mom = fsPart.getMomentum();
                 if (charge < 0) {
                     nTotEle++;
-                    aida.histogram1D(plotDir + "Electron Px (GeV)").fill(mom.x());
-                    aida.histogram1D(plotDir + "Electron Py (GeV)").fill(mom.y());
-                    aida.histogram1D(plotDir + "Electron Pz (GeV)").fill(mom.z());
-                    aida.histogram1D(plotDir + "Beam Electrons Pz (GeV)").fill(mom.z());
+                    aida.histogram1D(plotDir + triggerType + "/" + "Electron Px (GeV)").fill(mom.x());
+                    aida.histogram1D(plotDir + triggerType + "/" + "Electron Py (GeV)").fill(mom.y());
+                    aida.histogram1D(plotDir + triggerType + "/" + "Electron Pz (GeV)").fill(mom.z());
+                    aida.histogram1D(plotDir + triggerType + "/" + "Beam Electrons Pz (GeV)").fill(mom.z());
                 } else {
                     nTotPos++;
-                    aida.histogram1D(plotDir + "Positron Px (GeV)").fill(mom.x());
-                    aida.histogram1D(plotDir + "Positron Py (GeV)").fill(mom.y());
-                    aida.histogram1D(plotDir + "Positron Pz (GeV)").fill(mom.z());
+                    aida.histogram1D(plotDir + triggerType + "/" + "Positron Px (GeV)").fill(mom.x());
+                    aida.histogram1D(plotDir + triggerType + "/" + "Positron Py (GeV)").fill(mom.y());
+                    aida.histogram1D(plotDir + triggerType + "/" + "Positron Pz (GeV)").fill(mom.z());
                 }
 
             }
@@ -151,9 +171,9 @@
                 double ypos = clusterPosition.y();
                 nPhotons++;
                 nTotPhotons++;
-                aida.histogram1D(plotDir + "Photon Energy (GeV)").fill(ene);
-                aida.histogram1D(plotDir + "Photon X position (mm)").fill(xpos);
-                aida.histogram1D(plotDir + "Photon Y position (mm)").fill(ypos);
+                aida.histogram1D(plotDir + triggerType + "/" + "Photon Energy (GeV)").fill(ene);
+                aida.histogram1D(plotDir + triggerType + "/" + "Photon X position (mm)").fill(xpos);
+                aida.histogram1D(plotDir + triggerType + "/" + "Photon Y position (mm)").fill(ypos);
             }
 
             if (hasCluster && !isPhoton) {
@@ -170,13 +190,13 @@
                 sumdelY += dy;
                 sumEoverP += eOverP;
 
-                aida.histogram1D(plotDir + "Cluster Energy Over TrackMomentum").fill(eOverP);
-                aida.histogram1D(plotDir + "delta X @ ECal (mm)").fill(dx);
-                aida.histogram1D(plotDir + "delta Y @ ECal (mm)").fill(dy);
+                aida.histogram1D(plotDir + triggerType + "/" + "Cluster Energy Over TrackMomentum").fill(eOverP);
+                aida.histogram1D(plotDir + triggerType + "/" + "delta X @ ECal (mm)").fill(dx);
+                aida.histogram1D(plotDir + triggerType + "/" + "delta Y @ ECal (mm)").fill(dy);
                 /* here are some plots for debugging track-cluster matching */
-                // aida.histogram2D(plotDir + "track X vs ECal X").fill(trackPosAtEcal.x(), clusterPosition.x());
-                // aida.histogram2D(plotDir + "track Y vs ECal Y").fill(trackPosAtEcal.y(), clusterPosition.y());
-                aida.histogram2D(plotDir + "track mom vs ECal E").fill(fsPart.getMomentum().magnitude(), fsPart.getEnergy());
+                // aida.histogram2D(plotDir + triggerType + "/" + "track X vs ECal X").fill(trackPosAtEcal.x(), clusterPosition.x());
+                // aida.histogram2D(plotDir + triggerType + "/" + "track Y vs ECal Y").fill(trackPosAtEcal.y(), clusterPosition.y());
+                aida.histogram2D(plotDir + triggerType + "/" + "track mom vs ECal E").fill(fsPart.getMomentum().magnitude(), fsPart.getEnergy());
                 //          if(dy<-20)
                 //              System.out.println("Big deltaY...")
 
@@ -186,8 +206,8 @@
                 nTotUnAss++; //and keep a running total for averaging
             }
         }
-        aida.histogram1D(plotDir + "Number of unassociated tracks per event").fill(nUnAssTracks);
-        aida.histogram1D(plotDir + "Number of photons per event").fill(nPhotons);
+        aida.histogram1D(plotDir + triggerType + "/" + "Number of unassociated tracks per event").fill(nUnAssTracks);
+        aida.histogram1D(plotDir + triggerType + "/" + "Number of photons per event").fill(nPhotons);
     }
 
     @Override
@@ -206,7 +226,7 @@
         IAnalysisFactory analysisFactory = IAnalysisFactory.create();
         IFitFactory fitFactory = analysisFactory.createFitFactory();
         IFitter fitter = fitFactory.createFitter("chi2");
-        IHistogram1D beamE = aida.histogram1D(plotDir + "Beam Electrons Pz (GeV)");
+        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++)
@@ -252,4 +272,6 @@
         return fitter.fit(h1d, "g+p1", init);
     }
 
+  
+
 }

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 Apr 27 21:31:07 2015
@@ -5,8 +5,11 @@
 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.lcsim.detector.tracker.silicon.HpsSiSensor;
 import org.lcsim.event.EventHeader;
+import org.lcsim.event.GenericObject;
 import org.lcsim.event.LCRelation;
 import org.lcsim.event.RawTrackerHit;
 import org.lcsim.event.RelationalTable;
@@ -46,7 +49,57 @@
     double sumslope = 0;
     double sumchisq = 0;
     private final String plotDir = "Tracks/";
+    private final String positronDir = "Positrons/";
+    private final String electronDir = "Electrons/";
+    private final String topDir = "Top/";
+    private final String botDir = "Bottom/";
+    private final String hthplotDir = "HelicalTrackHits/";
     String[] trackingQuantNames = {"avg_N_tracks", "avg_N_hitsPerTrack", "avg_d0", "avg_z0", "avg_absslope", "avg_chi2"};
+    int nmodules = 6;
+    IHistogram1D[] hthTop = new IHistogram1D[nmodules];
+    IHistogram1D[] hthBot = new IHistogram1D[nmodules];
+    IHistogram2D[] xvsyTop = new IHistogram2D[nmodules];
+    IHistogram2D[] xvsyBot = new IHistogram2D[nmodules];
+
+    IHistogram1D trkChi2Pos;
+    IHistogram1D trkChi2Ele;
+    IHistogram1D trkChi2Top;
+    IHistogram1D trkChi2Bot;
+
+    IHistogram1D nTracksPos;
+    IHistogram1D nTracksEle;
+    IHistogram1D nTracksTop;
+    IHistogram1D nTracksBot;
+
+    IHistogram1D trkd0Pos;
+    IHistogram1D trkd0Ele;
+    IHistogram1D trkd0Top;
+    IHistogram1D trkd0Bot;
+
+    IHistogram1D trkphiPos;
+    IHistogram1D trkphiEle;
+    IHistogram1D trkphiTop;
+    IHistogram1D trkphiBot;
+
+    IHistogram1D trkomegaPos;
+    IHistogram1D trkomegaEle;
+    IHistogram1D trkomegaTop;
+    IHistogram1D trkomegaBot;
+
+    IHistogram1D trklamPos;
+    IHistogram1D trklamEle;
+    IHistogram1D trklamTop;
+    IHistogram1D trklamBot;
+
+    IHistogram1D trkz0Pos;
+    IHistogram1D trkz0Ele;
+    IHistogram1D trkz0Top;
+    IHistogram1D trkz0Bot;
+
+    IHistogram1D nHitsPos;
+    IHistogram1D nHitsEle;
+    IHistogram1D nHitsTop;
+    IHistogram1D nHitsBot;
 
     public void setHelicalTrackHitCollectionName(String helicalTrackHitCollectionName) {
         this.helicalTrackHitCollectionName = helicalTrackHitCollectionName;
@@ -61,18 +114,60 @@
         this.detector = detector;
         aida.tree().cd("/");
 
-        IHistogram1D trkChi2 = aida.histogram1D(plotDir + "Track Chi2", 25, 0, 25.0);
-        IHistogram1D nTracks = aida.histogram1D(plotDir + "Tracks per Event", 6, 0, 6);
-        IHistogram1D trkd0 = aida.histogram1D(plotDir + "d0 ", 25, -5.0, 5.0);
-        IHistogram1D trkphi = aida.histogram1D(plotDir + "sinphi ", 25, -0.2, 0.2);
-        IHistogram1D trkomega = aida.histogram1D(plotDir + "omega ", 25, -0.00025, 0.00025);
-        IHistogram1D trklam = aida.histogram1D(plotDir + "tan(lambda) ", 25, -0.1, 0.1);
-        IHistogram1D trkz0 = aida.histogram1D(plotDir + "z0 ", 25, -1.0, 1.0);
-        IHistogram1D nHits = aida.histogram1D(plotDir + "Hits per Track", 2, 5, 7);
-        IHistogram1D trackMeanTime = aida.histogram1D(plotDir + "Mean time of hits on track", 400, -100., 100.);
-        IHistogram1D trackRMSTime = aida.histogram1D(plotDir + "RMS time of hits on track", 200, 0., 15.);
-        IHistogram2D trackChi2RMSTime = aida.histogram2D(plotDir + "Track chi2 vs. RMS time of hits", 200, 0., 15., 25, 0, 25.0);
-        IHistogram1D seedRMSTime = aida.histogram1D(plotDir + "RMS time of hits on seed layers", 200, 0., 15.);
+        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.);
+        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);
+            hthTop[i - 1] = aida.histogram1D(hthplotDir + "Module " + i + "Top: Track Hits", 25, 0, 25);
+            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);
 
         // Make a list of SiSensors in the SVT.
         sensors = this.detector.getSubdetector(trackerName).getDetectorElement().findDescendants(HpsSiSensor.class);
@@ -91,42 +186,128 @@
 
         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))
+            return;
+
+        if (event.hasCollection(GenericObject.class, "TriggerBank")) {
+            List<GenericObject> triggerList = event.get(GenericObject.class, "TriggerBank");
+            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
+            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]);
+        }
+
         if (!event.hasCollection(Track.class, trackCollectionName)) {
-            aida.histogram1D(plotDir + "Tracks per Event").fill(0);
+            aida.histogram1D(plotDir + triggerType + "/" + "Tracks per Event").fill(0);
             return;
         }
         nEvents++;
         List<Track> tracks = event.get(Track.class, trackCollectionName);
         nTotTracks += tracks.size();
-        aida.histogram1D(plotDir + "Tracks per Event").fill(tracks.size());
+        aida.histogram1D(plotDir + triggerType + "/" + "Tracks per Event").fill(tracks.size());
+        int cntEle = 0;
+        int cntPos = 0;
+        int cntTop = 0;
+        int cntBot = 0;
         for (Track trk : tracks) {
             nTotHits += trk.getTrackerHits().size();
-            aida.histogram1D(plotDir + "Track Chi2").fill(trk.getChi2());
-            aida.histogram1D(plotDir + "Hits per Track").fill(trk.getTrackerHits().size());
-            aida.histogram1D(plotDir + "d0 ").fill(trk.getTrackStates().get(0).getD0());
-            aida.histogram1D(plotDir + "sinphi ").fill(Math.sin(trk.getTrackStates().get(0).getPhi()));
-            aida.histogram1D(plotDir + "omega ").fill(trk.getTrackStates().get(0).getOmega());
-            aida.histogram1D(plotDir + "tan(lambda) ").fill(trk.getTrackStates().get(0).getTanLambda());
-            aida.histogram1D(plotDir + "z0 ").fill(trk.getTrackStates().get(0).getZ0());
+            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());
+            if (trk.getTrackStates().get(0).getOmega() < 0) {//positrons
+                trkChi2Pos.fill(trk.getChi2());
+                nHitsPos.fill(trk.getTrackerHits().size());
+                trkd0Pos.fill(trk.getTrackStates().get(0).getD0());
+                trkphiPos.fill(Math.sin(trk.getTrackStates().get(0).getPhi()));
+                trkomegaPos.fill(trk.getTrackStates().get(0).getOmega());
+                trklamPos.fill(trk.getTrackStates().get(0).getTanLambda());
+                trkz0Pos.fill(trk.getTrackStates().get(0).getZ0());
+                cntPos++;
+            } else {
+                trkChi2Ele.fill(trk.getChi2());
+                nHitsEle.fill(trk.getTrackerHits().size());
+                trkd0Ele.fill(trk.getTrackStates().get(0).getD0());
+                trkphiEle.fill(Math.sin(trk.getTrackStates().get(0).getPhi()));
+                trkomegaEle.fill(trk.getTrackStates().get(0).getOmega());
+                trklamEle.fill(trk.getTrackStates().get(0).getTanLambda());
+                trkz0Ele.fill(trk.getTrackStates().get(0).getZ0());
+                cntEle++;
+            }
+
+            if (trk.getTrackStates().get(0).getTanLambda() < 0) {
+                trkChi2Bot.fill(trk.getChi2());
+                nHitsBot.fill(trk.getTrackerHits().size());
+                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());
+                trkz0Bot.fill(trk.getTrackStates().get(0).getZ0());
+                cntBot++;
+            } else {
+                trkChi2Top.fill(trk.getChi2());
+                nHitsTop.fill(trk.getTrackerHits().size());
+                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());
+                trkz0Top.fill(trk.getTrackStates().get(0).getZ0());
+                cntTop++;
+            }
+
             sumd0 += trk.getTrackStates().get(0).getD0();
             sumz0 += trk.getTrackStates().get(0).getZ0();
             sumslope += Math.abs(trk.getTrackStates().get(0).getTanLambda());
@@ -159,24 +340,27 @@
                     rmsTime += Math.pow(hts.getTime() - meanTime, 2);
                     HpsSiSensor sensor = (HpsSiSensor) ((RawTrackerHit) hts.getRawHits().get(0)).getDetectorElement();
                     int layer = sensor.getLayerNumber();
-                    if (layer <= 6) {
+                    if (layer <= 6)
                         rmsSeedTime += Math.pow(hts.getTime() - meanSeedTime, 2);
-                    }
                     String sensorName = getNiceSensorName(sensor);
                     getSensorPlot(plotDir + "hitTimeResidual_", sensorName).fill(hts.getTime() - meanTime);
                 }
             }
             rmsTime = Math.sqrt(rmsTime / nStrips);
-            aida.histogram1D(plotDir + "Mean time of hits on track").fill(meanTime);
-            aida.histogram1D(plotDir + "RMS time of hits on track").fill(rmsTime);
-            aida.histogram2D(plotDir + "Track chi2 vs. RMS time of hits").fill(rmsTime, trk.getChi2());
+            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 + "RMS time of hits on seed layers").fill(rmsSeedTime);
+            aida.histogram1D(plotDir + 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);
         }
+        nTracksTop.fill(cntTop);
+        nTracksBot.fill(cntBot);
+        nTracksPos.fill(cntPos);
+        nTracksEle.fill(cntEle);
     }
 
     @Override
@@ -192,17 +376,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/TrackingResiduals.java
 =============================================================================
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TrackingResiduals.java	(original)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TrackingResiduals.java	Mon Apr 27 21:31:07 2015
@@ -158,46 +158,53 @@
             IFitResult yresultTop = fitGaussian(yresidTop, fitter, "range=\"(-0.5,0.5)\"");
             IFitResult xresultBot = fitGaussian(xresidBot, fitter, "range=\"(-1.0,1.0)\"");
             IFitResult yresultBot = fitGaussian(yresidBot, fitter, "range=\"(-8.0,8.0)\"");
-            double[] parsXTop = xresultTop.fittedParameters();
-            double[] parsYTop = yresultTop.fittedParameters();
-            double[] parsXBot = xresultBot.fittedParameters();
-            double[] parsYBot = yresultBot.fittedParameters();
-
-            plotterXTop.region(irXTop).plot(xresidTop);
-            plotterXTop.region(irXTop).plot(xresultTop.fittedFunction());
-            irXTop++;
-            plotterXBottom.region(irXBot).plot(xresidBot);
-            plotterXBottom.region(irXBot).plot(xresultBot.fittedFunction());
-            irXBot++;
-
-            plotterYTop.region(irYTop).plot(yresidTop);
-            plotterYTop.region(irYTop).plot(yresultTop.fittedFunction());
-            irYTop++;
-            plotterYBottom.region(irYBot).plot(yresidBot);
-            plotterYBottom.region(irYBot).plot(yresultBot.fittedFunction());
-            irYBot++;
-
-            xposTopMeanResidMap.put(getQuantityName(0, 0, 1, i) + "_x", parsXTop[1]);
-            xposTopSigmaResidMap.put(getQuantityName(0, 1, 1, i) + "_x", parsXTop[2]);
-            yposTopMeanResidMap.put(getQuantityName(0, 0, 1, i) + "_y", parsYTop[1]);
-            yposTopSigmaResidMap.put(getQuantityName(0, 1, 1, i) + "_y", parsYTop[2]);
-            xposBotMeanResidMap.put(getQuantityName(0, 0, 0, i) + "_x", parsXBot[1]);
-            xposBotSigmaResidMap.put(getQuantityName(0, 1, 0, i) + "_x", parsXBot[2]);
-            yposBotMeanResidMap.put(getQuantityName(0, 0, 0, i) + "_y", parsYBot[1]);
-            yposBotSigmaResidMap.put(getQuantityName(0, 1, 0, i) + "_y", parsYBot[2]);
+            if (xresultTop != null) {
+                double[] parsXTop = xresultTop.fittedParameters();
+                plotterXTop.region(irXTop).plot(xresidTop);
+                plotterXTop.region(irXTop).plot(xresultTop.fittedFunction());
+                irXTop++;
+                xposTopMeanResidMap.put(getQuantityName(0, 0, 1, i) + "_x", parsXTop[1]);
+                xposTopSigmaResidMap.put(getQuantityName(0, 1, 1, i) + "_x", parsXTop[2]);
+            }
+            if (yresultTop != null) {
+                double[] parsYTop = yresultTop.fittedParameters();
+
+                plotterYTop.region(irYTop).plot(yresidTop);
+                plotterYTop.region(irYTop).plot(yresultTop.fittedFunction());
+                irYTop++;
+                yposTopMeanResidMap.put(getQuantityName(0, 0, 1, i) + "_y", parsYTop[1]);
+                yposTopSigmaResidMap.put(getQuantityName(0, 1, 1, i) + "_y", parsYTop[2]);
+            }
+            if (xresultBot != null) {
+                double[] parsXBot = xresultBot.fittedParameters();
+                plotterXBottom.region(irXBot).plot(xresidBot);
+                plotterXBottom.region(irXBot).plot(xresultBot.fittedFunction());
+                irXBot++;
+                xposBotMeanResidMap.put(getQuantityName(0, 0, 0, i) + "_x", parsXBot[1]);
+                xposBotSigmaResidMap.put(getQuantityName(0, 1, 0, i) + "_x", parsXBot[2]);
+            }
+            if (yresultBot != null) {
+                double[] parsYBot = yresultBot.fittedParameters();
+                plotterYBottom.region(irYBot).plot(yresidBot);
+                plotterYBottom.region(irYBot).plot(yresultBot.fittedFunction());
+                irYBot++;
+                yposBotMeanResidMap.put(getQuantityName(0, 0, 0, i) + "_y", parsYBot[1]);
+                yposBotSigmaResidMap.put(getQuantityName(0, 1, 0, i) + "_y", parsYBot[2]);
+            }
 
         }
         int iTime = 0;
         for (int i = 1; i <= nmodules * 2; i++) {
             IHistogram1D tresid = aida.histogram1D(plotDir + timeresDir + "HalfModule " + i + " t Residual");
             IFitResult tresult = fitGaussian(tresid, fitter, "range=\"(-15.0,15.0)\"");
-            double[] parsTime = tresult.fittedParameters();
-            plotterTime.region(iTime).plot(tresid);
-            plotterTime.region(iTime).plot(tresult.fittedFunction());
-            iTime++;
-
-            timeMeanResidMap.put(getQuantityName(1, 0, 2, i) + "_dt", parsTime[1]);
-            timeSigmaResidMap.put(getQuantityName(1, 1, 2, i) + "_dt", parsTime[2]);
+            if (tresult != null) {
+                double[] parsTime = tresult.fittedParameters();
+                plotterTime.region(iTime).plot(tresid);
+                plotterTime.region(iTime).plot(tresult.fittedFunction());
+                iTime++;
+                timeMeanResidMap.put(getQuantityName(1, 0, 2, i) + "_dt", parsTime[1]);
+                timeSigmaResidMap.put(getQuantityName(1, 1, 2, i) + "_dt", parsTime[2]);
+            }
 
         }
 
@@ -331,7 +338,13 @@
 
     IFitResult fitGaussian(IHistogram1D h1d, IFitter fitter, String range) {
         double[] init = {20.0, 0.0, 0.2};
-        return fitter.fit(h1d, "g", init, range);
+        IFitResult ifr = null;
+        try {
+            ifr = fitter.fit(h1d, "g", init, range);
+        } catch (RuntimeException ex) {
+            System.out.println(this.getClass().getSimpleName() + ":  caught exception in fitGaussian");
+        }
+        return ifr;
 //        double[] init = {20.0, 0.0, 1.0, 20, -1};
 //        return fitter.fit(h1d, "g+p1", init, range);
     }

Modified: java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TridentMonitoring.java
 =============================================================================
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TridentMonitoring.java	(original)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TridentMonitoring.java	Mon Apr 27 21:31:07 2015
@@ -6,6 +6,7 @@
 import hep.aida.IFitter;
 import hep.aida.IHistogram1D;
 import hep.aida.IHistogram2D;
+import hep.physics.vec.Hep3Vector;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -36,16 +37,8 @@
     String unconstrainedV0CandidatesColName = "UnconstrainedV0Candidates";
     String beamConV0CandidatesColName = "BeamspotConstrainedV0Candidates";
     String targetV0ConCandidatesColName = "TargetConstrainedV0Candidates";
+    String trackListName = "MatchedTracks";
     String[] fpQuantNames = {"nV0_per_Event", "avg_BSCon_mass", "avg_BSCon_Vx", "avg_BSCon_Vy", "avg_BSCon_Vz", "sig_BSCon_Vx", "sig_BSCon_Vy", "sig_BSCon_Vz", "avg_BSCon_Chi2"};
-    //some counters
-    int nRecoEvents = 0;
-    int nTotV0 = 0;
-    //some summers
-    double sumMass = 0.0;
-    double sumVx = 0.0;
-    double sumVy = 0.0;
-    double sumVz = 0.0;
-    double sumChi2 = 0.0;
 
     boolean debug = false;
     private String plotDir = "TridentMonitoring/";
@@ -55,6 +48,40 @@
     IHistogram2D vertexedTrackMomentum2D;
     IHistogram2D vertexPxPy;
     IHistogram1D goodVertexMass;
+
+    //clean up event first
+    int nTrkMax = 3;
+    int nPosMax = 1;
+    //v0 cuts   
+    double v0Chi2 = 10;
+    double v0PzMax = 1.1 * ebeam;//GeV 
+    double v0PzMin = 0.1;// GeV
+    double v0PyMax = 0.2;//GeV absolute value
+    double v0PxMax = 0.2;//GeV absolute value
+    double v0VzMax = 5.0;// mm from target...someday make mass dependent
+    double v0VyMax = 0.5;// mm from target...someday make mass dependent
+    double v0VxMax = 0.5;// mm from target...someday make mass dependent
+    //  track quality cuts
+    double trkChi2 = 10;
+    double trkPzMax = 0.9 * ebeam;//GeV
+    double trkPzMin = 0.1;//GeV
+    double trkPyMax = 0.2;//GeV absolute value
+    double trkPxMax = 0.2;//GeV absolute value
+    double trkTimeDiff = 5.0;
+//cluster matching
+    boolean reqCluster = true;
+    int nClustMax = 3;
+    double eneLossFactor = 0.7; //average E/p roughly
+    double eneOverPCut = 0.3; //|(E/p)_meas - (E/p)_mean|<eneOverPCut
+
+//counters
+    int nRecoEvents = 0;
+    int nPassBasicCuts = 0;
+    int nPassV0PCuts = 0;
+    int nPassV0VCuts = 0;
+    int nPassTrkCuts = 0;
+
+    int nPassClusterCuts = 0;
 
     @Override
     protected void detectorChanged(Detector detector) {
@@ -88,76 +115,77 @@
     @Override
     public void process(EventHeader event) {
         /*  make sure everything is there */
-        if (!event.hasCollection(ReconstructedParticle.class, finalStateParticlesColName)) {
-            return;
-        }
-        if (!event.hasCollection(ReconstructedParticle.class, unconstrainedV0CandidatesColName)) {
-            return;
-        }
-        if (!event.hasCollection(ReconstructedParticle.class, beamConV0CandidatesColName)) {
-            return;
-        }
-        if (!event.hasCollection(ReconstructedParticle.class, targetV0ConCandidatesColName)) {
-            return;
-        }
+        if (!event.hasCollection(ReconstructedParticle.class, finalStateParticlesColName))
+            return;
+        if (!event.hasCollection(ReconstructedParticle.class, unconstrainedV0CandidatesColName))
+            return;
+        if (!event.hasCollection(ReconstructedParticle.class, beamConV0CandidatesColName))
+            return;
+        if (!event.hasCollection(ReconstructedParticle.class, targetV0ConCandidatesColName))
+            return;
+        if (!event.hasCollection(Track.class, trackListName))
+            return;
+
         nRecoEvents++;
 
         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());
-            }
-        }
-
-        List<ReconstructedParticle> beamConstrainedV0List = event.get(ReconstructedParticle.class, beamConV0CandidatesColName);
-//        aida.histogram1D(plotDir + "Number of V0 per event").fill(beamConstrainedV0List.size());
-        for (ReconstructedParticle bsV0 : beamConstrainedV0List) {
-            nTotV0++;
-            Vertex bsVert = bsV0.getStartVertex();
-//            aida.histogram1D(plotDir + "BS Constrained Vx (mm)").fill(bsVert.getPosition().x());
-//            aida.histogram1D(plotDir + "BS Constrained Vy (mm)").fill(bsVert.getPosition().y());
-//            aida.histogram1D(plotDir + "BS Constrained Vz (mm)").fill(bsVert.getPosition().z());
-//            aida.histogram1D(plotDir + "BS Constrained Mass (GeV)").fill(bsV0.getMass());
-//            aida.histogram1D(plotDir + "BS Constrained Chi2").fill(bsVert.getChi2());
-            sumMass += bsV0.getMass();
-            sumVx += bsVert.getPosition().x();
-            sumVy += bsVert.getPosition().y();
-            sumVz += bsVert.getPosition().z();
-            sumChi2 += bsVert.getChi2();
-        }
+
+        List<Track> trks = event.get(Track.class, trackListName);
+        int ntracks = trks.size();
+        if (ntracks > nTrkMax || ntracks < 2)
+            return;
+        List<ReconstructedParticle> fspList = event.get(ReconstructedParticle.class, finalStateParticlesColName);
+        int npos = 0;
+        for (ReconstructedParticle fsp : fspList)
+            if (fsp.getCharge() > 0)
+                npos++;
+        if (npos < 1 || npos > nPosMax)
+            return;
+
+        nPassBasicCuts++;//passed some basic event-level cuts...
 
         List<ReconstructedParticle> targetConstrainedV0List = event.get(ReconstructedParticle.class, targetV0ConCandidatesColName);
         for (ReconstructedParticle tarV0 : targetConstrainedV0List) {
             Vertex tarVert = tarV0.getStartVertex();
-//            aida.histogram1D(plotDir + "Target Constrained Vx (mm)").fill(tarVert.getPosition().x());
-//            aida.histogram1D(plotDir + "Target Constrained Vy (mm)").fill(tarVert.getPosition().y());
-//            aida.histogram1D(plotDir + "Target Constrained Vz (mm)").fill(tarVert.getPosition().z());
-//            aida.histogram1D(plotDir + "Target Constrained Mass (GeV)").fill(tarV0.getMass());
-//            aida.histogram1D(plotDir + "Target Constrained Chi2").fill(tarVert.getChi2());
+//  v0 & vertex-quality cuts
+            Hep3Vector v0Mom = tarV0.getMomentum();
+            if (v0Mom.z() > v0PzMax || v0Mom.z() < v0PzMin)
+                break;
+            if (Math.abs(v0Mom.y()) > v0PyMax)
+                break;
+            if (Math.abs(v0Mom.x()) > v0PxMax)
+                break;
+            Hep3Vector v0Vtx = tarVert.getPosition();
+            if (Math.abs(v0Vtx.z()) > v0VzMax)
+                break;
+            if (Math.abs(v0Vtx.y()) > v0VyMax)
+                break;
+            if (Math.abs(v0Vtx.x()) > v0VxMax)
+                break;
+
             List<Track> tracks = new ArrayList<Track>();
             ReconstructedParticle electron = null, positron = null;
             for (ReconstructedParticle particle : tarV0.getParticles()) {
                 tracks.addAll(particle.getTracks());
-                if (particle.getCharge() > 0) {
+                if (particle.getCharge() > 0)
                     positron = particle;
-                } else if (particle.getCharge() < 0) {
+                else if (particle.getCharge() < 0)
                     electron = particle;
-                } else {
+                else
                     throw new RuntimeException("expected only electron and positron in vertex, got something with charge 0");
-                }
             }
-            if (tracks.size() != 2) {
+            if (tracks.size() != 2)
                 throw new RuntimeException("expected two tracks in vertex, got " + tracks.size());
-            }
             List<Double> trackTimes = new ArrayList<Double>();
             for (Track track : tracks) {
                 int nStrips = 0;
@@ -174,9 +202,9 @@
             }
             trackTime2D.fill(trackTimes.get(0), trackTimes.get(1));
             trackTimeDiff.fill(trackTimes.get(0) - trackTimes.get(1));
-            boolean trackTimeDiffCut = Math.abs(trackTimes.get(0) - trackTimes.get(1)) < 5.0;
-            boolean pCut = electron.getMomentum().magnitude() > 0.4 && positron.getMomentum().magnitude() > 0.4;
-            boolean pTotCut = tarV0.getMomentum().magnitude() > 0.8 * 2.2 && tarV0.getMomentum().magnitude() < 2.2;
+            boolean trackTimeDiffCut = Math.abs(trackTimes.get(0) - trackTimes.get(1)) < trkTimeDiff;
+            boolean pCut = electron.getMomentum().magnitude() > trkPzMin && positron.getMomentum().magnitude() > trkPzMin;
+            boolean pTotCut = tarV0.getMomentum().magnitude() > v0PzMin && tarV0.getMomentum().magnitude() < v0PzMax;
             if (trackTimeDiffCut) {
                 vertexMassMomentum.fill(tarV0.getMomentum().magnitude(), tarV0.getMass());
                 vertexedTrackMomentum2D.fill(electron.getMomentum().magnitude(), positron.getMomentum().magnitude());
@@ -192,9 +220,8 @@
     @Override
     public void printDQMData() {
         System.out.println("TridentMonitoring::printDQMData");
-        for (Entry<String, Double> entry : monitoredQuantityMap.entrySet()) {
+        for (Entry<String, Double> entry : monitoredQuantityMap.entrySet())
             System.out.println(entry.getKey() + " = " + entry.getValue());
-        }
         System.out.println("*******************************");
     }
 
@@ -207,66 +234,14 @@
         IAnalysisFactory analysisFactory = IAnalysisFactory.create();
         IFitFactory fitFactory = analysisFactory.createFitFactory();
         IFitter fitter = fitFactory.createFitter("chi2");
-//        IHistogram1D bsconVx = aida.histogram1D(plotDir + "BS Constrained Vx (mm)");
-//        IHistogram1D bsconVy = aida.histogram1D(plotDir + "BS Constrained Vy (mm)");
-//        IHistogram1D bsconVz = aida.histogram1D(plotDir + "BS Constrained Vz (mm)");
-//        double[] init = {50.0, 0.0, 0.2, 1.0, 0.0};
-//        IFitResult resVx = fitVertexPosition(bsconVx, fitter, init, "range=\"(-0.5,0.5)\"");
-//        double[] init2 = {50.0, 0.0, 0.04, 1.0, 0.0};
-//        IFitResult resVy = fitVertexPosition(bsconVy, fitter, init2, "range=\"(-0.2,0.2)\"");
-//        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(TridentMonitoring.class.getName()).log(Level.SEVERE, null, ex);
-//            }
-//        }
-//
-//        monitoredQuantityMap.put(fpQuantNames[0], (double) nTotV0 / nRecoEvents);
-//        monitoredQuantityMap.put(fpQuantNames[1], sumMass / nTotV0);
-////        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[8], sumChi2 / nTotV0);
 
     }
 
     @Override
     public void printDQMStrings() {
         for (int i = 0; i < 9; i++)//TODO:  do this in a smarter way...loop over the map
-        {
+
             System.out.println("ALTER TABLE dqm ADD " + fpQuantNames[i] + " double;");
-        }
     }
 
     IFitResult fitVertexPosition(IHistogram1D h1d, IFitter fitter, double[] init, String range) {

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 Apr 27 21:31:07 2015
@@ -5,6 +5,7 @@
 import hep.aida.IFitResult;
 import hep.aida.IFitter;
 import hep.aida.IHistogram1D;
+import hep.aida.IHistogram2D;
 import hep.aida.IPlotter;
 import hep.aida.IPlotterStyle;
 import java.io.IOException;
@@ -14,8 +15,12 @@
 import java.util.Map.Entry;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import org.hps.recon.ecal.triggerbank.AbstractIntData;
+import org.hps.recon.ecal.triggerbank.TIData;
 import org.lcsim.event.EventHeader;
+import org.lcsim.event.GenericObject;
 import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.Track;
 import org.lcsim.event.Vertex;
 import org.lcsim.geometry.Detector;
 
@@ -43,9 +48,18 @@
     double sumVz = 0.0;
     double sumChi2 = 0.0;
 
+    IHistogram2D pEleVspPos;
+    IHistogram2D pyEleVspyPos;
+    IHistogram2D pxEleVspxPos;
+    IHistogram2D massVsVtxZ;
+
     boolean debug = false;
     private String plotDir = "V0Monitoring/";
 
+      double beamEnergy = 1.05; //GeV
+    double maxFactor = 1.5;
+    double feeMomentumCut = 0.8; //GeV
+    
     @Override
     protected void detectorChanged(Detector detector) {
         System.out.println("V0Monitoring::detectorChanged  Setting up the plotter");
@@ -53,19 +67,30 @@
 
         /*  V0 Quantities   */
         /*  Mass, vertex, chi^2 of fit */
+        /*  unconstrained */
+        IHistogram1D unconMass = aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Mass (GeV)", 100, 0, 0.200);
+        IHistogram1D unconVx = aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Vx (mm)", 50, -10, 10);
+        IHistogram1D unconVy = aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Vy (mm)", 50, -10, 10);
+        IHistogram1D unconVz = aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Vz (mm)", 50, -50, 50);
+        IHistogram1D unconChi2 = aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Chi2", 25, 0, 25);
         /* beamspot constrained */
-        IHistogram1D nV0 = aida.histogram1D(plotDir + "Number of V0 per event", 10, 0, 10);
-        IHistogram1D bsconMass = aida.histogram1D(plotDir + "BS Constrained Mass (GeV)", 100, 0, 0.200);
-        IHistogram1D bsconVx = aida.histogram1D(plotDir + "BS Constrained Vx (mm)", 200, -5, 5);
-        IHistogram1D bsconVy = aida.histogram1D(plotDir + "BS Constrained Vy (mm)", 200, -5, 5);
-        IHistogram1D bsconVz = aida.histogram1D(plotDir + "BS Constrained Vz (mm)", 200, -50, 50);
-        IHistogram1D bsconChi2 = aida.histogram1D(plotDir + "BS Constrained Chi2", 100, 0, 100);
+
+        IHistogram1D nV0 = aida.histogram1D(plotDir + triggerType + "/" + "Number of V0 per event", 10, 0, 10);
+        IHistogram1D bsconMass = aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Mass (GeV)", 100, 0, 0.200);
+        IHistogram1D bsconVx = aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Vx (mm)", 50, -10, 10);
+        IHistogram1D bsconVy = aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Vy (mm)", 50, -10, 10);
+        IHistogram1D bsconVz = aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Vz (mm)", 50, -50, 50);
+        IHistogram1D bsconChi2 = aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Chi2", 25, 0, 25);
         /* target constrained */
-        IHistogram1D tarconMass = aida.histogram1D(plotDir + "Target Constrained Mass (GeV)", 100, 0, 0.200);
-        IHistogram1D tarconVx = aida.histogram1D(plotDir + "Target Constrained Vx (mm)", 200, -5, 5);
-        IHistogram1D tarconVy = aida.histogram1D(plotDir + "Target Constrained Vy (mm)", 200, -5, 5);
-        IHistogram1D tarconVz = aida.histogram1D(plotDir + "Target Constrained Vz (mm)", 200, -50, 50);
-        IHistogram1D tarconChi2 = aida.histogram1D(plotDir + "Target Constrained Chi2", 100, 0, 100);
+        IHistogram1D tarconMass = aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Mass (GeV)", 100, 0, 0.200);
+        IHistogram1D tarconVx = aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Vx (mm)", 50, -1, 1);
+        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);
+        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);
 
     }
 
@@ -80,18 +105,56 @@
             return;
         if (!event.hasCollection(ReconstructedParticle.class, targetV0ConCandidatesColName))
             return;
+
+        if (event.hasCollection(GenericObject.class, "TriggerBank")) {
+            List<GenericObject> triggerList = event.get(GenericObject.class, "TriggerBank");
+            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
+            System.out.println(this.getClass().getSimpleName() + ":  No trigger bank found...running over all trigger types");
+
         nRecoEvents++;
 
+        List<ReconstructedParticle> unonstrainedV0List = event.get(ReconstructedParticle.class, unconstrainedV0CandidatesColName);
+        for (ReconstructedParticle uncV0 : unonstrainedV0List) {
+            Vertex uncVert = uncV0.getStartVertex();
+            aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Vx (mm)").fill(uncVert.getPosition().x());
+            aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Vy (mm)").fill(uncVert.getPosition().y());
+            aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Vz (mm)").fill(uncVert.getPosition().z());
+            aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Mass (GeV)").fill(uncV0.getMass());
+            aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Chi2").fill(uncVert.getChi2());
+
+            aida.histogram2D(plotDir + triggerType + "/" + "Mass vs Vz").fill(uncV0.getMass(), uncVert.getPosition().z());
+            //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);
+            }
+            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]);
+
+        }
+
         List<ReconstructedParticle> beamConstrainedV0List = event.get(ReconstructedParticle.class, beamConV0CandidatesColName);
-        aida.histogram1D(plotDir + "Number of V0 per event").fill(beamConstrainedV0List.size());
+        aida.histogram1D(plotDir + triggerType + "/" + "Number of V0 per event").fill(beamConstrainedV0List.size());
         for (ReconstructedParticle bsV0 : beamConstrainedV0List) {
             nTotV0++;
             Vertex bsVert = bsV0.getStartVertex();
-            aida.histogram1D(plotDir + "BS Constrained Vx (mm)").fill(bsVert.getPosition().x());
-            aida.histogram1D(plotDir + "BS Constrained Vy (mm)").fill(bsVert.getPosition().y());
-            aida.histogram1D(plotDir + "BS Constrained Vz (mm)").fill(bsVert.getPosition().z());
-            aida.histogram1D(plotDir + "BS Constrained Mass (GeV)").fill(bsV0.getMass());
-            aida.histogram1D(plotDir + "BS Constrained Chi2").fill(bsVert.getChi2());
+            aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Vx (mm)").fill(bsVert.getPosition().x());
+            aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Vy (mm)").fill(bsVert.getPosition().y());
+            aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Vz (mm)").fill(bsVert.getPosition().z());
+            aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Mass (GeV)").fill(bsV0.getMass());
+            aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Chi2").fill(bsVert.getChi2());
             sumMass += bsV0.getMass();
             sumVx += bsVert.getPosition().x();
             sumVy += bsVert.getPosition().y();
@@ -102,11 +165,11 @@
         List<ReconstructedParticle> targetConstrainedV0List = event.get(ReconstructedParticle.class, targetV0ConCandidatesColName);
         for (ReconstructedParticle tarV0 : targetConstrainedV0List) {
             Vertex tarVert = tarV0.getStartVertex();
-            aida.histogram1D(plotDir + "Target Constrained Vx (mm)").fill(tarVert.getPosition().x());
-            aida.histogram1D(plotDir + "Target Constrained Vy (mm)").fill(tarVert.getPosition().y());
-            aida.histogram1D(plotDir + "Target Constrained Vz (mm)").fill(tarVert.getPosition().z());
-            aida.histogram1D(plotDir + "Target Constrained Mass (GeV)").fill(tarV0.getMass());
-            aida.histogram1D(plotDir + "Target Constrained Chi2").fill(tarVert.getChi2());
+            aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Vx (mm)").fill(tarVert.getPosition().x());
+            aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Vy (mm)").fill(tarVert.getPosition().y());
+            aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Vz (mm)").fill(tarVert.getPosition().z());
+            aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Mass (GeV)").fill(tarV0.getMass());
+            aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Chi2").fill(tarVert.getChi2());
         }
     }
 
@@ -127,9 +190,9 @@
         IAnalysisFactory analysisFactory = IAnalysisFactory.create();
         IFitFactory fitFactory = analysisFactory.createFitFactory();
         IFitter fitter = fitFactory.createFitter("chi2");
-        IHistogram1D bsconVx = aida.histogram1D(plotDir + "BS Constrained Vx (mm)");
-        IHistogram1D bsconVy = aida.histogram1D(plotDir + "BS Constrained Vy (mm)");
-        IHistogram1D bsconVz = aida.histogram1D(plotDir + "BS Constrained Vz (mm)");
+        IHistogram1D bsconVx = aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Vx (mm)");
+        IHistogram1D bsconVy = aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Vy (mm)");
+        IHistogram1D bsconVz = aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Vz (mm)");
         double[] init = {50.0, 0.0, 0.2, 1.0, 0.0};
         IFitResult resVx = fitVertexPosition(bsconVx, fitter, init, "range=\"(-0.5,0.5)\"");
         double[] init2 = {50.0, 0.0, 0.04, 1.0, 0.0};
@@ -156,13 +219,12 @@
         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);
-        }
-        }
+        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);
@@ -190,4 +252,12 @@
         return fitter.fit(h1d, "g+p1", init, range);
     }
 
+    private double getMomentum(Track trk) {
+
+        double px = trk.getTrackStates().get(0).getMomentum()[0];
+        double py = trk.getTrackStates().get(0).getMomentum()[1];
+        double pz = trk.getTrackStates().get(0).getMomentum()[2];
+        return Math.sqrt(px * px + py * py + pz * pz);
+    }
+
 }

Modified: java/trunk/tracking/src/main/resources/org/hps/recon/tracking/strategies/HPS-Full-L1-3.xml
 =============================================================================
--- java/trunk/tracking/src/main/resources/org/hps/recon/tracking/strategies/HPS-Full-L1-3.xml	(original)
+++ java/trunk/tracking/src/main/resources/org/hps/recon/tracking/strategies/HPS-Full-L1-3.xml	Mon Apr 27 21:31:07 2015
@@ -9,8 +9,8 @@
         <MinHits>3</MinHits>
         <MinConfirm>0</MinConfirm>
         
-        <MaxDCA>4.0</MaxDCA>
-        <MaxZ0>4.0</MaxZ0>
+        <MaxDCA>20.0</MaxDCA>
+        <MaxZ0>20.0</MaxZ0>
 
         <MaxChisq>25.0</MaxChisq>
         <BadHitChisq>10.0</BadHitChisq>

Modified: java/trunk/tracking/src/main/resources/org/hps/recon/tracking/strategies/HPS-Full-L4-6.xml
 =============================================================================
--- java/trunk/tracking/src/main/resources/org/hps/recon/tracking/strategies/HPS-Full-L4-6.xml	(original)
+++ java/trunk/tracking/src/main/resources/org/hps/recon/tracking/strategies/HPS-Full-L4-6.xml	Mon Apr 27 21:31:07 2015
@@ -9,8 +9,8 @@
         <MinHits>3</MinHits>
         <MinConfirm>0</MinConfirm>
         
-        <MaxDCA>10.0</MaxDCA>
-        <MaxZ0>10.0</MaxZ0>
+        <MaxDCA>20.0</MaxDCA>
+        <MaxZ0>20.0</MaxZ0>
 
         <MaxChisq>25.0</MaxChisq>
         <BadHitChisq>10.0</BadHitChisq>

Added: java/trunk/users/src/main/java/org/hps/users/mgraham/PositronDebug.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/mgraham/PositronDebug.java	(added)
+++ java/trunk/users/src/main/java/org/hps/users/mgraham/PositronDebug.java	Mon Apr 27 21:31:07 2015
@@ -0,0 +1,201 @@
+package org.hps.users.mgraham;
+
+import hep.aida.IHistogram1D;
+import hep.aida.IHistogram2D;
+import java.util.ArrayList;
+import java.util.List;
+import org.hps.recon.ecal.triggerbank.AbstractIntData;
+import org.hps.recon.ecal.triggerbank.TIData;
+import org.lcsim.detector.tracker.silicon.HpsSiSensor;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.GenericObject;
+import org.lcsim.event.Track;
+import org.lcsim.event.TrackState;
+import org.lcsim.event.TrackerHit;
+import org.lcsim.geometry.Detector;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+/**
+ *
+ * @author mgraham
+ */
+public class PositronDebug extends Driver {
+
+    static private AIDA aida = AIDA.defaultInstance();
+    private final String helicalTrackHitCollectionName = "HelicalTrackHits";
+    private final String rotatedTrackHitCollectionName = "RotatedHelicalTrackHits";
+    private final String helicalTrackHitRelationsCollectionName = "HelicalTrackHitRelations";
+    private final String rotatedHelicalTrackHitRelationsCollectionName = "RotatedHelicalTrackHitRelations";
+    private final String trackCollectionName = "MatchedTracks";
+    private final String trackerName = "Tracker";
+    private static final String nameStrip = "Tracker_TestRunModule_";
+    private String l1to3CollectionName = "L1to3Tracks";
+    private String l4to6CollectionName = "L4to6Tracks";
+    String ecalSubdetectorName = "Ecal";
+    String ecalCollectionName = "EcalClusters";
+    private Detector detector = null;
+    private List<HpsSiSensor> sensors;
+    private String triggerType = "pairs1";
+
+    IHistogram1D nTracks46PosDebug;
+    IHistogram1D nTracks13PosDebug;
+    IHistogram1D deld0PosDebug;
+    IHistogram1D delphiPosDebug;
+    IHistogram1D delwPosDebug;
+    IHistogram1D dellambdaPosDebug;
+    IHistogram1D delz0PosDebug;
+
+    IHistogram2D d0PosDebug;
+    IHistogram2D phiPosDebug;
+    IHistogram2D wPosDebug;
+    IHistogram2D lambdaPosDebug;
+    IHistogram2D z0PosDebug;
+
+    double rangeD0 = 75;
+    double rangePhi0 = 0.5;
+    double rangeOmega = 0.00050;
+    double rangeSlope = 0.06;
+    double rangeZ0 = 15;
+
+    @Override
+    protected void detectorChanged(Detector detector) {
+        aida.tree().cd("/");
+        nTracks13PosDebug = aida.histogram1D("Number of L1-3 Tracks: PosDebug ", 7, 0, 7.0);
+        nTracks46PosDebug = aida.histogram1D("Number of L4-6 Tracks: PosDebug ", 7, 0, 7.0);
+
+        deld0PosDebug = aida.histogram1D("Delta d0: PosDebug", 50, -rangeD0, rangeD0);
+        delphiPosDebug = aida.histogram1D("Delta sin(phi): PosDebug", 50, -rangePhi0, rangePhi0);
+        delwPosDebug = aida.histogram1D("Delta curvature: PosDebug", 50, -rangeOmega, rangeOmega);
+        dellambdaPosDebug = aida.histogram1D("Delta slope: PosDebug", 50, -rangeSlope, rangeSlope);
+        delz0PosDebug = aida.histogram1D("Delta y0: PosDebug", 50, -rangeZ0, rangeZ0);
+
+        d0PosDebug = aida.histogram2D("debug positrons d0: L46vs L13", 50, -rangeD0, rangeD0, 50, -rangeD0, rangeD0);
+        phiPosDebug = aida.histogram2D("debug positrons sin(phi): L46vs L13", 50, -rangePhi0, rangePhi0, 50, -rangePhi0, rangePhi0);
+        wPosDebug = aida.histogram2D("debug positrons curvature: L46vs L13", 50, -rangeOmega, rangeOmega, 50, -rangeOmega, rangeOmega);
+        lambdaPosDebug = aida.histogram2D("debug positrons slope: L46vs L13", 50, -rangeSlope, rangeSlope, 50, -rangeSlope, rangeSlope);
+        z0PosDebug = aida.histogram2D("debug positrons y0: L46vs L13", 50, -rangeZ0, rangeZ0, 50, -rangeZ0, rangeZ0);
+
+    }
+
+    @Override
+    public void process(EventHeader event) {
+        //select single trigger  type 
+        if (event.hasCollection(GenericObject.class, "TriggerBank")) {
+            List<GenericObject> triggerList = event.get(GenericObject.class, "TriggerBank");
+            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
+            System.out.println(this.getClass().getSimpleName() + ":  No trigger bank found...running over all trigger types");
+
+        if (!event.hasCollection(Track.class, trackCollectionName))
+            return;
+
+        boolean hasElectronTrack = false;
+        boolean hasPositronTrack = false;
+        boolean electronIsTop = false;
+        Track eleTrack = null;
+        Track posTrack = null;
+        List<Track> tracks = event.get(Track.class, trackCollectionName);
+        for (Track trk : tracks)
+            if (trk.getCharge() > 0) {
+                hasElectronTrack = true;
+                eleTrack = trk;
+                if (trk.getTrackerHits().get(0).getPosition()[2] > 0)
+                    electronIsTop = true;
+            } else {
+                System.out.println("Found a positron");
+                System.out.println(trk.toString());
+                posTrack = trk;
+            }
+
+        if (!event.hasCollection(Track.class, l1to3CollectionName))
+            return;
+
+        if (!event.hasCollection(Track.class, l4to6CollectionName))
+            return;
+
+        List<Track> l1to3tracks = event.get(Track.class, l1to3CollectionName);
+        List<Track> l4to6tracks = event.get(Track.class, l4to6CollectionName);
+
+        List<Track> l1to3tracksTop = splitTrackList(l1to3tracks, true);
+        List<Track> l1to3tracksBot = splitTrackList(l1to3tracks, false);
+        List<Track> l4to6tracksTop = splitTrackList(l4to6tracks, true);
+        List<Track> l4to6tracksBot = splitTrackList(l4to6tracks, false);
+
+        //if we have an electron, but no positron...why not?
+        if (eleTrack != null && posTrack == null)
+            if (electronIsTop)//positron should be on bottom
+                fillPlots(l1to3tracksBot, l4to6tracksBot);
+            else //positron in on top
+                fillPlots(l1to3tracksTop, l4to6tracksTop);
+
+    }
+
+    public boolean matchTriggerType(TIData triggerData) {
+        if (triggerType.contentEquals("") || triggerType.contentEquals("all"))
+            return true;
+        if (triggerData.isSingle0Trigger() && triggerType.contentEquals("singles0"))
+            return true;
+        if (triggerData.isSingle1Trigger() && triggerType.contentEquals("singles1"))
+            return true;
+        if (triggerData.isPair0Trigger() && triggerType.contentEquals("pairs0"))
+            return true;
+        return triggerData.isPair1Trigger() && triggerType.contentEquals("pairs1");
+    }
+
+    private List<Track> splitTrackList(List<Track> trks, boolean doTop) {
+        List<Track> tracksHalf = new ArrayList<Track>();
+        boolean isTop = false;
+        boolean isBot = false;
+        for (Track trk : trks) {
+            isTop = false;
+            isBot = false;
+            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 && doTop == true)  //if we want top tracks and all hits are in top
+                tracksHalf.add(trk);
+            if (isBot == true && isTop != true && doTop == false) //if we want bottom tracks and all hits are in bottom
+                tracksHalf.add(trk);
+        }
+        return tracksHalf;
+    }
+
+    private void fillPlots(List<Track> l1to3tracks, List<Track> l4to6tracks) {
+        int ntrksL1to3Pass = 0;
+        int ntrksL4to6Pass = 0;
+        for (Track trk46 : l4to6tracks) {
+            TrackState ts46 = trk46.getTrackStates().get(0);
+            for (Track trk13 : l1to3tracks) {
+                TrackState ts13 = trk13.getTrackStates().get(0);
+                deld0PosDebug.fill(ts46.getD0() - ts13.getD0());
+                delphiPosDebug.fill(Math.sin(ts46.getPhi()) - Math.sin(ts13.getPhi()));
+                delwPosDebug.fill(ts46.getOmega() - ts13.getOmega());
+                delz0PosDebug.fill(ts46.getZ0() - ts13.getZ0());
+                dellambdaPosDebug.fill(ts46.getTanLambda() - ts13.getTanLambda());
+
+                d0PosDebug.fill(ts46.getD0(), ts13.getD0());
+                phiPosDebug.fill(Math.sin(ts46.getPhi()), Math.sin(ts13.getPhi()));
+                wPosDebug.fill(ts46.getOmega(), ts13.getOmega());
+                lambdaPosDebug.fill(ts46.getTanLambda(), ts13.getTanLambda());
+                z0PosDebug.fill(ts46.getZ0(), ts13.getZ0());
+
+            }
+        }
+    }
+
+    private double trackTime(Track trk) {
+        int nhits = trk.getTrackerHits().size();
+        double sumTime = 0;
+        for (TrackerHit trkHit : trk.getTrackerHits())
+            sumTime += trkHit.getTime();
+        return sumTime / nhits;
+    }
+}