Print

Print


Commit in projects/lcsim/trunk/detector-framework/src on MAIN
main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java+68-503211 -> 3212
                                                   /HPSTestRunTracker2014Builder.java+395-483211 -> 3212
                                                   /HPSTestRunTracker2014GeomDef.java+273211 -> 3212
                                                   /HPSTestRunTracker2014LCDDBuilder.java+131-523211 -> 3212
test/resources/org/lcsim/geometry/subdetector/HPSTestRunTracker2014.xml+4-43211 -> 3212
+625-154
5 modified files
Start using separate builder class.

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
HPSTestRunTracker2014.java 3211 -> 3212
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java	2014-08-01 18:01:33 UTC (rev 3211)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java	2014-08-02 15:59:58 UTC (rev 3212)
@@ -127,14 +127,31 @@
 		
 	}
 	
+	
+	private void buildLCDD() {
+		
+		if(_debug) System.out.printf("%s: buildLCDD\n", getClass().getSimpleName());
+		
+		LCDD lcdd  = builder.getLCDD();
 
+		LCDDBaseGeom lcddObj = builder.getBaseLCDD();
+		
+		addToLCDD(lcddObj,lcdd);
+		
+		
+		if(_debug) System.out.printf("%s: buildLCDD DONE\n", getClass().getSimpleName());
+		
+	}
+	
+	
+
 	private void addToLCDD(LCDDBaseGeom lcddObj, LCDD lcdd) {
 		
 		if(_debug) System.out.printf("%s: adding %s to LCDD\n", getClass().getSimpleName(),lcddObj.getName());
 
 		if(lcddObj.getClass().isInstance(GhostBaseGeom.class)) {
 			System.out.printf("%s: trying to add a ghost volume: %s ??\n", getClass().getSimpleName(),lcddObj.getName());
-			throw new RuntimeException("adding a ghose volume (" + lcddObj.getName() + ") to LCDD is not allowed.");
+			throw new RuntimeException("adding a ghost volume (" + lcddObj.getName() + ") to LCDD is not allowed.");
 		}
 		// add box, pos, rotation and create phys volume
 		lcdd.add(lcddObj.getBox());
@@ -156,25 +173,10 @@
 		if(_debug) System.out.printf("%s: DONE adding %s\n", getClass().getSimpleName(),lcddObj.getName());
 	}
 	
-	private void buildLCDD() {
-		
-		if(_debug) System.out.printf("%s: buildLCDD\n", getClass().getSimpleName());
-		
-		LCDD lcdd  = builder.getLCDD();
-
-		LCDDBaseGeom lcddObj = builder.getBaseLCDD();
-		
-		addToLCDD(lcddObj,lcdd);
-		
-		
-		if(_debug) System.out.printf("%s: buildLCDD DONE\n", getClass().getSimpleName());
-		
-	}
 	
 	
+	/*
 	
-	
-	
 	private void makeBase(Volume motherVolume, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
 		
 		
@@ -184,7 +186,7 @@
 		
 		
 		
-		HPSTestRunTracker2014GeomDef.BaseGeom base = builder.getBase();
+		HPSTestRunTracker2014GeomDef.BaseGeom base = builder.getItem(HPSTestRunTracker2014GeomDef.Base.class);
 		
 		Hep3Vector ball_pos_base = base.getBallPos();
 		Hep3Vector vee_pos_base = base.getVeePos(); 
@@ -273,16 +275,17 @@
 	}
 
 	
+	*/
 	
+	/*
 	
-	
 		private void makeBasePlate(Volume motherVolume, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
 
 		if(_debug) {
 			print("--- makeBasePlate----");
 		}
 
-		HPSTestRunTracker2014GeomDef.BasePlate basePlate = builder.getBasePlate();
+		HPSTestRunTracker2014GeomDef.BasePlate basePlate = builder.getItem(HPSTestRunTracker2014GeomDef.BasePlate.class);
 		
 		HPSTestRunTracker2014GeomDef.Coord base_plate_coord = basePlate.getCoord();
 		
@@ -339,7 +342,9 @@
 		
 	}
 
+	*/
 	
+	/*
 	
 	private void makeSupport(String half, Volume motherVolume, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
 		
@@ -377,8 +382,8 @@
 		String volName;
 		HPSTestRunTracker2014GeomDef.Coord csup_coord;
 		HPSTestRunTracker2014GeomDef.BaseGeom mother;
-		HPSTestRunTracker2014GeomDef.SupportBottom supportBottom  = builder.getSupportBottom();
-		HPSTestRunTracker2014GeomDef.SupportTop supportTop = builder.getSupportTop();
+		HPSTestRunTracker2014GeomDef.SupportBottom supportBottom  = builder.getItem(HPSTestRunTracker2014GeomDef.SupportBottom.class);
+		HPSTestRunTracker2014GeomDef.SupportTop supportTop = builder.getItem(HPSTestRunTracker2014GeomDef.SupportTop.class);
 		if(half == "bottom") {
 			csup_coord = supportBottom.getCoord();
 			volName = supportBottom.getName();
@@ -452,25 +457,25 @@
 		// vee: corner of the hinge end at the surface on the side where sensors are
 		// flat: middle of plate at upstream end at the surface
 
-		/*
-		Hep3Vector ball_pos_support_plate;
-		Hep3Vector vee_pos_support_plate;
-		Hep3Vector flat_pos_support_plate;
-		if(half == "bottom") {
-			ball_pos_support_plate = new BasicHep3Vector(1.0, (17.0-5.0), 6.66+1.34); 
-			vee_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x() + support_plate_width, ball_pos_support_plate.y(),ball_pos_support_plate.z());
-			flat_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x(), ball_pos_support_plate.y() + support_plate_length,ball_pos_support_plate.z());
-			//ball_pos_support_plate = new BasicHep3Vector(0.0, 0.0, support_plate_height); // TODO figure out what height this should be from the C-support drawings
-			//vee_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x() + support_plate_width, ball_pos_support_plate.y(),ball_pos_support_plate.z());
-			//flat_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x(), ball_pos_support_plate.y() + support_plate_length,ball_pos_support_plate.z());
-		} else {
-			ball_pos_support_plate = new BasicHep3Vector(1.0, (17.0-5.0), -1.0 * (6.66+1.34)); // TODO figure out what height this should be from the C-support drawings
-			vee_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x() + support_plate_width, ball_pos_support_plate.y(),ball_pos_support_plate.z());
-			flat_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x(), ball_pos_support_plate.y() + support_plate_length,ball_pos_support_plate.z());
-		}
-		*/
 		
