Print

Print


Commit in projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim on MAIN
detector/converter/compact/HPSTestRunTracker2014Converter.java+23-103321 -> 3322
                          /HPSTestRunTracker2014JavaBuilder.java+11-4603321 -> 3322
                          /HPSTestRunTracker2014Test1JavaBuilder.java+200added 3322
geometry/compact/converter/lcdd/HPSTestRunTracker2014.java+38-273321 -> 3322
                               /HPSTestRunTracker2014Test1LCDDBuilder.java+33-53321 -> 3322
                               /HPSTrackerBuilder.java+3-33321 -> 3322
                               /HPSTrackerJavaBuilder.java+488added 3322
                               /HPSTrackerLCDDBuilder.java+1-13321 -> 3322
                               /IHPSTrackerJavaBuilder.java+31added 3322
+828-506
3 added + 6 modified, total 9 files
Refactoring and adding simple geom. for testing. Work in progress.

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact
HPSTestRunTracker2014Converter.java 3321 -> 3322
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014Converter.java	2014-09-14 07:56:37 UTC (rev 3321)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014Converter.java	2014-09-15 19:24:26 UTC (rev 3322)
@@ -3,20 +3,19 @@
  */
 package org.lcsim.detector.converter.compact;
 
+import javax.swing.text.html.HTMLDocument.HTMLReader.IsindexAction;
+
 import org.jdom.Element;
 import org.lcsim.detector.DetectorElement;
 import org.lcsim.detector.DetectorElementStore;
 import org.lcsim.detector.DetectorIdentifierHelper;
+import org.lcsim.detector.DetectorIdentifierHelper.SystemMap;
 import org.lcsim.detector.IDetectorElement;
 import org.lcsim.detector.IGeometryInfo;
 import org.lcsim.detector.ILogicalVolume;
 import org.lcsim.detector.IPhysicalVolume;
-import org.lcsim.detector.DetectorIdentifierHelper.SystemMap;
 import org.lcsim.detector.PhysicalVolume;
-import org.lcsim.detector.PhysicalVolumeStore;
 import org.lcsim.detector.Transform3D;
-import org.lcsim.detector.converter.compact.HPSTestRunTracker2014JavaBuilder.GhostJavaBaseGeom;
-import org.lcsim.detector.converter.compact.HPSTestRunTracker2014JavaBuilder.JavaBaseGeometry;
 import org.lcsim.detector.identifier.ExpandedIdentifier;
 import org.lcsim.detector.identifier.IExpandedIdentifier;
 import org.lcsim.detector.identifier.IIdentifier;
