GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
diff -u -r1.4 -r1.5
--- HPSEcal.java 13 Apr 2011 20:06:42 -0000 1.4
+++ HPSEcal.java 13 Apr 2011 21:58:24 -0000 1.5
@@ -24,12 +24,13 @@
* 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.
* The nx attribute defines the number of crystals in the X coordinate. The ny attribute
- * defines the number of crystals in Y, on each side of the beamline.
+ * 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.
*
* @author Jeremy McCormick
* @author Tim Nelson
*
- * @version $Id: HPSEcal.java,v 1.4 2011/04/13 20:06:42 jeremy Exp $
+ * @version $Id: HPSEcal.java,v 1.5 2011/04/13 21:58:24 jeremy Exp $
*/
public class HPSEcal extends LCDDSubdetector
{
@@ -37,10 +38,7 @@
{
super(node);
}
-
- /* (non-Javadoc)
- * @see org.lcsim.geometry.compact.converter.lcdd.LCDDSubdetector#addToLCDD(org.lcsim.geometry.compact.converter.lcdd.util.LCDD, org.lcsim.geometry.compact.converter.lcdd.util.SensitiveDetector)
- */
+
void addToLCDD(LCDD lcdd, SensitiveDetector sens) throws JDOMException
{
// Get the half-dimensions of the calorimeter crystal.
@@ -63,7 +61,7 @@
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();
System.out.println("beamgap="+beamgap);
System.out.println("nx="+nx);
@@ -79,16 +77,25 @@
Volume mother = lcdd.pickMotherVolume(this);
// Slope of the trapezoid side in X.
- double s = (dx2-dx1)/(2*dz);
+ 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(s);
+ 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 dthetax = atan(sx);
- // Distance between (virtual) angular origin and center of trapezoid.
- double z0 = dx1/s+dz;
+ // Distance between (virtual) angular origin and center of trapezoid in X.
+ double z0x = dx1/sx+dz;
+
+ // // Distance between (virtual) angular origin and center of trapezoid in Y.
+ double z0y = dy1/sy+dz;
// Always 0. (no rotation about Z)
- double thetaz = 0;
+ //double thetaz = 0;
// Odd or even number of crystals in X.
boolean oddx = (nx % 2 != 0);
@@ -103,77 +110,85 @@
{
nx /= 2;
}
-
- double thetax = 0;
- double ycenter = 0;
- double zcorrtot = 0;
- double xcorrtot = 0;
-
+
+ double ycorrtot = 0;
+ double zcorrtoty = 0;
//double fudgeFactor = .01;
-
- for (int ix=0; ix<=nx; ix++)
+
+ for (int iy=1; iy<=ny; iy++)
{
- System.out.println("ix="+ix);
-
- // Factor for even/odd.
- int coeff = 2*ix;
- if (!oddx)
- {
- coeff -= 1;
- if (ix==0)
- continue;
- }
-
- System.out.println("coffee="+coeff);
-
- double thetay = coeff*dthetay;
- double zcorr = dx1*(2*sin(coeff*dthetay));
- // Center point of trap front face along line instead of edge.
- // double zcorr = dx1*(sin(2*ix*dthetay))+sin(2*(ix-1)*dthetay));
- double xcorr = zcorr*tan((coeff-1)*dthetay);
- //+ fudgeFactor;
- double xcenter = z0*sin(coeff*dthetay)+xcorr+xcorrtot;
- double zcenter = z0*(cos(coeff*dthetay)-1)+zcorr+zcorrtot;
-
- System.out.println("xcorr="+xcorr);
- System.out.println("xcorrtot="+xcorrtot);
- System.out.println("xcenter="+xcenter);
- System.out.println("zcenter="+zcenter);
- System.out.println("zcorr="+zcorr);
- System.out.println("zcorrtot="+zcorrtot);
- System.out.println("thetay="+thetay);
- System.out.println();
+ double zcorrtotx = 0;
+ double xcorrtot = 0;
- Position ipos =
- new Position("crystal"+ix+"_pos_pos", xcenter, ycenter, zcenter);
- Rotation irot =
- new Rotation("crystal"+ix+"_rot_pos", thetax, -thetay, thetaz);
-
- define.addPosition(ipos);
- define.addRotation(irot);
-
- // Place crystal.
- PhysVol posCrystalPlacement = new PhysVol(crystalLogVol, mother, ipos, irot);
- // TODO Add PhysVolID.
-
- // Reflection to negative.
- if (ix != 0)
- {
- Position iposneg =
- new Position("crystal"+ix+"_pos_neg", -xcenter, ycenter, zcenter);
- Rotation irotneg =
- new Rotation("crystal"+ix+"_rot_neg", thetax, thetay, thetaz);
+ 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;
+
+ for (int ix=0; ix<=nx; ix++)
+ {
+ // Factor for even/odd.
+ int coeffx = 2*ix;
+ if (!oddx)
+ {
+ coeffx -= 1;
+ if (ix==0)
+ continue;
+ }
- define.addPosition(iposneg);
- define.addRotation(irotneg);
+ double thetay = coeffx*dthetay;
+ double zcorrx = dx1*(2*sin(coeffx*dthetay));
+ // Center point of trap front face along line instead of edge.
+ // double zcorr = dx1*(sin(2*ix*dthetay))+sin(2*(ix-1)*dthetay));
+ double xcorr = zcorrx*tan((coeffx-1)*dthetay);
+ //+ fudgeFactor;
+ double xcenter = z0x*sin(coeffx*dthetay)+xcorr+xcorrtot;
+ double zcenter = z0y*(cos(coeffy*dthetax)-1)+z0x*(cos(coeffx*dthetay)-1)+zcorrx+zcorrtotx+zcorry+zcorrtoty;
+
+ //double thetaz = -Math.pow(sin(thetay),2)*thetax;
+ double thetaz = 0;
+
+ String baseName = "crystal"+ix+"-"+iy;
- PhysVol negCrystalPlacement = new PhysVol(crystalLogVol, mother, iposneg, irotneg);
+ // TEST
+ //if (iy == ny)
+ //{
+ Position ipos =
+ new Position(baseName+"_pos_pos", xcenter, ycenter, zcenter);
+ Rotation irot =
+ new Rotation(baseName+"_rot_pos", thetax, -thetay, thetaz);
+
+ define.addPosition(ipos);
+ define.addRotation(irot);
+
+ // Place crystal.
+ PhysVol posCrystalPlacement = new PhysVol(crystalLogVol, mother, ipos, irot);
// TODO Add PhysVolID.
- }
-
- // Increment running X and Z totals.
- xcorrtot += xcorr;
- zcorrtot += zcorr;
- }
+
+ // Reflection to negative.
+ if (ix != 0)
+ {
+ Position iposneg =
+ new Position(baseName+"_pos_neg", -xcenter, ycenter, zcenter);
+ Rotation irotneg =
+ new Rotation(baseName+"_rot_neg", thetax, thetay, thetaz);
+
+ define.addPosition(iposneg);
+ define.addRotation(irotneg);
+
+ PhysVol negCrystalPlacement = new PhysVol(crystalLogVol, mother, iposneg, irotneg);
+ // TODO Add PhysVolID.
+ }
+ //}
+ // Increment running X and Z totals.
+ xcorrtot += xcorr;
+ zcorrtotx += zcorrx;
+ }
+
+ // Increment running Y totals.
+ ycorrtot += ycorr;
+ zcorrtoty += zcorry;
+ }
}
}
\ No newline at end of file