Commit in lcsim/src/org/lcsim/recon/pfa/structural on MAIN
ChargedHadronClusterEnergyCalculator.java+13-711.5 -> 1.6
FuzzyQNeutralHadronClusterEnergyCalculator.java+8-81.6 -> 1.7
LayerBasedMIPGeometryHandler.java+15-61.4 -> 1.5
FuzzyQPhotonClusterEnergyCalculator.java+4-41.2 -> 1.3
ReclusterDTreeDriver.java+78-21.27 -> 1.28
+118-91
5 modified files
Use CalorimeterInformation class

lcsim/src/org/lcsim/recon/pfa/structural
ChargedHadronClusterEnergyCalculator.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- ChargedHadronClusterEnergyCalculator.java	22 Oct 2008 22:46:55 -0000	1.5
+++ ChargedHadronClusterEnergyCalculator.java	3 Feb 2010 19:43:17 -0000	1.6
@@ -4,24 +4,10 @@
 import hep.physics.vec.*;
 
 import org.lcsim.recon.cluster.util.*;
-import org.lcsim.event.Cluster;
-import org.lcsim.event.CalorimeterHit;
-import org.lcsim.geometry.IDDecoder;
-import org.lcsim.conditions.*;
+import org.lcsim.geometry.Calorimeter;
 import org.lcsim.util.*;
 import org.lcsim.event.*;
-import org.lcsim.event.util.*;
-
-import org.lcsim.detector.IDetectorElement;
-import org.lcsim.detector.IDetectorElementContainer;
-import org.lcsim.detector.IParameters;
-import org.lcsim.detector.IGeometryInfo;
-import org.lcsim.detector.ILogicalVolume;
-import org.lcsim.detector.IPhysicalVolume;
-import org.lcsim.detector.IPhysicalVolumeContainer;
-import org.lcsim.detector.material.IMaterial;
-import org.lcsim.detector.material.IMaterialMixture;
-import org.lcsim.detector.solids.ISolid;
+import org.lcsim.recon.util.CalorimeterInformation;
 
 /**
   * ECAL/HCAL calibration designed for charged showers. The hits are divided into two classes: those
@@ -32,7 +18,7 @@
   *
   * @author Mat Charles <[log in to unmask]>
   *
-  * @version $Id: ChargedHadronClusterEnergyCalculator.java,v 1.5 2008/10/22 22:46:55 mcharles Exp $
+  * @version $Id: ChargedHadronClusterEnergyCalculator.java,v 1.6 2010/02/03 19:43:17 cassell Exp $
   */
 
 public class ChargedHadronClusterEnergyCalculator extends Driver implements ClusterEnergyCalculator
@@ -42,10 +28,13 @@
     EventHeader m_event = null;
     Map<Cluster, Hep3Vector> m_mipDirectionCache;
     boolean m_debug = false;
