LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  March 2015

HPS-SVN March 2015

Subject:

r2575 - in /java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon: PlotAndFitUtilities.java SVTOpeningAlignment.java TrackResiduals.java TrackTimePlots.java TrackingReconPlots.java

From:

[log in to unmask]

Reply-To:

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

Date:

Thu, 26 Mar 2015 15:07:17 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (1158 lines)

Author: [log in to unmask]
Date: Thu Mar 26 08:07:13 2015
New Revision: 2575

Log:
Online monitoring drivers for tracking & recon

Added:
    java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/PlotAndFitUtilities.java
Modified:
    java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/SVTOpeningAlignment.java
    java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackResiduals.java
    java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackTimePlots.java
    java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackingReconPlots.java

Added: java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/PlotAndFitUtilities.java
 =============================================================================
--- java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/PlotAndFitUtilities.java	(added)
+++ java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/PlotAndFitUtilities.java	Thu Mar 26 08:07:13 2015
@@ -0,0 +1,131 @@
+package org.hps.monitoring.drivers.trackrecon;
+
+import hep.aida.IBaseHistogram;
+import hep.aida.ICloud1D;
+import hep.aida.IFitFactory;
+import hep.aida.IFitResult;
+import hep.aida.IFitter;
+import hep.aida.IFunction;
+import hep.aida.IFunctionFactory;
+import hep.aida.IHistogram1D;
+import hep.aida.IHistogram2D;
+import hep.aida.IPlotter;
+import hep.aida.IPlotterFactory;
+import hep.aida.IPlotterStyle;
+import hep.aida.IProfile1D;
+import hep.aida.IProfile2D;
+import hep.aida.ref.plotter.style.registry.IStyleStore;
+import hep.aida.ref.plotter.style.registry.StyleRegistry;
+import org.lcsim.util.aida.AIDA;
+
+/**
+ *
+ * @author mgraham
+ */
+public class PlotAndFitUtilities {
+
+    static private AIDA aida = AIDA.defaultInstance();
+    
+    /*
+     *  creates a new plotter with one region and puts the histogram in it
+     *  copied from org.hps.monitoring.drivers.ecal.EcalMonitoringUtilities.java
+     */
+
+    static IPlotter plot(IPlotterFactory plotterFactory, IBaseHistogram histogram, IPlotterStyle style, boolean show) {
+        if (style == null)
+            style = getPlotterStyle(histogram);
+        IPlotter plotter = plotterFactory.create(histogram.title());
+        plotter.createRegion();
+        plotter.region(0).plot(histogram, style);
+        if (show)
+            plotter.show();
+        return plotter;
+    }
+
+    /*
+     *  puts a histogram on a plotter region with a  style
+     *  copied from org.hps.monitoring.drivers.ecal.EcalMonitoringUtilities.java
+     */
+    static void plot(IPlotter plotter, IBaseHistogram histogram, IPlotterStyle style, int region) {
+        if (style == null)
+            style = getPlotterStyle(histogram);
+        System.out.println("Putting plot in region "+region);
+        plotter.region(region).plot(histogram, style);
+
+    }
+      /*
+     *  puts a function on a plotter region with a  style
+     *  copied from org.hps.monitoring.drivers.ecal.EcalMonitoringUtilities.java
+     */
+      static void plot(IPlotter plotter, IFunction function, IPlotterStyle style, int region) {
+        if (style == null)
+            style = getPlotterStyle(function);
+        System.out.println("Putting function in region "+region);
+        plotter.region(region).plot(function, style);
+    }
+
+    /*
+     *  gets default plotter style based on histogram type
+     *  copied from org.hps.monitoring.drivers.ecal.EcalMonitoringUtilities.java
+     */
+    static IPlotterStyle getPlotterStyle(IBaseHistogram histogram) {
+        StyleRegistry styleRegistry = StyleRegistry.getStyleRegistry();
+        IStyleStore store = styleRegistry.getStore("DefaultStyleStore");
+        IPlotterStyle style = null;
+        if ((histogram instanceof IHistogram1D) || (histogram instanceof ICloud1D) || (histogram instanceof IProfile1D))
+            style = store.getStyle("DefaultHistogram1DStyle");
+        else if ((histogram instanceof IHistogram2D) || (histogram instanceof IProfile2D))
+            style = store.getStyle("DefaultColorMapStyle");
+        if (style == null)
+            throw new RuntimeException("A default style could not be found for " + histogram.title());
+
+        //custom stuff...mg
+        style.dataStyle().errorBarStyle().setVisible(false);
+        style.legendBoxStyle().setVisible(false);
+        style.dataStyle().outlineStyle().setVisible(false);
+        
+        return style;
+    }
+    
+       /*
+     *  gets default plotter style for a function type
+     *  copied from org.hps.monitoring.drivers.ecal.EcalMonitoringUtilities.java
+     */
+    static IPlotterStyle getPlotterStyle(IFunction func) {
+        StyleRegistry styleRegistry = StyleRegistry.getStyleRegistry();
+        IStyleStore store = styleRegistry.getStore("DefaultStyleStore");
+        IPlotterStyle style = null;        
+        style = store.getStyle("DefaultFunctionStyle");    
+        if (style == null)
+            throw new RuntimeException("A default style could not be found for " + func.title());
+        return style;
+    }
+
+    static IFitResult performGaussianFit(IHistogram1D histogram) {
+        IFunctionFactory functionFactory=aida.analysisFactory().createFunctionFactory(null);
+        IFitFactory fitFactory = aida.analysisFactory().createFitFactory();
+        IFunction function = functionFactory.createFunctionByName("Example Fit", "G");
+        IFitter fitter = fitFactory.createFitter("chi2", "jminuit");
+        double[] parameters = new double[3];
+        parameters[0] = histogram.maxBinHeight();
+        parameters[1] = histogram.mean();
+        parameters[2] = histogram.rms();
+        function.setParameters(parameters);
+        IFitResult fitResult = null;
+        try {
+            fitResult = fitter.fit(histogram, function);
+        } catch (RuntimeException e) {
+            System.out.println(e.getMessage());
+        }
+        return fitResult;
+    }
+
+    static void fitAndPutParameters(IHistogram1D hist, IFunction function) {
+        IFitResult fr = performGaussianFit(hist);
+        if (fr != null) {
+            IFunction currentFitFunction = fr.fittedFunction();
+            function.setParameters(currentFitFunction.parameters());
+        }
+    }
+
+}

Modified: java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/SVTOpeningAlignment.java
 =============================================================================
--- java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/SVTOpeningAlignment.java	(original)
+++ java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/SVTOpeningAlignment.java	Thu Mar 26 08:07:13 2015
@@ -1,14 +1,21 @@
 package org.hps.monitoring.drivers.trackrecon;
 
 import hep.aida.IAnalysisFactory;
+import hep.aida.IFitFactory;
+import hep.aida.IFitResult;
+import hep.aida.IFitter;
+import hep.aida.IFunction;
+import hep.aida.IFunctionFactory;
 import hep.aida.IHistogram1D;
 import hep.aida.IPlotter;
