Commit in projects/lcsim/trunk/detector-framework/src on MAIN
main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014Converter.java+2-23311 -> 3312
                                              /HPSTestRunTracker2014JavaBuilder.java+51-383311 -> 3312
main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java+2-23311 -> 3312
                                                   /HPSTestRunTracker2014Builder.java+46-213311 -> 3312
                                                   /HPSTestRunTracker2014GeometryDefinition.java+110-643311 -> 3312
                                                   /HPSTestRunTracker2014LCDDBuilder.java+71-543311 -> 3312
test/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014LCDDTest.java+35added 3312
+317-181
1 added + 6 modified, total 7 files
Added test for LCDD converter. Refactoring and adding comments. 

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact
HPSTestRunTracker2014Converter.java 3311 -> 3312
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014Converter.java	2014-09-04 23:17:17 UTC (rev 3311)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014Converter.java	2014-09-05 22:37:43 UTC (rev 3312)
@@ -36,7 +36,7 @@
  */
 public class HPSTestRunTracker2014Converter extends AbstractSubdetectorConverter {
 
-	private boolean _debug = true; 
+	private boolean _debug = false; 
 	private IMaterial trackingMaterial = null;
 	private static HPSTestRunTracker2014JavaBuilder builder;
 	
@@ -168,7 +168,7 @@
 					//builder.addLayerDetectorElement(layerDe);
 					builder.addLayerDetectorElement(layerDe);
 				} else {
-					System.out.printf("%s: layerDE exists\n", getClass().getSimpleName());
+					if(_debug) System.out.printf("%s: layerDE exists\n", getClass().getSimpleName());
 				}
 				
 				if(_debug) System.out.printf("%s: layerDE name %s  \n", getClass().getSimpleName(),layerDe.getName());

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact
HPSTestRunTracker2014JavaBuilder.java 3311 -> 3312
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014JavaBuilder.java	2014-09-04 23:17:17 UTC (rev 3311)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014JavaBuilder.java	2014-09-05 22:37:43 UTC (rev 3312)
@@ -10,26 +10,19 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.swing.text.html.HTMLDocument.HTMLReader.IsindexAction;
-
-import org.lcsim.detector.DetectorElement;
-import org.lcsim.detector.DetectorElementStore;
 import org.lcsim.detector.DetectorIdentifierHelper;
 import org.lcsim.detector.IDetectorElement;
 import org.lcsim.detector.ILogicalVolume;
 import org.lcsim.detector.IPhysicalVolume;
 import org.lcsim.detector.IRotation3D;
-import org.lcsim.detector.ITransform3D;
 import org.lcsim.detector.ITranslation3D;
 import org.lcsim.detector.LogicalVolume;
 import org.lcsim.detector.PhysicalVolume;
-import org.lcsim.detector.Rotation3D;
 import org.lcsim.detector.RotationGeant;
 import org.lcsim.detector.Transform3D;
 import org.lcsim.detector.Translation3D;
 import org.lcsim.detector.identifier.ExpandedIdentifier;
 import org.lcsim.detector.identifier.IExpandedIdentifier;
-import org.lcsim.detector.identifier.IIdentifier;
 import org.lcsim.detector.identifier.IIdentifierDictionary;
 import org.lcsim.detector.material.IMaterial;
 import org.lcsim.detector.material.MaterialStore;
@@ -38,12 +31,9 @@
 import org.lcsim.geometry.compact.Subdetector;
 import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014;
 import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014Builder;
-import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014Builder.HalfModuleBundle;
-import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014Builder.ModuleBundle;
 import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.Base;
 import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.BaseGeometry;
 import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.BasePlate;
-import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.CSupport;
 import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.SupportBottom;
 import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom;
 import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.SupportPlateTop;
@@ -87,7 +77,7 @@
 	
 	
 	/**
-	 * Build the JAVA geometry objects.
+	 * Build the JAVA geometry objects from the geometry definition.
 	 * @param trackingVolume - the reference volume.
 	 */
 	protected void build(ILogicalVolume trackingVolume) {
@@ -118,7 +108,7 @@
 
 		// build modules	
 		
-		if(isDebug()) System.out.printf("%s: build modules\n", getClass().getSimpleName());
+		if(isDebug()) System.out.printf("%s: build JAVA modules\n", getClass().getSimpleName());
 
 		// Loop over all modules created
 		for(ModuleBundle m : modules) {
@@ -127,7 +117,7 @@
 			//if(m.getLayer()!=1) continue;
 			
 			if(isDebug()) { 
-				System.out.printf("%s: module layer %d half %s\n", getClass().getSimpleName(),m.getLayer(),m.getHalf());
+				System.out.printf("%s: build module %s (layer %d half %s)\n", getClass().getSimpleName(),m.module.getName(),m.getLayer(),m.getHalf());
 				m.print();
 			}
 
@@ -141,19 +131,31 @@
 				}
 			}
 			// Check that it had a mother
-			if(mother==null) throw new RuntimeException("Cound't find mother to module layer " + m.getLayer() + " half "+ m.getHalf());
+			if(mother==null) throw new RuntimeException("Cound't find mother to module " + m.module.getName());
 
-			if(isDebug()) System.out.printf("%s: found mother %s for module layer %d half %s\n", getClass().getSimpleName(),mother.getName(),m.getLayer(),m.getHalf());
+			if(isDebug()) System.out.printf("%s: found mother %s to module %s\n", getClass().getSimpleName(),mother.getName(),m.module.getName());
 			
-			// add the module to the list of objects that will be added to LCDD
+			// put the module in the list of objects that will be added to LCDD
 			addModule(m, mother);
 			
+			if(isDebug()) System.out.printf("%s: DONE build module %s\n", getClass().getSimpleName(), m.module.getName());
+
+			
 		}
 		
+		if(isDebug()) System.out.printf("%s: DONE build JAVA modules\n", getClass().getSimpleName());
+
 		
-		
 		if(isDebug()) System.out.printf("%s: DONE building the JAVA geometry objects\n", getClass().getSimpleName());