+    protected boolean init;
+    protected CalorimeterInformation ci;
 
     public ChargedHadronClusterEnergyCalculator(String mipListName, ClusterEnergyCalculator neutralCalib) {
 	m_neutralCalib = neutralCalib;
 	m_mipListName = mipListName;
+        init = false;
     }
     public void process(EventHeader event) {
 	m_event = event;
@@ -108,6 +97,11 @@
     }
 
     private double getMIPEnergyAtNormalIncidence(CalorimeterHit hit) {
+        if(!init)
+        {
+            ci = CalorimeterInformation.instance();
+            init = true;
+        }
 	// First, grab hit info (ID, layer)
 	org.lcsim.geometry.IDDecoder id = hit.getIDDecoder();
 	id.setID(hit.getCellID());
@@ -115,60 +109,8 @@
 	// Next, figure out which subdetector we're in.
 	org.lcsim.geometry.Subdetector subdet = hit.getSubdetector();
 	if ( ! subdet.isCalorimeter() ) { throw new AssertionError("Cluster hit outside calorimeter"); }
-	// Set up dE/dx constants:
-	org.lcsim.util.step.DeDx materialDatabase = org.lcsim.util.step.DeDx.instance();
-
-	// 1) There is one SUBDETECTOR -- subdetectorElement
-	//      * If the SUBDETECTOR is a barrel, it has one corresponding SUBDETECTOR LOGICAL VOLUME
-	//      * If the SUBDETECTOR is an endcap, it has two daughter detector elements (for the +z
-	//           and -z endcaps), each of which has one corresponding SUBDETECTOR LOGICAL VOLUME.
-	//           Since the endcaps are symmetric, we pick the first one.
-	// 2) The SUBDETECTOR LOGICAL VOLUME has multiple LAYER PHYSICAL VOLUME daughters (e.g. 31 for ecal, 34 for hcal)
-	// 3) Each LAYER PHYSICAL VOLUME has a corresponding LAYER LOGICAL VOLUME
-	// 4) Each LAYER LOGICAL VOLUME has multiple SUBLAYER PHYSICAL VOLUME daughters (e.g. TungstenDens24, Silicon, Copper, Kapton, Air)
-	//
-	// Because of the way the ordering works, the total material since the last active element
-	//    is the same as the sum of the physical volume daughters in the current layer *except*
-	//    for the very first layer in the subdetector, for which we ignore anything that comes
-	//    after the active element. Neglect the difference for that layer for now.
-
-	double estimatedEnergyLoss = 0.0;
-
-	IDetectorElement subDetectorElement = subdet.getDetectorElement();	
-	IGeometryInfo subDetectorGeometry = null;
-	if (!subdet.isEndcap()) {
-	    // Barrel -- just one geometry:
-	    subDetectorGeometry = subDetectorElement.getGeometry();
-	} else {
-	    // Endcap -- extra level of indirection
-	    IDetectorElement oneEndcap = subDetectorElement.getChildren().get(0);
-	    subDetectorGeometry = oneEndcap.getGeometry();
-	}
-	ILogicalVolume subDetectorLogicalVolume = subDetectorGeometry.getLogicalVolume();
-	IPhysicalVolume layerPhysicalVolume = subDetectorLogicalVolume.getDaughter(layer);
-	ILogicalVolume layerLogicalVolume = layerPhysicalVolume.getLogicalVolume();
-	for (IPhysicalVolume subLayerPhysicalVolume : layerLogicalVolume.getDaughters()) {
-	    ILogicalVolume subLayerLogicalVolume = subLayerPhysicalVolume.getLogicalVolume();
-	    IMaterial subLayerMaterial = subLayerLogicalVolume.getMaterial();
-	    double estimated_dedx = materialDatabase.getDeDx(subLayerMaterial.getName());
-	    ISolid subLayerSolid = subLayerLogicalVolume.getSolid();
-	    if (subLayerSolid instanceof org.lcsim.detector.solids.Tube) {
-		org.lcsim.detector.solids.Tube subLayerTube = (org.lcsim.detector.solids.Tube)(subLayerSolid);
-		double layerThickness;
-		if (subdet.isEndcap()) {
-		    layerThickness = 2.0 * subLayerTube.getZHalfLength();
-		} else {
-		    layerThickness = subLayerTube.getOuterRadius() - subLayerTube.getInnerRadius();
-		}
-
-		// Watch out for factor of 10 -- this comes from the dE/dx being in units of MeV/cm and distance being in units of mm
-		estimatedEnergyLoss += (layerThickness * estimated_dedx * 0.1);
-	    } else {
-		throw new AssertionError("Don't know how to get layer thickness for geometry type "+subLayerSolid.getClass().getName());
-	    }
-	}
-	
-	return estimatedEnergyLoss;
+        Calorimeter.CalorimeterType t = ((Calorimeter) subdet).getCalorimeterType();
+        return ci.getMeanDe(t,layer);
     }
 
     Hep3Vector getNormal(CalorimeterHit hit) {

lcsim/src/org/lcsim/recon/pfa/structural
FuzzyQNeutralHadronClusterEnergyCalculator.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- FuzzyQNeutralHadronClusterEnergyCalculator.java	28 Oct 2008 06:55:09 -0000	1.6
+++ FuzzyQNeutralHadronClusterEnergyCalculator.java	3 Feb 2010 19:43:17 -0000	1.7
@@ -14,7 +14,7 @@
   * an extension of Ron's QNeutralHadronClusterEnergyCalculator
   * class.
   * 
-  * @version $Id: FuzzyQNeutralHadronClusterEnergyCalculator.java,v 1.6 2008/10/28 06:55:09 mcharles Exp $
+  * @version $Id: FuzzyQNeutralHadronClusterEnergyCalculator.java,v 1.7 2010/02/03 19:43:17 cassell Exp $
   */
 
 public class FuzzyQNeutralHadronClusterEnergyCalculator extends QNeutralHadronClusterEnergyCalculator
@@ -69,7 +69,7 @@
             IDDecoder idc = hit.getIDDecoder();
             idc.setID(hit.getCellID());
             int detector_index = idc.getValue("system");
-            if(detector_index == 2)
+            if(detector_index == eBid)
             {
 		// EM barrel
                 int layer = idc.getValue("layer");
@@ -84,7 +84,7 @@
                     EmeasEst += hitWeight * (hit.getRawEnergy()/sf[index]);
                 }
             }
