Print

Print


Author: phansson
Date: Mon Oct 27 10:09:38 2014
New Revision: 3388

Log:
First version of the geometry that is built using millepede alignment corrections from the compact.

Added:
    projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/MilleParameter.java
Removed:
    projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector/HPSTestRun2014-v0.xml
Modified:
    projects/lcsim/trunk/detector-framework/pom.xml
    projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014Converter.java
    projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/AlignmentCorrection.java
    projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/HPSTestRunTracker2014GeometryDefinition.java
    projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/HPSTrackerBuilder.java
    projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/HPSTrackerJavaBuilder.java
    projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/HPSTrackerLCDDBuilder.java
    projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/SurveyCoordinateSystem.java
    projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/SurveyVolume.java
    projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java
    projects/lcsim/trunk/detector-framework/src/test/java/org/lcsim/geometry/subdetector/HPSTestRunTracker2014Test.java
    projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector/HPSTestRunTracker2014.xml

Modified: projects/lcsim/trunk/detector-framework/pom.xml
 =============================================================================
--- projects/lcsim/trunk/detector-framework/pom.xml	(original)
+++ projects/lcsim/trunk/detector-framework/pom.xml	Mon Oct 27 10:09:38 2014
@@ -98,7 +98,12 @@
             <groupId>org.apache.commons</groupId>
 	    <artifactId>commons-math3</artifactId>
 	    <version>3.1</version>
-	</dependency>
+	   </dependency>
+       <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.3.2</version>
+        </dependency>
     </dependencies>
     
 </project>

Modified: projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014Converter.java
 =============================================================================
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014Converter.java	(original)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014Converter.java	Mon Oct 27 10:09:38 2014
@@ -40,7 +40,7 @@
  */
 public class HPSTestRunTracker2014Converter extends AbstractSubdetectorConverter {
 
-	private boolean _debug = false; 
+	private boolean _debug = true; 
 	private IMaterial trackingMaterial = null;
 	private static HPSTrackerJavaBuilder builder;
 	

Modified: projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/AlignmentCorrection.java
 =============================================================================
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/AlignmentCorrection.java	(original)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/AlignmentCorrection.java	Mon Oct 27 10:09:38 2014
@@ -1,5 +1,6 @@
 package org.lcsim.geometry.compact.converter;
 
+import hep.physics.vec.BasicHep3Vector;
 import hep.physics.vec.Hep3Vector;
 
 import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
@@ -14,6 +15,10 @@
 public class AlignmentCorrection {
     private Rotation rotation = null;
     private Hep3Vector translation = null;
+    public AlignmentCorrection(double x, double y, double z, double rot_x, double rot_y, double rot_z) {
+        setTranslation(x, y, z);
+        setRotation(rot_x, rot_y, rot_z);
+    }
     public AlignmentCorrection() {
     }
     public Rotation getRotation() {
@@ -36,4 +41,8 @@
     public void setTranslation(Hep3Vector translation) {
         this.translation = translation;
     }
+    public void setTranslation(double x, double y, double z) {
+        setTranslation(new BasicHep3Vector(x,y,z));
+    }
+
 }

Modified: projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/HPSTestRunTracker2014GeometryDefinition.java
 =============================================================================
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/HPSTestRunTracker2014GeometryDefinition.java	(original)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/HPSTestRunTracker2014GeometryDefinition.java	Mon Oct 27 10:09:38 2014
@@ -15,7 +15,7 @@
 
 /**
  * 
- * Class containing geometry information for HPS Test run tracker 2014
+ * Geometry information for the HPS Test run tracker
  * 
  * @author Per Hansson Adrian <[log in to unmask]>
  *
@@ -65,20 +65,29 @@
         // 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(cSupport);        
+        
+        AlignmentCorrection alignmentCorrectionSupportBottom = getSupportAlignmentCorrection(false);
+        SupportBottom supportBottom = new SupportBottom("support_bottom", base, alignmentCorrectionSupportBottom, 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(supportPlateBottom);        
+        
+        AlignmentCorrection alignmentCorrectionSupportTop = getSupportAlignmentCorrection(true);
+        SupportTop supportTop = new SupportTop("support_top", base, alignmentCorrectionSupportTop, cSupport);
         geometries.add(supportTop);
+        
         SupportPlateTop supportPlateTop = new SupportPlateTop("support_plate_top", base, supportTop, "Aluminum");
         geometries.add(supportPlateTop);
 
@@ -86,10 +95,10 @@
         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(doLayer(l)) {
+                if(doBottom) makeModuleBundle(l,"bottom");
+                if(doTop)    makeModuleBundle(l,"top");
+            }
         }       
 
         if(isDebug()) {
@@ -102,7 +111,9 @@
 
     }
 
-
+    
+    
+    
     /**
      * Create the module. 
      * @param layer - of the module
@@ -208,21 +219,26 @@
 
         // top or bottom?
         String half = mother.getHalf();
+        boolean isTopLayer = !mother.isBottom();
 
         // find layer
         int layer = mother.getLayer();
 
         TestRunModuleBundle bundle  = (TestRunModuleBundle)getModuleBundle(mother);
         TestRunHalfModuleBundle halfModuleBundle;
-
+        
+        
         // Build the half-module
         TestRunHalfModule halfModule;
+        AlignmentCorrection alignmentCorrection;
         if(side == "axial") {
-            halfModule = new TestRunHalfModuleAxial(volName, mother, null, layer, half);
+            alignmentCorrection =  getHalfModuleAlignmentCorrection(isTopLayer, getOldGeomDefLayerFromVolumeName(isTopLayer, layer, true));
+            halfModule = new TestRunHalfModuleAxial(volName, mother, alignmentCorrection, layer, half);
             halfModuleBundle = new TestRunHalfModuleBundle(halfModule);
             bundle.halfModuleAxial = halfModuleBundle;
         } else if(side == "stereo") {
-            halfModule = new TestRunHalfModuleStereo(volName, mother, null, layer, half);
+            alignmentCorrection =  getHalfModuleAlignmentCorrection(isTopLayer, getOldGeomDefLayerFromVolumeName(isTopLayer, layer, false));
+            halfModule = new TestRunHalfModuleStereo(volName, mother, alignmentCorrection, layer, half);
             halfModuleBundle = new TestRunHalfModuleBundle(halfModule);
             bundle.halfModuleStereo = halfModuleBundle;
         } else {
@@ -514,14 +530,17 @@
             }
         }
         protected void setPos() {
+            if(debug) System.out.printf("%s: setPos for %s\n",this.getClass().getSimpleName(),getName());
             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());
+            if(debug) {
+                System.out.printf("%s: survey positions for %s\n",this.getClass().getSimpleName(),getName());
+                printSurveyPos();
+            }
         }
         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
@@ -543,21 +562,21 @@
         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);
+        public SupportTop(String name, SurveyVolume mother, AlignmentCorrection alignmentCorrection) {
+            super(name,mother, alignmentCorrection);
+            init();
+        }
+        public SupportTop(String name, SurveyVolume mother, AlignmentCorrection alignmentCorrection, SurveyVolume referenceGeom) {
+            super(name,mother,alignmentCorrection, referenceGeom);
+            init();
+        }
+        public SupportTop(String name, SurveyVolume mother, AlignmentCorrection alignmentCorrection, List<SurveyVolume> referenceGeom) {
+            super(name,mother,alignmentCorrection, referenceGeom);
             init();
         }
 
         protected void setPos() {
-            if(debug) System.out.printf("%s: setPos support top\n",this.getClass().getSimpleName());
+            if(debug) System.out.printf("%s: setPos for %s\n",this.getClass().getSimpleName(),getName());
             // 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);
@@ -567,7 +586,7 @@
                     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)
+            // apply to flat local position (as for bottom it is an arbitrary offset)
             Vector3D flat_pos_csup_bearings_top_3D_rot = 
                     rot_csup_top.applyTo(new Vector3D(0.0,10.0,0.0));
 
@@ -582,7 +601,7 @@
             if(referenceGeom==null) {
                 throw new RuntimeException("No ref found for " + getName());
             }
-
+            /*
             for(SurveyVolume ref : referenceGeom) {
 
                 if(debug) {
@@ -601,6 +620,11 @@
                     printSurveyPos();
                 }
             }
+            */
+            if(debug) {
+                System.out.printf("%s: survey positions for %s\n",this.getClass().getSimpleName(),getName());
+                printSurveyPos();
+            }
         }
         protected void setCoord() {
             setCoord(null);
@@ -611,6 +635,43 @@
         protected void setBoxDim() {
             setBoxDim(support_top_width,support_top_length,support_top_height);
         }
+        /*
+        protected void applyReferenceTransformation() {
+         
+            if(debug) {
+                System.out.printf("%s: coord system before ref transformations:\n%s\n",this.getClass().getSimpleName(),getCoord().toString());
+            }
+
+            for(SurveyVolume ref : referenceGeom) {
+
+                if(debug) {
+                    //System.out.printf("%s: survey positions before ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
+                    //printSurveyPos();
+                    System.out.printf("%s: coord system before ref %s transform:\n%s\n",this.getClass().getSimpleName(),ref.getName(),getCoord().toString());
+                }
+
+                if(debug) System.out.printf("%s: Ref %s coord\n%s\n",this.getClass().getSimpleName(), ref.getName(),ref.getCoord().toString());
+                
+                getCoord().transform(ref.getCoord().getTransformation());
+                
+                //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();
+                    System.out.printf("%s: coord system after ref %s transform:\n%s\n",this.getClass().getSimpleName(),ref.getName(),getCoord().toString());
+                }
+            }
+            
+            if(debug) {
+                System.out.printf("%s: coord system after ref transformations:\n%s\n",this.getClass().getSimpleName(),getCoord().toString());
+            }
+            
+            
+        }
+         */
     }
 
 
@@ -631,15 +692,15 @@
         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, SurveyVolume mother, SurveyVolume referenceGeom) {
-            super(name,mother,null, referenceGeom);
+        public SupportBottom(String name, SurveyVolume mother, AlignmentCorrection alignmentCorrection, SurveyVolume referenceGeom) {
+            super(name,mother,alignmentCorrection, referenceGeom);
             init();
         }
 
         protected void setPos() {
 
-            if(debug) System.out.printf("%s: setPos support bottom\n",this.getClass().getSimpleName());
-
+            if(debug) System.out.printf("%s: setPos for %s\n",this.getClass().getSimpleName(),getName());
+            
             // 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
 
@@ -669,7 +730,7 @@
             if(referenceGeom==null) {
                 throw new RuntimeException("No ref found for " + getName());
             }
-
+            /*
             for(SurveyVolume ref : referenceGeom) {
 
                 if(debug) {
@@ -687,6 +748,11 @@
                     System.out.printf("%s: survey positions after ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
                     printSurveyPos();
                 }
+            }
+            */
+            if(debug) {
+                System.out.printf("%s: survey positions for %s\n",this.getClass().getSimpleName(),getName());
+                printSurveyPos();
             }
 
         }
@@ -742,8 +808,8 @@
             init();				
         }
         protected void setPos() {
-            if(debug) System.out.printf("%s: set survey positions \n",this.getClass().getSimpleName());
-
+            if(debug) System.out.printf("%s: setPos for %s\n",this.getClass().getSimpleName(),getName());
+            
             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());
