Print

Print


Commit in lcsim/src/org/lcsim/contrib/uiowa on MAIN
LocalHelixExtrapolationTrackMIPClusterMatcher.java+701.1 -> 1.2
MJC: Add a whole lot of debug printout (optional)

lcsim/src/org/lcsim/contrib/uiowa
LocalHelixExtrapolationTrackMIPClusterMatcher.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- LocalHelixExtrapolationTrackMIPClusterMatcher.java	9 May 2007 00:25:25 -0000	1.1
+++ LocalHelixExtrapolationTrackMIPClusterMatcher.java	19 Nov 2007 21:04:42 -0000	1.2
@@ -12,6 +12,8 @@
 import org.lcsim.event.EventHeader;
 import org.lcsim.util.Driver;
 import org.lcsim.event.Track;
+import org.lcsim.event.SimTrackerHit;
+import org.lcsim.event.SimCalorimeterHit;
 
 public class LocalHelixExtrapolationTrackMIPClusterMatcher extends LocalHelixExtrapolationTrackClusterMatcher
 {
@@ -36,6 +38,71 @@
 	    // Look through clusters, starting with the nearest ones:
 	    List<Cluster> nearestClusters = findNearestClusters(point, clusters);
 	    for (Cluster nearbyCluster : nearestClusters) {
+		if (m_debug) { 
+		    double debug_separation = proximity(point, nearbyCluster);
+		    int debug_layer = -1; 
+		    CalorimeterHit debug_firstHitInECAL = findInnermostHitInECAL(nearbyCluster);
+		    if (debug_firstHitInECAL != null) { 
+			debug_layer = getLayer(debug_firstHitInECAL);
+		    }
+		    double debug_unitDotProduct = findUnitDotProduct(tangent, nearbyCluster);
+		    System.out.println("DEBUG: LocalHelixExtrapolationTrackMIPClusterMatcher: trying to connect a track to a MIP ("+nearbyCluster.getCalorimeterHits().size()+" hits) with separation="+debug_separation+" and first ECAL layer="+debug_layer+" and unit dot product="+debug_unitDotProduct);
+		    System.out.println("DEBUG: LocalHelixExtrapolationTrackMIPClusterMatcher: Extrapolated point = ("+point.x()+", "+point.y()+", "+point.z()+")");
+		    System.out.println("DEBUG: LocalHelixExtrapolationTrackMIPClusterMatcher: Cross-check: point = ("+
+				       (m_trackParam_xc + m_trackParam_radius * Math.cos(m_trackPoint_phi))+", "+
+				       (m_trackParam_yc + m_trackParam_radius * Math.sin(m_trackPoint_phi))+", "+
+				       m_trackPoint_z+")");
+		    System.out.println("DEBUG: LocalHelixExtrapolationTrackMIPClusterMatcher: ... since xc="+m_trackParam_xc+" and yc="+m_trackParam_yc+" and radius="+m_trackParam_radius+" and phi="+m_trackPoint_phi);
+		    Collection<SimTrackerHit> trackerHits = findHits(tr);
+		    SimTrackerHit hit0 = null;
+		    SimTrackerHit hit1 = null;
+		    SimTrackerHit hit2 = null;
+		    for (SimTrackerHit hit : trackerHits) {
+			if (hit0==null || Math.abs(hit.getPoint()[2])>Math.abs(hit0.getPoint()[2])) {
+			    hit2 = hit1;
+			    hit1 = hit0;
+			    hit0 = hit;
+			} else if (hit1==null || Math.abs(hit.getPoint()[2])>Math.abs(hit1.getPoint()[2])) {
+			    hit2 = hit1;
+			    hit1 = hit;
+			} else if (hit2==null || Math.abs(hit.getPoint()[2])>Math.abs(hit2.getPoint()[2])) {
+			    hit2 = hit;
+			}
+		    }
+		    List<SimTrackerHit> otherHits = new Vector<SimTrackerHit>();
+		    List<SimTrackerHit> tmpHits = new Vector<SimTrackerHit>();
+		    tmpHits.add(hit0);
+		    tmpHits.add(hit1);
+		    tmpHits.add(hit2);
+		    for (SimTrackerHit hit : trackerHits) {
+			if (hit==hit0 || hit==hit1 || hit==hit2) {
+			    // ...
+			} else {
+			    otherHits.add(hit);
+			}
+		    }
+		    for (SimTrackerHit hit : tmpHits) {
+			double x = hit.getPoint()[0];
+			double y = hit.getPoint()[1];
+			double z = hit.getPoint()[2];
+			double r = Math.sqrt(x*x + y*y);
+			System.out.println("DEBUG: LocalHelixExtrapolationTrackMIPClusterMatcher: SimHit at x="+x+", y="+y+", z="+z+", r="+r);
+		    }
+		    for (SimTrackerHit hit : otherHits) {
+			double x = hit.getPoint()[0];
+			double y = hit.getPoint()[1];
+			double z = hit.getPoint()[2];
+			double r = Math.sqrt(x*x + y*y);
+			System.out.println("DEBUG: LocalHelixExtrapolationTrackMIPClusterMatcher: SimHit at x="+x+", y="+y+", z="+z+", r="+r+" [extra]");
+		    }
+		    if (new Double(debug_unitDotProduct).isNaN()) {
+			System.out.println("DEBUG: Dot product is NaN => dumping hits...");
+			for (CalorimeterHit hit : nearbyCluster.getCalorimeterHits()) {
+			    double[] pos = hit.getPosition();
+			    System.out.println("DEBUG:     Layer "+getLayer(hit)+", x="+pos[0]+", y="+pos[1]+", z="+pos[2]);
+			}
+		    }
+		}
 		double separation = proximity(point, nearbyCluster);
 		if (separation > m_cutSeparation) {
 		    // This cluster (and therefore all subsequent ones) are too far away to pass
@@ -73,6 +140,9 @@
 	Hep3Vector clusterDir = new BasicHep3Vector(axes[0][0], axes[0][1], axes[0][2]);
 	// Get the dot product:
 	double unitDotProduct = VecOp.dot(tangent, clusterDir) / (tangent.magnitude() * clusterDir.magnitude());
+	if (m_debug) { 
+	    System.out.println("DEBUG: LocalHelixExtrapolationTrackMIPClusterMatcher: Computed dot product as clusterDir=("+clusterDir.x()+", "+clusterDir.y()+", "+clusterDir.z()+"), tangent=("+tangent.x()+", "+tangent.y()+", "+tangent.z()+") using "+copy.getCalorimeterHits().size()+" hits.");
+	}
 	return unitDotProduct;
     }
 
CVSspam 0.2.8