Commit in lcsim/src/org/lcsim/contrib/uiowa on MAIN
ReclusterDTreeDriver.java+39-21.20 -> 1.21
MJC: (contrib) Use side edges of barrel HCAL too when checking for punch-through

lcsim/src/org/lcsim/contrib/uiowa
ReclusterDTreeDriver.java 1.20 -> 1.21
diff -u -r1.20 -r1.21
--- ReclusterDTreeDriver.java	6 Jun 2008 00:07:59 -0000	1.20
+++ ReclusterDTreeDriver.java	9 Jun 2008 16:32:25 -0000	1.21
@@ -34,7 +34,7 @@
   * in this package, which uses the implementation in
   * org.lcsim.recon.cluster.directedtree developed by NIU).
   *
-  * @version $Id: ReclusterDTreeDriver.java,v 1.20 2008/06/06 00:07:59 mcharles Exp $
+  * @version $Id: ReclusterDTreeDriver.java,v 1.21 2008/06/09 16:32:25 mcharles Exp $
   * @author Mat Charles <[log in to unmask]>
   */
 
@@ -803,6 +803,38 @@
 	return totalMomentum;
     }
 
+    protected int countHitsInSideEdgesOfHcal(Cluster clus, int nLayersToCheck) {
+	// Pick up detector geometry
+        Detector det = m_event.getDetector();
+        CylindricalCalorimeter hadBarrel = ((CylindricalCalorimeter) det.getSubdetectors().get("HADBarrel"));
+	double backZ = hadBarrel.getZMax();
+	double innerRadius = hadBarrel.getInnerRadius();
+	double tanTheta = innerRadius/backZ;
+
+	org.lcsim.geometry.IDDecoder id = hadBarrel.getIDDecoder();
+	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 {
+	    throw new AssertionError("Help! Don't know how to handle barrel geometry of class "+id.getClass().getName());
+	}
+    }
+
     protected int countHitsInLastLayersOfHcal(ReconstructedParticle part, int nLayersToCheck) {
 	return countHitsInLastLayersOfHcal(part.getClusters(), nLayersToCheck);
     }
@@ -1322,8 +1354,13 @@
 	} else {
 	    clusterToCheckForPunchThrough = makeCombinedCluster(showerComponents);
 	}
+	// Check for regular punch-through (shows up as hits in outermost layers of HCAL:
 	int hitCount = countHitsInLastLayersOfHcal(clusterToCheckForPunchThrough, m_punchThroughLayers);
-	return (hitCount >= m_punchThroughHitMinimum);
+	boolean longitudinalPunchThrough = (hitCount >= m_punchThroughHitMinimum);
+	// Also check for tracks that punch through the sides of the barrel
+	int barrelEdgeHitCount = countHitsInSideEdgesOfHcal(clusterToCheckForPunchThrough, m_punchThroughLayers);
+	boolean transversePunchThrough = (barrelEdgeHitCount >= m_punchThroughHitMinimum);
+	return (longitudinalPunchThrough || transversePunchThrough);
 
     }
 
CVSspam 0.2.8