+import hep.aida.IPlotterFactory;
 import hep.aida.IPlotterStyle;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import static org.hps.monitoring.drivers.trackrecon.PlotAndFitUtilities.fitAndPutParameters;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.Track;
 import org.lcsim.event.TrackState;
@@ -17,6 +24,7 @@
 import org.lcsim.geometry.Detector;
 import org.lcsim.util.Driver;
 import org.lcsim.util.aida.AIDA;
+import static org.hps.monitoring.drivers.trackrecon.PlotAndFitUtilities.performGaussianFit;
 
 /**
  *
@@ -24,7 +32,7 @@
  */
 public class SVTOpeningAlignment extends Driver {
 
-    private AIDA aida = AIDA.defaultInstance();
+    static private AIDA aida = AIDA.defaultInstance();
     private String helicalTrackHitCollectionName = "HelicalTrackHits";
     private String rotatedTrackHitCollectionName = "RotatedHelicalTrackHits";
     private String l1to3CollectionName = "L1to3Tracks";
@@ -36,6 +44,32 @@
     IHistogram1D nTracks13Top;
     IHistogram1D nTracks46Bot;
     IHistogram1D nTracks13Bot;
+    IHistogram1D deld0Top;
+    IHistogram1D delphiTop;
+    IHistogram1D delwTop;
+    IHistogram1D dellambdaTop;
+    IHistogram1D delz0Top;
+    IHistogram1D deld0Bot;
+    IHistogram1D delphiBot;
+    IHistogram1D delwBot;
+    IHistogram1D dellambdaBot;
+    IHistogram1D delz0Bot;
+
+    IPlotterFactory plotterFactory;
+    IFunctionFactory functionFactory;
+    IFitFactory fitFactory;
+    IFunction fd0Top;
+    IFunction fphi0Top;
+    IFunction fz0Top;
+    IFunction flambdaTop;
+    IFunction fwTop;
+    IFunction fd0Bot;
+    IFunction fphi0Bot;
+    IFunction fz0Bot;
+    IFunction flambdaBot;
+    IFunction fwBot;
+
+    IFitter jminChisq;
 
     public SVTOpeningAlignment() {
     }
@@ -61,56 +95,92 @@
         aida.tree().cd("/");
 
         IAnalysisFactory fac = aida.analysisFactory();
-        plotterTop = fac.createPlotterFactory().create("HPS Tracking Plots");
-        plotterTop.setTitle("Momentum");
+        IPlotterFactory pfac = fac.createPlotterFactory("SVT Alignment");
+        functionFactory = aida.analysisFactory().createFunctionFactory(null);
+        fitFactory = aida.analysisFactory().createFitFactory();
+        jminChisq = fitFactory.createFitter("chi2", "jminuit");
+
+        plotterTop = pfac.create("Top Layers");
         IPlotterStyle style = plotterTop.style();
         style.dataStyle().fillStyle().setColor("yellow");
         style.dataStyle().errorBarStyle().setVisible(false);
+        style.legendBoxStyle().setVisible(false);
+        style.dataStyle().outlineStyle().setVisible(false);
         plotterTop.createRegions(3, 3);
         //plotterFrame.addPlotter(plotter);
 
+        IPlotterStyle functionStyle = pfac.createPlotterStyle();
+        functionStyle.dataStyle().lineStyle().setColor("red");
+        functionStyle.dataStyle().markerStyle().setVisible(true);
+        functionStyle.dataStyle().markerStyle().setColor("black");
+        functionStyle.dataStyle().markerStyle().setShape("dot");
+        functionStyle.dataStyle().markerStyle().setSize(2);
+
         nTracks13Top = aida.histogram1D("Number of L1-3 Tracks: Top ", 7, 0, 7.0);
         nTracks46Top = aida.histogram1D("Number of L4-6 Tracks: Top ", 7, 0, 7.0);
 
-        IHistogram1D deld0Top = aida.histogram1D("Delta d0: Top", 50, -20.0, 20.0);
-        IHistogram1D delphiTop = aida.histogram1D("Delta sin(phi): Top", 50, -0.1, 0.1);
-        IHistogram1D delwTop = aida.histogram1D("Delta curvature: Top", 50, -0.0002, 0.0002);
-        IHistogram1D dellamdaTop = aida.histogram1D("Delta slope: Top", 50, -0.02, 0.02);
-        IHistogram1D delz0Top = aida.histogram1D("Delta y0: Top", 50, -5, 5.0);
+        deld0Top = aida.histogram1D("Delta d0: Top", 50, -20.0, 20.0);
+        delphiTop = aida.histogram1D("Delta sin(phi): Top", 50, -0.1, 0.1);
+        delwTop = aida.histogram1D("Delta curvature: Top", 50, -0.0002, 0.0002);
+        dellambdaTop = aida.histogram1D("Delta slope: Top", 50, -0.02, 0.02);
+        delz0Top = aida.histogram1D("Delta y0: Top", 50, -5, 5.0);
+
+        fd0Top = functionFactory.createFunctionByName("Gaussian", "G");
+        fphi0Top = functionFactory.createFunctionByName("Gaussian", "G");
+        fwTop = functionFactory.createFunctionByName("Gaussian", "G");
+        flambdaTop = functionFactory.createFunctionByName("Gaussian", "G");
+        fz0Top = functionFactory.createFunctionByName("Gaussian", "G");
 
         plotterTop.region(0).plot(deld0Top);
         plotterTop.region(3).plot(delphiTop);
         plotterTop.region(6).plot(delwTop);
-        plotterTop.region(1).plot(dellamdaTop);
+        plotterTop.region(1).plot(dellambdaTop);
         plotterTop.region(4).plot(delz0Top);
         plotterTop.region(2).plot(nTracks13Top);
         plotterTop.region(5).plot(nTracks46Top);
-
-        plotterBot = fac.createPlotterFactory().create("HPS Tracking Plots");
-        plotterBot.setTitle("Momentum");
+        plotterTop.region(0).plot(fd0Top, functionStyle);
+        plotterTop.region(3).plot(fphi0Top, functionStyle);
+        plotterTop.region(6).plot(fwTop, functionStyle);
+        plotterTop.region(1).plot(flambdaTop, functionStyle);
+        plotterTop.region(4).plot(fz0Top, functionStyle);
+        plotterTop.show();
+
+        plotterBot = pfac.create("Bottom Layers");
         IPlotterStyle styleBot = plotterBot.style();
+        styleBot.legendBoxStyle().setVisible(false);
         styleBot.dataStyle().fillStyle().setColor("yellow");
         styleBot.dataStyle().errorBarStyle().setVisible(false);
+        styleBot.dataStyle().outlineStyle().setVisible(false);
         plotterBot.createRegions(3, 3);
-        //plotterFrame.addPlotter(plotter);
 
         nTracks13Bot = aida.histogram1D("Number of L1-3 Tracks: Bot ", 7, 0, 7.0);
         nTracks46Bot = aida.histogram1D("Number of L4-6 Tracks: Bot ", 7, 0, 7.0);
 
-        IHistogram1D deld0Bot = aida.histogram1D("Delta d0: Bot", 50, -20.0, 20.0);
-        IHistogram1D delphiBot = aida.histogram1D("Delta sin(phi): Bot", 50, -0.1, 0.1);
-        IHistogram1D delwBot = aida.histogram1D("Delta curvature: Bot", 50, -0.0002, 0.0002);
-        IHistogram1D dellamdaBot = aida.histogram1D("Delta slope: Bot", 50, -0.02, 0.02);
-        IHistogram1D delz0Bot = aida.histogram1D("Delta y0: Bot", 50, -5, 5.0);
+        deld0Bot = aida.histogram1D("Delta d0: Bot", 50, -20.0, 20.0);
+        delphiBot = aida.histogram1D("Delta sin(phi): Bot", 50, -0.1, 0.1);
+        delwBot = aida.histogram1D("Delta curvature: Bot", 50, -0.0002, 0.0002);
+        dellambdaBot = aida.histogram1D("Delta slope: Bot", 50, -0.02, 0.02);
+        delz0Bot = aida.histogram1D("Delta y0: Bot", 50, -5, 5.0);
+
+        fd0Bot = functionFactory.createFunctionByName("Gaussian", "G");
+        fphi0Bot = functionFactory.createFunctionByName("Gaussian", "G");
+        fwBot = functionFactory.createFunctionByName("Gaussian", "G");
+        flambdaBot = functionFactory.createFunctionByName("Gaussian", "G");
+        fz0Bot = functionFactory.createFunctionByName("Gaussian", "G");
 
         plotterBot.region(0).plot(deld0Bot);
         plotterBot.region(3).plot(delphiBot);
         plotterBot.region(6).plot(delwBot);
-        plotterBot.region(1).plot(dellamdaBot);
+        plotterBot.region(1).plot(dellambdaBot);
         plotterBot.region(4).plot(delz0Bot);
         plotterBot.region(2).plot(nTracks13Bot);
         plotterBot.region(5).plot(nTracks46Bot);
-
+        plotterBot.region(0).plot(fd0Bot, functionStyle);
+        plotterBot.region(3).plot(fphi0Bot, functionStyle);
+        plotterBot.region(6).plot(fwBot, functionStyle);
+        plotterBot.region(1).plot(flambdaBot, functionStyle);
+        plotterBot.region(4).plot(fz0Bot, functionStyle);
+        plotterBot.show();
     }
 
     @Override
