LISTSERV mailing list manager LISTSERV 16.5

Help for LCDET-SVN Archives


LCDET-SVN Archives

LCDET-SVN Archives


LCDET-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

LCDET-SVN Home

LCDET-SVN Home

LCDET-SVN  October 2014

LCDET-SVN October 2014

Subject:

r3397 - in /projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter: HPSTestRunTracker2014GeometryDefinition.java SurveyCoordinateSystem.java SurveyVolume.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the lcdet svn repository <[log in to unmask]>

Date:

Tue, 28 Oct 2014 17:10:46 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (219 lines)

Author: phansson
Date: Tue Oct 28 10:10:44 2014
New Revision: 3397

Log:
Fix rotation correction.

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/SurveyCoordinateSystem.java
    projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/SurveyVolume.java

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	Tue Oct 28 10:10:44 2014
@@ -30,7 +30,7 @@
     public final boolean doColdBlock = false;
     public final boolean doBottom = true;
     public final boolean doTop = true;
-    public final int layerBitMask = 0x1F; //0x1;//    
+    public final int layerBitMask =  0x1F;    //0x1;//
 
 
     //General
@@ -223,26 +223,34 @@
         // find layer
         int layer = mother.getLayer();
 
+        // axial or stereo
+        boolean isAxial = isAxialFromName(volName);
+
+        // find layer according to old definition
+        int oldLayer = getOldGeomDefLayerFromVolumeName(isTopLayer, layer, isAxial);
+        //if(isDebug()) System.out.printf("%s: half? %s layer %d oldlayer %d axial? %s\n", 
+        //        this.getClass().getSimpleName(), isTopLayer?"top":"bottom", layer,oldLayer,isAxial?"yes":"no");
+
+        // find alignment correction to this volume
+        AlignmentCorrection alignmentCorrection =  getHalfModuleAlignmentCorrection(isTopLayer, oldLayer);
+        
+        
+        // find the bundle that it will be added to
         TestRunModuleBundle bundle  = (TestRunModuleBundle)getModuleBundle(mother);
         TestRunHalfModuleBundle halfModuleBundle;
         
         
         // Build the half-module
         TestRunHalfModule halfModule;
