GeomConverter/src/org/lcsim/geometry/subdetector
diff -u -r1.2 -r1.3
--- SiTrackerBarrel.java 6 Oct 2006 23:24:48 -0000 1.2
+++ SiTrackerBarrel.java 10 Oct 2006 21:57:29 -0000 1.3
@@ -4,12 +4,17 @@
import hep.graphics.heprep.HepRepFactory;
import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
import org.jdom.DataConversionException;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.lcsim.material.Material;
import org.lcsim.material.MaterialManager;
+import org.lcsim.geometry.subdetector.tracker.silicon.*;
/**
*
@@ -22,6 +27,12 @@
*/
public class SiTrackerBarrel extends AbstractTracker
{
+
+ // Fields
+ //=======
+ Map<String,SiTrackerModule> _modules = new HashMap<String,SiTrackerModule>();
+ List<SiTrackerBarrelLayer> _layers = new ArrayList<SiTrackerBarrelLayer>();
+
SiTrackerBarrel(Element node) throws JDOMException
{
super(node);
@@ -37,32 +48,40 @@
// Loop over modules.
for (Iterator i = detector.getChildren("module").iterator(); i.hasNext();)
{
- Element module = (Element)i.next();
+ Element module_element = (Element)i.next();
- Element module_envelope = module.getChild("module_envelope");
+ String module_name = module_element.getAttributeValue("name");
+ Element module_envelope = module_element.getChild("module_envelope");
+
double module_width = module_envelope.getAttribute("width").getDoubleValue();
double module_length = module_envelope.getAttribute("length").getDoubleValue();
double module_thickness = module_envelope.getAttribute("thickness").getDoubleValue();
-
- // FIXME: Make basic logical module object here. (e.g. non-placed)
-
- // Loop over module components.
- for (Iterator j = module.getChildren("module_component").iterator(); j.hasNext();)
+
+ // Make basic logical module object
+ SiTrackerModule module = new SiTrackerModule(new Box(module_width,module_length,module_thickness));
+
+ // Loop over module components
+ for (Iterator j = module_element.getChildren("module_component").iterator(); j.hasNext();)
{
- Element module_component = (Element)j.next();
+ Element module_component_element = (Element)j.next();
// module_component parameters.
- double module_component_length = module_component.getAttribute("width").getDoubleValue();
- double module_component_thickness = module_component.getAttribute("thickness").getDoubleValue();
- double module_component_width = module_component.getAttribute("width").getDoubleValue();
- Material material = MaterialManager.getMaterial(module_component.getAttributeValue("material"));
- boolean sensitive = (module_component.getAttribute("sensitive") == null) ? false : module_component.getAttribute("sensitive").getBooleanValue();
+ double module_component_length = module_component_element.getAttribute("width").getDoubleValue();
+ double module_component_thickness = module_component_element.getAttribute("thickness").getDoubleValue();
+ double module_component_width = module_component_element.getAttribute("width").getDoubleValue();
+ Material material = MaterialManager.getMaterial(module_component_element.getAttributeValue("material"));
+ boolean sensitive = (module_component_element.getAttribute("sensitive") == null) ? false :
+ module_component_element.getAttribute("sensitive").getBooleanValue();
- // module_component position.
+ // Build component
+ Component component = new Component
+ (new Box(module_component_width,module_component_length,module_component_thickness), material );
+
+ // module_component positions
double module_component_x, module_component_y, module_component_z = 0.0;
- if (module_component.getChild("position") != null)
+ if (module_component_element.getChild("position") != null)
{
- Element position = (Element)module_component.getChild("position");
+ Element position = (Element)module_component_element.getChild("position");
if (position.getAttribute("x") != null)
{
@@ -80,11 +99,11 @@
}
}
- // module_component rotation.
+ // module_component rotations
double module_component_rx, module_component_ry, module_component_rz = 0.0;
- if (module_component.getChild("rotation") != null)
+ if (module_component_element.getChild("rotation") != null)
{
- Element rotation = (Element)module_component.getChild("rotation");
+ Element rotation = (Element)module_component_element.getChild("rotation");
if (rotation.getAttribute("x") != null)
{
@@ -102,41 +121,55 @@
}
}
- // FIXME: Add the module_component to the module here. --JM
- }
+ // FIXME: position the component
+
+
+ // Add the module_component to the module.
+ module.addComponent(component);
+
+ }
+
+ // Store the module
+ _modules.put(module_name, module);
+
}
// Loop over layers.
int layern=0;
for (Iterator i = detector.getChildren("layer").iterator(); i.hasNext(); ++layern)
{
- Element layer = (Element)i.next();
+ Element layer_element = (Element)i.next();
// Name of the module associated with this layer.
- String module_lkp = layer.getAttributeValue("module");
+ String module_lkp = layer_element.getAttributeValue("module");
// barrel_envelope parameters.
- Element barrel_envelope = layer.getChild("barrel_envelope");
+ Element barrel_envelope = layer_element.getChild("barrel_envelope");
double layer_inner_r = barrel_envelope.getAttribute("inner_r").getDoubleValue();
double layer_outer_r = barrel_envelope.getAttribute("outer_r").getDoubleValue();
double layer_z_length = barrel_envelope.getAttribute("z_length").getDoubleValue();
// rphi_layout parameters.
- Element rphi_layout = layer.getChild("rphi_layout");
+ Element rphi_layout = layer_element.getChild("rphi_layout");
double phi_tilt = rphi_layout.getAttribute("phi_tilt").getDoubleValue();
- double nphi = rphi_layout.getAttribute("nphi").getIntValue();
+ int nphi = rphi_layout.getAttribute("nphi").getIntValue();
double phi0 = rphi_layout.getAttribute("phi0").getDoubleValue();
double rc = rphi_layout.getAttribute("rc").getDoubleValue();
double dr = rphi_layout.getAttribute("dr").getDoubleValue();
// z_layout parameters.
- Element z_layout = layer.getChild("z_layout");
+ Element z_layout = layer_element.getChild("z_layout");
double z_dr = z_layout.getAttribute("dr").getDoubleValue();
double z0 = z_layout.getAttribute("z0").getDoubleValue();
int nz = z_layout.getAttribute("nz").getIntValue();
- // FIXME: Make layer object here. --JM
- }
+ // Make layer object.
+ SiTrackerBarrelLayer layer = new SiTrackerBarrelLayer(layer_inner_r,layer_outer_r,layer_z_length);
+ layer.setPhiLayout(rc,nphi,phi0,phi_tilt,dr);
+ layer.setZLayout(nz,z0,z_dr);
+ layer.setModule(_modules.get(module_lkp));
+
+ }
}
public void appendHepRep(HepRepFactory factory, HepRep heprep)