@@ -142,25 +212,38 @@
             TrackState ts46 = trk46.getTrackStates().get(0);
             for (Track trk13 : l1to3tracksTop) {
                 TrackState ts13 = trk13.getTrackStates().get(0);
-                aida.histogram1D("Delta d0: Top").fill(ts46.getD0() - ts13.getD0());
-                aida.histogram1D("Delta sin(phi): Top").fill(Math.sin(ts46.getPhi()) - Math.sin(ts13.getPhi()));
-                aida.histogram1D("Delta curvature: Top").fill(ts46.getOmega() - ts13.getOmega());
-                aida.histogram1D("Delta y0: Top").fill(ts46.getZ0() - ts13.getZ0());
-                aida.histogram1D("Delta slope: Top").fill(ts46.getTanLambda() - ts13.getTanLambda());
+                deld0Top.fill(ts46.getD0() - ts13.getD0());
+                delphiTop.fill(Math.sin(ts46.getPhi()) - Math.sin(ts13.getPhi()));
+                delwTop.fill(ts46.getOmega() - ts13.getOmega());
+                delz0Top.fill(ts46.getZ0() - ts13.getZ0());
+                dellambdaTop.fill(ts46.getTanLambda() - ts13.getTanLambda());
             }
         }
+        fitAndPutParameters(deld0Top, fd0Top);
+        fitAndPutParameters(delphiTop, fphi0Top);
+        fitAndPutParameters(delwTop, fwTop);
+        fitAndPutParameters(delz0Top, fz0Top);
+        fitAndPutParameters(dellambdaTop, flambdaTop);
 
         for (Track trk46 : l4to6tracksBot) {
             TrackState ts46 = trk46.getTrackStates().get(0);
             for (Track trk13 : l1to3tracksBot) {
                 TrackState ts13 = trk13.getTrackStates().get(0);
-                aida.histogram1D("Delta d0: Bot").fill(ts46.getD0() - ts13.getD0());
-                aida.histogram1D("Delta sin(phi): Bot").fill(Math.sin(ts46.getPhi()) - Math.sin(ts13.getPhi()));
-                aida.histogram1D("Delta curvature: Bot").fill(ts46.getOmega() - ts13.getOmega());
-                aida.histogram1D("Delta y0: Bot").fill(ts46.getZ0() - ts13.getZ0());
-                aida.histogram1D("Delta slope: Bot").fill(ts46.getTanLambda() - ts13.getTanLambda());
+                deld0Bot.fill(ts46.getD0() - ts13.getD0());
+                delphiBot.fill(Math.sin(ts46.getPhi()) - Math.sin(ts13.getPhi()));
+                delwBot.fill(ts46.getOmega() - ts13.getOmega());
+                delz0Bot.fill(ts46.getZ0() - ts13.getZ0());
+                dellambdaBot.fill(ts46.getTanLambda() - ts13.getTanLambda());
             }
         }
+
+//        IFunction currentFitFunction = performGaussianFit(deld0Bot, fd0Bot, jminChisq).fittedFunction();;
+//         fd0Bot.setParameters(currentFitFunction.parameters());
+        fitAndPutParameters(deld0Bot, fd0Bot);
+        fitAndPutParameters(delphiBot, fphi0Bot);
+        fitAndPutParameters(delwBot, fwBot);
+        fitAndPutParameters(delz0Bot, fz0Bot);
+        fitAndPutParameters(dellambdaBot, flambdaBot);
 
     }
 

Modified: java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackResiduals.java
 =============================================================================
--- java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackResiduals.java	(original)
+++ java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackResiduals.java	Thu Mar 26 08:07:13 2015
@@ -4,15 +4,17 @@
 import hep.aida.IFitFactory;
 import hep.aida.IFitResult;
 import hep.aida.IFitter;
+import hep.aida.IFunction;
+import hep.aida.IFunctionFactory;
 import hep.aida.IHistogram1D;
 import hep.aida.IPlotter;
-import hep.aida.IPlotterStyle;
+import hep.aida.IPlotterFactory;
 import java.io.IOException;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import static org.hps.monitoring.drivers.trackrecon.PlotAndFitUtilities.fitAndPutParameters;
+import static org.hps.monitoring.drivers.trackrecon.PlotAndFitUtilities.plot;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.GenericObject;
 import org.lcsim.geometry.Detector;
@@ -30,41 +32,40 @@
     String trackResidualsCollectionName = "TrackResiduals";
     String gblStripClusterDataCollectionName = "GBLStripClusterData";
     private AIDA aida = AIDA.defaultInstance();
-
     int nEvents = 0;
-
-    private String plotDir = "TrackResiduals/";
-    String[] trackingQuantNames = {};
     int nmodules = 6;
-    private String posresDir = "PostionResiduals/";
-    private String uresDir = "UResiduals/";
-    private String timeresDir = "TimeResiduals/";
-  
+
     IPlotter plotterResX;
     IPlotter plotterResY;
 
+    IPlotterFactory plotterFactory;
+    IFunctionFactory functionFactory;
+    IFitFactory fitFactory;
+    IFunction fd0Top;
+
     String outputPlots;
