Commit in projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim on MAIN | |||
detector/converter/compact/HPSTestRunTracker2014Converter.java | +6 | -7 | 3352 -> 3353 |
/HPSTestRunTracker2014Dev1JavaBuilder.java | -117 | 3352 removed | |
/HPSTestRunTracker2014JavaBuilder.java | -241 | 3352 removed | |
geometry/compact/converter/lcdd/HPSTestRunTracker2014.java | +8 | -6 | 3352 -> 3353 |
/HPSTestRunTracker2014Builder.java | -360 | 3352 removed | |
/HPSTestRunTracker2014Dev1Builder.java | -155 | 3352 removed | |
/HPSTestRunTracker2014Dev1GeometryDefinition.java | -218 | 3352 removed | |
/HPSTestRunTracker2014Dev1LCDDBuilder.java | -140 | 3352 removed | |
/HPSTestRunTracker2014GeometryDefinition.java | -1590 | 3352 removed | |
/HPSTestRunTracker2014LCDDBuilder.java | -187 | 3352 removed | |
/HPSTrackerBuilder.java | -369 | 3352 removed | |
/HPSTrackerJavaBuilder.java | -513 | 3352 removed | |
/HPSTrackerLCDDBuilder.java | -439 | 3352 removed | |
/IHPSTrackerJavaBuilder.java | -31 | 3352 removed | |
/IHPSTrackerLCDDBuilder.java | -15 | 3352 removed | |
+14 | -4388 |
Extract geometry definition and builders to common place. May not be the final place.
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014Converter.java 2014-09-29 17:06:12 UTC (rev 3352) +++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014Converter.java 2014-09-30 23:23:47 UTC (rev 3353) @@ -26,10 +26,11 @@
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.HPSTestRunTracker2014Builder; -import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerJavaBuilder; -import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerJavaBuilder.GhostJavaBaseGeom; -import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerJavaBuilder.JavaBaseGeometry;
+import org.lcsim.geometry.compact.converter.HPSTestRunTracker2014Builder; +import org.lcsim.geometry.compact.converter.HPSTestRunTracker2014JavaBuilder; +import org.lcsim.geometry.compact.converter.HPSTrackerJavaBuilder; +import org.lcsim.geometry.compact.converter.HPSTrackerJavaBuilder.GhostJavaBaseGeom; +import org.lcsim.geometry.compact.converter.HPSTrackerJavaBuilder.JavaBaseGeometry;
import org.lcsim.geometry.subdetector.HPSTestRunTracker2014; /**
@@ -39,7 +40,7 @@
*/ public class HPSTestRunTracker2014Converter extends AbstractSubdetectorConverter {
- private boolean _debug = true;
+ private boolean _debug = false;
private IMaterial trackingMaterial = null; private static HPSTrackerJavaBuilder builder;
@@ -64,8 +65,6 @@
if(_debug) System.out.printf("%s: convert %s \n", getClass().getSimpleName(), subdet.getName()); builder = new HPSTestRunTracker2014JavaBuilder(_debug);
- //builder = new HPSTestRunTracker2014Test1JavaBuilder(_debug); - //builder = new HPSTestRunTracker2014Dev1JavaBuilder(_debug);
// check tracking material trackingMaterial = MaterialStore.getInstance().get("Vacuum");
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014Dev1JavaBuilder.java 2014-09-29 17:06:12 UTC (rev 3352) +++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014Dev1JavaBuilder.java 2014-09-30 23:23:47 UTC (rev 3353) @@ -1,117 +0,0 @@
-/** - * - */ -package org.lcsim.detector.converter.compact; - -import org.lcsim.detector.ILogicalVolume; -import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014Dev1Builder; -import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014Dev1GeometryDefinition; -import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition; -import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerJavaBuilder; - - -/** - * 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 HPSTestRunTracker2014Dev1JavaBuilder extends HPSTrackerJavaBuilder { - - - - /** - * Default constructor - */ - public HPSTestRunTracker2014Dev1JavaBuilder(boolean debugFlag) { - super(debugFlag); - } - - - - /** - * Build the JAVA geometry objects from the geometry definition. - * @param trackingVolume - the reference volume. - */ - public void build(ILogicalVolume trackingVolume) { - - // build geometry - setBuilder(new HPSTestRunTracker2014Dev1Builder(this._debug)); - - if(_builder==null) throw new RuntimeException("need to set builder class before calling build!"); - - if(isDebug()) System.out.printf("%s: build the base geometry objects\n", getClass().getSimpleName()); - - _builder.build(); - - if(isDebug()) System.out.printf("%s: DONE build the base geometry objects\n", getClass().getSimpleName()); - - if(isDebug()) System.out.printf("%s: build the JAVA geometry objects\n", getClass().getSimpleName()); - - - // Go through the list of volumes to build that is created in the generic builder class - JavaBaseGeometry trackingGeometry = new JavaBaseGeometry(_builder.getBaseGeometry(HPSTestRunTracker2014GeometryDefinition.TrackingBase.class), trackingVolume); - add(trackingGeometry); - //setBaseTrackerGeometry(trackingGeometry); - //setBaseTrackerGeometry(new GhostJavaBaseGeom(_builder.getBaseGeometry(HPSTestRunTracker2014Dev1GeometryDefinition.Base.class), trackingGeometry)); - //add(getBaseTrackerGeometry()); - setBaseTrackerGeometry(new JavaBaseGeometry(_builder.getBaseGeometry(HPSTestRunTracker2014Dev1GeometryDefinition.Base.class), trackingGeometry,1)); - add(getBaseTrackerGeometry()); - - - // build modules - - if(isDebug()) System.out.printf("%s: build JAVA modules\n", getClass().getSimpleName()); - - - JavaBaseGeometry mother = getBaseTrackerGeometry(); - - // Create the module - JavaBaseGeometry lcddM = new GhostJavaBaseGeom(_builder.getBaseGeometry(HPSTestRunTracker2014Dev1GeometryDefinition.TestRunModule.class), mother); - add(lcddM); - - - if(isDebug()) System.out.printf("%s: build JAVA half-modules\n", getClass().getSimpleName()); - - int oldCompactModuleId = 0; - JavaBaseGeometry lcddHM = new JavaBaseGeometry(_builder.getBaseGeometry(HPSTestRunTracker2014Dev1GeometryDefinition.TestRunHalfModuleAxial.class),lcddM,oldCompactModuleId); - add(lcddHM); - - // ComponentNumber is taken from old geometry where it is simply a counter when adding the xml daughters to the TestRunModule. - // It is simply 0 for sensor and 1 for carbon fiber in the old geometry - HPSTestRunTracker2014GeometryDefinition.Sensor sensor = _builder.getBaseGeometry(HPSTestRunTracker2014GeometryDefinition.Sensor.class); - int componentNumber = sensor.getId(); - - // create the sensor - JavaBaseGeometry lcddS = new JavaBaseGeometry(sensor, lcddHM, componentNumber); - add(lcddS); - - // create the active sensor - JavaBaseGeometry lcddAS = new JavaBaseGeometry(_builder.getBaseGeometry(HPSTestRunTracker2014GeometryDefinition.ActiveSensor.class), lcddS, componentNumber); - add(lcddAS); - - - - if(isDebug()) System.out.printf("%s: DONE build JAVA modules\n", getClass().getSimpleName()); - - - if(isDebug()) System.out.printf("%s: DONE building the JAVA geometry objects\n", getClass().getSimpleName()); - //if(isDebug()) { - System.out.printf("%s: DONE building the JAVA geometry objects\n", getClass().getSimpleName()); - System.out.printf("%s: List of all the JAVA geometry objects built\n", this.getClass().getSimpleName()); - for(JavaBaseGeometry bg : java_objects) { - System.out.printf("-------\n%s\n", bg.toString()); - } - //} - - - // Set visualization features - //setVis(); - - - } - - - -}
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014JavaBuilder.java 2014-09-29 17:06:12 UTC (rev 3352) +++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014JavaBuilder.java 2014-09-30 23:23:47 UTC (rev 3353) @@ -1,241 +0,0 @@
-/** - * - */ -package org.lcsim.detector.converter.compact; - -import java.util.ArrayList; - -import org.lcsim.detector.ILogicalVolume; -import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014Builder; -import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014Dev1GeometryDefinition; -import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.Base; -import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.BasePlate; -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.HPSTestRunTracker2014Dev1Builder; -import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerBuilder.HalfModuleBundle; -import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerBuilder.ModuleBundle; -import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerJavaBuilder.JavaBaseGeometry; -import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerLCDDBuilder.LCDDBaseGeometry; -import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerJavaBuilder; - - -/** - * 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 HPSTrackerJavaBuilder { - - - - /** - * Default constructor - */ - public HPSTestRunTracker2014JavaBuilder(boolean debugFlag) { - super(debugFlag); - } - - - - /** - * Build the JAVA geometry objects from the geometry definition. - * @param trackingVolume - the reference volume. - */ - public void build(ILogicalVolume trackingVolume) { - - // build geometry - setBuilder(new HPSTestRunTracker2014Builder(this._debug)); - - if(_builder==null) throw new RuntimeException("need to set builder class before calling build!"); - - if(isDebug()) System.out.printf("%s: build the base geometry objects\n", getClass().getSimpleName()); - - _builder.build(); - - if(isDebug()) System.out.printf("%s: DONE build the base geometry objects\n", getClass().getSimpleName()); - - 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<JavaBaseGeometry>(); - - // Go through the list of volumes to build that is created in the generic builder class - JavaBaseGeometry trackingGeometry = new JavaBaseGeometry(_builder.getBaseGeometry(TrackingBase.class), trackingVolume); - add(trackingGeometry); - //setBaseTrackerGeometry(new GhostJavaBaseGeom(_builder.getBaseGeometry(Base.class), trackingGeometry)); - setBaseTrackerGeometry(new JavaBaseGeometry(_builder.getBaseGeometry(HPSTestRunTracker2014Dev1GeometryDefinition.Base.class), trackingGeometry,1)); - add(getBaseTrackerGeometry()); - JavaBaseGeometry basePlateGeometry = new GhostJavaBaseGeom(_builder.getBaseGeometry(BasePlate.class), getBaseTrackerGeometry()); - add(basePlateGeometry); - // skip the c-support, this is purely a reference volume in the builder so should have no use here!? - //JavaBaseGeometry cSupportGeometry = new GhostJavaBaseGeom(_builder.getBaseGeometry(CSupport.class), baseTrackerGeometry); - //add(cSupportGeometry); - JavaBaseGeometry supportBottomGeometry = new GhostJavaBaseGeom(_builder.getBaseGeometry(SupportBottom.class), getBaseTrackerGeometry()); - add(supportBottomGeometry); - JavaBaseGeometry supportPlateBottomGeometry = new GhostJavaBaseGeom(_builder.getBaseGeometry(SupportPlateBottom.class), getBaseTrackerGeometry()); - add(supportPlateBottomGeometry); - JavaBaseGeometry supportTopGeometry = new GhostJavaBaseGeom(_builder.getBaseGeometry(SupportTop.class), getBaseTrackerGeometry()); - add(supportTopGeometry); - JavaBaseGeometry supportPlateTopGeometry = new GhostJavaBaseGeom(_builder.getBaseGeometry(SupportPlateTop.class), getBaseTrackerGeometry()); - add(supportPlateTopGeometry); - - // build modules - - if(isDebug()) System.out.printf("%s: build JAVA modules\n", getClass().getSimpleName()); - - // Loop over all modules created - for(ModuleBundle m : _builder.modules) { - - if(isDebug()) { - System.out.printf("%s: build module %s (layer %d half %s)\n", getClass().getSimpleName(),m.module.getName(),m.getLayer(),m.getHalf()); - m.print(); - } - - // Find the mother among the objects using its name, should probably have a better way... - String name_mother = m.getMother().getName(); - JavaBaseGeometry mother = null; - for(JavaBaseGeometry 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 " + m.module.getName()); - - if(isDebug()) System.out.printf("%s: found mother %s to module %s\n", getClass().getSimpleName(),mother.getName(),m.module.getName()); - - // put the module in the list of objects that will be added to LCDD - addModule(m, mother); - - if(isDebug()) System.out.printf("%s: DONE build module %s\n", getClass().getSimpleName(), m.module.getName()); - - - } - - if(isDebug()) System.out.printf("%s: DONE build JAVA modules\n", getClass().getSimpleName()); - - - if(isDebug()) System.out.printf("%s: DONE building the JAVA geometry objects\n", getClass().getSimpleName()); - //if(isDebug()) { - System.out.printf("%s: DONE building the JAVA geometry objects\n", getClass().getSimpleName()); - System.out.printf("%s: List of all the JAVA geometry objects built\n", this.getClass().getSimpleName()); - for(JavaBaseGeometry bg : java_objects) { - System.out.printf("-------\n%s\n", bg.toString()); - } - //} - - - // 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, JavaBaseGeometry mother) { - - if(isDebug()) { - System.out.printf("%s: addModule %s containing:\n",this.getClass().getSimpleName(), bundle.module.getName()); - bundle.print(); - } - - // Create the module - JavaBaseGeometry lcddM = new GhostJavaBaseGeom(bundle.module, mother); - add(lcddM); - - // add half modules - if(bundle.halfModuleAxial!=null) addHalfModule(bundle.halfModuleAxial,lcddM); - if(bundle.halfModuleStereo!=null) addHalfModule(bundle.halfModuleStereo,lcddM); - - - if(isDebug()) { - System.out.printf("%s: DONE addModule %s \n",this.getClass().getSimpleName(), bundle.module.getName()); - } - - } - - - /** - * 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, JavaBaseGeometry 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; - JavaBaseGeometry lcddHM = new JavaBaseGeometry(bundle.halfModule, mother,oldCompactModuleId); - add(lcddHM); - - // ComponentNumber is taken from old geometry where it is simply a counter when adding the xml daughters to the TestRunModule. - // It is simply 0 for sensor and 1 for carbon fiber in the old geometry - int componentNumber = bundle.sensor.getId(); - - // create the sensor - JavaBaseGeometry lcddS = new JavaBaseGeometry(bundle.sensor, lcddHM, componentNumber); - add(lcddS); - - // create the active sensor - JavaBaseGeometry lcddAS = new JavaBaseGeometry(bundle.activeSensor, lcddS, componentNumber); - add(lcddAS); - -// if(isDebug()) { -// System.out.printf("%s: added sensor %s \n",this.getClass().getSimpleName(), lcddS.getName()); -// System.out.printf("%s: local coordinate system\n%s\n",this.getClass().getSimpleName(), bundle.sensor.getCoord().toString()); -// dsd -// } - - - } - - - - - -// /** -// * Find the transform to a given parent volume. -// * @param t transformation of the object. -// * @param mother of the object -// * @param targetMotherName is the name of the parent volume to transform to. -// * @return translation to the target mother volume. -// */ -// public static ITransform3D getParentTransform(Transform3D t, JavaBaseGeometry mother, String targetMotherName) { -// boolean debug = true; -// if(mother==null) throw new RuntimeException("Trying to get mother transform but there is no mother?!"); -// if(debug) System.out.printf("getParentTransform for mother %s target mother %s with current transform\n%s\n",mother.getName(), targetMotherName, t.toString()); -// if(mother.getName().equals(targetMotherName)) { -// if(debug) System.out.printf("found the target object\n"); -// return t; -// } else { -// // Compound the transforms -// ITranslation3D p = mother.getPos(); -// IRotation3D r = mother.getRot(); -// if(p==null) throw new RuntimeException("cannot compound transform since the mother " + mother.getName() + " has no translation!?"); -// if(r==null) throw new RuntimeException("cannot compound transform since the mother " + mother.getName() + " has no rotation!?"); -// Transform3D tM = new Transform3D(p, r); -// if(debug) System.out.printf("add transform\n%s\n",tM.toString()); -// t.multiplyBy(tM); -// if(debug) System.out.printf("resulting transform\n%s\n",((Transform3D)t).toString()); -// if(debug) System.out.printf("continue searching\n"); -// return getParentTransform(t, mother.getMother(), targetMotherName); -// } -// } -// - - - - -}
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java 2014-09-29 17:06:12 UTC (rev 3352) +++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java 2014-09-30 23:23:47 UTC (rev 3353) @@ -10,8 +10,12 @@
import org.jdom.Element; import org.jdom.JDOMException; import org.lcsim.detector.Transform3D;
-import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerLCDDBuilder.GhostLCDDBaseGeometry; -import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerLCDDBuilder.LCDDBaseGeometry;
+import org.lcsim.geometry.compact.converter.HPSTestRunTracker2014Builder; +import org.lcsim.geometry.compact.converter.HPSTestRunTracker2014GeometryDefinition; +import org.lcsim.geometry.compact.converter.HPSTestRunTracker2014LCDDBuilder; +import org.lcsim.geometry.compact.converter.HPSTrackerLCDDBuilder; +import org.lcsim.geometry.compact.converter.HPSTrackerLCDDBuilder.GhostLCDDBaseGeometry; +import org.lcsim.geometry.compact.converter.HPSTrackerLCDDBuilder.LCDDBaseGeometry;
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;
@@ -31,8 +35,8 @@
*/ public class HPSTestRunTracker2014 extends LCDDSubdetector {
- private boolean _debug = true; - private final boolean buildBeamPlane = true;
+ private boolean _debug = false; + private final boolean buildBeamPlane = false;
// Builder class to handle all geometry information private static HPSTrackerLCDDBuilder builder;
@@ -96,8 +100,6 @@
if(_debug) System.out.printf("%s: setup and build the LCDD geometry\n", getClass().getSimpleName()); builder = new HPSTestRunTracker2014LCDDBuilder(_debug);
- //builder = new HPSTestRunTracker2014Test1LCDDBuilder(_debug); - //builder = new HPSTestRunTracker2014Dev1LCDDBuilder(_debug);
builder.setLCDD(lcdd); builder.setSensitiveDetector(sens);
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014Builder.java 2014-09-29 17:06:12 UTC (rev 3352) +++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014Builder.java 2014-09-30 23:23:47 UTC (rev 3353) @@ -1,360 +0,0 @@
-/** - * - */ -package org.lcsim.geometry.compact.converter.lcdd; - -import java.util.ArrayList; - -import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.BaseGeometry; - -/** - * - * Class used to encapsulate the rules for building geometry based building blocks defined in {@link HPSTestRunTracker2014GeometryDefinition} - * - * @author Per Hansson Adrian <[log in to unmask]> - * - */ -public class HPSTestRunTracker2014Builder extends HPSTrackerBuilder { - - public final boolean doAxial = true; - public final boolean doStereo = true; - public final boolean doColdBlock = false; - public final boolean doBottom = true; - public final boolean doTop = true; - public final int layerBitMask = 0x1F; - - - /** - * Default constructor. - */ - public HPSTestRunTracker2014Builder(boolean debugFlag) { - setDebug(debugFlag); - } - - - public void build() { - if(isDebug()) System.out.printf("%s: constructing the geometry objects\n", this.getClass().getSimpleName()); - - // Build the geometry from the basic 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); - geometries.add(tracking); - HPSTestRunTracker2014GeometryDefinition.Base base = new HPSTestRunTracker2014GeometryDefinition.Base("base",tracking); - geometries.add(base); - HPSTestRunTracker2014GeometryDefinition.BasePlate basePlate = new HPSTestRunTracker2014GeometryDefinition.BasePlate("baseplate",base, "Aluminum"); - geometries.add(basePlate); - HPSTestRunTracker2014GeometryDefinition.CSupport cSupport = new HPSTestRunTracker2014GeometryDefinition.CSupport("c_support", base); - geometries.add(cSupport); - HPSTestRunTracker2014GeometryDefinition.SupportBottom supportBottom = new HPSTestRunTracker2014GeometryDefinition.SupportBottom("support_bottom", base, cSupport); - geometries.add(supportBottom); - // 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"); - geometries.add(supportPlateBottom); - HPSTestRunTracker2014GeometryDefinition.SupportTop supportTop = new HPSTestRunTracker2014GeometryDefinition.SupportTop("support_top", base, cSupport); - geometries.add(supportTop); - HPSTestRunTracker2014GeometryDefinition.SupportPlateTop supportPlateTop = new HPSTestRunTracker2014GeometryDefinition.SupportPlateTop("support_plate_top", base, supportTop, "Aluminum"); - geometries.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) { - if(!doLayer(l)) continue; - if(doBottom) makeModuleBundle(l,"bottom"); - if(doTop) makeModuleBundle(l,"top"); - - } - - //if(isDebug()) { - System.out.printf("%s: DONE constructing the geometry objects\n", this.getClass().getSimpleName()); - System.out.printf("%s: List of all the geometry objects built\n", this.getClass().getSimpleName()); - for(BaseGeometry bg : geometries) { - System.out.printf("-------\n%s\n", bg.toString()); - } - //} - } - - - /** - * Create the module. - * @param layer - of the module - * @param half - top or bottom half of the tracker - */ - private void makeModuleBundle(int layer, String half) - { - - if(isDebug()) System.out.printf("%s: makeModule for layer %d %s \n", this.getClass().getSimpleName(), layer, half); - - - // build the module name - String volName = "module_L"+ layer + (half=="bottom"?"b":"t"); - - boolean isL13 = ( layer >=1 && layer <=3 ) ? true : false; - - // 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 = getBaseGeometry(HPSTestRunTracker2014GeometryDefinition.Base.class); - ref = getBaseGeometry(HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.class); - } else { - mother= getBaseGeometry(HPSTestRunTracker2014GeometryDefinition.Base.class); - ref = getBaseGeometry(HPSTestRunTracker2014GeometryDefinition.SupportPlateTop.class); - } - - //Create the module - HPSTestRunTracker2014GeometryDefinition.TestRunModule module; - if(isL13) { - module = new HPSTestRunTracker2014GeometryDefinition.TestRunModuleL13(volName, mother, ref, layer, half); - } else { - module = new HPSTestRunTracker2014GeometryDefinition.TestRunModuleL45(volName, mother, ref, layer, half); - } - - - // create the bundle for this module - ModuleBundle bundle = new ModuleBundle(module); - addModuleBundle(bundle); - - if(doAxial) makeHalfModule("axial", module); - if(doColdBlock) makeColdBlock(module); - if(doStereo) makeHalfModule("stereo", module); - - - if(isDebug()) { - System.out.printf("%s: created module bundle:\n", this.getClass().getSimpleName()); - bundle.print(); - } - - } - - - - /** - * 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 - HPSTestRunTracker2014GeometryDefinition.TestRunColdBlock coldBlock; - - if(layer >= 1 && layer <=3) { - coldBlock = new HPSTestRunTracker2014GeometryDefinition.TestRunColdBlockL13(volName, mother, layer); - } else if(layer >= 4 && layer <=5) { - coldBlock = new HPSTestRunTracker2014GeometryDefinition.TestRunColdBlockL45(volName, mother, layer); - } else { - throw new RuntimeException("wrong layer for " + volName); - } - - ModuleBundle bundle = getModuleBundle(mother); - bundle.coldBlock = coldBlock; - } - - - - /** - * 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(); - - if(isDebug()) System.out.printf("%s: makeHalfModule for %s %s \n", this.getClass().getSimpleName(), moduleName, side); - - String volName = moduleName + "_halfmodule_" + side; - - // top or bottom? - String half = mother.getHalf(); - - // find layer - int layer = mother.getLayer(); - - ModuleBundle bundle = getModuleBundle(mother); - HalfModuleBundle halfModuleBundle; - - // Build the half-module - HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule halfModule; - if(side == "axial") { - halfModule = new HPSTestRunTracker2014GeometryDefinition.TestRunHalfModuleAxial(volName, mother, layer, half); - halfModuleBundle = new HalfModuleBundle(halfModule); - bundle.halfModuleAxial = halfModuleBundle; - } else if(side == "stereo") { - halfModule = new HPSTestRunTracker2014GeometryDefinition.TestRunHalfModuleStereo(volName, mother, layer, half); - halfModuleBundle = new HalfModuleBundle(halfModule); - bundle.halfModuleStereo = halfModuleBundle; - } else { - throw new IllegalArgumentException("not a valid half-module side " + side); - } - - - // create the half module components - - makeHalfModuleComponentSensor(halfModule); - - makeHalfModuleComponentKapton(halfModule); - - makeHalfModuleComponentCF(halfModule); - - makeHalfModuleComponentHybrid(halfModule); - - - - - } - - - - 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 - - // id is hard coded - int component_number = 3; - - HPSTestRunTracker2014GeometryDefinition.Hybrid hybrid = new HPSTestRunTracker2014GeometryDefinition.Hybrid(volName,mother,component_number); - hybrid.setMaterial("G10"); - - 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()); - - - } - - - - 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 - - // id is hard coded - int component_number = 1; - - HPSTestRunTracker2014GeometryDefinition.CarbonFiber cf = new HPSTestRunTracker2014GeometryDefinition.CarbonFiber(volName,mother,component_number); - cf.setMaterial("CarbonFiber"); - - HalfModuleBundle hm = getHalfModuleBundle((HPSTestRunTracker2014GeometryDefinition.TestRunModule) mother.getMother(), mother.getName()); - hm.carbonFiber = cf; - - } - - - - - 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 - - // id is hard coded - int component_number = 2; - - HPSTestRunTracker2014GeometryDefinition.HalfModuleLamination lamination = new HPSTestRunTracker2014GeometryDefinition.HalfModuleLamination(volName,mother,component_number); - lamination.setMaterial("Kapton"); - - - HalfModuleBundle hm = getHalfModuleBundle((HPSTestRunTracker2014GeometryDefinition.TestRunModule) mother.getMother(), mother.getName()); - hm.lamination = lamination; - - } - - - private void makeHalfModuleComponentSensor(HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule mother) { - - if(isDebug()) System.out.printf("%s: makeHalfModuleComponentSensor for %s \n", this.getClass().getSimpleName(), mother.getName()); - - String volName = mother.getName() + "_sensor"; - - // sensor id is hard coded in old geometry to be zero by counting over the components of the module - int component_number = 0; - - // - HPSTestRunTracker2014GeometryDefinition.Sensor sensor = new HPSTestRunTracker2014GeometryDefinition.Sensor(volName, mother, component_number); - sensor.setMaterial("Silicon"); - - HalfModuleBundle hm = getHalfModuleBundle((HPSTestRunTracker2014GeometryDefinition.TestRunModule) mother.getMother(), mother.getName()); - hm.sensor = sensor; - - - makeHalfModuleComponentActiveSensor(sensor); - - - } - - - 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"; - - HPSTestRunTracker2014GeometryDefinition.ActiveSensor active_sensor = new HPSTestRunTracker2014GeometryDefinition.ActiveSensor(volName, mother); - active_sensor.setMaterial("Silicon"); - - HalfModuleBundle hm = getHalfModuleBundle((HPSTestRunTracker2014GeometryDefinition.TestRunModule) mother.getMother().getMother(), mother.getMother().getName()); - hm.activeSensor = active_sensor; - - } - - public boolean doLayer(int layer) { - int a = (1<<(layer-1)) & layerBitMask; - return a!=0?true:false; - } - - - /* - public static Hep3Vector transformToMotherCoord(Hep3Vector vec, BaseGeometry mother, String targetMotherName) { - int debug =1; - if(debug>0) System.out.printf("transformToMotherCoord vec %s mother %s target %s\n", vec.toString(), mother.getName(), targetMotherName); - if(mother.name.equals(targetMotherName)) { - if(debug>0) System.out.printf(String.format("found the transformed vec %s\n", vec.toString())); - return vec; - } else { - if(mother.name.equals("trackingVolume")) { - if(debug>0) System.out.print("reached tracking volume. return null?!\n"); - return null; - } - - Transform3D trans = new Transform3D(mother.pos, mother.rot); - Hep3Vector vec_t = trans.transformed(vec); - if(debug>0) System.out.print("continue searching\n"); - return transformToMotherCoord(vec_t, mother.mother, targetMotherName); - } - - } - */ - - - - -}
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014Dev1Builder.java 2014-09-29 17:06:12 UTC (rev 3352) +++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014Dev1Builder.java 2014-09-30 23:23:47 UTC (rev 3353) @@ -1,155 +0,0 @@
-/** - * - */ -package org.lcsim.geometry.compact.converter.lcdd; - -import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.BaseGeometry; - - -/** - * - * Class used to encapsulate the rules for building geometry based building blocks defined in {@link HPSTestRunTracker2014GeometryDefinition} - * - * @author Per Hansson Adrian <[log in to unmask]> - * - */ -public class HPSTestRunTracker2014Dev1Builder extends HPSTrackerBuilder { - - - - /** - * Default constructor. - */ - public HPSTestRunTracker2014Dev1Builder(boolean debugFlag) { - setDebug(debugFlag); - } - - - - public void build() { - if(isDebug()) System.out.printf("%s: constructing the geometry objects\n", this.getClass().getSimpleName()); - - // Build the geometry from the basic building blocks in the geometry definition class - // Keep the order correct. - // Each item has knowledge of its mother but not its daughters - HPSTestRunTracker2014Dev1GeometryDefinition.TrackingBase tracking = new HPSTestRunTracker2014Dev1GeometryDefinition.TrackingBase("trackingVolume",null); - geometries.add(tracking); - HPSTestRunTracker2014Dev1GeometryDefinition.Base base = new HPSTestRunTracker2014Dev1GeometryDefinition.Base("base",tracking); - geometries.add(base); - HPSTestRunTracker2014Dev1GeometryDefinition.CSupport cSupport = new HPSTestRunTracker2014Dev1GeometryDefinition.CSupport("c_support", base); - geometries.add(cSupport); - - - - if(isDebug()) System.out.printf("%s: build modules\n", getClass().getSimpleName()); - - - - int layer = 1; - String half = "bottom"; - if(isDebug()) System.out.printf("%s: makeModule for layer %d %s \n", this.getClass().getSimpleName(), layer, half); - - String moduleName = "module_L"+ layer + (half=="bottom"?"b":"t"); - BaseGeometry ref = cSupport; - BaseGeometry mother = base; - - //Create the module - HPSTestRunTracker2014GeometryDefinition.TestRunModule module = new HPSTestRunTracker2014Dev1GeometryDefinition.TestRunModuleL13(moduleName, mother, ref, layer, half); - - geometries.add(module); - - if(isDebug()) System.out.printf("%s: build half-modules\n", getClass().getSimpleName()); - - - - // Build the half-module - String side = "axial"; - String volName = moduleName + "_halfmodule_" + side; - mother = module; - - if(isDebug()) System.out.printf("%s: makeHalfModule with name %s\n", this.getClass().getSimpleName(), volName); - - HPSTestRunTracker2014Dev1GeometryDefinition.TestRunHalfModule halfModule = new HPSTestRunTracker2014Dev1GeometryDefinition.TestRunHalfModuleAxial(volName, mother, layer, half); - - if(isDebug()) System.out.printf("%s: %s\n", this.getClass().getSimpleName(), halfModule.toString()); - - geometries.add(halfModule); - - // create the half module components - - mother = halfModule; - - if(isDebug()) System.out.printf("%s: makeHalfModuleComponentSensor for %s \n", this.getClass().getSimpleName(), mother.getName()); - - volName = mother.getName() + "_sensor"; - - // sensor id is hard coded in old geometry to be zero by counting over the components of the module - int component_number = 0; - - // - HPSTestRunTracker2014Dev1GeometryDefinition.Sensor sensor = new HPSTestRunTracker2014Dev1GeometryDefinition.Sensor(volName, mother, component_number); - sensor.setMaterial("Silicon"); - - geometries.add(sensor); - - mother = sensor; - - if(isDebug()) System.out.printf("%s: makeHalfModuleComponentActiveSensor for %s \n", this.getClass().getSimpleName(), mother.getName()); - - volName = mother.getName() + "_active"; - - HPSTestRunTracker2014GeometryDefinition.ActiveSensor active_sensor = new HPSTestRunTracker2014GeometryDefinition.ActiveSensor(volName, mother); - active_sensor.setMaterial("Silicon"); - - geometries.add(active_sensor); - - - if(isDebug()) { - System.out.printf("%s: DONE constructing the geometry objects\n", this.getClass().getSimpleName()); - System.out.printf("%s: List of all the geometry objects built\n", this.getClass().getSimpleName()); - for(HPSTestRunTracker2014GeometryDefinition.BaseGeometry bg : geometries) { - System.out.printf("-------\n%s\n", bg.toString()); - } - } - - } - - - - - - - - - - - - - - - /* - public static Hep3Vector transformToMotherCoord(Hep3Vector vec, BaseGeometry mother, String targetMotherName) { - int debug =1; - if(debug>0) System.out.printf("transformToMotherCoord vec %s mother %s target %s\n", vec.toString(), mother.getName(), targetMotherName); - if(mother.name.equals(targetMotherName)) { - if(debug>0) System.out.printf(String.format("found the transformed vec %s\n", vec.toString())); - return vec; - } else { - if(mother.name.equals("trackingVolume")) { - if(debug>0) System.out.print("reached tracking volume. return null?!\n"); - return null; - } - - Transform3D trans = new Transform3D(mother.pos, mother.rot); - Hep3Vector vec_t = trans.transformed(vec); - if(debug>0) System.out.print("continue searching\n"); - return transformToMotherCoord(vec_t, mother.mother, targetMotherName); - } - - } - */ - - - - -}
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014Dev1GeometryDefinition.java 2014-09-29 17:06:12 UTC (rev 3352) +++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014Dev1GeometryDefinition.java 2014-09-30 23:23:47 UTC (rev 3353) @@ -1,218 +0,0 @@
-/** - * - */ -package org.lcsim.geometry.compact.converter.lcdd; - -import org.apache.commons.math3.geometry.euclidean.threed.Rotation; -import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; -import org.lcsim.detector.Rotation3D; -import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.BaseGeometry; -import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.HalfModuleComponent; -import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.HalfModuleLamination; -import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.Sensor; - -import hep.physics.vec.BasicHep3Vector; - -/** - * - * Class containing geometry information for HPS Test run tracker 2014 - * - * @author Per Hansson Adrian <[log in to unmask]> - * - */ - -public class HPSTestRunTracker2014Dev1GeometryDefinition extends HPSTestRunTracker2014GeometryDefinition { - - - - -/* - public static class Base extends HPSTestRunTracker2014GeometryDefinition.BaseGeometry { - // 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, HPSTestRunTracker2014GeometryDefinition.BaseGeometry mother) { - super(name,mother); - init(); - } - protected void setPos() { - //Default position - 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; - - //Unrotated compared to tracking coordinates position -// final double ball_pos_base_x = 100; -// final double ball_pos_base_y = 0; -// final double ball_pos_base_z = 0; -// 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 + BasePlate.base_plate_length; -// final double flat_pos_base_z = ball_pos_base_z; - - - 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); - -// Rotation r = new Rotation(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ, Math.PI/4, 0, 0); -// Vector3D b = r.applyTo(new Vector3D(this.ballPos.v())); -// Vector3D v = r.applyTo(new Vector3D(this.veePos.v())); -// Vector3D f = r.applyTo(new Vector3D(this.flatPos.v())); -// setBallPos(b.getX(), b.getY(), b.getZ()); -// setVeePos(v.getX(), v.getY(), v.getZ()); -// setFlatPos(f.getX(), f.getY(), f.getZ()); - - - - } - 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); - //setCenter(0,0,0); - } - protected void setBoxDim() { - setBoxDim(base_width,base_length,base_height); - } - } - - */ - - - - - - - - /* - public static class TestRunHalfModuleAxial extends HPSTestRunTracker2014GeometryDefinition.TestRunHalfModuleAxial { - - public TestRunHalfModuleAxial(String name, HPSTestRunTracker2014GeometryDefinition.BaseGeometry 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_local_x = 0; - final double ball_pos_halfmod_local_y = 0; - final double ball_pos_halfmod_local_z = 0; - final double vee_pos_halfmod_local_x = ball_pos_halfmod_local_x + Sensor.getSensorLength()/2.0; - final double vee_pos_halfmod_local_y = ball_pos_halfmod_local_y; - final double vee_pos_halfmod_local_z = ball_pos_halfmod_local_z; - final double flat_pos_halfmod_local_x = ball_pos_halfmod_local_x; - final double flat_pos_halfmod_local_y = ball_pos_halfmod_local_y + Sensor.getSensorThickness()/2.0; - final double flat_pos_halfmod_local_z = ball_pos_halfmod_local_z; - ballPos = new BasicHep3Vector(ball_pos_halfmod_local_x, ball_pos_halfmod_local_y, ball_pos_halfmod_local_z); - veePos = new BasicHep3Vector(vee_pos_halfmod_local_x, vee_pos_halfmod_local_y,vee_pos_halfmod_local_z); - flatPos = new BasicHep3Vector(flat_pos_halfmod_local_x, flat_pos_halfmod_local_y,flat_pos_halfmod_local_z); - - } - - 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 = 0; - double box_center_local_y = 0; - double box_center_local_z = 0; - setCenter(box_center_local_x, box_center_local_y, box_center_local_z); - } - - } - */ - - /* - public static class Sensor extends HPSTestRunTracker2014GeometryDefinition.Sensor { - - public Sensor(String name, BaseGeometry m, int id) { - super(name, m, id); - init(); - } - - protected void setPos() { - // using SiStrips convention -// setBallPos(0,0,0); -// setVeePos(ballPos.x(), ballPos.y(), ballPos.z() + getSensorWidth()/2.0); -// setFlatPos(ballPos.x() + getSensorLength()/2.0,ballPos.y(), ballPos.z()); -// Rotation r = new Rotation(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ, Math.PI/4, 0, 0); -// Vector3D b = r.applyTo(new Vector3D(this.ballPos.v())); -// Vector3D v = r.applyTo(new Vector3D(this.veePos.v())); -// Vector3D f = r.applyTo(new Vector3D(this.flatPos.v())); -// setBallPos(b.getX(), b.getY(), b.getZ()); -// setVeePos(v.getX(), v.getY(), v.getZ()); -// setFlatPos(f.getX(), f.getY(), f.getZ()); -// - // default convention - setBallPos(0,0,0); - setVeePos(ballPos.x() + getSensorLength()/2.0, ballPos.y(), ballPos.z()); - setFlatPos(ballPos.x(),ballPos.y() + getSensorThickness()/2.0, ballPos.z()); - - } - - protected void setBoxDim() { - // using SiStrips convention - //setBoxDim(getSensorWidth(),getSensorLength(),getSensorThickness()); - // default convention - setBoxDim(getSensorLength(),getSensorThickness(),getSensorWidth()); - - } - - } - - - public static class ActiveSensor extends HPSTestRunTracker2014GeometryDefinition.ActiveSensor { - public ActiveSensor(String name, BaseGeometry m) { - super(name, m); - init(); - } - protected void setPos() { - if(HPSTestRunTracker2014GeometryDefinition.useSiStripsConvention) { - ballPos = new BasicHep3Vector(0,0,0); - veePos = new BasicHep3Vector(getActiveSensorWidth()/2.0,0,0); - flatPos = new BasicHep3Vector(0,getActiveSensorLength()/2.0,0); - } else { - ballPos = new BasicHep3Vector(0,0,0); - veePos = new BasicHep3Vector(getActiveSensorWidth()/2.0,0,0); - flatPos = new BasicHep3Vector(0,getActiveSensorLength()/2.0,0); - } - } - protected void setCoord() { - setCoord(null); - } - protected void setCenter() { - setCenter(0,0,0); - } - @Override - protected void setBoxDim() { - if(HPSTestRunTracker2014GeometryDefinition.useSiStripsConvention) { - setBoxDim(getActiveSensorWidth(), getActiveSensorLength(), getActiveSensorThickness()); - } else { - setBoxDim(getActiveSensorLength(),getActiveSensorThickness(),getActiveSensorWidth()); - } - } - } - */ - - -} - - - -
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014Dev1LCDDBuilder.java 2014-09-29 17:06:12 UTC (rev 3352) +++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014Dev1LCDDBuilder.java 2014-09-30 23:23:47 UTC (rev 3353) @@ -1,140 +0,0 @@
-package org.lcsim.geometry.compact.converter.lcdd; - -import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.BaseGeometry; -import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerLCDDBuilder.LCDDBaseGeometry; -import org.lcsim.geometry.compact.converter.lcdd.util.Volume; - - -/** - * Class used by LCDD converter to build detector for SLIC. - * - * @author Per Hansson Adrian <[log in to unmask]> - * - */ -public class HPSTestRunTracker2014Dev1LCDDBuilder extends HPSTrackerLCDDBuilder { - - - public HPSTestRunTracker2014Dev1LCDDBuilder(boolean debugFlag) { - super(debugFlag); - } - - public void build(Volume worldVolume) { - - // build geometry - setBuilder(new HPSTestRunTracker2014Dev1Builder(this._debug)); - - if(_builder==null) throw new RuntimeException("need to set builder class before calling build!"); - - if(isDebug()) System.out.printf("%s: build the base geometry objects\n", getClass().getSimpleName()); - - _builder.build(); - - if(isDebug()) System.out.printf("%s: DONE build the base geometry objects\n", getClass().getSimpleName()); - - - if(isDebug()) System.out.printf("%s: build the LCDD geometry objects\n", getClass().getSimpleName()); - - - // 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 trackingGeometry = new LCDDBaseGeometry(_builder.getBaseGeometry(HPSTestRunTracker2014GeometryDefinition.TrackingBase.class), worldVolume); - add(trackingGeometry); - //baseTrackerGeometry = trackingGeometry; - baseTrackerGeometry = new LCDDBaseGeometry(_builder.getBaseGeometry(HPSTestRunTracker2014Dev1GeometryDefinition.Base.class), lcdd, trackingGeometry); - add(baseTrackerGeometry); - - - - // build modules - - - - if(isDebug()) System.out.printf("%s: build modules\n", getClass().getSimpleName()); - - int layer = 1; - String half = "bottom"; - if(isDebug()) System.out.printf("%s: makeModule for layer %d %s \n", this.getClass().getSimpleName(), layer, half); - - LCDDBaseGeometry mother = baseTrackerGeometry; - - //Create the module - LCDDBaseGeometry lcddM = new LCDDBaseGeometry(_builder.getBaseGeometry(HPSTestRunTracker2014Dev1GeometryDefinition.TestRunModule.class), lcdd, mother); - add(lcddM); - - - - - if(isDebug()) System.out.printf("%s: build half-modules\n", getClass().getSimpleName()); - - - - - LCDDBaseGeometry lcddHM = new LCDDBaseGeometry(_builder.getBaseGeometry(HPSTestRunTracker2014Dev1GeometryDefinition.TestRunHalfModuleAxial.class),lcdd, lcddM); - add(lcddHM); - - // create the sensor - LCDDBaseGeometry lcddS = new LCDDBaseGeometry(_builder.getBaseGeometry(HPSTestRunTracker2014GeometryDefinition.Sensor.class), lcdd, lcddHM); - add(lcddS); - // create the active sensor - LCDDBaseGeometry lcddAS = new LCDDBaseGeometry(_builder.getBaseGeometry(HPSTestRunTracker2014GeometryDefinition.ActiveSensor.class), lcdd, lcddS); - add(lcddAS); - /* - // create the lamination - LCDDBaseGeometry lcddL = new LCDDBaseGeometry(bundle.lamination, lcdd, lcddHM); - add(lcddL); - // create the carbon fiber frame - LCDDBaseGeometry lcddCF = new LCDDBaseGeometry(bundle.carbonFiber, lcdd, lcddHM); - add(lcddCF); - // create the hybrid frame - LCDDBaseGeometry lcddH = new LCDDBaseGeometry(bundle.hybrid, lcdd, lcddHM); - add(lcddH); - */ - - - - - //if(isDebug()) { - System.out.printf("%s: DONE building the LCDD geometry objects\n", getClass().getSimpleName()); - System.out.printf("%s: List of all %d LCDD geometry objects built\n", this.getClass().getSimpleName(), lcddGeometries.size()); - for(LCDDBaseGeometry bg : lcddGeometries) { - System.out.printf("-------\n%s\n", bg.toString()); - } - //} - - - - // Set visualization features - setVisualization(); - - - } - - - - public void setVisualization() { - - if(isDebug()) System.out.printf("%s: Set LCDD visualization for %d LCDD geometry objects \n", getClass().getSimpleName(), lcddGeometries.size()); - for(LCDDBaseGeometry g : lcddGeometries) { - if(isDebug()) System.out.printf("%s: Set LCDD vis for %s \n", getClass().getSimpleName(), g.getName()); - if(g.getName().endsWith("baseplate")) g.setVisName("BasePlateVis"); - //else if(g.getName().contains("base")) g.setVisName("BaseVis"); - 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()); - } - } - if(isDebug()) System.out.printf("%s: DONE Set LCDD vis \n", getClass().getSimpleName()); - } - - -}
\ No newline at end of file
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014GeometryDefinition.java 2014-09-29 17:06:12 UTC (rev 3352) +++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014GeometryDefinition.java 2014-09-30 23:23:47 UTC (rev 3353) @@ -1,1590 +0,0 @@
-/** - * - */ -package org.lcsim.geometry.compact.converter.lcdd; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.math3.geometry.euclidean.threed.Rotation; -import org.apache.commons.math3.geometry.euclidean.threed.RotationOrder; -import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; -import org.lcsim.detector.Rotation3D; -import org.lcsim.detector.Transform3D; -import org.lcsim.detector.Translation3D; - -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 HPSTestRunTracker2014GeometryDefinition { - - //General - static final double inch = 25.4; //mm - protected static final boolean useSiStripsConvention = true; - protected static final boolean use30mradRotation = true; - protected static final boolean useFakeHalfModuleAxialPos = false; - - // Global position references - protected static final double target_pos_wrt_base_plate_x = 162.3; //from Marco's 3D model - protected static final double target_pos_wrt_base_plate_y = 80.55; //from Tim's sketchup //68.75; //from Marco's 3D model - protected 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. - * - */ - public static abstract class BaseGeometry { - protected boolean debug = true; - private String name; - private String material = "Vacuum"; - private BaseGeometry 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 - protected List<BaseGeometry> referenceGeom = null; - 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 local coord system to make things consistent. Figure this out later. - public Hep3Vector explicit_rot_angles = null; - - public BaseGeometry(String name, BaseGeometry m) { - setName(name); - setMother(m); - } - public BaseGeometry(String name, BaseGeometry m, BaseGeometry ref) { - setName(name); - setMother(m); - addReferenceGeom(ref); - } - public BaseGeometry(String name, BaseGeometry m, List<BaseGeometry> ref) { - setName(name); - setMother(m); - addReferenceGeom(ref); - } - - protected abstract void setPos(); - protected abstract void setCoord(); - protected abstract void setCenter(); - protected abstract void setBoxDim(); - - protected void init() { - setPos(); - setCoord(); - setCenter(); - setBoxDim(); - applyCorrections(); - } - - protected void applyCorrections() { - //do nothing here unless overridden - } - - 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 BaseGeometry getMother() { - return mother; - } - public void setMother(BaseGeometry mother) { - this.mother = mother; - } - public void addReferenceGeom(BaseGeometry refGeom) { - if(refGeom!=null) { // check that it's not a dummy call - if(referenceGeom == null) { - referenceGeom = new ArrayList<BaseGeometry>(); - } - referenceGeom.add(refGeom); - } - } - public void addReferenceGeom(List<BaseGeometry> refGeomList) { - if(referenceGeom == null) { - referenceGeom = new ArrayList<BaseGeometry>(); - } - referenceGeom.addAll(refGeomList); - } - 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; - } - public String toString() { - String s = "BaseGeometry " + getName(); - s += "\n" + this.getCoord().toString(); - return s; - } - - } - - - /** - * Tracking volume geometry definition. - */ - public static class TrackingBase extends BaseGeometry { - public TrackingBase(String name, BaseGeometry 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 BaseGeometry { - // 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, BaseGeometry 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 BaseGeometry { - // 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, BaseGeometry 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 BaseGeometry { - // 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 double vee_pos_csup_pin_bottom_y = 121.62; - private static double vee_pos_csup_pin_bottom_z = 0.0; - - - public CSupport(String name, BaseGeometry mother) { - super(name,mother); - init(); - } - private void calcAndSetFlatPos() { - if(HPSTestRunTracker2014GeometryDefinition.use30mradRotation) { - // find the rotation to place the flat point - Rotation rot1_csup = - new Rotation( - new 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 Vector3D(1,0,0)); - - Vector3D flat_pos_csup_pin_bottom_3D_rot = rot1_csup.applyTo(new 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); - if(debug) System.out.println("rotated setPos for csupport: \n" + getFlatPos().toString()); - - } else { - - //vee_pos_csup_pin_bottom_x = ball_pos_csup_pin_bottom_x + 0; - vee_pos_csup_pin_bottom_y = ball_pos_csup_pin_bottom_y; - vee_pos_csup_pin_bottom_z = ball_pos_csup_pin_bottom_z + 0; - - double flat_pos_csup_pin_bottom_x = ball_pos_csup_pin_bottom_x + 0; - double flat_pos_csup_pin_bottom_y = ball_pos_csup_pin_bottom_y + 10.0; - double flat_pos_csup_pin_bottom_z = ball_pos_csup_pin_bottom_z + 0; - - setFlatPos(flat_pos_csup_pin_bottom_x,flat_pos_csup_pin_bottom_y,flat_pos_csup_pin_bottom_z); - if(debug) System.out.println("setPos for csupport: \n" + getFlatPos().toString()); - - } - } - protected void setPos() { - calcAndSetFlatPos(); - 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); - if(debug) System.out.println("setPos for csupport: \n" + getFlatPos().toString()); - } - protected void setCoord() { - setCoord(null); - if(debug) System.out.println("coord for csupport: \n" + this.getCoord().toString()); - } - protected void setCenter() { - // this is never used since it's only a reference volume - setCenter(null); - } - protected void setBoxDim() { - } - - } - - - - - public static class SupportTop extends BaseGeometry { - // 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, BaseGeometry mother) { - super(name,mother); - init(); - } - public SupportTop(String name, BaseGeometry mother, BaseGeometry referenceGeom) { - super(name,mother,referenceGeom); - init(); - } - public SupportTop(String name, BaseGeometry mother, List<BaseGeometry> referenceGeom) { - super(name,mother,referenceGeom); - init(); - } - - protected void setPos() { - if(debug) System.out.printf("%s: setPos support top\n",this.getClass().getSimpleName()); - // 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 - Rotation rot_csup_top = - new Rotation(RotationOrder.XYZ, - SupportPlateTop.support_plate_top_tilt_angle, 0.0, 0.0 ); - - // apply to flat local position (as for bottom it is arbitrary offset) - Vector3D flat_pos_csup_bearings_top_3D_rot = - rot_csup_top.applyTo(new 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 - if(referenceGeom==null) { - throw new RuntimeException("No ref found for " + getName()); - } - - for(BaseGeometry ref : referenceGeom) { - - if(debug) { - System.out.printf("%s: survey positions before ref %s transform\n",this.getClass().getSimpleName(),ref.getName()); - printSurveyPos(); - } - - if(debug) System.out.printf("%s: Ref %s coord\n%s\n",this.getClass().getSimpleName(), ref.getName(),ref.getCoord().toString()); - - ref.getCoord().getTransformation().transform(ballPos); - ref.getCoord().getTransformation().transform(veePos); - ref.getCoord().getTransformation().transform(flatPos); - - if(debug) { - System.out.printf("%s: survey positions after ref %s transform\n",this.getClass().getSimpleName(),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 BaseGeometry { - // "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, BaseGeometry mother, BaseGeometry referenceGeom) { - super(name,mother,referenceGeom); - init(); - } - - protected void setPos() { - - if(debug) System.out.printf("%s: setPos support bottom\n",this.getClass().getSimpleName()); - - // 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 - Rotation rot_csup = - new Rotation(RotationOrder.XYZ, - SupportPlateBottom.support_plate_bottom_tilt_angle, 0.0, 0.0 ); - // apply to flat local position - Vector3D flat_pos_csup_bearings_bottom_3D_rot = - rot_csup.applyTo(new 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 - if(referenceGeom==null) { - throw new RuntimeException("No ref found for " + getName()); - } - - for(BaseGeometry ref : referenceGeom) { - - if(debug) { - System.out.printf("%s: survey positions before ref %s transform\n",this.getClass().getSimpleName(),ref.getName()); - printSurveyPos(); - } - - if(debug) System.out.printf("%s: Ref %s coord\n%s\n",this.getClass().getSimpleName(), ref.getName(),ref.getCoord().toString()); - - ref.getCoord().getTransformation().transform(ballPos); - ref.getCoord().getTransformation().transform(veePos); - ref.getCoord().getTransformation().transform(flatPos); - - if(debug) { - System.out.printf("%s: survey positions after ref %s transform\n",this.getClass().getSimpleName(),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 BaseGeometry { - 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(BaseGeometry mother, BaseGeometry referenceGeom, String name, String material) { - super(name,mother,referenceGeom); - setMaterial(material); - } - public SupportPlate(BaseGeometry mother, List<BaseGeometry> referenceGeom, String name, String material) { - super(name,mother,referenceGeom); - 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, BaseGeometry mother, BaseGeometry referenceGeom, String material) { - super(mother, referenceGeom, name, material); - init(); - } - public SupportPlateBottom(String name, BaseGeometry mother, List<BaseGeometry> referenceGeom, String material) { - super(mother, referenceGeom, name, material); - init(); - } - protected void setPos() { - if(debug) System.out.printf("%s: set survey positions \n",this.getClass().getSimpleName()); - - 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()); - - if(referenceGeom==null) { - throw new RuntimeException("No ref found for " + getName()); - } - - for(BaseGeometry ref : referenceGeom) { - - if(debug) { - System.out.printf("%s: survey positions before ref %s transform\n",this.getClass().getSimpleName(),ref.getName()); - printSurveyPos(); - } - - if(debug) System.out.printf("%s: Ref %s coord\n%s\n",this.getClass().getSimpleName(), ref.getName(),ref.getCoord().toString()); - - ref.getCoord().getTransformation().transform(ballPos); - ref.getCoord().getTransformation().transform(veePos); - ref.getCoord().getTransformation().transform(flatPos); - - if(debug) { - System.out.printf("%s: survey positions after ref %s transform\n",this.getClass().getSimpleName(),ref.getName()); - printSurveyPos(); - } - } - } - 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, BaseGeometry mother, BaseGeometry referenceGeom, String material) { - super(mother,referenceGeom, name,material); - init(); - } - protected void setPos() { - if(debug) System.out.printf("%s: set survey positions \n",this.getClass().getSimpleName()); - - 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()); - - if(referenceGeom==null) { - throw new RuntimeException("No ref found for " + getName()); - } - - for(BaseGeometry ref : referenceGeom) { - - if(debug) System.out.printf("%s: survey positions before ref %s transform\n",this.getClass().getSimpleName(),ref.getName()); - if(debug) printSurveyPos(); - - if(debug) System.out.printf("%s: Ref %s coord\n%s\n",this.getClass().getSimpleName(), ref.getName(),ref.getCoord().toString()); - - ref.getCoord().getTransformation().transform(ballPos); - ref.getCoord().getTransformation().transform(veePos); - ref.getCoord().getTransformation().transform(flatPos); - - if(debug) System.out.printf("%s: survey positions after ref %s transform\n",this.getClass().getSimpleName(),ref.getName()); - if(debug) printSurveyPos(); - } - } - 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 + box_extra_length; // includes lexan spacer and cold block - protected static final double module_box_L45_height = 12.5 + box_extra_height; // includes screws height - protected static final double module_box_L45_width = 65.3-12.0 + box_extra_width; - protected static final double dist_lower_sensor_edge_to_cold_block_mounting_surface = 7.662; - - - public TestRunModuleL45(String name, BaseGeometry mother, int layer,String half) { - super(name, mother, layer, half); - } - public TestRunModuleL45(String name, BaseGeometry mother, BaseGeometry 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 { - protected static final double module_box_L13_length = 205.2 + box_extra_length; // includes lexan spacer and cold block - protected static final double module_box_L13_height = 12.5 + box_extra_height; // includes screws height - protected static final double module_box_L13_width = 71.3 - 13.0 + box_extra_width; // 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, BaseGeometry mother, int layer, String half) { - super(name, mother, layer, half); - } - public TestRunModuleL13(String name, BaseGeometry mother, BaseGeometry 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 { - protected final static double box_extra_length = 10.0;// random at this point - protected final static double box_extra_width = 15.0;// random at this point - protected final static double box_extra_height = 1.0;// random at this point - - public TestRunModule(String name, BaseGeometry mother, int layer, String half) { - super(name, mother,layer,half); - init(); - } - public TestRunModule(String name, BaseGeometry mother, BaseGeometry 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); - if(debug) System.out.printf("%s: coordinate system:\n%s\n",this.getClass().getSimpleName(), getCoord().toString()); - if(debug) System.out.printf("%s: translation:\n%s\n",this.getClass().getSimpleName(), getCoord().getTransformation().getTranslation().toString()); - if(debug) System.out.printf("%s: rotation:\n%s\n",this.getClass().getSimpleName(), getCoord().getTransformation().getRotation().toString()); - } - protected void setCenter() { - setCenter(getModuleBoxLength()/2.0-5.0, 0.0, getModuleBoxWidth()/2.0-box_extra_width/5.0); - } - protected void setPos() { - - if(debug) System.out.printf("%s: setPos\n",this.getClass().getSimpleName()); - - if(isBottom()) { - switch (getLayer()) { - case 1: - ballPos = new BasicHep3Vector(25.0, 661.1, HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L1-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth); - veePos = new BasicHep3Vector(95.0, 661.1, HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L1-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth); - flatPos = new BasicHep3Vector(60.0, 667.10, HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L1-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth); - break; - case 2: - ballPos = new BasicHep3Vector(25.0, 561.1, HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L2-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth); - veePos = new BasicHep3Vector(95.0, 561.1, HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L2-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth); - flatPos = new BasicHep3Vector(60.0, 567.10, HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L2-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth); - break; - case 3: - ballPos = new BasicHep3Vector(25.0, 461.1, HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L3-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth); - veePos = new BasicHep3Vector(95.0, 461.1, HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L3-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth); - flatPos = new BasicHep3Vector(60.0, 467.10, HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L3-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth); - break; - case 4: - ballPos = new BasicHep3Vector(25.0, 261.1, HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L4-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth); - veePos = new BasicHep3Vector(95.0, 261.1, HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L4-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth); - flatPos = new BasicHep3Vector(60.0, 267.10, HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L4-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth); - break; - case 5: - ballPos = new BasicHep3Vector(25.0, 61.1, HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L5-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth); - veePos = new BasicHep3Vector(95.0, 61.1, HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L5-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth); - flatPos = new BasicHep3Vector(60.0, 67.10, HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L5-HPSTestRunTracker2014GeometryDefinition.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 * (HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L1-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth)); - veePos = new BasicHep3Vector(95.0, 676.1, -1.0 * (HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L1-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth)); - flatPos = new BasicHep3Vector(60.0, 670.1, -1.0 * (HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L1-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth)); - break; - case 2: - ballPos = new BasicHep3Vector(25.0, 576.1, -1.0 * (HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L2-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth)); - veePos = new BasicHep3Vector(95.0, 576.1, -1.0 * (HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L2-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth)); - flatPos = new BasicHep3Vector(60.0, 570.1, -1.0 * (HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L2-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth)); - break; - case 3: - ballPos = new BasicHep3Vector(25.0, 476.1, -1.0 * (HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L3-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth)); - veePos = new BasicHep3Vector(95.0, 476.1, -1.0 * (HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L3-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth)); - flatPos =new BasicHep3Vector(60.0, 470.1, -1.0 * (HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L3-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth)); - break; - case 4: - ballPos = new BasicHep3Vector(25.0, 276.1, -1.0 * (HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L4-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth)); - veePos = new BasicHep3Vector(95.0, 276.1, -1.0 * (HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L4-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth)); - flatPos = new BasicHep3Vector(60.0, 270.1, -1.0 * (HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L4-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth)); - break; - case 5: - ballPos = new BasicHep3Vector(25.0, 76.1, -1.0 * (HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L5-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth)); - veePos = new BasicHep3Vector(95.0, 76.1, -1.0 * (HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L5-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth)); - flatPos = new BasicHep3Vector(60.0, 70.1, -1.0 * (HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.pedestal_height_L5-HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.support_plate_pocket_depth)); - break; - default: - System.out.printf("ERROR invalid layer %d for half %s\n",getLayer(),getHalf()); - System.exit(1); - break; - } - } - - if(debug) { - System.out.printf("%s: survey positions\n",this.getClass().getSimpleName()); - printSurveyPos(); - } - - // walk through the reference volumes - if(referenceGeom!=null) { - for(BaseGeometry ref : referenceGeom) { - - if(debug) { - System.out.printf("%s: survey positions before ref %s transform\n",this.getClass().getSimpleName(),ref.getName()); - printSurveyPos(); - } - - if(debug) System.out.printf("%s: Ref %s coord\n%s\n",this.getClass().getSimpleName(), ref.getName(),ref.getCoord().toString()); - - ref.getCoord().getTransformation().transform(ballPos); - ref.getCoord().getTransformation().transform(veePos); - ref.getCoord().getTransformation().transform(flatPos); - - if(debug) { - System.out.printf("%s: survey positions after ref %s transform\n",this.getClass().getSimpleName(),ref.getName()); - printSurveyPos(); - } - } - } - - } - - } - - - public static abstract class BaseModule extends BaseGeometry { - private int layer; - private String half; - - public BaseModule(String name, BaseGeometry mother, int layer, String half) { - super(name, mother); - setLayer(layer); - setHalf(half); - isValid(); - } - public BaseModule(String name, BaseGeometry mother, BaseGeometry 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 = HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule.getHybridThickness() + HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule.getCFThickness() + HalfModuleLamination.kapton_thickness; - protected static final double half_module_length = HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule.getCFLength(); - protected static final double half_module_width = 6.83 + HPSTestRunTracker2014GeometryDefinition.Sensor.getSensorWidth(); - - protected double stereo_angle = 0.0; - - public TestRunHalfModule(String name, BaseGeometry 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 = HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule.getLength()/2.0 - ( (170.00 + 10.00) - HPSTestRunTracker2014GeometryDefinition.Sensor.getSensorLength()/2.0); - double box_center_local_y = -1.0*HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule.getThickness()/2.0 + (HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule.getCFThickness() + HalfModuleLamination.kapton_thickness + HPSTestRunTracker2014GeometryDefinition.Sensor.getSensorThickness()/2.0); - double box_center_local_z = HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule.getWidth()/2.0 - ( 12.66 - (8.83 -3.00) + HPSTestRunTracker2014GeometryDefinition.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 {[truncated at 1000 lines; 593 more skipped]
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014LCDDBuilder.java 2014-09-29 17:06:12 UTC (rev 3352) +++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014LCDDBuilder.java 2014-09-30 23:23:47 UTC (rev 3353) @@ -1,187 +0,0 @@
-package org.lcsim.geometry.compact.converter.lcdd; - -import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.Base; -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.HPSTrackerBuilder.HalfModuleBundle; -import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerBuilder.ModuleBundle; -import org.lcsim.geometry.compact.converter.lcdd.util.Volume; - - -/** - * Class used by LCDD converter to build detector for SLIC. - * - * @author Per Hansson Adrian <[log in to unmask]> - * - */ -public class HPSTestRunTracker2014LCDDBuilder extends HPSTrackerLCDDBuilder { - - - public HPSTestRunTracker2014LCDDBuilder(boolean debugFlag) { - super(debugFlag); - } - - public void build(Volume worldVolume) { - - // build geometry - setBuilder(new HPSTestRunTracker2014Builder(this._debug)); - - if(_builder==null) throw new RuntimeException("need to set builder class before calling build!"); - - if(isDebug()) System.out.printf("%s: build the base geometry objects\n", getClass().getSimpleName()); - - _builder.build(); - - if(isDebug()) System.out.printf("%s: DONE build the base geometry objects\n", getClass().getSimpleName()); - - - if(isDebug()) System.out.printf("%s: build the LCDD geometry objects\n", getClass().getSimpleName()); - - - // 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 trackingGeometry = new LCDDBaseGeometry(_builder.getBaseGeometry(TrackingBase.class), worldVolume); - add(trackingGeometry); - baseTrackerGeometry = new LCDDBaseGeometry(_builder.getBaseGeometry(Base.class), lcdd, trackingGeometry); - add(baseTrackerGeometry); - LCDDBaseGeometry basePlateGeometry = new LCDDBaseGeometry(_builder.getBaseGeometry(BasePlate.class), lcdd, baseTrackerGeometry); - add(basePlateGeometry); - // TODO I don't think this c-support has any use at all since the coordinates of it has been already used in the builder. Should remove? - LCDDBaseGeometry cSupportGeometry = new GhostLCDDBaseGeometry(_builder.getBaseGeometry(CSupport.class), baseTrackerGeometry); - add(cSupportGeometry); - LCDDBaseGeometry supportBottomGeometry = new GhostLCDDBaseGeometry(_builder.getBaseGeometry(SupportBottom.class), baseTrackerGeometry); - add(supportBottomGeometry); - LCDDBaseGeometry supportPlateBottomGeometry = new LCDDBaseGeometry(_builder.getBaseGeometry(SupportPlateBottom.class), lcdd, baseTrackerGeometry); - add(supportPlateBottomGeometry); - LCDDBaseGeometry supportTopGeometry = new GhostLCDDBaseGeometry(_builder.getBaseGeometry(SupportTop.class), baseTrackerGeometry); - add(supportTopGeometry); - LCDDBaseGeometry supportPlateTopGeometry = new LCDDBaseGeometry(_builder.getBaseGeometry(SupportPlateTop.class), lcdd, baseTrackerGeometry); - add(supportPlateTopGeometry); - - // build modules - - if(isDebug()) System.out.printf("%s: build modules\n", getClass().getSimpleName()); - - // Loop over all modules created - for(ModuleBundle m : _builder.modules) { - - - 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(); - LCDDBaseGeometry mother = null; - for(LCDDBaseGeometry g : lcddGeometries) { - 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 LCDD geometry objects\n", getClass().getSimpleName()); - System.out.printf("%s: List of all %d LCDD geometry objects built\n", this.getClass().getSimpleName(), lcddGeometries.size()); - for(LCDDBaseGeometry bg : lcddGeometries) { - System.out.printf("-------\n%s\n", bg.toString()); - } - //} - - - - // Set visualization features - setVisualization(); - - - } - - - /** - * Rules for adding the LCDD module geometry. - * @param bundle - module to be added - * @param mother - mother LCDD geometry object - */ - 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 - LCDDBaseGeometry lcddM = new LCDDBaseGeometry(bundle.module, lcdd, mother); - add(lcddM); - if(bundle.halfModuleAxial!=null) addHalfModule(bundle.halfModuleAxial,lcddM); - if(bundle.coldBlock!=null) add(new LCDDBaseGeometry(bundle.coldBlock, lcdd, lcddM)); - if(bundle.halfModuleStereo!=null) addHalfModule(bundle.halfModuleStereo,lcddM); - } - - /** - * Rules for adding the LCDD half module geometry. - * @param bundle - module to be added - * @param mother - mother LCDD geometry object - */ - 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 - LCDDBaseGeometry lcddHM = new LCDDBaseGeometry(bundle.halfModule, lcdd, mother); - add(lcddHM); - // create the sensor - LCDDBaseGeometry lcddS = new LCDDBaseGeometry(bundle.sensor, lcdd, lcddHM); - add(lcddS); - // create the active sensor - LCDDBaseGeometry lcddAS = new LCDDBaseGeometry(bundle.activeSensor, lcdd, lcddS); - add(lcddAS); - // create the lamination - LCDDBaseGeometry lcddL = new LCDDBaseGeometry(bundle.lamination, lcdd, lcddHM); - add(lcddL); - // create the carbon fiber frame - LCDDBaseGeometry lcddCF = new LCDDBaseGeometry(bundle.carbonFiber, lcdd, lcddHM); - add(lcddCF); - // create the hybrid frame - LCDDBaseGeometry lcddH = new LCDDBaseGeometry(bundle.hybrid, lcdd, lcddHM); - add(lcddH); - - } - - - public void setVisualization() { - - if(isDebug()) System.out.printf("%s: Set LCDD visualization for %d LCDD geometry objects \n", getClass().getSimpleName(), lcddGeometries.size()); - for(LCDDBaseGeometry g : lcddGeometries) { - if(isDebug()) System.out.printf("%s: Set LCDD vis for %s \n", getClass().getSimpleName(), g.getName()); - if(g.getName().endsWith("baseplate")) g.setVisName("BasePlateVis"); - //else if(g.getName().contains("base")) g.setVisName("BaseVis"); - 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()); - } - } - if(isDebug()) System.out.printf("%s: DONE Set LCDD vis \n", getClass().getSimpleName()); - } - - -}
\ No newline at end of file
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTrackerBuilder.java 2014-09-29 17:06:12 UTC (rev 3352) +++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTrackerBuilder.java 2014-09-30 23:23:47 UTC (rev 3353) @@ -1,369 +0,0 @@
-package org.lcsim.geometry.compact.converter.lcdd; - -import hep.physics.vec.Hep3Vector; - -import java.util.ArrayList; -import java.util.List; - -import org.lcsim.detector.Transform3D; -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; - -public abstract class HPSTrackerBuilder { - - private boolean debug = true; - public List<ModuleBundle> modules; - protected List<HPSTestRunTracker2014GeometryDefinition.BaseGeometry> geometries = new ArrayList<HPSTestRunTracker2014GeometryDefinition.BaseGeometry>(); - - - - public HPSTrackerBuilder() { - super(); - } - - public abstract void build(); - - - public static String getHalfFromName(String name) { - String half = ""; - if(name.contains("bottom")) { - half = "bottom"; - } - if(name.contains("top")) { - // check that both sides are not found - if(half.equals("bottom")) { - throw new RuntimeException("found both halfs from name " + name); - } else { - half = "top"; - } - } - // check for other signatures - if( half.isEmpty()) { - // 6 layers is arbitrary here - for(int layer=1;layer<=6;++layer) { - if(name.contains(String.format("L%db", layer))) { - half = "bottom"; - break; - } - if(name.contains(String.format("L%dt", layer))) { - if(half.equals("bottom")) { - throw new RuntimeException("found both halfs from name " + name); - } - half = "top"; - break; - } - } - } - if( half.isEmpty()) { - System.out.println("found no half from " + name); - throw new RuntimeException("found no half from " + name); - } else { - return half; - - } - } - - public static int getLayerFromVolumeName(String name) { - int layer = -1; - for(int i=1; i<= 5; ++i) { - if(name.contains(String.format("module_L%d", i))) { - layer = i; - } - } - if( layer == -1) { - System.out.println("cannot find layer from " + name); - System.exit(1); - } - return layer; - } - - public static boolean isBase(String name) { - if(name.endsWith("base")) { - return true; - } - return false; - } - - 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; - } - - /** - * Bundle geometry objects in a module. - * This was done in order to package module geometry objects into a simpler form. - * If the geometry definition has access to daughter information I could avoid this? TODO check this? - * - * @author Per Hansson Adrian <[log in to unmask]> - * - */ - 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; - } - public int getLayer() { - if(module==null) throw new RuntimeException("Need to add module to bundle first!"); - return getLayerFromVolumeName(module.getName()); - } - public String getHalf() { - if(module==null) throw new RuntimeException("Need to add module to bundle first!"); - return getHalfFromName(module.getName()); - } - /** - * Find mother to this module. - * @return mother - */ - public BaseGeometry getMother() { - if(module==null) throw new RuntimeException("Need to add module to bundle first!"); - return module.getMother(); - } - public void 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 boolean isDebug() { - return debug; - } - - protected void setDebug(boolean debug) { - this.debug = debug; - } - - /** - * Find geometry object by type. - * @param c - class type to be found - * @return the found type. - */ - public <T> T getBaseGeometry(Class<T> c) { - //if(isDebug()) System.out.printf("%s: get Item %s\n", this.getClass().getSimpleName(),c.getName()); - - for(HPSTestRunTracker2014GeometryDefinition.BaseGeometry item : geometries) { - //if(isDebug()) System.out.printf("%s: item %s\n", getClass().getSimpleName(),item.getClass().getName()); - if(c.isInstance(item)) { - return (T)item; - } - } - throw new RuntimeException("Coulnd't find instance of " + c.getSimpleName() + " among the " + geometries.size() + " tracker items!"); - } - - protected List<ModuleBundle> getModules() { - return modules; - } - - /** - * Find module among the existing bundles. - * @param layer - layer id - * @param half - top or bottom half - * @return module or null if not found - */ - protected ModuleBundle getModuleBundle(int layer, String half) { - for(ModuleBundle m : modules) { - if(m.getLayer()==layer && m.getHalf().equals(half)) { - return m; - } - } - return null; - } - - /** - * Find module among the existing bundles. - * @param module - to find - * @return bundle - */ - protected ModuleBundle getModuleBundle(HPSTestRunTracker2014GeometryDefinition.TestRunModule module) { - return getModuleBundle(module.getLayer(), module.getHalf()); - } - - /** - * Find half module among the existing bundles. - * @param module - to find - * @return bundle - */ - protected HalfModuleBundle getHalfModuleBundle(HPSTestRunTracker2014GeometryDefinition.TestRunModule module, String halfModuleName) { - ModuleBundle m = getModuleBundle(module.getLayer(), module.getHalf()); - HalfModuleBundle hm = null; - if(m!=null) { - if(halfModuleName.contains("axial")) hm = m.halfModuleAxial; - else if(halfModuleName.contains("stereo")) hm = m.halfModuleStereo; - else throw new RuntimeException("NO axial or stereo string found in half module bundle name " + halfModuleName); - } else { - throw new RuntimeException("No module found for " + module.getLayer() + " and half " + module.getHalf()); - } - return hm; - } - - /** - * Add module to list. - * @param bundle - module to add. - */ - protected void addModuleBundle(ModuleBundle bundle) { - ModuleBundle b = getModuleBundle(bundle.getLayer(), bundle.getHalf()); - if(b==null) { - modules.add(bundle); - } else { - throw new RuntimeException("There is already a module bundle with layer " + bundle.getLayer() + " and half " + bundle.getHalf()); - } - } - - /** - * 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; - } - - 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() { - System.out.printf("%s: %s\n", this.getClass().getSimpleName(),halfModule.getName()); - } - } - - /** - * Find transform to parent volume coordinate system. - * @param t - current transform to mother - * @param mother - geometry object from current transform - * @param targetMotherName - parent volume defining new vector coordinate system - * @return transform. - */ - public static Transform3D getTransform(Transform3D t, BaseGeometry mother, String targetMotherName) { - int debug=1; - if(debug>0) System.out.printf("getTransform mother %s target %s with current transform\n%s\n", mother.getName(), targetMotherName,t.toString()); - if(mother==null) throw new RuntimeException("Trying to get mother transform but there is no mother?!"); - if(mother.getName().equals(targetMotherName)) { - if(debug>0) System.out.printf("found the transform\n"); - return t; - } else { - if(debug>0) System.out.printf("add mother transform\n%s\n",mother.getCoord().getTransformation().toString()); - Transform3D trans = Transform3D.multiply(mother.getCoord().getTransformation(), t); - if(debug>0) System.out.printf("resulting transform\n%s\ncontinue searching\n",trans.toString()); - return getTransform(trans, mother.getMother(), targetMotherName); - } - - } - - /** - * Find the vector in a parent volume coordinate system. - * @param vec - vector to transform - * @param geometry - geometry where vector is defined. - * @param targetMotherName - parent volume defining new vector coordinate system - * @return transformed vector. - */ - public static Hep3Vector transformToMotherCoord(Hep3Vector vec, BaseGeometry geometry, - String targetMotherName) { - int debug =0; - BaseGeometry mother = geometry.getMother(); - if(debug>0) System.out.printf("transformToMotherCoord vec %s geomtry %s mother %s target %s\n", vec.toString(), geometry.getName(), geometry.getMother().getName(), targetMotherName); - - Transform3D t = getTransform(geometry.getCoord().getTransformation(), mother, targetMotherName); - - Hep3Vector vec_t = t.transformed(vec); - - if(debug>0) { - System.out.printf("transformToMotherCoord apply transform \n%s\n",t.toString()); - System.out.printf("transformToMotherCoord vec_t%s\n",vec_t.toString()); - } - - - return vec_t; - } - - /** - * Find the vector in the tracking volume coordinate system. - * @param vec - vector to transform - * @param geometry - geometry where vector is defined. - * @return transformed vector. - */ - public static Hep3Vector transformToTracking(Hep3Vector vec, BaseGeometry geometry) { - int debug =0; - if(debug>0) System.out.printf("\ntransformToTracking: vec %s in local coordiantes of %s with mother %s\n", vec.toString(), geometry.getName(), geometry.getMother().getName().toString()); - Hep3Vector vec_mother_coord = geometry.getCoord().getTransformation().transformed(vec); - if(debug>0) System.out.printf("vec_mother_coord %s\n",vec_mother_coord.toString()); - if(geometry.getMother().getName().equals("trackingVolume")) { - if(debug>0) System.out.printf("reached tracking volume. Return \n"); - return vec_mother_coord; - } else { - if(debug>0) System.out.printf("continue searching.\n"); - } - return transformToTracking(vec_mother_coord, geometry.getMother()); - } - - /** - * Get the layer number consistent with the old geometry definition. - * @param module name that contains layer and half information. - * @return the layer. - */ - public static int getOldGeomDefLayerFromVolumeName(String name) { - String half = getHalfFromName(name); - boolean isTopLayer = false; - if(half=="top") isTopLayer=true; - else if(half=="bottom") isTopLayer = false; - else throw new RuntimeException("no half found from " + name); - boolean isAxial = false; - if(name.contains("axial")) isAxial=true; - else if(name.contains("stereo")) isAxial=false; - else throw new RuntimeException("no axial or stereo name found from " + name); - int l = getLayerFromVolumeName(name); - int layer=-1; - // convert to old definition - if(isAxial) { - if(isTopLayer) { - layer = 2*l-1; - } - else { - layer = 2*l; - } - } else { - if(isTopLayer) { - layer = 2*l; - } else { - layer = 2*l-1; - } - } - return layer; - } - - -}
\ No newline at end of file
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTrackerJavaBuilder.java 2014-09-29 17:06:12 UTC (rev 3352) +++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTrackerJavaBuilder.java 2014-09-30 23:23:47 UTC (rev 3353) @@ -1,513 +0,0 @@
-package org.lcsim.geometry.compact.converter.lcdd; - -import hep.physics.vec.BasicHep3Matrix; -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.DetectorIdentifierHelper; -import org.lcsim.detector.IDetectorElement; -import org.lcsim.detector.ILogicalVolume; -import org.lcsim.detector.IPhysicalVolume; -import org.lcsim.detector.IRotation3D; -import org.lcsim.detector.ITranslation3D; -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.detector.tracker.silicon.SiTrackerModule; -import org.lcsim.geometry.compact.Subdetector; -import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.BaseGeometry; -import org.lcsim.geometry.util.TransformationUtils; - -public abstract class HPSTrackerJavaBuilder implements IHPSTrackerJavaBuilder { - - protected boolean _debug = false; - private JavaBaseGeometry baseTrackerGeometry; - protected List<JavaBaseGeometry> java_objects = new ArrayList<JavaBaseGeometry>(); - protected DetectorIdentifierHelper detectorIdentifierHelper; - protected IIdentifierDictionary identifierDictionary; - protected Subdetector subdet; - protected List<IDetectorElement> layerDetectorElements = new ArrayList<IDetectorElement>(); - protected List<IDetectorElement> moduleDetectorElements = new ArrayList<IDetectorElement>(); - protected IDetectorElement baseDetectorElement = null; - public HPSTrackerBuilder _builder = null; - - public HPSTrackerJavaBuilder(boolean debugFlag) { - setDebug(debugFlag); - } - - public abstract void build(ILogicalVolume trackingVolume); - - - /** - * Add to list of objects. - * @param geom - object to add. - */ - public void add(JavaBaseGeometry geom) { - java_objects.add(geom); - } - - public void setBuilder(HPSTrackerBuilder b) { - _builder = b; - } - - public void build() { - _builder.build(); - } - - public void setDebug(boolean debug) { - _debug = debug; - } - - public boolean isDebug() { - return _debug; - } - - - public DetectorIdentifierHelper getDetectorIdentifierHelper() { - return detectorIdentifierHelper; - } - - public void setDetectorIdentifierHelper( - DetectorIdentifierHelper detectorIdentifierHelper) { - this.detectorIdentifierHelper = detectorIdentifierHelper; - } - - public IIdentifierDictionary getIdentifierDictionary() { - return identifierDictionary; - } - - public void setIdentifierDictionary( - IIdentifierDictionary identifierDictionary) { - this.identifierDictionary = identifierDictionary; - } - - - public void setSubdetector(Subdetector subdet) { - this.subdet = subdet; - } - - public Subdetector getSubdetector() { - return this.subdet; - } - - - - - - // This finds specific type. I would like to use the ID for this but can't, I think. - // TODO there must be a factory instance to do this - public SiTrackerModule getModuleDetectorElement(SiTrackerModule testElement) { - if(isDebug()) System.out.printf("%s: getModuleDetectorElement for module %s path: \"%s\"\n", this.getClass().getSimpleName(),testElement.getName(),testElement.getGeometry().getPathString()); - SiTrackerModule element = null; - for(IDetectorElement e : moduleDetectorElements) { - SiTrackerModule m = (SiTrackerModule) e; - if(isDebug()) System.out.printf("%s: compare with module %s path: %s\"%s\" \n", this.getClass().getSimpleName(),m.getName(),m.getGeometry().getPathString()); - if(m.getGeometry().getPathString().equals(testElement.getGeometry().getPathString())) { - if(element!=null) throw new RuntimeException("two DE sharing extended ID?"); - if(isDebug()) System.out.printf("%s: found it\n", this.getClass().getSimpleName()); - element = m; - } - } - return element; - } - - - // Find detector elements - // TODO This should be using some global geometry code like DetectorElementStore? - public IDetectorElement getLayerDetectorElement(IExpandedIdentifier expId) { - IDetectorElement element = null; - if(isDebug()) System.out.printf("%s: search among %d layer DEs\n", this.getClass().getSimpleName(), layerDetectorElements.size()); - for(IDetectorElement e : layerDetectorElements) { - if(isDebug()) System.out.printf("%s: test %s\n", this.getClass().getSimpleName(),e.getName()); - ExpandedIdentifier eId = (ExpandedIdentifier) e.getExpandedIdentifier(); - if(eId.equals(expId)) { // TODO order matters as expId is an interface without that function!? - //check that only one was found - if(element!=null) throw new RuntimeException("two DE sharing extended ID?"); - if(isDebug()) System.out.printf("%s: found it\n", this.getClass().getSimpleName()); - element = e; - } - - } - return element; - } - - - public void addLayerDetectorElement(IDetectorElement e) { - IExpandedIdentifier expId = e.getExpandedIdentifier(); - if(getLayerDetectorElement(expId) != null) - throw new RuntimeException("Trying to add an existing layer detector element."); - layerDetectorElements.add(e); - } - - public void addBaseDetectorElement(IDetectorElement e) { - baseDetectorElement = e; - } - - public IDetectorElement getBaseDetectorElement() { - return baseDetectorElement; - } - - public void addModuleDetectorElement(IDetectorElement e) { - if(!(e instanceof SiTrackerModule)) - throw new RuntimeException("Trying to add an existing module of wrong type."); - if(getModuleDetectorElement((SiTrackerModule) e) != null) - throw new RuntimeException("Trying to add an already existing module detector element."); - layerDetectorElements.add(e); - } - - - /** - * @return the baseTrackerGeometry - */ - public JavaBaseGeometry getBaseTrackerGeometry() { - return baseTrackerGeometry; - } - - /** - * @param baseTrackerGeometry the baseTrackerGeometry to set - */ - public void setBaseTrackerGeometry(JavaBaseGeometry baseTrackerGeometry) { - this.baseTrackerGeometry = baseTrackerGeometry; - } - - - /** - * - * Interface to the JAVA converter geometry for the geometry definition. - * In this case no volume is built but can be used as reference in building the geometry. - * @author Per Hansson Adrian <[log in to unmask]> - */ - public static class GhostJavaBaseGeom extends JavaBaseGeometry { - - /** - * 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, JavaBaseGeometry 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); - mother.addDaughter(this); - setPositionAndRotation(base); - if(isDebug()) System.out.printf("%s: DONE constructing JAVA object %s\n", this.getClass().getSimpleName(),base.getName()); - } - - - - } - - /** - * Interface to the JAVA converter geometry for the geometry definition. - * @author Per Hansson Adrian <[log in to unmask]> - */ - public static class JavaBaseGeometry { - private boolean debug = true; - private String name; - private Box box= null; - private ILogicalVolume volume = null; - private ITranslation3D pos = null; - private IRotation3D rot = null; - private IPhysicalVolume physVolume = null; - private JavaBaseGeometry mother = null; - public List<JavaBaseGeometry> daughters = new ArrayList<JavaBaseGeometry>(); - private int componentId = -1; - - /** - * Default constructor - */ - public JavaBaseGeometry() { - } - - /** - * Construct a JAVA geometry object from its geometry definition and an already built logical volume. - * This is typically used by the tracking volume. - * @param geomObject - input geometry definition - * @param vol - logical volume - */ - public JavaBaseGeometry(BaseGeometry geomObject, ILogicalVolume vol) { - if(isDebug()) System.out.printf("%s: JavaBaseGeometry %s (given logical volume %s)\n", this.getClass().getSimpleName(),geomObject.getName(),vol.getName()); - // this must be tracking volume. May change in the future and is probably weird to make this requirement here. - if(!geomObject.getName().contains("tracking")) throw new RuntimeException("this constructor is only used with the tracking volume!?"); - setName(geomObject.getName()); - setVolume(vol); - // since it's tracking volume, set the pos and rotation trivially - Hep3Vector lcdd_rot_angles = TransformationUtils.getCardanAngles(geomObject.getCoord().v(), geomObject.getCoord().w(), new BasicHep3Vector(0,1,0),new BasicHep3Vector(0,0,1)); - setPos(new Translation3D(0,0,0)); - setRot(new RotationGeant(lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z())); - if(isDebug()) System.out.printf("%s: DONE JavaBaseGeometry %s\n", this.getClass().getSimpleName(),geomObject.getName()); - } - - /** - * 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 JavaBaseGeometry(BaseGeometry geomObject, JavaBaseGeometry mother, int volumeId) { - if(isDebug()) System.out.printf("%s: JavaBaseGeometry %s (volumeID %d, mother %s)\n", this.getClass().getSimpleName(),geomObject.getName(),volumeId,mother==null?"null":mother.getName()); - setName(geomObject.getName()); - setComponentId(volumeId); - setMother(mother); - mother.addDaughter(this); - buildBox(geomObject); - buildVolume(geomObject); - setPositionAndRotation(geomObject); - if(isDebug()) System.out.printf("%s: DONE JavaBaseGeometry %s\n", this.getClass().getSimpleName(),geomObject.getName()); - } - - protected boolean hasCoordinateSystemInfo() { - return pos!=null && rot!=null; - } - - - public void buildPhysVolume() { - if(isDebug()) System.out.printf("%s: build phys volume for %s with mother %s and physical mother %s\n", this.getClass().getSimpleName(),getName(),getMother().getName(),getPhysMother().getName()); - JavaBaseGeometry physMother = getPhysMother(); - setPhysVolume(new PhysicalVolume(new Transform3D(getPos(), getRot()), name, volume, physMother.getVolume(),getComponentId())); - } - protected void buildBox(BaseGeometry base) { - Hep3Vector b = base.getBoxDim(); - b = VecOp.mult(0.5, b); - if(isDebug()) System.out.printf("%s: build box for %s with dimensions %s \n", this.getClass().getSimpleName(),getName(), b); - setBox(new Box(getName() + "Box", b.x(), b.y(), b.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 setPositionAndRotation(BaseGeometry base) { - if(isDebug()) System.out.printf("%s: set position and rotation for volume %s\n", this.getClass().getSimpleName(),getName()); - - // no mother, this must be the world/tracking volume!? - if(base.getMother()==null) throw new RuntimeException("trying to set coordinates w/o mother defined for "+base.getName()); - - // Vector from origin to center of box locally - Hep3Vector box_center_base_local = base.getCenter(); - - // find the physical mother i.e. not a ghost volume and compound transformations to it - JavaBaseGeometry physMother = getPhysMother(); - if(isDebug()) System.out.printf("%s: physical mother to transform to is %s; find the transform to it\n", this.getClass().getSimpleName(),physMother.getName()); - Transform3D trf = HPSTrackerBuilder.getTransform(base.getCoord().getTransformation(),base.getMother(),physMother.getName()); - if(isDebug()) System.out.printf("%s: found transform to physical mother \n%s\n\n", this.getClass().getSimpleName(),trf.toString()); - - // find the position of the center in the physical mother coord - Hep3Vector box_center_base = trf.transformed(box_center_base_local); - - // find the position of the center of the box in the mother coordinate system, make sure to use the physical mother coordinates - if(isDebug()) System.out.printf("%s: find center of box in physical mother coord %s \n", this.getClass().getSimpleName(),physMother.getName()); - // hack since my getTransform function needs a mother TODO Fix this! - BaseGeometry gm = base; - if(isDebug()) System.out.printf("%s: look for physical mother %s starting from mother %s \n", this.getClass().getSimpleName(),physMother.getName(),gm.getMother()!=null?gm.getMother().getName():"-- no mother --"); - while((gm=gm.getMother()).getName()!=physMother.getName()) { - if(isDebug()) System.out.printf("%s: gm is %s \n", this.getClass().getSimpleName(),gm.getName()); - //gm = gm.getMother(); - } - if(isDebug()) System.out.printf("%s: found physical mother %s with center at %s \n", this.getClass().getSimpleName(),gm.getName(), gm.getCenter()); - - Hep3Vector mother_center = gm.getCenter(); - - // now calculate the position of this box center in the mother LCDD coordinates - Hep3Vector box_center = VecOp.sub(box_center_base, mother_center); - - //Find LCDD Euler rotation angles from coordinate system unit vectors - //Note that this has to be rotation wrt to physical mother and not just mother as normally is the case - //Use apache lib to get angles, but in principle I should already have it from the trf above - //Hep3Vector lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(base.getCoord().v(), base.getCoord().w(), new BasicHep3Vector(0,1,0),new BasicHep3Vector(0,0,1)); - if(isDebug()) System.out.printf("%s: find LCDD Cardan rotation angles - need to find mother to physical mother transform \n", this.getClass().getSimpleName(),physMother.getName()); - Hep3Vector base_u = base.getCoord().u(); - Hep3Vector base_v = base.getCoord().v(); - Hep3Vector base_w = base.getCoord().w(); - if(isDebug()) System.out.printf("%s: unit vectors in mother coord: %s, %s, %s\n", this.getClass().getSimpleName(),base_u.toString(),base_v.toString(),base_w.toString()); - Hep3Vector unit_u = new BasicHep3Vector(1,0,0); - Hep3Vector unit_v = new BasicHep3Vector(0,1,0); - Hep3Vector unit_w = new BasicHep3Vector(0,0,1); - if(!base.getMother().getName().equals(physMother.getName())) { - if(isDebug()) System.out.printf("%s: Need to get unit vectors in physical mother %s coord system\n", this.getClass().getSimpleName(),physMother.getName()); - Transform3D trf_mother = HPSTrackerBuilder.getTransform(base.getMother().getCoord().getTransformation(),base.getMother().getMother(),physMother.getName()); - if(isDebug()) System.out.printf("%s: found transform from mother to physical mother \n%s\n", this.getClass().getSimpleName(),trf_mother.toString()); - //unit_u = VecOp.unit(trf_mother.rotated(unit_u)); - //unit_v = VecOp.unit(trf_mother.rotated(unit_v)); - //unit_w = VecOp.unit(trf_mother.rotated(unit_w)); - base_u = VecOp.unit(trf_mother.rotated(base_u)); - base_v = VecOp.unit(trf_mother.rotated(base_v)); - base_w = VecOp.unit(trf_mother.rotated(base_w)); - - } else { - if(isDebug()) System.out.printf("%s: mother and physical mother is the same so unit vectors didn't change\n",getClass().getSimpleName()); - } - - if(isDebug()) { - if(isDebug()) System.out.printf("%s: final unit vectors to get Cardan angles from : \n%s, %s, %s -> %s, %s, %s \n", - this.getClass().getSimpleName(), - base_u.toString(),base_v.toString(),base_w.toString(), - unit_u.toString(),unit_v.toString(),unit_w.toString()); - //System.out.printf("%s: unit vectors u %s v %s w %s\n", this.getClass().getSimpleName(),base.getCoord().u().toString(),base.getCoord().v().toString(),base.getCoord().w().toString()); - } - - //Hep3Vector lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(unit_u,unit_v,base.getCoord().u(), base.getCoord().v()); - //Hep3Vector lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(base.getCoord().u(), base.getCoord().v(), unit_u,unit_v); - Hep3Vector lcdd_rot_angles = TransformationUtils.getCardanAngles(base_u, base_v, base_w, unit_u, unit_v, unit_w); - - /* - - // 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) { - if(isDebug()) System.out.printf("%s: explicit angles to be applied %s\n", this.getClass().getSimpleName(),base.explicit_rot_angles.toString()); - // there are explicit rotations I need to apply. - // Find the displacement of the box center due to rotation about different origin - // Find the origin in the physical mother coord - if(isDebug()) System.out.printf("%s: transform origin %s to physical mother %s\n", this.getClass().getSimpleName(),base.getCoord().origin(),physMother.getName()); - Transform3D tpm = - getTransform(base.getMother().getCoord().getTransformation(),base.getMother().getMother(),physMother.getName()); - if(isDebug()) System.out.printf("%s: found transform to physical mother \n%s\n\n", this.getClass().getSimpleName(),tpm.toString()); - Hep3Vector origin_mother = tpm.transformed(base.getCoord().origin()); - if(isDebug()) System.out.printf("%s: origin in physical mother coord is %s\n", this.getClass().getSimpleName(),origin_mother.toString()); - Hep3Vector box_center_base_rot = HPSTestRunTracker2014.getRotationDisplacement(origin_mother, 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: origin %s\n", this.getClass().getSimpleName(), base.getCoord().origin().toString()); - System.out.printf("%s: origin_mother %s\n", this.getClass().getSimpleName(), origin_mother.toString()); - 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, mother_center); - } - */ - - // 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()==null?" <no mother> ":mother_center.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()); - - //calculate the position in tracking volume separately as a xcheck - Hep3Vector box_center_tracking_xcheck = HPSTrackerBuilder.transformToTracking(box_center_base_local, base); - System.out.printf("%s: box_center_tracking_xcheck %s for %s\n", this.getClass().getSimpleName(), box_center_tracking_xcheck.toString(),base.getName()); - } - - } - - /** - * Find the first non-ghost volume among parents. - * @return mother object - */ - public JavaBaseGeometry getPhysMother() { - //if(isDebug()) System.out.printf("%s: finding physical mother to %s\n", this.getClass().getSimpleName(), getName()); - if(mother==null) throw new RuntimeException("Trying to get phys mother but there is no mother!"); - if(mother instanceof GhostJavaBaseGeom) { - return mother.getPhysMother(); - } else { - //if(isDebug()) System.out.printf("%s: found a non-ghost volume: %s\n", this.getClass().getSimpleName(), mother.getName()); - return mother; - } - } - - - public ILogicalVolume getVolume() { - return volume; - } - protected void setVolume(ILogicalVolume volume) { - this.volume = volume; - } - protected Box getBox() { - return box; - } - protected void setBox(Box b) { - box = b; - } - public String getName() { - return name; - } - protected void setName(String name) { - this.name = name; - } - protected ITranslation3D getPos() { - return pos; - } - protected void setPos(ITranslation3D iTranslation3D) { - this.pos = iTranslation3D; - } - protected IRotation3D getRot() { - return rot; - } - protected void setRot(IRotation3D iRotation3D) { - this.rot = iRotation3D; - } - public JavaBaseGeometry getMother() { - return mother; - } - protected void setMother(JavaBaseGeometry mother) { - this.mother = mother; - } - public IPhysicalVolume getPhysVolume() { - return physVolume; - } - protected void setPhysVolume(PhysicalVolume physVolume) { - this.physVolume = physVolume; - } - public boolean isDebug() { - return debug; - } - - public List<JavaBaseGeometry> getDaughters() { - return daughters; - } - - protected void addDaughter(JavaBaseGeometry o) { - getDaughters().add(o); - } - - public int getComponentId() { - return componentId; - } - - public void setComponentId(int componentId) { - this.componentId = componentId; - } - - public String toString() { - String s = "JavaBaseGeometry " + getName() + "\n"; - if(getPos()!=null && getRot()!=null) { - s += "Position: " + getPos().toString() + "\n"; - s += "Rotation: " + getRot().toString() + "\n"; - } else { - s+= " - no position/rotation info -\n"; - } - return s; - } - - } - - -}
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTrackerLCDDBuilder.java 2014-09-29 17:06:12 UTC (rev 3352) +++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTrackerLCDDBuilder.java 2014-09-30 23:23:47 UTC (rev 3353) @@ -1,439 +0,0 @@
-package org.lcsim.geometry.compact.converter.lcdd; - -import hep.physics.vec.BasicHep3Vector; -import hep.physics.vec.Hep3Vector; -import hep.physics.vec.VecOp; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.jdom.JDOMException; -import org.lcsim.detector.Transform3D; -import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.BaseGeometry; -import org.lcsim.geometry.compact.converter.lcdd.util.Box; -import org.lcsim.geometry.compact.converter.lcdd.util.LCDD; -import org.lcsim.geometry.compact.converter.lcdd.util.Material; -import org.lcsim.geometry.compact.converter.lcdd.util.PhysVol; -import org.lcsim.geometry.compact.converter.lcdd.util.Position; -import org.lcsim.geometry.compact.converter.lcdd.util.Rotation; -import org.lcsim.geometry.compact.converter.lcdd.util.SensitiveDetector; -import org.lcsim.geometry.compact.converter.lcdd.util.Volume; -import org.lcsim.geometry.util.TransformationUtils; - -public abstract class HPSTrackerLCDDBuilder implements IHPSTrackerLCDDBuilder { - - public boolean _debug = true; - protected LCDD lcdd; - protected LCDDBaseGeometry baseTrackerGeometry; - protected List<LCDDBaseGeometry> lcddGeometries = new ArrayList<LCDDBaseGeometry>(); - private SensitiveDetector sensitiveDetector; - public HPSTrackerBuilder _builder = null; - - - - public HPSTrackerLCDDBuilder(boolean debugFlag) { - setDebug(debugFlag); - } - - public void setSensitiveDetector(SensitiveDetector sens) { - this.sensitiveDetector = sens; - } - - public SensitiveDetector getSensitiveDetector() { - return this.sensitiveDetector; - } - - public void setBuilder(HPSTrackerBuilder b) { - _builder = b; - } - - public void build() { - _builder.build(); - } - - public void setDebug(boolean debug) { - _debug = debug; - } - - public boolean isDebug() { - return _debug; - } - - /** - * Interface to the LCDD converter geometry for the geometry definition. - * - * @author Per Hansson Adrian <[log in to unmask]> - */ - public static class LCDDBaseGeometry extends LCDDBaseGeometryVisualization { - private boolean debug = true; - private String name; - private Box box= null; - private Volume volume = null; - private Position pos = null; - private Rotation rot = null; - private PhysVol physVolume = null; - private LCDD lcdd = null; - private LCDDBaseGeometry mother = null; - protected Map<String,Integer> physVolId = null; - public List<LCDDBaseGeometry> daughters = new ArrayList<LCDDBaseGeometry>(); - /** - * Default constructor - */ - public 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 LCDDBaseGeometry(BaseGeometry base, Volume volume) { - super(); - if(isDebug()) System.out.printf("%s: constructing LCDD object %s with given volume name %s\n", this.getClass().getSimpleName(),base.getName(),volume.getName()); - setName(base.getName()); - setVolume(volume); - if(isDebug()) System.out.printf("%s: DONE constructing LCDD object %s\n", this.getClass().getSimpleName(),base.getName()); - Hep3Vector lcdd_rot_angles = TransformationUtils.getCardanAngles(base.getCoord().v(), base.getCoord().w(), new BasicHep3Vector(0,1,0),new BasicHep3Vector(0,0,1)); - setPos(new Position(getName() + "_position", 0, 0, 0)); - setRot(new Rotation(getName() + "_rotation",lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z())); - if(isDebug()) System.out.printf("%s: DONE JavaBaseGeometry %s\n", this.getClass().getSimpleName(),base.getName()); - } - - /** - * Interface to the LCDD converter geometry for the geometry definition. - * @param base - input geometry definition - * @param lcdd - lcdd file - * @param mother - reference to mother LCDD definition - */ - 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()); - setMother(mother); - mother.addDaughter(this); - buildBox(base); - buildVolume(base); - setPositionAndRotation(base); - //buildPhysVolume(mother); - if(isDebug()) System.out.printf("%s: DONE constructing LCDD object %s\n", this.getClass().getSimpleName(),base.getName()); - } - - - protected void buildPhysVolume() { - 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(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()); - try { - Material mat = lcdd.getMaterial(base.getMaterial()); - setVolume(new Volume(getName() + "_volume", box, mat)); - } catch (JDOMException e) { - e.printStackTrace(); - } - } - - - protected void setPositionAndRotation(BaseGeometry base) { - if(isDebug()) System.out.printf("%s: set position and rotation for volume %s\n", this.getClass().getSimpleName(),getName()); - - // NOTE: - // This sets position and reference w.r.t. mother coordinate system. - // If I'm not building that volume this will be wrong. - // TODO Similar to in the JAVA converter this should be something like the physical mother. - - if(base.getMother()==null) throw new RuntimeException("trying to set coordinates w/o mother defined for "+base.getName()); - - // Vector from origin to center of box locally - Hep3Vector box_center_base_local = base.getCenter(); - - //translate to the mother coordinate system - LCDDBaseGeometry physMother = getPhysMother(); - if(isDebug()) System.out.printf("%s: physical mother to transform to is %s; find the transform to it\n", this.getClass().getSimpleName(),physMother.getName()); - Transform3D trf = HPSTrackerBuilder.getTransform(base.getCoord().getTransformation(),base.getMother(),physMother.getName()); - if(isDebug()) System.out.printf("%s: found transform to physical mother \n%s\n\n", this.getClass().getSimpleName(),trf.toString()); - - // find the position of the center in the physical mother coord - Hep3Vector box_center_base = trf.transformed(box_center_base_local); - - // find the position of the center of the box in the mother coordinate system, make sure to use the physical mother coordinates - if(isDebug()) System.out.printf("%s: find center of box in physical mother coord %s \n", this.getClass().getSimpleName(),physMother.getName()); - // hack since my getTransform function needs a mother TODO Fix this! - BaseGeometry gm = base; - if(isDebug()) System.out.printf("%s: look for physical mother %s starting from mother %s \n", this.getClass().getSimpleName(),physMother.getName(),gm.getMother()!=null?gm.getMother().getName():"-- no mother --"); - while((gm=gm.getMother()).getName()!=physMother.getName()) { - if(isDebug()) System.out.printf("%s: gm is %s \n", this.getClass().getSimpleName(),gm.getName()); - //gm = gm.getMother(); - } - if(isDebug()) System.out.printf("%s: found physical mother %s with center at %s \n", this.getClass().getSimpleName(),gm.getName(), gm.getCenter()); - - Hep3Vector mother_center = gm.getCenter(); - - // find the position of the center in the mother coord - Hep3Vector box_center = VecOp.sub(box_center_base, mother_center); - - //Find LCDD Euler rotation angles from coordinate system unit vectors - //Note that this has to be rotation wrt to physical mother and not just mother as normally is the case - if(isDebug()) System.out.printf("%s: find LCDD Cardan rotation angles - need to find mother to physical mother transform \n", this.getClass().getSimpleName(),physMother.getName()); - Hep3Vector base_u = base.getCoord().u(); - Hep3Vector base_v = base.getCoord().v(); - Hep3Vector base_w = base.getCoord().w(); - if(isDebug()) System.out.printf("%s: unit vectors in mother coord: %s, %s, %s\n", this.getClass().getSimpleName(),base_u.toString(),base_v.toString(),base_w.toString()); - Hep3Vector unit_u = new BasicHep3Vector(1,0,0); - Hep3Vector unit_v = new BasicHep3Vector(0,1,0); - Hep3Vector unit_w = new BasicHep3Vector(0,0,1); - if(!base.getMother().getName().equals(physMother.getName())) { - if(isDebug()) System.out.printf("%s: Need to get unit vectors in physical mother %s coord system\n", this.getClass().getSimpleName(),physMother.getName()); - Transform3D trf_mother = HPSTrackerBuilder.getTransform(base.getMother().getCoord().getTransformation(),base.getMother().getMother(),physMother.getName()); - if(isDebug()) System.out.printf("%s: found transform from mother to physical mother \n%s\n", this.getClass().getSimpleName(),trf_mother.toString()); - //unit_u = VecOp.unit(trf_mother.rotated(unit_u)); - //unit_v = VecOp.unit(trf_mother.rotated(unit_v)); - //unit_w = VecOp.unit(trf_mother.rotated(unit_w)); - base_u = VecOp.unit(trf_mother.rotated(base_u)); - base_v = VecOp.unit(trf_mother.rotated(base_v)); - base_w = VecOp.unit(trf_mother.rotated(base_w)); - - } else { - if(isDebug()) System.out.printf("%s: mother and physical mother is the same so unit vectors didn't change\n",getClass().getSimpleName()); - } - - if(isDebug()) { - if(isDebug()) System.out.printf("%s: final unit vectors to get Cardan angles from : \n%s, %s, %s -> %s, %s, %s \n", - this.getClass().getSimpleName(), - base_u.toString(),base_v.toString(),base_w.toString(), - unit_u.toString(),unit_v.toString(),unit_w.toString()); - //System.out.printf("%s: unit vectors u %s v %s w %s\n", this.getClass().getSimpleName(),base.getCoord().u().toString(),base.getCoord().v().toString(),base.getCoord().w().toString()); - } - Hep3Vector lcdd_rot_angles = TransformationUtils.getCardanAngles(base_u, base_v, base_w, unit_u, unit_v, unit_w); - - // 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: 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.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 Position(getName() + "_position",box_center.x(), box_center.y(), box_center.z())); - - 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()); - 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(), mother_center.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()); - - //calculate the position in tracking volume separately as a xcheck - Hep3Vector box_center_tracking_xcheck = HPSTrackerBuilder.transformToTracking(box_center_base_local, base); - System.out.printf("%s: box_center_tracking_xcheck %s\n", this.getClass().getSimpleName(), box_center_tracking_xcheck.toString()); - } - - } - /** - * Find the first non-ghost volume among parents. - * @return mother object - */ - public LCDDBaseGeometry getPhysMother() { - //if(isDebug()) System.out.printf("%s: finding physical mother to %s\n", this.getClass().getSimpleName(), getName()); - if(mother==null) throw new RuntimeException("Trying to get phys mother but there is no mother!"); - if(mother instanceof GhostLCDDBaseGeometry) { - return mother.getPhysMother(); - } else { - //if(isDebug()) System.out.printf("%s: found a non-ghost volume: %s\n", this.getClass().getSimpleName(), mother.getName()); - return mother; - } - } - - protected Volume getVolume() { - return volume; - } - protected void setVolume(Volume 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 Position getPos() { - return pos; - } - protected void setPos(Position pos) { - this.pos = pos; - } - protected Rotation getRot() { - return rot; - } - protected void setRot(Rotation rot) { - this.rot = rot; - } - protected LCDDBaseGeometry getMother() { - return mother; - } - protected void setMother(LCDDBaseGeometry mother) { - this.mother = mother; - } - protected PhysVol getPhysVolume() { - return physVolume; - } - protected void setPhysVolume(PhysVol physVolume) { - this.physVolume = physVolume; - } - public boolean isDebug() { - return debug; - } - protected List<LCDDBaseGeometry> getDaughters() { - return daughters; - } - protected void addDaughter(LCDDBaseGeometry o) { - getDaughters().add(o); - } - public String toString() { - String s = "LCDDBaseGeometry " + getName() + "\n"; - if(getPos()!=null && getRot()!=null) { - double x = Double.valueOf(getPos().getAttributeValue("x")); - double y = Double.valueOf(getPos().getAttributeValue("y")); - double z = Double.valueOf(getPos().getAttributeValue("z")); - s += "Position: " + String.format("(%.4f %.4f %.4f)\n", x,y,z); - x = Double.valueOf(getRot().getAttributeValue("x")); - y = Double.valueOf(getRot().getAttributeValue("y")); - z = Double.valueOf(getRot().getAttributeValue("z")); - s += "Rotation: " + String.format("(%.4f %.4f %.4f)\n", x,y,z); - } else { - s += " - no position/rotation info -\n"; - } - return s; - } - } - - /** - * Add to list of objects. - * @param geom - object to add. - */ - protected void add(LCDDBaseGeometry geom) { - lcddGeometries.add(geom); - } - - /** - * Build the LCDD geometry objects. - * @param worldVolume - the reference volume. - */ - public abstract void build(Volume worldVolume); - - - - protected void setLCDD(LCDD lcdd) { - this.lcdd = lcdd; - } - - protected LCDD getLCDD() { - return lcdd; - } - - protected LCDDBaseGeometry getBaseLCDD() { - return baseTrackerGeometry; - } - - /** - * - * Interface to the LCDD converter geometry for the geometry definition. - * 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 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; - } - - - } - - - - public void setVisualization() { - - if(isDebug()) System.out.printf("%s: Set LCDD visualization for %d LCDD geometry objects \n", getClass().getSimpleName(), lcddGeometries.size()); - for(LCDDBaseGeometry g : lcddGeometries) { - if(isDebug()) System.out.printf("%s: Set LCDD vis for %s \n", getClass().getSimpleName(), g.getName()); - if(g.getName().endsWith("baseplate")) g.setVisName("BasePlateVis"); - //else if(g.getName().contains("base")) g.setVisName("BaseVis"); - 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()); - } - } - if(isDebug()) System.out.printf("%s: DONE Set LCDD vis \n", getClass().getSimpleName()); - } - - -}
\ No newline at end of file
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/IHPSTrackerJavaBuilder.java 2014-09-29 17:06:12 UTC (rev 3352) +++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/IHPSTrackerJavaBuilder.java 2014-09-30 23:23:47 UTC (rev 3353) @@ -1,31 +0,0 @@
-package org.lcsim.geometry.compact.converter.lcdd; - -import org.lcsim.detector.DetectorIdentifierHelper; -import org.lcsim.detector.ILogicalVolume; -import org.lcsim.detector.identifier.IIdentifierDictionary; -import org.lcsim.geometry.compact.Subdetector; - -public interface IHPSTrackerJavaBuilder { - - /** - * Build the JAVA geometry objects from the geometry definition. - * @param trackingVolume - the reference volume. - */ - public void build(ILogicalVolume trackingVolume); - - public DetectorIdentifierHelper getDetectorIdentifierHelper(); - - public void setDetectorIdentifierHelper( - DetectorIdentifierHelper detectorIdentifierHelper); - - public IIdentifierDictionary getIdentifierDictionary(); - - public void setIdentifierDictionary( - IIdentifierDictionary identifierDictionary); - - - public void setSubdetector(Subdetector subdet); - - public Subdetector getSubdetector(); - -}
\ No newline at end of file
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/IHPSTrackerLCDDBuilder.java 2014-09-29 17:06:12 UTC (rev 3352) +++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/IHPSTrackerLCDDBuilder.java 2014-09-30 23:23:47 UTC (rev 3353) @@ -1,15 +0,0 @@
-package org.lcsim.geometry.compact.converter.lcdd; - -import org.lcsim.geometry.compact.converter.lcdd.util.SensitiveDetector; -import org.lcsim.geometry.compact.converter.lcdd.util.Volume; - -public interface IHPSTrackerLCDDBuilder { - - public void setSensitiveDetector(SensitiveDetector sens); - - public SensitiveDetector getSensitiveDetector(); - - public void build(Volume worldVolume); - - public void setVisualization(); -}
\ No newline at end of file
Use REPLY-ALL to reply to list
To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1