@@ -751,7 +817,7 @@
             if(referenceGeom==null) {
                 throw new RuntimeException("No ref found for " + getName());
             }
-
+            /*
             for(SurveyVolume ref : referenceGeom) {
 
                 if(debug) {
@@ -769,6 +835,11 @@
                     System.out.printf("%s: survey positions after ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
                     printSurveyPos();
                 }
+            }
+            */
+            if(debug) {
+                System.out.printf("%s: survey positions for %s\n",this.getClass().getSimpleName(),getName());
+                printSurveyPos();
             }
         }
         protected void setCoord() {
@@ -797,8 +868,8 @@
             init();
         }
         protected void setPos() {
-            if(debug) System.out.printf("%s: set survey positions \n",this.getClass().getSimpleName());
-
+            if(debug) System.out.printf("%s: setPos for %s\n",this.getClass().getSimpleName(),getName());
+            
             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());
@@ -806,7 +877,7 @@
             if(referenceGeom==null) {
                 throw new RuntimeException("No ref found for " + getName());
             }
-
+            /*
             for(SurveyVolume ref : referenceGeom) {
 
                 if(debug) System.out.printf("%s: survey positions before ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
@@ -820,6 +891,11 @@
 
                 if(debug) System.out.printf("%s: survey positions after ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
                 if(debug) printSurveyPos();
+            }
+            */
+            if(debug) {
+                System.out.printf("%s: survey positions for %s\n",this.getClass().getSimpleName(),getName());
+                printSurveyPos();
             }
         }
         protected void setCoord() {
@@ -932,7 +1008,8 @@
         }			
         protected void setPos() {
 
-            if(debug) System.out.printf("%s: setPos\n",this.getClass().getSimpleName());
+            if(debug) System.out.printf("%s: setPos for %s\n",this.getClass().getSimpleName(),getName());
+            
 
             if(isBottom()) {
                 switch (getLayer()) {
@@ -1006,10 +1083,11 @@
             }
 
             if(debug) {
-                System.out.printf("%s: survey positions\n",this.getClass().getSimpleName());
+                System.out.printf("%s: survey positions for %s\n",this.getClass().getSimpleName(),getName());
                 printSurveyPos();
             }
 
+            /*
             // walk through the reference volumes
             if(referenceGeom!=null) {
                 for(SurveyVolume ref : referenceGeom) {
@@ -1031,6 +1109,7 @@
                     }
                 }
             }
+            */
 
         }
 
@@ -1166,6 +1245,8 @@
         }
 
         protected void setPos() {
+            if(debug) System.out.printf("%s: setPos for %s\n",this.getClass().getSimpleName(),getName());
+            
             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;
 
@@ -1185,6 +1266,11 @@
             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);