+		//if(isDebug()) {
+		System.out.printf("%s: DONE building the JAVA geometry objects\n", getClass().getSimpleName());
+		System.out.printf("%s: List of all the JAVA geometry objects built\n", this.getClass().getSimpleName());
+		for(JavaBaseGeometry bg : java_objects) {
+			System.out.printf("-------\n%s\n", bg.toString());
+		}
+		//}
 
+
 		// Set visualization features
 		//setVis();
 
@@ -243,13 +245,12 @@
 		return this.subdet;
 	}
 
+	
 	/**
 	 * 
-	 * Base geometry class for holding JAVA geometry object definitions 
-	 * where no volume is built but it can be used as reference in building the geometry.
-	 * 
+	 *  Interface to the JAVA converter geometry for the geometry definition.   
+	 *  In this case no volume is built but can be used as reference in building the geometry.
 	 * @author Per Hansson Adrian <[log in to unmask]>
-	 *
 	 */
 	protected static class GhostJavaBaseGeom extends JavaBaseGeometry {
 		
@@ -265,7 +266,7 @@
 			setName(base.getName());
 			setMother(mother);
 			mother.addDaughter(this);
-			setPosAndRot(base);
+			setPositionAndRotation(base);
 			if(isDebug()) System.out.printf("%s: DONE constructing JAVA object %s\n", this.getClass().getSimpleName(),base.getName());
 		}
 		