@@ -30,6 +29,9 @@
 import org.lcsim.geometry.compact.Detector;
 import org.lcsim.geometry.compact.Subdetector;
 import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014Builder;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerJavaBuilder;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerJavaBuilder.GhostJavaBaseGeom;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerJavaBuilder.JavaBaseGeometry;
 import org.lcsim.geometry.subdetector.HPSTestRunTracker2014;
 
 /**
@@ -39,9 +41,9 @@
  */
 public class HPSTestRunTracker2014Converter extends AbstractSubdetectorConverter {
 
-	private boolean _debug = true; 
+	private boolean _debug = false; 
 	private IMaterial trackingMaterial = null;
-	private static HPSTestRunTracker2014JavaBuilder builder;
+	private static HPSTrackerJavaBuilder builder;
 	
 	public IIdentifierHelper makeIdentifierHelper(Subdetector subdetector, SystemMap systemMap) {
 		return new SiTrackerIdentifierHelper(subdetector.getDetectorElement(), makeIdentifierDictionary(subdetector), systemMap);
@@ -63,7 +65,8 @@
 		
 		if(_debug) System.out.printf("%s: convert %s \n", getClass().getSimpleName(), subdet.getName());
 		
-		builder = new HPSTestRunTracker2014JavaBuilder(_debug);
+		//builder = new HPSTestRunTracker2014JavaBuilder(_debug);
+		builder = new HPSTestRunTracker2014Test1JavaBuilder(_debug);
 		
 		// check tracking material
 		trackingMaterial = MaterialStore.getInstance().get("Vacuum");
@@ -127,7 +130,7 @@
 		
 		if(_debug) System.out.printf("%s: setup the detector elements\n", getClass().getSimpleName());
 
-		setupDetectorElement(builder.baseTrackerGeometry);
+		setupDetectorElement(builder.getBaseTrackerGeometry());
 		
 	
 		if(_debug) System.out.printf("%s: DONE setup the detector elements\n", getClass().getSimpleName());
@@ -153,10 +156,12 @@
 		// are added so I keep track of all the elements in the builder in order 
 		// to build a hierarchy.
 		
-		if(GhostJavaBaseGeom.class.isInstance(geometryObject)) {
+		if( geometryObject instanceof GhostJavaBaseGeom) {
 			
 			if(_debug) System.out.printf("%s: %s  is a ghost volume, dont create elements or physvol\n", getClass().getSimpleName(),geometryObject.getName());
 		
+		} else if(geometryObject.getName().contains("tracking")) {
+			if(_debug) System.out.printf("%s: %s  is the tracking volume, dont create elements or physvol\n", getClass().getSimpleName(),geometryObject.getName());
 		} else {
 
 			// build the physical volume
@@ -200,7 +205,15 @@
 				if(_debug) System.out.printf("%s: create the module detector element\n", getClass().getSimpleName());
 
 				// create the "module" detector element
-				ILogicalVolume trackingVolume = builder.baseTrackerGeometry.getMother().getVolume();
+				ILogicalVolume trackingVolume = null;
+				if(builder.getBaseTrackerGeometry().getName().contains("tracking")) {
+					trackingVolume = builder.getBaseTrackerGeometry().getVolume();
+				} else {
+					trackingVolume = builder.getBaseTrackerGeometry().getMother().getVolume();
+				}
+				if( trackingVolume == null ) {
+					throw new RuntimeException("failed to get tracking geometry from mother to " + builder.getBaseTrackerGeometry().getName()); 
+				}	
 				String moduleName = "TestRunModule";
 				//TODO I'm not sure I need to follow the old style here?
 				moduleName = geometryObject.getName();

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact
HPSTestRunTracker2014JavaBuilder.java 3321 -> 3322
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014JavaBuilder.java	2014-09-14 07:56:37 UTC (rev 3321)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014JavaBuilder.java	2014-09-15 19:24:26 UTC (rev 3322)
@@ -3,44 +3,17 @@
  */
 package org.lcsim.detector.converter.compact;
 
-import hep.physics.vec.BasicHep3Matrix;
-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.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.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.IIdentifierDictionary;
-import org.lcsim.detector.material.IMaterial;
-import org.lcsim.detector.material.MaterialStore;
-import org.lcsim.detector.solids.Box;
-import org.lcsim.detector.tracker.silicon.SiTrackerModule;
-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.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.SupportBottom;
 import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.SupportPlateBottom;
 import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.SupportPlateTop;
 import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.SupportTop;
 import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.TrackingBase;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerJavaBuilder;
 
 
 /**
@@ -50,39 +23,24 @@
  * @author Per Hansson Adrian <[log in to unmask]>
  *
  */
-public class HPSTestRunTracker2014JavaBuilder extends HPSTestRunTracker2014Builder {
+public class HPSTestRunTracker2014JavaBuilder extends HPSTrackerJavaBuilder {
 
-	protected JavaBaseGeometry baseTrackerGeometry;
-	protected List<JavaBaseGeometry> java_objects;
-	protected DetectorIdentifierHelper detectorIdentifierHelper;
-	protected IIdentifierDictionary identifierDictionary;
-	protected Subdetector subdet;
-	private List<IDetectorElement> layerDetectorElements;
-	private List<IDetectorElement> moduleDetectorElements;
 	
+	
 	/**
 	 * Default constructor
 	 */
 	public HPSTestRunTracker2014JavaBuilder(boolean debugFlag) {
 		super(debugFlag);
-		layerDetectorElements = new ArrayList<IDetectorElement>();
-		moduleDetectorElements = new ArrayList<IDetectorElement>();
 	}
 	
-	/**
-	 * Add to list of objects.
-	 * @param geom - object to add.
-	 */
-	private void add(JavaBaseGeometry geom) {
-		java_objects.add(geom);
-	}
 	
 	
 	/**
 	 * Build the JAVA geometry objects from the geometry definition.
 	 * @param trackingVolume - the reference volume.
 	 */
-	protected void build(ILogicalVolume trackingVolume) {
+	public void build(ILogicalVolume trackingVolume) {
 		
 		if(isDebug()) System.out.printf("%s: build the JAVA geometry objects\n", getClass().getSimpleName());
 		
@@ -92,20 +50,20 @@
 		// Go through the list of volumes to build that is created in the generic builder class
 		JavaBaseGeometry trackingGeometry = new JavaBaseGeometry(getBaseGeometry(TrackingBase.class), trackingVolume);
 		add(trackingGeometry);
-		baseTrackerGeometry = new GhostJavaBaseGeom(getBaseGeometry(Base.class), trackingGeometry);
-		add(baseTrackerGeometry);
-		JavaBaseGeometry basePlateGeometry = new GhostJavaBaseGeom(getBaseGeometry(BasePlate.class), baseTrackerGeometry);
+		setBaseTrackerGeometry(new GhostJavaBaseGeom(getBaseGeometry(Base.class), trackingGeometry));
+		add(getBaseTrackerGeometry());
+		JavaBaseGeometry basePlateGeometry = new GhostJavaBaseGeom(getBaseGeometry(BasePlate.class), getBaseTrackerGeometry());
 		add(basePlateGeometry);
 		// skip the c-support, this is purely a reference volume in the builder so should have no use here!?
 		//JavaBaseGeometry cSupportGeometry = new GhostJavaBaseGeom(getBaseGeometry(CSupport.class), baseTrackerGeometry);
 		//add(cSupportGeometry);
-		JavaBaseGeometry supportBottomGeometry = new GhostJavaBaseGeom(getBaseGeometry(SupportBottom.class), baseTrackerGeometry);
+		JavaBaseGeometry supportBottomGeometry = new GhostJavaBaseGeom(getBaseGeometry(SupportBottom.class), getBaseTrackerGeometry());
 		add(supportBottomGeometry);
-		JavaBaseGeometry supportPlateBottomGeometry = new GhostJavaBaseGeom(getBaseGeometry(SupportPlateBottom.class), baseTrackerGeometry);
+		JavaBaseGeometry supportPlateBottomGeometry = new GhostJavaBaseGeom(getBaseGeometry(SupportPlateBottom.class), getBaseTrackerGeometry());
 		add(supportPlateBottomGeometry);
-		JavaBaseGeometry supportTopGeometry = new GhostJavaBaseGeom(getBaseGeometry(SupportTop.class), baseTrackerGeometry);
+		JavaBaseGeometry supportTopGeometry = new GhostJavaBaseGeom(getBaseGeometry(SupportTop.class), getBaseTrackerGeometry());
 		add(supportTopGeometry);
-		JavaBaseGeometry supportPlateTopGeometry = new GhostJavaBaseGeom(getBaseGeometry(SupportPlateTop.class), baseTrackerGeometry);
+		JavaBaseGeometry supportPlateTopGeometry = new GhostJavaBaseGeom(getBaseGeometry(SupportPlateTop.class), getBaseTrackerGeometry());
 		add(supportPlateTopGeometry);
 
 		// build modules	
@@ -231,363 +189,10 @@
 		
 	}
 
-	protected DetectorIdentifierHelper getDetectorIdentifierHelper() {
-		return detectorIdentifierHelper;
-	}
 
-	protected void setDetectorIdentifierHelper(
-			DetectorIdentifierHelper detectorIdentifierHelper) {
-		this.detectorIdentifierHelper = detectorIdentifierHelper;
-	}
-
-	protected IIdentifierDictionary getIdentifierDictionary() {
-		return identifierDictionary;
-	}
-
-	protected void setIdentifierDictionary(
-			IIdentifierDictionary identifierDictionary) {
-		this.identifierDictionary = identifierDictionary;
-	}
-
-
-	protected void setSubdetector(Subdetector subdet) {
-		this.subdet = subdet;
-	}
-
-	protected Subdetector getSubdetector() {
-		return this.subdet;
-	}
-
 	
-	/**
-	 * 
-	 *  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 {
-		
-		/**
-		 * Initialize with base and mother. This is typically for a reference geometry object 
-		 * that is used for referencing coordinate systems but that doesn't have a volume itself.
-		 * @param base - object used to get geometry definitions
-		 * @param mother - mother object
-		 */
-		public GhostJavaBaseGeom(BaseGeometry base, JavaBaseGeometry mother) {
-			super();
-			if(isDebug()) System.out.printf("%s: constructing JAVA ghost object %s with mother %s\n", this.getClass().getSimpleName(),base.getName(),mother==null?"null":mother.getName());
-			setName(base.getName());
-			setMother(mother);
-			mother.addDaughter(this);
-			setPositionAndRotation(base);
-			if(isDebug()) System.out.printf("%s: DONE constructing JAVA object %s\n", this.getClass().getSimpleName(),base.getName());
-		}
-		
 
 
-	}
-
-	/**
-	 *  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 String name;
-		private Box box= null;
-		private ILogicalVolume volume = null;
-		private ITranslation3D pos = null;
-		private IRotation3D rot = null;
-		private IPhysicalVolume physVolume = null;
-		private JavaBaseGeometry mother = null;
-		public List<JavaBaseGeometry> daughters = new ArrayList<JavaBaseGeometry>();
-		private int componentId = -1;
-		
-		/**
-		 *  Default constructor
-		 */
-		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: 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);
-			// since it's tracking volume, set the pos and rotation trivially
-			Hep3Vector lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(geomObject.getCoord().v(), geomObject.getCoord().w(), new BasicHep3Vector(0,1,0),new BasicHep3Vector(0,0,1));
-			setPos(new Translation3D(0,0,0));
-			setRot(new RotationGeant(lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z()));
-			if(isDebug()) System.out.printf("%s: DONE JavaBaseGeometry %s\n", this.getClass().getSimpleName(),geomObject.getName());
-		}
-		
-		/**
-		 * Construct a JAVA geometry object from its geometry definition. 
-		 * @param geomObject - input geometry definition
-		 * @param mother - reference to mother JAVA definition
-		 * @param volumeId - component id number 
-		 */
-		public JavaBaseGeometry(BaseGeometry geomObject, JavaBaseGeometry mother, int volumeId) {
-			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);
-			setPositionAndRotation(geomObject);
-			if(isDebug()) System.out.printf("%s: DONE JavaBaseGeometry %s\n", this.getClass().getSimpleName(),geomObject.getName());
-		}
-
-		protected boolean hasCoordinateSystemInfo() {
-			return pos!=null && rot!=null;
-		}
-		
-		
-		protected void buildPhysVolume() {
-			if(isDebug()) System.out.printf("%s: build phys volume for %s with mother %s and physical mother %s\n", this.getClass().getSimpleName(),getName(),getMother().getName(),getPhysMother().getName());
-			JavaBaseGeometry physMother =  getPhysMother();
-			setPhysVolume(new PhysicalVolume(new Transform3D(getPos(), getRot()), name, volume, physMother.getVolume(),getComponentId()));
-		}
-		protected void buildBox(BaseGeometry base) {
-			Hep3Vector b = base.getBoxDim();
-			b = VecOp.mult(0.5, b);
-			if(isDebug()) System.out.printf("%s: build box for %s with dimensions %s \n", this.getClass().getSimpleName(),getName(), b);
-			setBox(new Box(getName() + "Box", b.x(), b.y(), b.z())); 
-		}
-		protected void buildVolume(BaseGeometry base) {
-			if(isDebug()) System.out.printf("%s: build volume for %s with material %s\n", this.getClass().getSimpleName(),getName(),base.getMaterial());
-				IMaterial material = MaterialStore.getInstance().get(base.getMaterial());
-				setVolume(new LogicalVolume(getName() + "_volume", box, material));
-			
-		}
-		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!?
-			if(base.getMother()==null) throw new RuntimeException("trying to set coordinates w/o mother defined for "+base.getName());
-			
-			// Vector from origin to center of box locally 
-			Hep3Vector box_center_base_local = base.getCenter();
-			
-			// find the physical mother i.e. not a ghost volume and compound transformations to it
-			JavaBaseGeometry physMother =  getPhysMother();
-			if(isDebug()) System.out.printf("%s: physical mother to transform to is %s; find the transform to it\n", this.getClass().getSimpleName(),physMother.getName());
-			Transform3D trf = getTransform(base.getCoord().getTransformation(),base.getMother(),physMother.getName()); 
-			if(isDebug()) System.out.printf("%s: found transform to physical mother \n%s\n\n", this.getClass().getSimpleName(),trf.toString());
-			
-			// find the position of the center in the physical mother coord
-			Hep3Vector box_center_base = trf.transformed(box_center_base_local);
-			
-			// find the position of the center of the box in the mother coordinate system, make sure to use the physical mother coordinates
-			if(isDebug()) System.out.printf("%s: find center of box in physical mother coord %s \n", this.getClass().getSimpleName(),physMother.getName());
-			// hack since my getTransform function needs a mother TODO Fix this!
-			BaseGeometry gm = base;
-			if(isDebug()) System.out.printf("%s: look for physical mother %s starting from mother  \n", this.getClass().getSimpleName(),physMother.getName(),gm.getMother());
-			while((gm=gm.getMother()).getName()!=physMother.getName()) {
-				if(isDebug()) System.out.printf("%s: gm is %s \n", this.getClass().getSimpleName(),gm.getName());
-				//gm = gm.getMother();
-			}
-			if(isDebug()) System.out.printf("%s: found physical mother %s with center at %s \n", this.getClass().getSimpleName(),gm.getName(), gm.getCenter());
-			
-			Hep3Vector mother_center = gm.getCenter();
-
-			// now calculate the position of this box center in the mother LCDD coordinates
-			Hep3Vector box_center = VecOp.sub(box_center_base, mother_center);
-
-			//Find LCDD Euler rotation angles from coordinate system unit vectors
-			//Note that this has to be rotation wrt to physical mother and not just mother as normally is the case
-			//Use apache lib to get angles, but in principle I should already have it from the trf above
-			//Hep3Vector lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(base.getCoord().v(), base.getCoord().w(), new BasicHep3Vector(0,1,0),new BasicHep3Vector(0,0,1));
-			if(isDebug()) System.out.printf("%s: find LCDD Cardan rotation angles - need to find mother to physical mother transform \n", this.getClass().getSimpleName(),physMother.getName());
-			Hep3Vector unit_u = new BasicHep3Vector(1,0,0);
-			Hep3Vector unit_v = new BasicHep3Vector(0,1,0);
-			Hep3Vector unit_w = new BasicHep3Vector(0,0,1);
-			if(!base.getMother().getName().equals(physMother.getName())) {
-				Transform3D trf_mother = getTransform(base.getMother().getCoord().getTransformation(),base.getMother().getMother(),physMother.getName()); 
-				unit_u = VecOp.unit(trf_mother.rotated(unit_u));
-				unit_v = VecOp.unit(trf_mother.rotated(unit_v));
-				unit_w = VecOp.unit(trf_mother.rotated(unit_w));
-				if(isDebug()) System.out.printf("%s: found transform from mother to physical mother \n%s\n", this.getClass().getSimpleName(),trf_mother.toString());
-			} else {
-				if(isDebug()) System.out.printf("%s: mother and physical mother is the same\n",getClass().getSimpleName());
-			}
-			
-		
-			if(isDebug()) System.out.printf("%s: unit vectors to get Cardan angles from become unit_u %s unit_v %s unit_w %s\n", this.getClass().getSimpleName(),unit_u.toString(),unit_v.toString(),unit_w.toString());
-			if(isDebug()) System.out.printf("%s: unit vectors u %s v %s w %s\n", this.getClass().getSimpleName(),base.getCoord().u().toString(),base.getCoord().v().toString(),base.getCoord().w().toString());
-			//Hep3Vector lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(unit_u,unit_v,base.getCoord().u(), base.getCoord().v());
-			Hep3Vector lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(base.getCoord().u(), base.getCoord().v(), unit_u,unit_v);
-			//Hep3Vector lcdd_rot_angles_active = HPSTestRunTracker2014.getActiveEulerAngles(base.getCoord().v(), base.getCoord().w(), unit_v,unit_w);
-			double rot_mat[][] = HPSTestRunTracker2014.getActiveEulerAnglesMatrix(base.getCoord().v(), base.getCoord().w(), unit_v,unit_w);
-			Rotation3D rot_xcheck = new Rotation3D();
-			BasicHep3Matrix rot_mat_hep = new BasicHep3Matrix();
-			for(int c=0;c<=2;++c) {
-				for(int r=0;r<=2;++r) {
-					rot_mat_hep.setElement(r, c, rot_xcheck.getComponent(r, c));
-				}
-			}
-			rot_xcheck.setRotationMatrix(rot_mat_hep);
-			if(isDebug()) {
-				System.out.printf("%s: xcheck active rotation matrix:\n", this.getClass().getSimpleName());
-				HPSTestRunTracker2014.printMatrix(rot_mat);
-				rot_xcheck.toString();
-			}
-			
-			/*
-			
-			// Check if there are explicit rotations built into the object itself which overrides
-			// TODO this should be included in the definition of the coordinate system. Fix this for the affected components.
-			if (base.explicit_rot_angles!=null) {
-				if(isDebug()) System.out.printf("%s: explicit angles to be applied %s\n", this.getClass().getSimpleName(),base.explicit_rot_angles.toString());
-				// there are explicit rotations I need to apply.
-				// Find the displacement of the box center due to rotation about different origin
-				// Find the origin in the physical mother coord
-				if(isDebug()) System.out.printf("%s: transform origin %s to physical mother %s\n", this.getClass().getSimpleName(),base.getCoord().origin(),physMother.getName());
-				Transform3D tpm = getTransform(base.getMother().getCoord().getTransformation(),base.getMother().getMother(),physMother.getName()); 
-				if(isDebug()) System.out.printf("%s: found transform to physical mother \n%s\n\n", this.getClass().getSimpleName(),tpm.toString());
-				Hep3Vector origin_mother = tpm.transformed(base.getCoord().origin());
-				if(isDebug()) System.out.printf("%s: origin in physical mother coord is %s\n", this.getClass().getSimpleName(),origin_mother.toString());
-				Hep3Vector box_center_base_rot = HPSTestRunTracker2014.getRotationDisplacement(origin_mother, box_center_base, base.explicit_rot_angles);
-				if(isDebug()) {
-					System.out.printf("%s: explicit_rot_angles 		  %s\n", this.getClass().getSimpleName(),lcdd_rot_angles);
-					System.out.printf("%s: explicit_rot_angles_2	  %s\n", this.getClass().getSimpleName(),base.explicit_rot_angles);
-					System.out.printf("%s: origin                     %s\n", this.getClass().getSimpleName(), base.getCoord().origin().toString());
-					System.out.printf("%s: origin_mother              %s\n", this.getClass().getSimpleName(), origin_mother.toString());
-					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.explicit_rot_angles;
-				// update the position of the center in the mother coord
-				box_center = VecOp.sub(box_center_base_rot, mother_center);
-			}
-			*/
-
-			// Create the LCDD position
-			setPos(new Translation3D(box_center.x(), box_center.y(), box_center.z()));
-			setRot(new RotationGeant(lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z()));
-			//setRot(new Rotation3D(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());
-				System.out.printf("%s: box_center_base             %s\n", this.getClass().getSimpleName(), box_center_base.toString());
-				System.out.printf("%s: mother center               %s\n", this.getClass().getSimpleName(), base.getMother()==null?" <no mother> ":mother_center.toString());
-				System.out.printf("%s: box_center                  %s\n", this.getClass().getSimpleName(), box_center.toString());
-				System.out.printf("%s: pos                         %s\n", this.getClass().getSimpleName(), getPos().toString());
-				System.out.printf("%s: euler                       %s\n", this.getClass().getSimpleName(), lcdd_rot_angles.toString());
-				//System.out.printf("%s: euler (active)              %s\n", this.getClass().getSimpleName(), lcdd_rot_angles_active.toString());
-				System.out.printf("%s: rot                         %s\n", this.getClass().getSimpleName(), getRot().toString());
-
-				//calculate the position in tracking volume separately as a xcheck
-				Hep3Vector box_center_tracking_xcheck = transformToTracking(box_center_base_local, base);
-				System.out.printf("%s: box_center_tracking_xcheck  %s for %s\n", this.getClass().getSimpleName(), box_center_tracking_xcheck.toString(),base.getName());
-			}
-			
-		}
-
-		/**
-		 * Find the first non-ghost volume among parents.  
-		 * @return mother object
-		 */
-		public JavaBaseGeometry getPhysMother() {
-			//if(isDebug()) System.out.printf("%s: finding physical mother to %s\n", this.getClass().getSimpleName(), getName());
-			if(mother==null) throw new RuntimeException("Trying to get phys mother but there is no mother!");
-			if(mother instanceof GhostJavaBaseGeom) {
-				return mother.getPhysMother();
-			} else {
-				//if(isDebug()) System.out.printf("%s: found a non-ghost volume: %s\n", this.getClass().getSimpleName(), mother.getName());
-				return mother;
-			}
-		}
-		
-		
-		protected ILogicalVolume getVolume() {
-			return volume;
-		}
-		protected void setVolume(ILogicalVolume volume) {
-			this.volume = volume;
-		}
-		protected Box getBox() {
-			return box;
-		}
-		protected void setBox(Box b) {
-			box = b;
-		}	
-		protected String getName() {
-			return name;
-		}
-		protected void setName(String name) {
-			this.name = name;
-		}
-		protected ITranslation3D getPos() {
-			return pos;
-		}
-		protected void setPos(ITranslation3D iTranslation3D) {
-			this.pos = iTranslation3D;
-		}
-		protected IRotation3D getRot() {
-			return rot;
-		}
-		protected void setRot(IRotation3D iRotation3D) {
-			this.rot = iRotation3D;
-		}
-		protected JavaBaseGeometry getMother() {
-			return mother;
-		}
-		protected void setMother(JavaBaseGeometry mother) {
-			this.mother = mother;
-		}
-		protected IPhysicalVolume getPhysVolume() {
-			return physVolume;
-		}
-		protected void setPhysVolume(PhysicalVolume physVolume) {
-			this.physVolume = physVolume;
-		}
-		public boolean isDebug() {
-			return debug;
-		}
-
-		protected List<JavaBaseGeometry> getDaughters() {
-			return daughters;
-		}
-
-		protected void addDaughter(JavaBaseGeometry o) {
-			getDaughters().add(o);
-		}
-
-		public int getComponentId() {
-			return componentId;
-		}
-
-		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;
-		}
-
-	}
-	
-	
-
-
 //	/**
 //	 * Find the transform to a given parent volume.  
 //	 * @param t transformation of the object. 