+            
+            if(debug) {
+                System.out.printf("%s: survey positions for %s\n",this.getClass().getSimpleName(),getName());
+                printSurveyPos();
+            }
 
         }
     }
@@ -1202,7 +1288,9 @@
         }
 
         protected void setPos() {
-
+            
+            if(debug) System.out.printf("%s: setPos for %s\n",this.getClass().getSimpleName(),getName());
+            
             //very similar to axial, see note below
 
             final double coldBlockThick = getLayer() <=3 ? TestRunColdBlockL13.coldblock_L13_thickness : TestRunColdBlockL45.coldblock_L45_thickness;
@@ -1221,7 +1309,12 @@
             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);
-
+            
+            if(debug) {
+                System.out.printf("%s: survey positions for %s\n",this.getClass().getSimpleName(),getName());
+                printSurveyPos();
+            }
+        
         }
 
 
@@ -1281,6 +1374,8 @@
             setCenter(getLength()/2.0, 0.0, getWidth()/2.0); 
         }
         protected void setPos() {
+            if(debug) System.out.printf("%s: setPos for %s\n",this.getClass().getSimpleName(),getName());
+            
             // cold block position w.r.t. module box coordinate system
             // this is a dummy coordinate system, make it simple
             // edge of cold block on the mounting surface
@@ -1296,6 +1391,12 @@
             setBallPos(ball_pos_coldblock_local_x, ball_pos_coldblock_local_y, ball_pos_coldblock_local_z);
             setVeePos(vee_pos_coldblock_local_x, vee_pos_coldblock_local_y,vee_pos_coldblock_local_z);
             setFlatPos(flat_pos_coldblock_local_x, flat_pos_coldblock_local_y,flat_pos_coldblock_local_z);
+            
+            if(debug) {
+                System.out.printf("%s: survey positions for %s\n",this.getClass().getSimpleName(),getName());
+                printSurveyPos();
+            }
+            
         }
         protected void setBoxDim() {
             setBoxDim(getLength(), getHeight(), getWidth());
@@ -1368,6 +1469,9 @@
             return getSensorHeight();
         }
         protected void setPos() {
+            
+            if(debug) System.out.printf("%s: setPos for %s\n",this.getClass().getSimpleName(),getName());
+            
             if(useSiStripsConvention) {
                 setBallPos(0,0,0);
                 setVeePos(ballPos.x(), ballPos.y(), ballPos.z() + getSensorWidth()/2.0);
@@ -1377,6 +1481,12 @@
                 setVeePos(ballPos.x() + getSensorLength()/2.0, ballPos.y(), ballPos.z());
                 setFlatPos(ballPos.x(),ballPos.y() + getSensorThickness()/2.0, ballPos.z());
             }
+
+            if(debug) {
+                System.out.printf("%s: survey positions for %s\n",this.getClass().getSimpleName(),getName());
+                printSurveyPos();
+            }
+            
         }
         protected void setCoord() {
             setCoord(null);
@@ -1426,6 +1536,9 @@
             return getActiveSensorHeight();
         }
         protected void setPos() {
+            
+            if(debug) System.out.printf("%s: setPos for %s\n",this.getClass().getSimpleName(),getName());
+            
             if(useSiStripsConvention) {
                 ballPos = new BasicHep3Vector(0,0,0);
                 veePos = new BasicHep3Vector(getActiveSensorWidth()/2.0,0,0);
@@ -1435,6 +1548,11 @@
                 veePos = new BasicHep3Vector(getActiveSensorWidth()/2.0,0,0);
                 flatPos = new BasicHep3Vector(0,getActiveSensorLength()/2.0,0);
             }
+            
+            if(debug) {
+                System.out.printf("%s: survey positions for %s\n",this.getClass().getSimpleName(),getName());
+                printSurveyPos();
+            }
         }
         protected void setCoord() {
             setCoord(null);
@@ -1479,6 +1597,9 @@
             init();
         }
         protected void setPos() {
+            
+            if(debug) System.out.printf("%s: setPos for %s\n",this.getClass().getSimpleName(),getName());
+            
             final double ball_pos_kapton_local_x =  -1 * (180.0 - Sensor.getSensorLength()/2.0) + 8.5;
             final double ball_pos_kapton_local_y =  (Sensor.getSensorThickness()/2.0 + HalfModuleLamination.kapton_thickness/2.0);
             final double ball_pos_kapton_local_z = -1 * (Sensor.getSensorWidth()/2.0 + 12.66) + 8.83 - 3.00 + 6.00 ;
@@ -1493,6 +1614,10 @@
             veePos = new BasicHep3Vector(vee_pos_kapton_local_x,vee_pos_kapton_local_y,vee_pos_kapton_local_z);
             flatPos = new BasicHep3Vector(flat_pos_kapton_local_x,flat_pos_kapton_local_y,flat_pos_kapton_local_z);
 
+            if(debug) {
+                System.out.printf("%s: survey positions for %s\n",this.getClass().getSimpleName(),getName());
+                printSurveyPos();
+            }
         }
         protected void setCenter() {
             setCenter(getLength()/2.0, 0.0, getWidth()/2.0);
@@ -1523,6 +1648,9 @@
             init();
         }
         protected void setPos() {
+            
+            if(debug) System.out.printf("%s: setPos for %s\n",this.getClass().getSimpleName(),getName());
+            
             final double ball_pos_cf_local_x =  -1 * (180.0 - Sensor.getSensorLength()/2.0);
             final double ball_pos_cf_local_y =  (Sensor.getSensorThickness()/2.0 + HalfModuleLamination.kapton_thickness + TestRunHalfModule.getCFThickness()/2.0);
             final double ball_pos_cf_local_z = -1 * (Sensor.getSensorWidth()/2.0 + 12.66) + 8.83 - 3.00;
@@ -1535,6 +1663,12 @@
             setBallPos(ball_pos_cf_local_x,ball_pos_cf_local_y,ball_pos_cf_local_z);
             setVeePos(vee_pos_cf_local_x,vee_pos_cf_local_y,vee_pos_cf_local_z);
             setFlatPos(flat_pos_cf_local_x,flat_pos_cf_local_y,flat_pos_cf_local_z);
+            
+            if(debug) {
+                System.out.printf("%s: survey positions for %s\n",this.getClass().getSimpleName(),getName());
+                printSurveyPos();
+            }
+            
         }
         protected void setCenter() {
             setCenter(getLength()/2.0, 0.0, getWidth()/2.0);
@@ -1566,6 +1700,9 @@
             init();
         }
         protected void setPos() {
+            
+            if(debug) System.out.printf("%s: setPos for %s\n",this.getClass().getSimpleName(),getName());
+            
             final double ball_pos_hybrid_local_x =  -1 * (170.0 - Sensor.getSensorLength()/2.0);
             final double ball_pos_hybrid_local_y =  (Sensor.getSensorThickness()/2.0 - TestRunHalfModule.getHybridThickness()/2.0);
             final double ball_pos_hybrid_local_z = -1 * (Sensor.getSensorWidth()/2.0);
@@ -1578,7 +1715,11 @@
             setBallPos(ball_pos_hybrid_local_x,ball_pos_hybrid_local_y,ball_pos_hybrid_local_z);
             setVeePos(vee_pos_hybrid_local_x,vee_pos_hybrid_local_y,vee_pos_hybrid_local_z);
             setFlatPos(flat_pos_hybrid_local_x,flat_pos_hybrid_local_y,flat_pos_hybrid_local_z);
-
+            
+            if(debug) {
+                System.out.printf("%s: survey positions for %s\n",this.getClass().getSimpleName(),getName());
+                printSurveyPos();
+            }
         }
         protected void setCenter() {
             setCenter(getLength()/2.0, 0.0, getWidth()/2.0);

Modified: projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/HPSTrackerBuilder.java
 =============================================================================
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/HPSTrackerBuilder.java	(original)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/HPSTrackerBuilder.java	Mon Oct 27 10:09:38 2014
@@ -1,18 +1,15 @@
 package org.lcsim.geometry.compact.converter;
 
+import hep.physics.vec.BasicHep3Vector;
 import hep.physics.vec.Hep3Vector;
 
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
+import org.jdom.DataConversionException;
 import org.jdom.Element;
 import org.lcsim.detector.Transform3D;
-import org.lcsim.geometry.compact.converter.HPSTestRunTracker2014GeometryDefinition.ActiveSensor;
-import org.lcsim.geometry.compact.converter.HPSTestRunTracker2014GeometryDefinition.CarbonFiber;
-import org.lcsim.geometry.compact.converter.HPSTestRunTracker2014GeometryDefinition.HalfModuleLamination;
-import org.lcsim.geometry.compact.converter.HPSTestRunTracker2014GeometryDefinition.Hybrid;
-import org.lcsim.geometry.compact.converter.HPSTestRunTracker2014GeometryDefinition.Sensor;
-import org.lcsim.geometry.compact.converter.HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule;
 import org.lcsim.geometry.compact.converter.HPSTestRunTracker2014GeometryDefinition.TestRunModule;
 
 public abstract class HPSTrackerBuilder {
@@ -21,6 +18,7 @@
 	public List<ModuleBundle> modules;
 	protected List<SurveyVolume> geometries = new ArrayList<SurveyVolume>();
     protected Element node;
+    protected List<MilleParameter> milleparameters = new ArrayList<MilleParameter>();
 	
 	
 
@@ -32,9 +30,111 @@
 	public HPSTrackerBuilder(boolean debug, Element node) {
         this.debug = debug;
         this.node = node;
-    }
-	
-	/**
+        initAlignmentParameters();
+    }
+	
+	private void initAlignmentParameters() {
+       
+        if(debug) System.out.printf("%s: initAlignmentParameters from %s\n",this.getClass().getSimpleName(),node.getAttributeValue("name"));
+        
+	 // Get alignment parameters.
+        int detId=-1;
+        try {
+            detId = node.getAttribute("id").getIntValue();
+        } catch (DataConversionException e) {
+            e.printStackTrace();
+        }
+        String detName = node.getAttributeValue("name");
+        String detType = node.getAttributeValue("type");
+        
+        Element constantsElement = node.getChild("millepede_constants");
+        if(constantsElement==null) {
+            throw new RuntimeException("no millepede constants found in compact file");
+        } 
+        
+        if(debug) System.out.printf("%s: %d alignment corrections for detId=%d detName=%s detType=%s\n",this.getClass().getSimpleName(),constantsElement.getChildren("millepede_constant").size(),detId,detName,detType);
+        
+        int id = -99999;
+        double value=-99999;
+        for(Iterator iConstant = constantsElement.getChildren("millepede_constant").iterator(); iConstant.hasNext();) {
+            Element constantElement = (Element)iConstant.next();
+            try {
+                id = constantElement.getAttribute("name").getIntValue();
+                value = constantElement.getAttribute("value").getDoubleValue();
+            } catch (DataConversionException e) {
+                e.printStackTrace();
+            }
+            //System.out.printf("%s: constant %d value %f\n",this.getClass().getSimpleName(),id,value);
+            
+            MilleParameter p = new MilleParameter(id,value,0.0);
+            //System.out.printf("%s: Milleparameter: %s\n", this.getClass().getSimpleName(),p.toString());
+            milleparameters.add(p);
+            
+        }
+        
+        if(debug) {
+            System.out.printf("%s: Initialized %d alignment parameters:\n",this.getClass().getSimpleName(),milleparameters.size());
+            for(MilleParameter p: milleparameters) {
+                System.out.printf("%s: %s \n",this.getClass().getSimpleName(),p.toString());                
+            }
+        }
+	    
+    }
+	
+	
+	/**
+	 * Extract @AlignmentCorrection for a half-module
+	 * @param isTopLayer - top or bottom layer
+	 * @param layer - to identify which sensor it is.
+	 * @return the alignment correction for this half-module
+	 */
+	protected AlignmentCorrection getHalfModuleAlignmentCorrection(boolean isTopLayer, int layer) {
+        double r[] = {0,0,0};
+        double t[] = {0,0,0};
+        for(MilleParameter p_loop: milleparameters) {
+            boolean paramIsTop = p_loop.getHalf()==1?true:false;
+            int paramLayer = p_loop.getSensor();
+            if(paramIsTop==isTopLayer && paramLayer==layer) {
+                if(p_loop.getType()==1) {
+                    t[p_loop.getDim()-1] = p_loop.getValue();
+                } else if(p_loop.getType()==2) {
+                    r[p_loop.getDim()-1] = p_loop.getValue();
+                } 
+            }
+        }
+        AlignmentCorrection c = new AlignmentCorrection();
+        c.setTranslation(new BasicHep3Vector(t));
+        c.setRotation(r[0],r[1],r[2]);
+        return c;
+    }
+	
+	/**
+     * Extract @AlignmentCorrection for the support
+     * @param isTopLayer - top or bottom layer
+     * @return the alignment correction
+     */
+    protected AlignmentCorrection getSupportAlignmentCorrection(boolean isTopLayer) {
+        double r[] = {0,0,0};
+        double t[] = {0,0,0};
+        for(MilleParameter p_loop: milleparameters) {
+            boolean paramIsTop = p_loop.getHalf()==1?true:false;
+            int paramType = p_loop.getType();
+            if(paramIsTop==isTopLayer && paramType==3) {
+                //xcheck
+                if(p_loop.getSensor()!=0) throw new RuntimeException("sensor name is not zero for support plate param! " + p_loop.getSensor());
+                // get the correction
+                r[p_loop.getDim()-1] = p_loop.getValue();
+            }
+        }
+        AlignmentCorrection c = new AlignmentCorrection();
+        c.setTranslation(new BasicHep3Vector(t));
+        c.setRotation(r[0],r[1],r[2]);
+        return c;
+    }
+	
+	
+
+    /**
 	 * Build the local geometry
 	 * 
 	 */
@@ -333,7 +433,9 @@
 	 * @return the layer.
 	 */
 	public static int getOldGeomDefLayerFromVolumeName(String name) {
+	    
 		String half = getHalfFromName(name);
+		int l = getLayerFromVolumeName(name);
 		boolean isTopLayer = false;
 		if(half=="top") isTopLayer=true;
 		else if(half=="bottom") isTopLayer = false;
@@ -342,25 +444,32 @@
 		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;
-	}
+		
+		return getOldGeomDefLayerFromVolumeName(isTopLayer, l, isAxial);
+	}
+	
+	
+	public static int getOldGeomDefLayerFromVolumeName(boolean isTopLayer, int l, boolean isAxial) {
+        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;
+    }
+    
+
 
 
 }

