Print

Print


Commit in projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd on MAIN
HPSTestRunTracker2014.java+94-403202 -> 3203
Moved out old geom definition to builder class and started bringing up the use of the LCDD builder class. Work in progress.

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
HPSTestRunTracker2014.java 3202 -> 3203
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java	2014-07-24 23:02:45 UTC (rev 3202)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java	2014-07-24 23:04:27 UTC (rev 3203)
@@ -22,11 +22,8 @@
 import org.lcsim.detector.RotationGeant;
 import org.lcsim.detector.Transform3D;
 import org.lcsim.detector.Translation3D;
-import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeomDef.BaseGeom;
-import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeomDef.HalfModuleLamination;
-import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeomDef.TestRunColdBlockL13;
-import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeomDef.TestRunColdBlockL45;
-import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeomDef.TestRunModule;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014LCDDBuilder.BaseGeom;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014LCDDBuilder.GhostBaseGeom;
 import org.lcsim.geometry.compact.converter.lcdd.util.Box;
 import org.lcsim.geometry.compact.converter.lcdd.util.LCDD;
 import org.lcsim.geometry.compact.converter.lcdd.util.Material;
@@ -49,32 +46,15 @@
 	private boolean _debug = true; 
 	private final boolean buildBeamPlane = true;
 	
+	private static HPSTestRunTracker2014LCDDBuilder builder;
 	
-	private static HPSTestRunTracker2014GeomDef.TrackingBase tracking; 
-	private static HPSTestRunTracker2014GeomDef.Base base; 
-	private static HPSTestRunTracker2014GeomDef.BasePlate basePlate; 
-	private static HPSTestRunTracker2014GeomDef.CSupport cSupport; 
-	private static HPSTestRunTracker2014GeomDef.SupportBottom supportBottom; 
-	private static HPSTestRunTracker2014GeomDef.SupportPlateBottom supportPlateBottom; 
-	private static HPSTestRunTracker2014GeomDef.SupportTop supportTop; 
-	private static HPSTestRunTracker2014GeomDef.SupportPlateTop supportPlateTop; 
-	private static List<HPSTestRunTracker2014GeomDef.TestRunModule> modules;
-	
-	
-	
 	public HPSTestRunTracker2014(Element node) throws JDOMException
 	{
 		super(node);
-		tracking = new HPSTestRunTracker2014GeomDef.TrackingBase("trackingVolume",null);
-		base = new HPSTestRunTracker2014GeomDef.Base("base",tracking);
-		basePlate = new HPSTestRunTracker2014GeomDef.BasePlate("baseplate",base);
-		cSupport = new HPSTestRunTracker2014GeomDef.CSupport("c_support", base);
-		supportBottom = new HPSTestRunTracker2014GeomDef.SupportBottom("support_bottom", base, cSupport);
-		supportPlateBottom = new HPSTestRunTracker2014GeomDef.SupportPlateBottom("support_plate_bottom", supportBottom);
-		supportTop = new HPSTestRunTracker2014GeomDef.SupportTop("support_top", base, cSupport);
-		supportPlateTop= new HPSTestRunTracker2014GeomDef.SupportPlateTop("support_plate_top", supportTop);
-		modules = new ArrayList<HPSTestRunTracker2014GeomDef.TestRunModule>();
-
+		builder = new HPSTestRunTracker2014LCDDBuilder(_debug);
+		
+		
+		
 	}
 
 	
