Commit in projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter on MAIN
HPSTestRunTracker2014GeometryDefinition.java+1496-14933373 -> 3374
Fix indentation.

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter
HPSTestRunTracker2014GeometryDefinition.java 3373 -> 3374
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/HPSTestRunTracker2014GeometryDefinition.java	2014-10-17 23:27:44 UTC (rev 3373)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/HPSTestRunTracker2014GeometryDefinition.java	2014-10-17 23:28:11 UTC (rev 3374)
@@ -22,9 +22,9 @@
  */
 
 public class HPSTestRunTracker2014GeometryDefinition extends HPSTrackerBuilder {
-    
-   
 
+
+
     //steering
     public final boolean doAxial = true;
     public final boolean doStereo = true;
@@ -32,1623 +32,1626 @@
     public final boolean doBottom = true;
     public final boolean doTop = true;
     public final int layerBitMask = 0x1F;   
-    
-    
-		//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;
 
 
-		
-		public HPSTestRunTracker2014GeometryDefinition(boolean debug, Element node) {
-		    super(debug, node);
-		}
+    //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;
 
-		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
-            TrackingVolume tracking = new TrackingVolume("trackingVolume",null);
-            geometries.add(tracking);
-            TrackerEnvelope base = new TrackerEnvelope("base",tracking);
-            geometries.add(base);
-            BasePlate basePlate = new BasePlate("baseplate",base, "Aluminum");
-            geometries.add(basePlate);
-            CSupport cSupport = new CSupport("c_support", base);
-            geometries.add(cSupport);
-            SupportBottom supportBottom = new 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
-            SupportPlateBottom supportPlateBottom = new SupportPlateBottom("support_plate_bottom", base, supportBottom, "Aluminum");
-            geometries.add(supportPlateBottom);
-            SupportTop supportTop = new SupportTop("support_top", base, cSupport);
-            geometries.add(supportTop);
-            SupportPlateTop supportPlateTop = new 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(SurveyVolume bg : geometries) {
-                    System.out.printf("-------\n%s\n", bg.toString());
-                }
+    public HPSTestRunTracker2014GeometryDefinition(boolean debug, Element node) {
+        super(debug, node);
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.lcsim.geometry.compact.converter.HPSTrackerBuilder#build()
+     */
+    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
+        TrackingVolume tracking = new TrackingVolume("trackingVolume",null);
+        geometries.add(tracking);
+        TrackerEnvelope base = new TrackerEnvelope("base",tracking);
+        geometries.add(base);
+        BasePlate basePlate = new BasePlate("baseplate",base, "Aluminum");
+        geometries.add(basePlate);
+        CSupport cSupport = new CSupport("c_support", base);
+        geometries.add(cSupport);
+        SupportBottom supportBottom = new 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
+        SupportPlateBottom supportPlateBottom = new SupportPlateBottom("support_plate_bottom", base, supportBottom, "Aluminum");
+        geometries.add(supportPlateBottom);
+        SupportTop supportTop = new SupportTop("support_top", base, cSupport);
+        geometries.add(supportTop);
+        SupportPlateTop supportPlateTop = new 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(SurveyVolume 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 SurveyVolume mother;
+        final SurveyVolume ref;
+        if(half == "bottom") {
+            mother = getBaseGeometry(TrackerEnvelope.class);
+            ref = getBaseGeometry(SupportPlateBottom.class);
+        } else {
+            mother= getBaseGeometry(TrackerEnvelope.class);
+            ref = getBaseGeometry(SupportPlateTop.class);
+        }
+
+        //Create the module
+        TestRunModule module;
+        if(isL13) {
+            module = new TestRunModuleL13(volName, mother, ref, layer, half);
+        } else {
+            module = new TestRunModuleL45(volName, mother, ref, layer, half);
+        }
+
+
+        // create the bundle for this module
+        TestRunModuleBundle bundle = new TestRunModuleBundle(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(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
+        TestRunColdBlock coldBlock;
+
+        if(layer >= 1 && layer <=3) {
+            coldBlock = new TestRunColdBlockL13(volName, mother, layer);
+        } else if(layer >= 4 && layer <=5) {
+            coldBlock = new 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, TestRunModule mother) {
         
-        /**
-         * Create the module. 
-         * @param layer - of the module
-         * @param half - top or bottom half of the tracker
-         */
-        private void makeModuleBundle(int layer, String half) 
-        {
+        String moduleName = mother.getName();
 
-            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 SurveyVolume mother;
-            final SurveyVolume ref;
-            if(half == "bottom") {
-                mother = getBaseGeometry(TrackerEnvelope.class);
-                ref = getBaseGeometry(SupportPlateBottom.class);
+        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();
+
+        TestRunModuleBundle bundle  = (TestRunModuleBundle)getModuleBundle(mother);
+        TestRunHalfModuleBundle halfModuleBundle;
+
+        // Build the half-module
+        TestRunHalfModule halfModule;
+        if(side == "axial") {
+            halfModule = new TestRunHalfModuleAxial(volName, mother, null, layer, half);
+            halfModuleBundle = new TestRunHalfModuleBundle(halfModule);
+            bundle.halfModuleAxial = halfModuleBundle;
+        } else if(side == "stereo") {
+            halfModule = new TestRunHalfModuleStereo(volName, mother, null, layer, half);
+            halfModuleBundle = new TestRunHalfModuleBundle(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(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;
+
+        Hybrid hybrid = new Hybrid(volName,mother,component_number);
+        hybrid.setMaterial("G10");
+
+        TestRunHalfModuleBundle hm = (TestRunHalfModuleBundle) getHalfModuleBundle((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(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;
+
+        CarbonFiber cf = new CarbonFiber(volName,mother,component_number);
+        cf.setMaterial("CarbonFiber");
+
+        TestRunHalfModuleBundle hm = (TestRunHalfModuleBundle) getHalfModuleBundle((TestRunModule) mother.getMother(), mother.getName());
+        hm.carbonFiber = cf;
+
+    }
+
+
+
+
+    private void makeHalfModuleComponentKapton(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;
+
+        HalfModuleLamination lamination = new HalfModuleLamination(volName,mother,component_number);
+        lamination.setMaterial("Kapton");
+
+
+        TestRunHalfModuleBundle hm = (TestRunHalfModuleBundle) getHalfModuleBundle((TestRunModule) mother.getMother(), mother.getName());
+        hm.lamination = lamination;
+
+    }
+
+
+    private void makeHalfModuleComponentSensor(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;
+
+        //  
+        Sensor sensor = new Sensor(volName, mother, component_number);
+        sensor.setMaterial("Silicon");
+
+        TestRunHalfModuleBundle hm = (TestRunHalfModuleBundle) getHalfModuleBundle((TestRunModule) mother.getMother(), mother.getName());
+        hm.sensor = sensor;
+
+
+        makeHalfModuleComponentActiveSensor(sensor);
+
+
+    }
+
+
+    private void makeHalfModuleComponentActiveSensor(Sensor mother) {
+
+        if(isDebug()) System.out.printf("%s: makeHalfModuleComponentActiveSensor for %s \n", this.getClass().getSimpleName(), mother.getName());
+
+        String volName = mother.getName() + "_active";
+
+        ActiveSensor active_sensor = new ActiveSensor(volName, mother);
+        active_sensor.setMaterial("Silicon");
+
+        TestRunHalfModuleBundle hm = (TestRunHalfModuleBundle) getHalfModuleBundle((TestRunModule) mother.getMother().getMother(), mother.getMother().getName());
+        hm.activeSensor = active_sensor;
+
+    }
+
+    private boolean doLayer(int layer) {
+        int a = (1<<(layer-1)) & layerBitMask;
+        return a!=0?true:false;
+    }
+
+
+    /**
+     * Tracking volume geometry definition. 
+     */
+    public static class TrackingVolume extends SurveyVolume {
+        public TrackingVolume(String name, SurveyVolume mother) {
+            super(name,mother, null);
+            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 TrackerEnvelope extends SurveyVolume {
+        // 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
+        public static final double base_height = PS_vac_box_inner_height - BasePlate.base_plate_offset_height; 
+        public static final double base_width = BasePlate.base_plate_width;
+        public static final double base_length = BasePlate.base_plate_length;
+
+        public TrackerEnvelope(String name, SurveyVolume mother) {
+            super(name,mother, null);
+            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 SurveyVolume {
+        // Base plate references	
+        public static final double base_plate_thickness = 0.25*inch;
+        public static final double base_plate_width = 385.00;
+        public 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, SurveyVolume mother, String material) {
+            super(name,mother, null);
+            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 SurveyVolume {
+        // 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, SurveyVolume mother) {
+            super(name,mother, null);
+            init();
+        }			
+        private void calcAndSetFlatPos() {
+            if(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 {
-                mother= getBaseGeometry(TrackerEnvelope.class);
-                ref = getBaseGeometry(SupportPlateTop.class);
+
+                //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());
+
             }
-            
-            //Create the module
-            TestRunModule module;
-            if(isL13) {
-                module = new TestRunModuleL13(volName, mother, ref, layer, half);
-            } else {
-                module = new TestRunModuleL45(volName, mother, ref, layer, half);
+        }
+        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 SurveyVolume {
+        // 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, SurveyVolume mother) {
+            super(name,mother, null);
+            init();
+        }
+        public SupportTop(String name, SurveyVolume mother, SurveyVolume referenceGeom) {
+            super(name,mother,null, referenceGeom);
+            init();
+        }
+        public SupportTop(String name, SurveyVolume mother, List<SurveyVolume> referenceGeom) {
+            super(name,mother,null, 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());
             }
-            
-            
-            // create the bundle for this module
-            TestRunModuleBundle bundle = new TestRunModuleBundle(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();
+
+            for(SurveyVolume 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);
+        }
+    }
 
-        /**
-         * Create the cold block object.
-         * @param mother to the cold block
-         */
-        private void makeColdBlock(TestRunModule mother) { 
 
 
-            String moduleName = mother.getName();
+    public static class SupportBottom extends SurveyVolume {
+        // "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;
 
-            if(isDebug()) System.out.printf("%s: makeColdBlock for %s \n", this.getClass().getSimpleName(), moduleName);
+        //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;
 
 
-            String volName = moduleName + "_coldblock";
+        public SupportBottom(String name, SurveyVolume mother, SurveyVolume referenceGeom) {
+            super(name,mother,null, referenceGeom);
+            init();
+        }
 
-            // find layer
-            int layer = getLayerFromVolumeName(moduleName);
+        protected void setPos() {
 
-            // Build the half-module
-            TestRunColdBlock coldBlock;
+            if(debug) System.out.printf("%s: setPos support bottom\n",this.getClass().getSimpleName());
 
-            if(layer >= 1 && layer <=3) {
-                coldBlock = new TestRunColdBlockL13(volName, mother, layer);
-            } else if(layer >= 4 && layer <=5) {
-                coldBlock = new TestRunColdBlockL45(volName, mother, layer);
-            } else {
-                throw new RuntimeException("wrong layer for " + volName);
+            // 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());
             }
 
-            ModuleBundle bundle = getModuleBundle(mother);
-            bundle.coldBlock = coldBlock;
-        }
+            for(SurveyVolume ref : referenceGeom) {
 
+                if(debug) {
+                    System.out.printf("%s: survey positions before ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
+                    printSurveyPos();
+                }
 
-        
-        /**
-         * Create the half-module.
-         * @param side - stereo or axial
-         * @param mother to the half-module
-         */
-        private void makeHalfModule(String side, 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();
-            
-            TestRunModuleBundle bundle  = (TestRunModuleBundle)getModuleBundle(mother);
-            TestRunHalfModuleBundle halfModuleBundle;
-            
-            // Build the half-module
-            TestRunHalfModule halfModule;
-            if(side == "axial") {
-                halfModule = new TestRunHalfModuleAxial(volName, mother, layer, half);
-                halfModuleBundle = new TestRunHalfModuleBundle(halfModule);
-                bundle.halfModuleAxial = halfModuleBundle;
-            } else if(side == "stereo") {
-                halfModule = new TestRunHalfModuleStereo(volName, mother, layer, half);
-                halfModuleBundle = new TestRunHalfModuleBundle(halfModule);
-                bundle.halfModuleStereo = halfModuleBundle;
-            } else {
-                throw new IllegalArgumentException("not a valid half-module side " + side);
+                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();
+                }
             }
-            
-            
-            // create the half module components 
-            
-            makeHalfModuleComponentSensor(halfModule);
-            
-            makeHalfModuleComponentKapton(halfModule);
-            
-            makeHalfModuleComponentCF(halfModule);
-            
-            makeHalfModuleComponentHybrid(halfModule);
-                
-            
-            
-            
+
         }
-        
-        
-        
-        private void makeHalfModuleComponentHybrid(TestRunHalfModule mother) {
-            
-            if(isDebug()) System.out.printf("%s: makeHalfModuleComponentHybrid for %s \n", this.getClass().getSimpleName(), mother.getName());
+        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);
+        }
 
-            String volName = mother.getName() + "_hybrid";
+    }
 
-            // Build the half-module
-            
-            //  id is hard coded
-            int component_number = 3;
 
-            Hybrid hybrid = new Hybrid(volName,mother,component_number);
-            hybrid.setMaterial("G10");
-            
-            TestRunHalfModuleBundle hm = (TestRunHalfModuleBundle) getHalfModuleBundle((TestRunModule) mother.getMother(), mother.getName());
-            hm.hybrid = hybrid;
+    protected static abstract class SupportPlate extends SurveyVolume {
+        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(SurveyVolume mother, SurveyVolume referenceGeom, String name, String material) {
+            super(name,mother,null, referenceGeom);
+            setMaterial(material);
+        }
+        public SupportPlate(SurveyVolume mother, List<SurveyVolume> referenceGeom, String name, String material) {
+            super(name,mother,null, referenceGeom);
+            setMaterial(material);
+        }
 
-            if(isDebug()) System.out.printf("%s: added hybrid to half-module with name %s \n", this.getClass().getSimpleName(), hm.halfModule.getName());
+    }
 
-        
+
+
+
+
+    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, SurveyVolume mother, SurveyVolume referenceGeom, String material) {
+            super(mother, referenceGeom, name, material);
+            init();				
         }
+        public SupportPlateBottom(String name, SurveyVolume mother, List<SurveyVolume> 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());
+            }
 
-        private void makeHalfModuleComponentCF(TestRunHalfModule mother) {
+            for(SurveyVolume ref : referenceGeom) {
 
-            if(isDebug()) System.out.printf("%s: makeHalfModuleComponentCF for %s \n", this.getClass().getSimpleName(), mother.getName());
+                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());
 
-            String volName = mother.getName() + "_cf";
+                ref.getCoord().getTransformation().transform(ballPos);
+                ref.getCoord().getTransformation().transform(veePos);
+                ref.getCoord().getTransformation().transform(flatPos);
 
-            // Build the half-module
-            
-            //  id is hard coded
-            int component_number = 1;
+                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);
+        }
+    }
 
-            CarbonFiber cf = new CarbonFiber(volName,mother,component_number);
-            cf.setMaterial("CarbonFiber");
-            
-            TestRunHalfModuleBundle hm = (TestRunHalfModuleBundle) getHalfModuleBundle((TestRunModule) mother.getMother(), mother.getName());
-            hm.carbonFiber = cf;
 
+    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, SurveyVolume mother, SurveyVolume 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());
[truncated at 1000 lines; 2132 more skipped]
SVNspam 0.1


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