+//		Hep3Vector ball_pos_support_plate;
+//		Hep3Vector vee_pos_support_plate;
+//		Hep3Vector flat_pos_support_plate;
+//		if(half == "bottom") {
+//			ball_pos_support_plate = new BasicHep3Vector(1.0, (17.0-5.0), 6.66+1.34); 
+//			vee_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x() + support_plate_width, ball_pos_support_plate.y(),ball_pos_support_plate.z());
+//			flat_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x(), ball_pos_support_plate.y() + support_plate_length,ball_pos_support_plate.z());
+//			//ball_pos_support_plate = new BasicHep3Vector(0.0, 0.0, support_plate_height); // TODO figure out what height this should be from the C-support drawings
+//			//vee_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x() + support_plate_width, ball_pos_support_plate.y(),ball_pos_support_plate.z());
+//			//flat_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x(), ball_pos_support_plate.y() + support_plate_length,ball_pos_support_plate.z());
+//		} else {
+//			ball_pos_support_plate = new BasicHep3Vector(1.0, (17.0-5.0), -1.0 * (6.66+1.34)); // TODO figure out what height this should be from the C-support drawings
+//			vee_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x() + support_plate_width, ball_pos_support_plate.y(),ball_pos_support_plate.z());
+//			flat_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x(), ball_pos_support_plate.y() + support_plate_length,ball_pos_support_plate.z());
+//		}
 		
+		
+		
 		//makeSupportPlate(supportWrap, ball_pos_support_plate, vee_pos_support_plate, flat_pos_support_plate, lcdd, sens );
 
 		makeSupportPlate(half, supportVolume, lcdd, sens );
@@ -513,7 +518,9 @@
 	
 	}
 
+	*/
 	
+	/*
 	
 	
 
@@ -533,8 +540,8 @@
 		HPSTestRunTracker2014GeomDef.Coord support_plate_coord;
 		HPSTestRunTracker2014GeomDef.BaseGeom mother;
 		
-		HPSTestRunTracker2014GeomDef.SupportPlateBottom supportPlateBottom = builder.getSupportPlateBottom();
-		HPSTestRunTracker2014GeomDef.SupportPlateTop supportPlateTop = builder.getSupportPlateTop();
+		HPSTestRunTracker2014GeomDef.SupportPlateBottom supportPlateBottom = builder.getItem(HPSTestRunTracker2014GeomDef.SupportPlateBottom.class);
+		HPSTestRunTracker2014GeomDef.SupportPlateTop supportPlateTop = builder.getItem(HPSTestRunTracker2014GeomDef.SupportPlateTop.class);
 		if(half == "bottom") {
 			volName = supportPlateBottom.getName();
 			width = HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_bottom_width;
@@ -609,7 +616,9 @@
 		
 	}
 
+	*/
 	
+	/*
 
 	
 	
@@ -632,10 +641,11 @@
 		final HPSTestRunTracker2014GeomDef.BaseGeom mother;
 		// reference is a intermediate geom object that are referenced but not it's direct mother
 		final HPSTestRunTracker2014GeomDef.BaseGeom ref;
-		HPSTestRunTracker2014GeomDef.SupportBottom supportBottom = builder.getSupportBottom();
-		HPSTestRunTracker2014GeomDef.SupportTop supportTop = builder.getSupportTop();
-		HPSTestRunTracker2014GeomDef.SupportPlateBottom supportPlateBottom = builder.getSupportPlateBottom();
-		HPSTestRunTracker2014GeomDef.SupportPlateTop supportPlateTop = builder.getSupportPlateTop();
+		HPSTestRunTracker2014GeomDef.SupportBottom supportBottom = builder.getItem(HPSTestRunTracker2014GeomDef.SupportBottom.class);
+		HPSTestRunTracker2014GeomDef.SupportTop supportTop = builder.getItem(HPSTestRunTracker2014GeomDef.SupportTop.class);
+
+		HPSTestRunTracker2014GeomDef.SupportPlateBottom supportPlateBottom = builder.getItem(HPSTestRunTracker2014GeomDef.SupportPlateBottom.class);
+		HPSTestRunTracker2014GeomDef.SupportPlateTop supportPlateTop = builder.getItem(HPSTestRunTracker2014GeomDef.SupportPlateTop.class);
 		if(half == "bottom") {
 			mother = supportBottom;
 			ref = supportPlateBottom;
@@ -653,7 +663,7 @@
 		}
 		
 		// add it to list of modules
-		List<HPSTestRunTracker2014GeomDef.TestRunModule> modules = builder.getModules();
+		List<HPSTestRunTracker2014GeomDef.BaseGeom> modules = builder.getModules();
 		modules.add(module);
 		
 		Box box = new Box(volName + "_box", module.getBoxDim().x(), module.getBoxDim().y(), module.getBoxDim().z());
@@ -706,20 +716,24 @@
     }
 	
 	
+	*/
 	
+	/*
 	
 	
 	
 	private HPSTestRunTracker2014GeomDef.BaseGeom findModule(String moduleName) {
-		List<HPSTestRunTracker2014GeomDef.TestRunModule> modules = builder.getModules();
-		for(HPSTestRunTracker2014GeomDef.TestRunModule m : modules) {
+		List<HPSTestRunTracker2014GeomDef.BaseGeom> modules = builder.getModules();
+		for(HPSTestRunTracker2014GeomDef.BaseGeom m : modules) {
 			if(m.getName().equals(moduleName)) return m;
 		}
 		return null;
 	}
 	
 	
+	*/
 	
+	/*
 	
 	
 	
@@ -841,7 +855,9 @@
 		
 	}
 	
+	*/
 	
