77//package clas12vis;
88
99package org .jlab .geom .detector .alert .ATOF ;
10-
1110import org .jlab .geom .base .ConstantProvider ;
1211import org .jlab .geom .base .DetectorTransformation ;
1312import org .jlab .geom .base .Factory ;
1413import org .jlab .geom .component .ScintillatorPaddle ;
15- import org .jlab .geom .prim .Plane3D ;
1614import org .jlab .geom .prim .Point3D ;
1715import org .jlab .geom .prim .Transformation3D ;
1816
19- import java .util .ArrayList ;
20- import java .util .List ;
2117
2218/**
23- * @author viktoriya
24- * this is the latest ATOF geometry class to be used in reco. and in GEMC simulations!
25- * commit on July 02, 2020
19+ * @author viktoriya, pilleux
20+ * Original geometry July 02, 2020
21+ * Updated December 2024 to match actual atof conventions
22+ * ATOF geometry class to be used in reco. and in GEMC simulations!
2623 */
2724public class AlertTOFFactory implements Factory <AlertTOFDetector , AlertTOFSector , AlertTOFSuperlayer , AlertTOFLayer > {
2825
29- private final int nsectors = 15 ;
30- private final int nsuperl = 2 ;
31- private final int nlayers1 = 10 ;
32- private final int npaddles = 4 ;
33-
26+ //Convention definitions: https://clasweb.jlab.org/wiki/index.php/File:Atof_def.png
27+ //The atof has 15 phi sectors.
28+ private final int nsectors = 15 ;
29+ //Top superlayer (index 1) = wedges.
30+ //Bottom one (0) = bar.
31+ private final int nsuperl = 2 ;
32+ //Layers = quarters of sectors.
33+ private final int nlayers = 4 ;
34+ //Components = slices in z. 10 for the wedges, 1 for the bar.
35+ private final int ncomponents = 10 ;
36+
37+ //Each pad = quarter of module
3438 private final double openAng_pad_deg = 6.0 ;
35- private final double openAng_pad_rad = Math . toRadians ( openAng_pad_deg );
36- private final double openAng_sector_rad = npaddles * openAng_pad_rad ;
39+ //4 pads = 4 layers = 1 sector
40+ private final double openAng_sector_deg = nlayers * openAng_pad_deg ;
3741
3842 @ Override
3943 public AlertTOFDetector createDetectorCLAS (ConstantProvider cp ) {
@@ -72,23 +76,15 @@ public AlertTOFSuperlayer createSuperlayer(ConstantProvider cp, int sectorId, in
7276 if (!(0 <= sectorId && sectorId < nsectors )) throw new IllegalArgumentException ("Error: invalid sector=" + sectorId );
7377 if (!(0 <= superlayerId && superlayerId < nsuperl )) throw new IllegalArgumentException ("Error: invalid superlayer=" + superlayerId );
7478 AlertTOFSuperlayer superlayer = new AlertTOFSuperlayer (sectorId , superlayerId );
75-
76- if (superlayerId == 0 ) {
77- int nlayers0 = 1 ;
78- for (int layerId = 0 ; layerId < nlayers0 ; layerId ++)
79- superlayer .addLayer (createLayer (cp , sectorId , superlayerId , layerId ));
80- } else {
81- for (int layerId = 0 ; layerId < nlayers1 ; layerId ++)
82- superlayer .addLayer (createLayer (cp , sectorId , superlayerId , layerId ));
83- }
79+ for (int layerId = 0 ; layerId < nlayers ; layerId ++) superlayer .addLayer (createLayer (cp , sectorId , superlayerId , layerId ));
8480 return superlayer ;
8581 }
86-
82+
8783 @ Override
8884 public AlertTOFLayer createLayer (ConstantProvider cp , int sectorId , int superlayerId , int layerId ) {
8985 if (!(0 <= sectorId && sectorId < nsectors )) throw new IllegalArgumentException ("Error: invalid sector=" + sectorId );
9086 if (!(0 <= superlayerId && superlayerId < nsuperl )) throw new IllegalArgumentException ("Error: invalid superlayer=" + superlayerId );
91- if (!(0 <= layerId && layerId < nlayers1 )) throw new IllegalArgumentException ("Error: invalid layer=" + layerId );
87+ if (!(0 <= layerId && layerId < nlayers )) throw new IllegalArgumentException ("Error: invalid layer=" + layerId );
9288
9389 double R0 = 77.0d ;
9490 double R1 = 80.0d ;
@@ -109,54 +105,68 @@ public AlertTOFLayer createLayer(ConstantProvider cp, int sectorId, int superlay
109105 double gap_pad_z = 0.3d ; // mm, gap between paddles in z
110106
111107 AlertTOFLayer layer = new AlertTOFLayer (sectorId , superlayerId , layerId );
112-
113- List <Plane3D > planes = new ArrayList <>();
114-
115- double len_b = layerId * pad_z + layerId * gap_pad_z ; // back paddle plan
116- double len_f = len_b + pad_z ; // front paddle plan
108+
109+ //Dimensions for the bar
117110 double Rl = R0 ;
118111 double dR = dR0 ;
119112 double widthTl = small_pad_b2 ;
120113 double widthBl = small_pad_b1 ;
121-
114+ //Dimensions for the wedge
122115 if (superlayerId == 1 ) {
123116 Rl = R1 ;
124117 dR = dR1 ;
125118 widthTl = pad_b2 ;
126119 widthBl = pad_b1 ;
127120 }
128-
129- for (int padId = 0 ; padId < npaddles ; padId ++) {
130- Point3D p0 = new Point3D (-dR / 2 , -widthBl / 2 , len_f );
131- Point3D p1 = new Point3D (dR / 2 , -widthTl / 2 , len_f );
132- Point3D p2 = new Point3D (dR / 2 , widthTl / 2 , len_f );
133- Point3D p3 = new Point3D (-dR / 2 , widthBl / 2 , len_f );
134-
135- Point3D p4 = new Point3D (-dR / 2 , -widthBl / 2 , len_b );
136- Point3D p5 = new Point3D (dR / 2 , -widthTl / 2 , len_b );
137- Point3D p6 = new Point3D (dR / 2 , widthTl / 2 , len_b );
138- Point3D p7 = new Point3D (-dR / 2 , widthBl / 2 , len_b );
139- ScintillatorPaddle Paddle = new ScintillatorPaddle (sectorId * 4 + padId , p0 , p1 , p2 , p3 , p4 , p5 , p6 , p7 );
140-
141- double openAng_sector_deg = npaddles * openAng_pad_deg ;
142- Paddle .rotateZ (Math .toRadians (padId * openAng_pad_deg + sectorId * openAng_sector_deg ));
143-
144- double xoffset ;
145- double yoffset ;
146-
147- xoffset = (Rl + dR / 2 ) * Math .cos (padId * openAng_pad_rad + sectorId * openAng_sector_rad );
148- yoffset = (Rl + dR / 2 ) * Math .sin (padId * openAng_pad_rad + sectorId * openAng_sector_rad );
149-
150- Paddle .translateXYZ (xoffset , yoffset , 0 );
151-
152- // Add the paddles to the list
153- layer .addComponent (Paddle );
121+
122+ //Layer = quarter of a sector
123+ double current_angle_deg = layerId * openAng_pad_deg + sectorId * openAng_sector_deg ;
124+ //Aligning the y axis with the separation between modules 0 and 14
125+ current_angle_deg = current_angle_deg + 90 + 3 ;
126+
127+ //Component = z slice.
128+ //There are 10 for the wedge/top/sl=1
129+ int current_ncomponents = ncomponents ;
130+ //There is only one for the bar/bottom/sl=0
131+ if (superlayerId ==0 ) current_ncomponents = 1 ;
132+
133+ //Starting loop on components
134+ for (int padId = 0 ; padId < current_ncomponents ; padId ++) {
135+
136+ //Component index increases with increasing z
137+ double len_b = padId * pad_z + padId * gap_pad_z ; // back paddle plan
138+ double len_f = len_b + pad_z ; // front paddle plan
139+
140+ Point3D p0 = new Point3D (-dR / 2 , -widthBl / 2 , len_f );
141+ Point3D p1 = new Point3D (dR / 2 , -widthTl / 2 , len_f );
142+ Point3D p2 = new Point3D (dR / 2 , widthTl / 2 , len_f );
143+ Point3D p3 = new Point3D (-dR / 2 , widthBl / 2 , len_f );
144+
145+ Point3D p4 = new Point3D (-dR / 2 , -widthBl / 2 , len_b );
146+ Point3D p5 = new Point3D (dR / 2 , -widthTl / 2 , len_b );
147+ Point3D p6 = new Point3D (dR / 2 , widthTl / 2 , len_b );
148+ Point3D p7 = new Point3D (-dR / 2 , widthBl / 2 , len_b );
149+
150+ //Component index is the z slice for the top/wedge/sl=1
151+ int component = padId ;
152+ //It is 10 for the bottom/bar/sl=0
153+ if (superlayerId ==0 ) component = 10 ;
154+
155+ ScintillatorPaddle Paddle = new ScintillatorPaddle (component , p0 , p1 , p2 , p3 , p4 , p5 , p6 , p7 );
156+
157+ Paddle .rotateZ (Math .toRadians (current_angle_deg ));
158+
159+ double xoffset ;
160+ double yoffset ;
161+
162+ xoffset = (Rl + dR / 2 ) * Math .cos (Math .toRadians (current_angle_deg ));
163+ yoffset = (Rl + dR / 2 ) * Math .sin (Math .toRadians (current_angle_deg ));
164+
165+ Paddle .translateXYZ (xoffset , yoffset , 0 );
166+
167+ // Add the paddles to the list
168+ layer .addComponent (Paddle );
154169 }
155-
156- Plane3D plane = new Plane3D (0 , Rl , 0 , 0 , 1 , 0 );
157- plane .rotateZ (sectorId * openAng_sector_rad - Math .toRadians (90 ));
158- planes .add (plane );
159-
160170 return layer ;
161171 }
162172
0 commit comments