SlicDiagnostics/src/org/lcsim/slic/diagnostics
diff -u -r1.13 -r1.14
--- CalorimeterHitPlots.java 29 Sep 2005 19:45:06 -0000 1.13
+++ CalorimeterHitPlots.java 29 Sep 2005 21:08:14 -0000 1.14
@@ -13,11 +13,16 @@
import org.lcsim.event.EventHeader.LCMetaData;
import org.lcsim.event.SimCalorimeterHit;
import org.lcsim.event.MCParticle;
-import org.lcsim.geometry.segmentation.SegmentationBase;
+import org.lcsim.geometry.subdetector.AbstractTestBeam;
+import org.lcsim.geometry.CalorimeterIDDecoder;
import org.lcsim.geometry.segmentation.ProjectiveCylinder;
import org.lcsim.geometry.segmentation.ProjectiveZPlane;
import org.lcsim.geometry.segmentation.NonprojectiveCylinder;
+import org.lcsim.geometry.segmentation.GridXYZ;
import org.lcsim.geometry.IDDecoder;
+import org.lcsim.geometry.Subdetector;
+import org.lcsim.geometry.SubdetectorIDDecoder;
+import org.lcsim.geometry.subdetector.CylindricalEndcapCalorimeter;
import org.lcsim.recon.cluster.cheat.CheatClusterer;
import org.lcsim.recon.cluster.cheat.CheatCluster;
@@ -38,12 +43,76 @@
String collName;
+ SegmentationType segmentationType = SegmentationType.NONE;
+
+ SegmentationPlots segmentationPlots;
+
+ enum SegmentationType
+ {
+ NONE, PRJ_CYL, PRJ_Z, NP_CYL, GRID_XY, GRID_XZ
+ };
+
static CheatClusterer clusterer = new CheatClusterer();
int clusterCount = 0;
public CalorimeterHitPlots(LCMetaData meta)
{
super(meta);
definePlots();
+ setSegmentationType(meta);
+ setupSegmentationPlots();
+ }
+
+ private void setSegmentationType(LCMetaData meta)
+ {
+ IDDecoder decoder = meta.getIDDecoder();
+ CalorimeterIDDecoder segmentation = (CalorimeterIDDecoder)decoder;
+ Subdetector detector = ((SubdetectorIDDecoder)decoder).getSubdetector();
+
+ if ( decoder != null )
+ {
+ if ( segmentation instanceof ProjectiveCylinder )
+ {
+ segmentationType = SegmentationType.PRJ_CYL;
+ }
+
+ if ( segmentation instanceof ProjectiveZPlane )
+ {
+ segmentationType = SegmentationType.PRJ_Z;
+ }
+
+ if ( segmentation instanceof NonprojectiveCylinder )
+ {
+ segmentationType = SegmentationType.NP_CYL;
+ }
+
+ if ( segmentation instanceof GridXYZ )
+ {
+ if ( detector instanceof AbstractTestBeam || detector instanceof CylindricalEndcapCalorimeter )
+ {
+ segmentationType = SegmentationType.GRID_XY;
+ }
+ }
+ }
+ }
+
+ private void setupSegmentationPlots()
+ {
+ if ( segmentationType == SegmentationType.PRJ_CYL || segmentationType == SegmentationType.PRJ_Z )
+ {
+ segmentationPlots = new ProjectivePlots(this);
+ }
+ else if ( segmentationType == SegmentationType.NP_CYL )
+ {
+ segmentationPlots = new NonprojectiveCylinderPlots(this);
+ }
+ else if ( segmentationType == SegmentationType.GRID_XY )
+ {
+ segmentationPlots = new GridXYPlots(this);
+ }
+ else if ( segmentationType == SegmentationType.GRID_XZ )
+ {
+ segmentationPlots = new GridXZPlots(this);
+ }
}
protected void definePlots()
@@ -80,7 +149,7 @@
if ( hits.size() > 0 )
{
- SegmentationBase segmentation = (SegmentationBase)eventHeader.getMetaData(hits).getIDDecoder();
+ CalorimeterIDDecoder segmentation = (CalorimeterIDDecoder)eventHeader.getMetaData(hits).getIDDecoder();
int mcpMissingCount = 0;
for ( SimCalorimeterHit hit : hits)
{
@@ -92,32 +161,8 @@
mcpMissingCount += 1;
}
- /* segmentation plots */
- /* FIXME: Clean this up! It is too slow. */
- if ( segmentation instanceof ProjectiveCylinder ||
- segmentation instanceof NonprojectiveCylinder ||
- segmentation instanceof ProjectiveZPlane )
- {
- aida.cloud2D(makePlotName("Phi vs Phi Bin")).fill(
- segmentation.getPhi(),
- (double)segmentation.getValue("phi")
- );
-
- if ( segmentation instanceof ProjectiveCylinder ||
- segmentation instanceof ProjectiveZPlane)
- {
- aida.cloud2D(makePlotName("Theta vs Theta Bin")).fill(
- segmentation.getTheta(),
- (double)segmentation.getValue("theta"));
- }
- else if ( segmentation instanceof NonprojectiveCylinder)
- {
- aida.cloud2D(makePlotName("Z vs Z Bin")).fill(
- segmentation.getZ(),
- (double)segmentation.getValue("z")
- );
- }
- }
+ /* Fill plots specific to type of segmentation. */
+ segmentationPlots.fill(segmentation);
/* corrected energy */
if (haveSF)
@@ -166,4 +211,98 @@
}
}
}
+
+ public abstract class SegmentationPlots
+ {
+ protected CalorimeterHitPlots plots;
+ SegmentationPlots(CalorimeterHitPlots plots)
+ {
+ this.plots = plots;
+ }
+ abstract public void fill(CalorimeterIDDecoder segmentation);
+ }
+
+ public class ProjectivePlots extends SegmentationPlots
+ {
+ ProjectivePlots(CalorimeterHitPlots plots)
+ {
+ super(plots);
+ }
+
+ public void fill(CalorimeterIDDecoder segmentation)
+ {
+ aida.cloud2D(plots.makePlotName("Phi vs Phi Bin")).fill(
+ segmentation.getPhi(),
+ (double)segmentation.getValue("phi")
+ );
+
+ aida.cloud2D(plots.makePlotName("Theta vs Theta Bin")).fill(
+ segmentation.getTheta(),
+ (double)segmentation.getValue("theta"));
+ }
+ }
+
+ public class NonprojectiveCylinderPlots extends SegmentationPlots
+ {
+ NonprojectiveCylinderPlots(CalorimeterHitPlots plots)
+ {
+ super(plots);
+ }
+
+ public void fill(CalorimeterIDDecoder segmentation)
+ {
+
+ aida.cloud2D(makePlotName("Phi vs Phi Bin")).fill(
+ segmentation.getPhi(),
+ (double)segmentation.getValue("phi")
+ );
+
+ aida.cloud2D(makePlotName("Z vs Z Bin")).fill(
+ segmentation.getZ(),
+ (double)segmentation.getValue("z")
+ );
+ }
+ }
+
+ public class GridXYPlots extends SegmentationPlots
+ {
+ GridXYPlots(CalorimeterHitPlots plots)
+ {
+ super(plots);
+ }
+
+ public void fill(CalorimeterIDDecoder segmentation)
+ {
+ aida.cloud2D(makePlotName("X vs X Bin")).fill(
+ segmentation.getX(),
+ (double)segmentation.getValue("x")
+ );
+
+ aida.cloud2D(makePlotName("Y vs Y Bin")).fill(
+ segmentation.getZ(),
+ (double)segmentation.getValue("y")
+ );
+ }
+ }
+
+ public class GridXZPlots extends SegmentationPlots
+ {
+ GridXZPlots(CalorimeterHitPlots plots)
+ {
+ super(plots);
+ }
+
+ public void fill(CalorimeterIDDecoder segmentation)
+ {
+ aida.cloud2D(makePlotName("X vs X Bin")).fill(
+ segmentation.getX(),
+ (double)segmentation.getValue("x")
+ );
+
+ aida.cloud2D(makePlotName("Z vs Z Bin")).fill(
+ segmentation.getZ(),
+ (double)segmentation.getValue("z")
+ );
+ }
+ }
}
\ No newline at end of file