+	/*
 	
 	private void makeColdBlock(String moduleName, Volume motherVolume, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
 		
@@ -1195,7 +1211,7 @@
 
 	}
 
-	
+	*/
 
 	private Hep3Vector transformToMotherCoord(Hep3Vector vec, VolWrapper motherWrap, String targetCoordName) {
 		if(_debug) print(String.format("vec %s motherWrap %s target %s", vec.toString(), motherWrap.name, targetCoordName));
@@ -1356,7 +1372,7 @@
 	 * @param lcdd_rot_angles
 	 * @return
 	 */
-	private Hep3Vector getRotationDisplacement(Hep3Vector origin_of_rotation,
+	protected static Hep3Vector getRotationDisplacement(Hep3Vector origin_of_rotation,
 			Hep3Vector point, Hep3Vector lcdd_rot_angles) {
 
 		// Find the vector from the center of rotation to the point
@@ -1366,6 +1382,7 @@
 		Hep3Vector s_prime = r.rotated(s);
 		// Find the displaced point
 		Hep3Vector point_rot = VecOp.add(origin_of_rotation, s_prime );
+		/*
 		if(_debug) {
 			print("--- getRotationDisplacement---");
 			print(String.format("point: %s", point.toString()));
@@ -1376,6 +1393,7 @@
 			print(String.format("point_rot:\n%s", point_rot.toString()));
 			print("--- getRotationDisplacement END---");
 		}
+		*/
 		return point_rot;
 	}
 

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
HPSTestRunTracker2014Builder.java 3211 -> 3212
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014Builder.java	2014-08-01 18:01:33 UTC (rev 3211)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014Builder.java	2014-08-02 15:59:58 UTC (rev 3212)
@@ -3,9 +3,25 @@
  */
 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.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeomDef.BaseGeom;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeomDef.TestRunColdBlock;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeomDef.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;
+
 /**
  * 
  * Class used to encapsulates building the basic geometry building blocks. 
@@ -20,16 +36,7 @@
 	
 	//Geometry members
 	protected List<HPSTestRunTracker2014GeomDef.BaseGeom> trackerItems = new ArrayList<HPSTestRunTracker2014GeomDef.BaseGeom>();
-	//TODO  I should delete these as they are part of the list..need to fix getters at the same time...
-	private  HPSTestRunTracker2014GeomDef.TrackingBase tracking; 
-	private  HPSTestRunTracker2014GeomDef.Base base; 
-	private  HPSTestRunTracker2014GeomDef.BasePlate basePlate; 
-	private  HPSTestRunTracker2014GeomDef.CSupport cSupport; 
-	private  HPSTestRunTracker2014GeomDef.SupportBottom supportBottom; 
-	private  HPSTestRunTracker2014GeomDef.SupportPlateBottom supportPlateBottom; 
-	private  HPSTestRunTracker2014GeomDef.SupportTop supportTop; 
-	private  HPSTestRunTracker2014GeomDef.SupportPlateTop supportPlateTop; 
-	private  List<HPSTestRunTracker2014GeomDef.TestRunModule> modules;
+	public  List<ModuleBundle> modules;
 	
 	
 	
@@ -43,71 +50,333 @@
 
 		// keep the order correct.
 		// each item has knowledge of its mother but not its daughters
-		tracking = new HPSTestRunTracker2014GeomDef.TrackingBase("trackingVolume",null);
+		HPSTestRunTracker2014GeomDef.TrackingBase tracking = new HPSTestRunTracker2014GeomDef.TrackingBase("trackingVolume",null);
 		trackerItems.add(tracking);
-		base = new HPSTestRunTracker2014GeomDef.Base("base",tracking);
+		HPSTestRunTracker2014GeomDef.Base base = new HPSTestRunTracker2014GeomDef.Base("base",tracking);
 		trackerItems.add(base);
-		basePlate = new HPSTestRunTracker2014GeomDef.BasePlate("baseplate",base, "Aluminum");
+		HPSTestRunTracker2014GeomDef.BasePlate basePlate = new HPSTestRunTracker2014GeomDef.BasePlate("baseplate",base, "Aluminum");
 		trackerItems.add(basePlate);
-		cSupport = new HPSTestRunTracker2014GeomDef.CSupport("c_support", base);
+		HPSTestRunTracker2014GeomDef.CSupport cSupport = new HPSTestRunTracker2014GeomDef.CSupport("c_support", base);
 		trackerItems.add(cSupport);
-		supportBottom = new HPSTestRunTracker2014GeomDef.SupportBottom("support_bottom", base, cSupport);
+		HPSTestRunTracker2014GeomDef.SupportBottom supportBottom = new HPSTestRunTracker2014GeomDef.SupportBottom("support_bottom", base, cSupport);
 		trackerItems.add(supportBottom);
-		supportPlateBottom = new HPSTestRunTracker2014GeomDef.SupportPlateBottom("support_plate_bottom", supportBottom, "Aluminum");
+		HPSTestRunTracker2014GeomDef.SupportPlateBottom supportPlateBottom = new HPSTestRunTracker2014GeomDef.SupportPlateBottom("support_plate_bottom", supportBottom, "Aluminum");
 		trackerItems.add(supportPlateBottom);
-		supportTop = new HPSTestRunTracker2014GeomDef.SupportTop("support_top", base, cSupport);
+		HPSTestRunTracker2014GeomDef.SupportTop supportTop = new HPSTestRunTracker2014GeomDef.SupportTop("support_top", base, cSupport);
 		trackerItems.add(supportTop);
-		supportPlateTop= new HPSTestRunTracker2014GeomDef.SupportPlateTop("support_plate_top", supportTop, "Aluminum");
+		HPSTestRunTracker2014GeomDef.SupportPlateTop supportPlateTop = new HPSTestRunTracker2014GeomDef.SupportPlateTop("support_plate_top", supportTop, "Aluminum");
 		trackerItems.add(supportPlateTop);
-		modules = new ArrayList<HPSTestRunTracker2014GeomDef.TestRunModule>();
+		modules = new ArrayList<ModuleBundle>();
 		
+		for(int l=1; l<=5;++l) {
+			makeModuleBundle(l,"bottom");
+			makeModuleBundle(l,"top");
+		}
 		
 		
+		
 		if(isDebug()) System.out.printf("%s: DONE constructing the geometry objects\n", this.getClass().getSimpleName());
 
 	}
 	
+
 	
-	protected <T> T getItem(Class<T> c) {
-		if(isDebug()) System.out.printf("%s: get Item %s\n", this.getClass().getSimpleName(),c.getName());
+	private void makeModuleBundle(int layer, String half) 
+    {
+
+		if(isDebug()) System.out.printf("%s: makeModule for layer %d %s \n", this.getClass().getSimpleName(), layer, half);
 		
-		for(HPSTestRunTracker2014GeomDef.BaseGeom item : trackerItems) {
-			if(isDebug()) System.out.printf("%s: item %s\n", getClass().getSimpleName(),item.getClass().getName());
-			if(c.isInstance(item)) {
-				return (T)item;
-			}
+		
+		// build the module name
+		String volName = "module_L"+ layer + (half=="bottom"?"b":"t");		
+		
+		boolean isL13 = ( layer >=1 && layer <=3 ) ? true : false;			
+		
+		// find the mother and reference geom
+		final HPSTestRunTracker2014GeomDef.BaseGeom mother;
+		// reference is a intermediate geom object that are referenced but not it's direct mother
+		final HPSTestRunTracker2014GeomDef.BaseGeom ref;
+		if(half == "bottom") {
+			mother = getItem(HPSTestRunTracker2014GeomDef.SupportBottom.class);
+			ref = getItem(HPSTestRunTracker2014GeomDef.SupportPlateBottom.class);
+		} else {
+			mother= getItem(HPSTestRunTracker2014GeomDef.SupportTop.class);
+			ref = getItem(HPSTestRunTracker2014GeomDef.SupportPlateTop.class);
 		}
-		throw new RuntimeException("Coulnd't find instance of " + c.getSimpleName() + " among the " + trackerItems.size() + " tracker items!");
+		
+		//Create the module
+		HPSTestRunTracker2014GeomDef.TestRunModule module;
+		if(isL13) {
+			module = new HPSTestRunTracker2014GeomDef.TestRunModuleL13(volName, mother, ref, layer, half);
+		} else {
+			module = new HPSTestRunTracker2014GeomDef.TestRunModuleL45(volName, mother, ref, layer, half);
+		}
+		
+		// create the bundle for this module
+		ModuleBundle bundle = new ModuleBundle(module);
+		addModuleBundle(bundle);
+		
+		makeHalfModule("axial", module);
+
+		/*
+
+		makeColdBlock(module);
+		
+		makeHalfModule("stereo", module);
+		 */
+		
+    }
+	
+	
+	
+private void makeColdBlock(HPSTestRunTracker2014GeomDef.TestRunModule mother) { 
+	
+
+		String moduleName = mother.getName();
+		
+		if(isDebug()) System.out.printf("%s: makeColdBlock for %s \n", this.getClass().getSimpleName(), moduleName);
+		
+		
+		String volName = moduleName + "_coldblock";
+
+		// find layer
+		int layer = getLayerFromVolumeName(moduleName);
+		
+		// Build the half-module
+		HPSTestRunTracker2014GeomDef.TestRunColdBlock coldBlock;
+		
+		if(layer >= 1 && layer <=3) {
+			coldBlock = new HPSTestRunTracker2014GeomDef.TestRunColdBlockL13(volName, mother, layer);
+		} else if(layer >= 4 && layer <=5) {
+			coldBlock = new HPSTestRunTracker2014GeomDef.TestRunColdBlockL45(volName, mother, layer);
+		} else {
+			throw new RuntimeException("wrong layer for " + volName);
+		}
+		
+		ModuleBundle bundle = getModuleBundle(mother);
+		bundle.coldBlock = coldBlock;
 	}
 	
-	//protected  HPSTestRunTracker2014GeomDef.BaseGeom getTracking() {
-	//	HPSTestRunTracker2014GeomDef.BaseGeom t =  getItem(HPSTestRunTracker2014GeomDef.TrackingBase.class);
-	//	return t;
-	//}
 	
-	//TODO replace all calls to the below with the  generic getItem() function above
-	protected  HPSTestRunTracker2014GeomDef.Base getBase() {
-		return base;
+	
+	private void makeHalfModule(String side, HPSTestRunTracker2014GeomDef.TestRunModule mother) {
+		
+		String moduleName = mother.getName();
+		
+		if(isDebug()) System.out.printf("%s: makeHalfModule for %s %s \n", this.getClass().getSimpleName(), moduleName, side);
+		
+		String volName = moduleName + "_halfmodule_" + side;
+		
+		// top or bottom?
+		String half = mother.getHalf();
+		
+		// find layer
+		int layer = mother.getLayer();
+		
+		ModuleBundle bundle  = getModuleBundle(mother);
+		
+		// Build the half-module
+		HPSTestRunTracker2014GeomDef.TestRunHalfModule halfModule;
+		if(side == "axial") {
+			halfModule = new HPSTestRunTracker2014GeomDef.TestRunHalfModuleAxial(volName, mother, layer, half);
+			bundle.halfModuleAxial = halfModule;
+		} else if(side == "stereo") {
+			halfModule = new HPSTestRunTracker2014GeomDef.TestRunHalfModuleStereo(volName, mother, layer, half);
+			bundle.halfModuleStereo = halfModule;
+		} else {
+			throw new IllegalArgumentException("not a valid half-module side " + side);
+		}
+		
+		
+		
+		// create the half module components 
+		
+		makeHalfModuleComponentSensor(halfModule);
+		
+		makeHalfModuleComponentKapton(halfModule);
+		
+		makeHalfModuleComponentCF(halfModule);
+		
+		makeHalfModuleComponentHybrid(halfModule);
+			
+		
+		
+		
 	}
-	protected  HPSTestRunTracker2014GeomDef.BasePlate getBasePlate() {
-		return basePlate;
+	
+	
+	
+	private void makeHalfModuleComponentHybrid(HPSTestRunTracker2014GeomDef.TestRunHalfModule mother) {
+		
+		if(isDebug()) System.out.printf("%s: makeHalfModuleComponentHybrid for %s \n", this.getClass().getSimpleName(), mother.getName());
+
+		String volName = mother.getName() + "_hybrid";
+
+		// Build the half-module
+		HPSTestRunTracker2014GeomDef.Hybrid hybrid = new HPSTestRunTracker2014GeomDef.Hybrid(volName,mother);
+		hybrid.setMaterial("G10");
+
+		getModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother()).hybrid = hybrid;
+		
 	}
-	protected  HPSTestRunTracker2014GeomDef.CSupport getcSupport() {
-		return cSupport;
+
+	
+	
+private void makeHalfModuleComponentCF(HPSTestRunTracker2014GeomDef.TestRunHalfModule mother) {
+	
+	if(isDebug()) System.out.printf("%s: makeHalfModuleComponentCF for %s \n", this.getClass().getSimpleName(), mother.getName());
+	
+	
+		String volName = mother.getName() + "_cf";
+
+		// Build the half-module
+		HPSTestRunTracker2014GeomDef.CarbonFiber cf = new HPSTestRunTracker2014GeomDef.CarbonFiber(volName,mother);
+		cf.setMaterial("CarbonFiber");
+		
+		getModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother()).carbonFiber = cf;
+
+}
+
+
+	
+	
+private void makeHalfModuleComponentKapton(HPSTestRunTracker2014GeomDef.TestRunHalfModule mother) {
+	
+	if(isDebug()) System.out.printf("%s: makeHalfModuleComponentKapton for %s \n", this.getClass().getSimpleName(), mother.getName());
+		
+	String volName = mother.getName() + "_lamination";
+
+	// Build the half-module
+	HPSTestRunTracker2014GeomDef.HalfModuleLamination kapton = new HPSTestRunTracker2014GeomDef.HalfModuleLamination(volName,mother);
+	kapton.setMaterial("Kapton");
+			
+	getModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother()).lamination = kapton;
+		
+}
+
+
+private void makeHalfModuleComponentSensor(HPSTestRunTracker2014GeomDef.TestRunHalfModule mother) {
+
+	if(isDebug()) System.out.printf("%s: makeHalfModuleComponentSensor for %s \n", this.getClass().getSimpleName(), mother.getName());
+
+	String volName = mother.getName() + "_sensor";
+
+	// sensor if
+	int sensor_number = 0;
+
+	//	
+	HPSTestRunTracker2014GeomDef.Sensor sensor = new HPSTestRunTracker2014GeomDef.Sensor(volName, mother, sensor_number);
+	sensor.setMaterial("Silicon");
+	getModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother()).sensor = sensor;
+
+	makeHalfModuleComponentActiveSensor(sensor);
+
+
+}
+
+	
+	private void makeHalfModuleComponentActiveSensor(HPSTestRunTracker2014GeomDef.Sensor mother) {
+		
+		if(isDebug()) System.out.printf("%s: makeHalfModuleComponentActiveSensor for %s \n", this.getClass().getSimpleName(), mother.getName());
+		
+		String volName = mother.getName() + "_active";
+
+		// Build the half-module
+		HPSTestRunTracker2014GeomDef.ActiveSensor active_sensor = new HPSTestRunTracker2014GeomDef.ActiveSensor(volName, mother);
+		active_sensor.setMaterial("Silicon");
+		
+//		PhysVol physVolume = new PhysVol(volume, motherVolume, pos, rot);
+//
+//		volume.setSensitiveDetector(sens);
+//		physVolume.addPhysVolID("sensor", sensor_number);
+//		physVolume.addPhysVolID("system", 0);
+//		physVolume.addPhysVolID("barrel", 0);
+//		physVolume.addPhysVolID("layer", layer);
+//		physVolume.addPhysVolID("module", layer);    
+//			
+			
+		getModuleBundle((HPSTestRunTracker2014GeomDef.TestRunModule) mother.getMother().getMother()).activeSensor = active_sensor;
+		
 	}