-            else if(detector_index == 6)
+            else if(detector_index == eEid)
             {
 		// EM endcap
                 int layer = idc.getValue("layer");
@@ -99,7 +99,7 @@
                     EmeasEst += hitWeight * (hit.getRawEnergy()/sf[index]);
                 }
             }
-            else if(detector_index == 9)
+            else if(detector_index == eLid)
             {
 		// Forward EM endcap -- treat mostly as EM endcap
                 int layer = idc.getValue("layer");
@@ -114,7 +114,7 @@
                     EmeasEst += hitWeight * (hit.getRawEnergy()/sf[index]);
                 }
             }
-            else if(detector_index == 3)
+            else if(detector_index == hBid)
             {
 		// HAD barrel
 		double Ehit = 1.0;
@@ -125,7 +125,7 @@
                 double st = Math.sqrt(1.-ctheta*ctheta);
                 EmeasEst += hitWeight * ((Ehit/(1. + alpha*(1./st - 1.)))/sf[4]);
             }
-            else if(detector_index == 7)
+            else if(detector_index == hEid)
             {
 		// HAD endcap
 		double Ehit = 1.0;
@@ -134,7 +134,7 @@
                 double R = Math.sqrt(pos[0]*pos[0]+pos[1]*pos[1]+pos[2]*pos[2]);
                 double st = Math.abs(pos[2])/R;
                 EmeasEst += hitWeight * ((Ehit/(1. + alpha*(1./st - 1.)))/sf[5]);
-	    } else if (detector_index == 8) {
+	    } else if (detector_index == mEid) {
 		// Muon endcap
 		boolean skipMuonHits = true;
 		double muonSamplingFraction = 3.80; // 0.263 GeV per hit => 3.80
@@ -152,7 +152,7 @@
 		    double st = Math.abs(pos[2])/R;
 		    EmeasEst += hitWeight * ((Ehit/(1. + alpha*(1./st - 1.)))/muonSamplingFraction);
 		}
