GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
diff -u -r1.1 -r1.2
--- SiTrackerBarrel.java 6 Oct 2006 19:11:28 -0000 1.1
+++ SiTrackerBarrel.java 11 Oct 2006 00:16:22 -0000 1.2
@@ -30,9 +30,9 @@
*
*/
public class SiTrackerBarrel extends LCDDSubdetector
-{
- Map<String,Volume> modules = new HashMap<String,Volume>();
-
+{
+ Map<String, Volume> modules = new HashMap<String, Volume>();
+
public SiTrackerBarrel(Element node) throws JDOMException
{
super(node);
@@ -64,13 +64,14 @@
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(); )
+ 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);
+ try
+ {
+ module_envelope = buildModule(node, module_name, lcdd, sens);
modules.put(module_name, module_envelope);
}
catch (Exception x)
@@ -78,7 +79,7 @@
throw new RuntimeException(x);
}
}
-
+
// Build the layers.
int nlayer = 0;
for (Iterator i = node.getChildren("layer").iterator(); i.hasNext(); nlayer++)
@@ -88,10 +89,10 @@
// 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");
@@ -143,7 +144,7 @@
{
rphi_dr = rphi_layout.getAttribute("dr").getDoubleValue();
}
-
+
// Phi increment for one module.
double phi_incr = (Math.PI * 2) / nphi;
@@ -192,13 +193,13 @@
{
// Delta x of module position.
double dx = z_dr * cos(phic + phi_tilt);
-
+
// Delta y of module position.
- double dy = z_dr * sin(phic + phi_tilt);
-
+ double dy = z_dr * sin(phic + phi_tilt);
+
// Basic x module position.
double x = rc * cos(phic);
-
+
// Basic y module position.
double y = rc * sin(phic);
@@ -206,8 +207,7 @@
for (int j = 0; j < nz; j++)
{
// Create a unique name for the module in this logical volume, layer, phi, and z.
- String module_place_name =
- detector_name + "_layer" + nlayer + "_phi" + ii + "_z" + j;
+ String module_place_name = detector_name + "_layer" + nlayer + "_phi" + ii + "_z" + j;
double z = module_z;
@@ -219,7 +219,7 @@
//System.out.println("module y=" + y);
//System.out.println("module z=" + z);
// DEBUG
-
+
// Position of module.
Position module_position = new Position(module_place_name + "_position");
module_position.setX(x);
@@ -248,7 +248,7 @@
module_physvol.addPhysVolID("phi", ii);
module_physvol.addPhysVolID("z", j);
layer_envelope_logvol.addPhysVol(module_physvol);
-
+
// Adjust the x and y coordinates of the module.
x += dx;
y += dy;
@@ -265,10 +265,10 @@
// Increment the phi placement of module.
phic += phi_incr;
-
+
// Increment the center radius according to dr parameter.
rc += rphi_dr;
-
+
// Flip sign of dr parameter.
rphi_dr *= -1;
@@ -281,7 +281,7 @@
{
layer_envelope_logvol.setVisAttributes(lcdd.getVisAttributes("InvisibleWithDaughters"));
}
-
+
// Add the layer volume to LCDD.
structure.addVolume(layer_envelope_logvol);
@@ -290,13 +290,13 @@
// Set the subdetector system ID.
layer_envelope_physvol.addPhysVolID("system", id);
-
+
// Flag this as a barrel subdetector.
- layer_envelope_physvol.addPhysVolID("barrel",0);
-
+ layer_envelope_physvol.addPhysVolID("barrel", 0);
+
// Set the layer ID.
layer_envelope_physvol.addPhysVolID("layer", nlayer);
-
+
// Put the layer into the mother volume.
tracking_logvol.addPhysVol(layer_envelope_physvol);
}
@@ -311,19 +311,19 @@
* @throws Exception
*/
Volume buildModule(Element detector, String name, LCDD lcdd, SensitiveDetector sens) throws Exception
- {
+ {
String detector_name = detector.getAttributeValue("name");
Volume module_logvol = null;
-
- int sensor_number=0;
-
+
+ int sensor_number = 0;
+
for (Iterator i = detector.getChildren("module").iterator(); i.hasNext();)
{
Element module = (Element) i.next();
-
+
if (module.getAttributeValue("name").compareTo(name) == 0)
- {
- Element module_envelope = module.getChild("module_envelope");
+ {
+ Element module_envelope = module.getChild("module_envelope");
String module_name = detector_name + "_" + module.getAttributeValue("name");
@@ -345,18 +345,18 @@
// Build module components.
int ncomponents = 0;
for (Iterator j = module.getChildren("module_component").iterator(); j.hasNext(); ++ncomponents)
- {
+ {
Element component = (Element) j.next();
- boolean sensitive = ( (component.getAttribute("sensitive") == null) ? false : component.getAttribute("sensitive").getBooleanValue());
-
+ boolean sensitive = ((component.getAttribute("sensitive") == null) ? false : component.getAttribute("sensitive").getBooleanValue());
+
String component_name = module_name + "_component" + ncomponents;
// DEBUG
//System.out.println("component_name=" + component_name);
//System.out.println("build component="+ncomponents);
//
-
+
// Create the box solid for the module component.
double component_length = component.getAttribute("length").getDoubleValue();
double component_width = component.getAttribute("width").getDoubleValue();
@@ -375,84 +375,84 @@
lcdd.getStructure().addVolume(component_logvol);
PhysVol component_physvol = new PhysVol(component_logvol);
-
+
// Set component position.
// FIXME: Processing of positions should be generalized in compact description.
if (component.getChild("position") != null)
{
Element pos_elem = component.getChild("position");
-
+
Position component_position = new Position(component_name + "_position");
-
+
if (pos_elem.getAttribute("x") != null)
{
component_position.setX(pos_elem.getAttribute("x").getDoubleValue());
}
-
+
if (pos_elem.getAttribute("y") != null)
{
component_position.setY(pos_elem.getAttribute("y").getDoubleValue());
}
-
+
if (pos_elem.getAttribute("z") != null)
{
component_position.setZ(pos_elem.getAttribute("z").getDoubleValue());
}
-
+
lcdd.getDefine().addPosition(component_position);
component_physvol.setPosition(component_position);
- }
-
+ }
+
// Set component rotation.
// FIXME: Processing of rotations should be generalized in compact description.
if (component.getChild("rotation") != null)
{
Element rot_elem = component.getChild("rotation");
-
+
Rotation component_rotation = new Rotation(component_name + "_rotation");
-
+
if (rot_elem.getAttribute("x") != null)
{
component_rotation.setX(rot_elem.getAttribute("x").getDoubleValue());
}
-
+
if (rot_elem.getAttribute("y") != null)
{
component_rotation.setY(rot_elem.getAttribute("y").getDoubleValue());
}
-
+
if (rot_elem.getAttribute("z") != null)
{
component_rotation.setZ(rot_elem.getAttribute("z").getDoubleValue());
}
component_physvol.setRotation(component_rotation);
-
+
lcdd.getDefine().addRotation(component_rotation);
- }
-
+ }
+
if (sensitive)
{
component_logvol.setSensitiveDetector(sens);
- component_physvol.addPhysVolID("sensor",sensor_number);
+ component_physvol.addPhysVolID("sensor", sensor_number);
++sensor_number;
}
-
+
module_logvol.addPhysVol(component_physvol);
}
-
+
break;
}
}
-
+
if (module_logvol == null)
{
throw new RuntimeException("Failed to find module " + name);
}
-
+
// Add module logical volume to LCDD.
lcdd.getStructure().addVolume(module_logvol);
-
+
return module_logvol;
}