-
-    void setupPlotter(IPlotter plotter, String title) {
-        plotter.setTitle(title);
-        IPlotterStyle style = plotter.style();
-        style.dataStyle().fillStyle().setColor("yellow");
-        style.dataStyle().errorBarStyle().setVisible(false);
-    }
+    IHistogram1D[] xresidTop = new IHistogram1D[nmodules];
+    IHistogram1D[] yresidTop = new IHistogram1D[nmodules];
+    IHistogram1D[] xresidBot = new IHistogram1D[nmodules];
+    IHistogram1D[] yresidBot = new IHistogram1D[nmodules];
+
+    IFunction[] fxresidTop = new IFunction[nmodules];
+    IFunction[] fyresidTop = new IFunction[nmodules];
+    IFunction[] fxresidBot = new IFunction[nmodules];
+    IFunction[] fyresidBot = new IFunction[nmodules];
 
     private int computePlotterRegion(int i, boolean istop) {
-    
-        int region =-99;
+
+        int region = -99;
         if (i < 3)
             if (istop)
-                region= i*4;
+                region = i * 4;
             else
-                region= i*4+1;
+                region = i * 4 + 1;
+        else if (istop)
+            region = (i - 3) * 4 + 2;
         else
-            if (istop)
-                region= (i-3)*4+2 ;
-            else
-                region= (i-3)*4+3;
+            region = (i - 3) * 4 + 3;
 //     System.out.println("Setting region to "+region);
         return region;
     }
@@ -75,25 +76,39 @@
         aida.tree().cd("/");
 //        resetOccupancyMap(); // this is for calculating averages         
         IAnalysisFactory fac = aida.analysisFactory();
-
-        plotterResX = fac.createPlotterFactory().create("HPS Tracking Plots");
-        setupPlotter(plotterResX, "X-Residuals");
+        IPlotterFactory pfac = fac.createPlotterFactory("Track Residuals");
+        functionFactory = aida.analysisFactory().createFunctionFactory(null);
+        fitFactory = aida.analysisFactory().createFitFactory();
+        plotterResX = pfac.create("X Residuals");
+        plotterResY = pfac.create("Y Residuals");
         plotterResX.createRegions(3, 4);