Modified: projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/HPSTrackerJavaBuilder.java
 =============================================================================
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/HPSTrackerJavaBuilder.java	(original)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/HPSTrackerJavaBuilder.java	Mon Oct 27 10:09:38 2014
@@ -31,7 +31,7 @@
 
 public abstract class HPSTrackerJavaBuilder implements IHPSTrackerJavaBuilder {
 
-	protected boolean _debug = false;
+	protected boolean _debug = true;
 	private JavaBaseGeometry baseTrackerGeometry;
 	protected List<JavaBaseGeometry> java_objects = new ArrayList<JavaBaseGeometry>();
 	protected DetectorIdentifierHelper detectorIdentifierHelper;

Modified: projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/HPSTrackerLCDDBuilder.java
 =============================================================================
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/HPSTrackerLCDDBuilder.java	(original)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/HPSTrackerLCDDBuilder.java	Mon Oct 27 10:09:38 2014
@@ -74,7 +74,7 @@
 	 * @author Per Hansson Adrian <[log in to unmask]>
 	 */
 	public static class LCDDBaseGeometry extends LCDDBaseGeometryVisualization {
-		private boolean debug = false;
+		private boolean debug = true;
 		private String name;
 		private Box box= null;
 		private Volume volume = null;

Added: projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/MilleParameter.java
 =============================================================================
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/MilleParameter.java	(added)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/MilleParameter.java	Mon Oct 27 10:09:38 2014
@@ -0,0 +1,110 @@
+package org.lcsim.geometry.compact.converter;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+
+
+
+public class MilleParameter {
+    private static double corrScaleFactor = -1.;
+	private int id;
+	private double value; 
+	private double presigma;
+	private static final Map<Integer,String> dMap;
+	private static final Map<Integer,String> tMap;
+	private static final Map<Integer,String> hMap;
+	static {
+		dMap = new HashMap<Integer,String>();
+		dMap.put(1, "x");dMap.put(2, "y"); dMap.put(3, "z");
+		tMap = new HashMap<Integer,String>();
+		tMap.put(1, "");tMap.put(2, "r");
+		hMap = new HashMap<Integer,String>();
+		hMap.put(1, "t");hMap.put(2, "b");
+		}
+	
+	public MilleParameter(String line) {
+		String[] vals = StringUtils.split(line);// line.split("\\s+");
+		if(vals.length <3) {
+			System.out.println("this line is ill-formatted (" + vals.length + ")");
+			System.out.println(line);
+			System.exit(1);
+		}
+		try {
+		//for(String v : vals) System.out.println("\"" + v + "\"");
+		setId(Integer.parseInt(vals[0]));
+		setValue( corrScaleFactor * Double.parseDouble(vals[1]) );
+		setPresigma(Double.parseDouble(vals[2]));
+		
+		} catch (NumberFormatException e) {
+			System.out.println(vals[0] + " " + vals[1] + " " + vals[2]);
+			throw new RuntimeException("problem parsing string ", e);
+		}
+	}
+	
+	public MilleParameter(int id, double value, double presigma) {
+	    setId(id);
+	    setValue(value);
+	    setPresigma(presigma);
+	}
+	
+	public String getXMLName() {
+		String d = dMap.get(getDim());
+		String t = tMap.get(getType());
+		String h = hMap.get(getHalf());
+		int s = getSensor();
+		return String.format("%s%s%d%s_align", t,d,s,h);
+		
+	}
+
+	public int getDim() {
+		int h = (int) (getHalf() * 1e4);
+		int t = (int) (getType() * 1e3);
+		return (int) Math.floor((id- h -t)/1e2);
+	}
+	
+	public int getSensor() {
+		int h = (int) (getHalf() * 1e4);
+		int t = (int) (getType() * 1e3);
+		int d = (int) (getDim() * 1e2);
+		return (id - h - t -d);
+	}
+
+	public int getType() {
+		int h = (int) (getHalf() * 1e4);
+		return (int) Math.floor((id -h)/1e3);
+	}
+
+	public int getHalf() {
+		return (int)Math.floor(id/1e4);
+	}
+
+	public int getId() {
+		return id;
+	}
+
+	public void setId(int id) {
+		this.id = id;
+	}
+
+	public double getValue() {
+		return value;
+	}
+
+	public void setValue(double value) {
+		this.value = value;
+	}
+
+	public double getPresigma() {
+		return presigma;
+	}
+
+	public void setPresigma(double presigma) {
+		this.presigma = presigma;
+	}
+	
+	public String toString() {
+	    return String.format("Milleparameter id=%d half=%d type=%d dim=%d sensor=%d value=%f", this.getId(), this.getHalf(), this.getType(), this.getDim(), this.getSensor(), this.getValue());
+	}
+}

Modified: projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/SurveyCoordinateSystem.java
 =============================================================================
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/SurveyCoordinateSystem.java	(original)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/SurveyCoordinateSystem.java	Mon Oct 27 10:09:38 2014
@@ -7,6 +7,7 @@
 
 import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
 import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
+import org.lcsim.detector.IRotation3D;
 import org.lcsim.detector.Rotation3D;
 import org.lcsim.detector.Transform3D;
 import org.lcsim.detector.Translation3D;
@@ -57,28 +58,51 @@
 		    }
 		}
 		
