GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
diff -u -r1.7 -r1.8
--- HPSEcal.java 13 Apr 2011 23:32:37 -0000 1.7
+++ HPSEcal.java 14 Apr 2011 22:15:46 -0000 1.8
@@ -20,7 +20,7 @@
/**
* LCDD model for the HPS inner ECal.
*
- * The dimensions element defines x1, x2, y1, y2, and z as half the full dimension.
+ * The dimensions element defines x1, x2, y1, y2, and z as half the full dimension of a crystal.
*
* The layout element defines the placement of the crystals. The beamgap defines the
* offset from the beamline in the Y coordinate, in the natural Geant4 coordinate system.
@@ -28,10 +28,13 @@
* defines the number of crystals in Y, on each side of the beamline. For example, to
* get 4 rows of crystals in Y, then ny would be 2.
*
+ * The position element has a z attribute that defines the distance from the origin
+ * to the front face of the crystal array.
+ *
* @author Jeremy McCormick
* @author Tim Nelson
*
- * @version $Id: HPSEcal.java,v 1.7 2011/04/13 23:32:37 jeremy Exp $
+ * @version $Id: HPSEcal.java,v 1.8 2011/04/14 22:15:46 jeremy Exp $
*/
public class HPSEcal extends LCDDSubdetector
{
@@ -39,7 +42,7 @@
static final double tolerance = 0.1;
// Tolerance factor for separating crystals to avoid overlaps.
- static final double crystalTolerance = 0.2;
+ static final double crystalTolerance = 0.1;
HPSEcal(Element node) throws JDOMException
{
@@ -68,11 +71,13 @@
Element layout = node.getChild("layout");
double beamgap = layout.getAttribute("beamgap").getDoubleValue();
int nx = layout.getAttribute("nx").getIntValue();
- int ny = layout.getAttribute("ny").getIntValue();
+ int ny = layout.getAttribute("ny").getIntValue();
+ double dface = layout.getAttribute("dface").getDoubleValue();
System.out.println("beamgap="+beamgap);
System.out.println("nx="+nx);
System.out.println("ny="+ny);
+ System.out.println("dface="+dface);
Trapezoid crystalTrap = new Trapezoid("crystal_trap", dx1, dx2, dy1, dy2, dz);
Volume crystalLogVol = new Volume("crystal_volume", crystalTrap, lcdd.getMaterial(materialName));
@@ -81,18 +86,17 @@
lcdd.add(crystalLogVol);
Define define = lcdd.getDefine();
- //Volume mother = lcdd.pickMotherVolume(this);
// Mother volume dimensions.
double mx, my, mz;
double margin = 1.1;
- mx = nx*Math.max(dx2,dx1);
- //mx *= margin;
- my = ny*Math.max(dy2, dy1);
- //my *= margin;
- mz = dz;
- //mz *= margin;
- Box momBox = new Box("mom_box", mx*2*margin, my*2*margin, mz*2*margin);
+ mx = nx*Math.max(dx2,dx1)*margin;
+ my = ny*Math.max(dy2, dy1)*margin;
+ mz = dz*margin;
+
+ // Envelope box and logical volume for one section (upper and lower each use this for placement).
+ // TODO Turn off visualization of envelope vol. Set daughters visible.
+ Box momBox = new Box("mom_box", mx*2, my*2, mz*2);
Volume momVol = new Volume("mom_volume", momBox, lcdd.getMaterial("Air"));
lcdd.add(momBox);
@@ -163,17 +167,14 @@
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;
- //double thetaz = -Math.pow(sin(thetay),2)*thetax;
double thetaz = 0;
String baseName = "crystal"+ix+"-"+iy;
- // TEST
- //if (iy == ny)
- //{
Position ipos =
- new Position(baseName+"_pos_pos", xcenter, ycenter-my*margin+tolerance, zcenter-((margin-1)*mz)+tolerance);
+ new Position(baseName+"_pos_pos", xcenter, ycenter-my+tolerance, zcenter-mz+tolerance);
Rotation irot =
new Rotation(baseName+"_rot_pos", thetax, -thetay, thetaz);
@@ -188,7 +189,7 @@
if (ix != 0)
{
Position iposneg =
- new Position(baseName+"_pos_neg", -xcenter, ycenter-my*margin+tolerance, zcenter-((margin-1)*mz)+tolerance);
+ new Position(baseName+"_pos_neg", -xcenter, ycenter-my+tolerance, zcenter-mz+tolerance);
Rotation irotneg =
new Rotation(baseName+"_rot_neg", thetax, thetay, thetaz);
@@ -198,7 +199,7 @@
PhysVol negCrystalPlacement = new PhysVol(crystalLogVol, momVol, iposneg, irotneg);
// TODO Add PhysVolID.
}
- //}
+
// Increment running X and Z totals and include tolerance to avoid overlaps.
xcorrtot += xcorr;
zcorrtotx += zcorrx;
@@ -208,13 +209,22 @@
ycorrtot += ycorr;
zcorrtoty += zcorry;
}
-
- // Mother volume placement.
+
+ // Get mother volume for envelope.
Volume world = lcdd.pickMotherVolume(this);
- Position mpos = new Position(momVol.getVolumeName() + "_pos", 0, 0, 0);
- Rotation mrot = new Rotation(momVol.getVolumeName() + "_rot", 0, 0, 0);
- define.addPosition(mpos);
- define.addRotation(mrot);
- new PhysVol(momVol, world, mpos, mrot);
+
+ // Place the top section.
+ Position mpostop = new Position(momVol.getVolumeName() + "_top_pos", dface+mz, 0, my+beamgap);
+ Rotation mrottop = new Rotation(momVol.getVolumeName() + "_top_rot", 0, -Math.PI/2, (3*Math.PI)/2);
+ define.addPosition(mpostop);
+ define.addRotation(mrottop);
+ new PhysVol(momVol, world, mpostop, mrottop);
+
+ // Place the bottom section.
+ Position mposbot = new Position(momVol.getVolumeName() + "_bot_pos", dface+mz, 0, -my-beamgap);
+ Rotation mrotbot = new Rotation(momVol.getVolumeName() + "_bot_rot", 0, -Math.PI/2, Math.PI/2);
+ define.addPosition(mposbot);
+ define.addRotation(mrotbot);
+ new PhysVol(momVol, world, mposbot, mrotbot);
}
}
\ No newline at end of file