@@ -90,6 +70,8 @@
 	public void addToLCDD(LCDD lcdd, SensitiveDetector sens) throws JDOMException
 	{
 		
+		
+		
 		/** General comments
 		// Roll: rotation around x
 		// pitch: rotation around y
@@ -110,13 +92,22 @@
 		// Name of the detector.
 		String detector_name = this.node.getAttributeValue("name");
 
-		if(_debug) {
-			print(String.format("detector id %d name %s", id,detector_name));
-		}
+		if(_debug) System.out.printf("%s: detector id %d name %s",getClass().getSimpleName(), id,detector_name);
 		
+		
 		// Pick the mother volume (tracking volume).
 		Volume trackingVolume = lcdd.pickMotherVolume(this);
 
+		
+		// setup and build the LCDD geometry
+		if(_debug) System.out.printf("%s: setup and build the LCDD geometry\n", getClass().getSimpleName());
+		
+		builder.setLCDD(lcdd);
+		builder.build(trackingVolume);
+		
+		if(_debug) System.out.printf("%s: DONE setup and build the LCDD geometry\n", getClass().getSimpleName());
+		
+		
 		//makeExample(lcdd,sens);
 
 		
@@ -129,23 +120,72 @@
 		}
 		
 				
-		makeBase(trackingVolume,lcdd,sens);
+		buildLCDD();
+		//makeBase(trackingVolume,lcdd,sens);
 		
 		
 		
 	}
 	
+
+	private void addToLCDD(BaseGeom lcddObj, LCDD lcdd) {
+		
+		if(_debug) System.out.printf("%s: adding %s to LCDD\n", getClass().getSimpleName(),lcddObj.getName());
+
+		if(lcddObj.getClass().isInstance(GhostBaseGeom.class)) {
+			System.out.printf("%s: trying to add a ghost volume: %s ??\n", getClass().getSimpleName(),lcddObj.getName());
+			throw new RuntimeException("adding a ghose volume (" + lcddObj.getName() + ") to LCDD is not allowed.");
+		}
+		// add box, pos, rotation and create phys volume
+		lcdd.add(lcddObj.getBox());
+		lcdd.add(lcddObj.getPos());
+		lcdd.add(lcddObj.getRot());
+		lcddObj.buildPhysVolume();
+
+		// add daughters
+		if(_debug) System.out.printf("%s: add %d daughters to %s\n", getClass().getSimpleName(),lcddObj.getDaughters().size(),lcddObj.getName());
+		for(BaseGeom daughter : lcddObj.getDaughters()) {
+			addToLCDD(daughter,lcdd);
+		}
+		
+		// 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(_debug) System.out.printf("%s: DONE adding %s\n", getClass().getSimpleName(),lcddObj.getName());
+	}
 	
+	private void buildLCDD() {
+		
+		if(_debug) System.out.printf("%s: buildLCDD\n", getClass().getSimpleName());
+		
+		LCDD lcdd  = builder.getLCDD();
+
+		BaseGeom lcddObj = builder.getBaseLCDD();
+		
+		addToLCDD(lcddObj,lcdd);
+		
+		
+		if(_debug) System.out.printf("%s: buildLCDD DONE\n", getClass().getSimpleName());
+		
+	}
 	
+	
+	
+	
+	
 	private void makeBase(Volume motherVolume, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
 		
 		
 		if(_debug) {
 			print("--- makeBase ----");
-			
 		}
-
 		
+		
+		
+		HPSTestRunTracker2014GeomDef.BaseGeom base = builder.getBase();
+		
 		Hep3Vector ball_pos_base = base.getBallPos();
 		Hep3Vector vee_pos_base = base.getVeePos(); 
 		Hep3Vector flat_pos_base = base.getFlatPos();
@@ -242,6 +282,8 @@
 			print("--- makeBasePlate----");
 		}
 
+		HPSTestRunTracker2014GeomDef.BasePlate basePlate = builder.getBasePlate();
+		
 		HPSTestRunTracker2014GeomDef.Coord base_plate_coord = basePlate.getCoord();
 		
 		String volName = basePlate.getName();
@@ -335,6 +377,8 @@
 		String volName;
 		HPSTestRunTracker2014GeomDef.Coord csup_coord;
 		HPSTestRunTracker2014GeomDef.BaseGeom mother;
+		HPSTestRunTracker2014GeomDef.SupportBottom supportBottom  = builder.getSupportBottom();
+		HPSTestRunTracker2014GeomDef.SupportTop supportTop = builder.getSupportTop();
 		if(half == "bottom") {
 			csup_coord = supportBottom.getCoord();
 			volName = supportBottom.getName();
@@ -488,6 +532,9 @@
 		double width,height,length;
 		HPSTestRunTracker2014GeomDef.Coord support_plate_coord;
 		HPSTestRunTracker2014GeomDef.BaseGeom mother;
+		
+		HPSTestRunTracker2014GeomDef.SupportPlateBottom supportPlateBottom = builder.getSupportPlateBottom();
+		HPSTestRunTracker2014GeomDef.SupportPlateTop supportPlateTop = builder.getSupportPlateTop();
 		if(half == "bottom") {
 			volName = supportPlateBottom.getName();
 			width = HPSTestRunTracker2014GeomDef.SupportPlateBottom.support_plate_bottom_width;
@@ -585,6 +632,10 @@
 		final HPSTestRunTracker2014GeomDef.BaseGeom mother;
 		// reference is a intermediate geom object that are referenced but not it's direct mother
 		final HPSTestRunTracker2014GeomDef.BaseGeom ref;
+		HPSTestRunTracker2014GeomDef.SupportBottom supportBottom = builder.getSupportBottom();
+		HPSTestRunTracker2014GeomDef.SupportTop supportTop = builder.getSupportTop();
+		HPSTestRunTracker2014GeomDef.SupportPlateBottom supportPlateBottom = builder.getSupportPlateBottom();
+		HPSTestRunTracker2014GeomDef.SupportPlateTop supportPlateTop = builder.getSupportPlateTop();
 		if(half == "bottom") {
 			mother = supportBottom;
 			ref = supportPlateBottom;
@@ -602,6 +653,7 @@
 		}
 		
 		// add it to list of modules
+		List<HPSTestRunTracker2014GeomDef.TestRunModule> modules = builder.getModules();
 		modules.add(module);
 		
 		Box box = new Box(volName + "_box", module.getBoxDim().x(), module.getBoxDim().y(), module.getBoxDim().z());
@@ -659,6 +711,7 @@
 	
 	
 	private HPSTestRunTracker2014GeomDef.BaseGeom findModule(String moduleName) {
+		List<HPSTestRunTracker2014GeomDef.TestRunModule> modules = builder.getModules();
 		for(HPSTestRunTracker2014GeomDef.TestRunModule m : modules) {
 			if(m.getName().equals(moduleName)) return m;
 		}
@@ -1042,7 +1095,7 @@
 	
 	
 
-	private void makeHalfModuleComponentCF(BaseGeom mother, Volume motherVolume, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
+	private void makeHalfModuleComponentCF(HPSTestRunTracker2014GeomDef.BaseGeom mother, Volume motherVolume, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
 		
 		if(_debug) {
 			print("--- makeHalfModuleComponentCF for half-module " + mother.getName());
@@ -1093,7 +1146,7 @@
 
 
 	
-	private void makeHalfModuleComponentHybrid(BaseGeom mother, Volume motherVolume, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
+	private void makeHalfModuleComponentHybrid(HPSTestRunTracker2014GeomDef.BaseGeom mother, Volume motherVolume, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
 		
 		if(_debug) {
 			print("--- makeHalfModuleComponentHybrid for half-module " + mother.getName());
@@ -1212,7 +1265,8 @@
 		return envelopeToSupportTransform;
 	}
 	
-	private Hep3Vector getEulerAngles(Hep3Vector u, Hep3Vector v, Hep3Vector u_prime, Hep3Vector v_prime) {
+	public static Hep3Vector getEulerAngles(Hep3Vector u, Hep3Vector v, Hep3Vector u_prime, Hep3Vector v_prime) {
+		boolean debug = false;
 		// 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());
 		org.apache.commons.math3.geometry.euclidean.threed.Vector3D v_3D = new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(v.v());
@@ -1223,9 +1277,9 @@
 		//Get the angles
 		double res[] = rot.getAngles(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ);
 		Hep3Vector euler = new BasicHep3Vector(res);
-		if(_debug) {
-			print("u " + u_3D.toString() + " v " + v_3D.toString() + " u' " + u_prime_3D.toString() + " v' " + v_prime_3D.toString());
-			print("rot matrix:");
+		if(debug) {
+			System.out.println("u " + u_3D.toString() + " v " + v_3D.toString() + " u' " + u_prime_3D.toString() + " v' " + v_prime_3D.toString());
+			System.out.println("rot matrix:");
 			double[][] mat = rot.getMatrix();
 			for(int r=0;r<3;++r) {
 				String row = "";
@@ -1235,7 +1289,7 @@
 				System.out.println(row);
 			}
 		
-			print("XYZ angles " + euler.toString());
+			System.out.println("XYZ angles " + euler.toString());
 		}
 		
 		
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