lcsim/src/org/lcsim/contrib/uiowa/structural/likelihood
diff -u -r1.2 -r1.3
--- MiscUtilities.java 14 Oct 2005 17:39:48 -0000 1.2
+++ MiscUtilities.java 18 Oct 2005 17:42:14 -0000 1.3
@@ -1,13 +1,20 @@
package structural.likelihood; // package org.lcsim.recon.cluster.structural.likelihood;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.VecOp;
+
import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.Cluster;
import org.lcsim.recon.cluster.util.BasicCluster;
-import hep.physics.vec.BasicHep3Vector;
import org.lcsim.recon.cluster.util.TensorClusterPropertyCalculator;
-import hep.physics.vec.Hep3Vector;
-import hep.physics.vec.VecOp;
-import java.util.List;
+import org.lcsim.geometry.layer.Layering;
+import org.lcsim.geometry.CylindricalSubdetector;
+//import org.lcsim.geometry.Subdetector;
import org.lcsim.util.swim.Line;
class MiscUtilities
@@ -90,4 +97,42 @@
posAndDir[1] = new BasicHep3Vector(axes[0][0], axes[0][1], axes[0][2]);
return posAndDir;
}
+
+ static protected org.lcsim.geometry.Subdetector findComponent(Hep3Vector point, org.lcsim.geometry.Detector det)
+ {
+ Map<String, org.lcsim.geometry.compact.Subdetector> subdetectorsMap = det.getSubdetectors();
+ Set<Map.Entry<String, org.lcsim.geometry.compact.Subdetector>> subdetectorsSet = subdetectorsMap.entrySet();
+ for (Map.Entry<String, org.lcsim.geometry.compact.Subdetector> subdetectorPair : subdetectorsSet) {
+ String name = subdetectorPair.getKey();
+ org.lcsim.geometry.compact.Subdetector subdet = subdetectorPair.getValue();
+ // Try to cast it to a cylinder...
+ if (subdet instanceof CylindricalSubdetector) {
+ CylindricalSubdetector cylinder = (CylindricalSubdetector) (subdet);
+ double innerR = cylinder.getInnerRadius();
+ double outerR = cylinder.getOuterRadius();
+ double minZ = cylinder.getZMin();
+ double maxZ = cylinder.getZMax();
+ // Are we inside?
+ double pointR = Math.sqrt(point.x()*point.x() + point.y()*point.y());
+ double pointZ = point.z();
+ if (pointR > innerR && pointR < outerR && pointZ > minZ && pointZ < maxZ) {
+ // Yes.
+ if (subdet.isCalorimeter()) {
+ //System.out.println("DEBUG: Point in calorimeter: "+point+" is inside system '"+name+"' which is of class '"+subdet.getClass().getName()+"'");
+ if (subdet.isLayered()) {
+ Layering layers = subdet.getLayering();
+ }
+ return subdet;
+ } else {
+ //System.out.println("DEBUG: Point not in calorimeter: "+point+" is inside system '"+name+"' which is of class '"+subdet.getClass().getName()+"'");
+ return subdet;
+ }
+ }
+ } else {
+ //System.out.println("DEBUG: Subdetector '"+name+"' of class '"+subdet.getClass().getName()+"' is not cylindrical.");
+ }
+ }
+
+ return null; // dummy
+ }
}