lcsim/src/org/lcsim/recon/tracking/gtrdetector
diff -u -r1.8 -r1.9
--- GtrDetector.java 7 May 2008 21:47:41 -0000 1.8
+++ GtrDetector.java 8 May 2008 00:02:03 -0000 1.9
@@ -3,10 +3,12 @@
*
* Created on July 30, 2005, 3:30 PM
*
- * $Id: GtrDetector.java,v 1.8 2008/05/07 21:47:41 ngraf Exp $
+ * $Id: GtrDetector.java,v 1.9 2008/05/08 00:02:03 jeremy Exp $
*/
package org.lcsim.recon.tracking.gtrdetector;
+import static java.lang.Math.PI;
+import static java.lang.Math.sin;
import static org.lcsim.units.clhep.SystemOfUnits.cm;
import hep.physics.vec.Hep3Vector;
@@ -16,15 +18,16 @@
import java.util.Map;
import java.util.Set;
-import static java.lang.Math.sin;
-import static java.lang.Math.PI;
-
import org.lcsim.conditions.DetectorLocator;
import org.lcsim.detector.IDetectorElement;
+import org.lcsim.detector.IPhysicalVolume;
import org.lcsim.detector.IRotation3D;
import org.lcsim.detector.material.IMaterial;
import org.lcsim.detector.solids.Box;
+import org.lcsim.detector.solids.ISolid;
import org.lcsim.detector.solids.Point3D;
+import org.lcsim.detector.solids.Trap;
+import org.lcsim.detector.solids.Trd;
import org.lcsim.geometry.compact.Subdetector;
import org.lcsim.geometry.layer.Layer;
import org.lcsim.geometry.layer.LayerSlice;
@@ -32,6 +35,7 @@
import org.lcsim.geometry.subdetector.DiskTracker;
import org.lcsim.geometry.subdetector.MultiLayerTracker;
import org.lcsim.geometry.subdetector.SiTrackerBarrel;
+import org.lcsim.geometry.subdetector.SiTrackerEndcap;
import org.lcsim.recon.tracking.spacegeom.CartesianPoint;
import org.lcsim.recon.tracking.spacegeom.CartesianTwoPoint;
import org.lcsim.recon.tracking.spacegeom.SpacePoint;
@@ -77,6 +81,10 @@
{
add((SiTrackerBarrel) subDet);
}
+ else if (subDet instanceof SiTrackerEndcap)
+ {
+ add((SiTrackerEndcap) subDet);
+ }
}
}
@@ -314,7 +322,7 @@
for (IDetectorElement module : layer.getChildren())
{
//System.out.println(" " + module.getName());
- double x0 = calculateModuleX0(module);
+ double x0 = calculateBarrelModuleX0(module);
//System.out.println(" module <" + module.getName() + "> x0="+x0);
IDetectorElement sensor = null;
for (IDetectorElement component : module.getChildren())
@@ -389,13 +397,54 @@
if(phi0<0.) phi0+=2.*PI;
BSurfXYPlane xyp = new BSurfXYPlane(rdist, phi0, u1, u2, globalP1.z(), globalP3.z());
- System.out.println("XYPlane for sensor <" + sensor.getName() + ">");
- System.out.println(xyp);
+ //System.out.println("XYPlane for sensor <" + sensor.getName() + ">");
+ //System.out.println(xyp);
}
}
}
-// return effective x/x0 for this layer
+ private void add(SiTrackerEndcap e)
+ {
+ IDetectorElement de = e.getDetectorElement();
+
+ for (IDetectorElement endcap : de.getChildren())
+ {
+ for (IDetectorElement layer : endcap.getChildren())
+ {
+ for (IDetectorElement wedge : layer.getChildren())
+ {
+ for (IDetectorElement module : wedge.getChildren())
+ {
+ double x0 = calculateEndcapModuleX0(module);
+
+ //System.out.println("module " + module.getName() + " x0 = " + x0);
+
+ IDetectorElement sensor = null;
+ for (IDetectorElement component : module.getChildren())
+ {
+ if (component.getGeometry().getPhysicalVolume().isSensitive())
+ {
+ sensor = component;
+ //System.out.println("sensor - " + component.getName());
+ break;
+ }
+ }
+
+ if (sensor == null)
+ throw new RuntimeException("No sensor found!");
+
+ ISolid solid = sensor.getGeometry().getLogicalVolume().getSolid();
+
+ // TODO: Create ZPlanes here!
+ }
+
+ }
+ }
+ }
+
+ }
+
+ // return effective x/x0 for this layer
private double calculateLayerX0( Layer layer)
{
List<LayerSlice> lslist = layer.getSlices();
@@ -404,26 +453,70 @@
{
double x0 = lsl.getMaterial().getRadiationLengthWithDensity(); // in cm.
double thickness = lsl.getThickness(); // in mm.
- xOverX0 += thickness/(x0*10.); // cm -> mm
+ xOverX0 += thickness/(x0*cm); // cm -> mm
// System.out.println(lsl.getMaterial().getName()+" x0= "+x0+ " thickness= "+thickness+ " => x/x0= "+thickness/(x0*10.));
}
return xOverX0;
}
- private double calculateModuleX0(IDetectorElement module)
- {
- double xOverX0 = 0.;
- for (IDetectorElement component : module.getChildren())
+ private double calculateEndcapModuleX0(IDetectorElement module)
+ {
+ System.out.println(module.getName() + " - calculateModuleX0");
+ double xOverX0 = 0.;
+ for (IPhysicalVolume component : module.getGeometry().getLogicalVolume().getDaughters())
{
- Box b = (Box)component.getGeometry().getLogicalVolume().getSolid();
- double thickness = b.getZHalfLength() * 2;
- IMaterial material = component.getGeometry().getLogicalVolume().getMaterial();
+ ISolid solid = component.getLogicalVolume().getSolid();
+ double thickness = 0.;
+ if (solid instanceof Box)
+ {
+ thickness = ((Box)solid).getYHalfLength() * 2;
+ //System.out.println("box thickness " + thickness);
+ }
+ else if (solid instanceof Trd)
+ {
+ thickness = ((Trd)solid).getYHalfLength1() * 2;
+ //System.out.println("trd thickness " + thickness);
+ }
+ else if (solid instanceof Trap)
+ {
+ thickness = ((Trap)solid).getYHalfLength1() * 2;
+ //System.out.println("trap thickness " + thickness);
+ }
+ else
+ {
+ throw new RuntimeException("Unknown solid type " + solid.getClass().getCanonicalName() + " for module " + module.getName() + "!");
+ }
+ IMaterial material = component.getLogicalVolume().getMaterial();
double x0 = material.getRadiationLengthWithDensity();
xOverX0 += thickness/(x0*cm);
}
return xOverX0;
- }
+ }
+ private double calculateBarrelModuleX0(IDetectorElement module)
+ {
+ //System.out.println(module.getName() + " - calculateModuleX0");
+ double xOverX0 = 0.;
+ for (IPhysicalVolume component : module.getGeometry().getLogicalVolume().getDaughters())
+ {
+ ISolid solid = component.getLogicalVolume().getSolid();
+ double thickness = 0.;
+ if (solid instanceof Box)
+ {
+ thickness = ((Box)solid).getZHalfLength() * 2;
+ //System.out.println("box thickness " + thickness);
+ }
+ else
+ {
+ throw new RuntimeException("Unknown solid type " + solid.getClass().getCanonicalName() + " for module " + module.getName() + "!");
+ }
+ IMaterial material = component.getLogicalVolume().getMaterial();
+ double x0 = material.getRadiationLengthWithDensity();
+ xOverX0 += thickness/(x0*cm);
+ }
+ return xOverX0;
+ }
+
public static void main(String[] args)
{
GtrDetector gtrdet = new GtrDetector("sid01");