Commit in java/trunk/analysis/src/main/java/org/hps/analysis/dataquality on MAIN
DataQualityMonitor.java+20-8749 -> 750
FinalStateMonitoring.java+7-9749 -> 750
SvtMonitoring.java+1-9749 -> 750
TrackingMonitoring.java+1-10749 -> 750
TrackingResiduals.java+286-22749 -> 750
V0Monitoring.java+24-19749 -> 750
+339-77
6 modified files
mostly adding stuff to TrackingResiduals; a few minor changes in other DQM routines

java/trunk/analysis/src/main/java/org/hps/analysis/dataquality
DataQualityMonitor.java 749 -> 750
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/DataQualityMonitor.java	2014-06-27 22:50:17 UTC (rev 749)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/DataQualityMonitor.java	2014-06-30 21:06:36 UTC (rev 750)
@@ -18,14 +18,18 @@
  */
 public class DataQualityMonitor extends Driver {
 
-    public AIDA aida = AIDA.defaultInstance();
-    public DQMDatabaseManager manager;
-    public String recoVersion = "v0.0";
-    public static int runNumber = 1350;
-    public boolean overwriteDB = false;
-    public boolean connectToDB = false;
-    public boolean printDQMStrings = false;
-    public Map<String, Double> monitoredQuantityMap = new HashMap<>();
+    protected AIDA aida = AIDA.defaultInstance();
+    protected DQMDatabaseManager manager;
+    protected String recoVersion = "v0.0";
+    protected static int runNumber = 1350;
+    protected boolean overwriteDB = false;
+    protected boolean connectToDB = false;
+    protected boolean printDQMStrings = false;
+    protected Map<String, Double> monitoredQuantityMap = new HashMap<>();
+
+    protected boolean outputPlots = true;
+    protected String outputPlotDir = "DQMOutputPlots/";
+    
     public void setRecoVersion(String recoVersion) {
         this.recoVersion = recoVersion;
     }
@@ -46,6 +50,14 @@
         this.printDQMStrings = print;
     }
 
+    public void setOutputPlots(boolean out){
+        this.outputPlots=out;
+    }
+    public void setOutputPlotDir(String dir){
+        this.outputPlotDir=dir;
+    }
+
+    
     public void DataQualityMonitor() {
 
     }

java/trunk/analysis/src/main/java/org/hps/analysis/dataquality
FinalStateMonitoring.java 749 -> 750
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/FinalStateMonitoring.java	2014-06-27 22:50:17 UTC (rev 749)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/FinalStateMonitoring.java	2014-06-30 21:06:36 UTC (rev 750)
@@ -40,7 +40,7 @@
 
     String finalStateParticlesColName = "FinalStateParticles";
 
-    String[] fpQuantNames = {"nEle_per_Event", "nPos_per_Event", "nPhoton_per_Event", "nUnAssociatedTracks_per_Event", "avg_delX_at_ECal", "avg_delY_at_ECal", "avg_E_Over_P"};
+    String[] fpQuantNames = {"nEle_per_Event", "nPos_per_Event", "nPhoton_per_Event", "nUnAssociatedTracks_per_Event", "avg_delX_at_ECal", "avg_delY_at_ECal", "avg_E_Over_P","avg_mom_beam_elec","sig_mom_beam_elec"};
     //some counters
     int nRecoEvents = 0;
     int nTotEle = 0;
@@ -163,8 +163,6 @@
                 Hep3Vector trackPosAtEcal = TrackUtils.extrapolateTrack(fsTrack, clusterPosition.z());
                 double dx = trackPosAtEcal.x() - clusterPosition.x();//remember track vs detector coords
                 double dy = trackPosAtEcal.y() - clusterPosition.y();//remember track vs detector coords
-                System.out.println(trackPosAtEcal.x() + ";" + trackPosAtEcal.y() + ";" + trackPosAtEcal.z());
-                System.out.println(clusterPosition.x() + ";" + clusterPosition.y() + ";" + clusterPosition.z());
 
                 sumdelX += dx;
                 sumdelY += dy;