-		public void rotateApache(Rotation r) {
-		    if(debug) System.out.printf("%s: apply apache rotation to this coord system\n%s\n", getClass().getSimpleName(),toString());
-		    this.u = new BasicHep3Vector(r.applyTo(new Vector3D(u.v())).toArray());
-		    this.v = new BasicHep3Vector(r.applyTo(new Vector3D(v.v())).toArray());
-		    this.w = new BasicHep3Vector(r.applyTo(new Vector3D(w.v())).toArray());
-		    if(debug) System.out.printf("%s: new coord system after apache rotation to this coord system\n%s\n", getClass().getSimpleName(),toString());                
+		
+		/**
+		 * Transform this coordinate system to another one.
+		 * @param t
+		 */
+		public void transform(Transform3D t) {
+		    Transform3D t_this = getTransformation();
+		    Hep3Vector v = t_this.getTranslation().getTranslationVector();
+		    Hep3Vector vrot = t.rotated(v);
+		    Hep3Vector vrottrans = t.translated(vrot);
+		    origin = vrottrans;
+            rotate(t.getRotation());
+            //System.out.printf("monkey transform\n"); 
+            //System.out.printf("v %s\n",v.toString());
+            //System.out.printf("vrot %s\n",vrot.toString());
+            //System.out.printf("vrottrans %s\n",vrottrans.toString());
+		    check();
+		}
+		
+		public void rotate(IRotation3D r) {
+			r.rotate(u);
+			r.rotate(v);
+			r.rotate(w);
+		}
+
+		public void translate(Hep3Vector translation) {
+			// update origin with local translation in u,v,w
+		    //origin = VecOp.add(origin, translation);
+		    translate(new Translation3D(translation));
+		}
+
+		public void translate(Translation3D t) {
+		    origin = t.translated(getTransformation().getTranslation().getTranslationVector());
 		}
 
 		
-/*
-		public void rotate(Hep3Vector euler_angles) {
-			RotationGeant rotation = new RotationGeant(euler_angles.x(), euler_angles.y(), euler_angles.z());
-			rotation.rotate(u);
-			rotation.rotate(v);
-			rotation.rotate(w);
-		}
-		*/
-		public void translate(Hep3Vector translation) {
-			// update origin with local translation in u,v,w
-			origin = VecOp.add(origin, translation);
-		}
-		public Hep3Vector origin() {
+		public void rotateApache(Rotation r) {
+            if(debug) System.out.printf("%s: apply apache rotation to this coord system\n%s\n", getClass().getSimpleName(),toString());
+            this.u = new BasicHep3Vector(r.applyTo(new Vector3D(u.v())).toArray());
+            this.v = new BasicHep3Vector(r.applyTo(new Vector3D(v.v())).toArray());
+            this.w = new BasicHep3Vector(r.applyTo(new Vector3D(w.v())).toArray());
+            if(debug) System.out.printf("%s: new coord system after apache rotation to this coord system\n%s\n", getClass().getSimpleName(),toString());                
+        }
+        
+        public Hep3Vector origin() {
 			return origin;
 		}
 		public Hep3Vector u() {

Modified: projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/SurveyVolume.java
 =============================================================================
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/SurveyVolume.java	(original)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/SurveyVolume.java	Mon Oct 27 10:09:38 2014
@@ -15,13 +15,10 @@
  * 
  */
 public abstract class SurveyVolume {
-	protected boolean debug = false;
+	protected boolean debug = true;
 	private String name;
 	private String material = "Vacuum";
 	private SurveyVolume 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<SurveyVolume> referenceGeom = null;
 	private SurveyCoordinateSystem coord;
 	protected  Hep3Vector ballPos;
@@ -47,6 +44,7 @@
 	public SurveyVolume(String name, SurveyVolume m, AlignmentCorrection alignmentCorrection, List<SurveyVolume> ref) {
 		setName(name);
 		setMother(m);
+		setAlignmentCorrection(alignmentCorrection);
 		addReferenceGeom(ref);
 	}
 	
@@ -58,6 +56,7 @@
 	protected void init() {
 		setPos();
 		setCoord();
+		applyReferenceTransformation();
 		setCenter();
 		setBoxDim();
 		applyGenericCoordinateSystemCorrections();
@@ -66,32 +65,64 @@
 
 	protected void applyGenericCoordinateSystemCorrections() {
 	    //do nothing here unless overridden
+	   
+	}
+	protected void applyReferenceTransformation() {
+
+	    if(debug) System.out.printf("%s: applyReferenceTransformation for %s\n",this.getClass().getSimpleName(),getName());
+            	    
+	    if(referenceGeom!=null) {
+
+
+	        if(debug) System.out.printf("%s: coord system before %d ref transformations:\n%s\n",this.getClass().getSimpleName(),referenceGeom.size(),getCoord().toString());
+	        
+	        for(SurveyVolume ref : referenceGeom) {
+
+	            if(debug) {
+	                System.out.printf("%s: coord system before ref %s transform:\n%s\n",this.getClass().getSimpleName(),ref.getName(),getCoord().toString());
+	                System.out.printf("%s: Ref %s coord\n%s\n",this.getClass().getSimpleName(), ref.getName(),ref.getCoord().toString());
+	            }
+	            
+	            getCoord().transform(ref.getCoord().getTransformation());
+
+	            if(debug) System.out.printf("%s: coord system after ref %s transform:\n%s\n",this.getClass().getSimpleName(),ref.getName(),getCoord().toString());
+	            
+	        }
+
+	        if(debug) System.out.printf("%s: coord system after ref transformations:\n%s\n",this.getClass().getSimpleName(),getCoord().toString());
+	        
+	    } else {
+	        
+	        if(debug) System.out.printf("%s: no ref geom for this volume\n",this.getClass().getSimpleName());
+	        
+	    }
+
 	}
 	
 	private void applyAlignmentCorrections() {
 	    // Apply alignment corrections to local coordinate system that is already built
-
+	    boolean debug_local = true;
 	    if(this.coord==null) throw new RuntimeException("no coordinate system was set before trying to apply alignment corrections.");
 
 	    if(alignmentCorrections!=null) {
 
-	        if(debug) System.out.printf("%s: Apply alignment corrections to this coord system:\n%s\n",this.getClass().getSimpleName(),getCoord().toString());
+	        if(debug_local) System.out.printf("%s: Apply alignment corrections to this coord system:\n%s\n",this.getClass().getSimpleName(),getCoord().toString());
 
 	        // translate
 	        if(alignmentCorrections.getTranslation()!=null) {			    
 
-	            if(debug) System.out.printf("%s: Apply translation %s to coordinate system\n", this.getClass().getSimpleName(),alignmentCorrections.getTranslation().toString());			    
+	            if(debug_local) System.out.printf("%s: Apply translation %s to coordinate system\n", this.getClass().getSimpleName(),alignmentCorrections.getTranslation().toString());			    
 
 	            getCoord().translate(alignmentCorrections.getTranslation());
 
 	        } else {
-	            if(debug) System.out.printf("%s: No translation to coordinate system\n", this.getClass().getSimpleName());
+	            if(debug_local) System.out.printf("%s: No translation to coordinate system\n", this.getClass().getSimpleName());
 	        }
 
 	        // rotate
 	        if(alignmentCorrections.getRotation()!=null) {                
 
-	            if(debug) {
+	            if(debug_local) {
 	                System.out.printf("%s: Apply rotation to coordinate system. Matrix:\n", this.getClass().getSimpleName());             
 	                double mat[][] = alignmentCorrections.getRotation().getMatrix();
 	                TransformationUtils.printMatrix(mat);
@@ -100,19 +131,19 @@
 	                // Since the rotation was created based on active transformations convert to passive right here. 
 	                // This conversion is simply to reverse the order of rotations.
 	                Hep3Vector res_passive = new BasicHep3Vector(res[2],res[1],res[0]);
-	                System.out.printf("%s: Corresponding LCDD Cardan angles:\n", this.getClass().getSimpleName(), res_passive.toString());             
+	                System.out.printf("%s: Corresponding LCDD Cardan angles: %s\n", this.getClass().getSimpleName(), res_passive.toString());             
 	            }
 
 	            getCoord().rotateApache(alignmentCorrections.getRotation());
 
 	        } else {
-	            if(debug) System.out.printf("%s: No rotation to coordinate system\n", this.getClass().getSimpleName());
-	        }
-
-	        if(debug) System.out.printf("%s: coordinate system after alignment corrections:\n%s\n",this.getClass().getSimpleName(),getCoord().toString());
+	            if(debug_local) System.out.printf("%s: No rotation to coordinate system\n", this.getClass().getSimpleName());
+	        }
+
+	        if(debug_local) System.out.printf("%s: coordinate system after alignment corrections:\n%s\n",this.getClass().getSimpleName(),getCoord().toString());
 
 	    } else {
-	        if(debug) System.out.printf("%s: No aligment corrections to coordinate system\n", this.getClass().getSimpleName());
+	        if(debug_local) System.out.printf("%s: No aligment corrections to coordinate system\n", this.getClass().getSimpleName());
 	    }
 
 	}

Modified: projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java
 =============================================================================
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java	(original)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java	Mon Oct 27 10:09:38 2014
@@ -36,7 +36,7 @@
  */
 public class HPSTestRunTracker2014 extends LCDDSubdetector
 {
-	private boolean _debug = false; 
+	private boolean _debug = true; 
 	private final boolean buildBeamPlane = false;
 	// Builder class to handle all geometry information
 	private static HPSTrackerLCDDBuilder builder;

Modified: projects/lcsim/trunk/detector-framework/src/test/java/org/lcsim/geometry/subdetector/HPSTestRunTracker2014Test.java
 =============================================================================
--- projects/lcsim/trunk/detector-framework/src/test/java/org/lcsim/geometry/subdetector/HPSTestRunTracker2014Test.java	(original)
+++ projects/lcsim/trunk/detector-framework/src/test/java/org/lcsim/geometry/subdetector/HPSTestRunTracker2014Test.java	Mon Oct 27 10:09:38 2014
@@ -8,6 +8,7 @@
 import org.lcsim.detector.PhysicalVolumePath;
 import org.lcsim.geometry.Detector;
 import org.lcsim.geometry.GeometryReader;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -28,7 +29,9 @@
 	protected void setUp() throws Exception {
 		GeometryReader geometryReader = new GeometryReader();
 		geometryReader.setBuildDetailed(true);
-		String pathToCompactFile = "/org/lcsim/geometry/subdetector/HPSTestRun2014-v0.xml";
+		//String pathToCompactFile = "/org/lcsim/geometry/subdetector/HPSTestRun2014-v0.xml";
+		String pathToCompactFile = "/org/lcsim/geometry/subdetector/HPSTestRunTracker2014.xml";
+
 		InputStream in = HPSTestRunTracker2014Test.class.getResourceAsStream(pathToCompactFile);
 		det = geometryReader.read(in);
 		

Modified: projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector/HPSTestRunTracker2014.xml
 =============================================================================
--- projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector/HPSTestRunTracker2014.xml	(original)
+++ projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector/HPSTestRunTracker2014.xml	Mon Oct 27 10:09:38 2014
@@ -54,36 +54,159 @@
   
   <detectors>
     <detector id="1" name="Tracker" type="HPSTestRunTracker2014" readout="TrackerHits">
-	  
-      <!-- Definition of half module logical volume. -->
-      <half_modules>
-        <half_module name="SvtHalfModuleLayers1-3">
-          <component x="50.0" y="100.0" z="0.0" material="Silicon" sensitive="true" />
-        </half_module>
-      </half_modules>
-      
-      <!-- Alignment of entire tracker box. -->
-      <alignment x="0.0" y="0.0" z="0.0" />
-      <support_plate name="SupportPlateL1-3bot">
-        <position name="ball" x="0.0" y="0.0" z="0.0"/>
-        <position name="vee" x="0.0" y="0.0" z="0.0"/>
-        <position name="flat" x="0.0" y="0.0" z="0.0"/>
-        <alignment x="5.0" y="5.0" z="5.0" rx="0.1" ry="0.1" rz="0.1"/>
-        <modules>
-          <module layer="1" ref="SvtModule">
-            <position name="ball" x="0.0" y="0.0" z="0.0"/>
-        	<position name="vee" x="0.0" y="0.0" z="0.0"/>
-        	<position name="flat" x="0.0" y="0.0" z="0.0"/>
-        	<alignment x="4.0" y="4.0" z="4.0" rx="0.1" ry="0.1" rz="0.1"/>
-        	<half_module type="axial" ref="SvtHalfModuleLayers1-3">
-	        	<position name="ball" x="0.0" y="0.0" z="0.0"/>
-    	    	<position name="vee" x="0.0" y="0.0" z="0.0"/>
-        		<position name="flat" x="0.0" y="0.0" z="0.0"/>
-            	<alignment x="3.0" y="3.0" z="3.0" rx="0.1" ry="0.1" rz="0.1" />
-            </half_module>
-          </module>
-        </modules>
-      </support_plate>
+        <millepede_constants>
+        
+            <!-- top half-module translations -->
+            <millepede_constant name="11101" value="0.0"/>
+            <millepede_constant name="11102" value="0.0"/>
+            <millepede_constant name="11103" value="0.0"/>
+            <millepede_constant name="11104" value="0.0"/>
+            <millepede_constant name="11105" value="0.0"/>
+            <millepede_constant name="11106" value="0.0"/>
+            <millepede_constant name="11107" value="0.0"/>
+            <millepede_constant name="11108" value="0.0"/>
+            <millepede_constant name="11109" value="0.0"/>
+            <millepede_constant name="11110" value="0.0"/>
+
+            <millepede_constant name="11201" value="0.0"/>
+            <millepede_constant name="11202" value="0.0"/>
+            <millepede_constant name="11203" value="0.0"/>
+            <millepede_constant name="11204" value="0.0"/>
+            <millepede_constant name="11205" value="0.0"/>
+            <millepede_constant name="11206" value="0.0"/>
+            <millepede_constant name="11207" value="0.0"/>
+            <millepede_constant name="11208" value="0.0"/>
+            <millepede_constant name="11209" value="0.0"/>
+            <millepede_constant name="11210" value="0.0"/>
+
+            <millepede_constant name="11301" value="0.0"/>
+            <millepede_constant name="11302" value="0.0"/>
+            <millepede_constant name="11303" value="0.0"/>
+            <millepede_constant name="11304" value="0.0"/>
+            <millepede_constant name="11305" value="0.0"/>
+            <millepede_constant name="11306" value="0.0"/>
+            <millepede_constant name="11307" value="0.0"/>
+            <millepede_constant name="11308" value="0.0"/>
+            <millepede_constant name="11309" value="0.0"/>
+            <millepede_constant name="11310" value="0.0"/>
+            
+            <!-- top half-module rotations -->
+            
+            <millepede_constant name="12101" value="0.0"/>
+            <millepede_constant name="12102" value="0.0"/>
+            <millepede_constant name="12103" value="0.0"/>
+            <millepede_constant name="12104" value="0.0"/>
+            <millepede_constant name="12105" value="0.0"/>
+            <millepede_constant name="12106" value="0.0"/>
+            <millepede_constant name="12107" value="0.0"/>
+            <millepede_constant name="12108" value="0.0"/>
+            <millepede_constant name="12109" value="0.0"/>
+            <millepede_constant name="12110" value="0.0"/>
+
+            <millepede_constant name="12201" value="0.0"/>
+            <millepede_constant name="12202" value="0.0"/>
+            <millepede_constant name="12203" value="0.0"/>
+            <millepede_constant name="12204" value="0.0"/>
+            <millepede_constant name="12205" value="0.0"/>
+            <millepede_constant name="12206" value="0.0"/>
+            <millepede_constant name="12207" value="0.0"/>
+            <millepede_constant name="12208" value="0.0"/>
+            <millepede_constant name="12209" value="0.0"/>
+            <millepede_constant name="12210" value="0.0"/>
+
+            <millepede_constant name="12301" value="0.0"/>
+            <millepede_constant name="12302" value="0.0"/>
+            <millepede_constant name="12303" value="0.0"/>
+            <millepede_constant name="12304" value="0.0"/>
+            <millepede_constant name="12305" value="0.0"/>
+            <millepede_constant name="12306" value="0.0"/>
+            <millepede_constant name="12307" value="0.0"/>
+            <millepede_constant name="12308" value="0.0"/>
+            <millepede_constant name="12309" value="0.0"/>
+            <millepede_constant name="12310" value="0.0"/>
+            
+            <!-- bottom half-module translations -->
+            
+            <millepede_constant name="21101" value="0.0"/>
+            <millepede_constant name="21102" value="0.0"/>
+            <millepede_constant name="21103" value="0.0"/>
+            <millepede_constant name="21104" value="0.0"/>
+            <millepede_constant name="21105" value="0.0"/>
+            <millepede_constant name="21106" value="0.0"/>
+            <millepede_constant name="21107" value="0.0"/>
+            <millepede_constant name="21108" value="0.0"/>
+            <millepede_constant name="21109" value="0.0"/>
+            <millepede_constant name="21110" value="0.0"/>
+
+            <millepede_constant name="21201" value="0.0"/>
+            <millepede_constant name="21202" value="0.0"/>
+            <millepede_constant name="21203" value="0.0"/>
+            <millepede_constant name="21204" value="0.0"/>
+            <millepede_constant name="21205" value="0.0"/>
+            <millepede_constant name="21206" value="0.0"/>
+            <millepede_constant name="21207" value="0.0"/>
+            <millepede_constant name="21208" value="0.0"/>
+            <millepede_constant name="21209" value="0.0"/>
+            <millepede_constant name="21210" value="0.0"/>
+
+            <millepede_constant name="21301" value="0.0"/>
+            <millepede_constant name="21302" value="0.0"/>
+            <millepede_constant name="21303" value="0.0"/>
+            <millepede_constant name="21304" value="0.0"/>
+            <millepede_constant name="21305" value="0.0"/>
+            <millepede_constant name="21306" value="0.0"/>
+            <millepede_constant name="21307" value="0.0"/>
+            <millepede_constant name="21308" value="0.0"/>
+            <millepede_constant name="21309" value="0.0"/>
+            <millepede_constant name="21310" value="0.0"/>
+            
+            <!-- bottom half-module rotations -->
+            
+            <millepede_constant name="22101" value="0.0"/>
+            <millepede_constant name="22102" value="0.0"/>
+            <millepede_constant name="22103" value="0.0"/>
+            <millepede_constant name="22104" value="0.0"/>
+            <millepede_constant name="22105" value="0.0"/>
+            <millepede_constant name="22106" value="0.0"/>
+            <millepede_constant name="22107" value="0.0"/>
+            <millepede_constant name="22108" value="0.0"/>
+            <millepede_constant name="22109" value="0.0"/>
+            <millepede_constant name="22110" value="0.0"/>
+
+            <millepede_constant name="22201" value="0.0"/>
+            <millepede_constant name="22202" value="0.0"/>
+            <millepede_constant name="22203" value="0.0"/>
+            <millepede_constant name="22204" value="0.0"/>
+            <millepede_constant name="22205" value="0.0"/>
+            <millepede_constant name="22206" value="0.0"/>
+            <millepede_constant name="22207" value="0.0"/>
+            <millepede_constant name="22208" value="0.0"/>
+            <millepede_constant name="22209" value="0.0"/>
+            <millepede_constant name="22210" value="0.0"/>
+
+            <millepede_constant name="22301" value="0.0"/>
+            <millepede_constant name="22302" value="0.0"/>
+            <millepede_constant name="22303" value="0.0"/>
+            <millepede_constant name="22304" value="0.0"/>
+            <millepede_constant name="22305" value="0.0"/>
+            <millepede_constant name="22306" value="0.0"/>
+            <millepede_constant name="22307" value="0.0"/>
+            <millepede_constant name="22308" value="0.0"/>
+            <millepede_constant name="22309" value="0.0"/>
+            <millepede_constant name="22310" value="0.0"/>
+            
+            
+            <!-- top support tilt angles -->
+            <millepede_constant name="13100" value="0.0"/> <!-- + means opening -->
+            <millepede_constant name="13200" value="0.0"/>
+            <millepede_constant name="13300" value="0.0"/>
+            
+            <!-- bottom support tilt angles -->
+            <millepede_constant name="23100" value="0.0"/> <!-- + means closing -->
+            <millepede_constant name="23200" value="0.0"/>
+            <millepede_constant name="23300" value="0.0"/>
+            
+        </millepede_constants>
     </detector>
   </detectors>
   <readouts>

########################################################################
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