Print

Print


Commit in SlicDiagnostics/src/org/lcsim/slic/diagnostics on MAIN
GenericHitPlots.java+195-921.28 -> 1.29
JM: Add depth of hit in layer and cumulative layer E and nhits plots

SlicDiagnostics/src/org/lcsim/slic/diagnostics
GenericHitPlots.java 1.28 -> 1.29
diff -u -r1.28 -r1.29
--- GenericHitPlots.java	14 Feb 2006 01:31:25 -0000	1.28
+++ GenericHitPlots.java	17 Feb 2006 01:27:43 -0000	1.29
@@ -1,21 +1,20 @@
 package org.lcsim.slic.diagnostics;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import static java.lang.Math.log10;
-
 import hep.aida.ICloud1D;
 import hep.aida.ICloud2D;
 import hep.aida.IHistogram1D;
 import hep.aida.IHistogram2D;
 
-import org.lcsim.event.EventHeader;
-import org.lcsim.event.EventHeader.LCMetaData;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.lcsim.geometry.Layered;
 import org.lcsim.geometry.Subdetector;
-import org.lcsim.geometry.segmentation.SegmentationBase;
+import org.lcsim.geometry.layer.Layer;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.EventHeader.LCMetaData;
 
 /**
  * A set of diagnostic plots on lists of GenericHits. These include
@@ -24,7 +23,7 @@
  * subdetector.
  * 
  * @author jeremym
- * @version $Id: GenericHitPlots.java,v 1.28 2006/02/14 01:31:25 jeremy Exp $
+ * @version $Id: GenericHitPlots.java,v 1.29 2006/02/17 01:27:43 jeremy Exp $
  */
 class GenericHitPlots extends AbstractPlots
 {
@@ -37,6 +36,7 @@
     ICloud1D _hitMaxEOverTotE;
     ICloud2D _hitMaxVsMinE;
     ICloud2D _hitVsTotE;
+    ICloud1D _hitOverE;
     IHistogram1D _layer;
     ICloud1D _hitCount;
     ICloud1D _time;
@@ -74,19 +74,24 @@
     ICloud1D _layerMinNHitsOverTot;
     IHistogram1D _layerAvgTotE;
     IHistogram1D _layerAvgTotNHits;
+    IHistogram1D _layerCumE;
+    IHistogram1D _layerCumNHits;
+    ICloud1D _hitDepth;
+    
+    Subdetector _detector;
 
     protected void definePlots()
     {
         super.definePlots();
 
         _energy = aida().cloud1D("Hit: Energy");
-        _energy.annotation().addItem("xAxisLabel", "Energy (GeV)");
+        _energy.annotation().addItem("xAxisLabel", "Energy (log10(GeV))");
         _energy.annotation().addItem("yAxisLabel", "Number of Hits");
 
         _hitAvgEnergy = aida().cloud1D("Hit: Average Energy by Event");
         _hitAvgEnergy.annotation().addItem("xAxisLabel", "Hit Average Energy (GeV)");
         _hitAvgEnergy.annotation().addItem("yAxisLabel", "Number of Events");
-
+                
         _time = aida().cloud1D("Hit: Time");
         _time.annotation().addItem("xAxisLabel", "Time (log10(seconds))");
         _time.annotation().addItem("yAxisLabel", "Number of Hits");
@@ -122,14 +127,26 @@
         _layer = aida().histogram1D("Hit: Count by Layer Number", _nlayers, 0, _nlayers);
         _layer.annotation().addItem("xAxisLabel", "Layer Number");
         _layer.annotation().addItem("yAxisLabel", "Hit Count");
+        
+        _layerCumE = aida().histogram1D("Layer: Cumulative Energy", _nlayers, 0, _nlayers);        
+        _layerCumE.annotation().addItem("xAxisLabel", "Layer Number");
+        _layerCumE.annotation().addItem("yAxisLabel", "Fraction of Total Energy");
+        
+        _layerCumNHits = aida().histogram1D("Layer: Cumulative Number of Hits", _nlayers, 0, _nlayers);        
+        _layerCumNHits.annotation().addItem("xAxisLabel", "Layer Number");
+        _layerCumNHits.annotation().addItem("yAxisLabel", "Fraction of Total Number of Hits");
 
         _layerEnergy = aida().histogram1D("Hit: Weighted Energy by Layer Number", _nlayers, 0, _nlayers);
         _layerEnergy.annotation().addItem("xAxisLabel", "Layer Number");
         _layerEnergy.annotation().addItem("yAxisLabel", "Weighted Energy (GeV)");
-
+                
         _energyEvent = aida().cloud1D("Event: Total Energy");
         _energyEvent.annotation().addItem("xAxisLabel", "Event Energy (GeV)");
         _energyEvent.annotation().addItem("yAxisLabel", "Number of Events");
+        
+        _hitOverE = aida().cloud1D("Event: Number of Hits over Energy");
+        _hitOverE.annotation().addItem("xAxisLabel", "# Hits / E (GeV)");
+        _hitOverE.annotation().addItem("yAxisLabel", "Number of Events");        
 
         _hitCount = aida().cloud1D("Event: Total Hit Count");
         _hitCount.annotation().addItem("xAxisLabel", "Number of Hits in Event");
@@ -202,7 +219,7 @@
         _layerPercentHits = aida().histogram2D("Layer: Fraction of Hit Count", _nlayers, 0, _nlayers, 100, 0, 1.0);
         _layerPercentHits.annotation().addItem("xAxisLabel", "Layer Number");
         _layerPercentHits.annotation().addItem("yAxisLabel", "Fraction of Number of Hits");
-
+                
         _layerAvgHitE = aida().histogram1D("Layer: Average Hit Energy", _nlayers, 0, _nlayers);
         _layerAvgHitE.annotation().addItem("xAxisLabel", "Layer Number");
         _layerAvgHitE.annotation().addItem("yAxisLabel", "Average Hit Energy (GeV)");
@@ -258,14 +275,36 @@
         _layerAvgTotNHits = aida().histogram1D("Layer: Average Total # Hits", _nlayers, 0, _nlayers);
         _layerAvgTotNHits.annotation().addItem("xAxisLabel", "Layer Number");
         _layerAvgTotNHits.annotation().addItem("yAxisLabel", "Average Total Number of Hits for All Events");
+        
+        _hitDepth = aida().cloud1D("Hit: Depth into Sensitive Layer");
+        _hitDepth.annotation().addItem("xAxisLabel", "Depth into Sensor (mm)");
+        _hitDepth.annotation().addItem("yAxisLabel", "Number of Hits");               
     }
 
     private void makeLayers()
     {
+        Layered l = (Layered)_detector;
         for (int i = 0; i < _nlayers; i++)
         {
             LayerInfo info = new LayerInfo(i);
-            _layers.put(i, info);
+            
+            Layer layer = l.getLayering().getLayer(i);
+            int sens = layer.findIndexOfFirstSensitiveSlice();
+            double sensThick = layer.getSlice(sens).getThickness();
+            double tosens = layer.getThicknessToSensitive();
+            double offset = l.getLayering().getDistanceToLayer(i);                       
+            double ir = offset + tosens;
+            double or = ir + sensThick;
+            
+//            System.out.println("layer " + i + " OFF = " + offset);
+//            System.out.println("layer " + i + " ToSens = " + tosens);
+//            System.out.println("layer " + i + " IR = " + ir);
+//            System.out.println("layer " + i + " OR = " + or);
+            
+            info.setSensorInnerRadius(ir);
+            info.setSensorOuterRadius(or);
+                        
+            _layers.put(i, info);            
 
             String layerName = info.getTitleName();
             String dirName = info.getDirName();
@@ -311,11 +350,19 @@
             plot = aida().cloud1D(layerName + ": Hit Time");
             plot.annotation().addItem("xAxisLabel", "Time (log10(seconds))");
             plot.annotation().addItem("yAxisLabel", "Number of Hits");
+            
+            plot = aida().cloud1D(layerName + ": Cumulative Energy");
+            plot.annotation().addItem("xAxisLabel", "Fraction of Total Energy");
+            plot.annotation().addItem("yAxisLabel", "Number of Events");
+            
+            plot = aida().cloud1D(layerName + ": Cumulative Number of Hits");
+            plot.annotation().addItem("xAxisLabel", "Fraction of Total Number of Hits");
+            plot.annotation().addItem("yAxisLabel", "Number of Events");
 
             ICloud2D plot1;
             plot1 = aida().cloud2D(layerName + ": Hit XY");
             plot1.annotation().addItem("xAxisLabel", "X (mm)");
-            plot1.annotation().addItem("yAxisLabel", "Y (mm)");
+            plot1.annotation().addItem("yAxisLabel", "Y (mm)");                       
         }
     }
 
@@ -357,8 +404,8 @@
         super(getBaseDir(meta), meta);
 
         // Set number of layers
-        Subdetector det = meta.getIDDecoder().getSubdetector();
-        _nlayers = ((Layered) det).getLayering().getLayerCount();
+        _detector = meta.getIDDecoder().getSubdetector();
+        _nlayers = ((Layered) _detector).getLayering().getLayerCount();
 
         // Make a LayerInfo for each layer and do layer plot definitions
         makeLayers();
@@ -404,7 +451,7 @@
         double minZ = 999999;
         double minR = 999999;
         double maxR = 0;
-
+                
         // Loop over hits
         for (GenericHit hit : hits)
         {
@@ -420,41 +467,44 @@
             int layern = hit.getLayer();
             double cylR = hit.getCylindricalRadius();
             double sphR = hit.getSphericalRadius();
-            
+                                    
             // Lookup the LayerInfo from this hit's layer number
             LayerInfo layerInfo = _layers.get(layern);
+            
+            // Fill hit depth
+            _hitDepth.fill(cylR - layerInfo.getSensorInnerRadius());
+                        
+            // Fill hit energy
+            _energy.fill(log10(energy));
 
-            // Plot hit energy
-            _energy.fill(energy);
-
-            // Plot hit time
+            // Fill hit time
             _time.fill(timelog10);
 
-            // Plot time vs spherical R
+            // Fill time vs spherical R
             _timeVsSphR.fill(timelog10, sphR);
 
-            // Plot hit theta vs. phi
+            // Fill hit theta vs. phi
             _thetaPhi.fill(theta, phi);
 
-            // Plot hit X vs. Y
+            // Fill hit X vs. Y
             _xy.fill(x, y);
 
-            // Plot Z vs. X
+            // Fill Z vs. X
             _zx.fill(z, x);
 
-            // Plot Z vs. Y
+            // Fill Z vs. Y
             _zy.fill(z, y);
 
-            // Plot hit Z vs. cylindrical radius 
+            // Fill hit Z vs. cylindrical radius 
             _rz.fill(z, cylR);
             
-            // Plot hit layer
+            // Fill hit layer
             _layer.fill(layern);
 
-            // Plot hit weighted layer energy
+            // Fill hit weighted layer energy
             _layerEnergy.fill(layern, energy);
 
-            // Plot layer number vs R
+            // Fill layer number vs R
             _layerVsR.fill(layern, cylR);
 
             // Enter layer dir
@@ -462,13 +512,13 @@
             aida().tree().cd(layerInfo.getDirName());
             String layerName = layerInfo.getTitleName();
 
-            // Plot layer hit energy
+            // Fill layer hit energy
             aida().cloud1D(layerName + ": Hit Energy").fill(energy);
 
-            // Plot layer hit XY
+            // Fill layer hit XY
             aida().cloud2D(layerName + ": Hit XY").fill(x, y);
 
-            // Plot layer time
+            // Fill layer time
             aida().cloud1D(layerName + ": Hit Time").fill(log10(time));
 
             // Leave layer dir
@@ -540,8 +590,11 @@
             // Increment total number of hits counter
             ++nhits;
         }
+        
+        // Fill # hits / E
+        _hitOverE.fill(((double)nhits) / eventTotE);
 
-        // Plot min and max XYZ
+        // Fill min and max XYZ
         _hitMaxX.fill(maxX);
         _hitMinX.fill(minX);
         _hitMaxY.fill(maxY);
@@ -551,149 +604,189 @@
         _hitMinR.fill(minR);
         _hitMaxR.fill(maxR);
 
-        // Plot min edep over total
+        // Fill min edep over total
         _hitMinEOverTotE.fill(minE / eventTotE);
 
-        // Plot max edep over total
+        // Fill max edep over total
         _hitMaxEOverTotE.fill(maxE / eventTotE);
 
-        // Plot average time
+        // Fill average time
         _timeAvg.fill(log10(totTime));
 
-        // Plot event energy
+        // Fill event energy
         _energyEvent.fill(eventTotE);
 
-        // Plot event hit count
+        // Fill event hit count
         _hitCount.fill(nhits);
 
         double hitAvgE = eventTotE / nhits;
         
-        // Plot avg energy per hit
+        // Fill avg energy per hit
         _hitAvgEnergy.fill(hitAvgE);
 
-        // Plot min edep
+        // Fill min edep
         _hitMinE.fill(minE);
 
-        // Plot max edep
+        // Fill max edep
         _hitMaxE.fill(maxE);
 
-        // Plot min vs max edep
+        // Fill min vs max edep
         _hitMaxVsMinE.fill(maxE, minE);
 
-        // Plot hit count vs total energy
+        // Fill hit count vs total energy
         _hitVsTotE.fill(eventTotE, nhits);
 
-        // do layer calcs and fill the plots
+        // Min layer E 
         double minLayerE = 9999.0;
+        
+        // Max layer E 
         double maxLayerE = 0.0;
 
+        // Min layer N hits
         int minLayerNHits = 99999999;
+        
+        // Max layer N hits
         int maxLayerNHits = 0;
+        
+        // Cumulative layer N hits
+        int cumn = 0;
+        
+        // Cumulative layer E
+        double cume = 0;
 
         // Loop over the layers after hits are processed
         for (LayerInfo layerInfo : _layers.values())
-        {
-            // Compute some layer statistics
+        {            
+            // Layer info into local vars
+            String layerName = layerInfo.getTitleName();
+            int layerNumber = layerInfo.getLayerNumber();
+            double layerE = layerInfo.getEnergy(); 
+            int layerNHits = layerInfo.getNHits();
+            
+            // Set percentage of total energy
             layerInfo.setPercentTotalEnergy(eventTotE);
+            
+            // Set percentage of total n hits
             layerInfo.setPercentNHits(nhits);
-            double layerAvgHitEdep = layerInfo.getEnergy() / layerInfo.getNHits();
-
-            // Plot fraction of total edep in this layer
-            _layerPercentTotE.fill(layerInfo.getLayerNumber(), layerInfo.getPercentTotalEnergy());
-
-            // Plot percentage of total hit count in this layer
-            _layerPercentHits.fill(layerInfo.getLayerNumber(), layerInfo.getPercentNHits());
-
-            // Plot average energy in this layer's hit
-            _layerAvgHitE.fill(layerInfo.getLayerNumber(), layerAvgHitEdep);
-
+            
+            // Compute average hit energy
+            double layerAvgHitEdep = layerE / layerNHits;
+            
+            // Increment cum N hits by this layer's hits
+            cumn += layerNHits;
+            
+            // Increment cum E by this layer's E
+            cume += layerE;
+            
             // Update max E
-            if (layerInfo.getEnergy() > maxLayerE)
+            if (layerE > maxLayerE)
             {
-                maxLayerE = layerInfo.getEnergy();
+                maxLayerE = layerE;
             }
 
             // Update min E
-            if (layerInfo.getEnergy() < minLayerE)
+            if (layerE < minLayerE)
             {
-                minLayerE = layerInfo.getEnergy();
+                minLayerE = layerE;
             }
 
             // Update max nhits
-            if (layerInfo.getNHits() > maxLayerNHits)
+            if (layerNHits > maxLayerNHits)
             {
-                maxLayerNHits = layerInfo.getNHits();
+                maxLayerNHits = layerNHits;
             }
 
             // Update min nhits
-            if (layerInfo.getNHits() < minLayerNHits)
+            if (layerNHits < minLayerNHits)
             {
-                minLayerNHits = layerInfo.getNHits();
+                minLayerNHits = layerNHits;
             }
+            
+            // Fill cumulative E per layer
+            double fe = cume / eventTotE;            
+            _layerCumE.fill(layerNumber, fe);            
+            
+            // Fill cumulative N hits per layer            
+            double fn = ((double)cumn) / ((double)nhits);            
+            _layerCumNHits.fill(layerNumber, fn);
+            
+            // Fill percentage of total hit count in this layer
+            _layerPercentHits.fill(layerNumber, layerInfo.getPercentNHits());
+                        
+            // Fill fraction of total edep in this layer
+            _layerPercentTotE.fill(layerNumber, layerInfo.getPercentTotalEnergy());           
+
+            // Fill average energy in this layer's hit
+            _layerAvgHitE.fill(layerNumber, layerAvgHitEdep);
 
             // cd into layer dir
             cd();
-            String layerName = layerInfo.getTitleName();
             aida().tree().cd(layerInfo.getDirName());
 
-            // Plot layer total E
-            aida().cloud1D(layerName + ": Total Energy").fill(layerInfo.getEnergy());
+            // Fill cumulative N hits for this layer
+            aida().cloud1D(layerName + ": Cumulative Number of Hits").fill(fn);
+            
+            // Fill cumulative E for this layer
+            aida().cloud1D(layerName + ": Cumulative Energy").fill(fe);
+                        
+            // Fill layer total E
+            aida().cloud1D(layerName + ": Total Energy").fill(layerE);
 
-            // Plot layer average hit E
+            // Fill layer average hit E
             aida().cloud1D(layerName + ": Average Hit Energy").fill(layerInfo.getAverageHitEnergy());
 
-            // Plot layer total # hits
-            aida().cloud1D(layerName + ": Number of Hits").fill(layerInfo.getNHits());
+            // Fill layer total # hits
+            aida().cloud1D(layerName + ": Number of Hits").fill(layerNHits);
 
-            // Plot layer's fraction of N hits
+            // Fill layer's fraction of N hits
             aida().cloud1D(layerName + ": Fraction of Number of Hits").fill(layerInfo.getPercentNHits());
 
-            // Plot layer's fraction of total E
+            // Fill layer's fraction of total E
             aida().cloud1D(layerName + ": Fraction of Total Energy").fill(layerInfo.getPercentTotalEnergy());
             cd();
         }
 
-        // Plot max edep in a layer
+        // Fill max edep in a layer
         _layerMaxE.fill(maxLayerE);
 
-        // Plot min edep in a layer
+        // Fill min edep in a layer
         _layerMinE.fill(minLayerE);
 
-        // Plot max nhits in a layer
+        // Fill max nhits in a layer
         _layerMaxNHits.fill(maxLayerNHits);
 
-        // Plot min # of hits in a layer
+        // Fill min # of hits in a layer
         _layerMinNHits.fill(minLayerNHits);
 
         double avgLayerE = eventTotE / _nlayers;
 
-        // Plot average energy in a layer
+        // Fill average energy in a layer
         _layerAvgE.fill(avgLayerE);
 
         double avgLayerNHits = nhits / _nlayers;
 
-        // Plot average # hits in a layer
+        // Fill average # hits in a layer
         _layerAvgNHits.fill(avgLayerNHits);
 
-        // Plot average layer E vs average layer Nhits
+        // Fill average layer E vs average layer Nhits
         _layerAvgEVsAvgNHits.fill(avgLayerE, avgLayerNHits);
 
-        // Plot maxLayerE / eventTotE
+        // Fill maxLayerE / eventTotE
         _layerMaxEOverTot.fill(maxLayerE / eventTotE);
 
-        // Plot minLayerE / eventTotE
+        // Fill minLayerE / eventTotE
         _layerMinEOverTot.fill(minLayerE / eventTotE);
 
-        // Plot maxLayerNHits / nhits
+        // Fill maxLayerNHits / nhits
         _layerMaxNHitsOverTot.fill(maxLayerNHits / ((double) nhits));
 
-        // Plot minLayerNHits / nhits
+        // Fill minLayerNHits / nhits
         _layerMinNHitsOverTot.fill(minLayerNHits / ((double) nhits));
 
-        // increment total energy
+        // Increment total energy
         _totalAvgEnergy += eventTotE;
 
-        // reset layer event data
+        // Reset layer event data
         resetLayers();
     }
 
@@ -709,16 +802,26 @@
     /** Do end of events processing */
     protected void endEvents(int nevents)
     {
+        // Compute scale factor
+        double scale = 1 / ((double)nevents);
+       
+        // Scale cum E
+        _layerCumE.scale(scale);
+        
+        // Scale cum N hits
+        _layerCumNHits.scale(scale);
+        
+        // Make layer plots
         for (int i = 0; i < _nlayers; i++)
         {
             LayerInfo layer = _layers.get(i);
 
-            // Plot average total energy in the layer for nevents
+            // Fill average total energy in the layer for nevents
             _layerAvgTotE.fill(i, layer.getAverageTotalEnergy(nevents));
 
-            // Plot average n hits in the layer for nevents
+            // Fill average n hits in the layer for nevents
             _layerAvgTotNHits.fill(i, layer.getAverageTotalNHits(nevents));
-
+                      
             // Reset LayerInfo objects after all events 
             layer.resetEndData();
         }
CVSspam 0.2.8