@@ -274,12 +275,11 @@
 	}
 
 	/**
-	 *  Base geometry class for holding JAVA geometry object definitions.
-	 *   
+	 *  Interface to the JAVA converter geometry for the geometry definition.  
 	 * @author Per Hansson Adrian <[log in to unmask]>
 	 */
 	protected static class JavaBaseGeometry {
-		private boolean debug = true;
+		private boolean debug = false;
 		private String name;
 		private Box box= null;
 		private ILogicalVolume volume = null;
@@ -296,20 +296,23 @@
 		public JavaBaseGeometry() {
 		}
 
+		/**
+		 * Construct a JAVA geometry object from its geometry definition and an already built logical volume. 
+		 * This is typically used by the tracking volume.
+		 * @param geomObject - input geometry definition
+		 * @param vol - logical volume
+		 */
 		public JavaBaseGeometry(BaseGeometry geomObject, ILogicalVolume vol) {
-			if(isDebug()) System.out.printf("%s: constructing JAVA object %s with volume (name %s)\n", this.getClass().getSimpleName(),geomObject.getName(),vol.getName());
+			if(isDebug()) System.out.printf("%s: JavaBaseGeometry %s (given logical volume %s)\n", this.getClass().getSimpleName(),geomObject.getName(),vol.getName());
+			// this must be tracking volume. May change in the future and is probably weird to make this requirement here. 
+			if(!geomObject.getName().contains("tracking")) throw new RuntimeException("this constructor is only used with the tracking volume!?");
 			setName(geomObject.getName());
 			setVolume(vol);
-			// this must be tracking volume. May change in the future and is probably weird to make this requirement here. 
-			if(!geomObject.getName().contains("tracking")) throw new RuntimeException("this constructor is only used with the tracking volume!?");
 			// since it's tracking volume, set the pos and rotation trivially
-			Hep3Vector box_center = new BasicHep3Vector(0,0,0);
 			Hep3Vector lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(geomObject.getCoord().v(), geomObject.getCoord().w(), new BasicHep3Vector(0,1,0),new BasicHep3Vector(0,0,1));
-			// Create the LCDD position
-			setPos(new Translation3D(box_center.x(), box_center.y(), box_center.z()));
+			setPos(new Translation3D(0,0,0));
 			setRot(new RotationGeant(lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z()));
-			//setPosAndRot(geomObject);		
-			if(isDebug()) System.out.printf("%s: DONE constructing JAVA object %s with volume (name %s)\n", this.getClass().getSimpleName(),geomObject.getName(),vol.getName());
+			if(isDebug()) System.out.printf("%s: DONE JavaBaseGeometry %s\n", this.getClass().getSimpleName(),geomObject.getName());
 		}
 		
 		/**
@@ -319,16 +322,15 @@
 		 * @param volumeId - component id number 
 		 */
 		public JavaBaseGeometry(BaseGeometry geomObject, JavaBaseGeometry mother, int volumeId) {
-			if(isDebug()) System.out.printf("%s: constructing JAVA object %s (volumeID %d) with mother %s\n", this.getClass().getSimpleName(),geomObject.getName(),volumeId,mother==null?"null":mother.getName());
+			if(isDebug()) System.out.printf("%s: JavaBaseGeometry %s (volumeID %d, mother %s)\n", this.getClass().getSimpleName(),geomObject.getName(),volumeId,mother==null?"null":mother.getName());
 			setName(geomObject.getName());
 			setComponentId(volumeId);
 			setMother(mother);
 			mother.addDaughter(this);
 			buildBox(geomObject);
 			buildVolume(geomObject);
-			setPosAndRot(geomObject);
-			//buildPhysVolume(mother);
-			if(isDebug()) System.out.printf("%s: DONE constructing JAVA object %s\n", this.getClass().getSimpleName(),geomObject.getName());
+			setPositionAndRotation(geomObject);
+			if(isDebug()) System.out.printf("%s: DONE JavaBaseGeometry %s\n", this.getClass().getSimpleName(),geomObject.getName());
 		}
 
 		protected boolean hasCoordinateSystemInfo() {
@@ -351,7 +353,7 @@
 				setVolume(new LogicalVolume(getName() + "_volume", box, material));
 			
 		}
-		protected void setPosAndRot(BaseGeometry base) {
+		protected void setPositionAndRotation(BaseGeometry base) {
 			if(isDebug()) System.out.printf("%s: set position and rotation for volume %s\n", this.getClass().getSimpleName(),getName());
 			
 			// no mother, this must be the world/tracking volume!?
@@ -513,6 +515,17 @@
 		public void setComponentId(int componentId) {
 			this.componentId = componentId;
 		}
+		
+		public String toString() {
+			String s = "JavaBaseGeometry " + getName() + "\n";
+			if(getPos()!=null && getRot()!=null) {
+				s += "Position: "  + getPos().toString() + "\n";
+				s += "Rotation: " + getRot().toString() + "\n";
+			} else {
+				s+= " - no position/rotation info -\n";
+			}
+			return s;
+		}
 
 	}
 	

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
HPSTestRunTracker2014.java 3311 -> 3312
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java	2014-09-04 23:17:17 UTC (rev 3311)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java	2014-09-05 22:37:43 UTC (rev 3312)
@@ -46,7 +46,7 @@
  */
 public class HPSTestRunTracker2014 extends LCDDSubdetector
 {
-	private boolean _debug = true; 
+	private boolean _debug = false; 
 	private final boolean buildBeamPlane = true;
 	// Builder class to handle all geometry information
 	private static HPSTestRunTracker2014LCDDBuilder builder;
@@ -334,7 +334,7 @@
 	
 	
 	public static Hep3Vector getEulerAngles(Hep3Vector u, Hep3Vector v, Hep3Vector u_prime, Hep3Vector v_prime) {
-		int debug = 1;
+		int debug = 0;
 		if (debug>0) System.out.printf("getEulerAngles: u %s v%s -> %s %s\n",u.toString(),v.toString(),u_prime.toString(),v_prime.toString());
 		// Convert to correct API
 		org.apache.commons.math3.geometry.euclidean.threed.Vector3D u_3D = new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(u.v());

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
HPSTestRunTracker2014Builder.java 3311 -> 3312
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014Builder.java	2014-09-04 23:17:17 UTC (rev 3311)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014Builder.java	2014-09-05 22:37:43 UTC (rev 3312)
@@ -23,10 +23,10 @@
 public class HPSTestRunTracker2014Builder  {
 
 	// general members
-	private boolean debug = true;
+	private boolean debug = false;
 	
 	//Geometry members
-	protected List<HPSTestRunTracker2014GeometryDefinition.BaseGeometry> trackerItems = new ArrayList<HPSTestRunTracker2014GeometryDefinition.BaseGeometry>();
+	protected List<HPSTestRunTracker2014GeometryDefinition.BaseGeometry> geometries = new ArrayList<HPSTestRunTracker2014GeometryDefinition.BaseGeometry>();
 	public  List<ModuleBundle> modules;
 	
 	
@@ -43,23 +43,23 @@
 		// Keep the order correct.
 		// Each item has knowledge of its mother but not its daughters
 		HPSTestRunTracker2014GeometryDefinition.TrackingBase tracking = new HPSTestRunTracker2014GeometryDefinition.TrackingBase("trackingVolume",null);
-		trackerItems.add(tracking);
+		geometries.add(tracking);
 		HPSTestRunTracker2014GeometryDefinition.Base base = new HPSTestRunTracker2014GeometryDefinition.Base("base",tracking);
-		trackerItems.add(base);
+		geometries.add(base);
 		HPSTestRunTracker2014GeometryDefinition.BasePlate basePlate = new HPSTestRunTracker2014GeometryDefinition.BasePlate("baseplate",base, "Aluminum");
-		trackerItems.add(basePlate);
+		geometries.add(basePlate);
 		HPSTestRunTracker2014GeometryDefinition.CSupport cSupport = new HPSTestRunTracker2014GeometryDefinition.CSupport("c_support", base);
-		trackerItems.add(cSupport);
+		geometries.add(cSupport);
 		HPSTestRunTracker2014GeometryDefinition.SupportBottom supportBottom = new HPSTestRunTracker2014GeometryDefinition.SupportBottom("support_bottom", base, cSupport);
-		trackerItems.add(supportBottom);
+		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
 		HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom supportPlateBottom = new HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom("support_plate_bottom", base, supportBottom, "Aluminum");
-		trackerItems.add(supportPlateBottom);
+		geometries.add(supportPlateBottom);
 		HPSTestRunTracker2014GeometryDefinition.SupportTop supportTop = new HPSTestRunTracker2014GeometryDefinition.SupportTop("support_top", base, cSupport);
-		trackerItems.add(supportTop);
+		geometries.add(supportTop);
 		HPSTestRunTracker2014GeometryDefinition.SupportPlateTop supportPlateTop = new HPSTestRunTracker2014GeometryDefinition.SupportPlateTop("support_plate_top", base, supportTop, "Aluminum");
-		trackerItems.add(supportPlateTop);
+		geometries.add(supportPlateTop);
 		
 		// Modules are built using an encapsulating class that keeps tracks of all components
 		modules = new ArrayList<ModuleBundle>();
@@ -70,8 +70,13 @@
 		}
 		
 		
-		if(isDebug()) System.out.printf("%s: DONE constructing the geometry objects\n", this.getClass().getSimpleName());
-
+		//if(isDebug()) {
+			System.out.printf("%s: DONE constructing the geometry objects\n", this.getClass().getSimpleName());
+			System.out.printf("%s: List of all the geometry objects built\n", this.getClass().getSimpleName());
+			for(BaseGeometry bg : geometries) {
+				System.out.printf("-------\n%s\n", bg.toString());
+			}
+		//}
 	}
 	
 
@@ -442,10 +447,8 @@
 		}
 		return false;
 	}
+		
 	
-
-	
-	
 	/**
 	 * Find geometry object by type.
 	 * @param c - class type to be found
@@ -454,13 +457,13 @@
 	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) {
+		for(HPSTestRunTracker2014GeometryDefinition.BaseGeometry item : geometries) {
 			//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!");
+		throw new RuntimeException("Coulnd't find instance of " + c.getSimpleName() + " among the " + geometries.size() + " tracker items!");
 	}
 	
 	protected  List<ModuleBundle> getModules() {
@@ -475,7 +478,9 @@
 	
 
 	/**
-	 * Bundle geometry objects in a module. Perhaps I can add daughter to geometry definition to avoid this?
+	 * Bundle geometry objects in a module. 
+	 * This was done in order to package module geometry objects into a simpler form.
+	 * If the geometry definition has access to daughter information I could avoid this? TODO check this? 
 	 * 
 	 * @author Per Hansson Adrian <[log in to unmask]>
 	 *
@@ -600,8 +605,15 @@
     }
     
     
+    /**
+     * Find transform to parent volume coordinate system.
+     * @param t - current transform to mother
+     * @param mother - geometry object from current transform 
+     * @param targetMotherName - parent volume defining new vector coordinate system
+     * @return transform.
+     */
     public static Transform3D getTransform(Transform3D t, BaseGeometry mother, String targetMotherName) {
-		int debug=1;
+		int debug=0;
 		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)) {
@@ -617,8 +629,15 @@
 	}
     
     
