Commit in projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact on MAIN | |||
HPSTestRunTracker2014JavaBuilder.java | +138 | -126 | 3305 -> 3306 |
Move transform finder to builder class. Make sure the translations are set at build time and not at phys volume build time. Name changes.
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014JavaBuilder.java 2014-09-04 05:41:48 UTC (rev 3305) +++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSTestRunTracker2014JavaBuilder.java 2014-09-04 05:44:17 UTC (rev 3306) @@ -60,8 +60,8 @@
*/ public class HPSTestRunTracker2014JavaBuilder extends HPSTestRunTracker2014Builder {
- protected JavaBaseGeom baseTrackerGeometry; - protected List<JavaBaseGeom> java_objects;
+ protected JavaBaseGeometry baseTrackerGeometry; + protected List<JavaBaseGeometry> java_objects;
protected DetectorIdentifierHelper detectorIdentifierHelper; protected IIdentifierDictionary identifierDictionary; protected Subdetector subdet;
@@ -81,7 +81,7 @@
* Add to list of objects. * @param geom - object to add. */
- private void add(JavaBaseGeom geom) {
+ private void add(JavaBaseGeometry geom) {
java_objects.add(geom); }
@@ -95,24 +95,25 @@
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<JavaBaseGeom>();
+ java_objects = new ArrayList<JavaBaseGeometry>();
// Go through the list of volumes to build that is created in the generic builder class
- JavaBaseGeom trackingGeometry = new JavaBaseGeom(getItem(TrackingBase.class), trackingVolume);
+ JavaBaseGeometry trackingGeometry = new JavaBaseGeometry(getBaseGeometry(TrackingBase.class), trackingVolume);
add(trackingGeometry);
- baseTrackerGeometry = new GhostJavaBaseGeom(getItem(Base.class), trackingGeometry);
+ baseTrackerGeometry = new GhostJavaBaseGeom(getBaseGeometry(Base.class), trackingGeometry);
add(baseTrackerGeometry);
- JavaBaseGeom basePlateGeometry = new GhostJavaBaseGeom(getItem(BasePlate.class), baseTrackerGeometry);
+ JavaBaseGeometry basePlateGeometry = new GhostJavaBaseGeom(getBaseGeometry(BasePlate.class), baseTrackerGeometry);
add(basePlateGeometry);
- JavaBaseGeom cSupportGeometry = new GhostJavaBaseGeom(getItem(CSupport.class), baseTrackerGeometry); - add(cSupportGeometry); - JavaBaseGeom supportBottomGeometry = new GhostJavaBaseGeom(getItem(SupportBottom.class), baseTrackerGeometry);
+ // 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);
add(supportBottomGeometry);
- JavaBaseGeom supportPlateBottomGeometry = new GhostJavaBaseGeom(getItem(SupportPlateBottom.class), baseTrackerGeometry);
+ JavaBaseGeometry supportPlateBottomGeometry = new GhostJavaBaseGeom(getBaseGeometry(SupportPlateBottom.class), baseTrackerGeometry);
add(supportPlateBottomGeometry);
- JavaBaseGeom supportTopGeometry = new GhostJavaBaseGeom(getItem(SupportTop.class), baseTrackerGeometry);
+ JavaBaseGeometry supportTopGeometry = new GhostJavaBaseGeom(getBaseGeometry(SupportTop.class), baseTrackerGeometry);
add(supportTopGeometry);
- JavaBaseGeom supportPlateTopGeometry = new GhostJavaBaseGeom(getItem(SupportPlateTop.class), baseTrackerGeometry);
+ JavaBaseGeometry supportPlateTopGeometry = new GhostJavaBaseGeom(getBaseGeometry(SupportPlateTop.class), baseTrackerGeometry);
add(supportPlateTopGeometry); // build modules
@@ -123,7 +124,7 @@
for(ModuleBundle m : modules) { // Do only L1?
- if(m.getLayer()!=1) continue;
+ //if(m.getLayer()!=1) continue;
if(isDebug()) { System.out.printf("%s: module layer %d half %s\n", getClass().getSimpleName(),m.getLayer(),m.getHalf());
@@ -132,8 +133,8 @@
// Find the mother among the objects using its name, should probably have a better way... String name_mother = m.getMother().getName();
- JavaBaseGeom mother = null; - for(JavaBaseGeom g : java_objects) {
+ JavaBaseGeometry mother = null; + for(JavaBaseGeometry g : java_objects) {
if(g.getName().equals(name_mother)) { mother = g; break;
@@ -164,7 +165,7 @@
* @param bundle - module to be added * @param mother - mother JAVA geometry object */
- private void addModule(ModuleBundle bundle, JavaBaseGeom mother) {
+ private void addModule(ModuleBundle bundle, JavaBaseGeometry mother) {
if(isDebug()) { System.out.printf("%s: addModule %s containing:\n",this.getClass().getSimpleName(), bundle.module.getName());
@@ -172,7 +173,7 @@
} // Create the module
- JavaBaseGeom lcddM = new GhostJavaBaseGeom(bundle.module, mother);
+ JavaBaseGeometry lcddM = new GhostJavaBaseGeom(bundle.module, mother);
add(lcddM); // add half modules
@@ -192,13 +193,13 @@
* @param bundle - module to be added * @param mother - mother JAVA geometry object */
- private void addHalfModule(HalfModuleBundle bundle, JavaBaseGeom mother) {
+ 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;
- JavaBaseGeom lcddHM = new JavaBaseGeom(bundle.halfModule, mother,oldCompactModuleId);
+ 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.
@@ -206,11 +207,11 @@
int componentNumber = bundle.sensor.getId(); // create the sensor
- JavaBaseGeom lcddS = new JavaBaseGeom(bundle.sensor, lcddHM, componentNumber);
+ JavaBaseGeometry lcddS = new JavaBaseGeometry(bundle.sensor, lcddHM, componentNumber);
add(lcddS); // create the active sensor
- JavaBaseGeom lcddAS = new JavaBaseGeom(bundle.activeSensor, lcddS, componentNumber);
+ JavaBaseGeometry lcddAS = new JavaBaseGeometry(bundle.activeSensor, lcddS, componentNumber);
add(lcddAS); }
@@ -250,20 +251,7 @@
* @author Per Hansson Adrian <[log in to unmask]> * */
- protected static class GhostJavaBaseGeom extends JavaBaseGeom { - - /** - * Initialize this object with a known volume and no mother. Typically the tracking volume would use this. - * @param base - object used to get geometry definitions - * @param vol - given volume - */ - public GhostJavaBaseGeom(BaseGeometry base, ILogicalVolume volume) { - super(); - if(isDebug()) System.out.printf("%s: constructing JAVA ghost object %s\n", this.getClass().getSimpleName(),base.getName()); - setName(base.getName()); - setVolume(volume); - if(isDebug()) System.out.printf("%s: DONE constructing JAVA object %s\n", this.getClass().getSimpleName(),base.getName()); - }
+ protected static class GhostJavaBaseGeom extends JavaBaseGeometry {
/** * Initialize with base and mother. This is typically for a reference geometry object
@@ -271,12 +259,13 @@
* @param base - object used to get geometry definitions * @param mother - mother object */
- public GhostJavaBaseGeom(BaseGeometry base, JavaBaseGeom mother) {
+ 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);
+ setPosAndRot(base);
if(isDebug()) System.out.printf("%s: DONE constructing JAVA object %s\n", this.getClass().getSimpleName(),base.getName()); }
@@ -289,7 +278,7 @@
* * @author Per Hansson Adrian <[log in to unmask]> */
- protected static class JavaBaseGeom {
+ protected static class JavaBaseGeometry {
private boolean debug = true; private String name; private Box box= null;
@@ -297,20 +286,29 @@
private ITranslation3D pos = null; private IRotation3D rot = null; private IPhysicalVolume physVolume = null;
- private JavaBaseGeom mother = null; - public List<JavaBaseGeom> daughters = new ArrayList<JavaBaseGeom>();
+ private JavaBaseGeometry mother = null; + public List<JavaBaseGeometry> daughters = new ArrayList<JavaBaseGeometry>();
private int componentId = -1; /** * Default constructor */
- public JavaBaseGeom() {
+ public JavaBaseGeometry() {
}
- public JavaBaseGeom(BaseGeometry geomObject, ILogicalVolume vol) {
+ public JavaBaseGeometry(BaseGeometry geomObject, ILogicalVolume vol) {
if(isDebug()) System.out.printf("%s: constructing JAVA object %s with volume (name %s)\n", this.getClass().getSimpleName(),geomObject.getName(),vol.getName()); setName(geomObject.getName()); setVolume(vol);
+ // this must be tracking volume. May change in the future and is probably weird to make this requirement here. + if(!geomObject.getName().contains("tracking")) throw new RuntimeException("this constructor is only used with the tracking volume!?"); + // since it's tracking volume, set the pos and rotation trivially + Hep3Vector box_center = new BasicHep3Vector(0,0,0); + Hep3Vector lcdd_rot_angles = HPSTestRunTracker2014.getEulerAngles(geomObject.getCoord().v(), geomObject.getCoord().w(), new BasicHep3Vector(0,1,0),new BasicHep3Vector(0,0,1)); + // Create the LCDD position + setPos(new Translation3D(box_center.x(), box_center.y(), box_center.z())); + setRot(new RotationGeant(lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z())); + //setPosAndRot(geomObject);
if(isDebug()) System.out.printf("%s: DONE constructing JAVA object %s with volume (name %s)\n", this.getClass().getSimpleName(),geomObject.getName(),vol.getName()); }
@@ -320,7 +318,7 @@
* @param mother - reference to mother JAVA definition * @param volumeId - component id number */
- public JavaBaseGeom(BaseGeometry geomObject, JavaBaseGeom mother, int volumeId) {
+ public JavaBaseGeometry(BaseGeometry geomObject, JavaBaseGeometry mother, int volumeId) {
if(isDebug()) System.out.printf("%s: constructing JAVA object %s (volumeID %d) with mother %s\n", this.getClass().getSimpleName(),geomObject.getName(),volumeId,mother==null?"null":mother.getName()); setName(geomObject.getName()); setComponentId(volumeId);
@@ -333,25 +331,15 @@
if(isDebug()) System.out.printf("%s: DONE constructing JAVA object %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\n", this.getClass().getSimpleName(),getName()); - if(isDebug()) System.out.printf("%s: mother %s \n", this.getClass().getSimpleName(),getMother().getName()); - // The physical volume needs to be built with a physical mother i.e. anot a ghost volume - // Find the closest physical mother - JavaBaseGeom physMother = getPhysMother(); - if(isDebug()) System.out.printf("%s: physical mother %s \n", this.getClass().getSimpleName(),physMother.getName()); - // similarly, if the mother is not the physical mother the positions and rotations of the - // mother needs to be updated - Transform3D tOld = new Transform3D(getPos(), getRot()); - if(isDebug()) System.out.printf("%s: transform before update of transform to physical mother\n%s\n", this.getClass().getSimpleName(),tOld.toString()); - ITransform3D t = getParentTransform(tOld, getMother(), physMother.getName()); - setPos(t.getTranslation()); - setRot(t.getRotation()); - Transform3D tNew = new Transform3D(getPos(), getRot()); - if(isDebug()) System.out.printf("%s: transform after update of transform to physical mother\n%s\n", this.getClass().getSimpleName(),tNew.toString()); - // TODO this seems dangerous to change it here, should this be done in the generic builder somehow? - setPhysVolume(new PhysicalVolume(tNew, name, volume, physMother.getVolume(),getComponentId()));
+ 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) { if(isDebug()) System.out.printf("%s: build box for %s\n", this.getClass().getSimpleName(),getName());
@@ -365,42 +353,85 @@
} protected void setPosAndRot(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();
- //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 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 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) {
+ 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
- Hep3Vector box_center_base_rot = HPSTestRunTracker2014.getRotationDisplacement(base.getCoord().origin(), box_center_base, base.explicit_rot_angles);
+ // 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, base.getMother().getCenter());
+ 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()));
+
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());
+ + 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: 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());
} }
@@ -409,7 +440,7 @@
* Find the first non-ghost volume among parents. * @return mother object */
- public JavaBaseGeom getPhysMother() {
+ 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) {
@@ -451,10 +482,10 @@
protected void setRot(IRotation3D iRotation3D) { this.rot = iRotation3D; }
- protected JavaBaseGeom getMother() {
+ protected JavaBaseGeometry getMother() {
return mother; }
- protected void setMother(JavaBaseGeom mother) {
+ protected void setMother(JavaBaseGeometry mother) {
this.mother = mother; } protected IPhysicalVolume getPhysVolume() {
@@ -467,11 +498,11 @@
return debug; }
- protected List<JavaBaseGeom> getDaughters() {
+ protected List<JavaBaseGeometry> getDaughters() {
return daughters; }
- protected void addDaughter(JavaBaseGeom o) {
+ protected void addDaughter(JavaBaseGeometry o) {
getDaughters().add(o); }
@@ -487,58 +518,39 @@
- public Hep3Vector transformToMotherCoord(Hep3Vector vec, JavaBaseGeom mother, String targetMotherName) { - if(isDebug()) System.out.printf("transformToMotherCoord vec %s mother %s target %s\n", vec.toString(), mother.name, targetMotherName); - if(mother.name.equals(targetMotherName)) { - if(isDebug()) System.out.printf(String.format("found the transformed vec %s\n", vec.toString())); - return vec; - } else { - if(mother.name.equals("trackingVolume")) { - if(isDebug()) System.out.print("reached tracking volume. return null?!\n"); - return null; - }
- Transform3D trans = new Transform3D(mother.pos, mother.rot); - Hep3Vector vec_t = trans.transformed(vec); - if(isDebug()) System.out.print("continue searching\n"); - return transformToMotherCoord(vec_t, mother.mother, targetMotherName); - } - - }
+// /** +// * 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); +// } +// } +//
- /** - * 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, JavaBaseGeom 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); - } - }
- - -
// 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
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