@@ -621,58 +226,4 @@
 	
 	
 
-	// This finds specific type. I would like to use the ID for this but can't, I think.
-	// TODO there must be a factory instance to do this
-	public SiTrackerModule getModuleDetectorElement(SiTrackerModule testElement) {
-		if(isDebug()) System.out.printf("%s: getModuleDetectorElement for module  %s path: \"%s\"\n", this.getClass().getSimpleName(),testElement.getName(),testElement.getGeometry().getPathString());
-		SiTrackerModule element = null;
-		for(IDetectorElement e : moduleDetectorElements) {
-			SiTrackerModule m = (SiTrackerModule) e;
-			if(isDebug()) System.out.printf("%s: compare with module  %s path: %s\"%s\" \n", this.getClass().getSimpleName(),m.getName(),m.getGeometry().getPathString());
-			if(m.getGeometry().getPathString().equals(testElement.getGeometry().getPathString())) {
-				if(element!=null) throw new RuntimeException("two DE sharing extended ID?");
-				if(isDebug()) System.out.printf("%s: found it\n", this.getClass().getSimpleName());
-				element = m;
-			}
-		}
-		return element;
-	}
-
-	
-	// Find detector elements
-	// TODO This should be using some global geometry code like DetectorElementStore?
-	protected IDetectorElement getLayerDetectorElement(IExpandedIdentifier expId) {
-		IDetectorElement element = null;
-		if(isDebug()) System.out.printf("%s: search among %d layer DEs\n", this.getClass().getSimpleName(), layerDetectorElements.size());
-		for(IDetectorElement e : layerDetectorElements) {
-			if(isDebug()) System.out.printf("%s: test %s\n", this.getClass().getSimpleName(),e.getName());
-			ExpandedIdentifier eId = (ExpandedIdentifier) e.getExpandedIdentifier();
-			if(eId.equals(expId)) { // TODO order matters as expId is an interface without that function!?
-				//check that only one was found
-				if(element!=null) throw new RuntimeException("two DE sharing extended ID?");
-				if(isDebug()) System.out.printf("%s: found it\n", this.getClass().getSimpleName());
-				element = e;
-			}
-
-		}
-		return element;
-	}
-
-
-	protected void addLayerDetectorElement(IDetectorElement e) {
-		IExpandedIdentifier expId = e.getExpandedIdentifier();
-		if(getLayerDetectorElement(expId) != null) 
-			throw new RuntimeException("Trying to add an existing layer detector element.");
-		layerDetectorElements.add(e);
-	}
-	
-	protected void addModuleDetectorElement(IDetectorElement e) {
-		if(!(e instanceof SiTrackerModule)) 
-			throw new RuntimeException("Trying to add an existing module of wrong type.");
-		if(getModuleDetectorElement((SiTrackerModule) e) != null) 
-			throw new RuntimeException("Trying to add an already existing module detector element.");
-		layerDetectorElements.add(e);
-	}
-	
-
 }

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact
HPSTestRunTracker2014Test1JavaBuilder.java added at 3322
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014Test1JavaBuilder.java	                        (rev 0)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014Test1JavaBuilder.java	2014-09-15 19:24:26 UTC (rev 3322)
@@ -0,0 +1,200 @@
+/**
+ * 
+ */
+package org.lcsim.detector.converter.compact;
+
+import java.util.ArrayList;
+
+import org.lcsim.detector.ILogicalVolume;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.TestRunHalfModuleAxial;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.TrackingBase;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerJavaBuilder;
+
+
+/**
+ * Class used by java converter to build java run time objects for the detector
+ * It encapsulates and adds the LCDD specific information to the generic @HPSTestRunTracker2014Builder. 
+ * 
+ * @author Per Hansson Adrian <[log in to unmask]>
+ *
+ */
+public class HPSTestRunTracker2014Test1JavaBuilder extends HPSTrackerJavaBuilder {
+
+	
+	
+	/**
+	 * Default constructor
+	 */
+	public HPSTestRunTracker2014Test1JavaBuilder(boolean debugFlag) {
+		super(debugFlag);
+	}
+	
+	
+	
+	/**
+	 * Build the JAVA geometry objects from the geometry definition.
+	 * @param trackingVolume - the reference volume.
+	 */
+	public void build(ILogicalVolume trackingVolume) {
+		
+		if(isDebug()) System.out.printf("%s: build the JAVA geometry objects\n", getClass().getSimpleName());
+		
+		// initialize the list to store a reference to each object
+		java_objects = new ArrayList<JavaBaseGeometry>();
+
+		// Go through the list of volumes to build that is created in the generic builder class
+		JavaBaseGeometry trackingGeometry = new JavaBaseGeometry(getBaseGeometry(TrackingBase.class), trackingVolume);
+		add(trackingGeometry);
+		setBaseTrackerGeometry(trackingGeometry);
+//		setBaseTrackerGeometry(new GhostJavaBaseGeom(getBaseGeometry(Base.class), trackingGeometry));
+//		add(getBaseTrackerGeometry());
+//		JavaBaseGeometry basePlateGeometry = new GhostJavaBaseGeom(getBaseGeometry(BasePlate.class), getBaseTrackerGeometry());
+//		add(basePlateGeometry);
+//		// skip the c-support, this is purely a reference volume in the builder so should have no use here!?
+//		//JavaBaseGeometry cSupportGeometry = new GhostJavaBaseGeom(getBaseGeometry(CSupport.class), baseTrackerGeometry);
+//		//add(cSupportGeometry);
+//		JavaBaseGeometry supportBottomGeometry = new GhostJavaBaseGeom(getBaseGeometry(SupportBottom.class), getBaseTrackerGeometry());
+//		add(supportBottomGeometry);
+//		JavaBaseGeometry supportPlateBottomGeometry = new GhostJavaBaseGeom(getBaseGeometry(SupportPlateBottom.class), getBaseTrackerGeometry());
+//		add(supportPlateBottomGeometry);
+//		JavaBaseGeometry supportTopGeometry = new GhostJavaBaseGeom(getBaseGeometry(SupportTop.class), getBaseTrackerGeometry());
+//		add(supportTopGeometry);
+//		JavaBaseGeometry supportPlateTopGeometry = new GhostJavaBaseGeom(getBaseGeometry(SupportPlateTop.class), getBaseTrackerGeometry());
+//		add(supportPlateTopGeometry);
+
+		// build modules	
+		
+		if(isDebug()) System.out.printf("%s: build JAVA modules\n", getClass().getSimpleName());
+
+		// Loop over all modules created
+		for(ModuleBundle m : modules) {
+			
+			// Do only L1?
+			if(onlyL1 && m.getLayer()!=1) continue;
+			
+			if(onlyBottom && m.getHalf()!="bottom") continue;
+			
+			if(isDebug()) { 
+				System.out.printf("%s: build module %s (layer %d half %s)\n", getClass().getSimpleName(),m.module.getName(),m.getLayer(),m.getHalf());
+				m.print();
+			}
+
+			JavaBaseGeometry mother = getBaseTrackerGeometry();
+			
+			
+			HalfModuleBundle hmb = m.halfModuleAxial;
+			
+			// Check that it had a mother
+			if(hmb==null) throw new RuntimeException("Cound't find hm bundle");
+
+			TestRunHalfModule hm = hmb.halfModule;
+			TestRunHalfModuleAxial hma = null;
+			if(hm instanceof TestRunHalfModuleAxial) {
+				hma = (TestRunHalfModuleAxial) hm;
+			}
+			// Check that it had a mother
+			if(hma==null) throw new RuntimeException("Cound't find hma");
+			
+			int oldCompactModuleId = 0;
+			JavaBaseGeometry lcddHM = new JavaBaseGeometry(hma, mother,oldCompactModuleId);
+			add(lcddHM);
+			
+			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();
+
+
+	}
+
+	
+	/**
+	 * Rules for adding the JAVA half module geometry.
+	 * @param bundle - module to be added
+	 * @param mother - mother JAVA geometry object
+	 */
+	private void addHalfModule(HalfModuleBundle bundle, JavaBaseGeometry mother) {
+		// Create the half-module
+		// This is not a ghost element but reflects the module 
+		// concept in the old compact description
+		// TODO fix the layer IDs
+		int oldCompactModuleId = 0;
+		JavaBaseGeometry lcddHM = new JavaBaseGeometry(bundle.halfModule, mother,oldCompactModuleId);
+		add(lcddHM);
+		
+		// ComponentNumber is taken from old geometry where it is simply a counter when adding the xml daughters to the TestRunModule.
+		// It is simply 0 for sensor and 1 for carbon fiber in the old geometry 
+		int componentNumber = bundle.sensor.getId();
+
+		// create the sensor
+		JavaBaseGeometry lcddS = new JavaBaseGeometry(bundle.sensor, lcddHM, componentNumber);
+		add(lcddS);
+
+		// create the active sensor
+		JavaBaseGeometry lcddAS = new JavaBaseGeometry(bundle.activeSensor, lcddS, componentNumber);
+		add(lcddAS);
+		
+//		if(isDebug()) {
+//			System.out.printf("%s: added sensor %s \n",this.getClass().getSimpleName(), lcddS.getName());
+//			System.out.printf("%s: local coordinate system\n%s\n",this.getClass().getSimpleName(), bundle.sensor.getCoord().toString());
+//			dsd
+//		}
+		
+		
+	}
+
+
+	
+
+
+//	/**
+//	 * Find the transform to a given parent volume.  
+//	 * @param t transformation of the object. 
+//	 * @param mother of the object
+//	 * @param targetMotherName is the name of the parent volume to transform to.
+//	 * @return translation to the target mother volume.
+//	 */
+//	public static ITransform3D getParentTransform(Transform3D t, JavaBaseGeometry mother, String targetMotherName) {
+//		boolean debug = true;
+//		if(mother==null) throw new RuntimeException("Trying to get mother transform but there is no mother?!");
+//		if(debug) System.out.printf("getParentTransform for mother %s target mother %s with current transform\n%s\n",mother.getName(), targetMotherName, t.toString());
+//		if(mother.getName().equals(targetMotherName)) {
+//			if(debug) System.out.printf("found the target object\n");
+//			return t; 
+//		} else {
+//			// Compound the transforms
+//			ITranslation3D p = mother.getPos();
+//			IRotation3D r = mother.getRot();
+//			if(p==null) throw new RuntimeException("cannot compound transform since the mother " + mother.getName() + " has no translation!?");
+//			if(r==null) throw new RuntimeException("cannot compound transform since the mother " + mother.getName() + " has no rotation!?");
+//			Transform3D tM = new Transform3D(p, r);
+//			if(debug) System.out.printf("add transform\n%s\n",tM.toString());
+//			t.multiplyBy(tM);
+//			if(debug) System.out.printf("resulting transform\n%s\n",((Transform3D)t).toString());
+//			if(debug) System.out.printf("continue searching\n");
+//			return getParentTransform(t, mother.getMother(), targetMotherName);
+//		}
+//	}
+//
+
+	
+	
+
+}

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
HPSTestRunTracker2014.java 3321 -> 3322
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java	2014-09-14 07:56:37 UTC (rev 3321)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java	2014-09-15 19:24:26 UTC (rev 3322)
@@ -35,7 +35,6 @@
 	private boolean _debug = false; 
 	private final boolean buildBeamPlane = true;
 	// Builder class to handle all geometry information
-	//private static HPSTestRunTracker2014LCDDBuilder builder;
 	private static HPSTrackerLCDDBuilder builder;
 	
 	
@@ -80,9 +79,9 @@
 		**/
 		
 		
-		builder = new HPSTestRunTracker2014LCDDBuilder(_debug);
+		//builder = new HPSTestRunTracker2014LCDDBuilder(_debug);
+		builder = new HPSTestRunTracker2014Test1LCDDBuilder(_debug);	
 		
-		
 		// ID of the detector.
 		int id = this.node.getAttribute("id").getIntValue();
 
@@ -171,27 +170,36 @@
 		
 		if(_debug) System.out.printf("%s: adding %s to LCDD\n", getClass().getSimpleName(),lcddObj.getName());
 
-		if(lcddObj.getClass().isInstance(GhostLCDDBaseGeometry.class)) {
-			System.out.printf("%s: trying to add a ghost volume: %s ??\n", getClass().getSimpleName(),lcddObj.getName());
-			throw new RuntimeException("adding a ghost volume (" + lcddObj.getName() + ") to LCDD is not allowed.");
+		boolean doAdd = true;
+		if(lcddObj.getName().contains("tracking")) doAdd=false;
+		
+		if(doAdd) {
+
+			// only world/tracking volume can be ghost here?!
+			if(lcddObj instanceof GhostLCDDBaseGeometry ) {
+				System.out.printf("%s: trying to add a ghost volume: %s ??\n", getClass().getSimpleName(),lcddObj.getName());
+				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());
+			lcdd.add(lcddObj.getPos());
+			lcdd.add(lcddObj.getRot());
+			lcddObj.buildPhysVolume();
+			// Set the phys volume Id's
+			// Since the builder don't have access to the system ID
+			// I keep the phys volume ID's outside. I think these 
+			// should belong to the builder to avoid repeating it in 
+			// the java converter
+			// TODO move this to the builder for each volume
+			try {
+				setPhysicalVolumeProperties(lcddObj, sd);
+			} catch (DataConversionException e) {
+				e.printStackTrace();
+			}
+		} else {
+			if(_debug) System.out.printf("%s:  skip building anything (name=%s)\n", getClass().getSimpleName(),lcddObj.getName());
 		}
-		// add box, pos, rotation and create phys volume
-		lcdd.add(lcddObj.getBox());
-		lcdd.add(lcddObj.getPos());
-		lcdd.add(lcddObj.getRot());
-		lcddObj.buildPhysVolume();
-		// Set the phys volume Id's
-		// Since the builder don't have access to the system ID
-		// I keep the phys volume ID's outside. I think these 
-		// should belong to the builder to avoid repeating it in 
-		// the java converter
-		// TODO move this to the builder for each volume
-		try {
-			setPhysicalVolumeProperties(lcddObj, sd);
-		} catch (DataConversionException e) {
-			e.printStackTrace();
-		}
-
+		
 		// add daughters
 		if(_debug) System.out.printf("%s: add %d daughters to %s\n", getClass().getSimpleName(),lcddObj.getDaughters().size(),lcddObj.getName());
 		for(LCDDBaseGeometry daughter : lcddObj.getDaughters()) {
@@ -199,10 +207,13 @@
 		}
 		
 		// finally add volume
-		if(_debug) System.out.printf("%s: adding volume %s\n", getClass().getSimpleName(),lcddObj.getName());
-		if(!lcddObj.getVisName().isEmpty()) lcddObj.getVolume().setVisAttributes(lcdd.getVisAttributes(lcddObj.getVisName()));
-		lcdd.add(lcddObj.getVolume());
-
+		if(doAdd) {
+			if(_debug) System.out.printf("%s: adding volume %s\n", getClass().getSimpleName(),lcddObj.getName());
+			if(!lcddObj.getVisName().isEmpty()) lcddObj.getVolume().setVisAttributes(lcdd.getVisAttributes(lcddObj.getVisName()));
+			lcdd.add(lcddObj.getVolume());
+		} else {
+			if(_debug) System.out.printf("%s: skip adding volume %s\n", getClass().getSimpleName(),lcddObj.getName());
+		}
 		if(_debug) System.out.printf("%s: DONE adding %s\n", getClass().getSimpleName(),lcddObj.getName());
 	}
 	

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
HPSTestRunTracker2014Test1LCDDBuilder.java 3321 -> 3322
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014Test1LCDDBuilder.java	2014-09-14 07:56:37 UTC (rev 3321)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014Test1LCDDBuilder.java	2014-09-15 19:24:26 UTC (rev 3322)
@@ -3,8 +3,11 @@
 import java.util.ArrayList;
 
 import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.BaseGeometry;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule;
 import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.TestRunHalfModuleAxial;
 import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.TrackingBase;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerBuilder.ModuleBundle;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTrackerLCDDBuilder.LCDDBaseGeometry;
 import org.lcsim.geometry.compact.converter.lcdd.util.Volume;
 
 /**
@@ -53,15 +56,40 @@
 		// Find the mother among the LCDD objects using its name, should probably have a better way...
 		LCDDBaseGeometry mother = trackingGeometry;
 
+		// Loop over all modules created
+		for(ModuleBundle m : modules) {
 
-		// create the half-module
-		
-		BaseGeometry halfModule = getBaseGeometry(TestRunHalfModuleAxial.class);
-		LCDDBaseGeometry lcddHM = new LCDDBaseGeometry(halfModule, lcdd, mother);
-		add(lcddHM);
+			// Do only L1?
+			if(onlyL1 && m.getLayer()!=1) continue;
 
+			if(onlyBottom && m.getHalf()!="bottom") continue;
 
+			if(isDebug()) { 
+				System.out.printf("%s: module layer %d half %s\n", getClass().getSimpleName(),m.getLayer(),m.getHalf());
+				m.print();
+			}
+			
+			HalfModuleBundle hmb = m.halfModuleAxial;
+			
+			// Check that it had a mother
+			if(hmb==null) throw new RuntimeException("Cound't find hm bundle");
 
+			TestRunHalfModule hm = hmb.halfModule;
+			TestRunHalfModuleAxial hma = null;
+			if(hm instanceof TestRunHalfModuleAxial) {
+				hma = (TestRunHalfModuleAxial) hm;
+			}
+			// Check that it had a mother
+			if(hma==null) throw new RuntimeException("Cound't find hma");
+			//BaseGeometry halfModule = getBaseGeometry(TestRunHalfModuleAxial.class);
+			LCDDBaseGeometry lcddHM = new LCDDBaseGeometry(hma, lcdd, mother);
+			add(lcddHM);
+
+			
+		}
+
+
+
 		//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());

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
HPSTrackerBuilder.java 3321 -> 3322
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTrackerBuilder.java	2014-09-14 07:56:37 UTC (rev 3321)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTrackerBuilder.java	2014-09-15 19:24:26 UTC (rev 3322)
@@ -12,7 +12,7 @@
 
 public class HPSTrackerBuilder {
 
-	private boolean debug = false;
+	private boolean debug = true;
 	public List<ModuleBundle> modules;
 	protected List<HPSTestRunTracker2014GeometryDefinition.BaseGeometry> geometries = new ArrayList<HPSTestRunTracker2014GeometryDefinition.BaseGeometry>();
 
@@ -144,10 +144,10 @@
 	 * @return the found type.
 	 */
 	protected <T> T getBaseGeometry(Class<T> c) {
-		///if(isDebug()) System.out.printf("%s: get Item %s\n", this.getClass().getSimpleName(),c.getName());
+		if(isDebug()) System.out.printf("%s: get Item %s\n", this.getClass().getSimpleName(),c.getName());
 		
 		for(HPSTestRunTracker2014GeometryDefinition.BaseGeometry item : geometries) {
-			//if(isDebug()) System.out.printf("%s: item %s\n", getClass().getSimpleName(),item.getClass().getName());
+			if(isDebug()) System.out.printf("%s: item %s\n", getClass().getSimpleName(),item.getClass().getName());
 			if(c.isInstance(item)) {
 				return (T)item;
 			}

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
HPSTrackerJavaBuilder.java added at 3322
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTrackerJavaBuilder.java	                        (rev 0)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTrackerJavaBuilder.java	2014-09-15 19:24:26 UTC (rev 3322)
@@ -0,0 +1,488 @@
+package org.lcsim.geometry.compact.converter.lcdd;
+
+import hep.physics.vec.BasicHep3Matrix;
+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.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.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.IIdentifierDictionary;
+import org.lcsim.detector.material.IMaterial;
+import org.lcsim.detector.material.MaterialStore;
+import org.lcsim.detector.solids.Box;
+import org.lcsim.detector.tracker.silicon.SiTrackerModule;
+import org.lcsim.geometry.compact.Subdetector;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.BaseGeometry;
+
+public abstract class HPSTrackerJavaBuilder extends HPSTestRunTracker2014Builder implements IHPSTrackerJavaBuilder {
+
+	private JavaBaseGeometry baseTrackerGeometry;
+	protected List<JavaBaseGeometry> java_objects;
+	protected DetectorIdentifierHelper detectorIdentifierHelper;
+	protected IIdentifierDictionary identifierDictionary;
+	protected Subdetector subdet;
+	protected List<IDetectorElement> layerDetectorElements;
+	protected List<IDetectorElement> moduleDetectorElements;
+	
+	public HPSTrackerJavaBuilder(boolean debugFlag) {
+		super(debugFlag);
+		layerDetectorElements = new ArrayList<IDetectorElement>();
+		moduleDetectorElements = new ArrayList<IDetectorElement>();
+
+	}
+	
+	/**
+	 * Add to list of objects.
+	 * @param geom - object to add.
+	 */
+	public void add(JavaBaseGeometry geom) {
+		java_objects.add(geom);
+	}
+	
+
+	public abstract void build(ILogicalVolume trackingVolume);
+
+	public DetectorIdentifierHelper getDetectorIdentifierHelper() {
+		return detectorIdentifierHelper;
+	}
+
+	public void setDetectorIdentifierHelper(
+			DetectorIdentifierHelper detectorIdentifierHelper) {
+		this.detectorIdentifierHelper = detectorIdentifierHelper;
+	}
+
+	public IIdentifierDictionary getIdentifierDictionary() {
+		return identifierDictionary;
+	}
+
+	public void setIdentifierDictionary(
+			IIdentifierDictionary identifierDictionary) {
+		this.identifierDictionary = identifierDictionary;
+	}
+
+
+	public void setSubdetector(Subdetector subdet) {
+		this.subdet = subdet;
+	}
+
+	public Subdetector getSubdetector() {
+		return this.subdet;
+	}
+
+	
+
+	
+
+	// This finds specific type. I would like to use the ID for this but can't, I think.
+	// TODO there must be a factory instance to do this
+	public SiTrackerModule getModuleDetectorElement(SiTrackerModule testElement) {
+		if(isDebug()) System.out.printf("%s: getModuleDetectorElement for module  %s path: \"%s\"\n", this.getClass().getSimpleName(),testElement.getName(),testElement.getGeometry().getPathString());
+		SiTrackerModule element = null;
+		for(IDetectorElement e : moduleDetectorElements) {
+			SiTrackerModule m = (SiTrackerModule) e;
+			if(isDebug()) System.out.printf("%s: compare with module  %s path: %s\"%s\" \n", this.getClass().getSimpleName(),m.getName(),m.getGeometry().getPathString());
+			if(m.getGeometry().getPathString().equals(testElement.getGeometry().getPathString())) {
+				if(element!=null) throw new RuntimeException("two DE sharing extended ID?");
+				if(isDebug()) System.out.printf("%s: found it\n", this.getClass().getSimpleName());
+				element = m;
+			}
+		}
+		return element;
+	}
+
+	
+	// Find detector elements
+	// TODO This should be using some global geometry code like DetectorElementStore?
+	public IDetectorElement getLayerDetectorElement(IExpandedIdentifier expId) {
+		IDetectorElement element = null;
+		if(isDebug()) System.out.printf("%s: search among %d layer DEs\n", this.getClass().getSimpleName(), layerDetectorElements.size());
+		for(IDetectorElement e : layerDetectorElements) {
+			if(isDebug()) System.out.printf("%s: test %s\n", this.getClass().getSimpleName(),e.getName());
+			ExpandedIdentifier eId = (ExpandedIdentifier) e.getExpandedIdentifier();
+			if(eId.equals(expId)) { // TODO order matters as expId is an interface without that function!?
+				//check that only one was found
+				if(element!=null) throw new RuntimeException("two DE sharing extended ID?");
+				if(isDebug()) System.out.printf("%s: found it\n", this.getClass().getSimpleName());
+				element = e;
+			}
+
+		}
+		return element;
+	}
+
+
+	public void addLayerDetectorElement(IDetectorElement e) {
+		IExpandedIdentifier expId = e.getExpandedIdentifier();
+		if(getLayerDetectorElement(expId) != null) 
+			throw new RuntimeException("Trying to add an existing layer detector element.");
+		layerDetectorElements.add(e);
+	}
+	
+	public void addModuleDetectorElement(IDetectorElement e) {
+		if(!(e instanceof SiTrackerModule)) 
+			throw new RuntimeException("Trying to add an existing module of wrong type.");
+		if(getModuleDetectorElement((SiTrackerModule) e) != null) 
+			throw new RuntimeException("Trying to add an already existing module detector element.");
+		layerDetectorElements.add(e);
+	}
+	
+
+	/**
+	 * @return the baseTrackerGeometry
+	 */
+	public JavaBaseGeometry getBaseTrackerGeometry() {
+		return baseTrackerGeometry;
+	}
+
+	/**
+	 * @param baseTrackerGeometry the baseTrackerGeometry to set
+	 */
+	public void setBaseTrackerGeometry(JavaBaseGeometry baseTrackerGeometry) {
+		this.baseTrackerGeometry = baseTrackerGeometry;
+	}
+
+
+	/**
+	 * 
+	 *  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]>
+	 */
+	public static class GhostJavaBaseGeom extends JavaBaseGeometry {
+		
+		/**
+		 * Initialize with base and mother. This is typically for a reference geometry object 
+		 * that is used for referencing coordinate systems but that doesn't have a volume itself.
+		 * @param base - object used to get geometry definitions
+		 * @param mother - mother object
+		 */
+		public GhostJavaBaseGeom(BaseGeometry base, JavaBaseGeometry mother) {
+			super();
+			if(isDebug()) System.out.printf("%s: constructing JAVA ghost object %s with mother %s\n", this.getClass().getSimpleName(),base.getName(),mother==null?"null":mother.getName());
+			setName(base.getName());
+			setMother(mother);
+			mother.addDaughter(this);
+			setPositionAndRotation(base);
+			if(isDebug()) System.out.printf("%s: DONE constructing JAVA object %s\n", this.getClass().getSimpleName(),base.getName());
+		}
+		
+
+
+	}
+
+	/**
+	 *  Interface to the JAVA converter geometry for the geometry definition.  
+	 * @author Per Hansson Adrian <[log in to unmask]>
+	 */
+	public static class JavaBaseGeometry {
+		private boolean debug = true;
+		private String name;
+		private Box box= null;
+		private ILogicalVolume volume = null;
+		private ITranslation3D pos = null;
+		private IRotation3D rot = null;
+		private IPhysicalVolume physVolume = null;
+		private JavaBaseGeometry mother = null;
+		public List<JavaBaseGeometry> daughters = new ArrayList<JavaBaseGeometry>();
+		private int componentId = -1;
+		
+		/**
+		 *  Default constructor
+		 */
+		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: 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);
+			// since it's tracking volume, set the pos and rotation trivially
+			Hep3Vector lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(geomObject.getCoord().v(), geomObject.getCoord().w(), new BasicHep3Vector(0,1,0),new BasicHep3Vector(0,0,1));
+			setPos(new Translation3D(0,0,0));
+			setRot(new RotationGeant(lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z()));
+			if(isDebug()) System.out.printf("%s: DONE JavaBaseGeometry %s\n", this.getClass().getSimpleName(),geomObject.getName());
+		}
+		
+		/**
+		 * Construct a JAVA geometry object from its geometry definition. 
+		 * @param geomObject - input geometry definition
+		 * @param mother - reference to mother JAVA definition
+		 * @param volumeId - component id number 
+		 */
+		public JavaBaseGeometry(BaseGeometry geomObject, JavaBaseGeometry mother, int volumeId) {
+			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);
+			setPositionAndRotation(geomObject);
+			if(isDebug()) System.out.printf("%s: DONE JavaBaseGeometry %s\n", this.getClass().getSimpleName(),geomObject.getName());
+		}
+
+		protected boolean hasCoordinateSystemInfo() {
+			return pos!=null && rot!=null;
+		}
+		
+		
+		public void buildPhysVolume() {
+			if(isDebug()) System.out.printf("%s: build phys volume for %s with mother %s and physical mother %s\n", this.getClass().getSimpleName(),getName(),getMother().getName(),getPhysMother().getName());
+			JavaBaseGeometry physMother =  getPhysMother();
+			setPhysVolume(new PhysicalVolume(new Transform3D(getPos(), getRot()), name, volume, physMother.getVolume(),getComponentId()));
+		}
+		protected void buildBox(BaseGeometry base) {
+			Hep3Vector b = base.getBoxDim();
+			b = VecOp.mult(0.5, b);
+			if(isDebug()) System.out.printf("%s: build box for %s with dimensions %s \n", this.getClass().getSimpleName(),getName(), b);
+			setBox(new Box(getName() + "Box", b.x(), b.y(), b.z())); 
+		}
+		protected void buildVolume(BaseGeometry base) {
+			if(isDebug()) System.out.printf("%s: build volume for %s with material %s\n", this.getClass().getSimpleName(),getName(),base.getMaterial());
+				IMaterial material = MaterialStore.getInstance().get(base.getMaterial());
+				setVolume(new LogicalVolume(getName() + "_volume", box, material));
+			
+		}
+		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!?
+			if(base.getMother()==null) throw new RuntimeException("trying to set coordinates w/o mother defined for "+base.getName());
+			
+			// Vector from origin to center of box locally 
+			Hep3Vector box_center_base_local = base.getCenter();
+			
+			// find the physical mother i.e. not a ghost volume and compound transformations to it
+			JavaBaseGeometry physMother =  getPhysMother();
+			if(isDebug()) System.out.printf("%s: physical mother to transform to is %s; find the transform to it\n", this.getClass().getSimpleName(),physMother.getName());
+			Transform3D trf = getTransform(base.getCoord().getTransformation(),base.getMother(),physMother.getName()); 
+			if(isDebug()) System.out.printf("%s: found transform to physical mother \n%s\n\n", this.getClass().getSimpleName(),trf.toString());
+			
+			// find the position of the center in the physical mother coord
+			Hep3Vector box_center_base = trf.transformed(box_center_base_local);
+			
+			// find the position of the center of the box in the mother coordinate system, make sure to use the physical mother coordinates
+			if(isDebug()) System.out.printf("%s: find center of box in physical mother coord %s \n", this.getClass().getSimpleName(),physMother.getName());
+			// hack since my getTransform function needs a mother TODO Fix this!
+			BaseGeometry gm = base;
+			if(isDebug()) System.out.printf("%s: look for physical mother %s starting from mother  \n", this.getClass().getSimpleName(),physMother.getName(),gm.getMother());
+			while((gm=gm.getMother()).getName()!=physMother.getName()) {
+				if(isDebug()) System.out.printf("%s: gm is %s \n", this.getClass().getSimpleName(),gm.getName());
+				//gm = gm.getMother();
+			}
+			if(isDebug()) System.out.printf("%s: found physical mother %s with center at %s \n", this.getClass().getSimpleName(),gm.getName(), gm.getCenter());
+			
+			Hep3Vector mother_center = gm.getCenter();
+
+			// now calculate the position of this box center in the mother LCDD coordinates
+			Hep3Vector box_center = VecOp.sub(box_center_base, mother_center);
+
+			//Find LCDD Euler rotation angles from coordinate system unit vectors
+			//Note that this has to be rotation wrt to physical mother and not just mother as normally is the case
+			//Use apache lib to get angles, but in principle I should already have it from the trf above
+			//Hep3Vector lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(base.getCoord().v(), base.getCoord().w(), new BasicHep3Vector(0,1,0),new BasicHep3Vector(0,0,1));
+			if(isDebug()) System.out.printf("%s: find LCDD Cardan rotation angles - need to find mother to physical mother transform \n", this.getClass().getSimpleName(),physMother.getName());
+			Hep3Vector unit_u = new BasicHep3Vector(1,0,0);
+			Hep3Vector unit_v = new BasicHep3Vector(0,1,0);
+			Hep3Vector unit_w = new BasicHep3Vector(0,0,1);
+			if(!base.getMother().getName().equals(physMother.getName())) {
+				Transform3D trf_mother = getTransform(base.getMother().getCoord().getTransformation(),base.getMother().getMother(),physMother.getName()); 
+				unit_u = VecOp.unit(trf_mother.rotated(unit_u));
+				unit_v = VecOp.unit(trf_mother.rotated(unit_v));
+				unit_w = VecOp.unit(trf_mother.rotated(unit_w));
+				if(isDebug()) System.out.printf("%s: found transform from mother to physical mother \n%s\n", this.getClass().getSimpleName(),trf_mother.toString());
+			} else {
+				if(isDebug()) System.out.printf("%s: mother and physical mother is the same\n",getClass().getSimpleName());
+			}
+			
+		
+			if(isDebug()) System.out.printf("%s: unit vectors to get Cardan angles from become unit_u %s unit_v %s unit_w %s\n", this.getClass().getSimpleName(),unit_u.toString(),unit_v.toString(),unit_w.toString());
+			if(isDebug()) System.out.printf("%s: unit vectors u %s v %s w %s\n", this.getClass().getSimpleName(),base.getCoord().u().toString(),base.getCoord().v().toString(),base.getCoord().w().toString());
+			//Hep3Vector lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(unit_u,unit_v,base.getCoord().u(), base.getCoord().v());
+			Hep3Vector lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(base.getCoord().u(), base.getCoord().v(), unit_u,unit_v);
+			//Hep3Vector lcdd_rot_angles_active = HPSTestRunTracker2014.getActiveEulerAngles(base.getCoord().v(), base.getCoord().w(), unit_v,unit_w);
+			double rot_mat[][] = HPSTestRunTracker2014.getActiveEulerAnglesMatrix(base.getCoord().v(), base.getCoord().w(), unit_v,unit_w);
+			Rotation3D rot_xcheck = new Rotation3D();
+			BasicHep3Matrix rot_mat_hep = new BasicHep3Matrix();
+			for(int c=0;c<=2;++c) {
+				for(int r=0;r<=2;++r) {
+					rot_mat_hep.setElement(r, c, rot_xcheck.getComponent(r, c));
+				}
+			}
+			rot_xcheck.setRotationMatrix(rot_mat_hep);
+			if(isDebug()) {
+				System.out.printf("%s: xcheck active rotation matrix:\n", this.getClass().getSimpleName());
+				HPSTestRunTracker2014.printMatrix(rot_mat);
+				rot_xcheck.toString();
+			}
+			
+			/*
+			
+			// Check if there are explicit rotations built into the object itself which overrides
+			// TODO this should be included in the definition of the coordinate system. Fix this for the affected components.
+			if (base.explicit_rot_angles!=null) {
+				if(isDebug()) System.out.printf("%s: explicit angles to be applied %s\n", this.getClass().getSimpleName(),base.explicit_rot_angles.toString());
+				// there are explicit rotations I need to apply.
+				// Find the displacement of the box center due to rotation about different origin
+				// Find the origin in the physical mother coord
+				if(isDebug()) System.out.printf("%s: transform origin %s to physical mother %s\n", this.getClass().getSimpleName(),base.getCoord().origin(),physMother.getName());
+				Transform3D tpm = getTransform(base.getMother().getCoord().getTransformation(),base.getMother().getMother(),physMother.getName()); 
+				if(isDebug()) System.out.printf("%s: found transform to physical mother \n%s\n\n", this.getClass().getSimpleName(),tpm.toString());
+				Hep3Vector origin_mother = tpm.transformed(base.getCoord().origin());
+				if(isDebug()) System.out.printf("%s: origin in physical mother coord is %s\n", this.getClass().getSimpleName(),origin_mother.toString());
+				Hep3Vector box_center_base_rot = HPSTestRunTracker2014.getRotationDisplacement(origin_mother, box_center_base, base.explicit_rot_angles);
+				if(isDebug()) {
+					System.out.printf("%s: explicit_rot_angles 		  %s\n", this.getClass().getSimpleName(),lcdd_rot_angles);
+					System.out.printf("%s: explicit_rot_angles_2	  %s\n", this.getClass().getSimpleName(),base.explicit_rot_angles);
+					System.out.printf("%s: origin                     %s\n", this.getClass().getSimpleName(), base.getCoord().origin().toString());
+					System.out.printf("%s: origin_mother              %s\n", this.getClass().getSimpleName(), origin_mother.toString());
+					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.explicit_rot_angles;
+				// update the position of the center in the mother coord
+				box_center = VecOp.sub(box_center_base_rot, mother_center);
+			}
+			*/
+
+			// Create the LCDD position
+			setPos(new Translation3D(box_center.x(), box_center.y(), box_center.z()));
+			setRot(new RotationGeant(lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z()));
+			//setRot(new Rotation3D(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());
+				System.out.printf("%s: box_center_base             %s\n", this.getClass().getSimpleName(), box_center_base.toString());
+				System.out.printf("%s: mother center               %s\n", this.getClass().getSimpleName(), base.getMother()==null?" <no mother> ":mother_center.toString());
+				System.out.printf("%s: box_center                  %s\n", this.getClass().getSimpleName(), box_center.toString());
+				System.out.printf("%s: pos                         %s\n", this.getClass().getSimpleName(), getPos().toString());
+				System.out.printf("%s: euler                       %s\n", this.getClass().getSimpleName(), lcdd_rot_angles.toString());
+				//System.out.printf("%s: euler (active)              %s\n", this.getClass().getSimpleName(), lcdd_rot_angles_active.toString());
+				System.out.printf("%s: rot                         %s\n", this.getClass().getSimpleName(), getRot().toString());
+
+				//calculate the position in tracking volume separately as a xcheck
+				Hep3Vector box_center_tracking_xcheck = transformToTracking(box_center_base_local, base);
+				System.out.printf("%s: box_center_tracking_xcheck  %s for %s\n", this.getClass().getSimpleName(), box_center_tracking_xcheck.toString(),base.getName());
+			}
+			
+		}
+
+		/**
+		 * Find the first non-ghost volume among parents.  
+		 * @return mother object
+		 */
+		public JavaBaseGeometry getPhysMother() {
+			//if(isDebug()) System.out.printf("%s: finding physical mother to %s\n", this.getClass().getSimpleName(), getName());
+			if(mother==null) throw new RuntimeException("Trying to get phys mother but there is no mother!");
+			if(mother instanceof GhostJavaBaseGeom) {
+				return mother.getPhysMother();
+			} else {
+				//if(isDebug()) System.out.printf("%s: found a non-ghost volume: %s\n", this.getClass().getSimpleName(), mother.getName());
+				return mother;
+			}
+		}
+		
+		
+		public ILogicalVolume getVolume() {
+			return volume;
+		}
+		protected void setVolume(ILogicalVolume volume) {
+			this.volume = volume;
+		}
+		protected Box getBox() {
+			return box;
+		}
+		protected void setBox(Box b) {
+			box = b;
+		}	
+		public String getName() {
+			return name;
+		}
+		protected void setName(String name) {
+			this.name = name;
+		}
+		protected ITranslation3D getPos() {
+			return pos;
+		}
+		protected void setPos(ITranslation3D iTranslation3D) {
+			this.pos = iTranslation3D;
+		}
+		protected IRotation3D getRot() {
+			return rot;
+		}
+		protected void setRot(IRotation3D iRotation3D) {
+			this.rot = iRotation3D;
+		}
+		public JavaBaseGeometry getMother() {
+			return mother;
+		}
+		protected void setMother(JavaBaseGeometry mother) {
+			this.mother = mother;
+		}
+		public IPhysicalVolume getPhysVolume() {
+			return physVolume;
+		}
+		protected void setPhysVolume(PhysicalVolume physVolume) {
+			this.physVolume = physVolume;
+		}
+		public boolean isDebug() {
+			return debug;
+		}
+
+		public List<JavaBaseGeometry> getDaughters() {
+			return daughters;
+		}
+
+		protected void addDaughter(JavaBaseGeometry o) {
+			getDaughters().add(o);
+		}
+
+		public int getComponentId() {
+			return componentId;
+		}
+
+		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
HPSTrackerLCDDBuilder.java 3321 -> 3322
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTrackerLCDDBuilder.java	2014-09-14 07:56:37 UTC (rev 3321)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTrackerLCDDBuilder.java	2014-09-15 19:24:26 UTC (rev 3322)
@@ -31,7 +31,7 @@
 	 *   
 	 * @author Per Hansson Adrian <[log in to unmask]>
 	 */
