projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java (rev 0)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java 2014-04-22 05:14:21 UTC (rev 3101)
@@ -0,0 +1,1496 @@
+package org.lcsim.geometry.compact.converter.lcdd;
+
+import hep.physics.vec.BasicHep3Matrix;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Matrix;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.VecOp;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.lcsim.detector.ITransform3D;
+import org.lcsim.detector.Rotation3D;
+import org.lcsim.detector.RotationGeant;
+import org.lcsim.detector.Transform3D;
+import org.lcsim.detector.Translation3D;
+import org.lcsim.geometry.compact.converter.lcdd.util.Box;
+import org.lcsim.geometry.compact.converter.lcdd.util.LCDD;
+import org.lcsim.geometry.compact.converter.lcdd.util.Material;
+import org.lcsim.geometry.compact.converter.lcdd.util.PhysVol;
+import org.lcsim.geometry.compact.converter.lcdd.util.Position;
+import org.lcsim.geometry.compact.converter.lcdd.util.Rotation;
+import org.lcsim.geometry.compact.converter.lcdd.util.SensitiveDetector;
+import org.lcsim.geometry.compact.converter.lcdd.util.Volume;
+
+/**
+ *
+ * Convert an SiTrackerBarrel subdetector to the LCDD format.
+ *
+ * @author Jeremy McCormick <[log in to unmask]>
+ * @author Tim Nelson <[log in to unmask]>
+ *
+ */
+public class HPSTestRunTracker2014 extends LCDDSubdetector
+{
+ private boolean _debug = true;
+ public static final double inch = 25.4;
+
+ private final double sensor_length= 98.33;
+ private final double sensor_width = 38.3399;
+ private final double sensor_thickness = 0.32;
+ private final double hybrid_length = 170.0 - sensor_length; // sensor b-to-b with hybrid
+ private final double hybrid_width = sensor_width;
+ private final double hybrid_width_L46 = 45.34;
+ private final double hybrid_thickness = 4.0/64.0*inch;
+ //TODO Check these numbers
+ private final double cf_length = 200.;
+ private final double cf_width = 45.;
+ private final double cf_thickness = 0.250;
+ private final double kapton_length = 184.0;
+ private final double kapton_width = 40.0;
+ private final double kapton_thickness = 0.050;
+
+ private final double support_plate_bottom_height = 12.7; //1/2"
+ private final double support_plate_bottom_length = 736.1;
+ private final double support_plate_bottom_width = 120.0;
+
+
+ private final double module_L13_width = 71.3 - 13.0; // height from cold block to encapsulate the whole module
+ private final double module_L45_width = 65.3-12.0;
+ final double module_box_L13_length = 205.2; // includes lexan spacer and cold block
+ final double module_box_L13_height = 12.5; // includes screws height
+ final double module_box_L13_width = module_L13_width;
+
+ private final double half_module_thickness = this.hybrid_thickness + this.cf_thickness + this.kapton_thickness;
+ private final double half_module_length = this.cf_length;
+ private final double half_module_width = 6.83 + this.sensor_width;
+
+ private final double coldblock_length = 82.00;
+ private final double coldblock_width = 52.50;
+ private final double coldblock_thickness = 6.00;
+
+ private final Hep3Vector ball_pos_module1_support_plate_local = new BasicHep3Vector(25.0, 661.0, 0.0);
+ private final Hep3Vector vee_pos_module1_support_plate_local = new BasicHep3Vector(95.0, 661.0, 0.0);
+ private final Hep3Vector flat_pos_module1_support_plate_local = new BasicHep3Vector(60.0, 667.10, 0.0);
+
+ private final Hep3Vector ball_pos_module2_support_plate_local = new BasicHep3Vector(25.0, 561.0, 0.0);
+ private final Hep3Vector vee_pos_module2_support_plate_local = new BasicHep3Vector(95.0, 561.0, 0.0);
+ private final Hep3Vector flat_pos_module2_support_plate_local = new BasicHep3Vector(60.0, 567.10, 0.0);
+
+ private final Hep3Vector ball_pos_module3_support_plate_local = new BasicHep3Vector(25.0, 461.0, 0.0);
+ private final Hep3Vector vee_pos_module3_support_plate_local = new BasicHep3Vector(95.0, 461.0, 0.0);
+ private final Hep3Vector flat_pos_module3_support_plate_local = new BasicHep3Vector(60.0, 467.10, 0.0);
+
+ private final Hep3Vector ball_pos_module4_support_plate_local = new BasicHep3Vector(25.0, 261.0, 0.0);
+ private final Hep3Vector vee_pos_module4_support_plate_local = new BasicHep3Vector(95.0, 261.0, 0.0);
+ private final Hep3Vector flat_pos_module4_support_plate_local = new BasicHep3Vector(60.0, 267.10, 0.0);
+
+ private final Hep3Vector ball_pos_module5_support_plate_local = new BasicHep3Vector(25.0, 61.0, 0.0);
+ private final Hep3Vector vee_pos_module5_support_plate_local = new BasicHep3Vector(95.0, 61.0, 0.0);
+ private final Hep3Vector flat_pos_module5_support_plate_local = new BasicHep3Vector(60.0, 67.10, 0.0);
+
+
+
+
+
+
+
+ public HPSTestRunTracker2014(Element node) throws JDOMException
+ {
+ super(node);
+ }
+
+
+ public boolean isTracker() {
+ return true;
+ }
+
+ /**
+ * Build the LCDD for the subdetector.
+ * @param lcdd The LCDD file being created.
+ * @param sens The SD for this subdetector.
+ */
+ public void addToLCDD(LCDD lcdd, SensitiveDetector sens) throws JDOMException
+ {
+
+ /** General comments
+ // Roll: rotation around x
+ // pitch: rotation around y
+ // yaw: rotation around z
+
+ // kinematic mounts:
+ // ball (constraints x,y,z)
+ // vee (constraints pitch & yaw)
+ // flat (constraints roll)
+ **/
+
+
+
+
+ // ID of the detector.
+ int id = this.node.getAttribute("id").getIntValue();
+
+ // Name of the detector.
+ String detector_name = this.node.getAttributeValue("name");
+
+ if(_debug) {
+ print(String.format("detector id %d name %s", id,detector_name));
+ }
+
+ // Pick the mother volume (tracking volume).
+ Volume trackingVolume = lcdd.pickMotherVolume(this);
+
+ VolWrapper trackingWrap = new VolWrapper();
+ trackingWrap.name = "trackingVolume";
+ trackingWrap.vol = trackingVolume;
+
+ // create the box around the support plate: "support box"
+ makeSupport(trackingWrap, lcdd, sens );
+
+
+
+
+
+
+
+ }
+
+
+
+ private void makeSupport(VolWrapper trackingWrap, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
+
+
+
+
+ final double support_length = this.support_plate_bottom_length;
+ final double support_width = (25.0-5.0) + this.module_box_L13_length;
+ // height to encapsulate all the modules; a little arbitrary here, TODO fix this
+ final double support_height = this.support_plate_bottom_height + module_L45_width;
+
+
+ String volName = "support";
+ Box box = new Box(volName + "Box", support_width, support_height , support_length);
+ lcdd.add(box);
+ Volume supportVolume = new Volume(volName + "_volume", box, lcdd.getMaterial("Vacuum"));
+
+ Position pos = new Position( volName + "_position", 0,0,0);
+ Rotation rot = new Rotation( volName + "_rotation",0,0,0);
+ lcdd.add(pos);
+ lcdd.add(rot);
+
+ PhysVol supportPV = new PhysVol(supportVolume, trackingWrap.vol, pos, rot);
+
+ VolWrapper supportWrap = new VolWrapper();
+ supportWrap.vol = supportVolume;
+ supportWrap.name = volName;
+ supportWrap.pos_vol = pos;
+ supportWrap.rot_vol = rot;
+
+
+
+
+
+ // create the support plate inside the support box at the "bottom"
+ // survey points are:
+ // ball: corner of the hinge end at the surface on the positron side
+ // vee: corner of the hinge end at the surface on the electron side
+ // flat: middle of plate at upstream end at the surface
+
+ Hep3Vector ball_pos_support_plate = new BasicHep3Vector(-1.0 * support_width/2.0, -1.0 * support_height/2.0 + support_plate_bottom_height , support_length/2.0);
+ Hep3Vector vee_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x() + support_plate_bottom_width, ball_pos_support_plate.y(),ball_pos_support_plate.z());
+ Hep3Vector flat_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x(), ball_pos_support_plate.y(),ball_pos_support_plate.z() - support_plate_bottom_length);
+
+ makeSupportPlate(supportWrap, ball_pos_support_plate, vee_pos_support_plate, flat_pos_support_plate, lcdd, sens );
+
+ // create the module from positions of module ball, vee and flat w.r.t. support plate survey points
+
+ // create the coordinate system of the support plate
+ CoordSysDef support_plate_coord = new CoordSysDef(ball_pos_support_plate, vee_pos_support_plate, flat_pos_support_plate);
+ Transform3D trans_support_plate_to_support = getTransformation(support_plate_coord);
+
+ if(_debug) {
+ print("Make modules on support plate");
+ }
+
+ for(int ilayer = 1; ilayer <=5; ++ilayer) {
+
+ String layerName = String.format("L%db", ilayer);
+
+ print(layerName);
+
+ // position of survey positions on the support plate in the support plate coordinates system
+ Hep3Vector ball_pos_mod_local = null;
+ Hep3Vector vee_pos_mod_local = null;
+ Hep3Vector flat_pos_mod_local = null;
+ if(ilayer == 1) {
+ ball_pos_mod_local = ball_pos_module1_support_plate_local;
+ vee_pos_mod_local = vee_pos_module1_support_plate_local;
+ flat_pos_mod_local = flat_pos_module1_support_plate_local;
+ }
+ else if (ilayer == 2) {
+ ball_pos_mod_local = ball_pos_module2_support_plate_local;
+ vee_pos_mod_local = vee_pos_module2_support_plate_local;
+ flat_pos_mod_local = flat_pos_module2_support_plate_local;
+ }
+ else if (ilayer == 3) {
+ ball_pos_mod_local = ball_pos_module3_support_plate_local;
+ vee_pos_mod_local = vee_pos_module3_support_plate_local;
+ flat_pos_mod_local = flat_pos_module3_support_plate_local;
+ }
+ else if (ilayer == 4) {
+ ball_pos_mod_local = ball_pos_module4_support_plate_local;
+ vee_pos_mod_local = vee_pos_module4_support_plate_local;
+ flat_pos_mod_local = flat_pos_module4_support_plate_local;
+ } else if (ilayer == 5) {
+ ball_pos_mod_local = ball_pos_module5_support_plate_local;
+ vee_pos_mod_local = vee_pos_module5_support_plate_local;
+ flat_pos_mod_local = flat_pos_module5_support_plate_local;
+ } else {
+ print("Not more than 5 layers!");
+ System.exit(1);
+ }
+
+ if(_debug) {
+ print(String.format("ball_pos_mod_local %s", ball_pos_mod_local.toString()));
+ print(String.format("vee_pos_mod_local %s", vee_pos_mod_local.toString()));
+ print(String.format("flat_pos_mod_local %s", flat_pos_mod_local.toString()));
+ }
+
+ // transform to support frame
+ Hep3Vector ball_pos_mod = trans_support_plate_to_support.transformed(ball_pos_mod_local);
+ Hep3Vector ball_pos_mod_rot = trans_support_plate_to_support.rotated(ball_pos_mod_local);
+ Hep3Vector ball_pos_mod_tr = trans_support_plate_to_support.translated(ball_pos_mod_local);
+ Hep3Vector vee_pos_mod = trans_support_plate_to_support.transformed(vee_pos_mod_local);
+ Hep3Vector flat_pos_mod = trans_support_plate_to_support.transformed(flat_pos_mod_local);
+
+ if(_debug) {
+ print(String.format("ball_pos_mod_rot %s", ball_pos_mod_rot.toString()));
+ print(String.format("ball_pos_mod_tr %s", ball_pos_mod_tr.toString()));
+ print(String.format("ball_pos_mod %s", ball_pos_mod.toString()));
+ print(String.format("vee_pos_mod %s", vee_pos_mod.toString()));
+ print(String.format("flat_pos_mod %s", flat_pos_mod.toString()));
+ }
+
+ // make the module
+ makeModule(layerName,supportWrap, ball_pos_mod, vee_pos_mod, flat_pos_mod,lcdd, sens);
+
+ } // ilayer
+
+
+
+ // add support volume to lcdd
+ lcdd.add(supportVolume);
+
+
+
+
+ /*
+
+ // Get corrections to survey ball positions from compact file to support plate positions (from e.g. survey)
+ Map<String, Hep3Vector> corr_balls = new HashMap<String,Hep3Vector>(); // save for debugging
+ for(Iterator i = node.getChildren("support_plate").iterator(); i.hasNext();) {
+ Element e = (Element)i.next();
+ if(e.getAttributeValue("name").equals("SupportPlateL1-3bot")) {
+ for(Iterator ii = e.getChildren("position").iterator(); ii.hasNext();) {
+ Element element = (Element) ii.next();
+ String name = element.getAttribute("name").getValue();
+ // get vector correction
+ Hep3Vector corr = new BasicHep3Vector(element.getAttribute("x").getDoubleValue(), element.getAttribute("y").getDoubleValue(), element.getAttribute("z").getDoubleValue());
+ if( name.equals("ball")) {
+ VecOp.add(ball_pos, corr);
+ corr_balls.put("ball", corr);
+ }
+ else if( name.equals("vee")) {
+ VecOp.add(vee_pos, corr);
+ corr_balls.put("vee", corr);
+ }
+ else if( name.equals("flat")) {
+ VecOp.add(flat_pos, corr);
+ corr_balls.put("flat", corr);
+ }
+ else {
+ print(String.format("wrong alignment name for support plate: \"%s\"", name));
+ System.exit(1);
+ }
+ } //ii
+ }
+ } //i
+
+
+ // Find the local alignment corrections to the support plate
+ Hep3Vector local_translation = new BasicHep3Vector(0,0,0);
+ Hep3Vector local_rotation = new BasicHep3Vector(0,0,0);
+ for(Iterator i = node.getChildren("support_plate").iterator(); i.hasNext();) {
+ Element e = (Element)i.next();
+ if(e.getAttributeValue("name").equals("SupportPlateL1-3bot")) {
+ for(Iterator ii = e.getChildren("alignment").iterator(); ii.hasNext();) {
+ Element element = (Element) ii.next();
+ local_translation = new BasicHep3Vector(element.getAttribute("x").getDoubleValue(), element.getAttribute("y").getDoubleValue(), element.getAttribute("z").getDoubleValue());
+ local_rotation = new BasicHep3Vector(element.getAttribute("rx").getDoubleValue(), element.getAttribute("ry").getDoubleValue(), element.getAttribute("rz").getDoubleValue());
+
+ } //ii
+ }
+ } //i
+
+
+
+ */
+ }
+
+
+ private void makeSupportPlate(VolWrapper supportWrap,
+ Hep3Vector ball_pos_support_plate,
+ Hep3Vector vee_pos_support_plate,
+ Hep3Vector flat_pos_support_plate, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
+
+
+
+
+ String volName = "supportplate";
+ Box box = new Box(volName + "Box", support_plate_bottom_width, support_plate_bottom_height , support_plate_bottom_length);
+ lcdd.add(box);
+ Volume supportPlateVolume = new Volume(volName + "_volume", box, lcdd.getMaterial("Aluminum"));
+
+
+ // create the coordinate system
+ CoordSysDef support_plate_coord = new CoordSysDef(ball_pos_support_plate, vee_pos_support_plate, flat_pos_support_plate);
+
+ print(String.format("support_plate ball %s", ball_pos_support_plate.toString()));
+ print(String.format("support_plate vee %s", vee_pos_support_plate.toString()));
+ print(String.format("support_plate flat %s", flat_pos_support_plate.toString()));
+ print(String.format("support_plate:\n%s", support_plate_coord.toString()));
+
+ // Find distance to center in the local coordinate system
+ Transform3D trans_support_plate_to_support = getTransformation(support_plate_coord);
+ Hep3Vector box_center_support_plate_local = new BasicHep3Vector(support_plate_bottom_width/2.0, support_plate_bottom_length/2.0, -1.0 * support_plate_bottom_height/2.0);
+ Hep3Vector box_center_support_plate = trans_support_plate_to_support.transformed(box_center_support_plate_local);
+
+ print(String.format("box_center_support_plate_local %s", box_center_support_plate_local.toString()));
+ print(String.format("box_center_support_plate %s", box_center_support_plate.toString()));
+
+
+ Position pos = new Position(volName + "_position",box_center_support_plate.x(), box_center_support_plate.y(), box_center_support_plate.z());
+ //Find LCDD rotation angles from coordinate system unit vectors
+ Hep3Vector lcdd_rot_angles = new BasicHep3Vector(0,0,0); //getLCDDRotation(support_plate_coord);
+ Rotation rot = new Rotation(volName + "_rotation",lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z());
+ lcdd.add(pos);
+ lcdd.add(rot);
+ PhysVol supportPlatePV = new PhysVol(supportPlateVolume, supportWrap.vol, pos, rot);
+ // add volume to lcdd
+
+ supportPlateVolume.setVisAttributes(lcdd.getVisAttributes("SupportPlateVis"));
+
+ lcdd.add(supportPlateVolume);
+
+ VolWrapper supportPlateWrap = new VolWrapper();
+ supportPlateWrap.mother = supportWrap;
+ supportPlateWrap.vol = supportPlateVolume;
+ supportPlateWrap.name = volName;
+ supportPlateWrap.pos_vol = pos;
+ supportPlateWrap.rot_vol = rot;
+ supportWrap.daughters.add(supportPlateWrap);
+
+
+
+ }
+
+
+ private void makeModule(String name, VolWrapper supportWrap, Hep3Vector ball_pos_mod, Hep3Vector vee_pos_mod, Hep3Vector flat_pos_mod, LCDD lcdd, SensitiveDetector sens) throws JDOMException
+ {
+
+ print(String.format("----- makeModule() ------"));
+
+ // create the coordinate system of the module in the support frame
+ CoordSysDef module_coord = new CoordSysDef(ball_pos_mod, vee_pos_mod, flat_pos_mod);
+ Transform3D trans = getTransformation(module_coord);
+
+ if(_debug) {
+ print(String.format("module_coord:\n%s", module_coord.toString()));
+ print(String.format("module_coord trans:\n%s", trans.toString()));
+ }
+
+
+
+ String moduleName = "module_" + name;
+ // Find the bounding box for the module
+ //TODO find dimensions of this module box from Shawn
+ // Right now the box starts from the ball position and approximately encapsulates the two half-modules on the drawing
+
+ Hep3Vector box_dim_local = new BasicHep3Vector(module_box_L13_length,module_box_L13_height,module_box_L13_width);
+ Hep3Vector box_dim = trans.rotated(box_dim_local);
+ if(_debug) {
+ print(String.format("box_dim_local: %s", box_dim_local.toString()));
+ print(String.format("box_dim : %s", box_dim.toString()));
+ }
+
+ Box box = new Box(moduleName + "_box", box_dim.x(), box_dim.y(), box_dim.z());
+ lcdd.add(box);
+ Volume moduleVolume = new Volume(moduleName + "_volume", box, lcdd.getMaterial("Vacuum"));
+
+
+
+ VolWrapper moduleWrap = new VolWrapper();
+ moduleWrap.name = moduleName;
+ moduleWrap.vol = moduleVolume;
+ moduleWrap.mother = supportWrap;
+ moduleWrap.coord = module_coord;
+
+ // distance to the center of the box in the local coordinates
+ Hep3Vector box_center_local = new BasicHep3Vector(box_dim_local.x()/2.0-5.0, 0.0, box_dim_local.z()/2.0);
+ //Hep3Vector box_center_local = new BasicHep3Vector(0.0, 0.0,0.0);
+ moduleWrap.center = box_center_local;
+
+ // Find the LCDD position and rotation of this module
+ // vector to the center of module box from ball position/origin
+ Hep3Vector box_center = trans.transformed(box_center_local);
+ //Position pos = new Position(volName + "_position",box_center.x(), box_center.y(), box_center.z());
+ Position pos = new Position(moduleName + "_position",box_center.x(), box_center.y(), box_center.z());
+ //Find LCDD rotation angles from coordinate system unit vectors
+ //Hep3Vector lcdd_rot_angles = new BasicHep3Vector( Math.PI/2.0,0,0); //getLCDDRotation(survey_coord);
+ Hep3Vector lcdd_rot_angles = new BasicHep3Vector(0,0,0); //getLCDDRotation(survey_coord);
+ Rotation rot = new Rotation(moduleName + "_rotation",lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z());
+ lcdd.add(pos);
+ lcdd.add(rot);
+
+ PhysVol physVolume = new PhysVol(moduleVolume, supportWrap.vol, pos, rot);
+ supportWrap.daughters.add(moduleWrap);
+ moduleWrap.pv = physVolume;
+ moduleWrap.pos_vol = pos;
+ moduleWrap.rot_vol = rot;
+
+ if(_debug) {
+ print(String.format("module box center local %s",box_center_local.toString()));
+ print(String.format("module box center %s",box_center.toString()));
+ }
+
+
+ // Find the coordinate system of the half-modules w.r.t. to the module survey points
+ // We are going to know the sensor center position w.r.t. module frame so the half-module
+ // is really just a dummy volume to contain the daughters. Therefore place it at the same place
+ // as where the sensor coordinate system will be to make things simpler.
+
+ final double ball_pos_halfmod_axial_local_x = (180.0 - 30.0 + (33.73 - 5.0)) - sensor_length/2.0;
+ final double ball_pos_halfmod_axial_local_y = -1.0* (this.coldblock_thickness/2.0 + this.cf_thickness + this.kapton_thickness + this.sensor_thickness/2.0);
+ final double ball_pos_halfmod_axial_local_z = 12.66 + sensor_width/2.0;
+ final double vee_pos_halfmod_axial_local_x = ball_pos_halfmod_axial_local_x + sensor_length/2.0;
+ final double vee_pos_halfmod_axial_local_y = ball_pos_halfmod_axial_local_y;
+ final double vee_pos_halfmod_axial_local_z = ball_pos_halfmod_axial_local_z;
+ final double flat_pos_halfmod_axial_local_x = ball_pos_halfmod_axial_local_x;
+ final double flat_pos_halfmod_axial_local_y = ball_pos_halfmod_axial_local_y + sensor_thickness/2.0;
+ final double flat_pos_halfmod_axial_local_z = ball_pos_halfmod_axial_local_z;
+ Hep3Vector ball_pos_halfmod_axial_local = new BasicHep3Vector(ball_pos_halfmod_axial_local_x, ball_pos_halfmod_axial_local_y, ball_pos_halfmod_axial_local_z);
+ Hep3Vector vee_pos_halfmod_axial_local = new BasicHep3Vector(vee_pos_halfmod_axial_local_x, vee_pos_halfmod_axial_local_y,vee_pos_halfmod_axial_local_z);
+ Hep3Vector flat_pos_halfmod_axial_local = new BasicHep3Vector(flat_pos_halfmod_axial_local_x, flat_pos_halfmod_axial_local_y,flat_pos_halfmod_axial_local_z);
+
+
+ if(_debug) {
+ print(String.format("ball_pos_halfmod_axial_local %s", ball_pos_halfmod_axial_local.toString()));
+ print(String.format("vee_pos_halfmod_axial_local %s", vee_pos_halfmod_axial_local.toString()));
+ print(String.format("flat_pos_halfmod_axial_local %s", flat_pos_halfmod_axial_local.toString()));
+ }
+
+ makeHalfModule("axial",moduleWrap, ball_pos_halfmod_axial_local, vee_pos_halfmod_axial_local, flat_pos_halfmod_axial_local,lcdd,sens);
+
+
+
+ // cold block
+
+
+
+ final double ball_pos_coldblock_local_x = -5.00;
+ final double ball_pos_coldblock_local_y = 0.00;
+ final double ball_pos_coldblock_local_z = 0.00;
+ final double vee_pos_coldblock_local_x = ball_pos_coldblock_local_x + 1.0; //arbitrary distance
+ final double vee_pos_coldblock_local_y = ball_pos_coldblock_local_y;
+ final double vee_pos_coldblock_local_z = ball_pos_coldblock_local_z;
+ final double flat_pos_coldblock_local_x = ball_pos_coldblock_local_x;
+ final double flat_pos_coldblock_local_y = ball_pos_coldblock_local_y + 1.0; //arbitrary distance
+ final double flat_pos_coldblock_local_z = ball_pos_coldblock_local_z;
+
+
+ Hep3Vector ball_pos_coldblock_local = new BasicHep3Vector(ball_pos_coldblock_local_x, ball_pos_coldblock_local_y, ball_pos_coldblock_local_z);
+ Hep3Vector vee_pos_coldblock_local = new BasicHep3Vector(vee_pos_coldblock_local_x, vee_pos_coldblock_local_y,vee_pos_coldblock_local_z);
+ Hep3Vector flat_pos_coldblock_local = new BasicHep3Vector(flat_pos_coldblock_local_x, flat_pos_coldblock_local_y,flat_pos_coldblock_local_z);
+
+
+ if(_debug) {
+ print(String.format("ball_pos_coldblock_local %s", ball_pos_coldblock_local.toString()));
+ print(String.format("vee_pos_coldblock_local %s", vee_pos_coldblock_local.toString()));
+ print(String.format("flat_pos_coldblock_local %s", flat_pos_coldblock_local.toString()));
+ }
+
+ makeColdBlock(moduleWrap, ball_pos_coldblock_local, vee_pos_coldblock_local, flat_pos_coldblock_local,lcdd,sens);
+
+
+
+ final double ball_pos_halfmod_stereo_local_x = ball_pos_halfmod_axial_local_x;
+ final double ball_pos_halfmod_stereo_local_y = -1.0 * ball_pos_halfmod_axial_local_y; // note minus sign
+ final double ball_pos_halfmod_stereo_local_z = ball_pos_halfmod_axial_local_z;
+ final double vee_pos_halfmod_stereo_local_x = ball_pos_halfmod_stereo_local_x + sensor_length/2.0;
+ final double vee_pos_halfmod_stereo_local_y = ball_pos_halfmod_stereo_local_y;
+ final double vee_pos_halfmod_stereo_local_z = ball_pos_halfmod_stereo_local_z;
+ final double flat_pos_halfmod_stereo_local_x = ball_pos_halfmod_stereo_local_x;
+ final double flat_pos_halfmod_stereo_local_y = ball_pos_halfmod_stereo_local_y + sensor_thickness/2.0;
+ final double flat_pos_halfmod_stereo_local_z = ball_pos_halfmod_stereo_local_z;
+ Hep3Vector ball_pos_halfmod_stereo_local = new BasicHep3Vector(ball_pos_halfmod_stereo_local_x, ball_pos_halfmod_stereo_local_y, ball_pos_halfmod_stereo_local_z);
+ Hep3Vector vee_pos_halfmod_stereo_local = new BasicHep3Vector(vee_pos_halfmod_stereo_local_x, vee_pos_halfmod_stereo_local_y,vee_pos_halfmod_stereo_local_z);
+ Hep3Vector flat_pos_halfmod_stereo_local = new BasicHep3Vector(flat_pos_halfmod_stereo_local_x, flat_pos_halfmod_stereo_local_y,flat_pos_halfmod_stereo_local_z);
+
+
+ if(_debug) {
+ print(String.format("ball_pos_halfmod_stereo_local %s", ball_pos_halfmod_stereo_local.toString()));
+ print(String.format("vee_pos_halfmod_stereo_local %s", vee_pos_halfmod_stereo_local.toString()));
+ print(String.format("flat_pos_halfmod_stereo_local %s", flat_pos_halfmod_stereo_local.toString()));
+ }
+
+ makeHalfModule("stereo",moduleWrap, ball_pos_halfmod_stereo_local, vee_pos_halfmod_stereo_local, flat_pos_halfmod_stereo_local,lcdd,sens);
+
+
+ moduleVolume.setVisAttributes(lcdd.getVisAttributes("ModuleVis"));
+
+ lcdd.add(moduleVolume);
+
+
+ }
+
+
+ private void makeHalfModule(String side, VolWrapper moduleWrap, Hep3Vector ball_pos_halfmod, Hep3Vector vee_pos_halfmod, Hep3Vector flat_pos_halfmod, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
+
+ if(_debug) {
+ print("--- makeHalfModule " + side);
+ }
+
+ CoordSysDef half_module_coord = new CoordSysDef(ball_pos_halfmod, vee_pos_halfmod, flat_pos_halfmod);
+ Transform3D transToModuleCoord = getTransformation(half_module_coord);
+ Transform3D transModuleToSupportCoord = getTransformation(moduleWrap.coord);
+
+ if(_debug) {
+ print(String.format("half_module_coord:\n%s", half_module_coord.toString()));
+ print(String.format("transToModuleCoord:\n%s", transToModuleCoord.toString()));
+ print(String.format("transModuleToSupportCoord:\n%s", transModuleToSupportCoord.toString()));
+ }
+
+
+ // the half-module box is built based on the location of the center of the sensor box
+ String halfModuleName = moduleWrap.name + "_halfmodule_" + side;
+ //find the bounding box for the half module
+ final double x_local = this.half_module_length;
+ final double y_local = this.half_module_thickness;
+ final double z_local = this.half_module_width;
+ Hep3Vector box_dim_local = new BasicHep3Vector( x_local, y_local, z_local);
+ // rotate to module coordinate system
+ Hep3Vector box_dim_module = transToModuleCoord.rotated(box_dim_local);
+ // apply the same rotation as to mother
+ Hep3Vector box_dim = transModuleToSupportCoord.rotated(box_dim_module);
+
+ if(_debug) {
+ print(String.format("box_dim_local:\n%s", box_dim_local.toString()));
+ print(String.format("box_dim_module:\n%s", box_dim_module.toString()));
+ print(String.format("box_dim:\n%s", box_dim.toString()));
+ }
+
+ Box box = new Box(halfModuleName + "Box", box_dim.x(), box_dim.y(), box_dim.z());
+ lcdd.add(box);
+ Volume halfModuleVolume = new Volume(halfModuleName + "_volume", box, lcdd.getMaterial("Vacuum"));
+
+
+ // vector to the center of the half module box from the half module ball position
+ double box_center_local_x = this.half_module_length/2.0 - ( (170.00 + 10.00) - this.sensor_length/2.0);
+ double box_center_local_y = (this.half_module_thickness/2.0 - (cf_thickness + kapton_thickness + sensor_thickness/2.0));
+ double box_center_local_z = this.half_module_width/2.0 - ( 12.66 - (8.83 -3.00) + this.sensor_width/2.0 );
+ Hep3Vector box_center_local = new BasicHep3Vector( box_center_local_x, box_center_local_y, box_center_local_z);
+ //Hep3Vector box_center_local = new BasicHep3Vector( 0.,0.,0.);
+
+
+ VolWrapper halfModuleWrap = new VolWrapper();
+ halfModuleWrap.name = halfModuleName;
+ halfModuleWrap.vol = halfModuleVolume;
+ halfModuleWrap.coord = half_module_coord;
+ halfModuleWrap.center = box_center_local;
+
+
+ Hep3Vector box_center_module_coord = transToModuleCoord.transformed(box_center_local);
+ Hep3Vector lcdd_rot_angles;
+ if(side.equals("stereo")) {
+ if(halfModuleName.contains("L1") || halfModuleName.contains("L2") ||halfModuleName.contains("L3")) {
+ lcdd_rot_angles = new BasicHep3Vector(0.0,0.1,0.0);
+ } else {
+ lcdd_rot_angles = new BasicHep3Vector(0.0,0.05,0.0);
+ }
+ }
+ else {
+ lcdd_rot_angles = new BasicHep3Vector(Math.PI,0,0);
+ }
+
+ // find the displacement from the rotation around an arbitrary point in local coordinates
+ Hep3Vector box_center_module_coord_rot = getRotationDisplacement(ball_pos_halfmod, box_center_module_coord, lcdd_rot_angles);
+
+ // find the position of the center in the module box
+ Hep3Vector box_center_sub = VecOp.sub(box_center_module_coord_rot, moduleWrap.center);
+ Hep3Vector box_center = transModuleToSupportCoord.rotated(box_center_sub);
+
+ // fix the rotation
+ Hep3Vector lcdd_rot_angles_support = transModuleToSupportCoord.rotated(lcdd_rot_angles);
+
+
+ // create the lcdd tags
+ Position pos = new Position(halfModuleName + "_position",box_center.x(), box_center.y(), box_center.z());
+ Rotation rot = new Rotation(halfModuleName + "_rotation",lcdd_rot_angles_support.x(), lcdd_rot_angles_support.y(), lcdd_rot_angles_support.z());
+ lcdd.add(pos);
+ lcdd.add(rot);
+
+ PhysVol physVolume = new PhysVol(halfModuleVolume, moduleWrap.vol, pos, rot);
+ halfModuleWrap.pv = physVolume;
+ halfModuleWrap.pos_vol = pos;
+ halfModuleWrap.rot_vol = rot;
+ halfModuleWrap.mother = moduleWrap;
+ moduleWrap.daughters.add(halfModuleWrap);
+
+ if(_debug) {
+ print(String.format("box_center_local %s", box_center_local.toString()));
+ print(String.format("box_center_module_coord %s", box_center_module_coord.toString()));
+ print(String.format("box_center_module_coord_rot %s", box_center_module_coord_rot.toString()));
+ print(String.format("moduleWrap.center %s", moduleWrap.center.toString()));
+ print(String.format("box_center_sub %s", box_center_sub.toString()));
+ print(String.format("box_center %s", box_center.toString()));
+ print(String.format("lcdd_rot_angles %s", lcdd_rot_angles.toString()));
+ print(String.format("lcdd_rot_angles_support %s", lcdd_rot_angles_support.toString()));
+
+
+ }
+
+ // create the half module components
+
+ Hep3Vector ball_pos_sensor_local = new BasicHep3Vector(0,0,0);
+ Hep3Vector vee_pos_sensor_local = new BasicHep3Vector(ball_pos_sensor_local.x() + sensor_length/2.0, ball_pos_sensor_local.y(), ball_pos_sensor_local.z());
+ Hep3Vector flat_pos_sensor_local = new BasicHep3Vector(ball_pos_sensor_local.x(),ball_pos_sensor_local.y() + sensor_thickness/2.0, ball_pos_sensor_local.z());
+
+ makeHalfModuleComponentSensor(halfModuleWrap,ball_pos_sensor_local,vee_pos_sensor_local,flat_pos_sensor_local, lcdd, sens);
+
+
+ final double ball_pos_kapton_local_x = -1 * (180.0 - this.sensor_length/2.0) + 8.5;
+ final double ball_pos_kapton_local_y = -1 * (this.sensor_thickness/2.0 + this.kapton_thickness/2.0);
+ final double ball_pos_kapton_local_z = -1 * (this.sensor_width/2.0 + 12.66) + 8.83 - 3.00 + 6.00 ;
+ final double vee_pos_kapton_local_x = ball_pos_kapton_local_x + 1.0; // arbitrary distance
+ final double vee_pos_kapton_local_y = ball_pos_kapton_local_y;
+ final double vee_pos_kapton_local_z = ball_pos_kapton_local_z;
+ final double flat_pos_kapton_local_x = ball_pos_kapton_local_x;
+ final double flat_pos_kapton_local_y = ball_pos_kapton_local_y + this.kapton_thickness/2.0; // arbitrary distance
+ final double flat_pos_kapton_local_z = ball_pos_kapton_local_z;
+
+ Hep3Vector ball_pos_kapton_local = new BasicHep3Vector(ball_pos_kapton_local_x,ball_pos_kapton_local_y,ball_pos_kapton_local_z);
+ Hep3Vector vee_pos_kapton_local = new BasicHep3Vector(vee_pos_kapton_local_x,vee_pos_kapton_local_y,vee_pos_kapton_local_z);
+ Hep3Vector flat_pos_kapton_local = new BasicHep3Vector(flat_pos_kapton_local_x,flat_pos_kapton_local_y,flat_pos_kapton_local_z);
+
+ makeHalfModuleComponentKapton(halfModuleWrap,ball_pos_kapton_local,vee_pos_kapton_local,flat_pos_kapton_local, lcdd, sens);
+
+
+
+ final double ball_pos_cf_local_x = -1 * (180.0 - this.sensor_length/2.0);
+ final double ball_pos_cf_local_y = -1 * (this.sensor_thickness/2.0 + this.kapton_thickness + this.cf_thickness/2.0);
+ final double ball_pos_cf_local_z = -1 * (this.sensor_width/2.0 + 12.66) + 8.83 - 3.00;
+ final double vee_pos_cf_local_x = ball_pos_cf_local_x + 1.0; // arbitrary distance
+ final double vee_pos_cf_local_y = ball_pos_cf_local_y;
+ final double vee_pos_cf_local_z = ball_pos_cf_local_z;
+ final double flat_pos_cf_local_x = ball_pos_cf_local_x;
+ final double flat_pos_cf_local_y = ball_pos_cf_local_y + this.cf_thickness/2.0; // arbitrary distance
+ final double flat_pos_cf_local_z = ball_pos_cf_local_z;
+
+ Hep3Vector ball_pos_cf_local = new BasicHep3Vector(ball_pos_cf_local_x,ball_pos_cf_local_y,ball_pos_cf_local_z);
+ Hep3Vector vee_pos_cf_local = new BasicHep3Vector(vee_pos_cf_local_x,vee_pos_cf_local_y,vee_pos_cf_local_z);
+ Hep3Vector flat_pos_cf_local = new BasicHep3Vector(flat_pos_cf_local_x,flat_pos_cf_local_y,flat_pos_cf_local_z);
+
+ makeHalfModuleComponentCF(halfModuleWrap,ball_pos_cf_local,vee_pos_cf_local,flat_pos_cf_local, lcdd, sens);
+
+
+
+
+ final double ball_pos_hybrid_local_x = -1 * (170.0 - this.sensor_length/2.0);
+ final double ball_pos_hybrid_local_y = -1 * (this.sensor_thickness/2.0 - this.hybrid_thickness/2.0);
+ final double ball_pos_hybrid_local_z = -1 * (this.sensor_width/2.0);
+ final double vee_pos_hybrid_local_x = ball_pos_hybrid_local_x + 1.0; // arbitrary distance
+ final double vee_pos_hybrid_local_y = ball_pos_hybrid_local_y;
+ final double vee_pos_hybrid_local_z = ball_pos_hybrid_local_z;
+ final double flat_pos_hybrid_local_x = ball_pos_hybrid_local_x;
+ final double flat_pos_hybrid_local_y = ball_pos_hybrid_local_y + this.hybrid_thickness/2.0; // arbitrary distance
+ final double flat_pos_hybrid_local_z = ball_pos_hybrid_local_z;
+
+ Hep3Vector ball_pos_hybrid_local = new BasicHep3Vector(ball_pos_hybrid_local_x,ball_pos_hybrid_local_y,ball_pos_hybrid_local_z);
+ Hep3Vector vee_pos_hybrid_local = new BasicHep3Vector(vee_pos_hybrid_local_x,vee_pos_hybrid_local_y,vee_pos_hybrid_local_z);
+ Hep3Vector flat_pos_hybrid_local = new BasicHep3Vector(flat_pos_hybrid_local_x,flat_pos_hybrid_local_y,flat_pos_hybrid_local_z);
+
+ makeHalfModuleComponentHybrid(halfModuleWrap,ball_pos_hybrid_local,vee_pos_hybrid_local,flat_pos_hybrid_local, lcdd, sens);
+
+
+
+
+ //set vis stuff
+ halfModuleVolume.setVisAttributes(lcdd.getVisAttributes("HalfModuleVis"));
+
+ lcdd.add(halfModuleVolume);
+
+
+ }
+
+
+
+ private void makeColdBlock(VolWrapper moduleWrap, Hep3Vector ball_pos_coldblock, Hep3Vector vee_pos_coldblock, Hep3Vector flat_pos_coldblock, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
+
+ if(_debug) {
+ print("--- makeColdBlock ");
+ }
+
+ CoordSysDef coldblock_coord = new CoordSysDef(ball_pos_coldblock, vee_pos_coldblock, flat_pos_coldblock);
+ Transform3D transToModuleCoord = getTransformation(coldblock_coord);
+ Transform3D transModuleToSupportCoord = getTransformation(moduleWrap.coord);
+
+ if(_debug) {
+ print(String.format("coldblock_coord:\n%s", coldblock_coord.toString()));
+ print(String.format("transToModuleCoord:\n%s", transToModuleCoord.toString()));
+ print(String.format("transModuleToSupportCoord:\n%s", transModuleToSupportCoord.toString()));
+ }
+
+
+ String coldBlockName = moduleWrap.name + "_coldBlock";
+ //find the bounding box
+ final double x_local = this.coldblock_length;
+ final double y_local = this.coldblock_thickness;
+ final double z_local = this.coldblock_width;
+ Hep3Vector box_dim_local = new BasicHep3Vector( x_local, y_local, z_local);
+ // rotate to module coordinate system
+ Hep3Vector box_dim_module = transToModuleCoord.rotated(box_dim_local);
+ // apply the same rotation as to mother
+ Hep3Vector box_dim = transModuleToSupportCoord.rotated(box_dim_module);
+
+ if(_debug) {
+ print(String.format("box_dim_local:\n%s", box_dim_local.toString()));
+ print(String.format("box_dim_module:\n%s", box_dim_module.toString()));
+ print(String.format("box_dim:\n%s", box_dim.toString()));
+ }
+
+ Box box = new Box(coldBlockName + "Box", box_dim.x(), box_dim.y(), box_dim.z());
+ lcdd.add(box);
+ Volume coldBlockVolume = new Volume(coldBlockName + "_volume", box, lcdd.getMaterial("Vacuum"));
+
+
+ // vector to the center of the half module box from the half module ball position
+ double box_center_local_x = this.coldblock_length/2.0;
+ double box_center_local_y = 0.0;
+ double box_center_local_z = this.coldblock_width/2.0;
+ Hep3Vector box_center_local = new BasicHep3Vector( box_center_local_x, box_center_local_y, box_center_local_z);
+ //Hep3Vector box_center_local = new BasicHep3Vector( 0.,0.,0.);
+
+
+ VolWrapper coldBlockWrap = new VolWrapper();
+ coldBlockWrap.name = coldBlockName;
+ coldBlockWrap.vol = coldBlockVolume;
+ coldBlockWrap.coord = coldblock_coord;
+ coldBlockWrap.center = box_center_local;
+
+
+ Hep3Vector box_center_module_coord = transToModuleCoord.transformed(box_center_local);
+ Hep3Vector lcdd_rot_angles = new BasicHep3Vector(0,0,0);
+
+ // find the displacement from the rotation around an arbitrary point in local coordinates
+ Hep3Vector box_center_module_coord_rot = getRotationDisplacement(ball_pos_coldblock, box_center_module_coord, lcdd_rot_angles);
+
+ // find the position of the center in the module box
+ Hep3Vector box_center_sub = VecOp.sub(box_center_module_coord_rot, moduleWrap.center);
+ Hep3Vector box_center = transModuleToSupportCoord.rotated(box_center_sub);
+ //Hep3Vector box_center = VecOp.sub(box_center_module_coord, moduleWrap.center);
+
+ // create the lcdd tags
+ Position pos = new Position(coldBlockName + "_position",box_center.x(), box_center.y(), box_center.z());
+ Rotation rot = new Rotation(coldBlockName + "_rotation",lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z());
+ lcdd.add(pos);
+ lcdd.add(rot);
+
+ PhysVol physVolume = new PhysVol(coldBlockVolume, moduleWrap.vol, pos, rot);
+ coldBlockWrap.pv = physVolume;
+ coldBlockWrap.pos_vol = pos;
+ coldBlockWrap.rot_vol = rot;
+ coldBlockWrap.mother = moduleWrap;
+ moduleWrap.daughters.add(coldBlockWrap);
+
+ if(_debug) {
+ print(String.format("box_center_local %s", box_center_local.toString()));
+ print(String.format("box_center_module_coord %s", box_center_module_coord.toString()));
+ print(String.format("box_center_module_coord_rot %s", box_center_module_coord_rot.toString()));
+ print(String.format("moduleWrap.center %s", moduleWrap.center.toString()));
+ print(String.format("hbox_center %s", box_center.toString()));
+ }
+
+
+ //set vis stuff
+ coldBlockVolume.setVisAttributes(lcdd.getVisAttributes("ColdBlockVis"));
+
+ lcdd.add(coldBlockVolume);
+
+
+ }
+
+
+
+
+
+ /**
+ * Find the displacement of a point when rotating around an arbitrary position
+ * @param origin_of_rotation
+ * @param point
+ * @param lcdd_rot_angles
+ * @return
+ */
+ private Hep3Vector getRotationDisplacement(Hep3Vector origin_of_rotation,
+ Hep3Vector point, Hep3Vector lcdd_rot_angles) {
+
+ // Find the vector from the center of rotation to the point
+ Hep3Vector s = VecOp.sub(point, origin_of_rotation );
+ //Apply the rotation to the vector
+ RotationGeant r = new RotationGeant(lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z());
+ Hep3Vector s_prime = r.rotated(s);
+ // Find the displaced point
+ Hep3Vector point_rot = VecOp.add(origin_of_rotation, s_prime );
+ if(_debug) {
+ print("--- getRotationDisplacement---");
+ print(String.format("point: %s", point.toString()));
+ print(String.format("origin_of_rotation: %s", origin_of_rotation.toString()));
+ print(String.format("s:\n%s", s.toString()));
+ print(String.format("r:\n%s", r.toString()));
+ print(String.format("s_prime:\n%s", s_prime.toString()));
+ print(String.format("box_center_module_coord_rot:\n%s", point_rot.toString()));
+ }
+ return point_rot;
+ }
+
+
+ private void makeHalfModuleComponentSensor(VolWrapper halfModuleWrap, Hep3Vector ball_pos_sensor_local, Hep3Vector vee_pos_sensor_local, Hep3Vector flat_pos_sensor_local, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
+
+ if(_debug) {
+ print("--- makeHalfModuleComponents ---");
+ }
+
+
+ if(_debug) {
+ print(" Add sensor...");
+ }
+
+ CoordSysDef sensor_coord = new CoordSysDef(ball_pos_sensor_local, vee_pos_sensor_local, flat_pos_sensor_local);
+ Transform3D transToHalfModuleCoord = getTransformation(sensor_coord);
+ Transform3D transToModuleCoord = getTransformation(halfModuleWrap.coord);
+ Transform3D transToSupportCoord = getTransformation(halfModuleWrap.mother.coord);
+
+ if(_debug) {
+ print(String.format("sensor_coord:\n%s", sensor_coord.toString()));
+ print(String.format("transToHalfModuleCoord:\n%s", transToHalfModuleCoord.toString()));
+ print(String.format("transToModuleCoord:\n%s", transToModuleCoord.toString()));
+ print(String.format("transToSupportCoord:\n%s", transToSupportCoord.toString()));
+ }
+
+
+
+
+ // add sensor
+
+ int sensor_number = 0;
+ String sensorName = halfModuleWrap.name + "_sensor" + sensor_number;
+ // Create the box solid for the component.
+ double x_local = this.sensor_length;
+ double y_local = this.sensor_thickness;
+ double z_local = this.sensor_width;
+ Hep3Vector box_dim_local = new BasicHep3Vector(x_local,y_local,z_local);
+ Hep3Vector box_dim_half_module = transToHalfModuleCoord.rotated(box_dim_local);
+ Hep3Vector box_dim_module = transToModuleCoord.rotated(box_dim_half_module);
+ Hep3Vector box_dim = transToSupportCoord.rotated(box_dim_module);
+
+ if(_debug) {
+ print(String.format("box_dim_local %s", box_dim_local.toString()));
+ print(String.format("box_dim_half_module %s", box_dim_half_module.toString()));
+ print(String.format("box_dim_module %s", box_dim_module.toString()));
+ print(String.format("box_dim %s", box_dim.toString()));
+ }
+
+
+ Box sensor_box = new Box(sensorName + "_box",box_dim.x(),box_dim.y(),box_dim.z());
+ lcdd.add(sensor_box);
+
+ // Create the volume for the module component.
+ Volume sensor_volume = new Volume(sensorName + "_volume", sensor_box,lcdd.getMaterial("Silicon"));
+
+ if(_debug) {
+ print(String.format("ball_pos_sensor_local %s", ball_pos_sensor_local.toString()));
+ print(String.format("vee_pos_sensor_local %s", vee_pos_sensor_local.toString()));
+ print(String.format("flat_pos_sensor_local %s", flat_pos_sensor_local.toString()));
+ }
+
+ Hep3Vector sensor_box_center_local = new BasicHep3Vector(0.,0.,0.);
+ Hep3Vector sensor_box_center_half_module_coord = transToHalfModuleCoord.transformed(sensor_box_center_local);
+ Hep3Vector sensor_box_center_half_module = VecOp.sub(sensor_box_center_half_module_coord, halfModuleWrap.center);
+ // transform according to mother volumes
+ Hep3Vector sensor_box_center_module = transToModuleCoord.rotated(sensor_box_center_half_module);
+ Hep3Vector sensor_box_center = transToSupportCoord.rotated(sensor_box_center_module);
+
+
+
+ if(_debug) {
+ print(String.format("sensor_box_center_local %s", sensor_box_center_local.toString()));
+ print(String.format("sensor_box_center_half_module_coord %s", sensor_box_center_half_module_coord.toString()));
+ print(String.format("half module box center in half module coord %s", halfModuleWrap.center.toString()));
+ print(String.format("sensor_box_center_half_module %s", sensor_box_center_half_module.toString()));
+ print(String.format("sensor_box_center_module %s", sensor_box_center_module.toString()));
+ print(String.format("sensor_box_center %s", sensor_box_center.toString()));
+ }
+
+
+ Position pos = new Position(sensorName + "_position",sensor_box_center.x(), sensor_box_center.y(), sensor_box_center.z());
+ //Position pos = new Position(volName + "_position",0,20.0,0);
+ Hep3Vector lcdd_rot_angles = new BasicHep3Vector(0,0,0); //getLCDDRotation(survey_coord);
+ Rotation rot = new Rotation(sensorName + "_rotation",lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z());
+ lcdd.add(pos);
+ lcdd.add(rot);
+
+
+
+ PhysVol sensor_physvol = new PhysVol(sensor_volume, halfModuleWrap.vol, pos, rot);
+ sensor_volume.setSensitiveDetector(sens);
+ sensor_physvol.addPhysVolID("sensor", sensor_number);
+ sensor_physvol.addPhysVolID("system", 0);
+ sensor_physvol.addPhysVolID("barrel", 0);
+ sensor_physvol.addPhysVolID("layer", 0);
+ sensor_physvol.addPhysVolID("module", 0);
+
+
+
+
+
+ VolWrapper sensorWrap = new VolWrapper();
+ sensorWrap.name = sensorName;
+ sensorWrap.pv = sensor_physvol;
+ sensorWrap.vol = sensor_volume;
+ sensorWrap.pos_vol = pos;
+ sensorWrap.rot_vol = rot;
+ sensorWrap.mother = halfModuleWrap;
+ sensorWrap.center = sensor_box_center_local;
+ sensorWrap.coord = sensor_coord;
+ halfModuleWrap.daughters.add(sensorWrap);
+
+
+ sensor_volume.setVisAttributes(lcdd.getVisAttributes("SensorVis"));
+
+
+ lcdd.add(sensor_volume);
+
+
+
+
+
+ }
+
+
+
+
+
[truncated at 1000 lines; 499 more skipped]