diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/DCGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/DCGeant4Factory.java index 574999888..28e5782fa 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/DCGeant4Factory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/DCGeant4Factory.java @@ -581,7 +581,7 @@ public final class DCGeant4Factory extends Geant4Factory { private int nsgwires; private final double y_enlargement = 3.65; - private final double z_enlargement = -2.96; + private final double z_enlargement = -2.46; private final double microgap = 0.01; private final Wire[][][][] wires; @@ -889,20 +889,30 @@ public Geant4Basic createRegion(int isector, int iregion) { return regionVolume; } - /////////////////////////////////////////////////// + + /** + * Create GEANT4 superlayer volume: + * - from first to last guard wire in layer=0 to define y + * - from first to last guard wire plane in z + * @param isuper + * @return + */ public Geant4Basic createSuperlayer(int isuper) { int nsglayers = dbref.nsenselayers(isuper) + dbref.nguardlayers(isuper); - Wire lw0 = new Wire(1, isuper, 1, 0); - Wire lw1 = new Wire(1, isuper, nsglayers-2, nsgwires - 1); + Wire lw0 = new Wire(1, isuper, 0, 0); + Wire lw1 = new Wire(1, isuper, 0, nsgwires - 1); + Wire lw2 = new Wire(1, isuper, 2, 0); - Vector3d midline = lw1.mid().minus(lw0.mid()); - double lay_dy = Math.sqrt(Math.pow(midline.magnitude(), 2.0) - Math.pow(midline.dot(lw0.dir()), 2.0)) / 2.0; + Vector3d yline = lw1.mid().minus(lw0.mid()); + double lay_dy = Math.sqrt(Math.pow(yline.magnitude(), 2.0) - Math.pow(yline.dot(lw0.dir()), 2.0)) / 2.0; double lay_dx0 = lw0.length() / 2.0; double lay_dx1 = lw1.length() / 2.0; - double lay_dz = (dbref.cellthickness(isuper)*dbref.nsenselayers(isuper)+1) * dbref.wpdist(isuper) / 2.0; + double lay_dz = (dbref.cellthickness(isuper)*dbref.nsenselayers(isuper)+1) * dbref.wpdist(isuper)/Math.cos(dbref.thtilt(isuper/2))/ 2.0; double lay_skew = lw0.center().minus(lw1.center()).angle(lw1.dir()) - Math.toRadians(90.0); - Vector3d lcent = lw0.center().plus(lw1.center()).dividedBy(2.0); + Vector3d zline = lw2.mid().minus(lw0.mid()).normalized(); + Vector3d lcent = lw0.center().plus(lw1.center()).dividedBy(2.0).plus(zline.times(lay_dz)); + G4Trap superlayerVolume = new G4Trap("sl" + (isuper + 1), lay_dz, -dbref.thtilt(isuper / 2), Math.toRadians(90.0), lay_dy, lay_dx0, lay_dx1, lay_skew,