Print

Print


Commit in projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd on MAIN
HPSTrackerBuilder.java+356added 3318
HPSTrackerLCDDBuilder.java+350added 3318
IHPSTrackerLCDDBuilder.java+15added 3318
+721
3 added files
Extract super classes and interface

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
HPSTrackerBuilder.java added at 3318
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTrackerBuilder.java	                        (rev 0)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTrackerBuilder.java	2014-09-12 19:04:24 UTC (rev 3318)
@@ -0,0 +1,356 @@
+package org.lcsim.geometry.compact.converter.lcdd;
+
+import hep.physics.vec.Hep3Vector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.lcsim.detector.Transform3D;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.BaseGeometry;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.TestRunColdBlock;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.TestRunModule;
+
+public class HPSTrackerBuilder {
+
+	private boolean debug = false;
+	public List<ModuleBundle> modules;
+	protected List<HPSTestRunTracker2014GeometryDefinition.BaseGeometry> geometries = new ArrayList<HPSTestRunTracker2014GeometryDefinition.BaseGeometry>();
+
+	public static String getHalfFromName(String name) {
+		String half = "";
+		if(name.contains("bottom")) {
+			half = "bottom";
+		}
+		if(name.contains("top")) {
+			// check that both sides are not found
+			if(half.equals("bottom")) {
+				throw new RuntimeException("found both halfs from name  " + name);
+			} else {
+				half = "top";
+			}
+		}
+		// check for other signatures
+		if( half.isEmpty()) {
+			// 6 layers is arbitrary here
+			for(int layer=1;layer<=6;++layer) {
+				if(name.contains(String.format("L%db", layer))) {
+					half = "bottom";
+					break;
+				} 
+				if(name.contains(String.format("L%dt", layer))) {
+					if(half.equals("bottom")) {
+						throw new RuntimeException("found both halfs from name  " + name);
+					}
+					half = "top";
+					break;
+				}
+			}
+		}		
+		if( half.isEmpty()) {
+			System.out.println("found no half from " + name);
+			throw new RuntimeException("found no half from " + name);
+		} else {
+			return half;
+	
+		}
+	}
+
+	public static int getLayerFromVolumeName(String name) {
+		int layer = -1;
+		for(int i=1; i<= 5; ++i) {
+			if(name.contains(String.format("module_L%d", i))) {
+				layer = i;
+			}
+		}
+		if( layer == -1) {
+			System.out.println("cannot find layer from " + name);
+			System.exit(1);
+		}
+		return layer;
+	}
+
+	public static boolean isHalfModule(String name) {
+		if(name.endsWith("halfmodule_axial") || name.endsWith("halfmodule_stereo")) {
+			return true;
+		}
+		return false;
+	}
+
+	public static boolean isSensor(String name) {
+		if(name.endsWith("sensor")) {
+			return true;
+		}
+		return false;
+	}
+
+	public static boolean isActiveSensor(String name) {
+		if(name.endsWith("sensor_active")) {
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * 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]>
+	 *
+	 */
+	public static class ModuleBundle {
+		public TestRunModule module = null;
+		public HalfModuleBundle halfModuleAxial = null;
+		public HalfModuleBundle halfModuleStereo = null;
+		protected TestRunColdBlock coldBlock = null;
+		ModuleBundle(TestRunModule m) {
+			module = m;
+		}	
+		public int getLayer() {
+			if(module==null) throw new RuntimeException("Need to add module to bundle first!");
+			return getLayerFromVolumeName(module.getName());
+		}
+		public String getHalf() {
+			if(module==null) throw new RuntimeException("Need to add module to bundle first!");
+			return getHalfFromName(module.getName()); 
+		}
+		/**
+		 * Find mother to this module.
+		 * @return mother 
+		 */
+		public BaseGeometry getMother() {
+			if(module==null) throw new RuntimeException("Need to add module to bundle first!");
+			return module.getMother();
+		}
+		public void print() {
+			if(module!=null) System.out.printf("%s: %s\n", this.getClass().getSimpleName(),module.getName());
+			if(halfModuleAxial!=null) halfModuleAxial.print();
+			if(coldBlock!=null)System.out.printf("%s: %s\n", this.getClass().getSimpleName(),coldBlock.getName());
+			if(halfModuleStereo!=null) halfModuleStereo.print();
+		}
+	}
+
+	protected boolean isDebug() {
+		return debug;
+	}
+
+	protected void setDebug(boolean debug) {
+		this.debug = debug;
+	}
+
+	/**
+	 * Find geometry object by type.
+	 * @param c - class type to be found
+	 * @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());
+		
+		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 " + geometries.size() + " tracker items!");
+	}
+
+	protected List<ModuleBundle> getModules() {
+		return modules;
+	}
+
+	/**
+	 * Find module among the existing bundles.
+	 * @param layer - layer id
+	 * @param half - top or bottom half
+	 * @return module or null if not found
+	 */
+	protected ModuleBundle getModuleBundle(int layer, String half) {
+		for(ModuleBundle m : modules) {
+			if(m.getLayer()==layer && m.getHalf().equals(half)) {
+				return m;
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * Find module among the existing bundles.
+	 * @param module - to find
+	 * @return bundle
+	 */
+	protected ModuleBundle getModuleBundle(HPSTestRunTracker2014GeometryDefinition.TestRunModule module) {
+		return getModuleBundle(module.getLayer(), module.getHalf());
+	}
+
+	/**
+	 * Find half module among the existing bundles.
+	 * @param module - to find
+	 * @return bundle
+	 */
+	protected HalfModuleBundle getHalfModuleBundle(HPSTestRunTracker2014GeometryDefinition.TestRunModule module, String halfModuleName) {
+		ModuleBundle m = getModuleBundle(module.getLayer(), module.getHalf());
+		HalfModuleBundle hm = null;
+		if(m!=null) {
+			if(halfModuleName.contains("axial")) hm = m.halfModuleAxial;
+			else if(halfModuleName.contains("stereo")) hm = m.halfModuleStereo;
+			else throw new RuntimeException("NO axial or stereo string found in half module bundle name " + halfModuleName);
+		} else {
+			throw new RuntimeException("No module found for " + module.getLayer() + " and half " + module.getHalf());
+		}
+		return hm;
+	}
+
+	/**
+	 * Add module to list.
+	 * @param bundle - module to add.
+	 */
+	protected void addModuleBundle(ModuleBundle bundle) {
+		ModuleBundle b = getModuleBundle(bundle.getLayer(), bundle.getHalf());
+		if(b==null) {
+			modules.add(bundle);
+		} else {
+			throw new RuntimeException("There is already a module bundle with layer " + bundle.getLayer() + " and half " + bundle.getHalf());
+		}
+	}
+
+	/**
+	 * Checks if the orientation of the sensor is axial.
+	 * Uses the moduleId definition from the "old" geometry for 
+	 * consistency.
+	 * 
+	 *  @return true if it is, false if it is a stereo sensor
+	 */
+	private boolean isAxial(boolean isTopLayer, int layer) {
+	    if (isTopLayer && layer % 2 == 1) {
+	        return true;
+	    } else if (!isTopLayer && layer % 2 == 0) {
+	        return true;
+	    }
+	    return false;
+	}
+
+	public static class HalfModuleBundle {
+		public HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule halfModule = null;
+		public HPSTestRunTracker2014GeometryDefinition.Sensor sensor = null;
+		public HPSTestRunTracker2014GeometryDefinition.ActiveSensor activeSensor = null;
+		protected HPSTestRunTracker2014GeometryDefinition.HalfModuleLamination lamination = null;
+		protected HPSTestRunTracker2014GeometryDefinition.CarbonFiber carbonFiber = null;
+		protected HPSTestRunTracker2014GeometryDefinition.Hybrid hybrid = null;
+		HalfModuleBundle(HPSTestRunTracker2014GeometryDefinition.TestRunHalfModule hm) {			
+			halfModule = hm;
+		}
+		public void print() {
+			System.out.printf("%s: %s\n", this.getClass().getSimpleName(),halfModule.getName());
+		}
+	}
+
+	/**
+	 * 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=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)) {
+			if(debug>0) System.out.printf("found the transform\n");
+			return t;
+		} else {
+			if(debug>0) System.out.printf("add mother transform\n%s\n",mother.getCoord().getTransformation().toString());
+			Transform3D trans = Transform3D.multiply(mother.getCoord().getTransformation(), t);
+			if(debug>0) System.out.printf("resulting transform\n%s\ncontinue searching\n",trans.toString());
+			return getTransform(trans, mother.getMother(), targetMotherName);
+		}
+		
+	}
+
+	/**
+	 * 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 =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);
+				
+				Transform3D t = getTransform(geometry.getCoord().getTransformation(), mother, targetMotherName);
+				
+				Hep3Vector vec_t = t.transformed(vec);
+				
+				if(debug>0) {
+					System.out.printf("transformToMotherCoord apply transform \n%s\n",t.toString());
+					System.out.printf("transformToMotherCoord vec_t%s\n",vec_t.toString());
+				}
+				
+				
+				return vec_t;
+			}
+
+	/**
+	 * 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;
+		if(debug>0) System.out.printf("\ntransformToTracking: vec %s in local coordiantes of %s with mother %s\n", vec.toString(), geometry.getName(), geometry.getMother().getName().toString());
+		Hep3Vector vec_mother_coord = geometry.getCoord().getTransformation().transformed(vec);
+		if(debug>0) System.out.printf("vec_mother_coord %s\n",vec_mother_coord.toString());
+		if(geometry.getMother().getName().equals("trackingVolume")) {
+			if(debug>0) System.out.printf("reached tracking volume. Return \n");
+			return vec_mother_coord;
+		} else {
+			if(debug>0) System.out.printf("continue searching.\n");
+		}
+		return transformToTracking(vec_mother_coord, geometry.getMother());
+	}
+
+	/**
+	 * Get the layer number consistent with the old geometry definition. 
+	 * @param module name that contains layer and half information.
+	 * @return the layer.
+	 */
+	public static int getOldGeomDefLayerFromVolumeName(String name) {
+		String half = getHalfFromName(name);
+		boolean isTopLayer = false;
+		if(half=="top") isTopLayer=true;
+		else if(half=="bottom") isTopLayer = false;
+		else throw new RuntimeException("no half found from " + name);
+		boolean isAxial = false;
+		if(name.contains("axial")) isAxial=true;
+		else if(name.contains("stereo")) isAxial=false;
+		else throw new RuntimeException("no axial or stereo name found from " + name);
+		int l = getLayerFromVolumeName(name);
+		int layer=-1;
+		// convert to old definition
+		if(isAxial) {
+			if(isTopLayer) {
+				layer = 2*l-1;
+			}
+			else {
+				layer = 2*l;
+			}
+		} else {
+			if(isTopLayer) {
+				layer = 2*l;
+			} else {
+				layer = 2*l-1;
+			}
+		}
+		return layer;
+	}
+
+	public HPSTrackerBuilder() {
+		super();
+	}
+
+}
\ No newline at end of file

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
HPSTrackerLCDDBuilder.java added at 3318
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTrackerLCDDBuilder.java	                        (rev 0)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTrackerLCDDBuilder.java	2014-09-12 19:04:24 UTC (rev 3318)
@@ -0,0 +1,350 @@
+package org.lcsim.geometry.compact.converter.lcdd;
+
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.VecOp;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jdom.JDOMException;
+import org.lcsim.geometry.compact.converter.lcdd.HPSTestRunTracker2014GeometryDefinition.BaseGeometry;
+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;
+import org.lcsim.geometry.compact.converter.lcdd.util.PhysVol;
+import org.lcsim.geometry.compact.converter.lcdd.util.Position;
+import org.lcsim.geometry.compact.converter.lcdd.util.Rotation;
+import org.lcsim.geometry.compact.converter.lcdd.util.SensitiveDetector;
+import org.lcsim.geometry.compact.converter.lcdd.util.Volume;
+
+public abstract class HPSTrackerLCDDBuilder extends HPSTestRunTracker2014Builder implements IHPSTrackerLCDDBuilder {
+
+	protected LCDD lcdd;
+	protected LCDDBaseGeometry baseTrackerGeometry;
+	protected List<LCDDBaseGeometry> lcddGeometries;
+	private SensitiveDetector sensitiveDetector;
+
+	/**
+	 * 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 = false;
+		private String name;
+		private Box box= null;
+		private Volume volume = null;
+		private Position pos = null;
+		private Rotation rot = null;
+		private PhysVol physVolume = null;
+		private LCDD lcdd = null;
+		private LCDDBaseGeometry mother = null;
+		protected Map<String,Integer> physVolId = null;
+		public List<LCDDBaseGeometry> daughters = new ArrayList<LCDDBaseGeometry>();
+		/**
+		 *  Default constructor
+		 */
+		public LCDDBaseGeometry() {
+		}
+		
+		/**
+		 * 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
+		 */
+		public LCDDBaseGeometry(BaseGeometry base, LCDD lcdd, LCDDBaseGeometry mother) {
+			if(isDebug()) System.out.printf("%s: constructing LCDD object %s with mother %s\n", this.getClass().getSimpleName(),base.getName(),mother==null?"null":mother.getName());
+			this.lcdd = lcdd;
+			setName(base.getName());
+			setMother(mother);
+			mother.addDaughter(this);
+			buildBox(base);
+			buildVolume(base);
+			setPositionAndRotation(base);
+			//buildPhysVolume(mother);
+			if(isDebug()) System.out.printf("%s: DONE constructing LCDD object %s\n", this.getClass().getSimpleName(),base.getName());
+		}
+	
+		
+		protected void buildPhysVolume() {
+			if(isDebug()) System.out.printf("%s: build phys volume for %s\n", this.getClass().getSimpleName(),getName());
+			setPhysVolume(new PhysVol(volume, getMother().getVolume(), getPos(), getRot()));
+		}
+		protected void buildBox(BaseGeometry base) {
+			if(isDebug()) System.out.printf("%s: build box for %s\n", this.getClass().getSimpleName(),getName());
+			setBox(new Box(getName() + "Box", base.getBoxDim().x(), base.getBoxDim().y(), base.getBoxDim().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());
+			try {
+				Material mat = lcdd.getMaterial(base.getMaterial());
+				setVolume(new Volume(getName() + "_volume", box, mat));
+			} catch (JDOMException e) {
+				e.printStackTrace();
+			}
+		}
+		
+		
+		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();
+			//translate to the mother coordinate system
+			Hep3Vector box_center_base = base.getCoord().getTransformation().transformed(box_center_base_local);
+			// find the position of the center in the mother coord
+			Hep3Vector box_center = VecOp.sub(box_center_base, base.getMother().getCenter());
+			//Find LCDD Euler rotation angles from coordinate system unit vectors
+			Hep3Vector lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(base.getCoord().v(), base.getCoord().w(), new BasicHep3Vector(0,1,0),new BasicHep3Vector(0,0,1));
+			// Check if there are explicit rotations built into the object itself which overrides
+			// TODO this should be included in the definition of the coordinate system. Fix this for the affected components.
+			/*
+			if (base.explicit_rot_angles!=null) {
+				// there are explicit rotations I need to apply.
+				// Find the displacement of the box center due to rotation about different origin
+				Hep3Vector box_center_base_rot = HPSTestRunTracker2014.getRotationDisplacement(base.getCoord().origin(), box_center_base, base.explicit_rot_angles);
+				if(isDebug()) {
+					System.out.printf("%s: lcdd_rot_angles 		  %s\n", this.getClass().getSimpleName(),lcdd_rot_angles);
+					System.out.printf("%s: lcdd_rot_angles_2	  %s\n", this.getClass().getSimpleName(),base.explicit_rot_angles);
+					System.out.printf("%s: box_center_base        %s\n", this.getClass().getSimpleName(), box_center_base.toString());
+					System.out.printf("%s: box_center_base_rot    %s\n", this.getClass().getSimpleName(), box_center_base_rot.toString());
+				}
+				// update the rotation angles
+				lcdd_rot_angles = base.explicit_rot_angles;
+				// update the position of the center in the mother coord
+				box_center = VecOp.sub(box_center_base_rot, base.getMother().getCenter());
+			}
+			*/
+			// Create the LCDD position
+			setPos(new Position(getName() + "_position",box_center.x(), box_center.y(), box_center.z()));
+			
+			if(getName().contains("module_L1t") && !getName().contains("halfmodule") && !getName().contains("cold")) {
+				lcdd_rot_angles = new BasicHep3Vector(-Math.PI,0,0.03);
+				lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(base.getCoord().u(), base.getCoord().v(), new BasicHep3Vector(1,0,0),new BasicHep3Vector(0,1,0));
+				lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(base.getCoord().u(), base.getCoord().w(), new BasicHep3Vector(1,0,0),new BasicHep3Vector(0,0,1));
+			}
+			if(getName().contains("module_L1b") && !getName().contains("halfmodule") && !getName().contains("cold")) {
+				lcdd_rot_angles = new BasicHep3Vector(0,0,-0.030);
+			}
+			
+			
+			setRot(new Rotation(getName() + "_rotation",lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z()));
+			if(isDebug()) {
+				System.out.printf("%s: box_center_base_local  %s\n", this.getClass().getSimpleName(), box_center_base_local.toString());
+				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().getCenter().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: 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\n", this.getClass().getSimpleName(), box_center_tracking_xcheck.toString());
+			}
+			
+		}
+		protected Volume getVolume() {
+			return volume;
+		}
+		protected void setVolume(Volume 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 Position getPos() {
+			return pos;
+		}
+		protected void setPos(Position pos) {
+			this.pos = pos;
+		}
+		protected Rotation getRot() {
+			return rot;
+		}
+		protected void setRot(Rotation rot) {
+			this.rot = rot;
+		}
+		protected LCDDBaseGeometry getMother() {
+			return mother;
+		}
+		protected void setMother(LCDDBaseGeometry mother) {
+			this.mother = mother;
+		}
+		protected PhysVol getPhysVolume() {
+			return physVolume;
+		}
+		protected void setPhysVolume(PhysVol physVolume) {
+			this.physVolume = physVolume;
+		}
+		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;
+		}
+	}
+
+	/**
+	 * Add to list of objects.
+	 * @param geom - object to add.
+	 */
+	protected void add(LCDDBaseGeometry geom) {
+		lcddGeometries.add(geom);
+	}
+
+	/**
+	 * Build the LCDD geometry objects.
+	 * @param worldVolume - the reference volume.
+	 */
+	public abstract void build(Volume worldVolume);
+
+	
+
+	protected void setLCDD(LCDD lcdd) {
+		this.lcdd = lcdd;
+	}
+
+	protected LCDD getLCDD() {
+		return lcdd;
+	}
+
+	protected LCDDBaseGeometry getBaseLCDD() {
+		return baseTrackerGeometry;
+	}
+
+	/**
+	 * 
+	 * 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]>
+	 *
+	 */
+	protected static class GhostLCDDBaseGeometry extends LCDDBaseGeometry {
+	
+		/**
+		 * Initialize this object with a known volume and no mother. Typically the world volume would use this.
+		 * @param base - object used to get geometry definitions
+		 * @param vol - given volume
+		 */
+		public GhostLCDDBaseGeometry(BaseGeometry base, Volume volume) {
+			super();
+			if(isDebug()) System.out.printf("%s: constructing LCDD ghost object %s\n", this.getClass().getSimpleName(),base.getName());
+			setName(base.getName());
+			setVolume(volume);
+			if(isDebug()) System.out.printf("%s: DONE constructing LCDD object %s\n", this.getClass().getSimpleName(),base.getName());
+		}
+		
+		/**
+		 * 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 LCDD object
+		 */
+		public GhostLCDDBaseGeometry(BaseGeometry base, LCDDBaseGeometry mother) {
+			super();
+			if(isDebug()) System.out.printf("%s: constructing LCDD ghost object %s with mother %s\n", this.getClass().getSimpleName(),base.getName(),mother==null?"null":mother.getName());
+			setName(base.getName());
+			setMother(mother);
+			if(isDebug()) System.out.printf("%s: DONE constructing LCDD object %s\n", this.getClass().getSimpleName(),base.getName());
+		}
+		
+	}
+
+	/**
+	 * 
+	 * LCDD geometry visualization information
+	 * 
+	 * @author Per Hansson Adrian <[log in to unmask]>
+	 */
+	protected static class LCDDBaseGeometryVisualization {
+		protected String visName = "";
+		public LCDDBaseGeometryVisualization() {}
+		protected String getVisName() {
+			return visName;
+		}
+		protected void setVisName(String visName) {
+			this.visName = visName;
+		}
+		
+		
+	}
+
+	public HPSTrackerLCDDBuilder(boolean debugFlag) {
+		super(debugFlag);
+	}
+
+	public void setSensitiveDetector(SensitiveDetector sens) {
+		this.sensitiveDetector = sens;
+	}
+
+	public SensitiveDetector getSensitiveDetector() {
+		return this.sensitiveDetector;
+	}
+
+	
+	public 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/main/java/org/lcsim/geometry/compact/converter/lcdd
IHPSTrackerLCDDBuilder.java added at 3318
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/IHPSTrackerLCDDBuilder.java	                        (rev 0)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/IHPSTrackerLCDDBuilder.java	2014-09-12 19:04:24 UTC (rev 3318)
@@ -0,0 +1,15 @@
+package org.lcsim.geometry.compact.converter.lcdd;
+
+import org.lcsim.geometry.compact.converter.lcdd.util.SensitiveDetector;
+import org.lcsim.geometry.compact.converter.lcdd.util.Volume;
+
+public interface IHPSTrackerLCDDBuilder {
+
+	public  void setSensitiveDetector(SensitiveDetector sens);
+
+	public  SensitiveDetector getSensitiveDetector();
+	
+	public void build(Volume worldVolume);
+
+	public void setVisualization();
+}
\ 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