Commit in GeomConverter/src/org/lcsim on MAIN | |||
detector/converter/compact/HPSEcal3Converter.java | +28 | -18 | 1.2 -> 1.3 |
geometry/compact/converter/lcdd/HPSEcal3.java | +139 | -162 | 1.5 -> 1.6 |
+167 | -180 |
add optional parameters for arbitrary ECal position displacements in any of the three axes; these are deltas applied to the nominal positions specified by other parameters such as beamgap
diff -u -r1.2 -r1.3 --- HPSEcal3Converter.java 30 Apr 2012 16:28:57 -0000 1.2 +++ HPSEcal3Converter.java 4 Jun 2012 23:26:53 -0000 1.3 @@ -4,7 +4,6 @@
import static java.lang.Math.cos; import static java.lang.Math.sin; import static java.lang.Math.tan;
-import hep.physics.vec.Hep3Vector;
import java.util.ArrayList; import java.util.List;
@@ -107,8 +106,11 @@
Element layout; double beamgap; int nx, ny;
- double dface; -
+ double dface; + double tdx, tdy, tdz; + double bdx, bdy, bdz; + tdx = tdy = tdz = bdx = bdy = bdz = 0.; +
try { dx1 = dimensions.getAttribute("x1").getDoubleValue(); dx2 = dimensions.getAttribute("x2").getDoubleValue();
@@ -122,6 +124,25 @@
nx = layout.getAttribute("nx").getIntValue(); ny = layout.getAttribute("ny").getIntValue(); dface = layout.getAttribute("dface").getDoubleValue();
+ + Element topElement = layout.getChild("top"); + Element bottomElement = layout.getChild("bottom"); + if (topElement != null) { + if (topElement.getAttribute("dx") != null) + tdx = topElement.getAttribute("dx").getDoubleValue(); + if (topElement.getAttribute("dy") != null) + tdy = topElement.getAttribute("dy").getDoubleValue(); + if (topElement.getAttribute("dz") != null) + tdz = topElement.getAttribute("dz").getDoubleValue(); + } + if (bottomElement != null) { + if (bottomElement.getAttribute("dx") != null) + bdx = bottomElement.getAttribute("dx").getDoubleValue(); + if (bottomElement.getAttribute("dy") != null) + bdy = bottomElement.getAttribute("dy").getDoubleValue(); + if (bottomElement.getAttribute("dz") != null) + bdz = bottomElement.getAttribute("dz").getDoubleValue(); + }
} catch (DataConversionException e) { throw new RuntimeException("Error converting HPSEcal3 from XML.", e); }
@@ -228,7 +249,7 @@
if (checkRange(ix, -iy, ranges)) { // Transform of positive bottom crystal.
- ITranslation3D iposBot = new Translation3D(xcenter, -(beamgap + ycenter + tolerance), zcenter + tolerance + dface);
+ ITranslation3D iposBot = new Translation3D(xcenter + bdx, -(beamgap + ycenter + tolerance) + bdy, zcenter + tolerance + dface + bdz);
IRotation3D irotBot = new RotationGeant(-thetax, -thetay, thetaz); // Place positive crystal.
@@ -241,7 +262,7 @@
if (ix != 0) { if (checkRange(-ix, -iy, ranges)) { // Transform of negative.
- ITranslation3D iposnegBot = new Translation3D(-xcenter, -(beamgap + ycenter + tolerance), zcenter + tolerance + dface);
+ ITranslation3D iposnegBot = new Translation3D(-xcenter + bdx, -(beamgap + ycenter + tolerance) + bdy, zcenter + tolerance + dface + bdz);
IRotation3D irotnegBot = new RotationGeant(-thetax, thetay, thetaz); // Place negative crystal.
@@ -253,7 +274,7 @@
if (checkRange(ix, iy, ranges)) { // Transform of positive top crystal.
- Translation3D iposTop = new Translation3D(xcenter, beamgap + ycenter + tolerance, zcenter + tolerance + dface);
+ Translation3D iposTop = new Translation3D(xcenter + tdx, beamgap + ycenter + tolerance + tdy, zcenter + tolerance + dface + tdz);
IRotation3D irotTop = new RotationGeant(thetax, -thetay, thetaz); // Place positive top crystal.
@@ -266,7 +287,7 @@
if (ix != 0) { if (checkRange(-ix, iy, ranges)) { // Transform of negative.
- ITranslation3D iposnegTop = new Translation3D(-xcenter, beamgap + ycenter + tolerance, zcenter + tolerance + dface);
+ ITranslation3D iposnegTop = new Translation3D(-xcenter + tdx, beamgap + ycenter + tolerance + tdy, zcenter + tolerance + dface + tdz);
IRotation3D irotnegTop = new RotationGeant(thetax, thetay, thetaz); // Place negative crystal.
@@ -309,18 +330,7 @@
expId.setValue(dict.getFieldIndex("ix"), ix); expId.setValue(dict.getFieldIndex("iy"), iy); final IIdentifier id = helper.pack(expId);
- // DetectorElement(String name, IDetectorElement parent, String support, IIdentifier id) - //DetectorElement de =
new DetectorElement(subdet.getName() + "_crystal" + crystal.getCopyNumber(), subdet.getDetectorElement(), path, id);
- - // debug print - //System.out.println(de.getName()); - //Hep3Vector t = de.getGeometry().getPosition(); - //System.out.println(" id = " + expId.toString()); - //System.out.println(" pos = " + t.x() + ", " + t.y() + "," + t.z()); - //IRotation3D r = de.getGeometry().getPhysicalVolume().getTransform().getRotation(); - //System.out.println(" rot = " + r.toString()); - //System.out.println("--------");
} public Class getSubdetectorType() {
diff -u -r1.5 -r1.6 --- HPSEcal3.java 15 Sep 2011 21:28:44 -0000 1.5 +++ HPSEcal3.java 4 Jun 2012 23:26:53 -0000 1.6 @@ -8,9 +8,9 @@
import java.util.ArrayList; import java.util.List;
+import org.jdom.DataConversionException;
import org.jdom.Element; import org.jdom.JDOMException;
-import org.lcsim.geometry.compact.converter.lcdd.util.Box;
import org.lcsim.geometry.compact.converter.lcdd.util.Define; import org.lcsim.geometry.compact.converter.lcdd.util.LCDD; import org.lcsim.geometry.compact.converter.lcdd.util.PhysVol;
@@ -24,7 +24,7 @@
* LCDD model for the HPS inner ECal. * * Coordinate System defined as follows:<br>
- *
+ *
* <ul> * <li>Beam travels in +X direction.</li> * <li>Magnetic field is in -Z.</li>
@@ -42,111 +42,90 @@
* <li><b>dface</b> - distance from origin to the face of the calorimeter along Z</li> * </ul> *
- * Under the layout element, <remove> tags can be included to exclude - * crystal placement by range. This element has the following parameters.<br>
+ * Under the layout element, <remove> tags can be included to exclude crystal placement by range. This element + * has the following parameters.<br>
* * <ul> * <li><b>ixmin</b> - minimum x index to exclude (inclusive)</li> * <li><b>ixmax</b> - maximum x index to exclude (inclusive)</li> * <li><b>iymin</b> - minimum y index to exclude (inclusive)</li> * <li><b>iymax</b> - maximum y index to exclude (inclusive)</li>
- * </ul>
+ * </ul>
* * To be excluded, a crystal's ID must pass all four of these min/max checks.<br> * * @author Jeremy McCormick * @author Tim Nelson *
- * @version $Id: HPSEcal3.java,v 1.5 2011/09/15 21:28:44 jeremy Exp $
+ * @version $Id: HPSEcal3.java,v 1.6 2012/06/04 23:26:53 jeremy Exp $
*/
-public class HPSEcal3 extends LCDDSubdetector -{
+public class HPSEcal3 extends LCDDSubdetector {
// Tolerance factor for moving crystals to appropriate place in mom volume. static final double tolerance = 0.0;
-
+
// Tolerance factor for separating crystals to avoid overlaps. static final double crystalTolerance = 0.15;
-
+
// Margin for mother volume. static final double margin = 1.1;
-
+
List<CrystalRange> ranges = new ArrayList<CrystalRange>();
- - private static class CrystalRange - {
+ + private static class CrystalRange {
int ixmin; int ixmax; int iymin; int iymax;
- - CrystalRange(Element elem) throws Exception - {
+ + CrystalRange(Element elem) throws Exception {
ixmin = ixmax = iymin = iymax = 0;
- - if (elem.getAttribute("ixmin") != null) - { - ixmin = elem.getAttribute("ixmin").getIntValue(); - } - else - {
+ + if (elem.getAttribute("ixmin") != null) { + ixmin = elem.getAttribute("ixmin").getIntValue(); + } else {
throw new RuntimeException("Missing ixmin parameter."); }
- - if (elem.getAttribute("ixmax") != null) - {
+ + if (elem.getAttribute("ixmax") != null) {
ixmax = elem.getAttribute("ixmax").getIntValue();
- } - else - {
+ } else {
throw new RuntimeException("Missing ixmax parameter."); }
- - if (elem.getAttribute("iymin") != null) - {
+ + if (elem.getAttribute("iymin") != null) {
iymin = elem.getAttribute("iymin").getIntValue();
- } - else - {
+ } else {
throw new RuntimeException("Missing ixmax parameter."); }
- - if (elem.getAttribute("iymax") != null) - {
+ + if (elem.getAttribute("iymax") != null) {
iymax = elem.getAttribute("iymax").getIntValue();
- } - else - {
+ } else {
throw new RuntimeException("Missing iymax parameter.");
- }
+ }
} }
- - private boolean checkRange(int ix, int iy, List<CrystalRange> ranges) - {
+ + private boolean checkRange(int ix, int iy, List<CrystalRange> ranges) {
if (ranges.size() == 0) return true;
- for (CrystalRange range : ranges) - { - if ((ix >= range.ixmin && ix <= range.ixmax) - && ((iy >= range.iymin) && (iy <= range.iymax))) - {
+ for (CrystalRange range : ranges) { + if ((ix >= range.ixmin && ix <= range.ixmax) && ((iy >= range.iymin) && (iy <= range.iymax))) {
return false; }
-
+
} return true; }
- - HPSEcal3(Element node) throws JDOMException - { - super(node);
+ + HPSEcal3(Element node) throws JDOMException { + super(node);
}
- - void addToLCDD(LCDD lcdd, SensitiveDetector sens) throws JDOMException - {
+ + void addToLCDD(LCDD lcdd, SensitiveDetector sens) throws JDOMException {
if (sens == null) throw new RuntimeException("SensitiveDetector parameter points to null.");
-
+
// Crystal dimensions. Element dimensions = node.getChild("dimensions"); double dx1 = dimensions.getAttribute("x1").getDoubleValue();
@@ -154,13 +133,13 @@
double dy1 = dimensions.getAttribute("y1").getDoubleValue(); double dy2 = dimensions.getAttribute("y2").getDoubleValue(); double dz = dimensions.getAttribute("z").getDoubleValue();
-
+
int system = this.getSystemID();
-
+
// Crystal material. Element mat = node.getChild("material"); String materialName = mat.getAttributeValue("name");
-
+
// Layout parameters. Element layout = node.getChild("layout"); double beamgap = layout.getAttribute("beamgap").getDoubleValue();
@@ -168,20 +147,38 @@
int ny = layout.getAttribute("ny").getIntValue(); double dface = layout.getAttribute("dface").getDoubleValue();
+ double tdx, tdy, tdz; + double bdx, bdy, bdz; + tdx = tdy = tdz = bdx = bdy = bdz = 0.; + Element topElement = layout.getChild("top"); + Element bottomElement = layout.getChild("bottom"); + if (topElement != null) { + if (topElement.getAttribute("dx") != null) + tdx = topElement.getAttribute("dx").getDoubleValue(); + if (topElement.getAttribute("dy") != null) + tdy = topElement.getAttribute("dy").getDoubleValue(); + if (topElement.getAttribute("dz") != null) + tdz = topElement.getAttribute("dz").getDoubleValue(); + } + if (bottomElement != null) { + if (bottomElement.getAttribute("dx") != null) + bdx = bottomElement.getAttribute("dx").getDoubleValue(); + if (bottomElement.getAttribute("dy") != null) + bdy = bottomElement.getAttribute("dy").getDoubleValue(); + if (bottomElement.getAttribute("dz") != null) + bdz = bottomElement.getAttribute("dz").getDoubleValue(); + } +
// Setup range of indices to be skipped.
- for (Object obj : layout.getChildren("remove")) - { - Element remove = (Element)obj; - try - {
+ for (Object obj : layout.getChildren("remove")) { + Element remove = (Element) obj; + try {
ranges.add(new CrystalRange(remove));
- } - catch (Exception x) - {
+ } catch (Exception x) {
throw new RuntimeException(x); } }
-
+
// Setup crystal logical volume. Trapezoid crystalTrap = new Trapezoid("crystal_trap", dx1, dx2, dy1, dy2, dz); Volume crystalLogVol = new Volume("crystal_volume", crystalTrap, lcdd.getMaterial(materialName));
@@ -189,123 +186,111 @@
// Set vis attributes on crystal log vol. setVisAttributes(lcdd, this.getNode(), crystalLogVol);
-
+
// Add shape and log vol to lcdd. lcdd.add(crystalTrap); lcdd.add(crystalLogVol);
-
+
// Place crystals in world volume. Volume world = lcdd.pickMotherVolume(this); // // Now we calculate parameters for crystal placement... //
-
+
// Slope of the trapezoid side in X.
- double sx = (dx2-dx1)/(2*dz); - - // Angle of the side of the trapezoid w.r.t. center line in X. Rotation about Y axis. - double dthetay = atan(sx); -
+ double sx = (dx2 - dx1) / (2 * dz); + + // Angle of the side of the trapezoid w.r.t. center line in X. Rotation about Y axis. + double dthetay = atan(sx); +
// Slope of the trapezoid side in Y.
- double sy = (dy2-dy1)/(2*dz); - - // Angle of the side of the trapezoid w.r.t. center line in Y. Rotation about X axis.
+ double sy = (dy2 - dy1) / (2 * dz); + + // Angle of the side of the trapezoid w.r.t. center line in Y. Rotation about X axis.
double dthetax = atan(sx);
-
+
// Distance between (virtual) angular origin and center of trapezoid in X.
- double z0x = dx1/sx+dz; -
+ double z0x = dx1 / sx + dz; +
// Distance between (virtual) angular origin and center of trapezoid in Y.
- double z0y = dy1/sy+dz; -
+ double z0y = dy1 / sy + dz; +
// Odd or even number of crystals in X. boolean oddx = (nx % 2 != 0);
-
+
// Calculate number of X for loop.
- if (oddx) - {
+ if (oddx) {
nx -= 1; nx /= 2;
- } - else - {
+ } else {
nx /= 2; } double ycorrtot = 0; double zcorrtoty = 0;
-
+
Define define = lcdd.getDefine();
- for (int iy=1; iy<=ny; iy++) - {
+ for (int iy = 1; iy <= ny; iy++) {
double zcorrtotx = 0; double xcorrtot = 0;
- - int coeffy = 2*iy-1; - double thetax = coeffy*dthetax; - double zcorry = dy1*(2*sin(coeffy*dthetax)); - double ycorr = zcorry*tan((coeffy-1)*dthetax); - double ycenter = z0y*sin(coeffy*dthetax)+ycorr+ycorrtot+(crystalTolerance*iy);
+ + int coeffy = 2 * iy - 1; + double thetax = coeffy * dthetax; + double zcorry = dy1 * (2 * sin(coeffy * dthetax)); + double ycorr = zcorry * tan((coeffy - 1) * dthetax); + double ycenter = z0y * sin(coeffy * dthetax) + ycorr + ycorrtot + (crystalTolerance * iy);
double thetaz = 0;
- - for (int ix=0; ix<=nx; ix++) - {
+ + for (int ix = 0; ix <= nx; ix++) {
// Coefficient for even/odd crystal
- int coeffx = 2*ix; - if (!oddx) - {
+ int coeffx = 2 * ix; + if (!oddx) {
coeffx -= 1; // For even number of crystals, the 0th is skipped.
- if (ix==0)
+ if (ix == 0)
continue; }
-
+
// Set parameters for next crystal placement.
- double thetay = coeffx*dthetay; - double zcorrx = dx1*(2*sin(coeffx*dthetay)); - double xcorr = zcorrx*tan((coeffx-1)*dthetay); - double xcenter = z0x*sin(coeffx*dthetay)+xcorr+xcorrtot+(crystalTolerance*ix); - double zcenter = z0y*(cos(coeffy*dthetax)-1)+z0x*(cos(coeffx*dthetay)-1)+zcorrx+zcorrtotx+zcorry+zcorrtoty;
+ double thetay = coeffx * dthetay; + double zcorrx = dx1 * (2 * sin(coeffx * dthetay)); + double xcorr = zcorrx * tan((coeffx - 1) * dthetay); + double xcenter = z0x * sin(coeffx * dthetay) + xcorr + xcorrtot + (crystalTolerance * ix); + double zcenter = z0y * (cos(coeffy * dthetax) - 1) + z0x * (cos(coeffx * dthetay) - 1) + zcorrx + zcorrtotx + zcorry + zcorrtoty;
zcenter += dz;
- - String baseName = "crystal"+ix+"-"+iy;
+ + String baseName = "crystal" + ix + "-" + iy;
// // Bottom section. //
- - if (checkRange(ix, -iy, ranges)) - {
+ + if (checkRange(ix, -iy, ranges)) {
// Transform of positive bottom crystal.
- Position iposBot = - new Position(baseName+"_pos_pos_bot", xcenter, -(beamgap+ycenter+tolerance), zcenter+tolerance+dface); - //System.out.println("iposBot = " + iposBot.x() + ", " + iposBot.y() + " , " + iposBot.z() + " --> " + ix + ", " + -iy); - Rotation irotBot = - new Rotation(baseName+"_rot_pos_bot", -thetax, -thetay, thetaz);
+ Position iposBot = new Position(baseName + "_pos_pos_bot", xcenter + bdx, -(beamgap + ycenter + tolerance) + bdy, zcenter + tolerance + dface + bdz); + // System.out.println("iposBot = " + iposBot.x() + ", " + iposBot.y() + " , " + + // iposBot.z() + " --> " + ix + ", " + -iy); + Rotation irotBot = new Rotation(baseName + "_rot_pos_bot", -thetax, -thetay, thetaz);
define.addPosition(iposBot);
- define.addRotation(irotBot);
+ define.addRotation(irotBot);
// Place positive crystal.
- PhysVol posCrystalPlacementBot = new PhysVol(crystalLogVol, world, iposBot, irotBot); -
+ PhysVol posCrystalPlacementBot = new PhysVol(crystalLogVol, world, iposBot, irotBot); +
// Add volume IDs. posCrystalPlacementBot.addPhysVolID("system", system); posCrystalPlacementBot.addPhysVolID("ix", ix);
- posCrystalPlacementBot.addPhysVolID("iy", -iy);
+ posCrystalPlacementBot.addPhysVolID("iy", -iy);
} // Reflection to negative.
- if (ix != 0) - { - if (checkRange(-ix, -iy, ranges)) - {
+ if (ix != 0) { + if (checkRange(-ix, -iy, ranges)) {
// Transform of negative.
- Position iposnegBot = - new Position(baseName+"_pos_neg_bot", -xcenter, -(beamgap+ycenter+tolerance), zcenter+tolerance+dface); - Rotation irotnegBot = - new Rotation(baseName+"_rot_neg_bot", -thetax, thetay, thetaz);
+ Position iposnegBot = new Position(baseName + "_pos_neg_bot", -xcenter + bdx, -(beamgap + ycenter + tolerance) + bdy, zcenter + tolerance + dface + bdz); + Rotation irotnegBot = new Rotation(baseName + "_rot_neg_bot", -thetax, thetay, thetaz);
define.addPosition(iposnegBot); define.addRotation(irotnegBot);
@@ -319,36 +304,29 @@
negCrystalPlacementBot.addPhysVolID("iy", -iy); } }
- - if (checkRange(ix, iy, ranges)) - {
+ + if (checkRange(ix, iy, ranges)) {
// Transform of positive top crystal.
- Position iposTop = - new Position(baseName+"_pos_pos_top", xcenter, beamgap+ycenter+tolerance, zcenter+tolerance+dface); - Rotation irotTop = - new Rotation(baseName+"_rot_pos_top", thetax, -thetay, thetaz);
+ Position iposTop = new Position(baseName + "_pos_pos_top", xcenter + tdx, beamgap + ycenter + tolerance + tdy, zcenter + tolerance + dface + tdz); + Rotation irotTop = new Rotation(baseName + "_rot_pos_top", thetax, -thetay, thetaz);
define.addPosition(iposTop);
- define.addRotation(irotTop);
+ define.addRotation(irotTop);
// Place positive top crystal. PhysVol posCrystalPlacementTop = new PhysVol(crystalLogVol, world, iposTop, irotTop);
- - // Add volume IDs.
+ + // Add volume IDs.
posCrystalPlacementTop.addPhysVolID("system", system); posCrystalPlacementTop.addPhysVolID("ix", ix); posCrystalPlacementTop.addPhysVolID("iy", iy); } // Reflection to negative.
- if (ix != 0) - { - if (checkRange(-ix, iy, ranges)) - {
+ if (ix != 0) { + if (checkRange(-ix, iy, ranges)) {
// Transform of negative.
- Position iposnegTop = - new Position(baseName+"_pos_neg_top", -xcenter, beamgap+ycenter+tolerance, zcenter+tolerance+dface); - Rotation irotnegTop = - new Rotation(baseName+"_rot_neg_top", thetax, thetay, thetaz);
+ Position iposnegTop = new Position(baseName + "_pos_neg_top", -xcenter + tdx, beamgap + ycenter + tolerance + tdy, zcenter + tolerance + dface + tdz); + Rotation irotnegTop = new Rotation(baseName + "_rot_neg_top", thetax, thetay, thetaz);
define.addPosition(iposnegTop); define.addRotation(irotnegTop);
@@ -362,20 +340,19 @@
negCrystalPlacementTop.addPhysVolID("iy", iy); } }
-
+
// Increment running X and Z totals and include tolerance to avoid overlaps. xcorrtot += xcorr; zcorrtotx += zcorrx;
- } -
+ } +
// Increment running Y totals. ycorrtot += ycorr; zcorrtoty += zcorry; } }
- - public boolean isCalorimeter() - {
+ + public boolean isCalorimeter() {
return true; } }
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1