@@ -208,10 +206,9 @@
         IFitter fitter = fitFactory.createFitter("chi2");
         IHistogram1D beamE = aida.histogram1D(plotDir + "Beam Electrons Pz (GeV)");
         IFitResult result = fitBeamEnergyPeak(beamE, fitter, "range=\"(-10.0,10.0)\"");
-
-        for (int i = 0; i < 5; i++) {
-            double par = result.fittedParameters()[i];
-            System.out.println("Beam Energy Peak:  " + result.fittedParameterNames()[i] + " = " + par);
+        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[0], (double) nTotEle / nRecoEvents);
@@ -221,7 +218,8 @@
         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();
@@ -239,7 +237,7 @@
 
     @Override
     public void printDQMStrings() {
-        for (int i = 0; i < 7; i++)//TODO:  do this in a smarter way...loop over the map
+        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;");
     }
 

java/trunk/analysis/src/main/java/org/hps/analysis/dataquality
SvtMonitoring.java 749 -> 750
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/SvtMonitoring.java	2014-06-27 22:50:17 UTC (rev 749)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/SvtMonitoring.java	2014-06-30 21:06:36 UTC (rev 750)
@@ -238,21 +238,13 @@
         int irBot = 0;
         for (SiSensor sensor : sensors) {
             IHistogram1D sensPlot = getSensorPlot(plotDir + "t0Hit_", sensor);
-            IFitResult result = fitGaussian(sensPlot, fitter, "range=\"(-10.0,10.0)\"");
-            for (int i = 0; i < 5; i++) {
-                double par = result.fittedParameters()[i];
-                System.out.println("t0Hit_" + sensor.getName() + ":  " + result.fittedParameterNames()[i] + " = " + par);
-            }
-
+            IFitResult result = fitGaussian(sensPlot, fitter, "range=\"(-8.0,8.0)\"");
             boolean isTop = SvtUtils.getInstance().isTopLayer(sensor);
-
             if (isTop) {
-                System.out.println("Plotting into Top region " + irTop);
                 plotterTop.region(irTop).plot(sensPlot);
                 plotterTop.region(irTop).plot(result.fittedFunction());
                 irTop++;
             } else {
-                System.out.println("Plotting into Bottom region " + irBot);
                 plotterBottom.region(irBot).plot(sensPlot);
                 plotterBottom.region(irBot).plot(result.fittedFunction());
                 irBot++;

java/trunk/analysis/src/main/java/org/hps/analysis/dataquality
TrackingMonitoring.java 749 -> 750
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TrackingMonitoring.java	2014-06-27 22:50:17 UTC (rev 749)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TrackingMonitoring.java	2014-06-30 21:06:36 UTC (rev 750)
@@ -1,19 +1,11 @@
 package org.hps.analysis.dataquality;
 
 import hep.aida.IHistogram1D;
-import hep.aida.IProfile;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import org.hps.conditions.deprecated.SvtUtils;
-import org.lcsim.detector.tracker.silicon.SiSensor;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.LCIOParameters;
-import org.lcsim.event.RawTrackerHit;
 import org.lcsim.event.Track;
-import org.lcsim.event.TrackerHit;
-import org.lcsim.fit.helicaltrack.HelicalTrackCross;
-import org.lcsim.fit.helicaltrack.HelicalTrackHit;
 import org.lcsim.geometry.Detector;
 import org.lcsim.geometry.IDDecoder;
 
@@ -76,11 +68,10 @@
         aida.tree().cd("/");
                    
         if (!event.hasCollection(Track.class, trackCollectionName)) {
-            System.out.println(trackCollectionName + " does not exist; skipping event");
             aida.histogram1D(plotDir+"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());

java/trunk/analysis/src/main/java/org/hps/analysis/dataquality
TrackingResiduals.java 749 -> 750
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TrackingResiduals.java	2014-06-27 22:50:17 UTC (rev 749)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TrackingResiduals.java	2014-06-30 21:06:36 UTC (rev 750)
@@ -1,15 +1,24 @@
 package org.hps.analysis.dataquality;
 
+import hep.aida.IAnalysisFactory;
+import hep.aida.IFitFactory;
+import hep.aida.IFitResult;
+import hep.aida.IFitter;
 import hep.aida.IHistogram1D;
+import hep.aida.IPlotter;
+import hep.aida.IPlotterStyle;
+import java.io.IOException;
+import java.util.HashMap;
 import java.util.List;
-import org.hps.recon.tracking.TrackResidualsData;
-import org.hps.recon.tracking.TrackTimeData;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.GenericObject;
 import org.lcsim.geometry.Detector;
 
 /**
- * DQM driver for  track residuals in position and time
+ * DQM driver for track residuals in position and time
  *
  * @author mgraham on June 5, 2014
  */
@@ -20,25 +29,38 @@
     String trackTimeDataCollectionName = "TrackTimeData";
     String trackResidualsCollectionName = "TrackResiduals";
 
-    
     int nEvents = 0;
-    
+
     private String plotDir = "TrackResiduals/";
     String[] trackingQuantNames = {};
     int nmodules = 6;
+    private String posresDir = "PostionResiduals/";
+    private String timeresDir = "TimeResiduals/";
+    private Map<String, Double> xposTopMeanResidMap;
+    private Map<String, Double> yposTopMeanResidMap;
+    private Map<String, Double> xposBotMeanResidMap;
+    private Map<String, Double> yposBotMeanResidMap;
+    private Map<String, Double> timeMeanResidMap;
+    private Map<String, Double> xposTopSigmaResidMap;
+    private Map<String, Double> yposTopSigmaResidMap;
+    private Map<String, Double> xposBotSigmaResidMap;
+    private Map<String, Double> yposBotSigmaResidMap;
+    private Map<String, Double> timeSigmaResidMap;
 
     @Override
     protected void detectorChanged(Detector detector) {
-        
+
         aida.tree().cd("/");
-
+        resetOccupancyMap();
         for (int i = 0; i < nmodules; i++) {
-            IHistogram1D xresid = aida.histogram1D(plotDir + "Layer " + i + " x Residual", 50, -2.5, 2.5);
-            IHistogram1D yresid = aida.histogram1D(plotDir + "Layer " + i + " y Residual", 50, -1, 1);
+            IHistogram1D xresid = aida.histogram1D(plotDir + posresDir + "Module " + i + "Top x Residual", 50,-getRange(i,true),getRange(i,true));
+            IHistogram1D yresid = aida.histogram1D(plotDir + posresDir + "Module " + i + "Top y Residual", 50,-getRange(i,false),getRange(i,false));
+            IHistogram1D xresidbot = aida.histogram1D(plotDir + posresDir + "Module " + i + "Bot x Residual", 50,-getRange(i,true),getRange(i,true));
+            IHistogram1D yresidbot = aida.histogram1D(plotDir + posresDir + "Module " + i + "Bot y Residual", 50,-getRange(i,false),getRange(i,false));
         }
 
         for (int i = 0; i < nmodules * 2; i++) {
-            IHistogram1D tresid = aida.histogram1D(plotDir + "Half-Layer " + i + " t Residual", 50, -20, 20);
+            IHistogram1D tresid = aida.histogram1D(plotDir + timeresDir + "HalfModule " + i + " t Residual", 50, -20, 20);
         }
     }
 
@@ -53,37 +75,279 @@
         List<GenericObject> trdList = event.get(GenericObject.class, trackResidualsCollectionName);
         for (GenericObject trd : trdList) {
             int nResid = trd.getNDouble();
-            for (int i = 0; i < nResid; i++) {
-                aida.histogram1D(plotDir + "Layer " + i + " x Residual").fill(trd.getDoubleVal(i));//x is the double value in the generic object
-                aida.histogram1D(plotDir + "Layer " + i + " y Residual").fill(trd.getFloatVal(i));//y is the float value in the generic object
-            }
+            int isBot = trd.getIntVal(trd.getNInt() - 1);//last Int is the top/bottom flag
+            for (int i = 0; i < nResid; i++)
+                if (isBot == 1) {
+                    aida.histogram1D(plotDir + posresDir + "Module " + i + "Bot x Residual").fill(trd.getDoubleVal(i));//x is the double value in the generic object
+                    aida.histogram1D(plotDir + posresDir + "Module " + i + "Bot y Residual").fill(trd.getFloatVal(i));//y is the float value in the generic object
+                } else {
+                    aida.histogram1D(plotDir + posresDir + "Module " + i + "Top x Residual").fill(trd.getDoubleVal(i));//x is the double value in the generic object
+                    aida.histogram1D(plotDir + posresDir + "Module " + i + "Top y Residual").fill(trd.getFloatVal(i));//y is the float value in the generic object                    
+                }
+
         }
 
         List<GenericObject> ttdList = event.get(GenericObject.class, trackTimeDataCollectionName);
         for (GenericObject ttd : ttdList) {
             int nResid = ttd.getNDouble();
             for (int i = 0; i < nResid; i++)
-                aida.histogram1D(plotDir + "Half-Layer " + i + " t Residual").fill(ttd.getDoubleVal(i));//x is the double value in the generic object               
+                aida.histogram1D(plotDir + timeresDir + "HalfModule " + i + " t Residual").fill(ttd.getDoubleVal(i));//x is the double value in the generic object               
         }
     }
 
     @Override
     public void calculateEndOfRunQuantities() {
-//        monitoredQuantityMap.put(trackingQuantNames[0], (double) nTotTracks / nEvents);
+        IAnalysisFactory analysisFactory = IAnalysisFactory.create();
+        IFitFactory fitFactory = analysisFactory.createFitFactory();
+        IFitter fitter = fitFactory.createFitter("chi2");
+        IPlotter plotterXTop = analysisFactory.createPlotterFactory().create("x-residual Top");
+        IPlotter plotterXBottom = analysisFactory.createPlotterFactory().create("x-residual Bottom");
+        IPlotter plotterYTop = analysisFactory.createPlotterFactory().create("y-residual Top");
+        IPlotter plotterYBottom = analysisFactory.createPlotterFactory().create("y-residual Bottom");
+
+        IPlotter plotterTime = analysisFactory.createPlotterFactory().create("Track Time");
+
+        plotterXTop.createRegions(2, 3);
+        IPlotterStyle pstyle = plotterXTop.style();
+        pstyle.legendBoxStyle().setVisible(false);
+        plotterXBottom.createRegions(2, 3);
+        IPlotterStyle pstyle2 = plotterXBottom.style();
+        pstyle2.legendBoxStyle().setVisible(false);
+
+        plotterYTop.createRegions(2, 3);
+        IPlotterStyle pstyle3 = plotterYTop.style();
+        pstyle3.legendBoxStyle().setVisible(false);
+        plotterYBottom.createRegions(2, 3);
+        IPlotterStyle pstyle4 = plotterYBottom.style();
+        pstyle4.legendBoxStyle().setVisible(false);
+
+        plotterTime.createRegions(3, 4);
+        IPlotterStyle pstyle5 = plotterTime.style();
+        pstyle5.legendBoxStyle().setVisible(false);
+
+        int irXTop = 0;
+        int irXBot = 0;
+        int irYTop = 0;
+        int irYBot = 0;
+        for (int i = 0; i < nmodules; i++) {
+            IHistogram1D xresidTop = aida.histogram1D(plotDir + posresDir + "Module " + i + "Top x Residual");
+            IHistogram1D yresidTop = aida.histogram1D(plotDir + posresDir + "Module " + i + "Top y Residual");
+            IHistogram1D xresidBot = aida.histogram1D(plotDir + posresDir + "Module " + i + "Bot x Residual");
+            IHistogram1D yresidBot = aida.histogram1D(plotDir + posresDir + "Module " + i + "Bot y Residual");
+            IFitResult xresultTop = fitGaussian(xresidTop, fitter, "range=\"(-1.0,1.0)\"");
+            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]);
+
+        }
+        int iTime = 0;
+        for (int i = 0; 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 (outputPlots) {
+            try {
+                plotterXTop.writeToFile(outputPlotDir + "X-Residuals-Top.png");
+            } catch (IOException ex) {
+                Logger.getLogger(SvtMonitoring.class.getName()).log(Level.SEVERE, null, ex);
+            }
+            try {
+                plotterYTop.writeToFile(outputPlotDir + "Y-Residuals-Top.png");
+            } catch (IOException ex) {
+                Logger.getLogger(SvtMonitoring.class.getName()).log(Level.SEVERE, null, ex);
+            }
+            try {
+                plotterXBottom.writeToFile(outputPlotDir + "X-Residuals-Bottom.png");
+            } catch (IOException ex) {
+                Logger.getLogger(SvtMonitoring.class.getName()).log(Level.SEVERE, null, ex);
+            }
+            try {
+                plotterYBottom.writeToFile(outputPlotDir + "Y-Residuals-Bottom.png");
+            } catch (IOException ex) {
+                Logger.getLogger(SvtMonitoring.class.getName()).log(Level.SEVERE, null, ex);
+            }
+            try {
+                plotterTime.writeToFile(outputPlotDir + "Time-Residuals.png");
+            } catch (IOException ex) {
+                Logger.getLogger(SvtMonitoring.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+
     }
 
+    private String getQuantityName(int itype, int iquant, int top, int nlayer) {
+        String typeString = "position_resid";
+        String quantString = "mean_";
+        if (itype == 1)
+            typeString = "time_resid";
+        if (iquant == 1)
+            quantString = "sigma_";
+
+        String botString = "bot_";
+        if (top == 1)
+            botString = "top_";
+        if (top == 2)
+            botString = "";
+
+        String layerString = "module" + nlayer;
+        if (itype == 1)
+            layerString = "halfmodule" + nlayer;
+
+        return typeString + quantString + botString + layerString;
+    }
+
     @Override
     public void printDQMData() {
-//        System.out.println("ReconMonitoring::printDQMData");
-//        for (Map.Entry<String, Double> entry : monitoredQuantityMap.entrySet())
-//            System.out.println(entry.getKey() + " = " + entry.getValue());
-//        System.out.println("*******************************");
+        System.out.println("TrackingResiduals::printDQMData");
+        for (Map.Entry<String, Double> entry : xposTopMeanResidMap.entrySet())
+            System.out.println(entry.getKey() + " = " + entry.getValue());
+        for (Map.Entry<String, Double> entry : xposBotMeanResidMap.entrySet())
+            System.out.println(entry.getKey() + " = " + entry.getValue());
+        for (Map.Entry<String, Double> entry : xposTopSigmaResidMap.entrySet())
+            System.out.println(entry.getKey() + " = " + entry.getValue());
+        for (Map.Entry<String, Double> entry : xposBotSigmaResidMap.entrySet())
+            System.out.println(entry.getKey() + " = " + entry.getValue());
+        for (Map.Entry<String, Double> entry : yposTopMeanResidMap.entrySet())
+            System.out.println(entry.getKey() + " = " + entry.getValue());
+        for (Map.Entry<String, Double> entry : yposBotMeanResidMap.entrySet())
+            System.out.println(entry.getKey() + " = " + entry.getValue());
+        for (Map.Entry<String, Double> entry : yposTopSigmaResidMap.entrySet())
+            System.out.println(entry.getKey() + " = " + entry.getValue());
+        for (Map.Entry<String, Double> entry : yposBotSigmaResidMap.entrySet())
+            System.out.println(entry.getKey() + " = " + entry.getValue());
+        for (Map.Entry<String, Double> entry : timeMeanResidMap.entrySet())
+            System.out.println(entry.getKey() + " = " + entry.getValue());
+        for (Map.Entry<String, Double> entry : timeSigmaResidMap.entrySet())
+            System.out.println(entry.getKey() + " = " + entry.getValue());
+        System.out.println("*******************************");
     }
 
     @Override
     public void printDQMStrings() {
-//        for (Map.Entry<String, Double> entry : monitoredQuantityMap.entrySet())
-//            System.out.println("ALTER TABLE dqm ADD " + entry.getKey() + " double;");
+        for (Map.Entry<String, Double> entry : xposTopMeanResidMap.entrySet())
+            System.out.println("ALTER TABLE dqm ADD " + entry.getKey() + " double;");
+        for (Map.Entry<String, Double> entry : xposBotMeanResidMap.entrySet())
+            System.out.println("ALTER TABLE dqm ADD " + entry.getKey() + " double;");
+        for (Map.Entry<String, Double> entry : xposTopSigmaResidMap.entrySet())
+            System.out.println("ALTER TABLE dqm ADD " + entry.getKey() + " double;");
+        for (Map.Entry<String, Double> entry : xposBotSigmaResidMap.entrySet())
+            System.out.println("ALTER TABLE dqm ADD " + entry.getKey() + " double;");
+        for (Map.Entry<String, Double> entry : yposTopMeanResidMap.entrySet())
+            System.out.println("ALTER TABLE dqm ADD " + entry.getKey() + " double;");
+        for (Map.Entry<String, Double> entry : yposBotMeanResidMap.entrySet())
+            System.out.println("ALTER TABLE dqm ADD " + entry.getKey() + " double;");
+        for (Map.Entry<String, Double> entry : yposTopSigmaResidMap.entrySet())
+            System.out.println("ALTER TABLE dqm ADD " + entry.getKey() + " double;");
+        for (Map.Entry<String, Double> entry : yposBotSigmaResidMap.entrySet())
+            System.out.println("ALTER TABLE dqm ADD " + entry.getKey() + " double;");
+        for (Map.Entry<String, Double> entry : timeMeanResidMap.entrySet())
+            System.out.println("ALTER TABLE dqm ADD " + entry.getKey() + " double;");
+        for (Map.Entry<String, Double> entry : timeSigmaResidMap.entrySet())
+            System.out.println("ALTER TABLE dqm ADD " + entry.getKey() + " double;");
     }
 
+    private void resetOccupancyMap() {
+        xposBotMeanResidMap = new HashMap<>();
+        xposBotSigmaResidMap = new HashMap<>();
+        yposBotMeanResidMap = new HashMap<>();
+        yposBotSigmaResidMap = new HashMap<>();
+        xposTopMeanResidMap = new HashMap<>();
+        xposTopSigmaResidMap = new HashMap<>();
+        yposTopMeanResidMap = new HashMap<>();
+        yposTopSigmaResidMap = new HashMap<>();
+        timeMeanResidMap = new HashMap<>();
+        timeSigmaResidMap = new HashMap<>();
+        for (int i = 0; i < nmodules; i++) {
+            xposTopMeanResidMap.put(getQuantityName(0, 0, 1, i) + "_x", -999.);
+            yposTopMeanResidMap.put(getQuantityName(0, 0, 1, i) + "_y", -999.);
+            xposTopSigmaResidMap.put(getQuantityName(0, 1, 1, i) + "_x", -999.);
+            yposTopSigmaResidMap.put(getQuantityName(0, 1, 1, i) + "_y", -999.);
+            xposBotMeanResidMap.put(getQuantityName(0, 0, 0, i) + "_x", -999.);
+            yposBotMeanResidMap.put(getQuantityName(0, 0, 0, i) + "_y", -999.);
+            xposBotSigmaResidMap.put(getQuantityName(0, 1, 0, i) + "_x", -999.);
+            yposBotSigmaResidMap.put(getQuantityName(0, 1, 0, i) + "_y", -999.);
+        }
+        for (int i = 0; i < nmodules * 2; i++) {
+            timeMeanResidMap.put(getQuantityName(1, 0, 2, i) + "_dt", -999.);
+            timeSigmaResidMap.put(getQuantityName(1, 1, 2, i) + "_dt", -999.);
+        }
+
+    }
+
+    IFitResult fitGaussian(IHistogram1D h1d, IFitter fitter, String range) {
+         double[] init = {20.0, 0.0, 0.2};  
+        return fitter.fit(h1d, "g", init,range);
+//        double[] init = {20.0, 0.0, 1.0, 20, -1};
+//        return fitter.fit(h1d, "g+p1", init, range);
+    }
+
+    private double getRange(int layer, boolean isX) {
+        double range = 2.5;
+        if (isX) {
+            if (layer == 0)
+                return 0.5;
+            if (layer == 1)
+                return 0.5;
+            if (layer == 2)
+                return 0.5;
+            if (layer == 3)
+                return 1.0;
+            if (layer == 4)
+                return 1.0;
+            if (layer == 5)
+                return 1.0;
+        } else {
+            if (layer == 0)
+                return 0.005;
+            if (layer == 1)
+                return 0.5;
+            if (layer == 2)
+                return 0.5;
+            if (layer == 3)
+                return 1.0;
+            if (layer == 4)
+                return 1.0;
+            if (layer == 5)
+                return 1.5;
+        }
+        return range;
+
+    }
+
 }

java/trunk/analysis/src/main/java/org/hps/analysis/dataquality
V0Monitoring.java 749 -> 750
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/V0Monitoring.java	2014-06-27 22:50:17 UTC (rev 749)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/V0Monitoring.java	2014-06-30 21:06:36 UTC (rev 750)
@@ -23,8 +23,8 @@
  * DQM driver V0 particles (i.e. e+e- pars) plots
  * things like number of vertex position an mass
  *
- * @author mgraham  on May 14, 2014
-
+ * @author mgraham on May 14, 2014
+ *
  */
 public class V0Monitoring extends DataQualityMonitor {
 
@@ -32,7 +32,7 @@
     String unconstrainedV0CandidatesColName = "UnconstrainedV0Candidates";
     String beamConV0CandidatesColName = "BeamspotConstrainedV0Candidates";
     String targetV0ConCandidatesColName = "TargetConstrainedV0Candidates";
-    String[] fpQuantNames = {"nV0_per_Event", "avg_BSCon_mass", "avg_BSCon_Vx", "avg_BSCon_Vy", "avg_BSCon_Vz", "avg_BSCon_Chi2"};
+    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;
@@ -100,16 +100,13 @@
         }
 
         List<ReconstructedParticle> targetConstrainedV0List = event.get(ReconstructedParticle.class, targetV0ConCandidatesColName);
-//        System.out.println("Number of V0s = " + targetConstrainedV0List.size());
         for (ReconstructedParticle tarV0 : targetConstrainedV0List) {
             Vertex tarVert = tarV0.getStartVertex();
-//            System.out.println(tarVert.toString());
             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());
-            //           System.out.println("Target Constrained chi^2 = " + tarVert.getChi2());
         }
     }
 
@@ -126,12 +123,6 @@
      */
     @Override
     public void calculateEndOfRunQuantities() {
-        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[5], sumChi2 / nTotV0);
 
         IAnalysisFactory analysisFactory = IAnalysisFactory.create();
         IFitFactory fitFactory = analysisFactory.createFitFactory();
@@ -146,13 +137,13 @@
         double[] init3 = {50.0, 0.0, 3.0, 1.0, 0.0};
         IFitResult resVz = fitVertexPosition(bsconVz, fitter, init3, "range=\"(-6,6)\"");
 
-        for (int i = 0; i < 5; i++) {
-            double parVx = resVx.fittedParameters()[i];
-            double parVy = resVy.fittedParameters()[i];
-            double parVz = resVz.fittedParameters()[i];
-            System.out.println("Vertex Fit Parameters:  " + resVx.fittedParameterNames()[i] + " = " + parVx + "; " + parVy + "; " + parVz);
-        }
+        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();
@@ -171,11 +162,25 @@
             Logger.getLogger(V0Monitoring.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 < 7; i++)//TODO:  do this in a smarter way...loop over the map
+        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;");
     }
 
SVNspam 0.1