GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
diff -u -r1.6 -r1.7
--- SiStripTrackerBarrel.java 29 Sep 2006 23:42:09 -0000 1.6
+++ SiStripTrackerBarrel.java 3 Oct 2006 21:34:47 -0000 1.7
@@ -4,6 +4,8 @@
import static java.lang.Math.sin;
import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
import org.jdom.Element;
import org.jdom.JDOMException;
@@ -28,9 +30,8 @@
*
*/
public class SiStripTrackerBarrel extends LCDDSubdetector
-{
- private int sensor_number = 0;
- private int module_number = 0;
+{
+ Map<String,Volume> modules = new HashMap<String,Volume>();
public SiStripTrackerBarrel(Element node) throws JDOMException
{
@@ -62,6 +63,22 @@
// Pick the mother volume (tracking volume).
Volume tracking_logvol = lcdd.pickMotherVolume(this);
+ // Loop over the modules and put them into a map for lookup later.
+ for (Iterator i = node.getChildren("module").iterator(); i.hasNext(); )
+ {
+ Element module = (Element) i.next();
+ String module_name = module.getAttributeValue("name");
+ Volume module_envelope;
+ try {
+ module_envelope = buildModule(node, module_name, lcdd, sens);
+ modules.put(module_name, module_envelope);
+ }
+ catch (Exception x)
+ {
+ throw new RuntimeException(x);
+ }
+ }
+
// Build the layers.
int nlayer = 0;
for (Iterator i = node.getChildren("layer").iterator(); i.hasNext(); nlayer++)
@@ -69,6 +86,12 @@
// Get the next layer element.
Element layer = (Element) i.next();
+ // Get the reference to the module from the layer.
+ String module_name = layer.getAttributeValue("module");
+
+ // Get the logical volume for the module.
+ Volume module_envelope = modules.get(module_name);
+
// Get the barrel_envelope for this layer.
Element barrel_envelope = layer.getChild("barrel_envelope");
@@ -162,21 +185,7 @@
//System.out.println("module dr=" + dr);
//
- String module_lkp_name = layer.getAttributeValue("module");
-
- // Create the module for this layer.
- // A new module is created, even if
- // the logical structure is the name,
- // in order to maintain the correct
- // sensor number for track recon.
- Volume module_envelope;
- try {
- module_envelope = buildModule(node, module_lkp_name, lcdd, sens);
- }
- catch (Exception x)
- {
- throw new RuntimeException(x);
- }
+ //String module_lkp_name = layer.getAttributeValue("module");
// Loop over the number of modules in phi.
for (int ii = 0; ii < nphi; ii++)
@@ -198,7 +207,7 @@
{
// Create a unique name for the module in this logical volume, layer, phi, and z.
String module_place_name =
- detector_name + "_" + module_lkp_name + "_layer" + nlayer + "_phi" + ii + "_z" + j;
+ detector_name + "_layer" + nlayer + "_phi" + ii + "_z" + j;
double z = module_z;
@@ -306,6 +315,8 @@
String detector_name = detector.getAttributeValue("name");
Volume module_logvol = null;
+ int sensor_number=0;
+
for (Iterator i = detector.getChildren("module").iterator(); i.hasNext();)
{
Element module = (Element) i.next();
@@ -314,7 +325,7 @@
{
Element module_envelope = module.getChild("module_envelope");
- String module_name = detector_name + "_" + module.getAttributeValue("name") + "_module" + module_number;
+ String module_name = detector_name + "_" + module.getAttributeValue("name");
// Create the module box.
double module_length = module_envelope.getAttribute("length").getDoubleValue();
@@ -423,14 +434,12 @@
if (sensitive)
{
component_logvol.setSensitiveDetector(sens);
- component_physvol.addPhysVolID("sensor",this.sensor_number);
- ++this.sensor_number;
+ component_physvol.addPhysVolID("sensor",sensor_number);
+ ++sensor_number;
}
module_logvol.addPhysVol(component_physvol);
}
-
- ++module_number;
break;
}