+    /**
+     * Find the vector in a parent volume coordinate system.
+     * @param vec - vector to transform
+     * @param geometry - geometry where vector is defined.
+     * @param targetMotherName - parent volume defining new vector coordinate system
+     * @return transformed vector.
+     */
     public static Hep3Vector transformToMotherCoord(Hep3Vector vec, BaseGeometry geometry, String targetMotherName) {
-		int debug =1;
+		int debug =0;
 		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);
 		
@@ -636,8 +655,14 @@
 	}
 		
     
+    /**
+     * Find the vector in the tracking volume coordinate system.
+     * @param vec - vector to transform
+     * @param geometry - geometry where vector is defined.
+     * @return transformed vector.
+     */
     public static Hep3Vector transformToTracking(Hep3Vector vec, BaseGeometry geometry) {
-		int debug =1;
+		int debug =0;
 		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());

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
HPSTestRunTracker2014GeometryDefinition.java 3311 -> 3312
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014GeometryDefinition.java	2014-09-04 23:17:17 UTC (rev 3311)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014GeometryDefinition.java	2014-09-05 22:37:43 UTC (rev 3312)
@@ -43,6 +43,7 @@
 		 * 
 		 */
 		public static abstract class BaseGeometry {
+			protected boolean debug = false;
 			private String name;
 			private String material = "Vacuum";
 			private BaseGeometry mother;
@@ -159,8 +160,6 @@
 				}
 				referenceGeom.addAll(refGeomList);
 			}
-			
-			
 			public void printSurveyPos() {
 				System.out.printf("Survey pos for %s:\n",getName());
 				System.out.printf("ballPos   %s\n", ballPos.toString());
@@ -173,7 +172,12 @@
 			public void setMaterial(String material) {
 				this.material = material;
 			}
-
+			public String toString() {
+				String s = "BaseGeometry " + getName();
+				s += "\n" + this.getCoord().toString();
+				return s;
+			}
+			
 		}
 	
 		
