Print

Print


Author: [log in to unmask]
Date: Mon Jan 25 10:53:05 2016
New Revision: 4132

Log:
Cleanup and refactor to help creating new detectors overriding objects in this detector.

Modified:
    java/branches/layer0-branch/detector-model/src/main/java/org/lcsim/geometry/compact/converter/HPSTracker2014GeometryDefinition.java
    java/branches/layer0-branch/detector-model/src/main/java/org/lcsim/geometry/compact/converter/HPSTracker2014LCDDBuilder.java

Modified: java/branches/layer0-branch/detector-model/src/main/java/org/lcsim/geometry/compact/converter/HPSTracker2014GeometryDefinition.java
 =============================================================================
--- java/branches/layer0-branch/detector-model/src/main/java/org/lcsim/geometry/compact/converter/HPSTracker2014GeometryDefinition.java	(original)
+++ java/branches/layer0-branch/detector-model/src/main/java/org/lcsim/geometry/compact/converter/HPSTracker2014GeometryDefinition.java	Mon Jan 25 10:53:05 2016
@@ -428,10 +428,10 @@
      *  @author Per Hansson Adrian <[log in to unmask]>
      */
     public abstract static class UChannelL13 extends SurveyVolume {
-        public final static double length = UChannelL13Plate.length;
-        public static final double width = UChannelL13Plate.width;
+        protected final static double length = UChannelL13Plate.length;
+        private static final double width = UChannelL13Plate.width;
         public static final double height = 2.575*inch;
-        public static final double kin_mount_to_edge_of_plate_x = width/2.0-4.0*inch;
+        //private static final double kin_mount_to_edge_of_plate_x = width/2.0-4.0*inch;
         public static final double side_plate_cone_y = 2.0*inch;
 
         public UChannelL13(String name, SurveyVolume m, AlignmentCorrection alignmentCorrection, SurveyVolume ref) {
@@ -442,6 +442,8 @@
             setBoxDim(getWidth(),getLength(),getHeight());
         }
         protected double getLength() {
+			System.out.println("UChannelL13 getLength");
+
             return length;
         }
         protected double getWidth() {
@@ -462,7 +464,7 @@
      *
      */
     public static class UChannelL13Bottom extends UChannelL13 {
-        private final static double cone_to_edge_of_plate_y = 12.25*inch; 
+        protected final static double cone_to_edge_of_plate_y = 12.25*inch; 
         private final static Hep3Vector ball_kinMount = new BasicHep3Vector(SupportRingL13BottomKinMount.kin_mount_pos_x,SupportRingL13BottomKinMount.kin_mount_pos_y,SupportRingL13BottomKinMount.kin_mount_pos_z);
 
         public UChannelL13Bottom(String name, SurveyVolume m,
@@ -471,12 +473,14 @@
             init();
         }
         protected void setCenter() {
+        	System.out.println("UChannelL13Bottom setCenter");
             final double x = 0.0;
             final double y = cone_to_edge_of_plate_y - length/2.0;
             final double z = -side_plate_cone_y - UChannelL13Plate.height + height/2.0;
             setCenter(x,y,z);
         }
         protected void setPos() {
+        	System.out.println("UChannelL13Bottom setPos");
             ballPos = VecOp.sub(UChannelL13BottomSurveyBalls.ball_pos, ball_kinMount);
             Hep3Vector veeOffset = UChannelL13BottomSurveyBalls.getVeeOffset();
             veePos = VecOp.add(ballPos, veeOffset);
@@ -539,10 +543,9 @@
     public static class UChannelL13Top extends UChannelL13 {
         private final static Hep3Vector ball_kinMount = new BasicHep3Vector(SupportRingL13TopKinMount.kin_mount_pos_x,SupportRingL13TopKinMount.kin_mount_pos_y,SupportRingL13TopKinMount.kin_mount_pos_z);
 
-        private final static double length = UChannelL13.length;
         private final static double cone_to_side_plate_pin_y = (14.5-3.125)*inch; 
         private final static double side_plate_pin_to_edge_of_plate_y = (16.0-14.5)*inch; 
-        private final static double cone_to_edge_of_plate_y = cone_to_side_plate_pin_y + side_plate_pin_to_edge_of_plate_y;
+        protected final static double cone_to_edge_of_plate_y = cone_to_side_plate_pin_y + side_plate_pin_to_edge_of_plate_y;
         
         public UChannelL13Top(String name, SurveyVolume m,
                 AlignmentCorrection alignmentCorrection, SurveyVolume ref) {
@@ -635,7 +638,7 @@
         private final static double pocket_depth_L2 = pocket_depth_L1 + 0.059;
         private final static double pocket_depth_L3 = pocket_depth_L2 + 0.059;
         //private final static double module_mounting_hole_to_hole_x =3.937*inch;
-        private static final double width = 9.25*inch;
+        protected static final double width = 9.25*inch;
         protected static final double height = 0.375*inch;
         protected final static double length = 16.0*inch;
         
@@ -704,8 +707,8 @@
 
         protected void setCenter() {
             final double x = 0.0;
-            final double y = UChannelL13Bottom.cone_to_edge_of_plate_y - length/2.0;
-            final double z = -UChannelL13.side_plate_cone_y - height/2.0;
+            final double y = UChannelL13Bottom.cone_to_edge_of_plate_y - getLength()/2.0;
+            final double z = -UChannelL13.side_plate_cone_y - getHeight()/2.0;
             setCenter(x,y,z);
         }
 
@@ -731,8 +734,8 @@
 
         protected void setCenter() {
             final double x = 0.0;
-            final double y = UChannelL13Top.cone_to_edge_of_plate_y - length/2.0;
-            final double z = -UChannelL13.side_plate_cone_y - height/2.0;
+            final double y = UChannelL13Top.cone_to_edge_of_plate_y - getLength()/2.0;
+            final double z = -UChannelL13.side_plate_cone_y - getHeight()/2.0;
             setCenter(x,y,z);
         }
        
@@ -1069,7 +1072,6 @@
         //private static final double hole_to_module_edge_height_dir = height - 0.875*inch;
         protected static final double hole_to_center_of_plate_width_dir = 3.75*inch;
         private static final double hole_to_module_edge_length_dir = 0.25*inch;
-        
         public ModuleL13(String name, SurveyVolume mother, AlignmentCorrection alignmentCorrection, SurveyVolume ref) {
             super(name, mother, alignmentCorrection, ref, getLayerFromVolumeName(name), getHalfFromName(name));
             
@@ -1091,6 +1093,7 @@
     }
     
     public abstract static class ModuleL13Top extends ModuleL13 {
+        protected static final double cone_to_hole_across_uchannel = -95.25;
         public ModuleL13Top(String name, SurveyVolume mother,
                 AlignmentCorrection alignmentCorrection, SurveyVolume ref) {
             super(name, mother, alignmentCorrection, ref);
@@ -1107,6 +1110,7 @@
     }
     
     public abstract static class ModuleL13Bot extends ModuleL13 {
+        protected static final double cone_to_hole_across_uchannel = 95.25;
         public ModuleL13Bot(String name, SurveyVolume mother,
                 AlignmentCorrection alignmentCorrection, SurveyVolume ref) {
             super(name, mother, alignmentCorrection, ref);
@@ -1123,6 +1127,8 @@
     
     
     public static class ModuleL1Bot extends ModuleL13Bot {
+        protected final static double cone_to_hole_along_uchannel = 9.525;
+        protected final static double cone_to_hole_vertical_from_uchannel = -51.435;
 
         public ModuleL1Bot(String name, SurveyVolume mother,
                 AlignmentCorrection alignmentCorrection, SurveyVolume ref) {
@@ -1130,9 +1136,9 @@
             init();
         }
         protected Hep3Vector getHolePosition() {
-            double x = 95.25;
-            double y = 9.525;
-            double z = -51.435;
+            double x = cone_to_hole_across_uchannel;
+            double y = cone_to_hole_along_uchannel;
+            double z = cone_to_hole_vertical_from_uchannel;
             return new BasicHep3Vector(x, y, z);
         }
         
@@ -1140,6 +1146,9 @@
     
    
     public static class ModuleL1Top extends ModuleL13Top {
+        
+        protected final static double cone_to_hole_along_uchannel = -9.525;
+        protected final static double cone_to_hole_vertical_from_uchannel = -51.435;
 
         public ModuleL1Top(String name, SurveyVolume mother,
                 AlignmentCorrection alignmentCorrection, SurveyVolume ref) {
@@ -1148,9 +1157,9 @@
         }
        
         protected Hep3Vector getHolePosition() {
-            double x = -95.25; // note minus sign compared to bottom
-            double y = -9.525;
-            double z = -51.435;
+            double x = cone_to_hole_across_uchannel; // note minus sign compared to bottom
+            double y = cone_to_hole_along_uchannel;
+            double z = cone_to_hole_vertical_from_uchannel;
             return new BasicHep3Vector(x, y, z);
         }
         
@@ -1160,21 +1169,26 @@
     
     public static class ModuleL2Bot extends ModuleL13Bot {
 
+        protected final static double cone_to_hole_along_uchannel = 109.525;
+        protected final static double cone_to_hole_vertical_from_uchannel = ModuleL1Bot.cone_to_hole_vertical_from_uchannel - 1.5;
+
         public ModuleL2Bot(String name, SurveyVolume mother,
                 AlignmentCorrection alignmentCorrection, SurveyVolume ref) {
             super(name, mother, alignmentCorrection, ref);
             init();
         }
         protected Hep3Vector getHolePosition() {
-            double x = 95.25;
-            double y = 109.525;
-            double z = -51.435 - 1.5;
+            double x = cone_to_hole_across_uchannel;
+            double y = cone_to_hole_along_uchannel;
+            double z = cone_to_hole_vertical_from_uchannel;
             return new BasicHep3Vector(x, y, z);
         }
         
     }
     
     public static class ModuleL2Top extends ModuleL13Top {
+        protected final static double cone_to_hole_along_uchannel = 90.475;
+        protected final static double cone_to_hole_vertical_from_uchannel = ModuleL1Top.cone_to_hole_vertical_from_uchannel - 1.5;
 
         public ModuleL2Top(String name, SurveyVolume mother,
                 AlignmentCorrection alignmentCorrection, SurveyVolume ref) {
@@ -1183,9 +1197,9 @@
         }
        
         protected Hep3Vector getHolePosition() {
-            double x = -95.25; // note minus sign compared to bottom
-            double y = 90.475;
-            double z = -51.435 - 1.5;
+            double x = cone_to_hole_across_uchannel; // note minus sign compared to bottom
+            double y = cone_to_hole_along_uchannel;
+            double z = cone_to_hole_vertical_from_uchannel;
             return new BasicHep3Vector(x, y, z);
         }
         
@@ -1195,6 +1209,8 @@
     
     
     public static class ModuleL3Bot extends ModuleL13Bot {
+        protected final static double cone_to_hole_along_uchannel = 209.525;
+        protected final static double cone_to_hole_vertical_from_uchannel = ModuleL1Bot.cone_to_hole_vertical_from_uchannel - 2*1.5;
 
         public ModuleL3Bot(String name, SurveyVolume mother,
                 AlignmentCorrection alignmentCorrection, SurveyVolume ref) {
@@ -1202,15 +1218,17 @@
             init();
         }
         protected Hep3Vector getHolePosition() {
-            double x = 95.25;
-            double y = 209.525;
-            double z = -51.435 - 2*1.5;
+            double x = cone_to_hole_across_uchannel;
+            double y = cone_to_hole_along_uchannel;
+            double z = cone_to_hole_vertical_from_uchannel;
             return new BasicHep3Vector(x, y, z);
         }
         
     }
         
     public static class ModuleL3Top extends ModuleL13Top {
+        protected final static double cone_to_hole_along_uchannel = 190.475;
+        protected final static double cone_to_hole_vertical_from_uchannel = ModuleL1Top.cone_to_hole_vertical_from_uchannel - 2*1.5;
 
         public ModuleL3Top(String name, SurveyVolume mother,
                 AlignmentCorrection alignmentCorrection, SurveyVolume ref) {
@@ -1219,9 +1237,9 @@
         }
        
         protected Hep3Vector getHolePosition() {
-            double x = -95.25; // note minus sign compared to bottom
-            double y = 190.475;
-            double z = -51.435 - 2*1.5;
+            double x = cone_to_hole_across_uchannel; // note minus sign compared to bottom
+            double y = cone_to_hole_along_uchannel;
+            double z = cone_to_hole_vertical_from_uchannel;
             return new BasicHep3Vector(x, y, z);
         }
         
@@ -1281,7 +1299,11 @@
      *
      */
     public static abstract class ModuleL46Bot extends ModuleL46 {
-
+        // positions are in the mother (U-channel) coord. systtem as usual
+        protected final static double x = 149.225; // distance from survey ball to hole mounting surface
+        protected final static double y = 9.525; // distance along U-channel
+        protected final static double z = -53.34; // distance normal to the U-channel plate
+        
         public ModuleL46Bot(String name, SurveyVolume mother,
                 AlignmentCorrection alignmentCorrection, SurveyVolume ref) {
             super(name, mother, alignmentCorrection, ref);
@@ -1306,7 +1328,11 @@
      *
      */
     public static abstract class ModuleL46Top extends ModuleL46 {
-
+        // positions are in the mother (U-channel) coord. systtem as usual
+        protected final static double x = -149.225; // distance from survey ball to hole mounting surface
+        protected final static double y = -9.525; // distance along U-channel
+        protected final static double z = -53.34; // distance normal to the U-channel plate
+        
         public ModuleL46Top(String name, SurveyVolume mother,
                 AlignmentCorrection alignmentCorrection, SurveyVolume ref) {
             super(name, mother, alignmentCorrection, ref);
@@ -1332,12 +1358,6 @@
         }
 
         protected Hep3Vector getHole() {
-            double x = 149.225;
-            double y = 9.525;
-            double z = -53.34;
-            //double x = hole_to_center_of_plate_width_dir;   
-            //double y = -getHoleModuleCenterOffset(); //Note minus sign compared to top
-            //double z = -UChannelL46.side_plate_cone_y - UChannelL46Plate.pocket_depth_L4;
             return new BasicHep3Vector(x, y, z);
         }
         
@@ -1352,12 +1372,6 @@
         }
 
         protected Hep3Vector getHole() {
-            double x = -149.225;
-            double y = -9.525;
-            double z = -53.34;
-//            double x = -1*hole_to_center_of_plate_width_dir;   
-//            double y = -getHoleModuleCenterOffset();
-//            double z = -UChannelL46.side_plate_cone_y - UChannelL46Plate.pocket_depth_L4;
             return new BasicHep3Vector(x, y, z);
         }
         
@@ -1373,10 +1387,9 @@
         }
 
         protected Hep3Vector getHole() {
-            double x = 149.225;
-            double y = 209.525;
-            double z = -53.34 - 3.0;
-            return new BasicHep3Vector(x, y, z);
+            double y_local = y + 200.0;
+            double z_local = z - 3.0;
+            return new BasicHep3Vector(x, y_local, z_local);
         }
 
     }
@@ -1390,10 +1403,9 @@
         }
 
         protected Hep3Vector getHole() {
-            double x = -149.225;
-            double y = 190.475;
-            double z = -53.34 - 3.0;
-            return new BasicHep3Vector(x, y, z);
+            double y_local = y + 200.0;
+            double z_local = z - 3.0;
+            return new BasicHep3Vector(x, y_local, z_local);
         }
 
     }
@@ -1407,10 +1419,9 @@
         }
 
         protected Hep3Vector getHole() {
-            double x = 149.225;
-            double y = 409.525;
-            double z = -53.34 - 2*3.0;
-            return new BasicHep3Vector(x, y, z);
+            double y_local = y + 200.0*2;
+            double z_local = z - 2*3.0;
+            return new BasicHep3Vector(x, y_local, z_local);
         }
 
     }
@@ -1424,10 +1435,9 @@
         }
 
         protected Hep3Vector getHole() {
-            double x = -149.225;
-            double y = 390.475;
-            double z = -53.34 - 2*3.0;
-            return new BasicHep3Vector(x, y, z);
+            double y_local = y + 2*200.0;
+            double z_local = z - 2*3.0;
+            return new BasicHep3Vector(x, y_local, z_local);
         }
 
     }
@@ -1657,6 +1667,10 @@
             double z = -Sensor.getSensorThickness()/2.0 - HPSTestRunTracker2014GeometryDefinition.HalfModuleLamination.thickness - CarbonFiber.thickness + half_module_thickness/2.0; 
             setCenter(x, y, z); 
         }
+        @Override
+        protected void setStereoAngle() {
+           // do nothing here
+        }
     }
     
     
@@ -1675,12 +1689,12 @@
     public static class HalfModuleStereo extends HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule {
         
         public static final double sensor_z = -0.52*inch;
+        protected static final double stereo_angle_value = 0.1;
         
         public HalfModuleStereo(String name, SurveyVolume mother,
                 AlignmentCorrection alignmentCorrection, int layer, String half) {
             super(name, mother, alignmentCorrection, layer, half);
-            if(layer>=1 && layer<=3) stereo_angle = 0.1;
-            else throw new RuntimeException("Layer " + layer + " is ill-defined for test run modules");
+            setStereoAngle();
             init();
         }
         protected void setPos() {
@@ -1721,6 +1735,9 @@
             if(debug) System.out.printf("%s: box center after corrections\n%s\n", getClass().getSimpleName(),getBoxDim().toString());
 
         }
+        protected void setStereoAngle() {
+            stereo_angle = stereo_angle_value;
+        }
 
         
     }
@@ -1763,24 +1780,13 @@
     }    
     
     
-    
     /**
      * Create the module. 
      * @param layer - of the module
      * @param half - top or bottom half of the tracker
      */
-    protected 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");      
-
-        // 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
+    protected void makeModuleBundle(int layer, String half) {
+        
         final SurveyVolume mother = getSurveyVolume(SvtBox.class);
         final SurveyVolume ref;
         AlignmentCorrection alignmentCorrection = new AlignmentCorrection();
@@ -1798,8 +1804,85 @@
                 ref = getSurveyVolume(UChannelL46Top.class);
             }
         }
-
+        
+        makeModuleBundle(layer, half, mother, ref);
+        
+    }
+    
+    
+    
+    /**
+     * Create the module. 
+     * @param layer - of the module
+     * @param half - top or bottom half of the tracker
+     * @param mother - mother volume
+     * @param ref - reference volume
+     */
+    protected void makeModuleBundle(int layer, String half, SurveyVolume mother, SurveyVolume ref) 
+    {
+
+        if(isDebug()) System.out.printf("%s: makeModule for layer %d %s \n", this.getClass().getSimpleName(), layer, half);
+        
         //Create the module
+        BaseModule module = createModule(half, layer, mother, ref);
+
+        // create the bundle for this module
+        // need to create it and add to list before half-module is created
+        // as it uses the list to find the bundle. Ugly. TODO fix this.
+        BaseModuleBundle bundle;
+        
+        if(layer<=3) {
+            bundle = new TestRunModuleBundle(module);
+            addModuleBundle(bundle);
+            if(doAxial) makeHalfModule("axial", module);
+            //        if(doColdBlock) makeColdBlock(module);
+            if(doStereo) makeHalfModule("stereo", module);
+        } else {
+            bundle = new LongModuleBundle(module);
+            addModuleBundle(bundle);
+            if(doAxial) {
+                makeLongHalfModule("axial","hole", module);
+                makeLongHalfModule("axial","slot", module);
+            }
+            //        if(doColdBlock) makeColdBlock(module);
+            if(doStereo) {
+                makeLongHalfModule("stereo","hole", module);
+                makeLongHalfModule("stereo","slot", module);
+            }
+        }
+
+
+
+        if(isDebug()) {
+            System.out.printf("%s: created module bundle:\n", this.getClass().getSimpleName());
+            bundle.print();
+            System.out.printf("%s: Now there are %d  modules\n", this.getClass().getSimpleName(),modules.size());
+        }
+
+        
+
+    }
+
+
+
+
+    /**
+     * Create a {@link BaseModule} object. 
+     * @param half - top or bottom string
+     * @param layer - layer integer
+     * @param mother - mother {@link SurveyVolume}
+     * @param ref - reference {@link SurveyVolume}
+     * @return the created {@link BaseModule}
+     */
+    protected BaseModule createModule(String half, int layer, SurveyVolume mother, SurveyVolume ref) {
+        
+        // build the module name
+        String volName = "module_L"+ layer + (half=="bottom"?"b":"t");      
+        
+        // find alignment corrections
+        AlignmentCorrection alignmentCorrection = new AlignmentCorrection();
+        alignmentCorrection.setNode(node);
+
         BaseModule module;
         if(half == "bottom") {
             if(layer==1) {
@@ -1834,47 +1917,8 @@
                 throw new UnsupportedOperationException("Layer " + layer + " not implemented yet for top");
             }
         }
-
-
-        // create the bundle for this module
-        // need to create it and add to list before half-module is created
-        // as it uses the list to find the bundle. Ugly. TODO fix this.
-        BaseModuleBundle bundle;
-        
-        if(layer<=3) {
-            bundle = new TestRunModuleBundle(module);
-            addModuleBundle(bundle);
-            if(doAxial) makeHalfModule("axial", module);
-            //        if(doColdBlock) makeColdBlock(module);
-            if(doStereo) makeHalfModule("stereo", module);
-        } else {
-            bundle = new LongModuleBundle(module);
-            addModuleBundle(bundle);
-            if(doAxial) {
-                makeLongHalfModule("axial","hole", module);
-                makeLongHalfModule("axial","slot", module);
-            }
-            //        if(doColdBlock) makeColdBlock(module);
-            if(doStereo) {
-                makeLongHalfModule("stereo","hole", module);
-                makeLongHalfModule("stereo","slot", module);
-            }
-        }
-
-
-
-        if(isDebug()) {
-            System.out.printf("%s: created module bundle:\n", this.getClass().getSimpleName());
-            bundle.print();
-            System.out.printf("%s: Now there are %d  modules\n", this.getClass().getSimpleName(),modules.size());
-        }
-
-        
-
-    }
-
-
-
+        return module;
+    }
 
 
     /**

Modified: java/branches/layer0-branch/detector-model/src/main/java/org/lcsim/geometry/compact/converter/HPSTracker2014LCDDBuilder.java
 =============================================================================
--- java/branches/layer0-branch/detector-model/src/main/java/org/lcsim/geometry/compact/converter/HPSTracker2014LCDDBuilder.java	(original)
+++ java/branches/layer0-branch/detector-model/src/main/java/org/lcsim/geometry/compact/converter/HPSTracker2014LCDDBuilder.java	Mon Jan 25 10:53:05 2016
@@ -109,7 +109,30 @@
 
         if(isDebug()) System.out.printf("%s: build modules\n", getClass().getSimpleName());
 
-        // Loop over all modules created
+        addModules();
+        
+        System.out.printf("%s: Built %d LCDD geometry objects\n", getClass().getSimpleName(), lcddSurveyVolumes.size());
+        
+        if(isDebug()) {
+            System.out.printf("%s: List of all %d LCDD geometry objects built\n", this.getClass().getSimpleName(), lcddSurveyVolumes.size());
+            for(SurveyVolumeImpl bg : lcddSurveyVolumes) {
+                System.out.printf("-------\n%s\n", bg.toString());
+            }
+        }
+
+
+
+        // Set visualization features
+        setVisualization();
+
+    }    
+    
+    
+    /**
+     * Rules for adding the LCDD modules.
+     */
+    protected void addModules() {
+     // Loop over all modules created
         for(BaseModuleBundle mod : _builder.modules) {
             //SVTModuleBundle m = (SVTModuleBundle) mod;
             BaseModuleBundle m = mod;
@@ -136,25 +159,8 @@
             addModule(m, mother);
 
         }
-
-
-       
-        
-        System.out.printf("%s: Built %d LCDD geometry objects\n", getClass().getSimpleName(), lcddSurveyVolumes.size());
-        
-        if(isDebug()) {
-            System.out.printf("%s: List of all %d LCDD geometry objects built\n", this.getClass().getSimpleName(), lcddSurveyVolumes.size());
-            for(SurveyVolumeImpl bg : lcddSurveyVolumes) {
-                System.out.printf("-------\n%s\n", bg.toString());
-            }
-        }
-
-
-
-        // Set visualization features
-        setVisualization();
-
-    }    
+    }
+    
     
     /**
      * Rules for adding the LCDD module geometry.