-        AlignmentCorrection alignmentCorrection = null;
-        if(side == "axial") {
-            //alignmentCorrection =  getHalfModuleAlignmentCorrection(isTopLayer, getOldGeomDefLayerFromVolumeName(isTopLayer, layer, true));
+        if(isAxial) {
             halfModule = new TestRunHalfModuleAxial(volName, mother, alignmentCorrection, layer, half);
             halfModuleBundle = new TestRunHalfModuleBundle(halfModule);
             bundle.halfModuleAxial = halfModuleBundle;
-        } else if(side == "stereo") {
-            //alignmentCorrection =  getHalfModuleAlignmentCorrection(isTopLayer, getOldGeomDefLayerFromVolumeName(isTopLayer, layer, false));
+        } else {
             halfModule = new TestRunHalfModuleStereo(volName, mother, alignmentCorrection, 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 
@@ -339,18 +347,8 @@
         // sensor id is hard coded in old geometry to be zero by counting over the components of the module
         int component_number = 0;
 
-        boolean isTopLayer = getHalfFromName(volName) == "top" ? true : false;
-        int layer  = getLayerFromVolumeName(volName);
-        boolean isAxial = isAxialFromName(volName);
-        int oldLayer = getOldGeomDefLayerFromVolumeName(isTopLayer, layer, isAxial);
-        if(isDebug()) System.out.printf("%s: half? %s layer %d oldlayer %d axial? %s\n", 
-                this.getClass().getSimpleName(), isTopLayer?"top":"bottom", layer,oldLayer,isAxial?"yes":"no");
-
-        AlignmentCorrection alignmentCorrection =  getHalfModuleAlignmentCorrection(isTopLayer, oldLayer);
-        
-        
         //  
-        Sensor sensor = new Sensor(volName, mother, alignmentCorrection, component_number);
+        Sensor sensor = new Sensor(volName, mother, null, component_number);
         sensor.setMaterial("Silicon");
 
         TestRunHalfModuleBundle hm = (TestRunHalfModuleBundle) getHalfModuleBundle((TestRunModule) mother.getMother(), mother.getName());

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	Tue Oct 28 10:10:44 2014
@@ -114,6 +114,15 @@
 		public Hep3Vector w() {
 			return w;
 		}
+		public void u(Hep3Vector vec) {
+            u = vec;
+		}
+        public void v(Hep3Vector vec) {
+            v = vec;
+        }
+        public void w(Hep3Vector vec) {
+            w = vec;
+        }
 		
         public String toString() {
 			return "Coordinate system: \norigin " + origin.toString() + "\nu " + u.toString() + "\nv " + v.toString() + "\nw " + w.toString();

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	Tue Oct 28 10:10:44 2014
@@ -1,12 +1,16 @@
 package org.lcsim.geometry.compact.converter;
 
+import hep.physics.vec.BasicHep3Matrix;
 import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Matrix;
 import hep.physics.vec.Hep3Vector;
 
 import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.commons.math3.geometry.euclidean.threed.RotationOrder;
+import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
+import org.lcsim.detector.Rotation3D;
 import org.lcsim.geometry.util.TransformationUtils;
 
 /**
@@ -126,21 +130,65 @@
 	        }
 
 	        // rotate
-	        if(alignmentCorrections.getRotation()!=null) {                
-
-	            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);
-	                // Get the Cardan angles of the rotation
-	                double res[] = alignmentCorrections.getRotation().getAngles(RotationOrder.ZYX);
-	                // 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: %s\n", this.getClass().getSimpleName(), res_passive.toString());             
-	            }
-
-	            getCoord().rotateApache(alignmentCorrections.getRotation());
+	        if(alignmentCorrections.getRotation()!=null) {  
+	            
+                if(debug_local) {
+                    System.out.printf("%s: Apply rotation matrix:\n", this.getClass().getSimpleName());   
+                    TransformationUtils.printMatrix(alignmentCorrections.getRotation().getMatrix());
+                    System.out.printf("%s: coord system before:\n%s\n", this.getClass().getSimpleName(),getCoord().toString());   
+                }
+
+	            
+	            // correct rotation of the local unit vectors
+	            Vector3D u_rot_local = alignmentCorrections.getRotation().applyTo(new Vector3D(1,0,0));
+	            Vector3D v_rot_local = alignmentCorrections.getRotation().applyTo(new Vector3D(0,1,0));
+	            Vector3D w_rot_local = alignmentCorrections.getRotation().applyTo(new Vector3D(0,0,1));
+
+	            // rotate the local unit vectors to the mother coordinates
+	            
+	            Hep3Vector u_rot = getCoord().getTransformation().getRotation().rotated(new BasicHep3Vector(u_rot_local.toArray()));
+	            Hep3Vector v_rot = getCoord().getTransformation().getRotation().rotated(new BasicHep3Vector(v_rot_local.toArray()));
+	            Hep3Vector w_rot = getCoord().getTransformation().getRotation().rotated(new BasicHep3Vector(w_rot_local.toArray()));
+               
+	            getCoord().u(u_rot);
+	            getCoord().v(v_rot);
+	            getCoord().w(w_rot);
+
+                if(debug_local) {
+                    System.out.printf("%s: coord system after:\n%s\n", this.getClass().getSimpleName(),getCoord().toString());   
+                }
+
+	            
+	            // Do some gymnastics from Apache rotation to use the rotation class
+	            //double matMP_v[][] = alignmentCorrections.getRotation().getMatrix();
+                //Hep3Matrix matMP = new BasicHep3Matrix(matMP_v[0][0], matMP_v[0][1], matMP_v[0][2], 
+                //                                       matMP_v[1][0], matMP_v[1][1], matMP_v[1][2],
+                //                                       matMP_v[2][0], matMP_v[2][1], matMP_v[2][2]);
+                //
+                //Rotation3D rotMP = new Rotation3D(matMP);
+
+                // get the rotation correction in the mother coordinate system
+                //Rotation3D r = Rotation3D.multiply(getCoord().getTransformation().getRotation(),rotMP);
+	            
+//                if(debug_local) {
+//	                System.out.printf("%s: Apply rotation matrix:\n", this.getClass().getSimpleName());             
+//	                double mat[][] = alignmentCorrections.getRotation().getMatrix();
+//	                TransformationUtils.printMatrix(mat);
+//	                System.out.printf("%s: corresponding Rotation3D object:\n%s\n",this.getClass().getSimpleName(), rotMP.toString());
+//	                // Get the Cardan angles of the rotation
+//	                double res[] = alignmentCorrections.getRotation().getAngles(RotationOrder.ZYX);
+//	                // 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: %s\n", this.getClass().getSimpleName(), res_passive.toString());             
+//	                System.out.printf("%s: Apply local to mother rotation\n%s\n",this.getClass().getSimpleName(), getCoord().getTransformation().getRotation().toString());
+//	                System.out.printf("%s: resulting rotation correction to apply\n%s\n",this.getClass().getSimpleName(), r.toString());
+//                    
+//	            }
+
+                // Apply correction to coordinate system
+	            //getCoord().rotateApache(alignmentCorrections.getRotation());
+                //getCoord().rotate(r);
 
 	        } else {
 	            if(debug_local) System.out.printf("%s: No rotation to coordinate system\n", this.getClass().getSimpleName());

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

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use