-
-        plotterResY = fac.createPlotterFactory().create("HPS Tracking Plots");
-        setupPlotter(plotterResY, "Y-Residuals");
         plotterResY.createRegions(3, 4);
 
         for (int i = 1; i <= nmodules; i++) {
-            IHistogram1D xresid = aida.histogram1D("Module " + i + " Top x Residual", 50, -getRange(i, true), getRange(i, true));
-            IHistogram1D yresid = aida.histogram1D("Module " + i + " Top y Residual", 50, -getRange(i, false), getRange(i, false));
-            IHistogram1D xresidbot = aida.histogram1D("Module " + i + " Bot x Residual", 50, -getRange(i, true), getRange(i, true));
-            IHistogram1D yresidbot = aida.histogram1D("Module " + i + " Bot y Residual", 50, -getRange(i, false), getRange(i, false));
-            plotterResX.region(computePlotterRegion(i - 1, true)).plot(xresid);
-            plotterResX.region(computePlotterRegion(i - 1, false)).plot(xresidbot);
-            plotterResY.region(computePlotterRegion(i - 1, true)).plot(yresid);
-            plotterResY.region(computePlotterRegion(i - 1, false)).plot(yresidbot);
-        }
+            xresidTop[i - 1] = aida.histogram1D("Module " + i + " Top x Residual", 50, -getRange(i, true), getRange(i, true));
+            yresidTop[i - 1] = aida.histogram1D("Module " + i + " Top y Residual", 50, -getRange(i, false), getRange(i, false));
+            xresidBot[i - 1] = aida.histogram1D("Module " + i + " Bot x Residual", 50, -getRange(i, true), getRange(i, true));
+            yresidBot[i - 1] = aida.histogram1D("Module " + i + " Bot y Residual", 50, -getRange(i, false), getRange(i, false));
+
+            fxresidTop[i - 1] = functionFactory.createFunctionByName("Gaussian", "G");
+            fyresidTop[i - 1] = functionFactory.createFunctionByName("Gaussian", "G");
+            fxresidBot[i - 1] = functionFactory.createFunctionByName("Gaussian", "G");
+            fyresidBot[i - 1] = functionFactory.createFunctionByName("Gaussian", "G");
+
+            plot(plotterResX, xresidTop[i - 1], null, computePlotterRegion(i - 1, true));
+            plot(plotterResX, xresidBot[i - 1], null, computePlotterRegion(i - 1, false));
+            plot(plotterResY, yresidTop[i - 1], null, computePlotterRegion(i - 1, true));
+            plot(plotterResY, yresidBot[i - 1], null, computePlotterRegion(i - 1, false));
+
+            plot(plotterResX, fxresidTop[i - 1], null, computePlotterRegion(i - 1, true));
+            plot(plotterResX, fxresidBot[i - 1], null, computePlotterRegion(i - 1, false));
+            plot(plotterResY, fyresidTop[i - 1], null, computePlotterRegion(i - 1, true));
+            plot(plotterResY, fyresidBot[i - 1], null, computePlotterRegion(i - 1, false));
+
+        }
+
+        plotterResX.show();
+        plotterResY.show();
 
         /*
          for (int i = 1; i <= nmodules * 2; i++) {
@@ -116,16 +131,23 @@
         for (GenericObject trd : trdList) {
             int nResid = trd.getNDouble();
             int isBot = trd.getIntVal(trd.getNInt() - 1);//last Int is the top/bottom flag
-            for (int i = 1; i <= nResid; i++)
+            for (int i = 0; i < nResid; i++)
 
                 if (isBot == 1) {
-                    aida.histogram1D("Module " + i + " Bot x Residual").fill(trd.getDoubleVal(i - 1));//x is the double value in the generic object
-                    aida.histogram1D("Module " + i + " Bot y Residual").fill(trd.getFloatVal(i - 1));//y is the float value in the generic object
+                    xresidBot[i].fill(trd.getDoubleVal(i));//x is the double value in the generic object
+                    yresidBot[i].fill(trd.getFloatVal(i));//y is the float value in the generic object
                 } else {
-                    aida.histogram1D("Module " + i + " Top x Residual").fill(trd.getDoubleVal(i - 1));//x is the double value in the generic object
-                    aida.histogram1D("Module " + i + " Top y Residual").fill(trd.getFloatVal(i - 1));//y is the float value in the generic object                    
+                    xresidTop[i].fill(trd.getDoubleVal(i));//x is the double value in the generic object
+                    yresidTop[i].fill(trd.getFloatVal(i));//y is the float value in the generic object                    
                 }
         }
+        for (int i = 0; i < nmodules; i++) {
+            fitAndPutParameters(xresidTop[i], fxresidTop[i]);
+            fitAndPutParameters(yresidTop[i], fyresidTop[i]);
+            fitAndPutParameters(xresidBot[i], fxresidBot[i]);
+            fitAndPutParameters(yresidBot[i], fyresidBot[i]);
+        }
+
         /*
          List<GenericObject> ttdList = event.get(GenericObject.class, trackTimeDataCollectionName);
          for (GenericObject ttd : ttdList) {
@@ -175,7 +197,6 @@
         return typeString + quantString + botString + layerString;
     }
 
-
     private double getRange(int layer, boolean isX) {
         double range = 2.5;
         if (isX) {
@@ -207,13 +228,6 @@
         }
         return range;
 
-    }
-
-    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);
     }
 
     public void setOutputPlots(String output) {

Modified: java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackTimePlots.java
 =============================================================================
--- java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackTimePlots.java	(original)
+++ java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackTimePlots.java	Thu Mar 26 08:07:13 2015
@@ -6,8 +6,11 @@
 import hep.aida.IPlotterFactory;
 import hep.aida.IPlotterStyle;
 import hep.aida.ref.plotter.PlotterRegion;
+import hep.aida.ref.plotter.style.registry.IStyleStore;
+import hep.aida.ref.plotter.style.registry.StyleRegistry;
 
 import java.util.List;
+import static org.hps.monitoring.drivers.trackrecon.PlotAndFitUtilities.plot;
 
 import org.hps.recon.ecal.triggerbank.AbstractIntData;
 import org.hps.recon.ecal.triggerbank.TestRunTriggerData;
@@ -38,139 +41,110 @@
     private IHistogram1D[][] t0 = new IHistogram1D[4][12];
     private IHistogram1D[][] trackHitT0 = new IHistogram1D[4][12];
     private IHistogram1D[][] trackHitDt = new IHistogram1D[4][12];
-    private IHistogram2D[][] trackHit2D = new IHistogram2D[4][12];
+    private IHistogram2D[] trackHit2D = new IHistogram2D[12];
     private IHistogram1D[] trackT0 = new IHistogram1D[4];
     private IHistogram2D[] trackTrigTime = new IHistogram2D[4];
-    private IHistogram2D[][] trackHitDtChan = new IHistogram2D[4][12];
+    private IHistogram2D[] trackHitDtChan = new IHistogram2D[12];
     private IHistogram1D[] trackTimeRange = new IHistogram1D[4];
     private IHistogram2D[] trackTimeMinMax = new IHistogram2D[4];
 
     private static final String subdetectorName = "Tracker";
-
+    int nlayers=12;
     @Override
     protected void detectorChanged(Detector detector) {
-        //plotterFrame = new AIDAFrame();
-        //plotterFrame.setTitle("HPS SVT Track Time Plots");
 
         aida.tree().cd("/");
 
         List<HpsSiSensor> sensors = detector.getSubdetector(subdetectorName).getDetectorElement().findDescendants(HpsSiSensor.class);
 
-        IPlotterFactory fac = aida.analysisFactory().createPlotterFactory();
-
-        IPlotterStyle style;
-
-        plotter = fac.create("HPS SVT Timing Plots");
-        plotter.setTitle("Hit Times");
-        //plotterFrame.addPlotter(plotter);
-        style = plotter.style();
-        style.dataStyle().fillStyle().setColor("yellow");
-        style.dataStyle().errorBarStyle().setVisible(false);
-        plotter.createRegions(8, 5);
-
-        plotter2 = fac.create("HPS SVT Track Time");
-        plotter2.setTitle("Track Time");
-        //plotterFrame.addPlotter(plotter2);
-        style = plotter2.style();
-        style.dataStyle().fillStyle().setColor("yellow");
-        style.dataStyle().errorBarStyle().setVisible(false);
+        IPlotterFactory fac = aida.analysisFactory().createPlotterFactory("Timing");
+
+        StyleRegistry styleRegistry = StyleRegistry.getStyleRegistry();
+        IStyleStore store = styleRegistry.getStore("DefaultStyleStore");
+        IPlotterStyle style2d = store.getStyle("DefaultColorMapStyle");
+        style2d.setParameter("hist2DStyle", "colorMap");
+        style2d.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+        //style2d.zAxisStyle().setParameter("scale", "log");
+        style2d.zAxisStyle().setVisible(false);
+        style2d.dataBoxStyle().setVisible(false);
+       
+        
+        IPlotterStyle styleOverlay = store.getStyle("DefaultHistogram1DStyle");
+        styleOverlay.dataStyle().errorBarStyle().setVisible(true);
+        styleOverlay.dataStyle().fillStyle().setVisible(false);        
+        styleOverlay.legendBoxStyle().setVisible(false);
+        styleOverlay.dataStyle().outlineStyle().setVisible(false);
+         
+        plotter = fac.create("Hit Times");
+        plotter.createRegions(3, 4);
+
+        plotter2 = fac.create("Track Time");
         plotter2.createRegions(2, 2);
 
-        plotter3 = fac.create("HPS SVT Timing Plots");
-        plotter3.setTitle("Track Hit Time");
-        //plotterFrame.addPlotter(plotter3);
-        style = plotter3.style();
-        style.dataStyle().fillStyle().setColor("yellow");
-        style.dataStyle().errorBarStyle().setVisible(false);
-        plotter3.createRegions(8, 5);
-
-        plotter4 = fac.create("HPS SVT Timing Plots");
-        plotter4.setTitle("Track Hit dt");
-        //plotterFrame.addPlotter(plotter4);
-        style = plotter4.style();
-        style.dataStyle().fillStyle().setColor("yellow");
-        style.dataStyle().errorBarStyle().setVisible(false);
-        plotter4.createRegions(8, 5);
-
-        plotter5 = fac.create("HPS SVT Timing Plots");
-        plotter5.setTitle("Track Time vs. dt");
-        //plotterFrame.addPlotter(plotter5);
-        style = plotter5.style();
-        style.statisticsBoxStyle().setVisible(false);
-        style.setParameter("hist2DStyle", "colorMap");
-        style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
-        style.zAxisStyle().setParameter("scale", "log");
-        plotter5.createRegions(8, 5);
-
-        plotter6 = fac.create("HPS SVT Timing Plots");
-        plotter6.setTitle("Track dt vs. Channel");
-        //plotterFrame.addPlotter(plotter6);
-        style = plotter6.style();
-        style.statisticsBoxStyle().setVisible(false);
-        style.setParameter("hist2DStyle", "colorMap");
-        style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
-        style.zAxisStyle().setParameter("scale", "log");
-        plotter6.createRegions(8, 5);
-
-        plotter7 = fac.create("HPS SVT Track Hit Time Range");
-        plotter7.setTitle("Track Hit Time Range");
-        //plotterFrame.addPlotter(plotter7);
-        style = plotter7.style();
-        style.dataStyle().fillStyle().setColor("yellow");
-        style.dataStyle().errorBarStyle().setVisible(false);
+        plotter3 = fac.create("Track Hit Time");
+//        plotter3.createRegions(8, 5);
+        plotter3.createRegions(3, 4);
+        plotter4 = fac.create("Track Hit dt");
+//        plotter4.createRegions(8, 5);
+        plotter4.createRegions(3, 4);
+
+        plotter5 = fac.create("Track Time vs. dt");
+//        plotter5.createRegions(8, 5);
+        plotter5.createRegions(3, 4);
+
+        plotter6 = fac.create("Track dt vs. Channel");
+//        plotter6.createRegions(8, 5);
+        plotter6.createRegions(3, 4);
+
+        plotter7 = fac.create("Track Hit Time Range");
         plotter7.createRegions(2, 2);
 
         for (HpsSiSensor sensor : sensors) {
             int module = sensor.getModuleNumber();
-            int layer = sensor.getLayerNumber();
-            int region = computePlotterRegion(layer + 1, module);
-
+            int layer = sensor.getLayerNumber() - 1;
+            int region = computePlotterRegion(layer);
+            styleOverlay.dataStyle().lineStyle().setColor(getColor(module));
+            System.out.println(sensor.getName() + ":   module = " + module + "; layer = " + layer);
             t0[module][layer] = aida.histogram1D(sensor.getName() + "_timing", 75, -50, 100.0);
-            plotter.region(region).plot(t0[module][layer]);
-            //((PlotterRegion) plotter.region(region)).getPlot().getXAxis().setLabel("Hit time [ns]");
+            plot(plotter, t0[module][layer], styleOverlay, region);
             trackHitT0[module][layer] = aida.histogram1D(sensor.getName() + "_trackHit_timing", 75, -50, 4000.0);
-            plotter3.region(region).plot(trackHitT0[module][layer]);
-            //((PlotterRegion) plotter3.region(region)).getPlot().getXAxis().setLabel("Hit time [ns]");
+            plot(plotter3, trackHitT0[module][layer], styleOverlay, region);
             trackHitDt[module][layer] = aida.histogram1D(sensor.getName() + "_trackHit_dt", 50, -20, 20.0);
-            plotter4.region(region).plot(trackHitDt[module][layer]);
-            //((PlotterRegion) plotter4.region(region)).getPlot().getXAxis().setLabel("Hit time residual [ns]");
-            trackHit2D[module][layer] = aida.histogram2D(sensor.getName() + "_trackHit_dt_2D", 75, -50, 100.0, 50, -20, 20.0);
-            plotter5.region(region).plot(trackHit2D[module][layer]);
-            //((PlotterRegion) plotter5.region(region)).getPlot().getXAxis().setLabel("Track time [ns]");
-            //((PlotterRegion) plotter5.region(region)).getPlot().getYAxis().setLabel("Hit time [ns]");
-            trackHitDtChan[module][layer] = aida.histogram2D(sensor.getName() + "_trackHit_dt_chan", 200, -20, 20, 50, -20, 20.0);
-            plotter6.region(region).plot(trackHitDtChan[module][layer]);
-            //((PlotterRegion) plotter6.region(region)).getPlot().getXAxis().setLabel("Hit position [mm]");
-            //((PlotterRegion) plotter6.region(region)).getPlot().getYAxis().setLabel("Hit time residual [ns]");
-        }
+            plot(plotter4, trackHitDt[module][layer], styleOverlay, region);
+           
+        }
+        
+        
+        
+        for (int i=0; i<nlayers;i++) {            
+            int region = computePlotterRegion(i);          
+         
+            trackHit2D[i] = aida.histogram2D("Layer "+i+" trackHit vs dt", 75, -50, 100.0, 50, -20, 20.0);
+            plot(plotter5, trackHit2D[i], style2d, region);
+            trackHitDtChan[i] = aida.histogram2D("Layer "+i+" dt vschan", 200, -20, 20, 50, -20, 20.0);
+            plot(plotter6, trackHit2D[i], style2d, region);
+        }
+        plotter.show();
+        plotter3.show();
+        plotter4.show();
+        plotter5.show();
+        plotter6.show();
 
         for (int module = 0; module < 2; module++) {
 
             trackT0[module] = aida.histogram1D((module == 0 ? "Top" : "Bottom") + " Track Time", 75, -50, 100.0);
-            plotter2.region(module).plot(trackT0[module]);
-            //((PlotterRegion) plotter2.region(module)).getPlot().getXAxis().setLabel("Track time [ns]");
+            plot(plotter2, trackT0[module], null, module);
             trackTrigTime[module] = aida.histogram2D((module == 0 ? "Top" : "Bottom") + " Track Time vs. Trig Time", 75, -50, 100.0, 33, -1, 32);
-            plotter2.region(module + 2).plot(trackTrigTime[module]);
-            //((PlotterRegion) plotter2.region(module + 2)).getPlot().getXAxis().setLabel("Track time [ns]");
-            //((PlotterRegion) plotter2.region(module + 2)).getPlot().getYAxis().setLabel("Trigger time [clocks]");
-            style = plotter2.region(module + 2).style();
-            style.setParameter("hist2DStyle", "colorMap");
-            style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
-            style.zAxisStyle().setParameter("scale", "log");
+            plot(plotter2, trackTrigTime[module], style2d, module + 2);
 
             trackTimeRange[module] = aida.histogram1D((module == 0 ? "Top" : "Bottom") + " Track Hit Time Range", 75, 0, 30.0);
-            plotter7.region(module).plot(trackTimeRange[module]);
-            //((PlotterRegion) plotter7.region(module)).getPlot().getXAxis().setLabel("Track time range [ns]");
+            plot(plotter7, trackTimeRange[module], null, module);
             trackTimeMinMax[module] = aida.histogram2D((module == 0 ? "Top" : "Bottom") + " First and Last Track Hit Times", 75, -50, 100.0, 75, -50, 100.0);
-            plotter7.region(module + 2).plot(trackTimeMinMax[module]);
-            //((PlotterRegion) plotter7.region(module + 2)).getPlot().getXAxis().setLabel("First track hit time [ns]");
-            //((PlotterRegion) plotter7.region(module + 2)).getPlot().getYAxis().setLabel("Last track hit time [ns]");
-            style = plotter7.region(module + 2).style();
-            style.setParameter("hist2DStyle", "colorMap");
-            style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
-            style.zAxisStyle().setParameter("scale", "log");
-        }
-
+            plot(plotter7, trackTimeMinMax[module], style2d, module + 2);
+        }
+
+        plotter2.show();
+        plotter7.show();
         /* ===> for (int module = 0; module < 2; module++) {
          for (int layer = 0; layer < 10; layer++) {
          SiSensor sensor = SvtUtils.getInstance().getSensor(module, layer);
@@ -242,40 +216,33 @@
         int botTrigTime = -1;
         if (event.hasCollection(GenericObject.class, "TriggerBank")) {
             List<GenericObject> triggerList = event.get(GenericObject.class, "TriggerBank");
-            for (GenericObject data : triggerList) {
+            for (GenericObject data : triggerList)
                 if (AbstractIntData.getTag(data) == TestRunTriggerData.BANK_TAG) {
                     TestRunTriggerData triggerData = new TestRunTriggerData(data);
 
                     orTrig = triggerData.getOrTrig();
-                    if (orTrig != 0) {
-                        for (int i = 0; i < 32; i++) {
+                    if (orTrig != 0)
+                        for (int i = 0; i < 32; i++)
                             if ((1 << (31 - i) & orTrig) != 0) {
                                 orTrigTime = i;
                                 break;
                             }
-                        }
-                    }
                     topTrig = triggerData.getTopTrig();
-                    if (topTrig != 0) {
-                        for (int i = 0; i < 32; i++) {
+                    if (topTrig != 0)
+                        for (int i = 0; i < 32; i++)
                             if ((1 << (31 - i) & topTrig) != 0) {
                                 topTrigTime = i;
                                 break;
                             }
-                        }
-                    }
                     botTrig = triggerData.getBotTrig();
-                    if (botTrig != 0) {
-                        for (int i = 0; i < 32; i++) {
+                    if (botTrig != 0)
+                        for (int i = 0; i < 32; i++)
                             if ((1 << (31 - i) & botTrig) != 0) {
                                 botTrigTime = i;
                                 break;
                             }
-                        }
-                    }
                     break;
                 }
-            }
         }
 
         //===> IIdentifierHelper helper = SvtUtils.getInstance().getHelper();
@@ -294,46 +261,40 @@
         List<Track> tracks = event.get(Track.class, trackCollection);
         for (Track track : tracks) {
             int trackModule = -1;
-            if (track.getTrackerHits().get(0).getPosition()[2] > 0) {
+            if (track.getTrackerHits().get(0).getPosition()[2] > 0)
                 trackModule = 0;
-            } else {
+            else
                 trackModule = 1;
-            }
             double minTime = Double.POSITIVE_INFINITY;
             double maxTime = Double.NEGATIVE_INFINITY;
             int hitCount = 0;
             double trackTime = 0;
-            for (TrackerHit hitCross : track.getTrackerHits()) {
+            for (TrackerHit hitCross : track.getTrackerHits())
                 for (HelicalTrackStrip hit : ((HelicalTrackCross) hitCross).getStrips()) {
                     int layer = hit.layer();
                     trackHitT0[trackModule][layer - 1].fill(hit.dEdx() / DopedSilicon.ENERGY_EHPAIR);
                     trackTime += hit.time();
                     hitCount++;
-                    if (hit.time() > maxTime) {
+                    if (hit.time() > maxTime)
                         maxTime = hit.time();
-                    }
-                    if (hit.time() < minTime) {
+                    if (hit.time() < minTime)
                         minTime = hit.time();
-                    }
                 }
-            }
             trackTimeMinMax[trackModule].fill(minTime, maxTime);
             trackTimeRange[trackModule].fill(maxTime - minTime);
             trackTime /= hitCount;
             trackT0[trackModule].fill(trackTime);
-            if (trackModule == 0) {
+            if (trackModule == 0)
                 trackTrigTime[trackModule].fill(trackTime, topTrigTime);
-            } else {
+            else
                 trackTrigTime[trackModule].fill(trackTime, botTrigTime);
-            }
-            for (TrackerHit hitCross : track.getTrackerHits()) {
+            for (TrackerHit hitCross : track.getTrackerHits())
                 for (HelicalTrackStrip hit : ((HelicalTrackCross) hitCross).getStrips()) {
                     int layer = hit.layer();
                     trackHitDt[trackModule][layer - 1].fill(hit.time() - trackTime);
-                    trackHit2D[trackModule][layer - 1].fill(trackTime, hit.time() - trackTime);
-                    trackHitDtChan[trackModule][layer - 1].fill(hit.umeas(), hit.time() - trackTime);
+                    trackHit2D[layer - 1].fill(trackTime, hit.time() - trackTime);
+                    trackHitDtChan[layer - 1].fill(hit.umeas(), hit.time() - trackTime);
                 }
-            }
         }
     }
 
@@ -342,16 +303,58 @@
         //plotterFrame.dispose();
     }
 
-    private int computePlotterRegion(int layer, int module) {
-        int iy = (layer - 1) / 2;
-        int ix = 0;
-        if (module > 0) {
-            ix += 2;
-        }
-        if (layer % 2 == 0) {
-            ix += 1;
-        }
-        int region = ix * 5 + iy;
-        return region;
+//    private int computePlotterRegion(int layer, int module) {
+//        int iy = (layer) / 2;
+//        int ix = 0;
+//        if (module > 0)
+//            ix += 2;
+//        if (layer % 2 == 0)
+//            ix += 1;
+//        int region = ix * 5 + iy;
+//        return region;
+//    }
+    //layer 1-12
+    //module 0-4...0,2 = top; 1,3=bottom
+    //this computePlotterRegion puts top&bottom modules on same region
+    //and assume plotter is split in 3 columns, 4 rows...L0-5 on top 2 rows; L6-11 on bottom 2
+    private int computePlotterRegion(int layer) {
+
+        if (layer == 0)
+            return 0;
+        if (layer == 1)
+            return 1;
+        if (layer == 2)
+            return 4;
+        if (layer == 3)
+            return 5;
+        if (layer == 4)
+            return 8;
+        if (layer == 5)
+            return 9;
+
+        if (layer == 6)
+            return 2;
+        if (layer == 7)
+            return 3;
+        if (layer == 8)
+            return 6;
+        if (layer == 9)
+            return 7;
+        if (layer == 10)
+            return 10;
+        if (layer == 11)
+            return 11;
+        return -1;
+    }
+    
+    private String getColor(int module){
+        String color="Black";
+        if(module==1)
+            color="Green";
+        if(module==2)
+            color="Blue";
+        if(module==3)
+            color="Red";
+        return color;
     }
 }

Modified: java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackingReconPlots.java
 =============================================================================
--- java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackingReconPlots.java	(original)
+++ java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackingReconPlots.java	Thu Mar 26 08:07:13 2015
@@ -3,12 +3,13 @@
 import hep.aida.IAnalysisFactory;
 import hep.aida.IHistogram1D;
 import hep.aida.IPlotter;
-import hep.aida.IPlotterStyle;
+import hep.aida.IPlotterFactory;
 
 import java.io.IOException;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import static org.hps.monitoring.drivers.trackrecon.PlotAndFitUtilities.plot;
 
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.LCIOParameters.ParameterName;
@@ -35,59 +36,68 @@
     private String outputPlots = null;
     IPlotter plotter;
     IPlotter plotter22;
+
+    IHistogram1D nTracks;
+    IHistogram1D nhits;
+    IHistogram1D charge;
     IHistogram1D trkPx;
-    IHistogram1D nTracks;
+    IHistogram1D trkPy;
+    IHistogram1D trkPz;
+    IHistogram1D trkChi2;
+    IHistogram1D trkd0;
+    IHistogram1D trkphi;
+    IHistogram1D trkomega;
+    IHistogram1D trklam;
+    IHistogram1D trkz0;
 
     @Override
     protected void detectorChanged(Detector detector) {
         aida.tree().cd("/");
 
         IAnalysisFactory fac = aida.analysisFactory();
-        plotter = fac.createPlotterFactory().create("HPS Tracking Plots");
-        plotter.setTitle("Momentum");
-        IPlotterStyle style = plotter.style();
-        style.dataStyle().fillStyle().setColor("yellow");
-        style.dataStyle().errorBarStyle().setVisible(false);
+        IPlotterFactory pfac = fac.createPlotterFactory("Track Recon");
+        plotter = pfac.create("Momentum");
+     
         plotter.createRegions(2, 3);
         //plotterFrame.addPlotter(plotter);
-        IHistogram1D nhits = aida.histogram1D("Hits per Track", 2, 5, 7);
-        IHistogram1D charge = aida.histogram1D("Track Charge", 3, -1, 2);
+        nhits = aida.histogram1D("Hits per Track", 2, 5, 7);
+        charge = aida.histogram1D("Track Charge", 3, -1, 2);
         trkPx = aida.histogram1D("Track Momentum (Px)", 50, -0.1, 0.2);
-        IHistogram1D trkPy = aida.histogram1D("Track Momentum (Py)", 50, -0.2, 0.2);
-        IHistogram1D trkPz = aida.histogram1D("Track Momentum (Pz)", 50, 0, 3);
-        IHistogram1D trkChi2 = aida.histogram1D("Track Chi2", 50, 0, 25.0);
+        trkPy = aida.histogram1D("Track Momentum (Py)", 50, -0.2, 0.2);
+        trkPz = aida.histogram1D("Track Momentum (Pz)", 50, 0, 3);
+        trkChi2 = aida.histogram1D("Track Chi2", 50, 0, 25.0);
 
-        plotter.region(0).plot(nhits);
-        plotter.region(1).plot(charge);
-        plotter.region(2).plot(trkPx);
-        plotter.region(3).plot(trkPy);
-        plotter.region(4).plot(trkPz);
-        plotter.region(5).plot(trkChi2);
+        plot(plotter, nhits, null, 0);
+        plot(plotter, charge, null, 1);
+        plot(plotter, trkPx, null, 2);
+        plot(plotter, trkPy, null, 3);
+        plot(plotter, trkPz, null, 4);
+        plot(plotter, trkChi2, null, 5);
 
+        plotter.show();
+        
 //   ******************************************************************
         nTracks = aida.histogram1D("Number of Tracks ", 7, 0, 7.0);
-        IHistogram1D trkd0 = aida.histogram1D("d0 ", 50, -5.0, 5.0);
-        IHistogram1D trkphi = aida.histogram1D("sinphi ", 50, -0.1, 0.15);
-        IHistogram1D trkomega = aida.histogram1D("omega ", 50, -0.0006, 0.0006);
-        IHistogram1D trklam = aida.histogram1D("tan(lambda) ", 50, -0.1, 0.1);
-        IHistogram1D trkz0 = aida.histogram1D("y0 ", 50, -1.0, 1.0);
+        trkd0 = aida.histogram1D("d0 ", 50, -5.0, 5.0);
+        trkphi = aida.histogram1D("sinphi ", 50, -0.1, 0.15);
+        trkomega = aida.histogram1D("omega ", 50, -0.0006, 0.0006);
+        trklam = aida.histogram1D("tan(lambda) ", 50, -0.1, 0.1);
+        trkz0 = aida.histogram1D("y0 ", 50, -1.0, 1.0);
 
-        plotter22 = fac.createPlotterFactory().create("HPS Track Params");
-        plotter22.setTitle("Track parameters");
-        //plotterFrame.addPlotter(plotter22);
-        IPlotterStyle style22 = plotter22.style();
-        style22.dataStyle().fillStyle().setColor("yellow");
-        style22.dataStyle().errorBarStyle().setVisible(false);
+        plotter22 = pfac.create("Track parameters");
+//        IPlotterStyle style22 = plotter22.style();
+//        style22.dataStyle().fillStyle().setColor("yellow");
+//        style22.dataStyle().errorBarStyle().setVisible(false);
         plotter22.createRegions(2, 3);
-        plotter22.region(0).plot(nTracks);
-        plotter22.region(1).plot(trkd0);
-        plotter22.region(2).plot(trkphi);
-        plotter22.region(3).plot(trkomega);
-        plotter22.region(4).plot(trklam);
-        plotter22.region(5).plot(trkz0);
+        plot(plotter22, nTracks, null, 0);
+        plot(plotter22, trkd0, null, 1);
+        plot(plotter22, trkphi, null, 2);
+        plot(plotter22, trkomega, null, 3);
+        plot(plotter22, trklam, null, 4);
+        plot(plotter22, trkz0, null, 5);
+        
+        plotter22.show();
 
-        plotter22.show();
-        plotter.show();
     }
 
     public TrackingReconPlots() {
@@ -130,18 +140,18 @@
 
         for (Track trk : tracks) {
 
-            aida.histogram1D("Track Momentum (Px)").fill(trk.getTrackStates().get(0).getMomentum()[1]);
-            aida.histogram1D("Track Momentum (Py)").fill(trk.getTrackStates().get(0).getMomentum()[2]);
-            aida.histogram1D("Track Momentum (Pz)").fill(trk.getTrackStates().get(0).getMomentum()[0]);
-            aida.histogram1D("Track Chi2").fill(trk.getChi2());
+            trkPx.fill(trk.getTrackStates().get(0).getMomentum()[1]);
+            trkPy.fill(trk.getTrackStates().get(0).getMomentum()[2]);
+            trkPz.fill(trk.getTrackStates().get(0).getMomentum()[0]);
+            trkChi2.fill(trk.getChi2());
 
-            aida.histogram1D("Hits per Track").fill(trk.getTrackerHits().size());
-            aida.histogram1D("Track Charge").fill(-trk.getCharge());
-            aida.histogram1D("d0 ").fill(trk.getTrackStates().get(0).getParameter(ParameterName.d0.ordinal()));
-            aida.histogram1D("sinphi ").fill(Math.sin(trk.getTrackStates().get(0).getParameter(ParameterName.phi0.ordinal())));
-            aida.histogram1D("omega ").fill(trk.getTrackStates().get(0).getParameter(ParameterName.omega.ordinal()));
-            aida.histogram1D("tan(lambda) ").fill(trk.getTrackStates().get(0).getParameter(ParameterName.tanLambda.ordinal()));
-            aida.histogram1D("y0 ").fill(trk.getTrackStates().get(0).getParameter(ParameterName.z0.ordinal()));
+            nhits.fill(trk.getTrackerHits().size());
+            charge.fill(-trk.getCharge());
+            trkd0.fill(trk.getTrackStates().get(0).getParameter(ParameterName.d0.ordinal()));
+            trkphi.fill(Math.sin(trk.getTrackStates().get(0).getParameter(ParameterName.phi0.ordinal())));
+            trkomega.fill(trk.getTrackStates().get(0).getParameter(ParameterName.omega.ordinal()));
+            trklam.fill(trk.getTrackStates().get(0).getParameter(ParameterName.tanLambda.ordinal()));
+            trkz0.fill(trk.getTrackStates().get(0).getParameter(ParameterName.z0.ordinal()));
 
 //            SeedTrack stEle = (SeedTrack) trk;
 //            SeedCandidate seedEle = stEle.getSeedCandidate();
@@ -155,8 +165,8 @@
     public void endOfData() {
         if (outputPlots != null)
             try {
-                plotter.writeToFile(outputPlots+"-mom.gif");
-                 plotter22.writeToFile(outputPlots+"-trkparams.gif");
+                plotter.writeToFile(outputPlots + "-mom.gif");
+                plotter22.writeToFile(outputPlots + "-trkparams.gif");
             } catch (IOException ex) {
                 Logger.getLogger(TrackingReconPlots.class.getName()).log(Level.SEVERE, null, ex);
             }

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

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

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

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

Privacy Notice, Security Notice and Terms of Use