-	protected static class LCDDBaseGeometry extends LCDDBaseGeometryVisualization {
+	public static class LCDDBaseGeometry extends LCDDBaseGeometryVisualization {
 		private boolean debug = false;
 		private String name;
 		private Box box= null;

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
IHPSTrackerJavaBuilder.java added at 3322
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/IHPSTrackerJavaBuilder.java	                        (rev 0)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/IHPSTrackerJavaBuilder.java	2014-09-15 19:24:26 UTC (rev 3322)
@@ -0,0 +1,31 @@
+package org.lcsim.geometry.compact.converter.lcdd;
+
+import org.lcsim.detector.DetectorIdentifierHelper;
+import org.lcsim.detector.ILogicalVolume;
+import org.lcsim.detector.identifier.IIdentifierDictionary;
+import org.lcsim.geometry.compact.Subdetector;
+
+public interface IHPSTrackerJavaBuilder {
+
+	/**
+	 * Build the JAVA geometry objects from the geometry definition.
+	 * @param trackingVolume - the reference volume.
+	 */
+	public void build(ILogicalVolume trackingVolume);
+	
+	public DetectorIdentifierHelper getDetectorIdentifierHelper();
+
+	public void setDetectorIdentifierHelper(
+			DetectorIdentifierHelper detectorIdentifierHelper);
+
+	public IIdentifierDictionary getIdentifierDictionary();
+
+	public void setIdentifierDictionary(
+			IIdentifierDictionary identifierDictionary);
+
+
+	public void setSubdetector(Subdetector subdet);
+
+	public Subdetector getSubdetector();
+	
+}
\ 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