Print

Print


Commit in projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd on MAIN
HPSTestRunTracker2014Builder.java+85-183307 -> 3308
Added functions to walk through transformations.

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
HPSTestRunTracker2014Builder.java 3307 -> 3308
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014Builder.java	2014-09-04 05:47:56 UTC (rev 3307)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014Builder.java	2014-09-04 06:00:37 UTC (rev 3308)
@@ -3,26 +3,15 @@
  */
 package org.lcsim.geometry.compact.converter.lcdd;
 
-import hep.physics.vec.BasicHep3Vector;
 import hep.physics.vec.Hep3Vector;
-import hep.physics.vec.VecOp;
 
 import java.util.ArrayList;
 import java.util.List;
 
-import org.jdom.JDOMException;
-import org.lcsim.detector.tracker.silicon.SiSensor;
+import org.lcsim.detector.Transform3D;
 import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.BaseGeometry;
 import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.TestRunColdBlock;
 import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.TestRunModule;
-import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.TestRunModuleL13;
-import org.lcsim.geometry.compact.converter.lcdd.util.Box;
-import org.lcsim.geometry.compact.converter.lcdd.util.LCDD;
-import org.lcsim.geometry.compact.converter.lcdd.util.PhysVol;
-import org.lcsim.geometry.compact.converter.lcdd.util.Position;
-import org.lcsim.geometry.compact.converter.lcdd.util.Rotation;
-import org.lcsim.geometry.compact.converter.lcdd.util.SensitiveDetector;
-import org.lcsim.geometry.compact.converter.lcdd.util.Volume;
 
 /**
  * 
@@ -50,7 +39,7 @@
 
 		if(isDebug()) System.out.printf("%s: constructing the geometry objects\n", this.getClass().getSimpleName());
 
-		// Build the geometry from the basicl building blocks in the geometry definition class
+		// Build the geometry from the basic building blocks in the geometry definition class
 		// Keep the order correct.
 		// Each item has knowledge of its mother but not its daughters
 		HPSTestRunTracker2014GeometryDefinition.TrackingBase tracking = new HPSTestRunTracker2014GeometryDefinition.TrackingBase("trackingVolume",null);
@@ -110,12 +99,12 @@
 		final HPSTestRunTracker2014GeometryDefinition.BaseGeometry ref;
 		if(half == "bottom") {
 			//mother = getItem(HPSTestRunTracker2014GeomDef.SupportBottom.class);
-			mother = getItem(HPSTestRunTracker2014GeometryDefinition.Base.class);
-			ref = getItem(HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.class);
+			mother = getBaseGeometry(HPSTestRunTracker2014GeometryDefinition.Base.class);
+			ref = getBaseGeometry(HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom.class);
 		} else {
 			//mother= getItem(HPSTestRunTracker2014GeomDef.SupportTop.class);
-			mother= getItem(HPSTestRunTracker2014GeometryDefinition.Base.class);
-			ref = getItem(HPSTestRunTracker2014GeometryDefinition.SupportPlateTop.class);
+			mother= getBaseGeometry(HPSTestRunTracker2014GeometryDefinition.Base.class);
+			ref = getBaseGeometry(HPSTestRunTracker2014GeometryDefinition.SupportPlateTop.class);
 		}
 		
 		//Create the module
@@ -462,7 +451,7 @@
 	 * @param c - class type to be found
 	 * @return the found type.
 	 */
-	protected <T> T getItem(Class<T> c) {
+	protected <T> T getBaseGeometry(Class<T> c) {
 		///if(isDebug()) System.out.printf("%s: get Item %s\n", this.getClass().getSimpleName(),c.getName());
 		
 		for(HPSTestRunTracker2014GeometryDefinition.BaseGeometry item : trackerItems) {
@@ -609,6 +598,84 @@
         }
         return false;
     }
+    
+    
+    public static Transform3D getTransform(Transform3D t, BaseGeometry mother, String targetMotherName) {
+		int debug=1;
+		if(debug>0) System.out.printf("getTransform mother %s target %s with current transform\n%s\n", mother.getName(), targetMotherName,t.toString());
+		if(mother==null) throw new RuntimeException("Trying to get mother transform but there is no mother?!");
+		if(mother.getName().equals(targetMotherName)) {
+			if(debug>0) System.out.printf("found the transform\n");
+			return t;
+		} else {
+			if(debug>0) System.out.printf("add mother transform\n%s\n",mother.getCoord().getTransformation().toString());
+			Transform3D trans = Transform3D.multiply(mother.getCoord().getTransformation(), t);
+			if(debug>0) System.out.printf("resulting transform\n%s\ncontinue searching\n",trans.toString());
+			return getTransform(trans, mother.getMother(), targetMotherName);
+		}
+		
+	}
+    
+    
+    public static Hep3Vector transformToMotherCoord(Hep3Vector vec, BaseGeometry geometry, String targetMotherName) {
+		int debug =1;
+		BaseGeometry mother = geometry.getMother();
+		if(debug>0) System.out.printf("transformToMotherCoord vec %s geomtry %s  mother %s target %s\n", vec.toString(), geometry.getName(), geometry.getMother().getName(), targetMotherName);
+		
+		Transform3D t = getTransform(geometry.getCoord().getTransformation(), mother, targetMotherName);
+		
+		Hep3Vector vec_t = t.transformed(vec);
+		
+		if(debug>0) {
+			System.out.printf("transformToMotherCoord apply transform \n%s\n",t.toString());
+			System.out.printf("transformToMotherCoord vec_t%s\n",vec_t.toString());
+		}
+		
+		
+		return vec_t;
+	}
+		
+    
+    public static Hep3Vector transformToTracking(Hep3Vector vec, BaseGeometry geometry) {
+		int debug =1;
+		if(debug>0) System.out.printf("\ntransformToTracking: vec %s in local coordiantes of %s with mother %s\n", vec.toString(), geometry.getName(), geometry.getMother().getName().toString());
+		Hep3Vector vec_mother_coord = geometry.getCoord().getTransformation().transformed(vec);
+		if(debug>0) System.out.printf("vec_mother_coord %s\n",vec_mother_coord.toString());
+		if(geometry.getMother().getName().equals("trackingVolume")) {
+			if(debug>0) System.out.printf("reached tracking volume. Return \n");
+			return vec_mother_coord;
+		} else {
+			if(debug>0) System.out.printf("continue searching.\n");
+		}
+		return transformToTracking(vec_mother_coord, geometry.getMother());
+	}
+		
+	
 
+    
+    /*
+	public static Hep3Vector transformToMotherCoord(Hep3Vector vec, BaseGeometry mother, String targetMotherName) {
+		int debug =1;
+		if(debug>0) System.out.printf("transformToMotherCoord vec %s mother %s target %s\n", vec.toString(), mother.getName(), targetMotherName);
+		if(mother.name.equals(targetMotherName)) {
+			if(debug>0) System.out.printf(String.format("found the transformed vec %s\n", vec.toString()));
+			return vec;
+		} else {
+			if(mother.name.equals("trackingVolume")) {
+				if(debug>0) System.out.print("reached tracking volume. return null?!\n");
+				return null;
+			}
+
+			Transform3D trans = new Transform3D(mother.pos, mother.rot);
+			Hep3Vector vec_t = trans.transformed(vec);
+			if(debug>0) System.out.print("continue searching\n");
+			return transformToMotherCoord(vec_t, mother.mother, targetMotherName);
+		}
+		
+	}
+	*/
+
+    
+    
 	
 }
SVNspam 0.1


Use REPLY-ALL to reply to list

To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1