-	    } else if (detector_index == 4) {
+	    } else if (detector_index == mBid) {
 		// Muon barrel
 		boolean skipMuonHits = true;
 		double muonSamplingFraction = Double.NaN;

lcsim/src/org/lcsim/recon/pfa/structural
LayerBasedMIPGeometryHandler.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- LayerBasedMIPGeometryHandler.java	22 Oct 2008 17:54:20 -0000	1.4
+++ LayerBasedMIPGeometryHandler.java	3 Feb 2010 19:43:17 -0000	1.5
@@ -8,6 +8,7 @@
 import org.lcsim.recon.pfa.identifier.*;
 import org.lcsim.recon.cluster.util.BasicCluster;
 import org.lcsim.geometry.*;
+import org.lcsim.recon.util.CalorimeterInformation;
 
 /**
  * This class provides a convenient wrapper to get the
@@ -23,7 +24,7 @@
  * from the IP, then finding the hits in the outermost layer
  * of that subdetector.
  *
- * @version $Id: LayerBasedMIPGeometryHandler.java,v 1.4 2008/10/22 17:54:20 mcharles Exp $
+ * @version $Id: LayerBasedMIPGeometryHandler.java,v 1.5 2010/02/03 19:43:17 cassell Exp $
  */
 
 public class LayerBasedMIPGeometryHandler extends MIPGeometryHandler {
@@ -32,11 +33,14 @@
     private HelixExtrapolator m_extrap;
     private HelixExtrapolationResult m_result;
     protected boolean m_debug = false;
+    protected boolean init;
+    CalorimeterInformation ci;
 
     public LayerBasedMIPGeometryHandler(Map<Track, BasicCluster> mapTrackToMIP, HelixExtrapolator extrap) {
 	super();
 	m_extrap = extrap;
 	m_newMapMIP = mapTrackToMIP;
+        init = false;
     }
 
     protected void findPointAndTangentNoCache(Track tr, BasicHep3Vector outputPoint, BasicHep3Vector outputTangentUnit) throws ExtrapolationFailureException {
@@ -99,6 +103,11 @@
     }
 
     protected Hep3Vector getTangentUnit(int lastLayer, Subdetector outermostSubdet) throws ExtrapolationFailureException {
+        if(!init)
+        {
+            ci = CalorimeterInformation.instance();
+            init = true;
+        }
 	// We need the tangent in the layer of interest.
 	// To do this, we extrapolate the track to the corresponding layer, and the previous one.
 	// (Or, if this is the first layer, use the next one).
@@ -112,19 +121,19 @@
 	// To do the extrapolation, we need to know if we're looking at a barrel or an endcap subdetector.
 	String calName = outermostSubdet.getName();
 	if (m_result != null) {
-	    if (calName.compareTo("HADBarrel")==0) {
+	    if (calName.compareTo(ci.getName("HAD_BARREL"))==0) {
 		trackPointInLayer_N = m_result.extendToHCALBarrelLayer(layerN);
 		trackPointInLayer_NminusOne = m_result.extendToHCALBarrelLayer(layerN-1);
-	    } else if (calName.compareTo("HADEndcap")==0) {
+	    } else if (calName.compareTo(ci.getName("HAD_ENDCAP"))==0) {
 		trackPointInLayer_N = m_result.extendToHCALEndcapLayer(layerN);
 		trackPointInLayer_NminusOne = m_result.extendToHCALEndcapLayer(layerN-1);
-	    } else if (calName.compareTo("EMBarrel")==0) {
+	    } else if (calName.compareTo(ci.getName("EM_BARREL"))==0) {
 		trackPointInLayer_N = m_result.extendToECALBarrelLayer(layerN);
 		trackPointInLayer_NminusOne = m_result.extendToECALBarrelLayer(layerN-1);
-	    } else if (calName.compareTo("EMEndcap")==0) {
+	    } else if (calName.compareTo(ci.getName("EM_ENDCAP"))==0) {
 		trackPointInLayer_N = m_result.extendToECALEndcapLayer(layerN);
 		trackPointInLayer_NminusOne = m_result.extendToECALEndcapLayer(layerN-1);
-	    } else if (calName.compareTo("MuonEndcap")==0) {
+	    } else if (calName.compareTo(ci.getName("EM_ENDCAP"))==0) {
 		trackPointInLayer_N = m_result.extendToMCALEndcapLayer(layerN);
 		trackPointInLayer_NminusOne = m_result.extendToMCALEndcapLayer(layerN-1);
 	    } else {

lcsim/src/org/lcsim/recon/pfa/structural
FuzzyQPhotonClusterEnergyCalculator.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- FuzzyQPhotonClusterEnergyCalculator.java	12 Aug 2008 23:45:11 -0000	1.2
+++ FuzzyQPhotonClusterEnergyCalculator.java	3 Feb 2010 19:43:17 -0000	1.3
@@ -13,7 +13,7 @@
   * clusters such that the total weight adds up to 1. This is
   * an extension of Ron's QPhotonClusterEnergyCalculator class.
   *
-  * @version $Id: FuzzyQPhotonClusterEnergyCalculator.java,v 1.2 2008/08/12 23:45:11 mcharles Exp $
+  * @version $Id: FuzzyQPhotonClusterEnergyCalculator.java,v 1.3 2010/02/03 19:43:17 cassell Exp $
   */
 
 public class FuzzyQPhotonClusterEnergyCalculator extends QPhotonClusterEnergyCalculator
@@ -48,7 +48,7 @@
             double cb = 1. + alpha*(1./st - 1.);
             double ce = 1. + alpha*(1./ctheta - 1.);
             double cc = cb;
-            if(detector_index == 2)
+            if(detector_index == eBid)
             {
 		// EM barrel
                 int layer = idc.getValue("layer");
@@ -61,7 +61,7 @@
                     index = 1;
                 }
             }
-            else if(detector_index == 6)
+            else if(detector_index == eEid)
             {
 		// EM endcap
                 cc = ce;
@@ -75,7 +75,7 @@
                     index = 3;
                 }
             }
-            else if(detector_index == 9)
+            else if(detector_index == eLid)
             {
 		// Forward endcap -- treat mostly as EM endcap
                 cc = ce;

lcsim/src/org/lcsim/recon/pfa/structural
ReclusterDTreeDriver.java 1.27 -> 1.28
diff -u -r1.27 -r1.28
--- ReclusterDTreeDriver.java	26 Jan 2010 16:09:25 -0000	1.27
+++ ReclusterDTreeDriver.java	3 Feb 2010 19:43:17 -0000	1.28
@@ -24,7 +24,7 @@
   * in this package, which uses the implementation in
   * org.lcsim.recon.cluster.directedtree developed by NIU).
   *
-  * @version $Id: ReclusterDTreeDriver.java,v 1.27 2010/01/26 16:09:25 cassell Exp $
+  * @version $Id: ReclusterDTreeDriver.java,v 1.28 2010/02/03 19:43:17 cassell Exp $
   * @author Mat Charles <[log in to unmask]>
   */
 
@@ -88,6 +88,8 @@
     protected List<String> m_inputBlocks = new Vector<String>();
     protected List<String> m_inputLeftoverHits = new Vector<String>();
     protected List<String> m_inputTrackClusterMaps = new Vector<String>();
+    protected CalorimeterInformation ci;
+    protected boolean init;
 
     public void addInputMips(String name) { m_inputMips.add(name); }
     public void addInputClumps(String name) { m_inputClumps.add(name); }
@@ -140,10 +142,16 @@
 	m_eval = new LikelihoodEvaluatorWrapper();
 	m_outputParticleListName = "DTreeReclusteredParticles";
 	m_muonTrackClusterMapName = muonTrackClusterMap;
+        init = false;
     }
 
     public MIPGeometryHandler geomHandler;
     public void process(EventHeader event) {
+        if(!init)
+        {
+            ci = CalorimeterInformation.instance();
+            init = true;
+        }
 	super.debugProcess(event);
 	m_event = event;
 	// Some likelihood selectors need per-event info
@@ -160,7 +168,6 @@
 	List<Cluster> largeClusters = dTreeClusters; // FIXME: NOT IDEAL! Perhaps run MST on DTree clusters?
 	if (trackList == null) { throw new AssertionError("Null track list!"); }
 	if (trackList.contains(null)) { throw new AssertionError("Track list contains null!"); }	
-        CalorimeterInformation ci = CalorimeterInformation.instance();
 
 	List<CalorimeterHit> allHitsEcalBarrel = m_event.get(CalorimeterHit.class,ci.getDigiCollectionName("EM_BARREL"));
 	List<CalorimeterHit> allHitsEcalEndcap = m_event.get(CalorimeterHit.class,ci.getDigiCollectionName("EM_ENDCAP"));
@@ -2270,4 +2277,73 @@
 	    }
 	}
     }
+    protected int countHitsInLastLayersOfHcal(ReconstructedParticle part, int nLayersToCheck) {
+	return countHitsInLastLayersOfHcal(part.getClusters(), nLayersToCheck);
+    }
+    protected int countHitsInLastLayersOfHcal(Cluster clus, int nLayersToCheck) {
+	List<Cluster> tmpList = new Vector<Cluster>();
+	tmpList.add(clus);
+	return countHitsInLastLayersOfHcal(tmpList, nLayersToCheck);
+    }
+    protected int countHitsInLastLayersOfHcal(Collection<Cluster> clusters, int nLayersToCheck) {
+	// Pick up detector geometry
+        int nLayersHadBarrel = ci.getNLayers("HAD_BARREL");
+        int nLayersHadEndcap = ci.getNLayers("HAD_ENDCAP");
+
+	// Scan for hits
+	Set<Long> hitsFoundInLastLayersOfHcal = new HashSet<Long>();
+	for (Cluster clus : clusters) {
+	    for (CalorimeterHit hit : clus.getCalorimeterHits()) {
+		int nLayersInSubdet = 0;
+		org.lcsim.geometry.Subdetector subdet = hit.getSubdetector();
+		String name = subdet.getName();
+		if (name.compareTo(ci.getName("HAD_BARREL"))==0) {
+		    nLayersInSubdet = nLayersHadBarrel;
+		} else if (name.compareTo(ci.getName("HAD_ENDCAP"))==0) {
+		    nLayersInSubdet = nLayersHadEndcap;
+		} else {
+		    // Not in HCAL
+		    continue;
+		}
+		org.lcsim.geometry.IDDecoder id = hit.getIDDecoder();
+		id.setID(hit.getCellID());
+		int layer = id.getLayer();
+		if (layer >= nLayersInSubdet-nLayersToCheck) {
+		    // In last n layers
+		    hitsFoundInLastLayersOfHcal.add(hit.getCellID());
+		}
+	    }
+	}
+	return hitsFoundInLastLayersOfHcal.size();
+    }
+    protected int countHitsInSideEdgesOfHcal(Cluster clus, int nLayersToCheck) {
+	// Pick up detector geometry
+	double backZ = ci.getZMax("HAD_BARREL");
+	double innerRadius = ci.getRMin("HAD_BARREL");
+	double tanTheta = innerRadius/backZ;
+
+	org.lcsim.geometry.IDDecoder id = ci.getIDDecoder("HAD_BARREL");
+	if (id instanceof org.lcsim.geometry.segmentation.NonprojectiveCylinder) {
+	    org.lcsim.geometry.segmentation.NonprojectiveCylinder segmentation = (org.lcsim.geometry.segmentation.NonprojectiveCylinder) id;
+	    double gridZ = segmentation.getGridSizeZ();
+	    // We want to include at least (nLayersToCheck) layers.
+	    // The layer segmentation is (gridZ).
+	    // For a MIP travelling at a polar angle theta, this means
+	    // a Z range of at least (nLayersToCheck*gridZ)/tanTheta.
+	    double nLayersToCheck_double = nLayersToCheck;
+	    double rangeZ = nLayersToCheck_double * gridZ / tanTheta;
+	    double backCellsRange = (backZ - rangeZ); // minimum Z to be included
+	    Set<Long> backCellsFound = new HashSet<Long>();
+	    for (CalorimeterHit hit : clus.getCalorimeterHits()) {
+		double hitZ = hit.getPosition()[2];
+		if (Math.abs(hitZ) > backCellsRange) {
+		    backCellsFound.add(hit.getCellID());
+		}
+	    }
+	    return backCellsFound.size();
+	} else {
+	    System.out.println("Help! Don't know how to handle barrel geometry of class "+id.getClass().getName());
+            return 0;
+	}
+    }
 }
CVSspam 0.2.8