GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
diff -u -r1.3 -r1.4
--- HPSEcal3.java 1 Sep 2011 23:58:41 -0000 1.3
+++ HPSEcal3.java 8 Sep 2011 06:32:59 -0000 1.4
@@ -23,41 +23,41 @@
/**
* LCDD model for the HPS inner ECal.
*
- * Coordinate System defined as follows:
- *
+ * Coordinate System defined as follows:<br>
+ *
* <ul>
* <li>Beam travels in +X direction.</li>
* <li>Magnetic field is in -Z.</li>
* <li>Y is the beam bend plane.</li>
* </ul>
*
- * The <dimensions> element defines the crystal HALF dimensions: x1, x2, y1, y2, and z.
+ * The <dimensions> element defines the crystal HALF dimensions: x1, x2, y1, y2, and z.<br>
*
- * The <layout> element defines the placement of the crystals.
+ * The <layout> element defines the number of crystals and (optionally) crystals to be left out.<br>
*
* <ul>
- * <li>beamgap - offset from the beamline in the Y coordinate of the top and bottom halves</li>
- * <li>nx - number of crystals in X</li>
- * <li>ny - number of crystals in Y along each side of beam</li>
- * <li>dface - distance from origin to the face of the calorimeter along Z</li>
+ * <li><b>beamgap</b> - offset from the beamline in the Y coordinate of the top and bottom halves</li>
+ * <li><b>nx</b> - number of crystals in X</li>
+ * <li><b>ny</b> - number of crystals in Y along each side of beam</li>
+ * <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.
+ * crystal placement by range. This element has the following parameters.<br>
*
* <ul>
- * <li>ixmin - minimum x index to exclude (inclusive)</li>
- * <li>ixmax - maximum x index to exclude (inclusive)</li>
- * <li>iymin - minimum y index to exclude (inclusive)</li>
- * <li>iymax - maximum y index to exclude (inclusive)</li>
+ * <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>
*
- * To be excluded, a crystal's ID must pass all four of these min/max checks.
+ * 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.3 2011/09/01 23:58:41 jeremy Exp $
+ * @version $Id: HPSEcal3.java,v 1.4 2011/09/08 06:32:59 jeremy Exp $
*/
public class HPSEcal3 extends LCDDSubdetector
{
@@ -146,7 +146,8 @@
{
if (sens == null)
throw new RuntimeException("SensitiveDetector parameter points to null.");
-
+
+
// Crystal dimensions.
Element dimensions = node.getChild("dimensions");
double dx1 = dimensions.getAttribute("x1").getDoubleValue();
@@ -186,28 +187,21 @@
Trapezoid crystalTrap = new Trapezoid("crystal_trap", dx1, dx2, dy1, dy2, dz);
Volume crystalLogVol = new Volume("crystal_volume", crystalTrap, lcdd.getMaterial(materialName));
crystalLogVol.setSensitiveDetector(sens);
+
+ // 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);
- // Mother volume dimensions.
- double mx, my, mz;
- mx = nx*Math.max(dx2, dx1)*margin;
- my = ny*Math.max(dy2, dy1)*margin;
- my *= 2;
- my += beamgap;
- mz = dz*margin;
-
- // Get mother volume for envelope.
+ // Place crystals in world volume.
Volume world = lcdd.pickMotherVolume(this);
- // Envelope box and logical volume for one section of ECal.
- Box momBox = new Box("ecal_env_box", mx*2, my*2, mz*2);
- Volume momVol = new Volume("ecal_env_volume", momBox, lcdd.getMaterial("Air"));
-
- lcdd.add(momBox);
- lcdd.add(momVol);
-
+ //
+ // Now we calculate parameters for crystal placement...
+ //
+
// Slope of the trapezoid side in X.
double sx = (dx2-dx1)/(2*dz);
@@ -255,6 +249,7 @@
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++)
{
@@ -269,7 +264,6 @@
}
// Set parameters for next crystal placement.
- // FIXME Need documentation here on the crystal placement and rotation algorithm.
double thetay = coeffx*dthetay;
double zcorrx = dx1*(2*sin(coeffx*dthetay));
double xcorr = zcorrx*tan((coeffx-1)*dthetay);
@@ -277,8 +271,6 @@
double zcenter = z0y*(cos(coeffy*dthetax)-1)+z0x*(cos(coeffx*dthetay)-1)+zcorrx+zcorrtotx+zcorry+zcorrtoty;
zcenter += dz;
- double thetaz = 0;
-
String baseName = "crystal"+ix+"-"+iy;
//
@@ -381,13 +373,10 @@
ycorrtot += ycorr;
zcorrtoty += zcorry;
}
-
- // Make the section box invisible.
- momVol.setVisAttributes(lcdd.getVisAttributes("InvisibleWithDaughters"));
}
public boolean isCalorimeter()
{
return true;
}
-}
\ No newline at end of file
+}