lcsim/src/org/lcsim/recon/cluster/structural/likelihood
diff -u -r1.1 -r1.2
--- MiscUtilities.java 1 Mar 2006 02:45:58 -0000 1.1
+++ MiscUtilities.java 7 May 2010 19:03:04 -0000 1.2
@@ -1,8 +1,6 @@
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;
@@ -12,17 +10,21 @@
import org.lcsim.event.Cluster;
import org.lcsim.recon.cluster.util.BasicCluster;
import org.lcsim.recon.cluster.util.TensorClusterPropertyCalculator;
-import org.lcsim.geometry.layer.Layering;
-import org.lcsim.geometry.CylindricalSubdetector;
-//import org.lcsim.geometry.Subdetector;
import org.lcsim.util.swim.Line;
-import org.lcsim.event.MCParticle;
-import org.lcsim.event.SimCalorimeterHit;
-import org.lcsim.event.EventHeader;
+import org.lcsim.recon.util.CalorimeterInformation;
+import org.lcsim.geometry.Calorimeter.CalorimeterType;
class MiscUtilities
{
//MiscUtilities() {}
+ static private CalorimeterInformation ci;
+ static private CalorimeterType[] ct;
+ static private double[] rmin;
+ static private double[] rmax;
+ static private double[] zmin;
+ static private double[] zmax;
+ static private int[] nsides;
+
/**
* Get the minimum distance between hits in the two clusters.
@@ -115,27 +117,56 @@
static protected org.lcsim.geometry.Subdetector findComponent(Hep3Vector point, org.lcsim.geometry.Detector det)
{
- if (det==null) { System.out.println("WARNING in MiscUtilities: det is null. I will crash..."); }
- 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) {
- return subdet;
- }
- }
- }
+ int ncal = 6;
+ if(ci == null)
+ {
+ ci = CalorimeterInformation.instance();
+ ct = new CalorimeterType[ncal];
+ rmin = new double[ncal];
+ rmax = new double[ncal];
+ zmin = new double[ncal];
+ zmax = new double[ncal];
+ nsides = new int[ncal];
+ ct[0] = CalorimeterType.EM_BARREL;
+ ct[1] = CalorimeterType.HAD_BARREL;
+ ct[2] = CalorimeterType.MUON_BARREL;
+ ct[3] = CalorimeterType.EM_ENDCAP;
+ ct[4] = CalorimeterType.HAD_ENDCAP;
+ ct[5] = CalorimeterType.MUON_ENDCAP;
+ for(int i=0;i<ct.length;i++)
+ {
+ CalorimeterType t = ct[i];
+ rmin[i] = ci.getRMin(t);
+ rmax[i] = ci.getRMax(t);
+ zmin[i] = ci.getZMin(t);
+ zmax[i] = ci.getZMax(t);
+ nsides[i] = ci.getNSides(t);
+ }
+ }
+ double pointR = Math.sqrt(point.x()*point.x() + point.y()*point.y());
+ double pointZ = Math.abs(point.z());
+ for(int i=0;i<ct.length;i++)
+ {
+ CalorimeterType t = ct[i];
+ double rlmin = rmin[i];
+ double rlmax = rmax[i];
+ if(nsides[i] > 3)
+ {
+ double phi = Math.atan2(point.y(),point.x());
+ while(phi > Math.PI/nsides[i])
+ {
+ phi -= 2.*Math.PI/nsides[i];
+ }
+ while(phi < -Math.PI/nsides[i])
+ {
+ phi += 2.*Math.PI/nsides[i];
+ }
+ rlmin /= Math.cos(phi);
+ rlmax /= Math.cos(phi);
+ }
+ if (pointR > rlmin && pointR < rlmax && pointZ > zmin[i] && pointZ < zmax[i])
+ return ci.getSubdetector(t);
+ }
return null; // Couldn't find a cylindrical detector containing this point
}