-	protected  HPSTestRunTracker2014GeomDef.SupportBottom getSupportBottom() {
-		return supportBottom;
+
+	
+	
+	
+	private static String getHalfFromName(String name) {
+		String half = "";
+		if(name.contains("bottom")) {
+			half = "bottom";
+		}
+		if(name.contains("top")) {
+			// check that both sides are not found
+			if(half.equals("bottom")) {
+				throw new RuntimeException("found both halfs from name  " + name);
+			} else {
+				half = "top";
+			}
+		}
+		// check for other signatures
+		if( half.isEmpty()) {
+			// 6 layers is arbitrary here
+			for(int layer=1;layer<=6;++layer) {
+				if(name.contains(String.format("L%db", layer))) {
+					half = "bottom";
+					break;
+				} 
+				if(name.contains(String.format("L%dt", layer))) {
+					if(half.equals("bottom")) {
+						throw new RuntimeException("found both halfs from name  " + name);
+					}
+					half = "top";
+					break;
+				}
+			}
+		}		
+		if( half.isEmpty()) {
+			System.out.println("found no half from " + name);
+			throw new RuntimeException("found no half from " + name);
+		} else {
+			return half;
+	
+		}
 	}
-	protected  HPSTestRunTracker2014GeomDef.SupportPlateBottom getSupportPlateBottom() {
-		return supportPlateBottom;
+
+	
+	private static int getLayerFromVolumeName(String name) {
+		int layer = -1;
+		for(int i=1; i<= 5; ++i) {
+			if(name.contains(String.format("_L%d", i))) {
+				layer = i;
+			}
+		}
+		if( layer == -1) {
+			System.out.println("cannot find layer from " + name);
+			System.exit(1);
+		}
+		return layer;
 	}
-	protected  HPSTestRunTracker2014GeomDef.SupportTop getSupportTop() {
-		return supportTop;
+
+	
+	
+	
+	/**
+	 * Find geometry object by type.
+	 * @param c - class type to be found
+	 * @return the found type.
+	 */
+	protected <T> T getItem(Class<T> c) {
+		///if(isDebug()) System.out.printf("%s: get Item %s\n", this.getClass().getSimpleName(),c.getName());
+		
+		for(HPSTestRunTracker2014GeomDef.BaseGeom item : trackerItems) {
+			//if(isDebug()) System.out.printf("%s: item %s\n", getClass().getSimpleName(),item.getClass().getName());
+			if(c.isInstance(item)) {
+				return (T)item;
+			}
+		}
+		throw new RuntimeException("Coulnd't find instance of " + c.getSimpleName() + " among the " + trackerItems.size() + " tracker items!");
 	}
-	protected  HPSTestRunTracker2014GeomDef.SupportPlateTop getSupportPlateTop() {
-		return supportPlateTop;
-	}
-	protected  List<HPSTestRunTracker2014GeomDef.TestRunModule> getModules() {
+	
+	protected  List<ModuleBundle> getModules() {
 		return modules;
 	}
 	protected boolean isDebug() {
@@ -116,4 +385,82 @@
 	protected void setDebug(boolean debug) {
 		this.debug = debug;
 	}
+	
+
+	/**
+	 * Bundle geometry objects in a module. Perhaps I can add daughter to geometry definition to avoid this?
+	 * 
+	 * @author Per Hansson Adrian <[log in to unmask]>
+	 *
+	 */
+	protected static class ModuleBundle {
+		protected HPSTestRunTracker2014GeomDef.TestRunModule module = null;
+		protected HPSTestRunTracker2014GeomDef.TestRunHalfModule halfModuleAxial = null;
+		protected HPSTestRunTracker2014GeomDef.TestRunHalfModule halfModuleStereo = null;
+		protected HPSTestRunTracker2014GeomDef.Sensor sensor = null;
+		protected HPSTestRunTracker2014GeomDef.ActiveSensor activeSensor = null;
+		protected HPSTestRunTracker2014GeomDef.HalfModuleLamination lamination = null;
+		protected HPSTestRunTracker2014GeomDef.CarbonFiber carbonFiber = null;
+		protected HPSTestRunTracker2014GeomDef.Hybrid hybrid = null;
+		protected HPSTestRunTracker2014GeomDef.TestRunColdBlock coldBlock;
+		ModuleBundle(HPSTestRunTracker2014GeomDef.TestRunModule m) {
+			module = m;
+		}		
+		int getLayer() {
+			if(module==null) throw new RuntimeException("Need to add module to bundle first!");
+			return getLayerFromVolumeName(module.getName());
+		}
+		String getHalf() {
+			if(module==null) throw new RuntimeException("Need to add module to bundle first!");
+			return getHalfFromName(module.getName()); 
+		}
+		/**
+		 * Find mother to this module.
+		 * @return mother 
+		 */
+		public BaseGeom getMother() {
+			if(module==null) throw new RuntimeException("Need to add module to bundle first!");
+			return module.getMother();
+		}
+	}
+	
+	/**
+	 * Find module among the existing bundles.
+	 * @param layer - layer id
+	 * @param half - top or bottom half
+	 * @return module or null if not found
+	 */
+	protected ModuleBundle getModuleBundle(int layer, String half) {
+		for(ModuleBundle m : modules) {
+			if(m.getLayer()==layer && m.getHalf().equals(half)) {
+				return m;
+			}
+		}
+		return null;
+	}
+	
+	
+	/**
+	 * Find module among the existing bundles.
+	 * @param module - to find
+	 * @return bundle
+	 */
+	protected ModuleBundle getModuleBundle(HPSTestRunTracker2014GeomDef.TestRunModule module) {
+		return getModuleBundle(module.getLayer(), module.getHalf());
+	}
+	
+	/**
+	 * Add module to list.
+	 * @param bundle - module to add.
+	 */
+	private void addModuleBundle(ModuleBundle bundle) {
+		ModuleBundle b = getModuleBundle(bundle.getLayer(), bundle.getHalf());
+		if(b==null) {
+			modules.add(bundle);
+		} else {
+			throw new RuntimeException("There is already a module bundle with layer " + bundle.getLayer() + " and half " + bundle.getHalf());
+		}
+	}
+	
+	
 }

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
HPSTestRunTracker2014GeomDef.java 3211 -> 3212
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014GeomDef.java	2014-08-01 18:01:33 UTC (rev 3211)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014GeomDef.java	2014-08-02 15:59:58 UTC (rev 3212)
@@ -53,6 +53,9 @@
 			protected  Hep3Vector flatPos;
 			private Hep3Vector center;
 			private Hep3Vector boxDim;
+			//store explicit rotations - if exist should be used instead of those extracted from coord
+			// TODO This is a workaround as I should really rotate the coord system to make things consistent. Figure this out later. 
+			protected Hep3Vector lcdd_rot_angles = null;
 			
 			public BaseGeom(String name, BaseGeom m) {
 				setName(name);
@@ -796,6 +799,7 @@
 			protected static final double half_module_length = HPSTestRunTracker2014GeomDef.TestRunHalfModule.getCFLength();
 			protected static final double half_module_width = 6.83 + HPSTestRunTracker2014GeomDef.Sensor.getSensorWidth();
 			
+			protected double stereo_angle = 0.0;
 			
 			public TestRunHalfModule(String name, BaseGeom mother, int layer, String half) {
 				super(name,mother, layer, half);
@@ -817,6 +821,12 @@
 			protected void setBoxDim() {
 				setBoxDim(getLength(), getThickness(), getWidth());
 			}
+			protected double getStereoAngle() {
+				return stereo_angle;
+			}
+			protected void setStereoAngle(double stereo_angle) {
+				this.stereo_angle = stereo_angle;
+			}
 			public static double getCFThickness() {
 				return CarbonFiber.cf_thickness;
 			}
@@ -882,6 +892,7 @@
 			public TestRunHalfModuleStereo(String name, BaseGeom mother, int layer, String half) {
 				super(name, mother, layer, half);
 				init();
+				setExplicitRotation();
 			}
 			
 			protected void setPos() {
@@ -905,6 +916,22 @@
 				veePos = new BasicHep3Vector(vee_pos_halfmod_axial_local_x, vee_pos_halfmod_axial_local_y,vee_pos_halfmod_axial_local_z);
 				flatPos = new BasicHep3Vector(flat_pos_halfmod_axial_local_x, flat_pos_halfmod_axial_local_y,flat_pos_halfmod_axial_local_z);
 			}
+			
+			/**
+			 * Set rotations explicitly. 
+			 * TODO Should be included in the coord system? Workaround!?
+			 */
+			protected void setExplicitRotation() {
+				if(getLayer()<4) {
+					stereo_angle = -0.1;
+				} else {
+					stereo_angle = -0.05;
+				}
+				org.apache.commons.math3.geometry.euclidean.threed.Rotation rot_stereo = new org.apache.commons.math3.geometry.euclidean.threed.Rotation(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ, Math.PI, stereo_angle,0);
+				double res[] = rot_stereo.getAngles(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ);
+				lcdd_rot_angles = new BasicHep3Vector(res);
+			}
+			
 		}
 		
 		public static abstract class TestRunColdBlock extends BaseGeom {		

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
HPSTestRunTracker2014LCDDBuilder.java 3211 -> 3212
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014LCDDBuilder.java	2014-08-01 18:01:33 UTC (rev 3211)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014LCDDBuilder.java	2014-08-02 15:59:58 UTC (rev 3212)
@@ -29,15 +29,8 @@
 	
 	
 	protected LCDD lcdd;
-	protected LCDDBaseGeom trackingLCDD;
 	protected LCDDBaseGeom baseLCDD;
-	protected LCDDBaseGeom basePlateLCDD;
-	protected LCDDBaseGeom cSupportLCDD;
-	protected LCDDBaseGeom supportBottomLCDD;
-	protected LCDDBaseGeom supportPlateBottomLCDD;
-	protected LCDDBaseGeom supportTopLCDD;
-	protected LCDDBaseGeom supportPlateTopLCDD;
-	protected List<LCDDBaseGeom> modulesLCDD;
+	protected List<LCDDBaseGeom> lcdd_objects;
 	
 	/**
 	 *  Default constructor
@@ -46,65 +39,136 @@
 		super(debugFlag);
 	}
 	
+	private void add(LCDDBaseGeom geom) {
+		lcdd_objects.add(geom);
+	}
 	
+	
+	
 	protected void build(Volume worldVolume) {
 		// go through the list of volumes to build
+		// TODO this is manual now since I don't have a way of knowing what is a ghost volume at this point
 		if(isDebug()) System.out.printf("%s: build the LCDD geometry objects\n", getClass().getSimpleName());
-		trackingLCDD = new GhostBaseGeom(getItem(HPSTestRunTracker2014GeomDef.TrackingBase.class), worldVolume);
+		
+		// initialize the list to store a reference to each object
+		lcdd_objects = new ArrayList<LCDDBaseGeom>();
+		LCDDBaseGeom trackingLCDD = new GhostBaseGeom(getItem(HPSTestRunTracker2014GeomDef.TrackingBase.class), worldVolume);
+		add(trackingLCDD);
 		baseLCDD = new LCDDBaseGeom(getItem(HPSTestRunTracker2014GeomDef.Base.class), lcdd, trackingLCDD);
-		basePlateLCDD = new LCDDBaseGeom(getItem(HPSTestRunTracker2014GeomDef.BasePlate.class), lcdd, baseLCDD);
-		cSupportLCDD = new GhostBaseGeom(getItem(HPSTestRunTracker2014GeomDef.CSupport.class), baseLCDD);
-		supportBottomLCDD = new LCDDBaseGeom(getItem(HPSTestRunTracker2014GeomDef.SupportBottom.class), lcdd, baseLCDD);
-		supportPlateBottomLCDD = new LCDDBaseGeom(getItem(HPSTestRunTracker2014GeomDef.SupportPlateBottom.class), lcdd, supportBottomLCDD);
-		supportTopLCDD = new LCDDBaseGeom(getItem(HPSTestRunTracker2014GeomDef.SupportTop.class), lcdd, baseLCDD);
-		supportPlateTopLCDD = new LCDDBaseGeom(getItem(HPSTestRunTracker2014GeomDef.SupportPlateTop.class), lcdd, supportTopLCDD);
+		add(baseLCDD);
+		LCDDBaseGeom basePlateLCDD = new LCDDBaseGeom(getItem(HPSTestRunTracker2014GeomDef.BasePlate.class), lcdd, baseLCDD);
+		add(basePlateLCDD);
+		LCDDBaseGeom cSupportLCDD = new GhostBaseGeom(getItem(HPSTestRunTracker2014GeomDef.CSupport.class), baseLCDD);
+		add(cSupportLCDD);
+		LCDDBaseGeom supportBottomLCDD = new LCDDBaseGeom(getItem(HPSTestRunTracker2014GeomDef.SupportBottom.class), lcdd, baseLCDD);
+		add(supportBottomLCDD);
+		LCDDBaseGeom supportPlateBottomLCDD = new LCDDBaseGeom(getItem(HPSTestRunTracker2014GeomDef.SupportPlateBottom.class), lcdd, supportBottomLCDD);
+		add(supportPlateBottomLCDD);
+		LCDDBaseGeom supportTopLCDD = new LCDDBaseGeom(getItem(HPSTestRunTracker2014GeomDef.SupportTop.class), lcdd, baseLCDD);
+		add(supportTopLCDD);
+		LCDDBaseGeom supportPlateTopLCDD = new LCDDBaseGeom(getItem(HPSTestRunTracker2014GeomDef.SupportPlateTop.class), lcdd, supportTopLCDD);
+		add(supportPlateTopLCDD);
+		
+		// build modules here based on the module bundle class	
+		
+		if(isDebug()) System.out.printf("%s: build modules\n", getClass().getSimpleName());
+		for(HPSTestRunTracker2014Builder.ModuleBundle m : modules) {
+			if(isDebug()) System.out.printf("%s: module layer %d half %s\n", getClass().getSimpleName(),m.getLayer(),m.getHalf());
+			String name_mother = m.getMother().getName();
+			LCDDBaseGeom mother = null;
+			//find the mother among the LCDD objects using name...
+			for(LCDDBaseGeom g : lcdd_objects) {
+				if(g.getName().equals(name_mother)) {
+					mother = g;
+					break;
+				}
+			}
+			if(mother==null) throw new RuntimeException("Cound't find mother to module layer " + m.getLayer() + " half "+ m.getHalf());
+
+			if(isDebug()) System.out.printf("%s: found mother %s for module layer %d half %s\n", getClass().getSimpleName(),mother.getName(),m.getLayer(),m.getHalf());
+			
+			// add to LCDD
+			addModule(m, mother);
+			
+		}
+		
+		
+		
 		if(isDebug()) System.out.printf("%s: DONE building the LCDD geometry objects\n", getClass().getSimpleName());
 
-		modulesLCDD = new ArrayList<LCDDBaseGeom>();
+		setVis();
 		
-		//set lcdd vis
-		basePlateLCDD.setVisName("BasePlateVis");
-		supportBottomLCDD.setVisName("SupportVolumeVis");
-		supportTopLCDD.setVisName("SupportVolumeVis");
-		supportPlateBottomLCDD.setVisName("SupportPlateVis");
-		supportBottomLCDD.setVisName("SupportVolumeVis");
 		
 	}
 	
+	/**
+	 * Rules for adding the LCDD module geometry.
+	 * @param bundle - module to be added
+	 * @param mother - mother LCDD geometry object
+	 */
+	private void addModule(ModuleBundle bundle, LCDDBaseGeom mother) {
+		// This could perhaps be fixed if there is a relation in geometry definition
+		// create the module
+		LCDDBaseGeom lcddM = new LCDDBaseGeom(bundle.module, lcdd, mother);
+		add(lcddM);
+		// create the half-module
+		LCDDBaseGeom lcddHM = new LCDDBaseGeom(bundle.halfModuleAxial, lcdd, lcddM);
+		add(lcddHM);
+		// create the sensor
+		LCDDBaseGeom lcddS = new LCDDBaseGeom(bundle.sensor, lcdd, lcddHM);
+		add(lcddS);
+		// create the active sensor
+		LCDDBaseGeom lcddAS = new LCDDBaseGeom(bundle.activeSensor, lcdd, lcddS);
+		add(lcddAS);
+		// create the lamination
+		LCDDBaseGeom lcddL = new LCDDBaseGeom(bundle.lamination, lcdd, lcddHM);
+		add(lcddL);
+		// create the carbon fiber frame
+		LCDDBaseGeom lcddCF = new LCDDBaseGeom(bundle.carbonFiber, lcdd, lcddHM);
+		add(lcddCF);
+		// create the hybrid frame
+		LCDDBaseGeom lcddH = new LCDDBaseGeom(bundle.hybrid, lcdd, lcddHM);
+		add(lcddH);
+		
+	}
+	
+	private void setVis() {
+
+		if(isDebug()) System.out.printf("%s: Set LCDD vis \n", getClass().getSimpleName());
+
+		//set lcdd vis
+		for(LCDDBaseGeom g : lcdd_objects) {
+			if(isDebug()) System.out.printf("%s: Set LCDD vis for %s \n", getClass().getSimpleName(), g.getName());
+			
+			if(g.getName().contains("baseplate")) g.setVisName("BasePlateVis");
+			//else if(g.getName().contains("base")) g.setVisName("BaseVis");
+			else if(g.getName().contains("support_bottom") || g.getName().contains("support_top")) g.setVisName("SupportVolumeVis");
+			else if(g.getName().contains("support_plate_bottom") || g.getName().contains("support_plate_top")) g.setVisName("SupportPlateVis");
+			else if(g.getName().contains("halfmodule")) g.setVisName("HalfModuleVis");
+			else if(g.getName().contains("module")) g.setVisName("ModuleVis");
+			else if(g.getName().contains("cold")) g.setVisName("ColdBlockVis");
+			else if(g.getName().contains("kapton")) g.setVisName("KaptonVis");
+			else if(g.getName().contains("sensor")) g.setVisName("SensorVis");
+			else if(g.getName().contains("carbon")) g.setVisName("CarbonFiberVis");
+			else if(g.getName().contains("hybrid")) g.setVisName("HybridVis");
+			else {
+				if(isDebug()) System.out.printf("%s: No LCDD vis for %s \n", getClass().getSimpleName(), g.getName());
+			}
+		}
+
+		if(isDebug()) System.out.printf("%s: DONE Set LCDD vis \n", getClass().getSimpleName());
+
+	}
+	
 	protected void setLCDD(LCDD lcdd) {
 		this.lcdd = lcdd;
 	}
 	protected LCDD getLCDD() {
 		return lcdd;
 	}
-
-	protected LCDDBaseGeom getTrackingLCDD() {
-		return trackingLCDD;
-	}
 	protected  LCDDBaseGeom getBaseLCDD() {
 		return baseLCDD;
 	}
-	protected  LCDDBaseGeom getBasePlateLCDD() {
-		return basePlateLCDD;
-	}
-	protected  LCDDBaseGeom getcSupportLCDD() {
-		return cSupportLCDD;
-	}
-	protected  LCDDBaseGeom getSupportBottomLCDD() {
-		return supportBottomLCDD;
-	}
-	protected  LCDDBaseGeom getSupportPlateBottomLCDD() {
-		return supportPlateBottomLCDD;
-	}
-	protected  LCDDBaseGeom getSupportTopLCDD() {
-		return supportTopLCDD;
-	}
-	protected  LCDDBaseGeom getSupportPlateTopLCDD() {
-		return supportPlateTopLCDD;
-	}
-	protected  List<LCDDBaseGeom> getModulesLCDD() {
-		return modulesLCDD;
-	}
 	
 
 	/**
@@ -167,10 +231,7 @@
 		
 	}
 
-
-
 	
-	
 	/**
 	 *  Base geometry class for holding LCDD geometry object definitions.
 	 *   
@@ -238,10 +299,27 @@
 			Hep3Vector box_center_base = base.getCoord().getTransformation().transformed(box_center_base_local);
 			// find the position of the center in the mother coord
 			Hep3Vector box_center = VecOp.sub(box_center_base, base.getMother().getCenter());
+			//Find LCDD Euler rotation angles from coordinate system unit vectors
+			Hep3Vector lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(base.getCoord().v(), base.getCoord().w(), new BasicHep3Vector(0,1,0),new BasicHep3Vector(0,0,1));
+			// Check if there are explicit rotations built into the object itself which overrides
+			// TODO this should be included in the coordinate system somehow?
+			if (base.lcdd_rot_angles!=null) {
+				// there are explicit rotations I need to apply.
+				// Find the displacement of the box center due to rotation about different origin
+				Hep3Vector box_center_base_rot = HPSTestRunTracker2014.getRotationDisplacement(base.getCoord().origin(), box_center_base, base.lcdd_rot_angles);
+				if(isDebug()) {
+					System.out.printf("%s: lcdd_rot_angles 		  %s\n", this.getClass().getSimpleName(),lcdd_rot_angles);
+					System.out.printf("%s: lcdd_rot_angles_2	  %s\n", this.getClass().getSimpleName(),base.lcdd_rot_angles);
+					System.out.printf("%s: box_center_base        %s\n", this.getClass().getSimpleName(), box_center_base.toString());
+					System.out.printf("%s: box_center_base_rot    %s\n", this.getClass().getSimpleName(), box_center_base_rot.toString());
+				}
+				// update the rotation angles
+				lcdd_rot_angles = base.lcdd_rot_angles;
+				// update the position of the center in the mother coord
+				box_center = VecOp.sub(box_center_base_rot, base.getMother().getCenter());
+			}
 			// Create the LCDD position
 			setPos(new Position(getName() + "_position",box_center.x(), box_center.y(), box_center.z()));
-			//Find LCDD Euler rotation angles from coordinate system unit vectors
-			Hep3Vector lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(base.getCoord().v(), base.getCoord().w(), new BasicHep3Vector(0,1,0),new BasicHep3Vector(0,0,1));
 			setRot(new Rotation(getName() + "_rotation",lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z()));
 			if(isDebug()) {
 				System.out.printf("%s: box_center_base_local  %s\n", this.getClass().getSimpleName(), box_center_base_local.toString());
@@ -310,5 +388,6 @@
 	}
 
 	
+	
 
 }
\ No newline at end of file

projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector
HPSTestRunTracker2014.xml 3211 -> 3212
--- projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector/HPSTestRunTracker2014.xml	2014-08-01 18:01:33 UTC (rev 3211)
+++ projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector/HPSTestRunTracker2014.xml	2014-08-02 15:59:58 UTC (rev 3212)
@@ -49,10 +49,10 @@
   <display>
 	
     <vis name="SensorVis" alpha="1.0" r="1.0" g="0.0" b="0.0" drawingStyle="wireframe" lineStyle="unbroken" showDaughters="true" visible="true"/>
-    <vis name="ActiveSensorVis" alpha="1.0" r="1.0" g="0.0" b="0.0" drawingStyle="wireframe" lineStyle="unbroken" showDaughters="true" visible="true"/>
-    <vis name="CarbonFiberVis" alpha="1.0" r="0.88" g="0.88" b="0.88" drawingStyle="wireframe" lineStyle="unbroken" showDaughters="true" visible="true"/>
-    <vis name="KaptonVis" alpha="1.0" r="0.91" g="0.77" b="0.06" drawingStyle="wireframe" lineStyle="unbroken" showDaughters="true" visible="true"/>
-    <vis name="HybridVis" alpha="1.0" r="0.0" g="1.0" b="0" drawingStyle="wireframe" lineStyle="unbroken" showDaughters="true" visible="true"/>
+    <vis name="ActiveSensorVis" alpha="1.0" r="1.0" g="0.0" b="0.0" drawingStyle="solid" lineStyle="unbroken" showDaughters="true" visible="true"/>
+    <vis name="CarbonFiberVis" alpha="1.0" r="0.88" g="0.88" b="0.88" drawingStyle="solid" lineStyle="unbroken" showDaughters="true" visible="true"/>
+    <vis name="KaptonVis" alpha="1.0" r="0.91" g="0.77" b="0.06" drawingStyle="solid" lineStyle="unbroken" showDaughters="true" visible="true"/>
+    <vis name="HybridVis" alpha="1.0" r="0.0" g="1.0" b="0" drawingStyle="solid" lineStyle="unbroken" showDaughters="true" visible="true"/>
     <vis name="HalfModuleVis" alpha="1.0" r="1.0" g="1.0" b="1.0" drawingStyle="wireframe" lineStyle="dashed" showDaughters="true" visible="true"/>
     <vis name="ColdBlockVis" alpha="1.0" r="0.75" g="0.73" b="0.75" drawingStyle="solid" lineStyle="dashed" showDaughters="true" visible="true"/>
     <vis name="ModuleVis" alpha="1.0" r="1.0" g="1.0" b="1.0" drawingStyle="wireframe" lineStyle="dotted" showDaughters="true" visible="true"/>
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