Commit in hps-java/src/main/java/org/lcsim/hps/users/phansson on MAIN
ecalGainAna.java+76-351.3 -> 1.4
use HV groups to guess gains

hps-java/src/main/java/org/lcsim/hps/users/phansson
ecalGainAna.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- ecalGainAna.java	23 Aug 2012 22:54:08 -0000	1.3
+++ ecalGainAna.java	24 Aug 2012 01:02:54 -0000	1.4
@@ -7,6 +7,7 @@
 import java.util.logging.Logger;
 import org.apache.commons.cli.*;
 import org.lcsim.geometry.util.DetectorLocator;
+import org.lcsim.hps.recon.ecal.HPSECalUtils;
 import org.lcsim.hps.recon.ecal.HPSEcalConditions;
 
 /**
@@ -118,48 +119,78 @@
 
         IHistogramFactory hf = af.createHistogramFactory(null);
 
-        IPlotter gainPlotter = af.createPlotterFactory().create();
-        gainPlotter.createRegion();
-//        gainPlotter.setTitle("ECal map");
-        IHistogram2D gainsPlot = hf.createHistogram2D("ECal map", 47, -23.5, 23.5, 11, -5.5, 5.5);
-        gainPlotter.region(0).plot(gainsPlot);
-        gainPlotter.region(0).style().statisticsBoxStyle().setVisible(false);
-        gainPlotter.region(0).style().setParameter("hist2DStyle", "colorMap");
-        gainPlotter.region(0).style().dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
-
-//        IHistogram1D pePlotsHV[][] = new IHistogram1D[4][12];
-//        for (int quad = 1; quad <= 4; ++quad) {
-//            for (int module = 1; module <= 12; ++module) {
-//                pePlotsHV[quad - 1][module - 1] = hf.createHistogram1D("E over p quadrant=" + quad + " HV group=" + module, 50, 0, 2);
-//            }
-//        }
-//
+        IPlotter plotter = af.createPlotterFactory().create();
+        plotter.createRegion();
+        IHistogram2D ecalPlot = hf.createHistogram2D("ECal map", 47, -23.5, 23.5, 11, -5.5, 5.5);
+        plotter.region(0).plot(ecalPlot);
+        plotter.region(0).style().statisticsBoxStyle().setVisible(false);
+        plotter.region(0).style().setParameter("hist2DStyle", "colorMap");
+        plotter.region(0).style().dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+
 
-        gainsPlot.setTitle("Crystal gains before iterating");
-        gainPlotter.region(0).refresh();
-//        gainPlotter.region(0).clear();
-//        gainPlotter.region(0).plot(gainsPlot);
-        for (int x = -23; x <= 23; x++) { // slot
-            for (int y = -5; y <= 5; y++) { // crate  
+        IHistogram1D pePlotsHVSim[][] = new IHistogram1D[4][12];
+        IHistogram1D pePlotsHVReal[][] = new IHistogram1D[4][12];
+        for (int quad = 1; quad <= 4; ++quad) {
+            for (int module = 1; module <= 12; ++module) {
+                pePlotsHVSim[quad - 1][module - 1] = hf.createHistogram1D("E over p quadrant=" + quad + " HV group=" + module, 50, 0, 2);
+                pePlotsHVReal[quad - 1][module - 1] = hf.createHistogram1D("E over p quadrant=" + quad + " HV group=" + module, 50, 0, 2);
+            }
+        }
+        for (int x = -23; x <= 23; x++) {
+            for (int y = -5; y <= 5; y++) {
+                pePlotsHVSim[HPSECalUtils.getQuadrant(x, y) - 1][HPSECalUtils.getHVGroup(x, y) - 1].add(pePlotsSim[x + 23][y + 5][0]);
+                pePlotsHVReal[HPSECalUtils.getQuadrant(x, y) - 1][HPSECalUtils.getHVGroup(x, y) - 1].add(pePlotsReal[x + 23][y + 5][0]);
+            }
+        }
+
+        for (int x = -23; x <= 23; x++) {
+            for (int y = -5; y <= 5; y++) {
                 Double gain = HPSEcalConditions.physicalToGain(HPSEcalConditions.makePhysicalID(x, y));
                 if (gain != null) {
-                    gainsPlot.fill(x, y, gain);
+                    ecalPlot.fill(x, y, gain);
 //                    gainsPlot.fill(x, y, HPSECalUtils.getHVGroup(x, y));
                 }
             }
         }
 
+        plotter.region(0).setTitle("Crystal gains before iterating");
+        plotter.region(0).refresh();
+        try {
+            plotter.writeToFile(outName + "_initial_gains.png", "png");
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        ecalPlot.reset();
+
+        for (int x = -23; x <= 23; x++) {
+            for (int y = -5; y <= 5; y++) {
+                ecalPlot.fill(x, y, pePlotsSim[x + 23][y + 5][0].allEntries());
+            }
+        }
+
+        plotter.region(0).setTitle("Matched cluster counts in simulation");
+        plotter.region(0).refresh();
         try {
-            gainPlotter.writeToFile(outName + "_initial_gains.png", "png");
+            plotter.writeToFile(outName + "_sim_counts.png", "png");
         } catch (IOException e) {
             throw new RuntimeException(e);
         }
+        ecalPlot.reset();
 
-        gainsPlot.reset();
-        gainsPlot.setTitle("Crystal gains after iterating");
-        gainPlotter.region(0).refresh();
-//        gainPlotter.region(0).clear();
-//        gainPlotter.region(0).plot(gainsPlot);
+        for (int x = -23; x <= 23; x++) {
+            for (int y = -5; y <= 5; y++) {
+                ecalPlot.fill(x, y, pePlotsReal[x + 23][y + 5][0].allEntries());
+            }
+        }
+
+        plotter.region(0).setTitle("Matched cluster counts in data");
+        plotter.region(0).refresh();
+        try {
+            plotter.writeToFile(outName + "_data_counts.png", "png");
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        ecalPlot.reset();
 
         PrintStream gainStream;
         try {
@@ -168,24 +199,34 @@
             throw new RuntimeException(e);
         }
 
+        int minCount = 10;
+        
         gainStream.format("#x\ty\tgain\n");
-        for (int x = -23; x <= 23; x++) { // slot
-            for (int y = -5; y <= 5; y++) { // crate  
+        for (int x = -23; x <= 23; x++) {
+            for (int y = -5; y <= 5; y++) {
                 Double gain = HPSEcalConditions.physicalToGain(HPSEcalConditions.makePhysicalID(x, y));
+                IHistogram1D peSim = pePlotsSim[x + 23][y + 5][0];
+                IHistogram1D peReal = pePlotsReal[x + 23][y + 5][0];
+                IHistogram1D peHVSim = pePlotsHVSim[HPSECalUtils.getQuadrant(x, y) - 1][HPSECalUtils.getHVGroup(x, y) - 1];
+                IHistogram1D peHVReal = pePlotsHVReal[HPSECalUtils.getQuadrant(x, y) - 1][HPSECalUtils.getHVGroup(x, y) - 1];
                 if (gain != null) {
-                    if (pePlotsSim[x + 23][y + 5][0].allEntries() >= 10 && pePlotsReal[x + 23][y + 5][0].allEntries() >= 10) {
-                        gain *= (pePlotsSim[x + 23][y + 5][0].mean() / pePlotsReal[x + 23][y + 5][0].mean());
+                    if (peSim.allEntries() >= minCount && peReal.allEntries() >= minCount) {
+                        gain *= (peSim.mean() / peReal.mean());
+                    } else if (peHVSim.allEntries() >= minCount && peHVReal.allEntries() >= minCount) {
+                        gain *= (peHVSim.mean() / peHVReal.mean());
                     }
                     gainStream.format("%d\t%d\t%f\n", x, y, gain);
-                    gainsPlot.fill(x, y, gain);
+                    ecalPlot.fill(x, y, gain);
 //                    System.out.printf("%d\t%d\t%d\t%f\t%f\n", x, y, pePlotsSim[x + 23][y + 5][0].allEntries(), pePlotsSim[x + 23][y + 5][0].mean(), pePlotsSim[x + 23][y + 5][0].rms());
                 }
             }
         }
         gainStream.close();
 
+        plotter.region(0).setTitle("Crystal gains after iterating");
+        plotter.region(0).refresh();
         try {
-            gainPlotter.writeToFile(outName + "_final_gains.png", "png");
+            plotter.writeToFile(outName + "_final_gains.png", "png");
         } catch (IOException e) {
             throw new RuntimeException(e);
         }
CVSspam 0.2.12


Use REPLY-ALL to reply to list

To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1