@@ -356,7 +360,7 @@
 			}
 
 			protected void setPos() {
-				System.out.printf("%s: setPos support top\n",this.getClass().getSimpleName());
+				if(debug) System.out.printf("%s: setPos support top\n",this.getClass().getSimpleName());
 				// 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);
@@ -384,17 +388,21 @@
 
 				for(BaseGeometry ref : referenceGeom) {
 				
-					System.out.printf("%s: survey positions before ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
-					printSurveyPos();
+					if(debug) {
+						System.out.printf("%s: survey positions before ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
+						printSurveyPos();
+					}
 				
-					System.out.printf("%s: Ref %s coord\n%s\n",this.getClass().getSimpleName(), ref.getName(),ref.getCoord().toString());
+					if(debug) System.out.printf("%s: Ref %s coord\n%s\n",this.getClass().getSimpleName(), ref.getName(),ref.getCoord().toString());
 				
 					ref.getCoord().getTransformation().transform(ballPos);
 					ref.getCoord().getTransformation().transform(veePos);
 					ref.getCoord().getTransformation().transform(flatPos);
 				
-					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 after ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
+						printSurveyPos();
+					}
 				}
 			}
 			protected void setCoord() {
@@ -433,7 +441,7 @@
 			
 			protected void setPos() {
 				
-				System.out.printf("%s: setPos support bottom\n",this.getClass().getSimpleName());
+				if(debug) System.out.printf("%s: setPos support bottom\n",this.getClass().getSimpleName());
 				
 				// 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
@@ -467,17 +475,21 @@
 
 				for(BaseGeometry ref : referenceGeom) {
 				
-					System.out.printf("%s: survey positions before ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
-					printSurveyPos();
+					if(debug) {
+						System.out.printf("%s: survey positions before ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
+						printSurveyPos();
+					}
 				
-					System.out.printf("%s: Ref %s coord\n%s\n",this.getClass().getSimpleName(), ref.getName(),ref.getCoord().toString());
+					if(debug) System.out.printf("%s: Ref %s coord\n%s\n",this.getClass().getSimpleName(), ref.getName(),ref.getCoord().toString());
 				
 					ref.getCoord().getTransformation().transform(ballPos);
 					ref.getCoord().getTransformation().transform(veePos);
 					ref.getCoord().getTransformation().transform(flatPos);
 				
-					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 after ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
+						printSurveyPos();
+					}
 				}
 				
 			}
@@ -533,7 +545,7 @@
 				init();				
 			}
 			protected void setPos() {
-				System.out.printf("%s: set survey positions \n",this.getClass().getSimpleName());
+				if(debug) System.out.printf("%s: set survey positions \n",this.getClass().getSimpleName());
 				
 				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());
@@ -545,17 +557,21 @@
 
 				for(BaseGeometry ref : referenceGeom) {
 				
-					System.out.printf("%s: survey positions before ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
-					printSurveyPos();
+					if(debug) {
+						System.out.printf("%s: survey positions before ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
+						printSurveyPos();
+					}
 				
-					System.out.printf("%s: Ref %s coord\n%s\n",this.getClass().getSimpleName(), ref.getName(),ref.getCoord().toString());
+					if(debug) System.out.printf("%s: Ref %s coord\n%s\n",this.getClass().getSimpleName(), ref.getName(),ref.getCoord().toString());
 				
 					ref.getCoord().getTransformation().transform(ballPos);
 					ref.getCoord().getTransformation().transform(veePos);
 					ref.getCoord().getTransformation().transform(flatPos);
 				
-					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 after ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
+						printSurveyPos();
+					}
 				}
 			}
 			protected void setCoord() {
@@ -584,7 +600,7 @@
 				init();
 			}
 			protected void setPos() {
-				System.out.printf("%s: set survey positions \n",this.getClass().getSimpleName());
+				if(debug) System.out.printf("%s: set survey positions \n",this.getClass().getSimpleName());
 				
 				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());
@@ -596,17 +612,17 @@
 
 				for(BaseGeometry ref : referenceGeom) {
 				
-					System.out.printf("%s: survey positions before ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
-					printSurveyPos();
+					if(debug) System.out.printf("%s: survey positions before ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
+					if(debug) printSurveyPos();
 				
-					System.out.printf("%s: Ref %s coord\n%s\n",this.getClass().getSimpleName(), ref.getName(),ref.getCoord().toString());
+					if(debug) System.out.printf("%s: Ref %s coord\n%s\n",this.getClass().getSimpleName(), ref.getName(),ref.getCoord().toString());
 				
 					ref.getCoord().getTransformation().transform(ballPos);
 					ref.getCoord().getTransformation().transform(veePos);
 					ref.getCoord().getTransformation().transform(flatPos);
 				
-					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 after ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
+					if(debug) printSurveyPos();
 				}
 			}
 			protected void setCoord() {
@@ -706,16 +722,16 @@
 			}
 			protected void setCoord() {				
 				setCoord(null);
-				System.out.printf("%s: coordinate system:\n%s\n",this.getClass().getSimpleName(), getCoord().toString());
-				System.out.printf("%s: translation:\n%s\n",this.getClass().getSimpleName(), getCoord().getTransformation().getTranslation().toString());
-				System.out.printf("%s: rotation:\n%s\n",this.getClass().getSimpleName(), getCoord().getTransformation().getRotation().toString());
+				if(debug) System.out.printf("%s: coordinate system:\n%s\n",this.getClass().getSimpleName(), getCoord().toString());
+				if(debug) System.out.printf("%s: translation:\n%s\n",this.getClass().getSimpleName(), getCoord().getTransformation().getTranslation().toString());
+				if(debug) System.out.printf("%s: rotation:\n%s\n",this.getClass().getSimpleName(), getCoord().getTransformation().getRotation().toString());
 			}
 			protected void setCenter() {
 				setCenter(getModuleBoxLength()/2.0-5.0, 0.0, getModuleBoxWidth()/2.0); 
 			}			
 			protected void setPos() {
 				
-				System.out.printf("%s: setPos\n",this.getClass().getSimpleName());
+				if(debug) System.out.printf("%s: setPos\n",this.getClass().getSimpleName());
 
 				if(isBottom()) {
 					switch (getLayer()) {
@@ -788,8 +804,10 @@
 					 }
 				 }
 				
-				System.out.printf("%s: survey positions\n",this.getClass().getSimpleName());
-				printSurveyPos();
+				if(debug) {
+					System.out.printf("%s: survey positions\n",this.getClass().getSimpleName());
+					printSurveyPos();
+				}
 				
 				//
 				// Note that the mother volume is the support wrap box which can be different than support plate coord system.
@@ -800,17 +818,21 @@
 
 				for(BaseGeometry ref : referenceGeom) {
 				
-					System.out.printf("%s: survey positions before ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
-					printSurveyPos();
+					if(debug) {
+						System.out.printf("%s: survey positions before ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
+						printSurveyPos();
+					}
 				
-					System.out.printf("%s: Ref %s coord\n%s\n",this.getClass().getSimpleName(), ref.getName(),ref.getCoord().toString());
+					if(debug) System.out.printf("%s: Ref %s coord\n%s\n",this.getClass().getSimpleName(), ref.getName(),ref.getCoord().toString());
 				
 					ref.getCoord().getTransformation().transform(ballPos);
 					ref.getCoord().getTransformation().transform(veePos);
 					ref.getCoord().getTransformation().transform(flatPos);
 				
-					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 after ref %s transform\n",this.getClass().getSimpleName(),ref.getName());
+						printSurveyPos();
+					}
 				}
 				
 			
@@ -951,18 +973,18 @@
 				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;
 				
-				final double ball_pos_halfmod_axial_local_x =  dist_sensor_center_to_coldblock_hole_vdir;
-				final double ball_pos_halfmod_axial_local_y =  -1.0* (coldBlockThick/2.0 + TestRunHalfModule.getCFThickness() + HalfModuleLamination.kapton_thickness + HPSTestRunTracker2014GeometryDefinition.Sensor.getSensorThickness()/2.0);
-				final double ball_pos_halfmod_axial_local_z =  dist_lower_sensor_edge_to_cold_block_mounting_surface + Sensor.getSensorWidth()/2.0;
-				final double vee_pos_halfmod_axial_local_x =  ball_pos_halfmod_axial_local_x + Sensor.getSensorLength()/2.0;
-				final double vee_pos_halfmod_axial_local_y =  ball_pos_halfmod_axial_local_y;
-				final double vee_pos_halfmod_axial_local_z =  ball_pos_halfmod_axial_local_z;
-				final double flat_pos_halfmod_axial_local_x =  ball_pos_halfmod_axial_local_x;
-				final double flat_pos_halfmod_axial_local_y =  ball_pos_halfmod_axial_local_y + Sensor.getSensorThickness()/2.0;
-				final double flat_pos_halfmod_axial_local_z =  ball_pos_halfmod_axial_local_z;		
-				ballPos = new BasicHep3Vector(ball_pos_halfmod_axial_local_x, ball_pos_halfmod_axial_local_y, ball_pos_halfmod_axial_local_z);
-				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);
+				final double ball_pos_halfmod_local_x =  dist_sensor_center_to_coldblock_hole_vdir;
+				final double ball_pos_halfmod_local_y =  -1.0* (coldBlockThick/2.0 + TestRunHalfModule.getCFThickness() + HalfModuleLamination.kapton_thickness + HPSTestRunTracker2014GeometryDefinition.Sensor.getSensorThickness()/2.0);
+				final double ball_pos_halfmod_local_z =  dist_lower_sensor_edge_to_cold_block_mounting_surface + Sensor.getSensorWidth()/2.0;
+				final double vee_pos_halfmod_local_x =  ball_pos_halfmod_local_x + Sensor.getSensorLength()/2.0;
+				final double vee_pos_halfmod_local_y =  ball_pos_halfmod_local_y;
+				final double vee_pos_halfmod_local_z =  ball_pos_halfmod_local_z;
+				final double flat_pos_halfmod_local_x =  ball_pos_halfmod_local_x;
+				final double flat_pos_halfmod_local_y =  ball_pos_halfmod_local_y + Sensor.getSensorThickness()/2.0;
+				final double flat_pos_halfmod_local_z =  ball_pos_halfmod_local_z;		
+				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);
 
 			}
 		}
@@ -983,21 +1005,45 @@
 				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;
 				
-				final double ball_pos_halfmod_axial_local_x =  dist_sensor_center_to_coldblock_hole_vdir;
+				final double ball_pos_halfmod_local_x =  dist_sensor_center_to_coldblock_hole_vdir;
 				// note minus sign to separate from axial
-				final double ball_pos_halfmod_axial_local_y =  -1.0 * (-1.0* (coldBlockThick/2.0 + TestRunHalfModule.getCFThickness() + HalfModuleLamination.kapton_thickness + HPSTestRunTracker2014GeometryDefinition.Sensor.getSensorThickness()/2.0));
-				final double ball_pos_halfmod_axial_local_z =  dist_lower_sensor_edge_to_cold_block_mounting_surface + Sensor.getSensorWidth()/2.0;
-				final double vee_pos_halfmod_axial_local_x =  ball_pos_halfmod_axial_local_x + Sensor.getSensorLength()/2.0;
-				final double vee_pos_halfmod_axial_local_y =  ball_pos_halfmod_axial_local_y;
-				final double vee_pos_halfmod_axial_local_z =  ball_pos_halfmod_axial_local_z;
-				final double flat_pos_halfmod_axial_local_x =  ball_pos_halfmod_axial_local_x;
-				final double flat_pos_halfmod_axial_local_y =  ball_pos_halfmod_axial_local_y + Sensor.getSensorThickness()/2.0;
-				final double flat_pos_halfmod_axial_local_z =  ball_pos_halfmod_axial_local_z;		
-				ballPos = new BasicHep3Vector(ball_pos_halfmod_axial_local_x, ball_pos_halfmod_axial_local_y, ball_pos_halfmod_axial_local_z);
-				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);
+				final double ball_pos_halfmod_local_y =  -1.0 * (-1.0* (coldBlockThick/2.0 + TestRunHalfModule.getCFThickness() + HalfModuleLamination.kapton_thickness + HPSTestRunTracker2014GeometryDefinition.Sensor.getSensorThickness()/2.0));
+				final double ball_pos_halfmod_local_z =  dist_lower_sensor_edge_to_cold_block_mounting_surface + Sensor.getSensorWidth()/2.0;
+				final double vee_pos_halfmod_local_x =  ball_pos_halfmod_local_x + Sensor.getSensorLength()/2.0;
+				final double vee_pos_halfmod_local_y =  ball_pos_halfmod_local_y;
+				final double vee_pos_halfmod_local_z =  ball_pos_halfmod_local_z;
+				final double flat_pos_halfmod_local_x =  ball_pos_halfmod_local_x;
+				final double flat_pos_halfmod_local_y =  ball_pos_halfmod_local_y + Sensor.getSensorThickness()/2.0;
+				final double flat_pos_halfmod_local_z =  ball_pos_halfmod_local_z;		
+				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);
+			
+				// I should set the coordiantes from the the drawing without explicit roations
+				// TODO FIX THIS!
+				calcAndSetPos();
 			}
 			
