Skip to content

Commit 047f594

Browse files
added support for geeant4 polycones (#1346)
* added support for geeant4 polycoones * fixed bug in number of dimensions of G4Pcone --------- Co-authored-by: Nathan Baltzell <baltzell@gmx.com>
1 parent 9223156 commit 047f594

3 files changed

Lines changed: 94 additions & 2 deletions

File tree

common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUCALGeant4Factory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import java.util.ArrayList;
55
import org.jlab.detector.volume.Geant4Basic;
66
import org.jlab.detector.units.SystemOfUnits.Length;
7-
import org.jlab.detector.volume.G4Pgon;
7+
import org.jlab.detector.volume.G4Pcone;
88
import org.jlab.detector.volume.G4Trd;
99
import org.jlab.detector.volume.G4World;
1010
import org.jlab.geom.base.ConstantProvider;
@@ -24,7 +24,7 @@ public MUCALGeant4Factory(ConstantProvider provider) {
2424
double[] mucal_iradius = {301.0*Length.mm, 72.8*Length.mm, 81.5*Length.mm, 98.7*Length.mm};
2525
double[] mucal_oradius = {301.1*Length.mm, 360.6*Length.mm, 401.0*Length.mm, 98.8*Length.mm};
2626
double[] mucal_zpos_root = {520.0*Length.mm, 625.0*Length.mm, 696.0*Length.mm, 836.0*Length.mm};
27-
G4Pgon mucalVolume = new G4Pgon("mucalVolume", phiStart, phiTotal, nplanes, nplanes, mucal_zpos_root, mucal_iradius, mucal_oradius);
27+
G4Pcone mucalVolume = new G4Pcone("mucalVolume", phiStart, phiTotal, nplanes, mucal_zpos_root, mucal_iradius, mucal_oradius);
2828
mucalVolume.setMother(motherVolume);
2929
for (int sector = 1; sector <= 2; sector++) {
3030
List<G4Trd> layerVolume = createPanel(provider, sector, 1);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.jlab.detector.volume;
2+
3+
import org.jlab.geometry.prim.Pcone;
4+
import org.jlab.detector.units.Measurement;
5+
import org.jlab.detector.units.SystemOfUnits.Angle;
6+
import org.jlab.detector.units.SystemOfUnits.Length;
7+
8+
/**
9+
* @author pdavies/devita
10+
*/
11+
// FIXME: currently support only polyheadra defintion to gemc geometry
12+
public class G4Pcone extends Geant4Basic {
13+
14+
public G4Pcone(String name, double phiStart, double phiTotal, int numZPlanes,
15+
double[] zPlane, double[] rInner, double[] rOuter ) {
16+
17+
super( new Pcone(phiStart, phiTotal, numZPlanes, zPlane, rInner, rOuter));
18+
setName( name );
19+
setType("Polycone");
20+
21+
Measurement[] dimensions = new Measurement[3+3*numZPlanes];
22+
dimensions[0] = Angle.value(phiStart);
23+
dimensions[1] = Angle.value(phiTotal);
24+
dimensions[2] = new Measurement(numZPlanes,"counts");
25+
for(int i=0; i<numZPlanes; i++) dimensions[3+0*numZPlanes+i] = Length.value(rInner[i]);
26+
for(int i=0; i<numZPlanes; i++) dimensions[3+1*numZPlanes+i] = Length.value(rOuter[i]);
27+
for(int i=0; i<numZPlanes; i++) dimensions[3+2*numZPlanes+i] = Length.value(zPlane[i]);
28+
setDimensions(dimensions);
29+
}
30+
31+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package org.jlab.geometry.prim;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
import eu.mihosoft.vrl.v3d.Polygon;
6+
import eu.mihosoft.vrl.v3d.Primitive;
7+
import eu.mihosoft.vrl.v3d.PropertyStorage;
8+
9+
/**
10+
* @author pdavies/devita
11+
*/
12+
13+
// FIXME: currently support only polyheadra defintion to gemc geometry
14+
public class Pcone implements Primitive {
15+
16+
private final PropertyStorage properties = new PropertyStorage();
17+
private int numZPlanes;
18+
private double phiStart, phiTotal;
19+
double[] zPlane;
20+
double[] rInner;
21+
double[] rOuter;
22+
23+
public Pcone(double phiStart,
24+
double phiTotal,
25+
int numZPlanes,
26+
double[] zPlane,
27+
double[] rInner,
28+
double[] rOuter)
29+
{
30+
if( numZPlanes < 0 || phiStart < 0 || phiTotal <= 0 ) {
31+
throw new IllegalArgumentException("Illegal arguments for Polyhedra Primitive!");
32+
}
33+
if( zPlane.length<2 || rInner.length<2 || rOuter.length<2) {
34+
throw new IllegalArgumentException("Illegal arguments for Polyhedra Primitive!");
35+
}
36+
if( zPlane.length!=rInner.length || zPlane.length!=rOuter.length) {
37+
throw new IllegalArgumentException("Illegal arguments for Polyhedra Primitive!");
38+
}
39+
40+
this.phiStart = phiStart;
41+
this.phiTotal = phiTotal;
42+
this.zPlane = zPlane;
43+
this.rInner = rInner;
44+
this.rOuter = rOuter;
45+
}
46+
47+
@Override
48+
public List<Polygon> toPolygons()
49+
{
50+
List<Polygon> polygons = new ArrayList<>();
51+
// just returns something to not cause a NullPointerException
52+
return polygons;
53+
}
54+
55+
@Override
56+
public PropertyStorage getProperties()
57+
{
58+
return null;
59+
}
60+
61+
}

0 commit comments

Comments
 (0)