4 added + 1 removed + 4 modified, total 9 files
projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014Converter.java (rev 0)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014Converter.java 2014-08-19 00:32:47 UTC (rev 3270)
@@ -0,0 +1,275 @@
+/**
+ *
+ */
+package org.lcsim.detector.converter.compact;
+
+import org.jdom.Element;
+import org.lcsim.detector.DetectorElement;
+import org.lcsim.detector.DetectorIdentifierHelper;
+import org.lcsim.detector.IDetectorElement;
+import org.lcsim.detector.ILogicalVolume;
+import org.lcsim.detector.IPhysicalVolume;
+import org.lcsim.detector.DetectorIdentifierHelper.SystemMap;
+import org.lcsim.detector.LogicalVolume;
+import org.lcsim.detector.converter.compact.HPSTestRunTracker2014JavaBuilder.GhostJavaBaseGeom;
+import org.lcsim.detector.converter.compact.HPSTestRunTracker2014JavaBuilder.JavaBaseGeom;
+import org.lcsim.detector.identifier.ExpandedIdentifier;
+import org.lcsim.detector.identifier.IExpandedIdentifier;
+import org.lcsim.detector.identifier.IIdentifier;
+import org.lcsim.detector.identifier.IIdentifierDictionary;
+import org.lcsim.detector.identifier.IIdentifierHelper;
+import org.lcsim.detector.material.IMaterial;
+import org.lcsim.detector.material.MaterialStore;
+import org.lcsim.detector.solids.Box;
+import org.lcsim.detector.tracker.silicon.HpsSiSensor;
+import org.lcsim.detector.tracker.silicon.SiTrackerIdentifierHelper;
+import org.lcsim.detector.tracker.silicon.SiTrackerModule;
+import org.lcsim.geometry.compact.Detector;
+import org.lcsim.geometry.compact.Subdetector;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014Builder;
+import org.lcsim.geometry.compact.converter.lcdd.util.LCDD;
+
+/**
+ * Converters the HPSTestRunTracker2014 compact description into Java runtime objects
+ * @author Per Hansson Adrian <[log in to unmask]>
+ *
+ */
+public class HPSTestRunTracker2014Converter extends AbstractSubdetectorConverter {
+
+ private boolean _debug = true;
+ private IMaterial trackingMaterial;
+ private static HPSTestRunTracker2014JavaBuilder builder;
+
+ public IIdentifierHelper makeIdentifierHelper(Subdetector subdetector, SystemMap systemMap) {
+ return new SiTrackerIdentifierHelper(subdetector.getDetectorElement(), makeIdentifierDictionary(subdetector), systemMap);
+ }
+
+
+ public Class getSubdetectorType() {
+ return HPSTestRunTracker2014.class;
+ }
+
+ public HPSTestRunTracker2014Converter() {
+ super();
+ trackingMaterial = MaterialStore.getInstance().get("Vacuum");
+ builder = new HPSTestRunTracker2014JavaBuilder(_debug);
+ }
+
+ public void convert(Subdetector subdet, Detector detector) {
+
+ if(_debug) System.out.printf("%s: convert %s \n", getClass().getSimpleName(), subdet.getName());
+
+
+ // check tracking material
+ if(trackingMaterial==null) {
+ System.out.printf("%s: error the tracking material was not found!\n", this.getClass().getSimpleName());
+ System.exit(1);
+ }
+
+ // Get the tracking volume for module placement.
+ ILogicalVolume trackingVolume = detector.getTrackingVolume().getLogicalVolume();
+
+ // Set subdetector
+ builder.setSubdetector(subdet);
+
+ // Get ID helper and dictionary for subdetector.
+ builder.setDetectorIdentifierHelper( (DetectorIdentifierHelper) subdet.getDetectorElement().getIdentifierHelper());
+ builder.setIdentifierDictionary(subdet.getDetectorElement().getIdentifierHelper().getIdentifierDictionary());
+
+
+ // Get XML node for this subdetector.
+ Element node = subdet.getNode();
+
+ // Build the detector here
+ // setup and build the LCDD geometry
+ if(_debug) System.out.printf("%s: setup and build the JAVA geometry\n", getClass().getSimpleName());
+
+ builder.build(trackingVolume);
+
+ if(_debug) System.out.printf("%s: DONE setup and build the JAVA geometry\n", getClass().getSimpleName());
+
+ setupDetectorElements();
+
+
+ }
+
+
+
+ /**
+ * Setup relations between detector elements.
+ */
+ private void setupDetectorElements() {
+
+ if(_debug) System.out.printf("%s: setup the detector elements\n", getClass().getSimpleName());
+
+ setupDetectorElement(builder.baseTrackerGeometry);
+
+
+ if(_debug) System.out.printf("%s: DONE setup the detector elements\n", getClass().getSimpleName());
+
+
+ }
+
+ /**
+ * Setup the detector element for a geometry object.
+ * @param geometryObject - volume to process.
+ */
+ private void setupDetectorElement(JavaBaseGeom geometryObject) {
+
+ if(_debug) System.out.printf("%s: setupDetectorElement for %s\n", getClass().getSimpleName(),geometryObject.getName());
+
+ // Only certain objects are setup as detector elements
+ // Ghost volumes are never setup
+
+ // I do this recursively for daughters now as I wanted it to be generic
+ // but for now since I know what the daughters are I could manually
+ // go and add:layer->module->sensor detector elements similar to
+ // the old setup. I wanted this to be more generic in case more structures
+ // are added so I keep track of all the elements in the builder in order
+ // to build a hierarchy.
+
+ if(geometryObject.getClass().isInstance(GhostJavaBaseGeom.class)) {
+
+ if(_debug) System.out.printf("%s: %s is a ghost volume, dont create elements or physvol\n", getClass().getSimpleName(),geometryObject.getName());
+
+ } else {
+
+ // build the physical volume
+ geometryObject.buildPhysVolume();
+
+ // create detector element
+ if(HPSTestRunTracker2014Builder.isHalfModule(geometryObject.getName())) {
+
+ if(_debug) System.out.printf("%s: create the layer detector element\n", getClass().getSimpleName());
+
+ // The old geometry was built using a layer definition from a barrel tracker
+ // It also only has the concept of half-modules which it calls modules
+ // Thus the nomenclature here is a little strange
+ // Anyway, find those ID's
+
+ int nfields = builder.getDetectorIdentifierHelper().getIdentifierDictionary().getNumberOfFields();
+ IExpandedIdentifier layerPosId = new ExpandedIdentifier(nfields);
+
+ layerPosId.setValue(builder.getDetectorIdentifierHelper().getFieldIndex("system"), builder.getSubdetector().getSystemID());
+ layerPosId.setValue(builder.getDetectorIdentifierHelper().getFieldIndex("barrel"), builder.getDetectorIdentifierHelper().getBarrelValue());
+ int layer = HPSTestRunTracker2014Builder.getLayerFromVolumeName(geometryObject.getName());
+ layerPosId.setValue(builder.getDetectorIdentifierHelper().getFieldIndex("layer"), layer);
+
+ // create the layer detector element and keep track of it
+ IDetectorElement layerDe = builder.getLayerDetectorElement(layerPosId);
+ if(layerDe==null) {
+ layerDe = new DetectorElement(builder.getSubdetector().getName() + "_layer" + layer, builder.getSubdetector().getDetectorElement(), builder.getDetectorIdentifierHelper().pack(layerPosId));
+ builder.addLayerDetectorElement(layerDe);
+ } else {
+ System.out.printf("%s: layerDE exists\n", getClass().getSimpleName());
+ }
+
+
+ if(_debug) System.out.printf("%s: create the module detector element\n", getClass().getSimpleName());
+
+ // create the "module" detector element
+ ILogicalVolume trackingVolume = builder.baseTrackerGeometry.getMother().getVolume();
+ String moduleName = "TestRunModule";
+ //TODO I'm not sure I need to follow the old style here?
+ moduleName = geometryObject.getName();
+ String half = HPSTestRunTracker2014Builder.getHalfFromName(geometryObject.getName());
+ if(half.equals("")) throw new RuntimeException("No half found for " + geometryObject.getName());
+ int moduleNumber = half.equals("top") ? 0 : 1;
+ String modulePlacementName = builder.getSubdetector().getName() + "_" + moduleName + "_layer" + layer + "_module" + moduleNumber;
+ String modulePath = "/" + trackingVolume.getName() + "/" + modulePlacementName;
+ SiTrackerModule moduleDe = new SiTrackerModule(modulePlacementName, layerDe, modulePath, moduleNumber);
+
+ //keep track of the module detector element
+ builder.addModuleDetectorElement(moduleDe);
+
+
+ } else if(HPSTestRunTracker2014Builder.isActiveSensor(geometryObject.getName())) {
+
+ //TODO should this be the active sensor volume????
+
+ if(_debug) System.out.printf("%s: create the sensor detector element\n", getClass().getSimpleName());
+
+ // Sensor physical volume.
+ IPhysicalVolume sensorPhysVol = geometryObject.getPhysVolume();
+
+ // Helpers
+ IIdentifierDictionary iddict = builder.getDetectorIdentifierHelper().getIdentifierDictionary();
+
+ // Find the mother: the module detector element
+ IExpandedIdentifier layerExpId = new ExpandedIdentifier(iddict.getNumberOfFields());
+ layerExpId.setValue(iddict.getFieldIndex("system"), builder.getSubdetector().getSystemID());
+ layerExpId.setValue(iddict.getFieldIndex("barrel"), 0);
+ int layer = HPSTestRunTracker2014Builder.getLayerFromVolumeName(geometryObject.getName());
+ layerExpId.setValue(iddict.getFieldIndex("layer"), layer);
+
+ // TODO Jeremy, why is the module ID not part of the expanded ID for the module DE but stored as a separate member?
+
+ //String half = HPSTestRunTracker2014Builder.getHalfFromName(geometryObject.getName());
+ //if(half.equals("")) throw new RuntimeException("No half found for " + geometryObject.getName());
+ //int moduleNumber = half.equals("top") ? 0 : 1;
+
+ IDetectorElement moduleDe = builder.getModuleDetectorElement(layerExpId);
+
+ if(moduleDe==null) throw new RuntimeException("Cannot find module DE for " + geometryObject.getName());
+
+ // Find the layer element
+ IDetectorElement layerDe = moduleDe.getParent();
+
+ // Setup SiSensor's identifier.
+ IExpandedIdentifier expId = new ExpandedIdentifier(iddict.getNumberOfFields());
+ expId.setValue(iddict.getFieldIndex("system"), builder.getSubdetector().getSystemID());
+ expId.setValue(iddict.getFieldIndex("barrel"), 0);
+ expId.setValue(iddict.getFieldIndex("layer"), builder.getDetectorIdentifierHelper().getValue(layerDe.getIdentifier(), "layer"));
+ expId.setValue(iddict.getFieldIndex("module"), ((SiTrackerModule) moduleDe).getModuleId());
+
+ // TODO: what does this number mean? It's basically just a counter in the old compact
+ int sensorNumber = 0;
+ expId.setValue(iddict.getFieldIndex("sensor"), sensorNumber);
+
+ // Packed identifier.
+ IIdentifier sensorId = iddict.pack(expId);
+
+ // Sensor paths.
+ String modulePath = moduleDe.getGeometry().getPathString();
+ IPhysicalVolume componentPhysVol = geometryObject.getMother().getPhysVolume();
+ String sensorPath = modulePath.toString() + "/" + componentPhysVol.getName() + "/" + sensorPhysVol.getName();
+ String sensorName = moduleDe.getName() + "_sensor" + sensorNumber;
+
+ // Create the sensor.
+ HpsSiSensor sensor = new HpsSiSensor(sensorNumber, sensorName, moduleDe, sensorPath, sensorId);
+
+ if(_debug) System.out.printf("%s: created sensor %s \n", getClass().getSimpleName(), sensor.getName());
+
+ // Increment sensor numbering.
+ // TODO this is just random. Not sure what to do here!
+ // ++sensorNumber;
+
+ } else {
+ throw new RuntimeException("I dont this I should reach this?");
+ }
+
+
+ }
+
+ // add daughters
+ if(_debug) System.out.printf("%s: add %d daughters to %s\n", this.getClass().getSimpleName(),geometryObject.getDaughters().size(), geometryObject.getName());
+ for(JavaBaseGeom daughter : geometryObject.getDaughters()) {
+ setupDetectorElement(daughter);
+ }
+
+
+
+ if(_debug) System.out.printf("%s: DONE setup the detector element for %s\n", this.getClass().getSimpleName(),geometryObject.getName());
+
+
+ }
+
+
+
+
+
+
+
+
+}
projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014JavaBuilder.java (rev 0)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014JavaBuilder.java 2014-08-19 00:32:47 UTC (rev 3270)
@@ -0,0 +1,470 @@
+/**
+ *
+ */
+package org.lcsim.detector.converter.compact;
+
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.VecOp;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.lcsim.detector.DetectorElement;
+import org.lcsim.detector.DetectorIdentifierHelper;
+import org.lcsim.detector.IDetectorElement;
+import org.lcsim.detector.ILogicalVolume;
+import org.lcsim.detector.IPhysicalVolume;
+import org.lcsim.detector.LogicalVolume;
+import org.lcsim.detector.PhysicalVolume;
+import org.lcsim.detector.Rotation3D;
+import org.lcsim.detector.RotationGeant;
+import org.lcsim.detector.Transform3D;
+import org.lcsim.detector.Translation3D;
+import org.lcsim.detector.identifier.ExpandedIdentifier;
+import org.lcsim.detector.identifier.IExpandedIdentifier;
+import org.lcsim.detector.identifier.IIdentifierDictionary;
+import org.lcsim.detector.material.IMaterial;
+import org.lcsim.detector.material.MaterialStore;
+import org.lcsim.detector.solids.Box;
+import org.lcsim.geometry.compact.Subdetector;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014Builder;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014Builder.HalfModuleBundle;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014Builder.ModuleBundle;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.Base;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.BaseGeometry;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.BasePlate;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.CSupport;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.SupportBottom;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.SupportPlateTop;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.SupportTop;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.TrackingBase;
+
+
+/**
+ * Class used by java converter to build java run time objects for the detector
+ * It encapsulates and adds the LCDD specific information to the generic @HPSTestRunTracker2014Builder.
+ *
+ * @author Per Hansson Adrian <[log in to unmask]>
+ *
+ */
+public class HPSTestRunTracker2014JavaBuilder extends HPSTestRunTracker2014Builder {
+
+ protected JavaBaseGeom baseTrackerGeometry;
+ protected List<JavaBaseGeom> java_objects;
+ protected DetectorIdentifierHelper detectorIdentifierHelper;
+ protected IIdentifierDictionary identifierDictionary;
+ protected Subdetector subdet;
+ private List<IDetectorElement> layerDetectorElements;
+ private List<IDetectorElement> moduleDetectorElements;
+
+ /**
+ * Default constructor
+ */
+ public HPSTestRunTracker2014JavaBuilder(boolean debugFlag) {
+ super(debugFlag);
+ layerDetectorElements = new ArrayList<IDetectorElement>();
+ moduleDetectorElements = new ArrayList<IDetectorElement>();
+ }
+
+ /**
+ * Add to list of objects.
+ * @param geom - object to add.
+ */
+ private void add(JavaBaseGeom geom) {
+ java_objects.add(geom);
+ }
+
+
+ /**
+ * Build the JAVA geometry objects.
+ * @param worldVolume - the reference volume.
+ */
+ protected void build(ILogicalVolume worldVolume) {
+
+ if(isDebug()) System.out.printf("%s: build the JAVA geometry objects\n", getClass().getSimpleName());
+
+ // initialize the list to store a reference to each object
+ java_objects = new ArrayList<JavaBaseGeom>();
+
+ // Go through the list of volumes to build that is created in the generic builder class
+ // TODO this is manual now since I don't have a way of knowing in the generic builder class what is a ghost volume at this point.
+ JavaBaseGeom tracking = new GhostJavaBaseGeom(getItem(TrackingBase.class), worldVolume);
+ add(tracking);
+
+ baseTrackerGeometry = new GhostJavaBaseGeom(getItem(Base.class), tracking);
+ add(baseTrackerGeometry);
+ JavaBaseGeom basePlateGeometry = new GhostJavaBaseGeom(getItem(BasePlate.class), baseTrackerGeometry);
+ add(basePlateGeometry);
+ JavaBaseGeom cSupportGeometry = new GhostJavaBaseGeom(getItem(CSupport.class), baseTrackerGeometry);
+ add(cSupportGeometry);
+ JavaBaseGeom supportBottomGeometry = new GhostJavaBaseGeom(getItem(SupportBottom.class), baseTrackerGeometry);
+ add(supportBottomGeometry);
+ JavaBaseGeom supportPlateBottomGeometry = new GhostJavaBaseGeom(getItem(SupportPlateBottom.class), baseTrackerGeometry);
+ add(supportPlateBottomGeometry);
+ JavaBaseGeom supportTopGeometry = new GhostJavaBaseGeom(getItem(SupportTop.class), baseTrackerGeometry);
+ add(supportTopGeometry);
+ JavaBaseGeom supportPlateTopGeometry = new GhostJavaBaseGeom(getItem(SupportPlateTop.class), baseTrackerGeometry);
+ add(supportPlateTopGeometry);
+
+ // build modules
+
+ if(isDebug()) System.out.printf("%s: build modules\n", getClass().getSimpleName());
+
+ // Loop over all modules created
+ for(ModuleBundle m : modules) {
+
+ // Do only L1?
+ if(m.getLayer()!=1) continue;
+
+ if(isDebug()) {
+ System.out.printf("%s: module layer %d half %s\n", getClass().getSimpleName(),m.getLayer(),m.getHalf());
+ m.print();
+ }
+
+ // Find the mother among the LCDD objects using its name, should probably have a better way...
+ String name_mother = m.getMother().getName();
+ JavaBaseGeom mother = null;
+ for(JavaBaseGeom g : java_objects) {
+ if(g.getName().equals(name_mother)) {
+ mother = g;
+ break;
+ }
+ }
+ // Check that it had a mother
+ if(mother==null) throw new RuntimeException("Cound't find mother to module layer " + m.getLayer() + " half "+ m.getHalf());
+
+ if(isDebug()) System.out.printf("%s: found mother %s for module layer %d half %s\n", getClass().getSimpleName(),mother.getName(),m.getLayer(),m.getHalf());
+
+ // add the module to the list of objects that will be added to LCDD
+ addModule(m, mother);
+
+ }
+
+
+
+ if(isDebug()) System.out.printf("%s: DONE building the JAVA geometry objects\n", getClass().getSimpleName());
+
+ // Set visualization features
+ //setVis();
+
+
+ }
+
+ /**
+ * Rules for adding the JAVA module geometry.
+ * @param bundle - module to be added
+ * @param mother - mother JAVA geometry object
+ */
+ private void addModule(ModuleBundle bundle, JavaBaseGeom mother) {
+
+ // Create the module
+ JavaBaseGeom lcddM = new GhostJavaBaseGeom(bundle.module, mother);
+ add(lcddM);
+ // add half modules
+ addHalfModule(bundle.halfModuleAxial,lcddM);
+ addHalfModule(bundle.halfModuleStereo,lcddM);
+
+ }
+
+
+ /**
+ * Rules for adding the JAVA half module geometry.
+ * @param bundle - module to be added
+ * @param mother - mother JAVA geometry object
+ */
+ private void addHalfModule(HalfModuleBundle bundle, JavaBaseGeom mother) {
+ // Create the half-module
+ // This is not a ghost element but reflects the module
+ // concept in the old compact description
+ // TODO fix the layer IDs
+ int oldCompactModuleId = 0;
+ JavaBaseGeom lcddHM = new JavaBaseGeom(bundle.halfModule, mother,oldCompactModuleId);
+ add(lcddHM);
+
+ //TODO find the sensor id, this needs to be fixed.
+ int sensorNumber = mother.getComponentId();
+
+ // create the sensor
+ JavaBaseGeom lcddS = new JavaBaseGeom(bundle.sensor, lcddHM, sensorNumber);
+ add(lcddS);
+
+ // create the active sensor
+ JavaBaseGeom lcddAS = new JavaBaseGeom(bundle.activeSensor, lcddS, sensorNumber);
+ add(lcddAS);
+
+ }
+
+ protected DetectorIdentifierHelper getDetectorIdentifierHelper() {
+ return detectorIdentifierHelper;
+ }
+
+ protected void setDetectorIdentifierHelper(
+ DetectorIdentifierHelper detectorIdentifierHelper) {
+ this.detectorIdentifierHelper = detectorIdentifierHelper;
+ }
+
+ protected IIdentifierDictionary getIdentifierDictionary() {
+ return identifierDictionary;
+ }
+
+ protected void setIdentifierDictionary(
+ IIdentifierDictionary identifierDictionary) {
+ this.identifierDictionary = identifierDictionary;
+ }
+
+
+ protected void setSubdetector(Subdetector subdet) {
+ this.subdet = subdet;
+ }
+
+ protected Subdetector getSubdetector() {
+ return this.subdet;
+ }
+
+ /**
+ *
+ * Base geometry class for holding JAVA geometry object definitions
+ * where no volume is built but it can be used as reference in building the geometry.
+ *
+ * @author Per Hansson Adrian <[log in to unmask]>
+ *
+ */
+ protected static class GhostJavaBaseGeom extends JavaBaseGeom {
+
+ /**
+ * Initialize this object with a known volume and no mother. Typically the world volume would use this.
+ * @param base - object used to get geometry definitions
+ * @param vol - given volume
+ */
+ public GhostJavaBaseGeom(BaseGeometry base, ILogicalVolume volume) {
+ super();
+ if(isDebug()) System.out.printf("%s: constructing JAVA ghost object %s\n", this.getClass().getSimpleName(),base.getName());
+ setName(base.getName());
+ setVolume(volume);
+ if(isDebug()) System.out.printf("%s: DONE constructing JAVA object %s\n", this.getClass().getSimpleName(),base.getName());
+ }
+
+ /**
+ * Initialize with base and mother. This is typically for a reference geometry object
+ * that is used for referencing coordinate systems but that doesn't have a volume itself.
+ * @param base - object used to get geometry definitions
+ * @param mother - mother object
+ */
+ public GhostJavaBaseGeom(BaseGeometry base, JavaBaseGeom mother) {
+ super();
+ if(isDebug()) System.out.printf("%s: constructing JAVA ghost object %s with mother %s\n", this.getClass().getSimpleName(),base.getName(),mother==null?"null":mother.getName());
+ setName(base.getName());
+ setMother(mother);
+ if(isDebug()) System.out.printf("%s: DONE constructing JAVA object %s\n", this.getClass().getSimpleName(),base.getName());
+ }
+
+
+
+ }
+
+ /**
+ * Base geometry class for holding JAVA geometry object definitions.
+ *
+ * @author Per Hansson Adrian <[log in to unmask]>
+ */
+ protected static class JavaBaseGeom {
+ private boolean debug = true;
+ private String name;
+ private Box box= null;
+ private ILogicalVolume volume = null;
+ private Translation3D pos = null;
+ private Rotation3D rot = null;
+ private IPhysicalVolume physVolume = null;
+ private JavaBaseGeom mother = null;
+ public List<JavaBaseGeom> daughters = new ArrayList<JavaBaseGeom>();
+ private int componentId = -1;
+
+ /**
+ * Default constructor
+ */
+ public JavaBaseGeom() {
+ }
+
+ /**
+ * Construct a JAVA geometry object from its geometry definition.
+ * @param geomObject - input geometry definition
+ * @param mother - reference to mother JAVA definition
+ * @param volumeId - component id number
+ */
+ public JavaBaseGeom(BaseGeometry geomObject, JavaBaseGeom mother, int volumeId) {
+ if(isDebug()) System.out.printf("%s: constructing JAVA object %s (volumeID %d) with mother %s\n", this.getClass().getSimpleName(),volumeId,geomObject.getName(),mother==null?"null":mother.getName());
+ setName(geomObject.getName());
+ setComponentId(volumeId);
+ setMother(mother);
+ mother.addDaughter(this);
+ buildBox(geomObject);
+ buildVolume(geomObject);
+ setPosAndRot(geomObject);
+ //buildPhysVolume(mother);
+ if(isDebug()) System.out.printf("%s: DONE constructing JAVA object %s\n", this.getClass().getSimpleName(),geomObject.getName());
+ }
+
+
+ protected void buildPhysVolume() {
+ if(isDebug()) System.out.printf("%s: build phys volume for %s\n", this.getClass().getSimpleName(),getName());
+ setPhysVolume(new PhysicalVolume(new Transform3D(pos, rot), name, volume, getMother().getVolume(),getComponentId()));
+ }
+ protected void buildBox(BaseGeometry base) {
+ if(isDebug()) System.out.printf("%s: build box for %s\n", this.getClass().getSimpleName(),getName());
+ setBox(new Box(getName() + "Box", base.getBoxDim().x(), base.getBoxDim().y(), base.getBoxDim().z()));
+ }
+ protected void buildVolume(BaseGeometry base) {
+ if(isDebug()) System.out.printf("%s: build volume for %s with material %s\n", this.getClass().getSimpleName(),getName(),base.getMaterial());
+ IMaterial material = MaterialStore.getInstance().get(base.getMaterial());
+ setVolume(new LogicalVolume(getName() + "_volume", box, material));
+
+ }
+ protected void setPosAndRot(BaseGeometry base) {
+ if(isDebug()) System.out.printf("%s: set position and rotation for volume %s\n", this.getClass().getSimpleName(),getName());
+ // Vector from origin to center of box locally
+ Hep3Vector box_center_base_local = base.getCenter();
+ //translate to the mother coordinate system
+ Hep3Vector box_center_base = base.getCoord().getTransformation().transformed(box_center_base_local);
+ // find the position of the center in the mother coord
+ Hep3Vector box_center = VecOp.sub(box_center_base, base.getMother().getCenter());
+ //Find LCDD Euler rotation angles from coordinate system unit vectors
+ Hep3Vector lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(base.getCoord().v(), base.getCoord().w(), new BasicHep3Vector(0,1,0),new BasicHep3Vector(0,0,1));
+ // Check if there are explicit rotations built into the object itself which overrides
+ // TODO this should be included in the definition of the coordinate system. Fix this for the affected components.
+ if (base.explicit_rot_angles!=null) {
+ // there are explicit rotations I need to apply.
+ // Find the displacement of the box center due to rotation about different origin
+ Hep3Vector box_center_base_rot = HPSTestRunTracker2014.getRotationDisplacement(base.getCoord().origin(), box_center_base, base.explicit_rot_angles);
+ if(isDebug()) {
+ System.out.printf("%s: explicit_rot_angles %s\n", this.getClass().getSimpleName(),lcdd_rot_angles);
+ System.out.printf("%s: explicit_rot_angles_2 %s\n", this.getClass().getSimpleName(),base.explicit_rot_angles);
+ System.out.printf("%s: box_center_base %s\n", this.getClass().getSimpleName(), box_center_base.toString());
+ System.out.printf("%s: box_center_base_rot %s\n", this.getClass().getSimpleName(), box_center_base_rot.toString());
+ }
+ // update the rotation angles
+ lcdd_rot_angles = base.explicit_rot_angles;
+ // update the position of the center in the mother coord
+ box_center = VecOp.sub(box_center_base_rot, base.getMother().getCenter());
+ }
+ // Create the LCDD position
+ setPos(new Translation3D(box_center.x(), box_center.y(), box_center.z()));
+ setRot(new RotationGeant(lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z()));
+ if(isDebug()) {
+ System.out.printf("%s: box_center_base_local %s\n", this.getClass().getSimpleName(), box_center_base_local.toString());
+ System.out.printf("%s: box_center_base %s\n", this.getClass().getSimpleName(), box_center_base.toString());
+ System.out.printf("%s: mother center %s\n", this.getClass().getSimpleName(), base.getMother().getCenter().toString());
+ System.out.printf("%s: box_center %s\n", this.getClass().getSimpleName(), box_center.toString());
+ System.out.printf("%s: pos %s\n", this.getClass().getSimpleName(), getPos().toString());
+ System.out.printf("%s: euler %s\n", this.getClass().getSimpleName(), lcdd_rot_angles.toString());
+ System.out.printf("%s: rot %s\n", this.getClass().getSimpleName(), getRot().toString());
+ }
+
+ }
+ protected ILogicalVolume getVolume() {
+ return volume;
+ }
+ protected void setVolume(ILogicalVolume volume) {
+ this.volume = volume;
+ }
+ protected Box getBox() {
+ return box;
+ }
+ protected void setBox(Box b) {
+ box = b;
+ }
+ protected String getName() {
+ return name;
+ }
+ protected void setName(String name) {
+ this.name = name;
+ }
+ protected Translation3D getPos() {
+ return pos;
+ }
+ protected void setPos(Translation3D pos) {
+ this.pos = pos;
+ }
+ protected Rotation3D getRot() {
+ return rot;
+ }
+ protected void setRot(Rotation3D rot) {
+ this.rot = rot;
+ }
+ protected JavaBaseGeom getMother() {
+ return mother;
+ }
+ protected void setMother(JavaBaseGeom mother) {
+ this.mother = mother;
+ }
+ protected IPhysicalVolume getPhysVolume() {
+ return physVolume;
+ }
+ protected void setPhysVolume(PhysicalVolume physVolume) {
+ this.physVolume = physVolume;
+ }
+ public boolean isDebug() {
+ return debug;
+ }
+
+ protected List<JavaBaseGeom> getDaughters() {
+ return daughters;
+ }
+
+ protected void addDaughter(JavaBaseGeom o) {
+ getDaughters().add(o);
+ }
+
+ public int getComponentId() {
+ return componentId;
+ }
+
+ public void setComponentId(int componentId) {
+ this.componentId = componentId;
+ }
+
+ }
+
+ // Find detector elements
+ // I could keep a single list of elements for all types since
+ // the search is done using idenitifier which should be unique.
+ // But it looks like the module DE has the same expanded ID as the layer
+ // since the module ID is saved not inside the ID?
+ // TODO Jeremy, is this correct?
+ protected IDetectorElement getLayerDetectorElement(IExpandedIdentifier layerPosId) {
+ IDetectorElement element = null;
+ for(IDetectorElement e : layerDetectorElements) {
+ if(e.getExpandedIdentifier().match(layerPosId)==0) {
+ //check that only one was found
+ if(element!=null) throw new RuntimeException("two DE sharing extended ID?");
+ element = e;
+ }
+ }
+ return element;
+ }
+ protected IDetectorElement getModuleDetectorElement(IExpandedIdentifier layerPosId) {
+ IDetectorElement element = null;
+ for(IDetectorElement e : moduleDetectorElements) {
+ if(e.getExpandedIdentifier().match(layerPosId)==0) {
+ //check that only one was found
+ if(element!=null) throw new RuntimeException("two DE sharing extended ID?");
+ element = e;
+ }
+ }
+ return element;
+ }
+ protected void addLayerDetectorElement(IDetectorElement e) {
+ if(getLayerDetectorElement(e.getExpandedIdentifier()) != null)
+ throw new RuntimeException("Trying to add an existing layer detector element.");
+ layerDetectorElements.add(e);
+ }
+ protected void addModuleDetectorElement(IDetectorElement e) {
+ if(getLayerDetectorElement(e.getExpandedIdentifier()) != null)
+ throw new RuntimeException("Trying to add an existing layer detector element.");
+ moduleDetectorElements.add(e);
+ }
+
+
+}
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 2014-08-18 20:46:54 UTC (rev 3269)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java 2014-08-19 00:32:47 UTC (rev 3270)
@@ -14,7 +14,10 @@
import java.util.List;
import java.util.Map;
+import javax.management.RuntimeErrorException;
+
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
+import org.jdom.DataConversionException;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.lcsim.detector.ITransform3D;
@@ -22,8 +25,8 @@
import org.lcsim.detector.RotationGeant;
import org.lcsim.detector.Transform3D;
import org.lcsim.detector.Translation3D;
-import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014LCDDBuilder.LCDDBaseGeom;
-import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014LCDDBuilder.GhostBaseGeom;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014LCDDBuilder.LCDDBaseGeometry;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014LCDDBuilder.GhostLCDDBaseGeometry;
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;
@@ -45,9 +48,16 @@
{
private boolean _debug = true;
private final boolean buildBeamPlane = true;
-
+ // Builder class to handle all geometry information
private static HPSTestRunTracker2014LCDDBuilder builder;
+
+
+ /**
+ * Default constructor
+ * @param node
+ * @throws JDOMException
+ */
public HPSTestRunTracker2014(Element node) throws JDOMException
{
super(node);
@@ -64,8 +74,8 @@
/**
* Build the LCDD for the subdetector.
- * @param lcdd The LCDD file being created.
- * @param sens The SD for this subdetector.
+ * @param lcdd - the LCDD file being created.
+ * @param sens - the SD for this subdetector.
*/
public void addToLCDD(LCDD lcdd, SensitiveDetector sens) throws JDOMException
{
@@ -108,48 +118,70 @@
if(_debug) System.out.printf("%s: DONE setup and build the LCDD geometry\n", getClass().getSimpleName());
- //makeExample(lcdd,sens);
+ makeExample(lcdd,sens);
+ //makeExample2(lcdd,sens);
+ makeExample3(lcdd,sens);
+ makeExample4(lcdd,sens);
+ makeExample5(lcdd,sens);
+ makeExample3b(lcdd,sens);
+ makeExample5b(lcdd,sens);
+ makeExample6(lcdd,sens);
+ makeExample66(lcdd,sens);
+ makeExample7(lcdd,sens);
+ makeExample77(lcdd,sens);
+ makeExample8(lcdd, sens);
+ makeExample9(lcdd, sens);
+ makeExample10(lcdd, sens);
-
if(buildBeamPlane ) {
// beam plane at global z=0
- Hep3Vector ball_pos_beamplane = new BasicHep3Vector(-1.0*HPSTestRunTracker2014GeomDef.BasePlate.base_plate_width/2.0,0.0,HPSTestRunTracker2014GeomDef.BasePlate.base_plate_length/2.0);
- Hep3Vector vee_pos_beamplane = new BasicHep3Vector(ball_pos_beamplane.x()+HPSTestRunTracker2014GeomDef.BasePlate.base_plate_width,ball_pos_beamplane.y(),ball_pos_beamplane.z());
- Hep3Vector flat_pos_beamplane = new BasicHep3Vector(ball_pos_beamplane.x(), ball_pos_beamplane.y(), ball_pos_beamplane.z()-HPSTestRunTracker2014GeomDef.BasePlate.base_plate_length/2.0);
+ Hep3Vector ball_pos_beamplane = new BasicHep3Vector(-1.0*HPSTestRunTracker2014GeometryDefinition.BasePlate.base_plate_width/2.0,0.0,HPSTestRunTracker2014GeometryDefinition.BasePlate.base_plate_length/2.0);
+ Hep3Vector vee_pos_beamplane = new BasicHep3Vector(ball_pos_beamplane.x()+HPSTestRunTracker2014GeometryDefinition.BasePlate.base_plate_width,ball_pos_beamplane.y(),ball_pos_beamplane.z());
+ Hep3Vector flat_pos_beamplane = new BasicHep3Vector(ball_pos_beamplane.x(), ball_pos_beamplane.y(), ball_pos_beamplane.z()-HPSTestRunTracker2014GeometryDefinition.BasePlate.base_plate_length/2.0);
makeBeamPlane(trackingVolume, ball_pos_beamplane, vee_pos_beamplane, flat_pos_beamplane, lcdd, sens);
}
-
+
+ // Actually build the LCDD
buildLCDD();
- //makeBase(trackingVolume,lcdd,sens);
-
}
+ /**
+ * Top function to add objects to the LCDD file using the geometry builder class.
+ */
private void buildLCDD() {
if(_debug) System.out.printf("%s: buildLCDD\n", getClass().getSimpleName());
+ // Get a reference to the LCDD
LCDD lcdd = builder.getLCDD();
- LCDDBaseGeom lcddObj = builder.getBaseLCDD();
+ // Reference to the top level object in the builder class
+ // In this case it is the base volume holding the entire tracker
+ LCDDBaseGeometry lcddObj = builder.getBaseLCDD();
+ // Add the base volume and all its daughters to the LCDD
addToLCDD(lcddObj,lcdd);
-
if(_debug) System.out.printf("%s: buildLCDD DONE\n", getClass().getSimpleName());
}
- private void addToLCDD(LCDDBaseGeom lcddObj, LCDD lcdd) {
+ /**
+ * Add a @LCDDBaseGeom geometry object to the LCDD file.
+ * @param lcddObj to add
+ * @param lcdd file
+ */
+ private void addToLCDD(LCDDBaseGeometry lcddObj, LCDD lcdd) {
if(_debug) System.out.printf("%s: adding %s to LCDD\n", getClass().getSimpleName(),lcddObj.getName());
- if(lcddObj.getClass().isInstance(GhostBaseGeom.class)) {
+ if(lcddObj.getClass().isInstance(GhostLCDDBaseGeometry.class)) {
System.out.printf("%s: trying to add a ghost volume: %s ??\n", getClass().getSimpleName(),lcddObj.getName());
throw new RuntimeException("adding a ghost volume (" + lcddObj.getName() + ") to LCDD is not allowed.");
}
@@ -158,10 +190,21 @@
lcdd.add(lcddObj.getPos());
lcdd.add(lcddObj.getRot());
lcddObj.buildPhysVolume();
+ // Set the phys volume Id's
+ // Since the builder don't have access to the system ID
+ // I keep the phys volume ID's outside. I think these
+ // should belong to the builder to avoid repeating it in
+ // the java converter
+ // TODO move this to the builder for each volume
+ try {
+ setPhysicalVolumeProperties(lcddObj);
+ } catch (DataConversionException e) {
+ e.printStackTrace();
+ }
// add daughters
if(_debug) System.out.printf("%s: add %d daughters to %s\n", getClass().getSimpleName(),lcddObj.getDaughters().size(),lcddObj.getName());
- for(LCDDBaseGeom daughter : lcddObj.getDaughters()) {
+ for(LCDDBaseGeometry daughter : lcddObj.getDaughters()) {
addToLCDD(daughter,lcdd);
}
@@ -174,1045 +217,71 @@
}
-
- /*
-
- private void makeBase(Volume motherVolume, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
+ /**
+ * Set properties of the physical volume.
+ * @param geometryObject
+ */
+ private void setPhysicalVolumeProperties(LCDDBaseGeometry geometryObject) throws DataConversionException {
+ if(_debug) System.out.printf("%s: setPhysVolumeProperties for name %s\n", getClass().getSimpleName(),geometryObject.getName());
- if(_debug) {
- print("--- makeBase ----");
- }
-
-
-
- HPSTestRunTracker2014GeomDef.BaseGeom base = builder.getItem(HPSTestRunTracker2014GeomDef.Base.class);
-
- Hep3Vector ball_pos_base = base.getBallPos();
- Hep3Vector vee_pos_base = base.getVeePos();
- Hep3Vector flat_pos_base = base.getFlatPos();
- HPSTestRunTracker2014GeomDef.Coord base_coord = base.getCoord();
-
- String volName = base.getName();
- Box box = new Box(volName + "Box", base.getBoxDim().x(), base.getBoxDim().y(), base.getBoxDim().z());
- lcdd.add(box);
- Volume volume = new Volume(volName + "_volume", box, lcdd.getMaterial("Vacuum"));
-
- if(_debug) {
- print(String.format("ball_pos_base %s", ball_pos_base.toString()));
- print(String.format("vee_pos_base %s", vee_pos_base.toString()));
- print(String.format("flat_pos_base %s", flat_pos_base.toString()));
- print(String.format("base_coord:\n%s", base_coord.toString()));
- }
-
-
-
- Hep3Vector box_center_base_local = base.getCenter();
-
- //translate to the mother coordinate system
- Hep3Vector box_center_base = base.getCoord().getTransformation().transformed(box_center_base_local);
-
-
- // find the position of the center in the mother coord
- Hep3Vector box_center = VecOp.sub(box_center_base, base.getMother().getCenter());
-
-
-
- if(_debug) {
- print(String.format("box_center_base_local %s", box_center_base_local.toString()));
- print(String.format("box_center_base %s", box_center_base.toString()));
- print(String.format("mother center %s", base.getMother().getCenter().toString()));
- print(String.format("box_center %s", box_center.toString()));
- }
-
- // Create the LCDD position
- Position pos = new Position(volName + "_position",box_center.x(), box_center.y(), box_center.z());
-
- //Find LCDD Euler rotation angles from coordinate system unit vectors
- Hep3Vector lcdd_rot_angles = getEulerAngles(base_coord.v(), base_coord.w(), new BasicHep3Vector(0,1,0),new BasicHep3Vector(0,0,1));
- Rotation rot = new Rotation(volName + "_rotation",lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z());
- lcdd.add(pos);
- lcdd.add(rot);
-
- // Create the physical volume
- PhysVol physVolume = new PhysVol(volume, motherVolume, pos, rot);
- if(_debug) {
- print("Created physical volume " + physVolume.getName());
- }
-
-
- // create the base plate inside the base tracker box
-
- makeBasePlate(volume, lcdd, sens );
-
-
- // create the box around the support plates w.r.t. base plate survey positions
-
- if(_debug) {
- print("Make c-support positions on base plate for bottom");
- }
-
-
-
- makeSupport("bottom",volume, lcdd, sens );
-
-
-
- if(_debug) {
- print("Make c-support positions on base plate for top");
- }
-
- // the top has the same bearing positions as the bottom c-support except for the offset vertically from base plate
- // the tilt angle is independent though.
-
- makeSupport("top", volume, lcdd, sens );
-
- //volume.setVisAttributes(lcdd.getVisAttributes("BasePlateVis"));
- lcdd.add(volume);
-
-
-
- }
-
-
- */
-
- /*
-
- private void makeBasePlate(Volume motherVolume, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
-
- if(_debug) {
- print("--- makeBasePlate----");
- }
-
- HPSTestRunTracker2014GeomDef.BasePlate basePlate = builder.getItem(HPSTestRunTracker2014GeomDef.BasePlate.class);
-
- HPSTestRunTracker2014GeomDef.Coord base_plate_coord = basePlate.getCoord();
-
- String volName = basePlate.getName();
- Box box = new Box(volName + "Box", basePlate.getBoxDim().x(),basePlate.getBoxDim().y(),basePlate.getBoxDim().z());
- lcdd.add(box);
- Volume basePlateVolume = new Volume(volName + "_volume", box, lcdd.getMaterial("Aluminum"));
-
-
- if(_debug) {
- print(String.format("base_plate_coord:\n%s", base_plate_coord.toString()));
- }
-
-
-
- // Find distance to center in the local coordinate system
- Hep3Vector box_center_base_plate_local = basePlate.getCenter();
-
- //translate to the mother coordinate system
- Hep3Vector box_center_base_plate = basePlate.getCoord().getTransformation().transformed(box_center_base_plate_local);
-
- // 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 mother coord
- Hep3Vector box_center = VecOp.sub(box_center_base_plate, basePlate.getMother().getCenter());
-
- if(_debug) {
- print(String.format("box_center_base_plate_local %s", box_center_base_plate_local.toString()));
- print(String.format("box_center_base_plate %s", box_center_base_plate.toString()));
- print(String.format("mother center %s", basePlate.getMother().getCenter().toString()));
- print(String.format("box_center %s", box_center.toString()));
- }
-
- // Create the LCDD position
- Position pos = new Position(volName + "_position",box_center.x(), box_center.y(), box_center.z());
-
- //Find LCDD Euler rotation angles from coordinate system unit vectors
- Hep3Vector lcdd_rot_angles = getEulerAngles(base_plate_coord.u(), base_plate_coord.v(), new BasicHep3Vector(1,0,0),new BasicHep3Vector(0,1,0));
- Rotation rot = new Rotation(volName + "_rotation",lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z());
- lcdd.add(pos);
- lcdd.add(rot);
-
- // Create the physical volume
- PhysVol basePlatePV = new PhysVol(basePlateVolume, motherVolume, pos, rot);
- if(_debug) {
- print("Created physical vomume " + basePlatePV.getName());
- }
-
- // add volume to lcdd
- basePlateVolume.setVisAttributes(lcdd.getVisAttributes("BasePlateVis"));
- lcdd.add(basePlateVolume);
-
-
- }
-
- */
-
- /*
-
- private void makeSupport(String half, Volume motherVolume, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
-
-
- if(_debug) {
- print("--- makeSupport for " + half + " half ----");
+ // the physical vol ID's here are for the <module_placement> TestRunModules
+ // which is essentially the sensor objects
+ String name = geometryObject.getName();
+ if(name.endsWith("halfmodule_axial") || name.endsWith("halfmodule_stereo") ) {
+ PhysVol physVol = geometryObject.getPhysVolume();
+ int sysId = node.getAttribute("id").getIntValue();
+ physVol.addPhysVolID("system", sysId);
+ physVol.addPhysVolID("barrel", 0);
+ int layer = HPSTestRunTracker2014Builder.getLayerFromVolumeName(geometryObject.getName());
+ geometryObject.getPhysVolume().addPhysVolID("layer", layer);
+ String half = HPSTestRunTracker2014Builder.getHalfFromName(geometryObject.getName());
+ if(half.equals("")) throw new RuntimeException("no half was found for name " + geometryObject.getName());
+ int moduleId = half.equals("top") ? 0 : 1;
+ geometryObject.getPhysVolume().addPhysVolID("module", moduleId);
}
-
- double support_length = -99999.9;
- double support_width = -99999.9;
- double support_height = -99999.9;
- double support_plate_length = -99999.9;
- double support_plate_width = -99999.9;
-
- if( half == "bottom" ) {
- support_length = HPSTestRunTracker2014GeomDef.SupportBottom.support_bottom_length;
- support_width = HPSTestRunTracker2014GeomDef.SupportBottom.support_bottom_width;
- support_height = HPSTestRunTracker2014GeomDef.SupportBottom.support_bottom_height;
- support_plate_length = HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_bottom_length;
- support_plate_width = HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_bottom_width;
+ //TODO is this really needed?
+ else if(name.endsWith("sensor_active")) {
+ geometryObject.getPhysVolume().addPhysVolID("sensor", 0);
}
- else if( half == "top" ) {
- support_length = HPSTestRunTracker2014GeomDef.SupportTop.support_top_length;
- support_width = HPSTestRunTracker2014GeomDef.SupportTop.support_top_width;
- support_height = HPSTestRunTracker2014GeomDef.SupportTop.support_top_height;
- support_plate_length = HPSTestRunTracker2014GeomDef.SupportPlateTop.support_plate_top_length;
- support_plate_width = HPSTestRunTracker2014GeomDef.SupportPlateTop.support_plate_top_width;
- } else {
- print("Error: cannot make support for " + half);
- System.exit(1);
+ //TODO are the component id's really needed?
+ else if(name.endsWith("sensor")) {
+ geometryObject.getPhysVolume().addPhysVolID("component", 0);
}
-
- String volName;
- HPSTestRunTracker2014GeomDef.Coord csup_coord;
- HPSTestRunTracker2014GeomDef.BaseGeom mother;
- HPSTestRunTracker2014GeomDef.SupportBottom supportBottom = builder.getItem(HPSTestRunTracker2014GeomDef.SupportBottom.class);
- HPSTestRunTracker2014GeomDef.SupportTop supportTop = builder.getItem(HPSTestRunTracker2014GeomDef.SupportTop.class);
- if(half == "bottom") {
- csup_coord = supportBottom.getCoord();
- volName = supportBottom.getName();
- mother = supportBottom.getMother();
- } else {
- csup_coord = supportTop.getCoord();
- volName = supportTop.getName();
- mother = supportTop.getMother();
- }
- Transform3D trans_csup_to_base = getTransformation(csup_coord);
-
-
-
- Box box = new Box(volName + "Box", support_width, support_length, support_height);
- lcdd.add(box);
- Volume supportVolume = new Volume(volName + "_volume", box, lcdd.getMaterial("Vacuum"));
-
-
- if(_debug) {
- print(String.format("support_coord:\n%s", csup_coord.toString()));
+ else if(name.endsWith("lamination")) {
+ geometryObject.getPhysVolume().addPhysVolID("component", 1);
}
-
-
-
- // Find distance to center in the local coordinate system
-
- // the support plate sits exactly in between the bearing positions
- // it's offset along the local directions
-
- Hep3Vector box_center_support_local;
- if(half == "bottom") {
- box_center_support_local = supportBottom.getCenter();
- } else {
- box_center_support_local = supportTop.getCenter();
- }
-
- //translate to the mother coordinate system
- Hep3Vector box_center_support_base = trans_csup_to_base.transformed(box_center_support_local);
-
- // find the position of the center in the mother coord
-
- Hep3Vector box_center = VecOp.sub(box_center_support_base, mother.getCenter());
-
- if(_debug) {
- print(String.format("box_center_support_local %s", box_center_support_local.toString()));
- print(String.format("box_center_support_base %s", box_center_support_base.toString()));
- print(String.format("mother center %s", mother.getCenter().toString()));
- print(String.format("box_center %s", box_center.toString()));
+ else if(name.endsWith("cf")) {
+ geometryObject.getPhysVolume().addPhysVolID("component", 2);
}
- // Create the LCDD position
- Position pos = new Position(volName + "_position",box_center.x(), box_center.y(), box_center.z());
-
- //Find LCDD Euler rotation angles from coordinate system unit vectors
- Hep3Vector lcdd_rot_angles = getEulerAngles(csup_coord.u(), csup_coord.v(), new BasicHep3Vector(1,0,0),new BasicHep3Vector(0,1,0));
- Rotation rot = new Rotation(volName + "_rotation",lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z());
- lcdd.add(pos);
- lcdd.add(rot);
-
-
- // Create the physical volume
- PhysVol supportPV = new PhysVol(supportVolume, motherVolume, pos, rot);
- if(_debug) {
- print("Created physical vomume " + supportPV.getName());
- }
-
-
-
- // create the support plate inside the support box coordinate system
- // survey points on the support plate are:
- // ball: corner of the hinge end at the surface on the side where module cold blocks are
- // vee: corner of the hinge end at the surface on the side where sensors are
- // flat: middle of plate at upstream end at the surface
-
-
-// Hep3Vector ball_pos_support_plate;
-// Hep3Vector vee_pos_support_plate;
-// Hep3Vector flat_pos_support_plate;
-// if(half == "bottom") {
-// ball_pos_support_plate = new BasicHep3Vector(1.0, (17.0-5.0), 6.66+1.34);
-// vee_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x() + support_plate_width, ball_pos_support_plate.y(),ball_pos_support_plate.z());
-// flat_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x(), ball_pos_support_plate.y() + support_plate_length,ball_pos_support_plate.z());
-// //ball_pos_support_plate = new BasicHep3Vector(0.0, 0.0, support_plate_height); // TODO figure out what height this should be from the C-support drawings
-// //vee_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x() + support_plate_width, ball_pos_support_plate.y(),ball_pos_support_plate.z());
-// //flat_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x(), ball_pos_support_plate.y() + support_plate_length,ball_pos_support_plate.z());
-// } else {
-// ball_pos_support_plate = new BasicHep3Vector(1.0, (17.0-5.0), -1.0 * (6.66+1.34)); // TODO figure out what height this should be from the C-support drawings
-// vee_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x() + support_plate_width, ball_pos_support_plate.y(),ball_pos_support_plate.z());
-// flat_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x(), ball_pos_support_plate.y() + support_plate_length,ball_pos_support_plate.z());
-// }
-
-
-
- //makeSupportPlate(supportWrap, ball_pos_support_plate, vee_pos_support_plate, flat_pos_support_plate, lcdd, sens );
-
- makeSupportPlate(half, supportVolume, lcdd, sens );
-
-
-
-
-
-
- // create the module from positions of module ball, vee and flat w.r.t. support plate survey points
- // ball: hole on the cold block mounting surface
- // vee: slot on the cold block mounting surface
- // flat: midpoint between line joining ball and vee and offset 90deg along plate going upstream
-
- if(_debug) {
- print("Make modules on support plate");
+ else if(name.endsWith("hybrid")) {
+ geometryObject.getPhysVolume().addPhysVolID("component", 3);
}
-
- for(int ilayer = 1; ilayer <=5; ++ilayer) {
- String layerName = String.format("L%d%s", ilayer,half=="bottom"?"b":"t");
-
- print(layerName);
-
- // make the module
- makeModule(half,layerName,supportVolume,lcdd, sens);
-
- } // ilayer
-
-
-
- // add support volume to lcdd
- supportVolume.setVisAttributes(lcdd.getVisAttributes("SupportVolumeVis"));
- lcdd.add(supportVolume);
-
-
-
-
-
-
- }
-
- */
-
- /*
-
-
-
- private void makeSupportPlate(String half, Volume motherVolume, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
-
-
if(_debug) {
- print("--- makeSupportPlate for " + half + " ----");
-
- }
-
-
-
- // Create the box
- String volName;
- double width,height,length;
- HPSTestRunTracker2014GeomDef.Coord support_plate_coord;
- HPSTestRunTracker2014GeomDef.BaseGeom mother;
-
- HPSTestRunTracker2014GeomDef.SupportPlateBottom supportPlateBottom = builder.getItem(HPSTestRunTracker2014GeomDef.SupportPlateBottom.class);
- HPSTestRunTracker2014GeomDef.SupportPlateTop supportPlateTop = builder.getItem(HPSTestRunTracker2014GeomDef.SupportPlateTop.class);
- if(half == "bottom") {
- volName = supportPlateBottom.getName();
- width = HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_bottom_width;
- length = HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_bottom_length;
- height = HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_bottom_height;
- support_plate_coord = supportPlateBottom.getCoord();
- mother = supportPlateBottom.getMother();
- } else {
- volName = supportPlateTop.getName();
- width = HPSTestRunTracker2014GeomDef.SupportPlateTop.support_plate_top_width;
- length = HPSTestRunTracker2014GeomDef.SupportPlateTop.support_plate_top_length;
- height = HPSTestRunTracker2014GeomDef.SupportPlateTop.support_plate_top_height;
- support_plate_coord = supportPlateTop.getCoord();
- mother = supportPlateTop.getMother();
- }
-
- volName = volName + "_supportplate";
- Box box = new Box(volName + "Box", width, length, height);
- lcdd.add(box);
- Volume supportPlateVolume = new Volume(volName + "_volume", box, lcdd.getMaterial("Aluminum"));
-
-
- // create the coordinate system
- Transform3D trans_support_plate_to_support = getTransformation(support_plate_coord);
-
- if(_debug) {
- print(String.format("support_plate_coord:\n%s", support_plate_coord.toString()));
- }
-
-
- // Find distance to center in the local coordinate system
- Hep3Vector box_center_support_plate_local;
- if(half == "bottom") {
- //box_center_support_plate_local = new BasicHep3Vector(HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_bottom_width/2.0, HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_bottom_length/2.0, -1.0 * HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_bottom_height/2.0);
- box_center_support_plate_local = supportPlateBottom.getCenter();
- } else {
- //box_center_support_plate_local = new BasicHep3Vector(HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_bottom_width/2.0, HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_bottom_length/2.0, HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_bottom_height/2.0);
- box_center_support_plate_local = supportPlateTop.getCenter();
- }
-
- //translate to the mother coordinate system
- Hep3Vector box_center_support = trans_support_plate_to_support.transformed(box_center_support_plate_local);
-
- // find the position of the center in the mother coord
- //Hep3Vector box_center = VecOp.sub(box_center_support, supportWrap.center);
- Hep3Vector box_center = VecOp.sub(box_center_support, mother.getCenter());
-
- if(_debug) {
- 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.toString()));
- print(String.format("mother center %s", mother.getCenter().toString()));
- print(String.format("box_center %s", box_center.toString()));
- }
-
- // Create the LCDD position
- Position pos = new Position(volName + "_position",box_center.x(), box_center.y(), box_center.z());
-
- //Find LCDD rotation angles from coordinate system unit vectors
- Hep3Vector lcdd_rot_angles = this.getEulerAngles(support_plate_coord.u(), support_plate_coord.v(), new BasicHep3Vector(1,0,0), new BasicHep3Vector(0,1,0));
- 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, motherVolume, pos, rot);
- if(_debug) {
- print("Created physical vomume " + supportPlatePV.getName());
- }
-
- supportPlateVolume.setVisAttributes(lcdd.getVisAttributes("SupportPlateVis"));
- lcdd.add(supportPlateVolume);
-
-
- }
-
- */
-
- /*
-
-
-
-
- private void makeModule(String half, String name, Volume motherVolume, LCDD lcdd, SensitiveDetector sens) throws JDOMException
- {
-
- print(String.format("----- makeModule " + name + " " + half + " ------"));
-
-
- // build the module name
- String volName = "module_" + name;
-
- // find the module layer
- int layer = getLayerFromVolumeName(volName);
-
- boolean isL13 = ( layer >=1 && layer <=3 ) ? true : false;
-
- // find the mother and reference geom
- final HPSTestRunTracker2014GeomDef.BaseGeom mother;
- // reference is a intermediate geom object that are referenced but not it's direct mother
- final HPSTestRunTracker2014GeomDef.BaseGeom ref;
- HPSTestRunTracker2014GeomDef.SupportBottom supportBottom = builder.getItem(HPSTestRunTracker2014GeomDef.SupportBottom.class);
- HPSTestRunTracker2014GeomDef.SupportTop supportTop = builder.getItem(HPSTestRunTracker2014GeomDef.SupportTop.class);
-
- HPSTestRunTracker2014GeomDef.SupportPlateBottom supportPlateBottom = builder.getItem(HPSTestRunTracker2014GeomDef.SupportPlateBottom.class);
- HPSTestRunTracker2014GeomDef.SupportPlateTop supportPlateTop = builder.getItem(HPSTestRunTracker2014GeomDef.SupportPlateTop.class);
- if(half == "bottom") {
- mother = supportBottom;
- ref = supportPlateBottom;
- } else {
- mother= supportTop;
- ref = supportPlateTop;
- }
-
- //Create the module
- HPSTestRunTracker2014GeomDef.TestRunModule module;
- if(isL13) {
- module = new HPSTestRunTracker2014GeomDef.TestRunModuleL13(volName, mother, ref, layer, half);
- } else {
- module = new HPSTestRunTracker2014GeomDef.TestRunModuleL45(volName, mother, ref, layer, half);
- }
-
- // add it to list of modules
- List<HPSTestRunTracker2014GeomDef.BaseGeom> modules = builder.getModules();
- modules.add(module);
-
- Box box = new Box(volName + "_box", module.getBoxDim().x(), module.getBoxDim().y(), module.getBoxDim().z());
- lcdd.add(box);
- Volume moduleVolume = new Volume(volName + "_volume", box, lcdd.getMaterial("Vacuum"));
-
-
- // Find distance to center in the local coordinate system
- Hep3Vector box_center_local = module.getCenter();
-
- //translate to the mother coordinate system
- Hep3Vector box_center_support = module.getCoord().getTransformation().transformed(box_center_local);
-
- // find the position of the center in the mother coord
- Hep3Vector box_center = VecOp.sub(box_center_support, mother.getCenter());
-
- if(_debug) {
- print(String.format("box_center_local %s", box_center_local.toString()));
- print(String.format("box_center_support %s", box_center_support.toString()));
- print(String.format("mother center %s", mother.getCenter().toString()));
- print(String.format("box_center %s", box_center.toString()));
- }
-
- // Create the LCDD position
- Position pos = new Position(volName + "_position",box_center.x(), box_center.y(), box_center.z());
-
- //Find LCDD rotation angles from coordinate system unit vectors
- Hep3Vector lcdd_rot_angles = this.getEulerAngles(module.getCoord().u(), module.getCoord().v(), new BasicHep3Vector(1,0,0), new BasicHep3Vector(0,1,0));
- 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 physVolume = new PhysVol(moduleVolume, motherVolume, pos, rot);
-
-
- makeHalfModule("axial", volName ,moduleVolume, lcdd,sens);
-
- makeColdBlock(volName, moduleVolume, lcdd,sens);
-
- makeHalfModule("stereo", volName ,moduleVolume, lcdd,sens);
-
-
- moduleVolume.setVisAttributes(lcdd.getVisAttributes("ModuleVis"));
-
- lcdd.add(moduleVolume);
-
-
- }
-
-
- */
-
- /*
-
-
-
- private HPSTestRunTracker2014GeomDef.BaseGeom findModule(String moduleName) {
- List<HPSTestRunTracker2014GeomDef.BaseGeom> modules = builder.getModules();
- for(HPSTestRunTracker2014GeomDef.BaseGeom m : modules) {
- if(m.getName().equals(moduleName)) return m;
- }
- return null;
- }
-
-
- */
-
- /*
-
-
-
-
- private void makeHalfModule(String side, String moduleName, Volume motherVolume, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
-
- if(_debug) {
- print("--- makeHalfModule " + side + " for module " + moduleName);
- }
-
-
- String volName = moduleName + "_halfmodule_" + side;
-
- // top or bottom?
- String half = this.getHalfFromName(moduleName);
-
- // find layer
- int layer = this.getLayerFromVolumeName(moduleName);
-
- // find the mother
- HPSTestRunTracker2014GeomDef.BaseGeom mother = findModule(moduleName);
-
- if(mother==null) {
- throw new RuntimeException("Couldn't find mother " + moduleName + " to " + volName);
- }
-
- // Build the half-module
- HPSTestRunTracker2014GeomDef.TestRunHalfModule halfModule;
- if(side == "axial") {
- halfModule = new HPSTestRunTracker2014GeomDef.TestRunHalfModuleAxial(volName, mother, layer, half);
- } else if(side == "stereo") {
- halfModule = new HPSTestRunTracker2014GeomDef.TestRunHalfModuleStereo(volName, mother, layer, half);
- } else {
- throw new IllegalArgumentException("not a valid half-module side " + side);
- }
-
- Box box = new Box(volName + "Box", halfModule.getBoxDim().x(), halfModule.getBoxDim().y(), halfModule.getBoxDim().z());
- lcdd.add(box);
- Volume halfModuleVolume = new Volume(volName + "_volume", box, lcdd.getMaterial("Vacuum"));
-
-
- if(_debug) {
- print(String.format("half_module_coord:\n%s", halfModule.getCoord().toString()));
- }
-
- Hep3Vector box_center_local = halfModule.getCenter();
-
- //translate to the mother coordinate system
- Hep3Vector box_center_module_coord = halfModule.getCoord().getTransformation().transformed(box_center_local);
-
- //Find LCDD rotation angles
- // Since we want to keep the local coordinate system the same for both axial and stereo
- // sensors we rotate the half-modules in place "by-hand" and not only from system unit vectors
-
- Hep3Vector lcdd_rot_angles = this.getEulerAngles(halfModule.getCoord().u(), halfModule.getCoord().v(), new BasicHep3Vector(1,0,0), new BasicHep3Vector(0,1,0));
-
- if(side.equals("stereo")) {
- double stereo_angle;
- if(layer<4) {
- stereo_angle = -0.1;
- } else {
- stereo_angle = -0.05;
+ System.out.printf("%s: %d physvolid's\n", getClass().getSimpleName(),geometryObject.getPhysVolume().getChildren("physvolid").size());
+ //geomObj.getPhysVolume().getChildren("physvolid field_name="sensor" value="0"")
+ for (Iterator i = geometryObject.getPhysVolume().getChildren("physvolid").iterator(); i.hasNext();) {
+ Element e = (Element)i.next();
+ System.out.printf("%s: %s %d\n", getClass().getSimpleName(),e.getAttributeValue("field_name"),e.getAttribute("value").getIntValue());
}
-
- org.apache.commons.math3.geometry.euclidean.threed.Rotation rot_stereo = new org.apache.commons.math3.geometry.euclidean.threed.Rotation(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ, Math.PI, stereo_angle,0);
- double res[] = rot_stereo.getAngles(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ);
- Hep3Vector lcdd_rot_angles_2 = new BasicHep3Vector(res);
- if(_debug) {
- print(String.format("lcdd_rot_angles %s", lcdd_rot_angles.toString()));
- print(String.format("lcdd_rot_angles_2 %s", lcdd_rot_angles_2.toString()));
- }
-
- lcdd_rot_angles = lcdd_rot_angles_2;
- }
-
- // Find the displacement of the box center due to rotation about different origin
- Hep3Vector box_center_module_coord_rot = getRotationDisplacement(halfModule.getCoord().origin(), box_center_module_coord, lcdd_rot_angles);
-
- // find the position of the center in the mother coord
- Hep3Vector box_center = VecOp.sub(box_center_module_coord_rot, mother.getCenter());
-
- 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("mother center %s", mother.getCenter().toString()));
- print(String.format("box_center %s", box_center.toString()));
- }
-
- // Create the LCDD position
- Position pos = new Position(volName + "_position",box_center.x(), box_center.y(), box_center.z());
- // Create the LCDD rotation
- 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 physVolume = new PhysVol(halfModuleVolume, motherVolume, pos, rot);
-
-
-
-
-
- // create the half module components
-
- makeHalfModuleComponentSensor(halfModule, halfModuleVolume, lcdd, sens);
-
- makeHalfModuleComponentKapton(halfModule,halfModuleVolume, lcdd, sens);
-
- makeHalfModuleComponentCF(halfModule, halfModuleVolume, lcdd, sens);
-
- makeHalfModuleComponentHybrid(halfModule, halfModuleVolume, lcdd, sens);
+ if(_debug) System.out.printf("%s: DONE setPhysVolumeProperties for name %s\n", getClass().getSimpleName(),geometryObject.getName());
- //set vis stuff
- halfModuleVolume.setVisAttributes(lcdd.getVisAttributes("HalfModuleVis"));
-
- lcdd.add(halfModuleVolume);
-
-
- }
-
- */
-
- /*
-
- private void makeColdBlock(String moduleName, Volume motherVolume, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
-
- if(_debug) {
- print("--- makeColdBlock for module " + moduleName);
}
-
- String volName = moduleName + "_coldblock";
- // find layer
- int layer = this.getLayerFromVolumeName(moduleName);
- // find the mother
- HPSTestRunTracker2014GeomDef.BaseGeom mother = findModule(moduleName);
-
- if(mother==null) {
- throw new RuntimeException("Couldn't find mother " + moduleName + " to " + volName);
- }
-
- // Build the half-module
- HPSTestRunTracker2014GeomDef.TestRunColdBlock coldBlock;
-
- if(layer >= 1 && layer <=3) {
- coldBlock = new HPSTestRunTracker2014GeomDef.TestRunColdBlockL13(volName, mother, layer);
- } else if(layer >= 4 && layer <=5) {
- coldBlock = new HPSTestRunTracker2014GeomDef.TestRunColdBlockL45(volName, mother, layer);
- } else {
- throw new RuntimeException("wrong layer for " + volName);
- }
-
-
- Box box = new Box(volName + "Box", coldBlock.getBoxDim().x(),coldBlock.getBoxDim().y(), coldBlock.getBoxDim().z());
- lcdd.add(box);
- Volume coldBlockVolume = new Volume(volName + "_volume", box, lcdd.getMaterial("Aluminum"));
-
- // Find distance to center in the local coordinate system
- Hep3Vector box_center_local = coldBlock.getCenter();
-
- //translate to the mother coordinate system
- Hep3Vector box_center_module_coord = coldBlock.getCoord().getTransformation().transformed(box_center_local);
-
- // find the position of the center in the mother coord
- Hep3Vector box_center = VecOp.sub(box_center_module_coord, mother.getCenter());
-
- 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("mother center %s", mother.getCenter().toString()));
- print(String.format("box_center %s", box_center.toString()));
- }
-
- // Create the LCDD position
- Position pos = new Position(volName + "_position",box_center.x(), box_center.y(), box_center.z());
-
- //Find LCDD rotation angles from coordinate system unit vectors
- Hep3Vector lcdd_rot_angles = this.getEulerAngles(coldBlock.getCoord().u(), coldBlock.getCoord().v(), new BasicHep3Vector(1,0,0), new BasicHep3Vector(0,1,0));
- 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 physVolume = new PhysVol(coldBlockVolume, motherVolume, pos, rot);
-
-
- //set vis stuff
- coldBlockVolume.setVisAttributes(lcdd.getVisAttributes("ColdBlockVis"));
-
- lcdd.add(coldBlockVolume);
-
-
}
- private void makeHalfModuleComponentSensor(HPSTestRunTracker2014GeomDef.BaseGeom mother, Volume motherVolume, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
-
- if(_debug) {
- print("--- makeHalfModuleComponentSensor for half-module " + mother.getName());
- }
-
- String volName = mother.getName() + "_sensor";
-
- // sensor if
- int sensor_number = 0;
-
- // Build the half-module
- HPSTestRunTracker2014GeomDef.Sensor sensor = new HPSTestRunTracker2014GeomDef.Sensor(volName, mother, sensor_number);
-
-
- Box box = new Box(volName + "Box", sensor.getBoxDim().x(),sensor.getBoxDim().y(), sensor.getBoxDim().z());
- lcdd.add(box);
- Volume volume = new Volume(volName + "_volume", box, lcdd.getMaterial("Silicon"));
-
- // Find distance to center in the local coordinate system
- Hep3Vector box_center_local = sensor.getCenter();
-
- //translate to the mother coordinate system
- Hep3Vector box_center_module_coord = sensor.getCoord().getTransformation().transformed(box_center_local);
-
- // find the position of the center in the mother coord
- Hep3Vector box_center = VecOp.sub(box_center_module_coord, mother.getCenter());
-
- 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("mother center %s", mother.getCenter().toString()));
- print(String.format("box_center %s", box_center.toString()));
- }
-
- // Create the LCDD position
- Position pos = new Position(volName + "_position",box_center.x(), box_center.y(), box_center.z());
-
- //Find LCDD rotation angles from coordinate system unit vectors
- Hep3Vector lcdd_rot_angles = this.getEulerAngles(sensor.getCoord().u(), sensor.getCoord().v(), new BasicHep3Vector(1,0,0), new BasicHep3Vector(0,1,0));
- Rotation rot = new Rotation(volName + "_rotation",lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z());
[truncated at 1000 lines; 3061 more skipped]
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/HPSTestRunTracker2014Builder.java 2014-08-18 20:46:54 UTC (rev 3269)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014Builder.java 2014-08-19 00:32:47 UTC (rev 3270)
@@ -11,9 +11,11 @@
import java.util.List;
import org.jdom.JDOMException;
-import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeomDef.BaseGeom;
-import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeomDef.TestRunColdBlock;
-import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeomDef.TestRunModuleL13;
+import org.lcsim.detector.tracker.silicon.SiSensor;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.BaseGeometry;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.TestRunColdBlock;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.TestRunModule;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.TestRunModuleL13;
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.PhysVol;
@@ -24,7 +26,7 @@
/**
*
- * Class used to encapsulates building the basic geometry building blocks.
+ * Class used to encapsulate the rules for building geometry based building blocks defined in {@link HPSTestRunTracker2014GeometryDefinition}
*
* @author Per Hansson Adrian <[log in to unmask]>
*
@@ -35,7 +37,7 @@
private boolean debug = true;
//Geometry members
- protected List<HPSTestRunTracker2014GeomDef.BaseGeom> trackerItems = new ArrayList<HPSTestRunTracker2014GeomDef.BaseGeom>();
+ protected List<HPSTestRunTracker2014GeometryDefinition.BaseGeometry> trackerItems = new ArrayList<HPSTestRunTracker2014GeometryDefinition.BaseGeometry>();
public List<ModuleBundle> modules;
@@ -48,24 +50,29 @@
if(isDebug()) System.out.printf("%s: constructing the geometry objects\n", this.getClass().getSimpleName());
- // keep the order correct.
- // each item has knowledge of its mother but not its daughters
- HPSTestRunTracker2014GeomDef.TrackingBase tracking = new HPSTestRunTracker2014GeomDef.TrackingBase("trackingVolume",null);
+ // Build the geometry from the basicl building blocks in the geometry definition class
+ // Keep the order correct.
+ // Each item has knowledge of its mother but not its daughters
+ HPSTestRunTracker2014GeometryDefinition.TrackingBase tracking = new HPSTestRunTracker2014GeometryDefinition.TrackingBase("trackingVolume",null);
trackerItems.add(tracking);
- HPSTestRunTracker2014GeomDef.Base base = new HPSTestRunTracker2014GeomDef.Base("base",tracking);
+ HPSTestRunTracker2014GeometryDefinition.Base base = new HPSTestRunTracker2014GeometryDefinition.Base("base",tracking);
trackerItems.add(base);
- HPSTestRunTracker2014GeomDef.BasePlate basePlate = new HPSTestRunTracker2014GeomDef.BasePlate("baseplate",base, "Aluminum");
+ HPSTestRunTracker2014GeometryDefinition.BasePlate basePlate = new HPSTestRunTracker2014GeometryDefinition.BasePlate("baseplate",base, "Aluminum");
trackerItems.add(basePlate);
- HPSTestRunTracker2014GeomDef.CSupport cSupport = new HPSTestRunTracker2014GeomDef.CSupport("c_support", base);
+ HPSTestRunTracker2014GeometryDefinition.CSupport cSupport = new HPSTestRunTracker2014GeometryDefinition.CSupport("c_support", base);
trackerItems.add(cSupport);
- HPSTestRunTracker2014GeomDef.SupportBottom supportBottom = new HPSTestRunTracker2014GeomDef.SupportBottom("support_bottom", base, cSupport);
+ HPSTestRunTracker2014GeometryDefinition.SupportBottom supportBottom = new HPSTestRunTracker2014GeometryDefinition.SupportBottom("support_bottom", base, cSupport);
trackerItems.add(supportBottom);
- HPSTestRunTracker2014GeomDef.SupportPlateBottom supportPlateBottom = new HPSTestRunTracker2014GeomDef.SupportPlateBottom("support_plate_bottom", supportBottom, "Aluminum");
+ // The support survey positions are now with respect to its mother and not the reference coord. system.
+ // So to get the reference for the support plate I don't need to apply that extra transformation
+ HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom supportPlateBottom = new HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom("support_plate_bottom", base, supportBottom, "Aluminum");
trackerItems.add(supportPlateBottom);
- HPSTestRunTracker2014GeomDef.SupportTop supportTop = new HPSTestRunTracker2014GeomDef.SupportTop("support_top", base, cSupport);
+ HPSTestRunTracker2014GeometryDefinition.SupportTop supportTop = new HPSTestRunTracker2014GeometryDefinition.SupportTop("support_top", base, cSupport);
trackerItems.add(supportTop);
- HPSTestRunTracker2014GeomDef.SupportPlateTop supportPlateTop = new HPSTestRunTracker2014GeomDef.SupportPlateTop("support_plate_top", supportTop, "Aluminum");
+ HPSTestRunTracker2014GeometryDefinition.SupportPlateTop supportPlateTop = new HPSTestRunTracker2014GeometryDefinition.SupportPlateTop("support_plate_top", base, supportTop, "Aluminum");
trackerItems.add(supportPlateTop);
+
+ // Modules are built using an encapsulating class that keeps tracks of all components
modules = new ArrayList<ModuleBundle>();
for(int l=1; l<=5;++l) {
@@ -74,13 +81,17 @@
}
-
if(isDebug()) System.out.printf("%s: DONE constructing the geometry objects\n", this.getClass().getSimpleName());
}
+ /**
+ * Create the module.
+ * @param layer - of the module
+ * @param half - top or bottom half of the tracker
+ */
private void makeModuleBundle(int layer, String half)
{
@@ -92,37 +103,42 @@
boolean isL13 = ( layer >=1 && layer <=3 ) ? true : false;
- // find the mother and reference geom
- final HPSTestRunTracker2014GeomDef.BaseGeom mother;
- // reference is a intermediate geom object that are referenced but not it's direct mother
- final HPSTestRunTracker2014GeomDef.BaseGeom ref;
+ // find the mother and reference geometry
+ // Note that the reference geometry is the support plate and since that is assumed to be
+ // created through it's references we don't need more than one reference to reach the mother coordinate system
+ final HPSTestRunTracker2014GeometryDefinition.BaseGeometry mother;
+ final HPSTestRunTracker2014GeometryDefinition.BaseGeometry ref;
if(half == "bottom") {
- mother = getItem(HPSTestRunTracker2014GeomDef.SupportBottom.class);
- ref = getItem(HPSTestRunTracker2014GeomDef.SupportPlateBottom.class);
+ //mother = getItem(HPSTestRunTracker2014GeomDef.SupportBottom.class);
+ mother = getItem(HPSTestRunTracker2014GeometryDefinition.Base.class);
+ ref = getItem(HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.class);
} else {
- mother= getItem(HPSTestRunTracker2014GeomDef.SupportTop.class);
- ref = getItem(HPSTestRunTracker2014GeomDef.SupportPlateTop.class);
+ //mother= getItem(HPSTestRunTracker2014GeomDef.SupportTop.class);
+ mother= getItem(HPSTestRunTracker2014GeometryDefinition.Base.class);
+ ref = getItem(HPSTestRunTracker2014GeometryDefinition.SupportPlateTop.class);
}
//Create the module
- HPSTestRunTracker2014GeomDef.TestRunModule module;
+ HPSTestRunTracker2014GeometryDefinition.TestRunModule module;
if(isL13) {
- module = new HPSTestRunTracker2014GeomDef.TestRunModuleL13(volName, mother, ref, layer, half);
+ module = new HPSTestRunTracker2014GeometryDefinition.TestRunModuleL13(volName, mother, ref, layer, half);
} else {
- module = new HPSTestRunTracker2014GeomDef.TestRunModuleL45(volName, mother, ref, layer, half);
+ module = new HPSTestRunTracker2014GeometryDefinition.TestRunModuleL45(volName, mother, ref, layer, half);
}
+
// create the bundle for this module
ModuleBundle bundle = new ModuleBundle(module);
addModuleBundle(bundle);
+
makeHalfModule("axial", module);
-
+
makeColdBlock(module);
-
+ /*
makeHalfModule("stereo", module);
+ */
-
if(isDebug()) {
System.out.printf("%s: created module bundle:\n", this.getClass().getSimpleName());
bundle.print();
@@ -131,38 +147,47 @@
}
-
-private void makeColdBlock(HPSTestRunTracker2014GeomDef.TestRunModule mother) {
-
+ /**
+ * Create the cold block object.
+ * @param mother to the cold block
+ */
+ private void makeColdBlock(HPSTestRunTracker2014GeometryDefinition.TestRunModule mother) {
+
+
String moduleName = mother.getName();
-
+
if(isDebug()) System.out.printf("%s: makeColdBlock for %s \n", this.getClass().getSimpleName(), moduleName);
-
-
+
+
String volName = moduleName + "_coldblock";
// find layer
int layer = getLayerFromVolumeName(moduleName);
-
+
// Build the half-module
- HPSTestRunTracker2014GeomDef.TestRunColdBlock coldBlock;
-
+ HPSTestRunTracker2014GeometryDefinition.TestRunColdBlock coldBlock;
+
if(layer >= 1 && layer <=3) {
- coldBlock = new HPSTestRunTracker2014GeomDef.TestRunColdBlockL13(volName, mother, layer);
+ coldBlock = new HPSTestRunTracker2014GeometryDefinition.TestRunColdBlockL13(volName, mother, layer);
} else if(layer >= 4 && layer <=5) {
- coldBlock = new HPSTestRunTracker2014GeomDef.TestRunColdBlockL45(volName, mother, layer);
+ coldBlock = new HPSTestRunTracker2014GeometryDefinition.TestRunColdBlockL45(volName, mother, layer);
} else {
throw new RuntimeException("wrong layer for " + volName);
}
-
+
ModuleBundle bundle = getModuleBundle(mother);
bundle.coldBlock = coldBlock;
}
+
+
-
-
- private void makeHalfModule(String side, HPSTestRunTracker2014GeomDef.TestRunModule mother) {
+ /**
+ * Create the half-module.
+ * @param side - stereo or axial
+ * @param mother to the half-module
+ */
+ private void makeHalfModule(String side, HPSTestRunTracker2014GeometryDefinition.TestRunModule mother) {
String moduleName = mother.getName();
@@ -180,13 +205,13 @@
HalfModuleBundle halfModuleBundle;
// Build the half-module
- HPSTestRunTracker2014GeomDef.TestRunHalfModule halfModule;
+ HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule halfModule;
if(side == "axial") {
- halfModule = new HPSTestRunTracker2014GeomDef.TestRunHalfModuleAxial(volName, mother, layer, half);
+ halfModule = new HPSTestRunTracker2014GeometryDefinition.TestRunHalfModuleAxial(volName, mother, layer, half);
halfModuleBundle = new HalfModuleBundle(halfModule);
bundle.halfModuleAxial = halfModuleBundle;
} else if(side == "stereo") {
- halfModule = new HPSTestRunTracker2014GeomDef.TestRunHalfModuleStereo(volName, mother, layer, half);
+ halfModule = new HPSTestRunTracker2014GeometryDefinition.TestRunHalfModuleStereo(volName, mother, layer, half);
halfModuleBundle = new HalfModuleBundle(halfModule);
bundle.halfModuleStereo = halfModuleBundle;
} else {
@@ -194,7 +219,6 @@
}
-
// create the half module components
makeHalfModuleComponentSensor(halfModule);
@@ -212,17 +236,17 @@
- private void makeHalfModuleComponentHybrid(HPSTestRunTracker2014GeomDef.TestRunHalfModule mother) {
+ private void makeHalfModuleComponentHybrid(HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule mother) {
if(isDebug()) System.out.printf("%s: makeHalfModuleComponentHybrid for %s \n", this.getClass().getSimpleName(), mother.getName());
String volName = mother.getName() + "_hybrid";
// Build the half-module
- HPSTestRunTracker2014GeomDef.Hybrid hybrid = new HPSTestRunTracker2014GeomDef.Hybrid(volName,mother);
+ HPSTestRunTracker2014GeometryDefinition.Hybrid hybrid = new HPSTestRunTracker2014GeometryDefinition.Hybrid(volName,mother);
hybrid.setMaterial("G10");
- HalfModuleBundle hm = getHalfModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother(), mother.getName());
+ HalfModuleBundle hm = getHalfModuleBundle((HPSTestRunTracker2014GeometryDefinition.TestRunModule) mother.getMother(), mother.getName());
hm.hybrid = hybrid;
if(isDebug()) System.out.printf("%s: added hybrid to half-module with name %s \n", this.getClass().getSimpleName(), hm.halfModule.getName());
@@ -230,85 +254,77 @@
}
-
-
-private void makeHalfModuleComponentCF(HPSTestRunTracker2014GeomDef.TestRunHalfModule mother) {
-
- if(isDebug()) System.out.printf("%s: makeHalfModuleComponentCF for %s \n", this.getClass().getSimpleName(), mother.getName());
-
-
+
+
+ private void makeHalfModuleComponentCF(HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule mother) {
+
+ if(isDebug()) System.out.printf("%s: makeHalfModuleComponentCF for %s \n", this.getClass().getSimpleName(), mother.getName());
+
+
String volName = mother.getName() + "_cf";
// Build the half-module
- HPSTestRunTracker2014GeomDef.CarbonFiber cf = new HPSTestRunTracker2014GeomDef.CarbonFiber(volName,mother);
+ HPSTestRunTracker2014GeometryDefinition.CarbonFiber cf = new HPSTestRunTracker2014GeometryDefinition.CarbonFiber(volName,mother);
cf.setMaterial("CarbonFiber");
- HalfModuleBundle hm = getHalfModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother(), mother.getName());
+ HalfModuleBundle hm = getHalfModuleBundle((HPSTestRunTracker2014GeometryDefinition.TestRunModule) mother.getMother(), mother.getName());
hm.carbonFiber = cf;
-
-}
+ }
-
-
-private void makeHalfModuleComponentKapton(HPSTestRunTracker2014GeomDef.TestRunHalfModule mother) {
-
- if(isDebug()) System.out.printf("%s: makeHalfModuleComponentKapton for %s \n", this.getClass().getSimpleName(), mother.getName());
-
- String volName = mother.getName() + "_lamination";
- // Build the half-module
- HPSTestRunTracker2014GeomDef.HalfModuleLamination lamination = new HPSTestRunTracker2014GeomDef.HalfModuleLamination(volName,mother);
- lamination.setMaterial("Kapton");
+
+
+ private void makeHalfModuleComponentKapton(HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule mother) {
+
+ if(isDebug()) System.out.printf("%s: makeHalfModuleComponentKapton for %s \n", this.getClass().getSimpleName(), mother.getName());
+
+ String volName = mother.getName() + "_lamination";
+
+ // Build the half-module
+ HPSTestRunTracker2014GeometryDefinition.HalfModuleLamination lamination = new HPSTestRunTracker2014GeometryDefinition.HalfModuleLamination(volName,mother);
+ lamination.setMaterial("Kapton");
+
- HalfModuleBundle hm = getHalfModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother(), mother.getName());
- hm.lamination = lamination;
-
-}
+ HalfModuleBundle hm = getHalfModuleBundle((HPSTestRunTracker2014GeometryDefinition.TestRunModule) mother.getMother(), mother.getName());
+ hm.lamination = lamination;
+ }
-private void makeHalfModuleComponentSensor(HPSTestRunTracker2014GeomDef.TestRunHalfModule mother) {
- if(isDebug()) System.out.printf("%s: makeHalfModuleComponentSensor for %s \n", this.getClass().getSimpleName(), mother.getName());
+ private void makeHalfModuleComponentSensor(HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule mother) {
- String volName = mother.getName() + "_sensor";
+ if(isDebug()) System.out.printf("%s: makeHalfModuleComponentSensor for %s \n", this.getClass().getSimpleName(), mother.getName());
- // sensor if
- int sensor_number = 0;
+ String volName = mother.getName() + "_sensor";
- //
- HPSTestRunTracker2014GeomDef.Sensor sensor = new HPSTestRunTracker2014GeomDef.Sensor(volName, mother, sensor_number);
- sensor.setMaterial("Silicon");
-
- HalfModuleBundle hm = getHalfModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother(), mother.getName());
- hm.sensor = sensor;
+ // sensor if
+ int sensor_number = 0;
- makeHalfModuleComponentActiveSensor(sensor);
+ //
+ HPSTestRunTracker2014GeometryDefinition.Sensor sensor = new HPSTestRunTracker2014GeometryDefinition.Sensor(volName, mother, sensor_number);
+ sensor.setMaterial("Silicon");
+
+ HalfModuleBundle hm = getHalfModuleBundle((HPSTestRunTracker2014GeometryDefinition.TestRunModule) mother.getMother(), mother.getName());
+ hm.sensor = sensor;
+
+ makeHalfModuleComponentActiveSensor(sensor);
-}
+ }
+
- private void makeHalfModuleComponentActiveSensor(HPSTestRunTracker2014GeomDef.Sensor mother) {
+ private void makeHalfModuleComponentActiveSensor(HPSTestRunTracker2014GeometryDefinition.Sensor mother) {
if(isDebug()) System.out.printf("%s: makeHalfModuleComponentActiveSensor for %s \n", this.getClass().getSimpleName(), mother.getName());
String volName = mother.getName() + "_active";
- // Build the half-module
- HPSTestRunTracker2014GeomDef.ActiveSensor active_sensor = new HPSTestRunTracker2014GeomDef.ActiveSensor(volName, mother);
+ HPSTestRunTracker2014GeometryDefinition.ActiveSensor active_sensor = new HPSTestRunTracker2014GeometryDefinition.ActiveSensor(volName, mother);
active_sensor.setMaterial("Silicon");
-// PhysVol physVolume = new PhysVol(volume, motherVolume, pos, rot);
-//
-// volume.setSensitiveDetector(sens);
-// physVolume.addPhysVolID("sensor", sensor_number);
-// physVolume.addPhysVolID("system", 0);
-// physVolume.addPhysVolID("barrel", 0);
-// physVolume.addPhysVolID("layer", layer);
-// physVolume.addPhysVolID("module", layer);
-//
- HalfModuleBundle hm = getHalfModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother().getMother(), mother.getMother().getName());
+ HalfModuleBundle hm = getHalfModuleBundle((HPSTestRunTracker2014GeometryDefinition.TestRunModule) mother.getMother().getMother(), mother.getMother().getName());
hm.activeSensor = active_sensor;
}
@@ -316,7 +332,7 @@
- private static String getHalfFromName(String name) {
+ public static String getHalfFromName(String name) {
String half = "";
if(name.contains("bottom")) {
half = "bottom";
@@ -356,10 +372,10 @@
}
- private static int getLayerFromVolumeName(String name) {
+ public static int getLayerFromVolumeName(String name) {
int layer = -1;
for(int i=1; i<= 5; ++i) {
- if(name.contains(String.format("_L%d", i))) {
+ if(name.contains(String.format("module_L%d", i))) {
layer = i;
}
}
@@ -370,7 +386,28 @@
return layer;
}
+ public static boolean isHalfModule(String name) {
+ if(name.endsWith("halfmodule_axial") || name.endsWith("halfmodule_stereo")) {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isSensor(String name) {
+ if(name.endsWith("sensor")) {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isActiveSensor(String name) {
+ if(name.endsWith("sensor_active")) {
+ return true;
+ }
+ return false;
+ }
+
/**
@@ -381,7 +418,7 @@
protected <T> T getItem(Class<T> c) {
///if(isDebug()) System.out.printf("%s: get Item %s\n", this.getClass().getSimpleName(),c.getName());
- for(HPSTestRunTracker2014GeomDef.BaseGeom item : trackerItems) {
+ for(HPSTestRunTracker2014GeometryDefinition.BaseGeometry item : trackerItems) {
//if(isDebug()) System.out.printf("%s: item %s\n", getClass().getSimpleName(),item.getClass().getName());
if(c.isInstance(item)) {
return (T)item;
@@ -407,19 +444,19 @@
* @author Per Hansson Adrian <[log in to unmask]>
*
*/
- protected static class ModuleBundle {
- protected HPSTestRunTracker2014GeomDef.TestRunModule module = null;
- protected HalfModuleBundle halfModuleAxial = null;
- protected HalfModuleBundle halfModuleStereo = null;
- protected HPSTestRunTracker2014GeomDef.TestRunColdBlock coldBlock = null;
- ModuleBundle(HPSTestRunTracker2014GeomDef.TestRunModule m) {
+ public static class ModuleBundle {
+ public TestRunModule module = null;
+ public HalfModuleBundle halfModuleAxial = null;
+ public HalfModuleBundle halfModuleStereo = null;
+ protected TestRunColdBlock coldBlock = null;
+ ModuleBundle(TestRunModule m) {
module = m;
}
- int getLayer() {
+ public int getLayer() {
if(module==null) throw new RuntimeException("Need to add module to bundle first!");
return getLayerFromVolumeName(module.getName());
}
- String getHalf() {
+ public String getHalf() {
if(module==null) throw new RuntimeException("Need to add module to bundle first!");
return getHalfFromName(module.getName());
}
@@ -427,25 +464,25 @@
* Find mother to this module.
* @return mother
*/
- public BaseGeom getMother() {
+ public BaseGeometry getMother() {
if(module==null) throw new RuntimeException("Need to add module to bundle first!");
return module.getMother();
}
public void print() {
- System.out.printf("%s: %s\n", this.getClass().getSimpleName(),module.getName());
- halfModuleAxial.print();
- System.out.printf("%s: %s\n", this.getClass().getSimpleName(),coldBlock.getName());
- halfModuleStereo.print();
+ if(module!=null) System.out.printf("%s: %s\n", this.getClass().getSimpleName(),module.getName());
+ if(halfModuleAxial!=null) halfModuleAxial.print();
+ if(coldBlock!=null)System.out.printf("%s: %s\n", this.getClass().getSimpleName(),coldBlock.getName());
+ if(halfModuleStereo!=null) halfModuleStereo.print();
}
}
- protected static class HalfModuleBundle {
- protected HPSTestRunTracker2014GeomDef.TestRunHalfModule halfModule = null;
- protected HPSTestRunTracker2014GeomDef.Sensor sensor = null;
- protected HPSTestRunTracker2014GeomDef.ActiveSensor activeSensor = null;
- protected HPSTestRunTracker2014GeomDef.HalfModuleLamination lamination = null;
- protected HPSTestRunTracker2014GeomDef.CarbonFiber carbonFiber = null;
- protected HPSTestRunTracker2014GeomDef.Hybrid hybrid = null;
- HalfModuleBundle(HPSTestRunTracker2014GeomDef.TestRunHalfModule hm) {
+ public static class HalfModuleBundle {
+ public HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule halfModule = null;
+ public HPSTestRunTracker2014GeometryDefinition.Sensor sensor = null;
+ public HPSTestRunTracker2014GeometryDefinition.ActiveSensor activeSensor = null;
+ protected HPSTestRunTracker2014GeometryDefinition.HalfModuleLamination lamination = null;
+ protected HPSTestRunTracker2014GeometryDefinition.CarbonFiber carbonFiber = null;
+ protected HPSTestRunTracker2014GeometryDefinition.Hybrid hybrid = null;
+ HalfModuleBundle(HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule hm) {
halfModule = hm;
}
public void print() {
@@ -474,7 +511,7 @@
* @param module - to find
* @return bundle
*/
- protected ModuleBundle getModuleBundle(HPSTestRunTracker2014GeomDef.TestRunModule module) {
+ protected ModuleBundle getModuleBundle(HPSTestRunTracker2014GeometryDefinition.TestRunModule module) {
return getModuleBundle(module.getLayer(), module.getHalf());
}
@@ -483,7 +520,7 @@
* @param module - to find
* @return bundle
*/
- protected HalfModuleBundle getHalfModuleBundle(HPSTestRunTracker2014GeomDef.TestRunModule module, String halfModuleName) {
+ protected HalfModuleBundle getHalfModuleBundle(HPSTestRunTracker2014GeometryDefinition.TestRunModule module, String halfModuleName) {
ModuleBundle m = getModuleBundle(module.getLayer(), module.getHalf());
HalfModuleBundle hm = null;
if(m!=null) {
@@ -510,4 +547,21 @@
}
+ /**
+ * Checks if the orientation of the sensor is axial.
+ * Uses the moduleId definition from the "old" geometry for
+ * consistency.
+ *
+ * @return true if it is, false if it is a stereo sensor
+ */
+ private boolean isAxial(boolean isTopLayer, int layer) {
+ if (isTopLayer && layer % 2 == 1) {
+ return true;
+ } else if (!isTopLayer && layer % 2 == 0) {
+ return true;
+ }
+ return false;
+ }
+
+
}
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/HPSTestRunTracker2014GeomDef.java 2014-08-18 20:46:54 UTC (rev 3269)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014GeomDef.java 2014-08-19 00:32:47 UTC (rev 3270)
@@ -1,1342 +0,0 @@
-/**
- *
- */
-package org.lcsim.geometry.compact.converter.lcdd;
-
-import org.lcsim.detector.Rotation3D;
-import org.lcsim.detector.Transform3D;
-import org.lcsim.detector.Translation3D;
-import org.lcsim.geometry.compact.converter.lcdd.util.Box;
-
-import hep.physics.vec.BasicHep3Matrix;
-import hep.physics.vec.BasicHep3Vector;
-import hep.physics.vec.Hep3Vector;
-import hep.physics.vec.VecOp;
-
-/**
- *
- * Class containing geometry information for HPS Test run tracker 2014
- *
- * @author Per Hansson Adrian <[log in to unmask]>
- *
- */
-
-public class HPSTestRunTracker2014GeomDef {
-
- //General
- private static final double inch = 25.4; //mm
-
- // Global position references
- private static final double target_pos_wrt_base_plate_x = 162.3; //from Marco's 3D model
- private static final double target_pos_wrt_base_plate_y = 80.55; //from Tim's sketchup //68.75; //from Marco's 3D model
- private static final double target_pos_wrt_base_plate_z = 926.59; //from Marco's 3D model
- protected static final double PS_vac_box_inner_height = 7.0*inch;
-
-
-
- /**
- *
- * Base geometry class for generating volumes based on survey information.
- *
- */
- protected static abstract class BaseGeom {
- private String name;
- private String material = "Vacuum";
- private BaseGeom mother;
- // The reference geometry is used when the survey points are w.r.t. to
- // a different/intermediate coord system. So that transformation has to be used when
- // transforming to the mother system
- private BaseGeom referenceGeom;
- private Coord coord;
- protected Hep3Vector ballPos;
- protected Hep3Vector veePos;
- protected Hep3Vector flatPos;
- private Hep3Vector center;
- private Hep3Vector boxDim;
- //store explicit rotations - if exist should be used instead of those extracted from coord
- // TODO This is a workaround as I should really rotate the coord system to make things consistent. Figure this out later.
- protected Hep3Vector lcdd_rot_angles = null;
-
- public BaseGeom(String name, BaseGeom m) {
- setName(name);
- setMother(m);
- setReferenceGeom(null);
- }
- public BaseGeom(String name, BaseGeom m, BaseGeom ref) {
- setName(name);
- setMother(m);
- setReferenceGeom(ref);
- }
-
- protected abstract void setPos();
- protected abstract void setCoord();
- protected abstract void setCenter();
- protected abstract void setBoxDim();
-
- protected void init() {
- setPos();
- setCoord();
- setCenter();
- setBoxDim();
- }
- public void setBallPos(double x, double y, double z) {
- ballPos = new BasicHep3Vector(x,y,z);
- }
- public void setVeePos(double x, double y, double z) {
- veePos = new BasicHep3Vector(x,y,z);
- }
- public void setFlatPos(double x, double y, double z) {
- flatPos = new BasicHep3Vector(x,y,z);
- }
- public Hep3Vector getBallPos() {
- return ballPos;
- }
- public Hep3Vector getVeePos() {
- return veePos;
- }
- public Hep3Vector getFlatPos() {
- return flatPos;
- }
- public void setCoord(Hep3Vector origin) {
- if(ballPos==null || veePos==null || flatPos==null) {
- throw new RuntimeException("Need to set ball, vee and flat before building coord system!");
- }
- if(origin!=null) {
- coord = new Coord(origin, ballPos, veePos, flatPos);
- } else {
- coord = new Coord(ballPos, veePos, flatPos);
- }
- }
- public Coord getCoord() {
- if(coord == null) {
- throw new RuntimeException("Need to setCoord!");
- }
- return coord;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public Hep3Vector getCenter() {
- return center;
- }
- public void setCenter(Hep3Vector center) {
- this.center = center;
- }
- public void setCenter(double x, double y, double z) {
- this.center = new BasicHep3Vector(x,y,z);
- }
- public Hep3Vector getBoxDim() {
- return boxDim;
- }
- public void setBoxDim(double x, double y, double z) {
- this.boxDim = new BasicHep3Vector(x,y,z);
- }
- public BaseGeom getMother() {
- return mother;
- }
- public void setMother(BaseGeom mother) {
- this.mother = mother;
- }
- public BaseGeom getReferenceGeom() {
- return referenceGeom;
- }
- public void setReferenceGeom(BaseGeom referenceGeom) {
- this.referenceGeom = referenceGeom;
- }
- public void printSurveyPos() {
- System.out.printf("Survey pos for %s:\n",getName());
- System.out.printf("ballPos %s\n", ballPos.toString());
- System.out.printf("veePos %s\n", veePos.toString());
- System.out.printf("flatPos %s\n", flatPos.toString());
- }
- public String getMaterial() {
- return material;
- }
- public void setMaterial(String material) {
- this.material = material;
- }
-
- }
-
-
- /**
- * Tracking volume geometry definition.
- */
- public static class TrackingBase extends BaseGeom {
- public TrackingBase(String name, BaseGeom mother) {
- super(name,mother);
- init();
- }
- protected void setPos() {
- // Dummy survey positions to setup a coordinate system
- ballPos = new BasicHep3Vector(1,0,0);
- veePos = new BasicHep3Vector(0,1,0);
- flatPos = new BasicHep3Vector(0,0,1);
- }
- protected void setCoord() {
- // at the origin
- setCoord(new BasicHep3Vector(0,0,0));
- }
- protected void setCenter() {
- // at the origin
- setCenter(new BasicHep3Vector(0,0,0));
- }
- protected void setBoxDim() {
- // do nothing since we are not building a tracking volume
- }
- }
-
- public static class Base extends BaseGeom {
- // height of the dummy box holding the entire SVT:
- // this means the bottom of the base plate to the the inner surface of of the PS vac box for now
- protected static final double base_height = PS_vac_box_inner_height - BasePlate.base_plate_offset_height;
- protected static final double base_width = BasePlate.base_plate_width;
- protected static final double base_length = BasePlate.base_plate_length;
-
- public Base(String name, BaseGeom mother) {
- super(name,mother);
- init();
- }
- protected void setPos() {
- final double ball_pos_base_x = -1.0*target_pos_wrt_base_plate_x;
- final double ball_pos_base_y = -1.0*target_pos_wrt_base_plate_y;
- final double ball_pos_base_z = target_pos_wrt_base_plate_z;
- final double vee_pos_base_x = ball_pos_base_x + BasePlate.base_plate_width;
- final double vee_pos_base_y = ball_pos_base_y;
- final double vee_pos_base_z = ball_pos_base_z;
- final double flat_pos_base_x = ball_pos_base_x;
- final double flat_pos_base_y = ball_pos_base_y;
- final double flat_pos_base_z = ball_pos_base_z - BasePlate.base_plate_length;
- setBallPos(ball_pos_base_x,ball_pos_base_y,ball_pos_base_z);
- setVeePos(vee_pos_base_x,vee_pos_base_y,vee_pos_base_z);
- setFlatPos(flat_pos_base_x, flat_pos_base_y, flat_pos_base_z);
- }
- protected void setCoord() {
- setCoord(null);
- }
- protected void setCenter() {
- setCenter(base_width/2.0, base_length/2.0, base_height/2.0 - BasePlate.base_plate_thickness);
- }
- protected void setBoxDim() {
- setBoxDim(base_width,base_length,base_height);
- }
- }
-
-
-
- public static class BasePlate extends BaseGeom {
- // Base plate references
- protected static final double base_plate_thickness = 0.25*inch;
- protected static final double base_plate_width = 385.00;
- protected static final double base_plate_length = 1216.00;
- //height from vacuum chamber surface
- protected static final double base_plate_offset_height = 2.0; //from Marco's 3D model
- public BasePlate(String name, BaseGeom mother, String material) {
- super(name,mother);
- init();
- setMaterial(material);
- }
- protected void setPos() {
- setBallPos(0,0,0);
- setVeePos(base_plate_width,ballPos.y(),ballPos.z());
- setFlatPos(ballPos.x(),base_plate_length,ballPos.z());
- }
- protected void setCoord() {
- setCoord(null);
- }
- protected void setCenter() {
- setCenter(base_plate_width/2.0, base_plate_length/2.0, -base_plate_thickness/2.0);
- }
- protected void setBoxDim() {
- setBoxDim(base_plate_width,base_plate_length, base_plate_thickness);
- }
- }
-
-
-
-
- public static class CSupport extends BaseGeom {
- // This is the sequence of locating the support plate positions:
- // The c-support pin positions are found
- // the points on the axis of rotation are used as references for building the box surrounding the support plates (incl sensors).
- // this should make it more straightforward when applying a tilt angle
- // c-support:
- // ball position is C-support pin position on electron side on the base plate surface
- // vee position is C-support pin position on positron side on the base plate surface
- // flat position is a randomly chosen point perpendicular to ball to vee vector and offset 10mm along the plate.
- // Note that the flat here sets the tilt angle of the support plates.
-
- // c-support references
- // pin position on base plate surface
- private static final double ball_pos_csup_pin_bottom_x = 51.15;
- private static final double ball_pos_csup_pin_bottom_y = 115.02;
- private static final double ball_pos_csup_pin_bottom_z = 0.0;
- private static final double vee_pos_csup_pin_bottom_x = 271.05;
- private static final double vee_pos_csup_pin_bottom_y = 121.62;
- private static final double vee_pos_csup_pin_bottom_z = 0.0;
-
-
- public CSupport(String name, BaseGeom mother) {
- super(name,mother);
- init();
- }
- private void calcAndSetFlatPos() {
- // find the rotation to place the flat point
- org.apache.commons.math3.geometry.euclidean.threed.Rotation rot1_csup =
- new org.apache.commons.math3.geometry.euclidean.threed.Rotation(
- new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(vee_pos_csup_pin_bottom_x-ball_pos_csup_pin_bottom_x,
- vee_pos_csup_pin_bottom_y-ball_pos_csup_pin_bottom_y,
- vee_pos_csup_pin_bottom_z-ball_pos_csup_pin_bottom_z),
- new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(1,0,0));
-
- org.apache.commons.math3.geometry.euclidean.threed.Vector3D flat_pos_csup_pin_bottom_3D_rot = rot1_csup.applyTo(new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(0,10.0,0));
- // translate
- double flat_pos_csup_pin_bottom_x = ball_pos_csup_pin_bottom_x + flat_pos_csup_pin_bottom_3D_rot.getX();
- double flat_pos_csup_pin_bottom_y = ball_pos_csup_pin_bottom_y + flat_pos_csup_pin_bottom_3D_rot.getY();
- double flat_pos_csup_pin_bottom_z = ball_pos_csup_pin_bottom_z + flat_pos_csup_pin_bottom_3D_rot.getZ();
- setFlatPos(flat_pos_csup_pin_bottom_x,flat_pos_csup_pin_bottom_y,flat_pos_csup_pin_bottom_z);
- }
- protected void setPos() {
- setBallPos(ball_pos_csup_pin_bottom_x,ball_pos_csup_pin_bottom_y,ball_pos_csup_pin_bottom_z);
- setVeePos(vee_pos_csup_pin_bottom_x,vee_pos_csup_pin_bottom_y,vee_pos_csup_pin_bottom_z);
- calcAndSetFlatPos();
- }
- protected void setCoord() {
- setCoord(null);
- }
- protected void setCenter() {
- // this is never used since it's only a reference volume
- setCenter(null);
- }
- protected void setBoxDim() {
- }
-
- }
-
-
-
-
- public static class SupportTop extends BaseGeom {
- // Top only needs a vertical offset to be specified
- private static final double ball_pos_csup_bearings_top_z = 146.4;
- //these are for the box surrounding the whole support including modules
- protected static final double support_top_length = SupportBottom.support_bottom_length;
- protected static final double support_top_width = SupportBottom.support_bottom_width;
- protected static final double support_top_height = SupportBottom.support_bottom_height;
-
- public SupportTop(String name, BaseGeom mother) {
- super(name,mother);
- init();
- }
- public SupportTop(String name, BaseGeom mother, BaseGeom referenceGeom) {
- super(name,mother,referenceGeom);
- init();
- }
-
- protected void setPos() {
- System.out.printf("setPos support top\n");
- // the top has the same bearing positions as the bottom c-support except for the offset vertically from base plate
- // the tilt angle is independent though.
- setBallPos(SupportBottom.ball_pos_csup_bearings_bottom_x, SupportBottom.ball_pos_csup_bearings_bottom_y, ball_pos_csup_bearings_top_z);
- setVeePos(SupportBottom.vee_pos_csup_bearings_bottom_x, SupportBottom.vee_pos_csup_bearings_bottom_y, ball_pos_csup_bearings_top_z);
- // build the rotation to find the proper location of the flat
- org.apache.commons.math3.geometry.euclidean.threed.Rotation rot_csup_top =
- new org.apache.commons.math3.geometry.euclidean.threed.Rotation(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ,
- SupportPlateTop.support_plate_top_tilt_angle, 0.0, 0.0 );
-
- // apply to flat local position (as for bottom it is arbitrary offset)
- org.apache.commons.math3.geometry.euclidean.threed.Vector3D flat_pos_csup_bearings_top_3D_rot =
- rot_csup_top.applyTo(new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(0.0,10.0,0.0));
-
- // translate the flat position
- final double flat_pos_csup_bearings_top_x = getBallPos().x() + flat_pos_csup_bearings_top_3D_rot.getX();
- final double flat_pos_csup_bearings_top_y = getBallPos().y() + flat_pos_csup_bearings_top_3D_rot.getY();
- final double flat_pos_csup_bearings_top_z = getBallPos().z() + flat_pos_csup_bearings_top_3D_rot.getZ();
- setFlatPos(flat_pos_csup_bearings_top_x,flat_pos_csup_bearings_top_y,flat_pos_csup_bearings_top_z);
-
- // since we don't care (no volume is built) about the local position of the bearings in the pin coord system we'll get rid of it
- // and find the bearings position in the base coordinate system directly
- BaseGeom ref = getReferenceGeom();
- if(ref==null) {
- throw new RuntimeException("No ref found for " + getName());
- }
-
- System.out.printf("before ref %s transform\n",ref.getName());
- printSurveyPos();
-
- System.out.printf("%s coord\n%s\n",ref.getName(),ref.getCoord().toString());
-
- ref.getCoord().getTransformation().transform(ballPos);
- ref.getCoord().getTransformation().transform(veePos);
- ref.getCoord().getTransformation().transform(flatPos);
-
- System.out.printf("after ref %s transform\n",ref.getName());
- printSurveyPos();
- }
- protected void setCoord() {
- setCoord(null);
- }
- protected void setCenter() {
- setCenter(support_top_width/2.0+1.0, support_top_length/2.0 + (17.00-10.50/2.0), -1.0 * (support_top_height/2.0 - (12.70-6.66-1.34)));
- }
- protected void setBoxDim() {
- setBoxDim(support_top_width,support_top_length,support_top_height);
- }
- }
-
-
-
- public static class SupportBottom extends BaseGeom {
- // "bearings" are points on axis of rotation on the inside of the c-support frame where the insert get's attached
- // this is referenced to the pin position of the c-support
- private static final double ball_pos_csup_bearings_bottom_x = 240.0 - 265.0 + 14.0;
- private static final double ball_pos_csup_bearings_bottom_y = (-6.0 + 22.0);
- private static final double ball_pos_csup_bearings_bottom_z = 14.7;
- private static final double vee_pos_csup_bearings_bottom_x = 240.0- 129.0;
- private static final double vee_pos_csup_bearings_bottom_y = (-6.0 + 22.0);
- private static final double vee_pos_csup_bearings_bottom_z = 14.7;
-
- //these are for the box surrounding the whole support including modules
- protected static final double support_bottom_length = SupportPlateBottom.support_plate_bottom_length;
- protected static final double support_bottom_width = (25.0-5.0) + TestRunModuleL13.module_box_L13_length;
- protected static final double support_bottom_height = SupportPlateBottom.support_plate_bottom_height - SupportPlateBottom.support_plate_pocket_depth + TestRunModuleL13.module_box_L13_width + SupportPlateBottom.pedestal_height_L1;
-
-
- public SupportBottom(String name, BaseGeom mother, BaseGeom referenceGeom) {
- super(name,mother,referenceGeom);
- init();
- }
-
- protected void setPos() {
-
- System.out.printf("setPos support bottom\n");
-
- // now create the support box which will have it's coordinates at the rotation axis so that the flat determines the tilt of the plates
- // it is referenced locally to the c-support pin coordinate system here
-
- // build the rotation to find the proper location of the flat
- org.apache.commons.math3.geometry.euclidean.threed.Rotation rot_csup =
- new org.apache.commons.math3.geometry.euclidean.threed.Rotation(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ,
- SupportPlateBottom.support_plate_bottom_tilt_angle, 0.0, 0.0 );
- // apply to flat local position
- org.apache.commons.math3.geometry.euclidean.threed.Vector3D flat_pos_csup_bearings_bottom_3D_rot =
- rot_csup.applyTo(new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(0.0,10.0,0.0));
- // translate
- final double flat_pos_csup_bearings_bottom_x = ball_pos_csup_bearings_bottom_x + flat_pos_csup_bearings_bottom_3D_rot.getX();
- final double flat_pos_csup_bearings_bottom_y = ball_pos_csup_bearings_bottom_y + flat_pos_csup_bearings_bottom_3D_rot.getY();
- final double flat_pos_csup_bearings_bottom_z = ball_pos_csup_bearings_bottom_z + flat_pos_csup_bearings_bottom_3D_rot.getZ();
-
- // make vectors
- setBallPos(ball_pos_csup_bearings_bottom_x,ball_pos_csup_bearings_bottom_y,ball_pos_csup_bearings_bottom_z);
- setVeePos(vee_pos_csup_bearings_bottom_x,vee_pos_csup_bearings_bottom_y,vee_pos_csup_bearings_bottom_z);
- setFlatPos(flat_pos_csup_bearings_bottom_x,flat_pos_csup_bearings_bottom_y,flat_pos_csup_bearings_bottom_z);
-
-
- // create the coordinate system of the c-support bearings
- //HPSTestRunTracker2014GeomDef.Coord csup_bearings_bottom_coord = new HPSTestRunTracker2014GeomDef.Coord(ball_pos_csup_bearings_bottom, vee_pos_csup_bearings_bottom, flat_pos_csup_bearings_bottom);
-
- // since we don't care (no volume is built) about the local position of the bearings in the pin coord system we'll get rid of it
- // and find the bearings position in the base coordinate system directly
- BaseGeom ref = getReferenceGeom();
- if(ref==null) {
- throw new RuntimeException("No ref found for " + getName());
- }
-
- System.out.printf("before ref %s transform\n",ref.getName());
- printSurveyPos();
-
- System.out.printf("%s coord\n%s\n",ref.getName(),ref.getCoord().toString());
-
- ref.getCoord().getTransformation().transform(ballPos);
- ref.getCoord().getTransformation().transform(veePos);
- ref.getCoord().getTransformation().transform(flatPos);
-
- System.out.printf("after ref %s transform\n",ref.getName());
- printSurveyPos();
-
- }
- protected void setCoord() {
- setCoord(null);
- }
- protected void setCenter() {
- setCenter(support_bottom_width/2.0+1.0, support_bottom_length/2.0 + (17.00-10.50/2.0), support_bottom_height/2.0 - (12.70-6.66-1.34));
- }
- protected void setBoxDim() {
- setBoxDim(support_bottom_width,support_bottom_length,support_bottom_height);
- }
-
- }
-
-
- protected static abstract class SupportPlate extends BaseGeom {
- protected static final double support_plate_pocket_depth = 6.65; // Tim's sketchup, drawing says 6.66mm?
- protected static final double pedestal_height_L1 = 11.00;
- protected static final double pedestal_height_L2 = 9.50;
- protected static final double pedestal_height_L3 = 8.00;
- protected static final double pedestal_height_L4 = 10.00;
- protected static final double pedestal_height_L5 = 7.00;
- public SupportPlate(BaseGeom mother, String name, String material) {
- super(name,mother);
- setMaterial(material);
- }
-
- }
-
-
-
-
-
- public static class SupportPlateBottom extends SupportPlate {
- // support plate references
- // use a settable rotation to effectively determine the flat and therefore the tilt of the support
- protected static final double support_plate_bottom_tilt_angle = 0.0;
- protected static final double support_plate_bottom_height = 12.7;
- protected static final double support_plate_bottom_length = 736.1;
- protected static final double support_plate_bottom_width = 120.0;
-
- public SupportPlateBottom(String name, BaseGeom mother, String material) {
- super(mother,name, material);
- init();
-
- }
- protected void setPos() {
- ballPos = new BasicHep3Vector(1.0, (17.0-5.0), 6.66+1.34);
- veePos = new BasicHep3Vector(ballPos.x() + support_plate_bottom_length, ballPos.y(),ballPos.z());
- flatPos = new BasicHep3Vector(ballPos.x(), ballPos.y() + support_plate_bottom_length,ballPos.z());
- }
- protected void setCoord() {
- setCoord(null);
- }
- protected void setCenter() {
- setCenter(support_plate_bottom_width/2.0, support_plate_bottom_length/2.0, -1.0 * support_plate_bottom_height/2.0);
- }
- @Override
- protected void setBoxDim() {
- setBoxDim(support_plate_bottom_width,support_plate_bottom_length,support_plate_bottom_height);
- }
- }
-
-
- public static class SupportPlateTop extends SupportPlate {
- // support plate references
- // use a settable rotation to effectively determine the flat and therefore the tilt of the support
- protected static final double support_plate_top_tilt_angle = 0.0;
- protected static final double support_plate_top_length = SupportPlateBottom.support_plate_bottom_length;
- protected static final double support_plate_top_width = SupportPlateBottom.support_plate_bottom_width;
- protected static final double support_plate_top_height = SupportPlateBottom.support_plate_bottom_height;
-
- public SupportPlateTop(String name, BaseGeom mother, String material) {
- super(mother,name,material);
- init();
- }
- protected void setPos() {
- ballPos = new BasicHep3Vector(1.0, (17.0-5.0), -1.0 * (6.66+1.34));
- veePos = new BasicHep3Vector(ballPos.x() + support_plate_top_width, ballPos.y(),ballPos.z());
- flatPos = new BasicHep3Vector(ballPos.x(), ballPos.y() + support_plate_top_length,ballPos.z());
- }
- protected void setCoord() {
- setCoord(null);
- }
- protected void setCenter() {
- setCenter(support_plate_top_width/2.0, support_plate_top_length/2.0, support_plate_top_height/2.0);
- }
- @Override
- protected void setBoxDim() {
- setBoxDim(support_plate_top_width, support_plate_top_length, support_plate_top_height);
- }
- }
-
-
-
-
- public static class TestRunModuleL45 extends TestRunModule {
- protected static final double module_box_L45_length = 205.2; // includes lexan spacer and cold block
- protected static final double module_box_L45_height = 12.5; // includes screws height
- protected static final double module_box_L45_width = 65.3-12.0;
- protected static final double dist_lower_sensor_edge_to_cold_block_mounting_surface = 7.662;
-
-
- public TestRunModuleL45(String name, BaseGeom mother, int layer,String half) {
- super(name, mother, layer, half);
- }
- public TestRunModuleL45(String name, BaseGeom mother, BaseGeom ref, int layer, String half) {
- super(name, mother, ref, layer, half);
- }
- protected double getColdBlockThickness() {
- return TestRunColdBlockL45.coldblock_L45_thickness;
- }
- protected double getModuleBoxLength() {
- return module_box_L45_length;
- }
- protected double getModuleBoxWidth() {
- return module_box_L45_width;
- }
- protected double getModuleBoxHeight() {
- return module_box_L45_height;
- }
- protected double get_dist_lower_sensor_edge_to_cold_block_mounting_surface() {
- return dist_lower_sensor_edge_to_cold_block_mounting_surface;
- }
-
- }
-
- public static class TestRunModuleL13 extends TestRunModule {
- // module references
- protected static final double module_box_L13_length = 205.2; // includes lexan spacer and cold block
- protected static final double module_box_L13_height = 12.5; // includes screws height
- protected static final double module_box_L13_width = 71.3 - 13.0; // height from cold block to encapsulate the whole module
- protected static final double dist_lower_sensor_edge_to_cold_block_mounting_surface = 12.66;
-
- public TestRunModuleL13(String name, BaseGeom mother, int layer, String half) {
- super(name, mother, layer, half);
- }
- public TestRunModuleL13(String name, BaseGeom mother, BaseGeom ref, int layer, String half) {
- super(name, mother, ref, layer, half);
- }
- protected double getColdBlockThickness() {
- return TestRunColdBlockL13.coldblock_L13_thickness;
- }
- protected double getModuleBoxLength() {
- return module_box_L13_length;
- }
- protected double getModuleBoxWidth() {
- return module_box_L13_width;
- }
- protected double getModuleBoxHeight() {
- return module_box_L13_height;
- }
- protected double get_dist_lower_sensor_edge_to_cold_block_mounting_surface() {
- return dist_lower_sensor_edge_to_cold_block_mounting_surface;
- }
- }
-
-
- public static abstract class TestRunModule extends BaseModule {
- public TestRunModule(String name, BaseGeom mother, int layer, String half) {
- super(name, mother,layer,half);
- init();
- }
- public TestRunModule(String name, BaseGeom mother, BaseGeom ref, int layer, String half) {
- super(name, mother,ref,layer,half);
- init();
- }
- protected abstract double getColdBlockThickness();
- protected abstract double getModuleBoxLength();
- protected abstract double getModuleBoxWidth();
- protected abstract double getModuleBoxHeight();
- protected abstract double get_dist_lower_sensor_edge_to_cold_block_mounting_surface();
-
- protected void setBoxDim() {
- setBoxDim(getModuleBoxLength(),getModuleBoxHeight(),getModuleBoxWidth());
- }
- protected void setCoord() {
- setCoord(null);
- }
- protected void setCenter() {
- setCenter(getModuleBoxLength()/2.0-5.0, 0.0, getModuleBoxWidth()/2.0);
- }
- protected void setPos() {
- // bottom
- if(isBottom()) {
- switch (getLayer()) {
- case 1:
- ballPos = new BasicHep3Vector(25.0, 661.1, HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L1-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth);
- veePos = new BasicHep3Vector(95.0, 661.1, HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L1-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth);
- flatPos = new BasicHep3Vector(60.0, 667.10, HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L1-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth);
- break;
- case 2:
- ballPos = new BasicHep3Vector(25.0, 561.1, HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L2-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth);
- veePos = new BasicHep3Vector(95.0, 561.1, HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L2-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth);
- flatPos = new BasicHep3Vector(60.0, 567.10, HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L2-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth);
- break;
- case 3:
- ballPos = new BasicHep3Vector(25.0, 461.1, HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L3-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth);
- veePos = new BasicHep3Vector(95.0, 461.1, HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L3-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth);
- flatPos = new BasicHep3Vector(60.0, 467.10, HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L3-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth);
- break;
- case 4:
- ballPos = new BasicHep3Vector(25.0, 261.1, HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L4-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth);
- veePos = new BasicHep3Vector(95.0, 261.1, HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L4-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth);
- flatPos = new BasicHep3Vector(60.0, 267.10, HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L4-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth);
- break;
- case 5:
- ballPos = new BasicHep3Vector(25.0, 61.1, HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L5-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth);
- veePos = new BasicHep3Vector(95.0, 61.1, HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L5-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth);
- flatPos = new BasicHep3Vector(60.0, 67.10, HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L5-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth);
- break;
- default:
- System.out.printf("ERROR invalid layer %d for half %s\n",getLayer(),getHalf());
- System.exit(1);
- break;
- }
-
- } else {
- // top
- // top has a fixed offset of 15mm along plate on module pocket positions w.r.t. bottom
- // top local coordinates is rotation pi around u-vec so need to adjust pocket depth coordinate
-
- switch (getLayer()) {
- case 1:
- ballPos = new BasicHep3Vector(25.0, 676.1, -1.0 * (HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L1-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth));
- veePos = new BasicHep3Vector(95.0, 676.1, -1.0 * (HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L1-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth));
- flatPos = new BasicHep3Vector(60.0, 670.1, -1.0 * (HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L1-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth));
- break;
- case 2:
- ballPos = new BasicHep3Vector(25.0, 576.1, -1.0 * (HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L2-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth));
- veePos = new BasicHep3Vector(95.0, 576.1, -1.0 * (HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L2-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth));
- flatPos = new BasicHep3Vector(60.0, 570.1, -1.0 * (HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L2-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth));
- break;
- case 3:
- ballPos = new BasicHep3Vector(25.0, 476.1, -1.0 * (HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L3-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth));
- veePos = new BasicHep3Vector(95.0, 476.1, -1.0 * (HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L3-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth));
- flatPos =new BasicHep3Vector(60.0, 470.1, -1.0 * (HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L3-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth));
- break;
- case 4:
- ballPos = new BasicHep3Vector(25.0, 276.1, -1.0 * (HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L4-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth));
- veePos = new BasicHep3Vector(95.0, 276.1, -1.0 * (HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L4-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth));
- flatPos = new BasicHep3Vector(60.0, 270.1, -1.0 * (HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L4-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth));
- break;
- case 5:
- ballPos = new BasicHep3Vector(25.0, 76.1, -1.0 * (HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L5-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth));
- veePos = new BasicHep3Vector(95.0, 76.1, -1.0 * (HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L5-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth));
- flatPos = new BasicHep3Vector(60.0, 70.1, -1.0 * (HPSTestRunTracker2014GeomDef.SupportPlateBottom.pedestal_height_L5-HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_pocket_depth));
- break;
- default:
- System.out.printf("ERROR invalid layer %d for half %s\n",getLayer(),getHalf());
- System.exit(1);
- break;
- }
- }
-
- System.out.printf("test run module in support plate coord\n");
- printSurveyPos();
-
- //
- // Note that the mother volume is the support wrap box which can be different than support plate coord system.
- // Thus I need to take that into account when making the modules by referencing through the support plate
- BaseGeom ref = getReferenceGeom();
- if(ref==null) {
- throw new RuntimeException("No reference geom found for " + getName());
- }
-
- System.out.printf("ref coord system %s\n%s\n",ref.getName(),ref.getCoord().toString());
-
-
- // transform the survey points
- ref.getCoord().getTransformation().transform(ballPos);
- ref.getCoord().getTransformation().transform(veePos);
- ref.getCoord().getTransformation().transform(flatPos);
-
- System.out.printf("test run module after support plate coord-> support coord transformation\n");
- printSurveyPos();
-
- }
-
- }
-
-
- public static abstract class BaseModule extends BaseGeom {
- private int layer;
- private String half;
-
- public BaseModule(String name, BaseGeom mother, int layer, String half) {
- super(name, mother);
- setLayer(layer);
- setHalf(half);
- isValid();
- }
- public BaseModule(String name, BaseGeom mother, BaseGeom ref, int layer, String half) {
- super(name, mother,ref);
- setLayer(layer);
- setHalf(half);
- isValid();
- }
- private void isValid() {
- if(half!="bottom" && half!="top") {
- System.out.printf("ERROR invalid half %s for BaseModule\n",half);
- System.exit(1);
- }
- }
- public int getLayer() {
- return layer;
- }
- public void setLayer(int layer) {
- this.layer = layer;
- }
-
- public String getHalf() {
- return half;
- }
-
- public void setHalf(String half) {
- this.half = half;
- }
-
- public boolean isBottom() {
- return getHalf() == "bottom" ? true : false;
- }
-
- }
-
-
-
- public abstract static class TestRunHalfModule extends BaseModule {
-
- // 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 coordinate system 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.
-
- // Distance from sensor to CF edge: 180mm
- // Distance from CF edge to screw hole: 30mm
- // Distance from screw hole to edge of cold block: 33.75mm
- // Distance from edge of cold block to hole/ball position: 5mm
- protected static final double dist_sensor_center_to_coldblock_hole_vdir = (180.0 - 30.0 + (33.75 - 5.0)) - Sensor.sensor_length/2.0;
- protected static final double half_module_thickness = HPSTestRunTracker2014GeomDef.TestRunHalfModule.getHybridThickness() + HPSTestRunTracker2014GeomDef.TestRunHalfModule.getCFThickness() + HalfModuleLamination.kapton_thickness;
- protected static final double half_module_length = HPSTestRunTracker2014GeomDef.TestRunHalfModule.getCFLength();
- protected static final double half_module_width = 6.83 + HPSTestRunTracker2014GeomDef.Sensor.getSensorWidth();
-
- protected double stereo_angle = 0.0;
-
- public TestRunHalfModule(String name, BaseGeom mother, int layer, String half) {
- super(name,mother, layer, half);
- }
-
- protected void setCenter() {
- // Find distance to center in the local coordinate system
- // Note that this can be different between axial and stereo since the survey positions determine the local coordinate
- // system now.
- // I'm not sure this feels good but this has to be done somewhere
- double box_center_local_x = HPSTestRunTracker2014GeomDef.TestRunHalfModule.getLength()/2.0 - ( (170.00 + 10.00) - HPSTestRunTracker2014GeomDef.Sensor.getSensorLength()/2.0);
- double box_center_local_y = -1.0*HPSTestRunTracker2014GeomDef.TestRunHalfModule.getThickness()/2.0 + (HPSTestRunTracker2014GeomDef.TestRunHalfModule.getCFThickness() + HalfModuleLamination.kapton_thickness + HPSTestRunTracker2014GeomDef.Sensor.getSensorThickness()/2.0);
- double box_center_local_z = HPSTestRunTracker2014GeomDef.TestRunHalfModule.getWidth()/2.0 - ( 12.66 - (8.83 -3.00) + HPSTestRunTracker2014GeomDef.Sensor.getSensorWidth()/2.0 );
- setCenter(box_center_local_x, box_center_local_y, box_center_local_z);
- }
- protected void setCoord() {
- setCoord(null);
- }
- protected void setBoxDim() {
- setBoxDim(getLength(), getThickness(), getWidth());
- }
- protected double getStereoAngle() {
- return stereo_angle;
- }
- protected void setStereoAngle(double stereo_angle) {
- this.stereo_angle = stereo_angle;
- }
- public static double getCFThickness() {
- return CarbonFiber.cf_thickness;
- }
- public static double getCFLength() {
- return CarbonFiber.cf_length;
- }
- public static double getCFWidth() {
- return CarbonFiber.cf_width;
- }
- public static double getHybridLength() {
- return Hybrid.hybrid_length;
- }
- public static double getHybridWidth() {
- return Hybrid.hybrid_width;
- }
- public static double getHybridThickness() {
- return Hybrid.hybrid_thickness;
- }
- public static double getThickness() {
- return half_module_thickness;
- }
- public static double getLength() {
- return half_module_length;
- }
- public static double getWidth() {
- return half_module_width;
- }
-
-
- }
-
-
- public static class TestRunHalfModuleAxial extends TestRunHalfModule {
-
- public TestRunHalfModuleAxial(String name, BaseGeom mother, int layer, String half) {
- super(name, mother, layer, half);
- init();
- }
-
- protected void setPos() {
- final double coldBlockThick = getLayer() <=3 ? TestRunColdBlockL13.coldblock_L13_thickness : TestRunColdBlockL45.coldblock_L45_thickness;
- final double dist_lower_sensor_edge_to_cold_block_mounting_surface = getLayer() <=3 ? TestRunModuleL13.dist_lower_sensor_edge_to_cold_block_mounting_surface : TestRunModuleL45.dist_lower_sensor_edge_to_cold_block_mounting_surface;
-
- final double ball_pos_halfmod_axial_local_x = dist_sensor_center_to_coldblock_hole_vdir;
- final double ball_pos_halfmod_axial_local_y = -1.0* (coldBlockThick/2.0 + TestRunHalfModule.getCFThickness() + HalfModuleLamination.kapton_thickness + HPSTestRunTracker2014GeomDef.Sensor.getSensorThickness()/2.0);
- final double ball_pos_halfmod_axial_local_z = dist_lower_sensor_edge_to_cold_block_mounting_surface + Sensor.getSensorWidth()/2.0;
- final double vee_pos_halfmod_axial_local_x = ball_pos_halfmod_axial_local_x + Sensor.getSensorLength()/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.getSensorThickness()/2.0;
- final double flat_pos_halfmod_axial_local_z = ball_pos_halfmod_axial_local_z;
- ballPos = new BasicHep3Vector(ball_pos_halfmod_axial_local_x, ball_pos_halfmod_axial_local_y, ball_pos_halfmod_axial_local_z);
- veePos = new BasicHep3Vector(vee_pos_halfmod_axial_local_x, vee_pos_halfmod_axial_local_y,vee_pos_halfmod_axial_local_z);
- flatPos = new BasicHep3Vector(flat_pos_halfmod_axial_local_x, flat_pos_halfmod_axial_local_y,flat_pos_halfmod_axial_local_z);
-
- }
- }
-
-
- public static class TestRunHalfModuleStereo extends TestRunHalfModule {
-
- public TestRunHalfModuleStereo(String name, BaseGeom mother, int layer, String half) {
- super(name, mother, layer, half);
- init();
- setExplicitRotation();
- }
-
- protected void setPos() {
-
- //very similar to axial, see note below
-
- final double coldBlockThick = getLayer() <=3 ? TestRunColdBlockL13.coldblock_L13_thickness : TestRunColdBlockL45.coldblock_L45_thickness;
- final double dist_lower_sensor_edge_to_cold_block_mounting_surface = getLayer() <=3 ? TestRunModuleL13.dist_lower_sensor_edge_to_cold_block_mounting_surface : TestRunModuleL45.dist_lower_sensor_edge_to_cold_block_mounting_surface;
-
- final double ball_pos_halfmod_axial_local_x = dist_sensor_center_to_coldblock_hole_vdir;
- // note minus sign to separate from axial
- final double ball_pos_halfmod_axial_local_y = -1.0 * (-1.0* (coldBlockThick/2.0 + TestRunHalfModule.getCFThickness() + HalfModuleLamination.kapton_thickness + HPSTestRunTracker2014GeomDef.Sensor.getSensorThickness()/2.0));
- final double ball_pos_halfmod_axial_local_z = dist_lower_sensor_edge_to_cold_block_mounting_surface + Sensor.getSensorWidth()/2.0;
- final double vee_pos_halfmod_axial_local_x = ball_pos_halfmod_axial_local_x + Sensor.getSensorLength()/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.getSensorThickness()/2.0;
- final double flat_pos_halfmod_axial_local_z = ball_pos_halfmod_axial_local_z;
- ballPos = new BasicHep3Vector(ball_pos_halfmod_axial_local_x, ball_pos_halfmod_axial_local_y, ball_pos_halfmod_axial_local_z);
- veePos = new BasicHep3Vector(vee_pos_halfmod_axial_local_x, vee_pos_halfmod_axial_local_y,vee_pos_halfmod_axial_local_z);
- flatPos = new BasicHep3Vector(flat_pos_halfmod_axial_local_x, flat_pos_halfmod_axial_local_y,flat_pos_halfmod_axial_local_z);
- }
-
- /**
- * Set rotations explicitly.
- * TODO Should be included in the coord system? Workaround!?
- */
- protected void setExplicitRotation() {
- if(getLayer()<4) {
- stereo_angle = -0.1;
- } else {
- stereo_angle = -0.05;
- }
- org.apache.commons.math3.geometry.euclidean.threed.Rotation rot_stereo = new org.apache.commons.math3.geometry.euclidean.threed.Rotation(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ, Math.PI, stereo_angle,0);
- double res[] = rot_stereo.getAngles(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ);
- lcdd_rot_angles = new BasicHep3Vector(res);
- }
-
- }
-
- public static abstract class TestRunColdBlock extends BaseGeom {
- private int layer;
- public TestRunColdBlock(String name, BaseGeom mother, int layer) {
- super(name, mother);
- setLayer(layer);
- init();
- }
- protected abstract double getWidth();
- protected abstract double getLength();
- protected abstract double getHeight();
- public int getLayer() {
- return layer;
- }
- public void setLayer(int layer) {
- this.layer = layer;
- }
- protected void setCoord() {
- setCoord(null);
- }
- protected void setCenter() {
- setCenter(getLength()/2.0, 0.0, getWidth()/2.0);
- }
- protected void setPos() {
- // cold block position w.r.t. module box coordinate system
- // this is a dummy coordinate system, make it simple
- // edge of cold block on the mounting surface
- 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;
- setBallPos(ball_pos_coldblock_local_x, ball_pos_coldblock_local_y, ball_pos_coldblock_local_z);
- setVeePos(vee_pos_coldblock_local_x, vee_pos_coldblock_local_y,vee_pos_coldblock_local_z);
- setFlatPos(flat_pos_coldblock_local_x, flat_pos_coldblock_local_y,flat_pos_coldblock_local_z);
- }
- protected void setBoxDim() {
- setBoxDim(getLength(), getHeight(), getWidth());
- }
- }
-
- public static class TestRunColdBlockL13 extends TestRunColdBlock {
- protected static final double coldblock_L13_length = 82.00;
- protected static final double coldblock_L13_width = 52.50;
- protected static final double coldblock_L13_thickness = 6.00;
-
- public TestRunColdBlockL13(String name, BaseGeom mother, int layer) {
- super(name, mother, layer);
- }
- protected double getWidth() {
- return coldblock_L13_width;
- }
- protected double getLength() {
- return coldblock_L13_length;
- }
- protected double getHeight() {
- return coldblock_L13_thickness;
- }
[truncated at 1000 lines; 345 more skipped]
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/HPSTestRunTracker2014LCDDBuilder.java 2014-08-18 20:46:54 UTC (rev 3269)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014LCDDBuilder.java 2014-08-19 00:32:47 UTC (rev 3270)
@@ -2,14 +2,22 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import hep.physics.vec.BasicHep3Vector;
import hep.physics.vec.Hep3Vector;
import hep.physics.vec.VecOp;
import org.jdom.JDOMException;
-import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeomDef.BaseGeom;
-import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeomDef.TrackingBase;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.Base;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.BaseGeometry;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.BasePlate;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.CSupport;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.SupportBottom;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.SupportPlateTop;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.SupportTop;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.TrackingBase;
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;
@@ -19,7 +27,8 @@
import org.lcsim.geometry.compact.converter.lcdd.util.Volume;
/**
- * Class used by LCDD converter to builder detector for SLIC
+ * Class used by LCDD converter to build detector for SLIC.
+ * It encapsulates and adds the LCDD specific information to the generic @HPSTestRunTracker2014Builder.
*
* @author Per Hansson Adrian <[log in to unmask]>
*
@@ -29,8 +38,8 @@
protected LCDD lcdd;
- protected LCDDBaseGeom baseLCDD;
- protected List<LCDDBaseGeom> lcdd_objects;
+ protected LCDDBaseGeometry baseTrackerGeometry;
+ protected List<LCDDBaseGeometry> lcdd_objects;
/**
* Default constructor
@@ -39,58 +48,76 @@
super(debugFlag);
}
- private void add(LCDDBaseGeom geom) {
+ /**
+ * Add to list of objects.
+ * @param geom - object to add.
+ */
+ private void add(LCDDBaseGeometry geom) {
lcdd_objects.add(geom);
}
+ /**
+ * Build the LCDD geometry objects.
+ * @param worldVolume - the reference volume.
+ */
protected void build(Volume worldVolume) {
- // go through the list of volumes to build
- // TODO this is manual now since I don't have a way of knowing what is a ghost volume at this point
+
if(isDebug()) System.out.printf("%s: build the LCDD geometry objects\n", getClass().getSimpleName());
// initialize the list to store a reference to each object
- lcdd_objects = new ArrayList<LCDDBaseGeom>();
- LCDDBaseGeom trackingLCDD = new GhostBaseGeom(getItem(HPSTestRunTracker2014GeomDef.TrackingBase.class), worldVolume);
- add(trackingLCDD);
- baseLCDD = new LCDDBaseGeom(getItem(HPSTestRunTracker2014GeomDef.Base.class), lcdd, trackingLCDD);
- add(baseLCDD);
- LCDDBaseGeom basePlateLCDD = new LCDDBaseGeom(getItem(HPSTestRunTracker2014GeomDef.BasePlate.class), lcdd, baseLCDD);
- add(basePlateLCDD);
- LCDDBaseGeom cSupportLCDD = new GhostBaseGeom(getItem(HPSTestRunTracker2014GeomDef.CSupport.class), baseLCDD);
- add(cSupportLCDD);
- LCDDBaseGeom supportBottomLCDD = new LCDDBaseGeom(getItem(HPSTestRunTracker2014GeomDef.SupportBottom.class), lcdd, baseLCDD);
- add(supportBottomLCDD);
- LCDDBaseGeom supportPlateBottomLCDD = new LCDDBaseGeom(getItem(HPSTestRunTracker2014GeomDef.SupportPlateBottom.class), lcdd, supportBottomLCDD);
- add(supportPlateBottomLCDD);
- LCDDBaseGeom supportTopLCDD = new LCDDBaseGeom(getItem(HPSTestRunTracker2014GeomDef.SupportTop.class), lcdd, baseLCDD);
- add(supportTopLCDD);
- LCDDBaseGeom supportPlateTopLCDD = new LCDDBaseGeom(getItem(HPSTestRunTracker2014GeomDef.SupportPlateTop.class), lcdd, supportTopLCDD);
- add(supportPlateTopLCDD);
+ lcdd_objects = new ArrayList<LCDDBaseGeometry>();
+
+ // Go through the list of volumes to build that is created in the generic builder class
+ // TODO this is manual now since I don't have a way of knowing in the generic builder class what is a ghost volume at this point.
+ LCDDBaseGeometry trackingGeom = new GhostLCDDBaseGeometry(getItem(TrackingBase.class), worldVolume);
+ add(trackingGeom);
+ baseTrackerGeometry = new LCDDBaseGeometry(getItem(Base.class), lcdd, trackingGeom);
+ add(baseTrackerGeometry);
+ LCDDBaseGeometry basePlateGeometry = new LCDDBaseGeometry(getItem(BasePlate.class), lcdd, baseTrackerGeometry);
+ add(basePlateGeometry);
+ LCDDBaseGeometry cSupportGeometry = new GhostLCDDBaseGeometry(getItem(CSupport.class), baseTrackerGeometry);
+ add(cSupportGeometry);
+ LCDDBaseGeometry supportBottomGeometry = new GhostLCDDBaseGeometry(getItem(SupportBottom.class), baseTrackerGeometry);
+ add(supportBottomGeometry);
+ LCDDBaseGeometry supportPlateBottomGeometry = new LCDDBaseGeometry(getItem(SupportPlateBottom.class), lcdd, baseTrackerGeometry);
+ add(supportPlateBottomGeometry);
+ LCDDBaseGeometry supportTopGeometry = new GhostLCDDBaseGeometry(getItem(SupportTop.class), baseTrackerGeometry);
+ add(supportTopGeometry);
+ LCDDBaseGeometry supportPlateTopGeometry = new LCDDBaseGeometry(getItem(SupportPlateTop.class), lcdd, baseTrackerGeometry);
+ add(supportPlateTopGeometry);
+
+ // build modules
- // build modules here based on the module bundle class
-
if(isDebug()) System.out.printf("%s: build modules\n", getClass().getSimpleName());
- for(HPSTestRunTracker2014Builder.ModuleBundle m : modules) {
+
+ // Loop over all modules created
+ for(ModuleBundle m : modules) {
+
+ // Do only L1?
+ if(m.getLayer()!=1) continue;
+
if(isDebug()) {
System.out.printf("%s: module layer %d half %s\n", getClass().getSimpleName(),m.getLayer(),m.getHalf());
m.print();
}
+
+ // Find the mother among the LCDD objects using its name, should probably have a better way...
String name_mother = m.getMother().getName();
- LCDDBaseGeom mother = null;
- //find the mother among the LCDD objects using name...
- for(LCDDBaseGeom g : lcdd_objects) {
+ LCDDBaseGeometry mother = null;
+ for(LCDDBaseGeometry g : lcdd_objects) {
if(g.getName().equals(name_mother)) {
mother = g;
break;
}
}
+ // Check that it had a mother
if(mother==null) throw new RuntimeException("Cound't find mother to module layer " + m.getLayer() + " half "+ m.getHalf());
if(isDebug()) System.out.printf("%s: found mother %s for module layer %d half %s\n", getClass().getSimpleName(),mother.getName(),m.getLayer(),m.getHalf());
- // add to LCDD
+ // add the module to the list of objects that will be added to LCDD
addModule(m, mother);
}
@@ -99,6 +126,7 @@
if(isDebug()) System.out.printf("%s: DONE building the LCDD geometry objects\n", getClass().getSimpleName());
+ // Set visualization features
setVis();
@@ -109,13 +137,15 @@
* @param bundle - module to be added
* @param mother - mother LCDD geometry object
*/
- private void addModule(ModuleBundle bundle, LCDDBaseGeom mother) {
+ private void addModule(ModuleBundle bundle, LCDDBaseGeometry mother) {
// This could perhaps be fixed if there is a relation with daughters in geometry definition?
// create the module
- LCDDBaseGeom lcddM = new LCDDBaseGeom(bundle.module, lcdd, mother);
+ LCDDBaseGeometry lcddM = new LCDDBaseGeometry(bundle.module, lcdd, mother);
add(lcddM);
addHalfModule(bundle.halfModuleAxial,lcddM);
- addHalfModule(bundle.halfModuleStereo,lcddM);
+ LCDDBaseGeometry lcddCB = new LCDDBaseGeometry(bundle.coldBlock, lcdd, lcddM);
+ add(lcddCB);
+ //addHalfModule(bundle.halfModuleStereo,lcddM);
}
@@ -124,48 +154,53 @@
* @param bundle - module to be added
* @param mother - mother LCDD geometry object
*/
- private void addHalfModule(HalfModuleBundle bundle, LCDDBaseGeom mother) {
+ private void addHalfModule(HalfModuleBundle bundle, LCDDBaseGeometry mother) {
// This could perhaps be fixed if there is a relation with daughters in geometry definition?
// create the half-module
- LCDDBaseGeom lcddHM = new LCDDBaseGeom(bundle.halfModule, lcdd, mother);
+ LCDDBaseGeometry lcddHM = new LCDDBaseGeometry(bundle.halfModule, lcdd, mother);
add(lcddHM);
// create the sensor
- LCDDBaseGeom lcddS = new LCDDBaseGeom(bundle.sensor, lcdd, lcddHM);
+ LCDDBaseGeometry lcddS = new LCDDBaseGeometry(bundle.sensor, lcdd, lcddHM);
add(lcddS);
// create the active sensor
- LCDDBaseGeom lcddAS = new LCDDBaseGeom(bundle.activeSensor, lcdd, lcddS);
+ LCDDBaseGeometry lcddAS = new LCDDBaseGeometry(bundle.activeSensor, lcdd, lcddS);
add(lcddAS);
// create the lamination
- LCDDBaseGeom lcddL = new LCDDBaseGeom(bundle.lamination, lcdd, lcddHM);
+ LCDDBaseGeometry lcddL = new LCDDBaseGeometry(bundle.lamination, lcdd, lcddHM);
add(lcddL);
// create the carbon fiber frame
- LCDDBaseGeom lcddCF = new LCDDBaseGeom(bundle.carbonFiber, lcdd, lcddHM);
+ LCDDBaseGeometry lcddCF = new LCDDBaseGeometry(bundle.carbonFiber, lcdd, lcddHM);
add(lcddCF);
// create the hybrid frame
- LCDDBaseGeom lcddH = new LCDDBaseGeom(bundle.hybrid, lcdd, lcddHM);
+ LCDDBaseGeometry lcddH = new LCDDBaseGeometry(bundle.hybrid, lcdd, lcddHM);
add(lcddH);
}
+ /**
+ * Set visualization features.
+ */
private void setVis() {
if(isDebug()) System.out.printf("%s: Set LCDD vis \n", getClass().getSimpleName());
//set lcdd vis
- for(LCDDBaseGeom g : lcdd_objects) {
+ for(LCDDBaseGeometry g : lcdd_objects) {
if(isDebug()) System.out.printf("%s: Set LCDD vis for %s \n", getClass().getSimpleName(), g.getName());
- if(g.getName().contains("baseplate")) g.setVisName("BasePlateVis");
+ if(g.getName().endsWith("baseplate")) g.setVisName("BasePlateVis");
//else if(g.getName().contains("base")) g.setVisName("BaseVis");
- else if(g.getName().contains("support_bottom") || g.getName().contains("support_top")) g.setVisName("SupportVolumeVis");
- else if(g.getName().contains("support_plate_bottom") || g.getName().contains("support_plate_top")) g.setVisName("SupportPlateVis");
- else if(g.getName().contains("halfmodule")) g.setVisName("HalfModuleVis");
- else if(g.getName().contains("module")) g.setVisName("ModuleVis");
- else if(g.getName().contains("cold")) g.setVisName("ColdBlockVis");
- else if(g.getName().contains("kapton")) g.setVisName("KaptonVis");
- else if(g.getName().contains("sensor")) g.setVisName("SensorVis");
- else if(g.getName().contains("carbon")) g.setVisName("CarbonFiberVis");
- else if(g.getName().contains("hybrid")) g.setVisName("HybridVis");
+ else if(g.getName().endsWith("support_bottom") || g.getName().contains("support_top")) g.setVisName("SupportVolumeVis");
+ else if(g.getName().endsWith("support_plate_bottom") || g.getName().contains("support_plate_top")) g.setVisName("SupportPlateVis");
+ else if(g.getName().endsWith("halfmodule_axial")) g.setVisName("HalfModuleVis");
+ else if(g.getName().endsWith("halfmodule_stereo")) g.setVisName("HalfModuleVis");
+ else if(g.getName().endsWith("module")) g.setVisName("ModuleVis");
+ else if(g.getName().endsWith("cold")) g.setVisName("ColdBlockVis");
+ else if(g.getName().endsWith("lamination")) g.setVisName("KaptonVis");
+ else if(g.getName().endsWith("sensor")) g.setVisName("SensorVis");
+ else if(g.getName().endsWith("sensor_active")) g.setVisName("SensorVis");
+ else if(g.getName().endsWith("cf")) g.setVisName("CarbonFiberVis");
+ else if(g.getName().endsWith("hybrid")) g.setVisName("HybridVis");
else {
if(isDebug()) System.out.printf("%s: No LCDD vis for %s \n", getClass().getSimpleName(), g.getName());
}
@@ -181,78 +216,18 @@
protected LCDD getLCDD() {
return lcdd;
}
- protected LCDDBaseGeom getBaseLCDD() {
- return baseLCDD;
+ protected LCDDBaseGeometry getBaseLCDD() {
+ return baseTrackerGeometry;
}
- /**
- *
- * Base geometry class for holding LCDD geometry object definitions
- * where no volume is built but it can be used as reference in building the geometry.
- *
- * @author Per Hansson Adrian <[log in to unmask]>
- *
- */
- protected static class GhostBaseGeom extends LCDDBaseGeom {
-
- /**
- * Initialize this object with a known volume and no mother. Typically the world volume would use this.
- * @param base - object used to get geometry definitions
- * @param vol - given volume
- */
- public GhostBaseGeom(HPSTestRunTracker2014GeomDef.BaseGeom base, Volume volume) {
- super();
- if(isDebug()) System.out.printf("%s: constructing LCDD ghost object %s\n", this.getClass().getSimpleName(),base.getName());
- setName(base.getName());
- setVolume(volume);
- if(isDebug()) System.out.printf("%s: DONE constructing LCDD object %s\n", this.getClass().getSimpleName(),base.getName());
- }
-
- /**
- * Initialize with base and mother. This is typically for a reference geometry object
- * that is used for referencing coordinate systems but that doesn't have a volume itself.
- * @param base - object used to get geometry definitions
- * @param mother - mother LCDD object
- */
- public GhostBaseGeom(HPSTestRunTracker2014GeomDef.BaseGeom base, LCDDBaseGeom mother) {
- super();
- if(isDebug()) System.out.printf("%s: constructing LCDD ghost object %s with mother %s\n", this.getClass().getSimpleName(),base.getName(),mother==null?"null":mother.getName());
- setName(base.getName());
- setMother(mother);
- if(isDebug()) System.out.printf("%s: DONE constructing LCDD object %s\n", this.getClass().getSimpleName(),base.getName());
- }
-
- }
-
-
/**
- *
- * LCDD geometry visualization information
- *
- * @author Per Hansson Adrian <[log in to unmask]>
- */
- protected static class LCDDBaseGeomVis {
- protected String visName = "";
- public LCDDBaseGeomVis() {}
- protected String getVisName() {
- return visName;
- }
- protected void setVisName(String visName) {
- this.visName = visName;
- }
-
-
- }
-
-
- /**
* Base geometry class for holding LCDD geometry object definitions.
*
* @author Per Hansson Adrian <[log in to unmask]>
*/
- protected static class LCDDBaseGeom extends LCDDBaseGeomVis {
+ protected static class LCDDBaseGeometry extends LCDDBaseGeometryVisualization {
private boolean debug = true;
private String name;
private Box box= null;
@@ -261,12 +236,13 @@
private Rotation rot = null;
private PhysVol physVolume = null;
private LCDD lcdd = null;
- private LCDDBaseGeom mother = null;
- public List<LCDDBaseGeom> daughters = new ArrayList<LCDDBaseGeom>();
+ private LCDDBaseGeometry mother = null;
+ protected Map<String,Integer> physVolId = null;
+ public List<LCDDBaseGeometry> daughters = new ArrayList<LCDDBaseGeometry>();
/**
* Default constructor
*/
- public LCDDBaseGeom() {
+ public LCDDBaseGeometry() {
}
/**
@@ -275,7 +251,7 @@
* @param lcdd - lcdd file
* @param mother - reference to mother LCDD definition
*/
- public LCDDBaseGeom(HPSTestRunTracker2014GeomDef.BaseGeom base, LCDD lcdd, LCDDBaseGeom mother) {
+ public LCDDBaseGeometry(BaseGeometry base, LCDD lcdd, LCDDBaseGeometry mother) {
if(isDebug()) System.out.printf("%s: constructing LCDD object %s with mother %s\n", this.getClass().getSimpleName(),base.getName(),mother==null?"null":mother.getName());
this.lcdd = lcdd;
setName(base.getName());
@@ -293,11 +269,11 @@
if(isDebug()) System.out.printf("%s: build phys volume for %s\n", this.getClass().getSimpleName(),getName());
setPhysVolume(new PhysVol(volume, getMother().getVolume(), getPos(), getRot()));
}
- protected void buildBox(HPSTestRunTracker2014GeomDef.BaseGeom base) {
+ protected void buildBox(BaseGeometry base) {
if(isDebug()) System.out.printf("%s: build box for %s\n", this.getClass().getSimpleName(),getName());
setBox(new Box(getName() + "Box", base.getBoxDim().x(), base.getBoxDim().y(), base.getBoxDim().z()));
}
- protected void buildVolume(HPSTestRunTracker2014GeomDef.BaseGeom base) {
+ protected void buildVolume(BaseGeometry base) {
if(isDebug()) System.out.printf("%s: build volume for %s with material %s\n", this.getClass().getSimpleName(),getName(),base.getMaterial());
try {
Material mat = lcdd.getMaterial(base.getMaterial());
@@ -306,7 +282,7 @@
e.printStackTrace();
}
}
- protected void setPosAndRot(HPSTestRunTracker2014GeomDef.BaseGeom base) {
+ protected void setPosAndRot(BaseGeometry base) {
if(isDebug()) System.out.printf("%s: set position and rotation for volume %s\n", this.getClass().getSimpleName(),getName());
// Vector from origin to center of box locally
Hep3Vector box_center_base_local = base.getCenter();
@@ -317,24 +293,35 @@
//Find LCDD Euler rotation angles from coordinate system unit vectors
Hep3Vector lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(base.getCoord().v(), base.getCoord().w(), new BasicHep3Vector(0,1,0),new BasicHep3Vector(0,0,1));
// Check if there are explicit rotations built into the object itself which overrides
- // TODO this should be included in the coordinate system somehow?
- if (base.lcdd_rot_angles!=null) {
+ // TODO this should be included in the definition of the coordinate system. Fix this for the affected components.
+ if (base.explicit_rot_angles!=null) {
// there are explicit rotations I need to apply.
// Find the displacement of the box center due to rotation about different origin
- Hep3Vector box_center_base_rot = HPSTestRunTracker2014.getRotationDisplacement(base.getCoord().origin(), box_center_base, base.lcdd_rot_angles);
+ Hep3Vector box_center_base_rot = HPSTestRunTracker2014.getRotationDisplacement(base.getCoord().origin(), box_center_base, base.explicit_rot_angles);
if(isDebug()) {
System.out.printf("%s: lcdd_rot_angles %s\n", this.getClass().getSimpleName(),lcdd_rot_angles);
- System.out.printf("%s: lcdd_rot_angles_2 %s\n", this.getClass().getSimpleName(),base.lcdd_rot_angles);
+ System.out.printf("%s: lcdd_rot_angles_2 %s\n", this.getClass().getSimpleName(),base.explicit_rot_angles);
System.out.printf("%s: box_center_base %s\n", this.getClass().getSimpleName(), box_center_base.toString());
System.out.printf("%s: box_center_base_rot %s\n", this.getClass().getSimpleName(), box_center_base_rot.toString());
}
// update the rotation angles
- lcdd_rot_angles = base.lcdd_rot_angles;
+ lcdd_rot_angles = base.explicit_rot_angles;
// update the position of the center in the mother coord
box_center = VecOp.sub(box_center_base_rot, base.getMother().getCenter());
}
// Create the LCDD position
setPos(new Position(getName() + "_position",box_center.x(), box_center.y(), box_center.z()));
+
+ if(getName().contains("module_L1t") && !getName().contains("halfmodule") && !getName().contains("cold")) {
+ lcdd_rot_angles = new BasicHep3Vector(-Math.PI,0,0.03);
+ lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(base.getCoord().u(), base.getCoord().v(), new BasicHep3Vector(1,0,0),new BasicHep3Vector(0,1,0));
+ lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(base.getCoord().u(), base.getCoord().w(), new BasicHep3Vector(1,0,0),new BasicHep3Vector(0,0,1));
+ }
+ if(getName().contains("module_L1b") && !getName().contains("halfmodule") && !getName().contains("cold")) {
+ lcdd_rot_angles = new BasicHep3Vector(0,0,-0.030);
+ }
+
+
setRot(new Rotation(getName() + "_rotation",lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z()));
if(isDebug()) {
System.out.printf("%s: box_center_base_local %s\n", this.getClass().getSimpleName(), box_center_base_local.toString());
@@ -377,10 +364,10 @@
protected void setRot(Rotation rot) {
this.rot = rot;
}
- protected LCDDBaseGeom getMother() {
+ protected LCDDBaseGeometry getMother() {
return mother;
}
- protected void setMother(LCDDBaseGeom mother) {
+ protected void setMother(LCDDBaseGeometry mother) {
this.mother = mother;
}
protected PhysVol getPhysVolume() {
@@ -393,16 +380,78 @@
return debug;
}
- protected List<LCDDBaseGeom> getDaughters() {
+ protected List<LCDDBaseGeometry> getDaughters() {
return daughters;
}
- protected void addDaughter(LCDDBaseGeom o) {
+ protected void addDaughter(LCDDBaseGeometry o) {
getDaughters().add(o);
}
}
+
+ /**
+ *
+ * Base geometry class for holding LCDD geometry object definitions
+ * where no volume is built but it can be used as reference in building the geometry.
+ *
+ * @author Per Hansson Adrian <[log in to unmask]>
+ *
+ */
+ protected static class GhostLCDDBaseGeometry extends LCDDBaseGeometry {
+
+ /**
+ * Initialize this object with a known volume and no mother. Typically the world volume would use this.
+ * @param base - object used to get geometry definitions
+ * @param vol - given volume
+ */
+ public GhostLCDDBaseGeometry(BaseGeometry base, Volume volume) {
+ super();
+ if(isDebug()) System.out.printf("%s: constructing LCDD ghost object %s\n", this.getClass().getSimpleName(),base.getName());
+ setName(base.getName());
+ setVolume(volume);
+ if(isDebug()) System.out.printf("%s: DONE constructing LCDD object %s\n", this.getClass().getSimpleName(),base.getName());
+ }
+
+ /**
+ * Initialize with base and mother. This is typically for a reference geometry object
+ * that is used for referencing coordinate systems but that doesn't have a volume itself.
+ * @param base - object used to get geometry definitions
+ * @param mother - mother LCDD object
+ */
+ public GhostLCDDBaseGeometry(BaseGeometry base, LCDDBaseGeometry mother) {
+ super();
+ if(isDebug()) System.out.printf("%s: constructing LCDD ghost object %s with mother %s\n", this.getClass().getSimpleName(),base.getName(),mother==null?"null":mother.getName());
+ setName(base.getName());
+ setMother(mother);
+ if(isDebug()) System.out.printf("%s: DONE constructing LCDD object %s\n", this.getClass().getSimpleName(),base.getName());
+ }
+
+ }
+
+
+ /**
+ *
+ * LCDD geometry visualization information
+ *
+ * @author Per Hansson Adrian <[log in to unmask]>
+ */
+ protected static class LCDDBaseGeometryVisualization {
+ protected String visName = "";
+ public LCDDBaseGeometryVisualization() {}
+ protected String getVisName() {
+ return visName;
+ }
+ protected void setVisName(String visName) {
+ this.visName = visName;
+ }
+
+
+ }
+
+
+
}
\ No newline at end of file
projects/lcsim/trunk/detector-framework/src/test/java/org/lcsim/geometry/subdetector
--- projects/lcsim/trunk/detector-framework/src/test/java/org/lcsim/geometry/subdetector/HPSTestRunTracker2014Test.java (rev 0)
+++ projects/lcsim/trunk/detector-framework/src/test/java/org/lcsim/geometry/subdetector/HPSTestRunTracker2014Test.java 2014-08-19 00:32:47 UTC (rev 3270)
@@ -0,0 +1,52 @@
+package org.lcsim.geometry.subdetector;
+
+import java.io.InputStream;
+
+import org.lcsim.detector.DetectorElementStore;
+import org.lcsim.detector.IDetectorElement;
+import org.lcsim.detector.IDetectorElementStore;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.GeometryReader;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * @author Per Hansson Adrian <[log in to unmask]>
+ *
+ */
+public class HPSTestRunTracker2014Test extends TestCase {
+
+
+ Detector det;
+ public HPSTestRunTracker2014Test(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ GeometryReader geometryReader = new GeometryReader();
+ geometryReader.setBuildDetailed(true);
+ String pathToCompactFile = "/org/lcsim/geometry/subdetector/HPSTestRun2014-v0.xml";
+ InputStream in = HPSTestRunTracker2014Test.class.getResourceAsStream(pathToCompactFile);
+ det = geometryReader.read(in);
+
+ System.out.printf("%s: detector name converted: %s\n",this.getClass().getSimpleName(), det.getName());
+
+
+ }
+
+ public void test() {
+
+
+ IDetectorElementStore store = DetectorElementStore.getInstance();
+ System.out.printf("%s: Printing %d DE:\n",this.getClass().getSimpleName(), store.size());
+ for(IDetectorElement e : store) {
+ System.out.printf("%s: %s\n",this.getClass().getSimpleName(), e.getName());
+ }
+
+ }
+
+
+
+}
projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector
--- projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector/HPSTestRun2014-v0.xml (rev 0)
+++ projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector/HPSTestRun2014-v0.xml 2014-08-19 00:32:47 UTC (rev 3270)
@@ -0,0 +1,100 @@
+<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
+
+ <info name="HPSTest2014-v0">
+ <comment>new SVT test run geometry</comment>
+ </info>
+
+ <define>
+ <!-- units -->
+ <constant name="mm" value="0.1*cm"/>
+ <constant name="inch" value="25.4*mm"/>
+
+ <!-- world -->
+ <constant name="world_side" value="500.0*cm" />
+ <constant name="world_x" value="world_side" />
+ <constant name="world_y" value="world_side" />
+ <constant name="world_z" value="world_side" />
+
+ <!-- tracking region -->
+ <constant name="tracking_region_radius" value="200.0*cm"/>
+ <constant name="tracking_region_min" value="5.0*cm"/>
+ <constant name="tracking_region_zmax" value="131.8*cm"/>
+
+
+ </define>
+
+ <materials>
+ <!-- Set tracking material to vacuum. -->
+ <material name="TrackingMaterial">
+ <D type="density" unit="g/cm3" value="0.0000000000000001" />
+ <fraction n="1.0" ref="Vacuum" />
+ </material>
+ </materials>
+
+ <display>
+
+ <vis name="SensorVis" alpha="1.0" r="1.0" g="0.0" b="0.0" drawingStyle="wireframe" lineStyle="unbroken" showDaughters="true" visible="true"/>
+ <vis name="ActiveSensorVis" alpha="1.0" r="1.0" g="0.0" b="0.0" drawingStyle="solid" lineStyle="unbroken" showDaughters="true" visible="true"/>
+ <vis name="CarbonFiberVis" alpha="1.0" r="0.88" g="0.88" b="0.88" drawingStyle="solid" lineStyle="unbroken" showDaughters="true" visible="true"/>
+ <vis name="KaptonVis" alpha="1.0" r="0.91" g="0.77" b="0.06" drawingStyle="solid" lineStyle="unbroken" showDaughters="true" visible="true"/>
+ <vis name="HybridVis" alpha="1.0" r="0.0" g="1.0" b="0" drawingStyle="solid" lineStyle="unbroken" showDaughters="true" visible="true"/>
+ <vis name="HalfModuleVis" alpha="1.0" r="1.0" g="1.0" b="1.0" drawingStyle="wireframe" lineStyle="dashed" showDaughters="true" visible="true"/>
+ <vis name="ColdBlockVis" alpha="1.0" r="0.75" g="0.73" b="0.75" drawingStyle="solid" lineStyle="dashed" showDaughters="true" visible="true"/>
+ <vis name="ModuleVis" alpha="1.0" r="1.0" g="1.0" b="1.0" drawingStyle="wireframe" lineStyle="dotted" showDaughters="true" visible="true"/>
+ <vis name="SupportPlateVis" alpha="1.0" r="0.45" g="0.45" b="0.45" drawingStyle="solid" lineStyle="dashed" showDaughters="true" visible="true"/>
+ <vis name="SupportVolumeVis" alpha="1.0" r="0.75" g="0.73" b="0.75" drawingStyle="wireframe" lineStyle="dashed" showDaughters="true" visible="true"/>
+ <vis name="BasePlateVis" alpha="1.0" r="0.35" g="0.35" b="0.35" drawingStyle="solid" lineStyle="dashed" showDaughters="true" visible="true"/>
+ <vis name="LayerVis" alpha="0.0" r="0.0" g="0.0" b="1.0" drawingStyle="wireframe" showDaughters="true" visible="false"/>
+ <vis name="ComponentVis" alpha="0.0" r="0.0" g="0.2" b="0.4" drawingStyle="solid" showDaughters="false" visible="false"/>
+ <vis name="BeamPlaneVis" alpha="1.0" r="1.0" g="1.0" b="1.0" drawingStyle="solid" lineStyle="unbroken" showDaughters="false" visible="true"/>
+
+ </display>
+
+ <detectors>
+ <detector id="1" name="Tracker" type="HPSTestRunTracker2014" readout="TrackerHits">
+
+ <!-- Definition of half module logical volume. -->
+ <half_modules>
+ <half_module name="SvtHalfModuleLayers1-3">
+ <component x="50.0" y="100.0" z="0.0" material="Silicon" sensitive="true" />
+ </half_module>
+ </half_modules>
+
+ <!-- Alignment of entire tracker box. -->
+ <alignment x="0.0" y="0.0" z="0.0" />
+ <support_plate name="SupportPlateL1-3bot">
+ <position name="ball" x="0.0" y="0.0" z="0.0"/>
+ <position name="vee" x="0.0" y="0.0" z="0.0"/>
+ <position name="flat" x="0.0" y="0.0" z="0.0"/>
+ <alignment x="5.0" y="5.0" z="5.0" rx="0.1" ry="0.1" rz="0.1"/>
+ <modules>
+ <module layer="1" ref="SvtModule">
+ <position name="ball" x="0.0" y="0.0" z="0.0"/>
+ <position name="vee" x="0.0" y="0.0" z="0.0"/>
+ <position name="flat" x="0.0" y="0.0" z="0.0"/>
+ <alignment x="4.0" y="4.0" z="4.0" rx="0.1" ry="0.1" rz="0.1"/>
+ <half_module type="axial" ref="SvtHalfModuleLayers1-3">
+ <position name="ball" x="0.0" y="0.0" z="0.0"/>
+ <position name="vee" x="0.0" y="0.0" z="0.0"/>
+ <position name="flat" x="0.0" y="0.0" z="0.0"/>
+ <alignment x="3.0" y="3.0" z="3.0" rx="0.1" ry="0.1" rz="0.1" />
+ </half_module>
+ </module>
+ </modules>
+ </support_plate>
+ </detector>
+ </detectors>
+ <readouts>
+ <readout name="TrackerHits">
+ <id>system:6,barrel:3,layer:4,module:12,sensor:1,side:32:-2,strip:12</id>
+ </readout>
+ </readouts>
+ <fields>
+ <field type="BoxDipole" name="AnalyzingDipole" x="0*cm" y="0*cm"
+ z="45.22*cm" dx="22.86*cm" dy="7.62*cm" dz="46.22*cm" bx="0.0" by="-0.5"
+ bz="0.0">
+ </field>
+ </fields>
+</lccdd>
\ No newline at end of file
projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector
--- projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector/HPSTestRunTracker2014.xml 2014-08-18 20:46:54 UTC (rev 3269)
+++ projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector/HPSTestRunTracker2014.xml 2014-08-19 00:32:47 UTC (rev 3270)
@@ -22,20 +22,7 @@
<constant name="tracking_region_min" value="5.0*cm"/>
<constant name="tracking_region_zmax" value="131.8*cm"/>
- <!--
- <constant name="target_pos_wrt_base_plate_x" value="16.23*cm" />
- <constant name="target_pos_wrt_base_plate_y" value="8.055*cm" />
- <constant name="target_pos_wrt_base_plate_z" value="92.659*cm" />
-
- <constant name="base_plate_thickness" value="0.25*inch"/>
- <constant name="base_plate_width" value="385.00*mm"/>
- <constant name="base_plate_length" value="1216.00*mm"/>
-
- <constant name="base_height" value="0.25*inch"/>
- <constant name="base_width" value="base_plate_width"/>
- <constant name="base_length" value="base_plate_length"/>
- -->
-
+
</define>
<materials>
@@ -67,15 +54,6 @@
<detectors>
<detector id="1" name="Tracker" type="HPSTestRunTracker2014" readout="TrackerHits">
- <!--
- <base_plate>
- <box x="base_plate_width" y="base_plate_length" z="base_plate_thickness"/>
- <ball x="-1.0*target_pos_wrt_base_plate_x" y="-1.0*target_pos_wrt_base_plate_y" z="target_pos_wrt_base_plate_z" />
- </base_plate>
- <base>
- <box x="base_width" y="base_length" z="base_height"/>
- </base>
- -->
<!-- Definition of half module logical volume. -->
<half_modules>
@@ -103,25 +81,7 @@
<position name="flat" x="0.0" y="0.0" z="0.0"/>
<alignment x="3.0" y="3.0" z="3.0" rx="0.1" ry="0.1" rz="0.1" />
</half_module>
- <!--
- <half_module type="stereo" ref="SvtHalfModuleLayers1-3">
- <position name="ball" x="0.0" y="0.0" z="0.0"/>
- <position name="vee" x="0.0" y="0.0" z="0.0"/>
- <position name="flat" x="0.0" y="0.0" z="0.0"/>
- <alignment x="2.0" y="2.0" z="2.0" rx="0.1" ry="0.1" rz="0.1" />
- </half_module>
- -->
</module>
- <!--
- <module layer="2" ref="SvtModule">
- <alignment x="0.0" y="0.0" z="" rx="0.0" ry="0.0"
- rz="0.0" />
- </module>
- <module layer="3" ref="SvtModule">
- <alignment x="0.0" y="0.0" z="" rx="0.0" ry="0.0"
- rz="0.0" />
- </module>
- -->
</modules>
</support_plate>
</detector>
SVNspam 0.1