+			private void calcAndSetPos() {
+			/*
+				// find the rotation to place the flat point
+				org.apache.commons.math3.geometry.euclidean.threed.Rotation rot1_csup = 
+						new org.apache.commons.math3.geometry.euclidean.threed.Rotation(
+								new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(vee_pos_csup_pin_bottom_x-ball_pos_csup_pin_bottom_x,
+																								vee_pos_csup_pin_bottom_y-ball_pos_csup_pin_bottom_y,
+																								vee_pos_csup_pin_bottom_z-ball_pos_csup_pin_bottom_z),
+																								new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(1,0,0));
+								
+				org.apache.commons.math3.geometry.euclidean.threed.Vector3D flat_pos_csup_pin_bottom_3D_rot = rot1_csup.applyTo(new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(0,10.0,0));
+				// translate
+				double flat_pos_csup_pin_bottom_x = ball_pos_csup_pin_bottom_x + flat_pos_csup_pin_bottom_3D_rot.getX();
+				double flat_pos_csup_pin_bottom_y = ball_pos_csup_pin_bottom_y + flat_pos_csup_pin_bottom_3D_rot.getY();
+				double flat_pos_csup_pin_bottom_z = ball_pos_csup_pin_bottom_z + flat_pos_csup_pin_bottom_3D_rot.getZ();
+				setFlatPos(flat_pos_csup_pin_bottom_x,flat_pos_csup_pin_bottom_y,flat_pos_csup_pin_bottom_z);
+			*/
+			}
+
+			
 			/**
 			 * Set rotations explicitly. 
 			 * TODO Should be included in the coord system? Workaround!?
@@ -1105,8 +1151,8 @@
 		
 		
 		public static class Sensor extends HalfModuleComponent {
-			private static final double sensor_length= 100.00; //98.33;
-			private static final double sensor_width = 40.34; //38.3399;
+			private static final double sensor_length= 100.00; 
+			private static final double sensor_width = 40.34; 
 			private static final double sensor_thickness = 0.32;
 			public Sensor(String name, BaseGeometry m, int id) {
 				super(name, m, id);

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
HPSTestRunTracker2014LCDDBuilder.java 3311 -> 3312
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014LCDDBuilder.java	2014-09-04 23:17:17 UTC (rev 3311)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014LCDDBuilder.java	2014-09-05 22:37:43 UTC (rev 3312)
@@ -35,12 +35,10 @@
  *
  */
 public class HPSTestRunTracker2014LCDDBuilder extends HPSTestRunTracker2014Builder {
-
 	
-	
 	protected LCDD lcdd;
 	protected LCDDBaseGeometry baseTrackerGeometry;
-	protected List<LCDDBaseGeometry> lcdd_objects;
+	protected List<LCDDBaseGeometry> lcddGeometries;
 	private SensitiveDetector sensitiveDetector;
 	
 	/**
@@ -55,7 +53,7 @@
 	 * @param geom - object to add.
 	 */
 	private void add(LCDDBaseGeometry geom) {
-		lcdd_objects.add(geom);
+		lcddGeometries.add(geom);
 	}
 	
 	
@@ -69,7 +67,7 @@
 		if(isDebug()) System.out.printf("%s: build the LCDD geometry objects\n", getClass().getSimpleName());
 		
 		// initialize the list to store a reference to each object
-		lcdd_objects = new ArrayList<LCDDBaseGeometry>();
+		lcddGeometries = new ArrayList<LCDDBaseGeometry>();
 
 		// Go through the list of volumes to build that is created in the generic builder class
 		// TODO this is manual now since I don't have a way of knowing in the generic builder class what is a ghost volume at this point.
@@ -109,7 +107,7 @@
 			// Find the mother among the LCDD objects using its name, should probably have a better way...
 			String name_mother = m.getMother().getName();
 			LCDDBaseGeometry mother = null;
-			for(LCDDBaseGeometry g : lcdd_objects) {
+			for(LCDDBaseGeometry g : lcddGeometries) {
 				if(g.getName().equals(name_mother)) {
 					mother = g;
 					break;
@@ -127,10 +125,18 @@
 		
 		
 		
-		if(isDebug()) System.out.printf("%s: DONE building the LCDD geometry objects\n", getClass().getSimpleName());
+		//if(isDebug()) {
+		System.out.printf("%s: DONE building the LCDD geometry objects\n", getClass().getSimpleName());
+		System.out.printf("%s: List of all %d LCDD geometry objects built\n", this.getClass().getSimpleName(), lcddGeometries.size());
+		for(LCDDBaseGeometry bg : lcddGeometries) {
+			System.out.printf("-------\n%s\n", bg.toString());
+		}
+		//}
 
+		
+
 		// Set visualization features
-		setVis();
+		setVisualization();
 		
 		
 	}
@@ -180,38 +186,6 @@
 		
 	}
 	
-	/**
-	 * Set visualization features.
-	 */
-	private void setVis() {
-
-		if(isDebug()) System.out.printf("%s: Set LCDD vis \n", getClass().getSimpleName());
-
-		//set lcdd vis
-		for(LCDDBaseGeometry g : lcdd_objects) {
-			if(isDebug()) System.out.printf("%s: Set LCDD vis for %s \n", getClass().getSimpleName(), g.getName());
-			
-			if(g.getName().endsWith("baseplate")) g.setVisName("BasePlateVis");
-			//else if(g.getName().contains("base")) g.setVisName("BaseVis");
-			else if(g.getName().endsWith("support_bottom") || g.getName().contains("support_top")) g.setVisName("SupportVolumeVis");
-			else if(g.getName().endsWith("support_plate_bottom") || g.getName().contains("support_plate_top")) g.setVisName("SupportPlateVis");
-			else if(g.getName().endsWith("halfmodule_axial")) g.setVisName("HalfModuleVis");
-			else if(g.getName().endsWith("halfmodule_stereo")) g.setVisName("HalfModuleVis");
-			else if(g.getName().endsWith("module")) g.setVisName("ModuleVis");
-			else if(g.getName().endsWith("cold")) g.setVisName("ColdBlockVis");
-			else if(g.getName().endsWith("lamination")) g.setVisName("KaptonVis");
-			else if(g.getName().endsWith("sensor")) g.setVisName("SensorVis");
-			else if(g.getName().endsWith("sensor_active")) g.setVisName("SensorVis");
-			else if(g.getName().endsWith("cf")) g.setVisName("CarbonFiberVis");
-			else if(g.getName().endsWith("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;
@@ -226,12 +200,12 @@
 
 	
 	/**
-	 *  Base geometry class for holding LCDD geometry object definitions.
+	 * Interface to the LCDD converter geometry for the geometry definition. 
 	 *   
 	 * @author Per Hansson Adrian <[log in to unmask]>
 	 */
 	protected static class LCDDBaseGeometry extends LCDDBaseGeometryVisualization {
-		private boolean debug = true;
+		private boolean debug = false;
 		private String name;
 		private Box box= null;
 		private Volume volume = null;
@@ -249,7 +223,7 @@
 		}
 		
 		/**
-		 * Construct a LCDD geometry object from its geometry definition. 
+		 * Interface to the LCDD converter geometry for the geometry definition. 
 		 * @param base - input geometry definition
 		 * @param lcdd - lcdd file 
 		 * @param mother - reference to mother LCDD definition
@@ -262,7 +236,7 @@
 			mother.addDaughter(this);
 			buildBox(base);
 			buildVolume(base);
-			setPosAndRot(base);
+			setPositionAndRotation(base);
 			//buildPhysVolume(mother);
 			if(isDebug()) System.out.printf("%s: DONE constructing LCDD object %s\n", this.getClass().getSimpleName(),base.getName());
 		}
@@ -285,10 +259,16 @@
 				e.printStackTrace();
 			}
 		}
-		protected void setPosAndRot(BaseGeometry base) {
-			// TODO this sets position and reference w.r.t. mother coordinate system. If I'm not building that volume this will be wrong. Similar to in the JAVA converter this should be something like the physical mother.
+		
+		
+		protected void setPositionAndRotation(BaseGeometry base) {
 			
+			// NOTE:
+			// This sets position and reference w.r.t. mother coordinate system. 
+			// If I'm not building that volume this will be wrong. 
+			// TODO Similar to in the JAVA converter this should be something like the physical mother.
 			
+			
 			if(isDebug()) System.out.printf("%s: set position and rotation for volume %s\n", this.getClass().getSimpleName(),getName());
 			// Vector from origin to center of box locally 
 			Hep3Vector box_center_base_local = base.getCenter();
@@ -389,22 +369,36 @@
 		public boolean isDebug() {
 			return debug;
 		}
-
 		protected List<LCDDBaseGeometry> getDaughters() {
 			return daughters;
 		}
-
 		protected void addDaughter(LCDDBaseGeometry o) {
 			getDaughters().add(o);
 		}
+		public String toString() {
+			String s = "LCDDBaseGeometry " + getName() + "\n";
+			if(getPos()!=null && getRot()!=null) 	{
+				double x = Double.valueOf(getPos().getAttributeValue("x"));
+				double y = Double.valueOf(getPos().getAttributeValue("y"));
+				double z = Double.valueOf(getPos().getAttributeValue("z"));
+				s += "Position: " + String.format("(%.4f %.4f %.4f)\n", x,y,z);
+				x = Double.valueOf(getRot().getAttributeValue("x"));
+				y = Double.valueOf(getRot().getAttributeValue("y"));
+				z = Double.valueOf(getRot().getAttributeValue("z"));
+				s += "Rotation: " + String.format("(%.4f %.4f %.4f)\n", x,y,z);
+			} else {
+				s += " - no position/rotation info -\n";
+			}
+			return s;
+		}
 	}
 
 	
 
 	/**
 	 * 
-	 * Base geometry class for holding LCDD geometry object definitions 
-	 * where no volume is built but it can be used as reference in building the geometry.
+	 * Interface to the LCDD converter geometry for the geometry definition. 
+	 * No volume is built but it can be used as reference in building the geometry.
 	 * 
 	 * @author Per Hansson Adrian <[log in to unmask]>
 	 *
@@ -461,18 +455,41 @@
 		
 	}
 
-
-
 	public void setSensitiveDetector(SensitiveDetector sens) {
 		this.sensitiveDetector = sens;
-		
 	}
 
 	public SensitiveDetector getSensitiveDetector() {
 		return this.sensitiveDetector;
 	}
 
+	/**
+	 * Set visualization features.
+	 */
+	private void setVisualization() {
+
+		if(isDebug()) System.out.printf("%s: Set LCDD visualization for %d LCDD geometry objects \n", getClass().getSimpleName(), lcddGeometries.size());
+		for(LCDDBaseGeometry g : lcddGeometries) {
+			if(isDebug()) System.out.printf("%s: Set LCDD vis for %s \n", getClass().getSimpleName(), g.getName());			
+			if(g.getName().endsWith("baseplate")) g.setVisName("BasePlateVis");
+			//else if(g.getName().contains("base")) g.setVisName("BaseVis");
+			else if(g.getName().endsWith("support_bottom") || g.getName().contains("support_top")) g.setVisName("SupportVolumeVis");
+			else if(g.getName().endsWith("support_plate_bottom") || g.getName().contains("support_plate_top")) g.setVisName("SupportPlateVis");
+			else if(g.getName().endsWith("halfmodule_axial")) g.setVisName("HalfModuleVis");
+			else if(g.getName().endsWith("halfmodule_stereo")) g.setVisName("HalfModuleVis");
+			else if(g.getName().endsWith("module")) g.setVisName("ModuleVis");
+			else if(g.getName().endsWith("cold")) g.setVisName("ColdBlockVis");
+			else if(g.getName().endsWith("lamination")) g.setVisName("KaptonVis");
+			else if(g.getName().endsWith("sensor")) g.setVisName("SensorVis");
+			else if(g.getName().endsWith("sensor_active")) g.setVisName("SensorVis");
+			else if(g.getName().endsWith("cf")) g.setVisName("CarbonFiberVis");
+			else if(g.getName().endsWith("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());
+	}	
 	
-	
 
 }
\ No newline at end of file

projects/lcsim/trunk/detector-framework/src/test/java/org/lcsim/geometry/compact/converter/lcdd
HPSTestRunTracker2014LCDDTest.java added at 3312
--- projects/lcsim/trunk/detector-framework/src/test/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014LCDDTest.java	                        (rev 0)
+++ projects/lcsim/trunk/detector-framework/src/test/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014LCDDTest.java	2014-09-05 22:37:43 UTC (rev 3312)
@@ -0,0 +1,35 @@
+package org.lcsim.geometry.compact.converter.lcdd;
+
+import java.io.BufferedOutputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.lcsim.util.test.TestUtil.TestOutputFile;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+*
+* @author Per Hansson Adrian <[log in to unmask]>
+*/
+public class HPSTestRunTracker2014LCDDTest extends TestCase
+{    
+   public HPSTestRunTracker2014LCDDTest(String name)
+   {
+   	super(name);
+   }
+   
+   public static TestSuite suite()
+   {
+       return new TestSuite(HPSTestRunTracker2014LCDDTest.class);
+   }
+   
+   public void test_converter() throws Exception
+   {
+       InputStream in = HPSTestRunTracker2014.class.getResourceAsStream("/org/lcsim/geometry/subdetector/HPSTestRunTracker2014.xml");
+       OutputStream out = new BufferedOutputStream(new FileOutputStream(new TestOutputFile("HPSTestRunTracker2014.lcdd")));
+       new Main().convert("HPSTestRunTracker2014",in,out);
+   }
+}
\ No newline at end of file
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