generate_35t4apa_v2.pl
Go to the documentation of this file.
1 #!/usr/bin/perl
2 
3 # Much of this program is taken straight from generate_gdml.pl that
4 # generates MicroBooNE fragment files (Thank you.)
5 
6 # Each subroutine generates a fragment GDML file, and the last subroutine
7 # creates an XML file that make_gdml.pl will use to appropriately arrange
8 # the fragment GDML files to create the final desired DUNE GDML file,
9 # to be named by make_gdml output command
10 
11 # If you are playing with different geometries, you can use the
12 # suffix command to help organize your work.
13 
14 use vars;
15 use Switch;
16 use Math::Trig;
17 use Getopt::Long;
18 use Math::BigFloat;
19 Math::BigFloat->precision(-15);
20 
21 GetOptions( "help|h" => \$help,
22  "suffix|s:s" => \$suffix,
23  "output|o:s" => \$output,
24  "wires|w:s" => \$wires,
25  "helpcube|c" => \$helpcube);
26 
27 if ( defined $help )
28 {
29  # If the user requested help, print the usage notes and exit.
30  usage();
31  exit;
32 }
33 
34 if ( ! defined $suffix )
35 {
36  # The user didn't supply a suffix, so append nothing to the file
37  # names.
38  $suffix = "";
39 }
40 else
41 {
42  # Otherwise, stick a "-" before the suffix, so that a suffix of
43  # "test" applied to filename.gdml becomes "filename-test.gdml".
44  $suffix = "-" . $suffix;
45 }
46 
47 
48 
49 
50 #++++++++++++++++++++++++ Begin defining variables +++++++++++++++++++++++++
51 
52 # Define detector geometry variables - later to be put in a parameters
53 # XML file to be parsed as an input?
54 
55 # set wires on to be the default, unless given an input by the user
56 $wires_on = 1; # 1=on, 0=off
57 if (defined $wires)
58 {
59 $wires_on = $wires
60 }
61 
62 $tpc_on=1;
63 $inch = 2.54;
64 
65 
66 
67 #################################################
68 #### 4APA 35t parameters from DocDb 7550 ####
69 #################################################
70 
71 
72 
73 ##################################################################
74 ##################### wire plane parameters ######################
75 
76 $UWirePitch = .4888;
77 $VWirePitch = .5012;
78 $XWirePitch = .45;
79 
80 $UAng[0] = 45.707;
81 $VAng[0] = 44.275;
82 $UAng[1] = 45.707;
83 $VAng[1] = 44.275;
84 $UAng[2] = 45.707;
85 $VAng[2] = 44.275;
86 $UAng[3] = 45.707;
87 $VAng[3] = 44.275;
88 
89 #$UAng[0] = 36;
90 #$VAng[0] = 36;
91 #$UAng[3] = 36;
92 #$VAng[3] = 36;
93 
94 
95 
96 
97 ##################################################################
98 ######################## TPC parameters ##########################
99 
100 $LongDrift = 227;
101 $ShortDrift = 27;
102 $APAFrame_x = 2*$inch; #this does not include the wire spacing
103 $APAWirePlaneSpacing = 0.476; # center to center spacing between all of the wire planes (g, u, v, and x)
104 
105 $TPCWireThickness = 0.015;
106 $TPCWirePlaneThickness = $TPCWireThickness;
107 
108 $APA_z = 51.99; # DocDb 7550: "overall width"
109  # 144 U/V each, good
110 
111 $APAActive_z = 49.95; # DocDb 7550: "active width"
112 
113  # NUMBER VERTICAL WIRES = (APAActive_z / pitch) + 1
114  # Since APAActive_z is defined in docdb 7550 to be distance
115  # between outer vertical wires, + 1 since the floor of this
116  # division will be one under, giveing the amt of spaces, not wires
117  # POSITIONING: plane centered between +/- APAActive_z/2
118 
119 # Let APAs be numbered as follows
120 # 0 & 3 - Largest
121 # 1 - Middle
122 # 2 - Smallest
123 
124 # Here are the APA heights indexed by APA number (lengths, z, are constant)
125 
126 $APAHeight[0] = 196.0;
127 $APAHeight[1] = 112.0;
128 $APAHeight[2] = 84.0;
129 $APAHeight[3] = $APAHeight[0];
130 
131 
132 $APALongGap = 1.5; #separation between APAs along the incident beam axis
133 $APAVerticalGap = 2.5; #separation between APAs along the vertical axis
134 
135 
136  # include APA spacing in y and z so volTPCs touch in y and z directions with correct APA
137  # spacing - this makes for smoother event generation.
138 
139 $TPCSmallestLongDrift_x = $LongDrift + 3*$APAWirePlaneSpacing + $TPCWirePlaneThickness;
140 $TPCSmallestLongDrift_y = $APAHeight[2] + $APAVerticalGap;
141 $TPCSmallestLongDrift_z = $APA_z + $APALongGap;
142 
143 $TPCMidLongDrift_x = $LongDrift + 3*$APAWirePlaneSpacing + $TPCWirePlaneThickness;
144 $TPCMidLongDrift_y = $APAHeight[1] + $APAVerticalGap;
145 $TPCMidLongDrift_z = $APA_z + $APALongGap;
146 
147 $TPCLargestLongDrift_x = $LongDrift + 3*$APAWirePlaneSpacing + $TPCWirePlaneThickness;
148 $TPCLargestLongDrift_y = $APAHeight[0];
149 $TPCLargestLongDrift_z = $APA_z + $APALongGap;
150 
151 $TPCSmallestShortDrift_x = $ShortDrift + 3*$APAWirePlaneSpacing + $TPCWirePlaneThickness;
152 $TPCSmallestShortDrift_y = $APAHeight[2] + $APAVerticalGap;
153 $TPCSmallestShortDrift_z = $APA_z + $APALongGap;
154 
155 $TPCMidShortDrift_x = $ShortDrift + 3*$APAWirePlaneSpacing + $TPCWirePlaneThickness;
156 $TPCMidShortDrift_y = $APAHeight[1] + $APAVerticalGap;
157 $TPCMidShortDrift_z = $APA_z + $APALongGap;
158 
159 $TPCLargestShortDrift_x = $ShortDrift + 3*$APAWirePlaneSpacing + $TPCWirePlaneThickness;
160 $TPCLargestShortDrift_y = $APAHeight[0];
161 $TPCLargestShortDrift_z = $APA_z + $APALongGap;
162 
163 
164 
165 ############################################################
166 ############### Optical Detector parameters ################
167 
168 # TODO: while the structure is exactly what we need, the parameters for
169 # paddle height and positioning are all placeholders
170 
171 $nPaddlesInAPA[0] = 3;
172 $nPaddlesInAPA[1] = 1;
173 $nPaddlesInAPA[2] = 1;
174 $nPaddlesInAPA[3] = $nPaddlesInAPA[0]; # for now, this one is the same as 0
175 
176 $SiPM_y = 0;
177 $LightPaddle_x = 0.476;
178 $LightPaddle_y = 56; # in cm from docDb 7803
179 $LightPaddle_z = 4*$inch;
180 
181 # z and x are given by APA frame center.
182 # Hardcode y distance of each paddle from the
183 # bottom of the APA to the paddle y-center.
184 # To be used in make_APA like [apa#][paddle#]
185 
186 $PaddleYPositions[0][0] = $APAHeight[0]/2; # this puts it in the y center
187 $PaddleYPositions[1][0] = $APAHeight[1] - 4*$inch - $LightPaddle_y/2;
188 $PaddleYPositions[2][0] = $APAHeight[2] - 4*$inch - $LightPaddle_y/2;
189 $PaddleYPositions[3][0] = $PaddleYPositions[0][0];
190 
191 $PaddleYPositions[0][1] = $APAHeight[0] - 4*$inch - $LightPaddle_y/2;
192 $PaddleYPositions[3][1] = $PaddleYPositions[0][1];
193 
194 $PaddleYPositions[0][2] = 4*$inch + $LightPaddle_y/2;
195 $PaddleYPositions[3][2] = $PaddleYPositions[0][2];
196 
197 
198 
199 ##################################################################
200 ###################### Cryostat parameters #######################
201 
202 # "Dead" LAr outside of the fiducial volume but inside the cryostat
203 $SpaceCPAToCryoWall = 10; #$SideLArPadding
204 $SpaceAPAToFloor = 10; #$BottomLArPadding
205 $SpaceAPAToTopLAr = 3.53; #$TopLArPadding
206 $HeightGaseousAr = 13.5; #$Height of Gaseous Ar region
207 $UpstreamLArPadding = 10;
208 $DownstreamLArPadding = 10;
209 
210 #$APALongGap = 1.5; #separation between APAs along the incident beam axis
211 #$APAVerticalGap = 2.5; #separation between APAs along the vertical axis
212 
213 $CPA_x = 5.08;
214 $CPA_y = ( $APAHeight[1]
215  + $APAVerticalGap
216  + $APAHeight[2] ) / 2;
217 $CPA_z = 77;
218 
219 # Liquid and Gaseous Argon dimensions
220 $Argon_x = $TPCLargestShortDrift_x
221  + $APAFrame_x
222  + $TPCLargestLongDrift_x
223  + 2*$CPA_x
224  + 2*$SpaceCPAToCryoWall;
225 $Argon_y = $APAHeight[1]
226  + $APAVerticalGap
227  + $APAHeight[2]
228  + $SpaceAPAToFloor
229  + $SpaceAPAToTopLAr
230  + $HeightGaseousAr; # assuming mid_y+smallest_y > largest_y
231 $Argon_z = 3*$APA_z + 2*$APALongGap
232  + $UpstreamLArPadding
233  + $DownstreamLArPadding;
234 
235 # Cryostat Dimensions
236 $SteelThickness = 0.5*$inch;
237 $Cryostat_x = $Argon_x+2*$SteelThickness;
238 $Cryostat_y = $Argon_y+2*$SteelThickness;
239 $Cryostat_z = $Argon_z+2*$SteelThickness;
240 
241 
242 
243 ##################################################################
244 ################# Detector Enclosure parameters ##################
245 
246 $ConcretePadding = 50;
247 $FoamPadding = 80;
248 $TotalPadding = $ConcretePadding+$FoamPadding;
249 $DetEnc_x = $Cryostat_x+2*$TotalPadding;
250 $DetEnc_y = $Cryostat_y+2*$TotalPadding-$FoamPadding; # no foam on bottom
251 $CryoInDetEnc_ypos = -$DetEnc_y/2 + $ConcretePadding + $Cryostat_y/2;
252 $DetEnc_z = $Cryostat_z+2*$TotalPadding;
253 
254  # We want the world origin to be at the very front of the fiducial volume.
255  # move it to the front of the enclosure, then back it up through the concrete/foam,
256  # then through the Cryostat shell, then through the upstream dead LAr (including the
257  # dead LAr on the edge of the TPC, but this is covered in $UpstreamLArPadding).
258  # This is to be added to the z position of every volume in volWorld
259 
260 $OriginZSet = $DetEnc_z/2
261  - $TotalPadding
262  - $SteelThickness
263  - $UpstreamLArPadding;
264 
265  # We want the world origin to be vertically centered between the two stacked APAs.
266  # (for now, that is, so the sorting works. this is quite asymetric, but then again
267  # so is the entire 35t geometry. this may be kept.)
268  # the cryostat sits on top of concrete padding, move the detector enclosure back
269  # and then move the world origin to the bottom of the smallest/lowest TPC, then
270  # and then up through the TPC, then back up to being centered between the stacked APAs.
271  # This is to be added to the y/x position of every volume in volWorld
272 
273 $OriginYSet = $DetEnc_y/2
274  - $ConcretePadding
275  - $SteelThickness
276  - $SpaceAPAToFloor
277  - $APAHeight[2] #using tpc heights would include gap, we dont want to
278  - $APAVerticalGap/2;
279 
280 $OriginYSetCheck = - $DetEnc_y/2
281  + $TotalPadding
282  + $SteelThickness
283  + $HeightGaseousAr
284  + $SpaceAPAToTopLAr
285  + $APAHeight[1]
286  + $APAVerticalGap/2;
287 
288 
289 $OriginXSet = - $DetEnc_x/2
290  + $TotalPadding
291  + $SteelThickness
292  + $SpaceCPAToCryoWall
293  + $CPA_x
294  + $LongDrift;
295 
296 
297 $PosDirCubeSide = 0;
298 if (defined $helpcube)
299 {
300 $PosDirCubeSide = $ArToAr; #seems to be a good proportion
301 }
302 
303 
304 # The world dimensions are critical in the CRY cosmics generator
305 # following uboone's lead, make world much larger
306 # the cry helper needs a lot of room
307 
308 
309 $World_x = 100*$DetEnc_x;
310 $World_y = 100*$DetEnc_y;
311 $World_z = 100*$DetEnc_z;
312 
313 
314 
315 
316 ##################################################################
317 ######################### CPA positions ##########################
318 
319 $posCPA0_x = - $Argon_x/2 + $SpaceCPAToCryoWall + $CPA_x/2;
320 $posCPA0_y = - $Argon_y/2 + $SpaceAPAToFloor + $CPA_y/2;
321 $posCPA0_z = - $Argon_z/2 + $UpstreamLArPadding + $CPA_z/2;
322 
323 
324 $posCPA1_x = $Argon_x/2 - $SpaceCPAToCryoWall - $CPA_x/2;
325 $posCPA1_y = - $Argon_y/2 + $SpaceAPAToFloor + $CPA_y/2;
326 $posCPA1_z = - $Argon_z/2 + $UpstreamLArPadding + $CPA_z/2;
327 
328 
329 $posCPA2_x = - $Argon_x/2 + $SpaceCPAToCryoWall + $CPA_x/2;
330 $posCPA2_y = $Argon_y/2 - $SpaceAPAToTopLAr
331  - $HeightGaseousAr - $CPA_y/2;
332 $posCPA2_z = - $Argon_z/2 + $UpstreamLArPadding + $CPA_z/2;
333 
334 
335 $posCPA3_x = $Argon_x/2 - $SpaceCPAToCryoWall - $CPA_x/2;
336 $posCPA3_y = $Argon_y/2 - $SpaceAPAToTopLAr
337  - $HeightGaseousAr - $CPA_y/2;
338 $posCPA3_z = - $Argon_z/2 + $UpstreamLArPadding + $CPA_z/2;
339 
340 
341 $posCPA4_x = - $Argon_x/2 + $SpaceCPAToCryoWall + $CPA_x/2;
342 $posCPA4_y = - $Argon_y/2 + $SpaceAPAToFloor + $CPA_y/2;
343 $posCPA4_z = $Argon_z/2 - $DownstreamLArPadding - $CPA_z/2;
344 
345 
346 $posCPA5_x = $Argon_x/2 - $SpaceCPAToCryoWall - $CPA_x/2;
347 $posCPA5_y = - $Argon_y/2 + $SpaceAPAToFloor + $CPA_y/2;
348 $posCPA5_z = $Argon_z/2 - $DownstreamLArPadding - $CPA_z/2;
349 
350 
351 $posCPA6_x = - $Argon_x/2 + $SpaceCPAToCryoWall + $CPA_x/2;
352 $posCPA6_y = $Argon_y/2 - $SpaceAPAToTopLAr
353  - $HeightGaseousAr - $CPA_y/2;
354 $posCPA6_z = $Argon_z/2 - $DownstreamLArPadding - $CPA_z/2;
355 
356 
357 $posCPA7_x = $Argon_x/2 - $SpaceCPAToCryoWall - $CPA_x/2;
358 $posCPA7_y = $Argon_y/2 - $SpaceAPAToTopLAr
359  - $HeightGaseousAr - $CPA_y/2;
360 $posCPA7_z = $Argon_z/2 - $DownstreamLArPadding - $CPA_z/2;
361 
362 
363 
364 
365 ##################################################################
366 ######################### TPC positions ##########################
367 
368 
369 
370 # Largest Short Drift
371 $posTPClsd_x = - $Argon_x/2
372  + $SpaceCPAToCryoWall
373  + $CPA_x
374  + $TPCLargestShortDrift_x/2;
375 $posTPClsd_y = $Argon_y/2
376  - $HeightGaseousAr
377  - $SpaceAPAToTopLAr
378  - $TPCLargestShortDrift_y/2;
379 
380 # Largest Long Drift
381 $posTPClld_x = $Argon_x/2
382  - $SpaceCPAToCryoWall
383  - $CPA_x
384  - $TPCLargestLongDrift_x/2;
385 $posTPClld_y = $Argon_y/2
386  - $HeightGaseousAr
387  - $SpaceAPAToTopLAr
388  - $TPCLargestLongDrift_y/2;
389 
390 $posTPCl_z_upstream = - $Argon_z/2
391  + $UpstreamLArPadding ## this already steps into the APALongGap/2 space on outside of TPC...
392  + $APA_z/2;
393 $posTPCl_z_downstream = $Argon_z/2
394  - $DownstreamLArPadding ## ...as well as this
395  - $APA_z/2;
396 
397 
398 
399 # Smallest Long Drift
400 $posTPCsld_x = $Argon_x/2
401  - $SpaceCPAToCryoWall
402  - $CPA_x
403  - $TPCSmallestLongDrift_x/2;
404 $posTPCsld_y = - $Argon_y/2
405  + $SpaceAPAToFloor
406  + $APAHeight[2]/2;
407 $posTPCsld_z = $Argon_z/2
408  - $DownstreamLArPadding
409  - $APA_z
410  - $APALongGap
411  - $APA_z/2;
412 
413 # Mid Long Drift
414 $posTPCmld_x = $Argon_x/2
415  - $SpaceCPAToCryoWall
416  - $CPA_x
417  - $TPCMidLongDrift_x/2;
418 $posTPCmld_y = $Argon_y/2
419  - $HeightGaseousAr
420  - $SpaceAPAToTopLAr
421  - $APAHeight[1]/2;
422 $posTPCmld_z = $Argon_z/2
423  - $DownstreamLArPadding
424  - $APA_z
425  - $APALongGap
426  - $APA_z/2;
427 
428 
429 
430 # Smallest Short Drift
431 $posTPCssd_x = - $Argon_x/2
432  + $SpaceCPAToCryoWall
433  + $CPA_x
434  + $TPCSmallestShortDrift_x/2;
435 $posTPCssd_y = - $Argon_y/2
436  + $SpaceAPAToFloor
437  + $APAHeight[2]/2;
438 $posTPCssd_z = $Argon_z/2
439  - $DownstreamLArPadding
440  - $APA_z
441  - $APALongGap
442  - $APA_z/2;
443 
444 # Mid Short Drift
445 $posTPCmsd_x = - $Argon_x/2
446  + $SpaceCPAToCryoWall
447  + $CPA_x
448  + $TPCMidShortDrift_x/2;
449 $posTPCmsd_y = $Argon_y/2
450  - $HeightGaseousAr
451  - $SpaceAPAToTopLAr
452  - $APAHeight[1]/2;
453 $posTPCmsd_z = $Argon_z/2
454  - $DownstreamLArPadding
455  - $APA_z
456  - $APALongGap
457  - $APA_z/2;
458 
459 
460 
461 #TODO: maybe define APA centers more fundamentally and then place TPC centers based off of this
462 $APA_Xcenter = $Argon_x/2
463  - $SpaceCPAToCryoWall
464  - $CPA_x
465  - $TPCLargestLongDrift_x
466  - $APAFrame_x/2;
467 
468 $APACenter[0][0] = $APA_Xcenter;
469 $APACenter[0][1] = $posTPClld_y;
470 $APACenter[0][2] = $posTPCl_z_upstream;
471 
472 $APACenter[1][0] = $APA_Xcenter;
473 $APACenter[1][1] = $posTPCmld_y;
474 $APACenter[1][2] = $posTPCmld_z;
475 
476 $APACenter[2][0] = $APA_Xcenter;
477 $APACenter[2][1] = $posTPCsld_y;
478 $APACenter[2][2] = $posTPCsld_z;
479 
480 $APACenter[3][0] = $APACenter[0][0];
481 $APACenter[3][1] = $APACenter[0][1];
482 $APACenter[3][2] = $posTPCl_z_downstream;
483 
484 
485 ##################################################################
486 #################### Bar Fiber Module numbers ####################
487 $numberofbarlayers=4;
488 $numberofbarsegments=20;
489 $numberofplanklayers=4;
490 $numberofplanksegments=20;
491 $numberoffiberlayers=32;
492 
493 $numberofbars=4;
494 $numberoffibers=3;
495 $numberofplanks=1;
496 
497 $PaddleCenterX=$APA_Xcenter;
498 $PaddleCenterY[0][0]=$APACenter[0][1]-$APAHeight[0]/2+ $PaddleYPositions[0][0];
499 $PaddleCenterY[0][1]=$APACenter[0][1]-$APAHeight[0]/2+ $PaddleYPositions[0][1];
500 $PaddleCenterY[0][2]=$APACenter[0][1]-$APAHeight[0]/2+ $PaddleYPositions[0][2];
501 $PaddleCenterY[1][0]=$APACenter[1][1]-$APAHeight[1]/2+ $PaddleYPositions[1][0];
502 $PaddleCenterY[2][0]=$APACenter[2][1]-$APAHeight[2]/2+ $PaddleYPositions[2][0];
503 $PaddleCenterY[3][0]=$PaddleCenterY[0][0];
504 $PaddleCenterY[3][1]=$PaddleCenterY[0][1];
505 $PaddleCenterY[3][2]=$PaddleCenterY[0][2];
506 $PaddleCenterZ[0]=$APACenter[0][2];
507 $PaddleCenterZ[1]=$APACenter[1][2];
508 $PaddleCenterZ[2]=$APACenter[2][2];
509 $PaddleCenterZ[3]=$APACenter[3][2];
510 ################
511 
512 #+++++++++++++++++++++++++ End defining variables ++++++++++++++++++++++++++
513 
514 
515 
516 # run the sub routines that generate the fragments
517 
518 gen_Define(); # generates definitions at beginning of GDML
519 gen_Materials(); # generates materials to be used
520 
521  # pass a name to gen_TPC that begins with TPC
522  gen_TPC( $TPCSmallestLongDrift_x, $TPCSmallestLongDrift_y, $TPCSmallestLongDrift_z, 'SmallestLongDrift', 1);
523  gen_TPC( $TPCMidLongDrift_x, $TPCMidLongDrift_y, $TPCMidLongDrift_z, 'MidLongDrift', 2);
524  gen_TPC( $TPCLargestLongDrift_x, $TPCLargestLongDrift_y, $TPCLargestLongDrift_z, 'LargestLongDrift', 0);
525 
526  gen_TPC( $TPCSmallestShortDrift_x, $TPCSmallestShortDrift_y, $TPCSmallestShortDrift_z, 'SmallestShortDrift', 1);
527  gen_TPC( $TPCMidShortDrift_x, $TPCMidShortDrift_y, $TPCMidShortDrift_z, 'MidShortDrift', 2) ;
528  gen_TPC( $TPCLargestShortDrift_x, $TPCLargestShortDrift_y, $TPCLargestShortDrift_z, 'LargestShortDrift', 0);
529 
530 
531 gen_Cryostat();
532 gen_Enclosure();
533 gen_World();
534 
535 
536 write_fragments(); # writes the XML input for make_gdml.pl
537  # which zips together the final GDML
538 exit;
539 
540 
541 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
542 #+++++++++++++++++++++++++++++++++++++++++ usage +++++++++++++++++++++++++++++++++++++++++
543 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
544 
545 sub usage()
546 {
547  print "Usage: $0 [-h|--help] [-o|--output <fragments-file>] [-s|--suffix <string>]\n";
548  print " if -o is omitted, output goes to STDOUT; <fragments-file> is input to make_gdml.pl\n";
549  print " -s <string> appends the string to the file names; useful for multiple detector versions\n";
550  print " -h prints this message, then quits\n";
551 }
552 
553 
554 
555 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
556 #++++++++++++++++++++++++++++++++++++++ gen_Define +++++++++++++++++++++++++++++++++++++++
557 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
558 
559 sub gen_Define()
560 {
561 
562 # Create the <define> fragment file name,
563 # add file to list of fragments,
564 # and open it
565  $DEF = "dune_10kT_Def" . $suffix . ".gdml";
566  push (@gdmlFiles, $DEF);
567  $DEF = ">" . $DEF;
568  open(DEF) or die("Could not open file $DEF for writing");
569 
570 
571 print DEF <<EOF;
572 <?xml version='1.0'?>
573 <gdml>
574 <define>
575 
576 <!--
577 
578 
579 
580 -->
581 
582  <position name="posOriginSet" unit="cm" x="$OriginXSet" y="$OriginYSet" z="$OriginZSet"/>
583 
584  <position name="posTPCLargestShortDrift_Pos" unit="cm" x="$posTPClsd_x" y="$posTPClsd_y" z="$posTPCl_z_downstream"/>
585  <position name="posTPCLargestLongDrift_Pos" unit="cm" x="$posTPClld_x" y="$posTPClld_y" z="$posTPCl_z_downstream"/>
586  <position name="posTPCLargestShortDrift_Neg" unit="cm" x="$posTPClsd_x" y="$posTPClsd_y" z="$posTPCl_z_upstream"/>
587  <position name="posTPCLargestLongDrift_Neg" unit="cm" x="$posTPClld_x" y="$posTPClld_y" z="$posTPCl_z_upstream"/>
588  <position name="posTPCSmallestShortDrift" unit="cm" x="$posTPCssd_x" y="$posTPCssd_y" z="$posTPCssd_z"/>
589  <position name="posTPCSmallestLongDrift" unit="cm" x="$posTPCsld_x" y="$posTPCsld_y" z="$posTPCsld_z"/>
590  <position name="posTPCMidShortDrift" unit="cm" x="$posTPCmsd_x" y="$posTPCmsd_y" z="$posTPCmsd_z"/>
591  <position name="posTPCMidLongDrift" unit="cm" x="$posTPCmld_x" y="$posTPCmld_y" z="$posTPCmld_z"/>
592 
593 
594  <position name="posCathode0" unit="cm" x="$posCPA0_x" y="$posCPA0_y" z="$posCPA0_z"/>
595  <position name="posCathode1" unit="cm" x="$posCPA1_x" y="$posCPA1_y" z="$posCPA1_z"/>
596  <position name="posCathode2" unit="cm" x="$posCPA2_x" y="$posCPA2_y" z="$posCPA2_z"/>
597  <position name="posCathode3" unit="cm" x="$posCPA3_x" y="$posCPA3_y" z="$posCPA3_z"/>
598  <position name="posCathode4" unit="cm" x="$posCPA4_x" y="$posCPA4_y" z="$posCPA4_z"/>
599  <position name="posCathode5" unit="cm" x="$posCPA5_x" y="$posCPA5_y" z="$posCPA5_z"/>
600  <position name="posCathode6" unit="cm" x="$posCPA6_x" y="$posCPA6_y" z="$posCPA6_z"/>
601  <position name="posCathode7" unit="cm" x="$posCPA7_x" y="$posCPA7_y" z="$posCPA7_z"/>
602 
603  <position name="posCenter" unit="cm" x="0" y="0" z="0"/>
604  <rotation name="rPlus90AboutX" unit="deg" x="90" y="0" z="0"/>
605  <rotation name="rMinus90AboutY" unit="deg" x="0" y="270" z="0"/>
606  <rotation name="rMinus90AboutYMinus90AboutX" unit="deg" x="270" y="270" z="0"/>
607  <rotation name="rPlus180AboutY" unit="deg" x="0" y="180" z="0"/>
608  <rotation name="rIdentity" unit="deg" x="0" y="0" z="0"/>
609 EOF
610 
611 ##################################################################
612 ###################### Bar Module Position #######################
613 for ($k=1; $k<$numberofbars+1; ++$k)
614 {
615 if($k==1) {$APA_i=1;$p=0;}
616 elsif($k==2) {$APA_i=0;$p=1;}
617 elsif($k==3) {$APA_i=0;$p=2;}
618 elsif($k==4) {$APA_i=3;$p=1;}
619 
620 for ($j=1; $j<$numberofbarlayers+1; ++$j)
621 {
622 $bar_z=-4.11 + 2.74*($j-1)+$PaddleCenterZ[$APA_i];
623  for ($i=1; $i<$numberofbarsegments+1; ++$i)
624  {
625  $bar_y=9.5*$inch + $PaddleCenterY[$APA_i][$p] - 2.54*($i-1);
626  $bar_name="Bar" . $k . "Pos" . $j . "_" . $i;
627 print DEF <<EOF;
628  <position name="$bar_name" x="$PaddleCenterX" y="$bar_y" z="$bar_z" unit="cm"/>
629 EOF
630 }
631 }
632 }
633 
634 ##################################################################
635 ##################### Plank Module Position ######################
636 for ($k=1; $k<$numberofplanks+1; ++$k)
637 {
638 if($k==1) {$APA_i=3;$p=2;}
639 
640 for ($j=1; $j<$numberofplanklayers+1; ++$j)
641 {
642 $plank_z=-4.125 + 2.75*($j-1)+$PaddleCenterZ[$APA_i];
643  for ($i=1; $i<$numberofplanksegments+1; ++$i)
644  {
645  $plank_y=9.5*$inch + $PaddleCenterY[$APA_i][$p] - 2.54*($i-1);
646  $plank_name="PlankPos" . $j . "_" . $i;
647 print DEF <<EOF;
648  <position name="$plank_name" x="$PaddleCenterX" y="$plank_y" z="$plank_z" unit="cm"/>
649 EOF
650 }
651 }
652 }
653 ##################################################################
654 ##################### Fiber Module Position ######################
655 
656 for ($k=1; $k<$numberoffibers+1; ++$k)
657 {
658 if($k==1) {$APA_i=2;$p=0;}
659 elsif($k==2) {$APA_i=0;$p=0;}
660 elsif($k==3) {$APA_i=3;$p=0;}
661 
662 ############################# Fiber ##############################
663 $numberoffibersegments=20;
664 
665 for ($j=2; $j<$numberoffiberlayers+1; ++$j)
666 {
667 if($j%2==0) {$fiber_x=$PaddleCenterX-0.15;}
668 else {$fiber_x=$PaddleCenterX+0.15;}
669 
670 $fiber_z=-4.65+0.3*($j-1)+$PaddleCenterZ[$APA_i];
671  for ($i=1; $i<$numberoffibersegments+1; ++$i)
672  {
673  $fiber_y=$PaddleCenterY[$APA_i][$p]-9.5*$inch+ 2.54*($i-1);
674  $fiber_name="Fiber" . $k . "Pos" . $j . "_" . $i;
675 print DEF <<EOF;
676  <position name="$fiber_name" x="$fiber_x" y="$fiber_y" z="$fiber_z" unit="cm"/>
677 EOF
678 }
679 if($j%2!=0) {$j+=2;}
680 }
681 
682 ########################## FiberBottom ###########################
683 
684 $numberoffibersegments=17;
685 
686 for ($j=1; $j<$numberoffiberlayers+1; ++$j)
687 {
688 if($j%2==0) {$fiber_x=$PaddleCenterX-0.15;}
689 else {$fiber_x=$PaddleCenterX+0.15;}
690 
691 $fiber_z=-4.65+0.3*($j-1)+$PaddleCenterZ[$APA_i];
692  for ($i=1; $i<$numberoffibersegments+1; ++$i)
693  {
694  $fiber_y=$PaddleCenterY[$APA_i][$p]-9.5*$inch+ 2.54*($i-1);
695  $fiber_name="Fiber" . $k . "PosBottom" . $j . "_" . $i;
696 print DEF <<EOF;
697  <position name="$fiber_name" x="$fiber_x" y="$fiber_y" z="$fiber_z" unit="cm"/>
698 EOF
699 }
700 if($j%2!=0) {$j+=2;}
701 }
702 
703 ############################ FiberTop ############################
704 
705 for ($j=1; $j<$numberoffiberlayers+1; ++$j)
706 {
707 if($j%2==0) {$fiber_x=$PaddleCenterX-0.15;$fiber_z=-4.35+0.3*($j-3)+$PaddleCenterZ[$APA_i];}
708 else {$fiber_x=$PaddleCenterX+0.15;$fiber_z=-4.35+0.3*($j-1)+$PaddleCenterZ[$APA_i];}
709 $fiber_y=$PaddleCenterY[$APA_i][$p]+24.289;
710 $fiber_name="Fiber" . $k . "PosTop" . $j;
711 
712 print DEF <<EOF;
713  <position name="$fiber_name" x="$fiber_x" y="$fiber_y" z="$fiber_z" unit="cm"/>
714 EOF
715 if($j%2!=0) {$j+=2;}
716 }
717 
718 ########################### FiberRight ###########################
719 
720 $numberoffibersegments=2;
721 
722 for ($j=1; $j<$numberoffiberlayers+1; $j+=4)
723 {
724 $fiber_x=$PaddleCenterX+0.15;
725  for ($i=1; $i<$numberoffibersegments+1; ++$i)
726  {
727  if($i%2==0) {$fiber_y=$PaddleCenterY[$APA_i][$p]+21.8281;}
728  else {$fiber_y=$PaddleCenterY[$APA_i][$p]+19.1294;}
729  $fiber_z=-4.575+0.15*($i-1)+0.3*($j-1)+$PaddleCenterZ[$APA_i];
730  $fiber_name="Fiber" . $k . "PosRight" . $j . "_" . $i;
731 print DEF <<EOF;
732  <position name="$fiber_name" x="$fiber_x" y="$fiber_y" z="$fiber_z" unit="cm"/>
733 EOF
734 }
735 
736 }
737 
738 ########################### FiberLeft ############################
739 
740 $numberoffibersegments=2;
741 
742 for ($j=4; $j<$numberoffiberlayers+1; $j+=4)
743 {
744 $fiber_x=$PaddleCenterX-0.15;
745  for ($i=1; $i<$numberoffibersegments+1; ++$i)
746  {
747  if($i%2==0) {$fiber_y=$PaddleCenterY[$APA_i][$p]+21.8281;}
748  else {$fiber_y=$PaddleCenterY[$APA_i][$p]+19.1294;}
749  $fiber_z=-4.725-0.15*($i-1)+0.3*($j-1)+$PaddleCenterZ[$APA_i];
750  $fiber_name="Fiber" . $k . "PosLeft" . $j . "_" . $i;
751 print DEF <<EOF;
752  <position name="$fiber_name" x="$fiber_x" y="$fiber_y" z="$fiber_z" unit="cm"/>
753 EOF
754 }
755 
756 }
757 
758 
759 }
760 
761 print DEF <<EOF;
762 </define>
763 </gdml>
764 EOF
765  close (DEF);
766 }
767 
768 
769 
770 
771 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
772 #+++++++++++++++++++++++++++++++++++++ gen_Materials +++++++++++++++++++++++++++++++++++++
773 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
774 
775 sub gen_Materials()
776 {
777 
778 # Create the <materials> fragment file name,
779 # add file to list of output GDML fragments,
780 # and open it
781  $MAT = "dune_10kT_Materials" . $suffix . ".gdml";
782  push (@gdmlFiles, $MAT);
783  $MAT = ">" . $MAT;
784  open(MAT) or die("Could not open file $MAT for writing");
785 
786 
787  print MAT <<EOF;
788 <materials>
789  <element name="videRef" formula="VACUUM" Z="1"> <atom value="1"/> </element>
790  <element name="bromine" formula="Br" Z="35"> <atom value="79.904"/> </element>
791  <element name="hydrogen" formula="H" Z="1"> <atom value="1.0079"/> </element>
792  <element name="nitrogen" formula="N" Z="7"> <atom value="14.0067"/> </element>
793  <element name="oxygen" formula="O" Z="8"> <atom value="15.999"/> </element>
794  <element name="aluminum" formula="Al" Z="13"> <atom value="26.9815"/> </element>
795  <element name="silicon" formula="Si" Z="14"> <atom value="28.0855"/> </element>
796  <element name="carbon" formula="C" Z="6"> <atom value="12.0107"/> </element>
797  <element name="potassium" formula="K" Z="19"> <atom value="39.0983"/> </element>
798  <element name="chromium" formula="Cr" Z="24"> <atom value="51.9961"/> </element>
799  <element name="iron" formula="Fe" Z="26"> <atom value="55.8450"/> </element>
800  <element name="nickel" formula="Ni" Z="28"> <atom value="58.6934"/> </element>
801  <element name="calcium" formula="Ca" Z="20"> <atom value="40.078"/> </element>
802  <element name="magnesium" formula="Mg" Z="12"> <atom value="24.305"/> </element>
803  <element name="sodium" formula="Na" Z="11"> <atom value="22.99"/> </element>
804  <element name="titanium" formula="Ti" Z="22"> <atom value="47.867"/> </element>
805  <element name="argon" formula="Ar" Z="18"> <atom value="39.9480"/> </element>
806  <element name="sulphur" formula="S" Z="16"> <atom value="32.065"/> </element>
807  <element name="phosphorus" formula="P" Z="15"> <atom value="30.973"/> </element>
808 
809  <material name="Vacuum" formula="Vacuum">
810  <D value="1.e-25" unit="g/cm3"/>
811  <fraction n="1.0" ref="videRef"/>
812  </material>
813 
814  <material name="ALUMINUM_Al" formula="ALUMINUM_Al">
815  <D value="2.6990" unit="g/cm3"/>
816  <fraction n="1.0000" ref="aluminum"/>
817  </material>
818 
819  <material name="SILICON_Si" formula="SILICON_Si">
820  <D value="2.3300" unit="g/cm3"/>
821  <fraction n="1.0000" ref="silicon"/>
822  </material>
823 
824  <material name="epoxy_resin" formula="C38H40O6Br4">
825  <D value="1.1250" unit="g/cm3"/>
826  <composite n="38" ref="carbon"/>
827  <composite n="40" ref="hydrogen"/>
828  <composite n="6" ref="oxygen"/>
829  <composite n="4" ref="bromine"/>
830  </material>
831 
832  <material name="SiO2" formula="SiO2">
833  <D value="2.2" unit="g/cm3"/>
834  <composite n="1" ref="silicon"/>
835  <composite n="2" ref="oxygen"/>
836  </material>
837 
838  <material name="Al2O3" formula="Al2O3">
839  <D value="3.97" unit="g/cm3"/>
840  <composite n="2" ref="aluminum"/>
841  <composite n="3" ref="oxygen"/>
842  </material>
843 
844  <material name="Fe2O3" formula="Fe2O3">
845  <D value="5.24" unit="g/cm3"/>
846  <composite n="2" ref="iron"/>
847  <composite n="3" ref="oxygen"/>
848  </material>
849 
850  <material name="CaO" formula="CaO">
851  <D value="3.35" unit="g/cm3"/>
852  <composite n="1" ref="calcium"/>
853  <composite n="1" ref="oxygen"/>
854  </material>
855 
856  <material name="MgO" formula="MgO">
857  <D value="3.58" unit="g/cm3"/>
858  <composite n="1" ref="magnesium"/>
859  <composite n="1" ref="oxygen"/>
860  </material>
861 
862  <material name="Na2O" formula="Na2O">
863  <D value="2.27" unit="g/cm3"/>
864  <composite n="2" ref="sodium"/>
865  <composite n="1" ref="oxygen"/>
866  </material>
867 
868  <material name="TiO2" formula="TiO2">
869  <D value="4.23" unit="g/cm3"/>
870  <composite n="1" ref="titanium"/>
871  <composite n="2" ref="oxygen"/>
872  </material>
873 
874  <material name="FeO" formula="FeO">
875  <D value="5.745" unit="g/cm3"/>
876  <composite n="1" ref="iron"/>
877  <composite n="1" ref="oxygen"/>
878  </material>
879 
880  <material name="CO2" formula="CO2">
881  <D value="1.562" unit="g/cm3"/>
882  <composite n="1" ref="iron"/>
883  <composite n="2" ref="oxygen"/>
884  </material>
885 
886  <material name="P2O5" formula="P2O5">
887  <D value="1.562" unit="g/cm3"/>
888  <composite n="2" ref="phosphorus"/>
889  <composite n="5" ref="oxygen"/>
890  </material>
891 
892  <material formula=" " name="DUSEL_Rock">
893  <D value="2.82" unit="g/cm3"/>
894  <fraction n="0.5267" ref="SiO2"/>
895  <fraction n="0.1174" ref="FeO"/>
896  <fraction n="0.1025" ref="Al2O3"/>
897  <fraction n="0.0473" ref="MgO"/>
898  <fraction n="0.0422" ref="CO2"/>
899  <fraction n="0.0382" ref="CaO"/>
900  <fraction n="0.0240" ref="carbon"/>
901  <fraction n="0.0186" ref="sulphur"/>
902  <fraction n="0.0053" ref="Na2O"/>
903  <fraction n="0.00070" ref="P2O5"/>
904  <fraction n="0.0771" ref="oxygen"/>
905  </material>
906 
907  <material name="fibrous_glass">
908  <D value="2.74351" unit="g/cm3"/>
909  <fraction n="0.600" ref="SiO2"/>
910  <fraction n="0.118" ref="Al2O3"/>
911  <fraction n="0.001" ref="Fe2O3"/>
912  <fraction n="0.224" ref="CaO"/>
913  <fraction n="0.034" ref="MgO"/>
914  <fraction n="0.010" ref="Na2O"/>
915  <fraction n="0.013" ref="TiO2"/>
916  </material>
917 
918  <material name="FR4">
919  <D value="1.98281" unit="g/cm3"/>
920  <fraction n="0.47" ref="epoxy_resin"/>
921  <fraction n="0.53" ref="fibrous_glass"/>
922  </material>
923 
924  <material name="STEEL_STAINLESS_Fe7Cr2Ni" formula="STEEL_STAINLESS_Fe7Cr2Ni">
925  <D value="7.9300" unit="g/cm3"/>
926  <fraction n="0.0010" ref="carbon"/>
927  <fraction n="0.1792" ref="chromium"/>
928  <fraction n="0.7298" ref="iron"/>
929  <fraction n="0.0900" ref="nickel"/>
930  </material>
931 
932  <material name="LAr" formula="LAr">
933  <D value="1.40" unit="g/cm3"/>
934  <fraction n="1.0000" ref="argon"/>
935  </material>
936 
937  <material name="ArGas" formula="ArGas">
938  <D value="0.00166" unit="g/cm3"/>
939  <fraction n="1.0" ref="argon"/>
940  </material>
941 
942  <material formula=" " name="Air">
943  <D value="0.001205" unit="g/cm3"/>
944  <fraction n="0.781154" ref="nitrogen"/>
945  <fraction n="0.209476" ref="oxygen"/>
946  <fraction n="0.00934" ref="argon"/>
947  </material>
948 
949  <material formula=" " name="G10">
950  <D value="1.7" unit="g/cm3"/>
951  <fraction n="0.2805" ref="silicon"/>
952  <fraction n="0.3954" ref="oxygen"/>
953  <fraction n="0.2990" ref="carbon"/>
954  <fraction n="0.0251" ref="hydrogen"/>
955  </material>
956 
957  <material formula=" " name="Granite">
958  <D value="2.7" unit="g/cm3"/>
959  <fraction n="0.438" ref="oxygen"/>
960  <fraction n="0.257" ref="silicon"/>
961  <fraction n="0.222" ref="sodium"/>
962  <fraction n="0.049" ref="aluminum"/>
963  <fraction n="0.019" ref="iron"/>
964  <fraction n="0.015" ref="potassium"/>
965  </material>
966 
967  <material formula=" " name="ShotRock">
968  <D value="2.7*0.6" unit="g/cm3"/>
969  <fraction n="0.438" ref="oxygen"/>
970  <fraction n="0.257" ref="silicon"/>
971  <fraction n="0.222" ref="sodium"/>
972  <fraction n="0.049" ref="aluminum"/>
973  <fraction n="0.019" ref="iron"/>
974  <fraction n="0.015" ref="potassium"/>
975  </material>
976 
977  <material formula=" " name="Dirt">
978  <D value="1.7" unit="g/cm3"/>
979  <fraction n="0.438" ref="oxygen"/>
980  <fraction n="0.257" ref="silicon"/>
981  <fraction n="0.222" ref="sodium"/>
982  <fraction n="0.049" ref="aluminum"/>
983  <fraction n="0.019" ref="iron"/>
984  <fraction n="0.015" ref="potassium"/>
985  </material>
986 
987  <material formula=" " name="Concrete">
988  <D value="2.3" unit="g/cm3"/>
989  <fraction n="0.530" ref="oxygen"/>
990  <fraction n="0.335" ref="silicon"/>
991  <fraction n="0.060" ref="calcium"/>
992  <fraction n="0.015" ref="sodium"/>
993  <fraction n="0.020" ref="iron"/>
994  <fraction n="0.040" ref="aluminum"/>
995  </material>
996 
997  <material formula="H2O" name="Water">
998  <D value="1.0" unit="g/cm3"/>
999  <fraction n="0.1119" ref="hydrogen"/>
1000  <fraction n="0.8881" ref="oxygen"/>
1001  </material>
1002 
1003  <material formula="Ti" name="Titanium">
1004  <D value="4.506" unit="g/cm3"/>
1005  <fraction n="1." ref="titanium"/>
1006  </material>
1007 
1008  <material name="TPB" formula="TPB">
1009  <D value="1.40" unit="g/cm3"/>
1010  <fraction n="1.0000" ref="argon"/>
1011  </material>
1012 
1013  <material name="Glass">
1014  <D value="2.74351" unit="g/cm3"/>
1015  <fraction n="0.600" ref="SiO2"/>
1016  <fraction n="0.118" ref="Al2O3"/>
1017  <fraction n="0.001" ref="Fe2O3"/>
1018  <fraction n="0.224" ref="CaO"/>
1019  <fraction n="0.034" ref="MgO"/>
1020  <fraction n="0.010" ref="Na2O"/>
1021  <fraction n="0.013" ref="TiO2"/>
1022  </material>
1023 
1024  <material name="Acrylic">
1025  <D value="1.19" unit="g/cm3"/>
1026  <fraction n="0.600" ref="carbon"/>
1027  <fraction n="0.320" ref="oxygen"/>
1028  <fraction n="0.080" ref="hydrogen"/>
1029  </material>
1030 
1031  <material name="Plastic" formula="Plastic">
1032  <D value="1.032" unit="g/cm3"/>
1033  <fraction n=".474" ref="carbon"/>
1034  <fraction n=".526" ref="hydrogen"/>
1035  </material>
1036 
1037 </materials>
1038 EOF
1039 
1040 close(MAT);
1041 }
1042 
1043 
1044 
1045 
1046 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1047 #++++++++++++++++++++++++++++++++++++++++ gen_TPC ++++++++++++++++++++++++++++++++++++++++
1048 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1049 
1050 
1051 sub gen_TPC()
1052 {
1053 
1054 # $_[0] = $TPC_x
1055 # $_[1] = $TPC_y
1056 # $_[2] = $TPC_z
1057 # $_[3] = 'name'
1058 
1059  my $TPCWirePlaneHeight = $_[1] - $APAVerticalGap;
1060  my $TPCWirePlaneLength = $_[2] - $APALongGap;
1061 
1062  my $TPCActive_x = $_[0]-(4*$APAWirePlaneSpacing);
1063  my $TPCActive_y = $TPCWirePlaneHeight;
1064  my $TPCActive_z = $TPCWirePlaneLength;
1065 
1066  my $UAngle = $UAng[$_[4]];
1067  my $VAngle = $VAng[$_[4]];
1068 
1069  my $SinUAngle = sin( deg2rad($UAngle) );
1070  my $CosUAngle = cos( deg2rad($UAngle) );
1071  my $TanUAngle = tan( deg2rad($UAngle) );
1072 
1073  my $SinVAngle = sin( deg2rad($VAngle) );
1074  my $CosVAngle = cos( deg2rad($VAngle) );
1075  my $TanVAngle = tan( deg2rad($VAngle) );
1076 
1077  my $UWire_yint = $UWirePitch/$SinUAngle;
1078  my $UWire_zint = $UWirePitch/$CosUAngle;
1079 
1080  my $VWire_yint = $VWirePitch/$SinVAngle;
1081  my $VWire_zint = $VWirePitch/$CosVAngle;
1082 
1083 #constructs everything inside volTPC, namely
1084 # (moving from left to right, or from +x to -x)
1085 # -volCPA
1086 # -volTPCPlaneU: with wires angled from vertical slightly different than in V
1087 # -volTPCPlaneV: with wires angled from vertical slightly differently than in U
1088 # -volTPCPlaneX: with vertical wires
1089 
1090 
1091 # Create the TPC fragment file name,
1092 # add file to list of output GDML fragments,
1093 # and open it
1094  $TPC = "35t_TPC_${_[3]}" . $suffix . ".gdml";
1095  push (@gdmlFiles, $TPC);
1096  $TPC = ">" . $TPC;
1097  open(TPC) or die("Could not open file $TPC for writing");
1098 
1099 
1100 # The standard XML prefix and starting the gdml
1101  print TPC <<EOF;
1102 <?xml version='1.0'?>
1103 <gdml>
1104 EOF
1105 
1106 
1107 # All the TPC solids save the wires.
1108 print TPC <<EOF;
1109 <solids>
1110  <box name="$_[3]" lunit="cm"
1111  x="$_[0]"
1112  y="$_[1]"
1113  z="$_[2]"/>
1114  <box name="${_[3]}Plane" lunit="cm"
1115  x="$TPCWirePlaneThickness"
1116  y="$TPCWirePlaneHeight"
1117  z="$TPCWirePlaneLength"/>
1118  <box name="${_[3]}Active" lunit="cm"
1119  x="$TPCActive_x"
1120  y="$TPCActive_y"
1121  z="$TPCActive_z"/>
1122 EOF
1123 
1124 
1125 #++++++++++++++++++++++++++++ Wire Solids ++++++++++++++++++++++++++++++
1126 
1127 print TPC <<EOF;
1128 
1129  <tube name="${_[3]}WireVert"
1130  rmax="0.5*$TPCWireThickness"
1131  z="$TPCWirePlaneHeight"
1132  deltaphi="360"
1133  aunit="deg"
1134  lunit="cm"/>
1135 EOF
1136 
1137 # Set number of wires to default to zero, when $wires_on = 0, for a low memory
1138 # version. But if $wires_on = 1, calculate the number of wires on each side of each
1139 # plane to be used in the for loops
1140 
1141 my $NumberCornerUWires = 0;
1142 my $NumberSideUWires = 0;
1143 my $NumberCommonUWires = 0;
1144 my $NumberCornerVWires = 0;
1145 my $NumberSideVWires = 0;
1146 my $NumberCommonVWires = 0;
1147 my $NumberVerticalWires = 0;
1148 
1149 if ($wires_on == 1)
1150 {
1151  # Number of wires in one corner
1152 $NumberCornerUWires = int( $TPCWirePlaneLength/($UWirePitch/$CosUAngle) );
1153 
1154 $NumberCornerVWires = int( $TPCWirePlaneLength/($VWirePitch/$CosVAngle) );
1155 
1156  # Total number of wires touching one vertical (longer) side
1157  # Note that the total number of wires per plane is this + another set of corner wires
1158 $NumberSideUWires = int( $TPCWirePlaneHeight/($UWirePitch/$SinUAngle) );
1159 
1160 $NumberSideVWires = int( $TPCWirePlaneHeight/($VWirePitch/$SinVAngle) );
1161 
1162  # Number of wires per side that aren't cut off by the corner
1163 $NumberCommonUWires = $NumberSideUWires - $NumberCornerUWires;
1164 
1165 $NumberCommonVWires = $NumberSideVWires - $NumberCornerVWires;
1166 
1167  # Number of wires on the vertical plane
1168  # Since APAActive_z is defined in docdb 7550 to be distance
1169  # between outer vertical wires, + 1 since the floor of this
1170  # division will be one under, giveing the amt of spaces, not wires
1171 $NumberVerticalWires = int( $APAActive_z/$XWirePitch + 1 );
1172 }
1173 
1174 # The corner wires for the U plane
1175 if ($wires_on==1)
1176 {
1177  for ($i = 0; $i < $NumberCornerUWires; ++$i)
1178  {
1179  # Subtraction to avoid corners of wires overlapping the TPCPlane sides,
1180  # equal to 0.5*TCPWireThickness*($TanUAngle+1/$TanUAngle),
1181  # allowing for 30deg<UAngle
1182 
1183  print TPC <<EOF;
1184  <tube name="${_[3]}WireU$i"
1185  rmax="0.5*$TPCWireThickness"
1186  z="$UWirePitch*($TanUAngle+1/$TanUAngle)*($i+1)-0.01732"
1187  deltaphi="360"
1188  aunit="deg"
1189  lunit="cm"/>
1190 EOF
1191 
1192  }
1193  # Next, the wire used many times in the middle of the U plane.
1194  # Subtraction again to avoid wire corners overlapping, equal to
1195  # 0.5*TCPWireThickness*2/$TanVAngle, allowing for 30deg<VAngle
1196 
1197  print TPC <<EOF;
1198  <tube name="${_[3]}WireUCommon"
1199  rmax="0.5*$TPCWireThickness"
1200  z="$TPCWirePlaneLength/$SinUAngle-0.02598"
1201  deltaphi="360"
1202  aunit="deg"
1203  lunit="cm"/>
1204 EOF
1205 
1206 }
1207 
1208 
1209 # The corner wires for the V plane
1210 if ($wires_on==1)
1211 {
1212  for ($i = 0; $i < $NumberCornerVWires; ++$i)
1213  {
1214  # Same subtraction to avoid corners of wires overlapping
1215  # the TPCPlane sides
1216 
1217  print TPC <<EOF;
1218 
1219  <tube name="${_[3]}WireV$i"
1220  rmax="0.5*$TPCWireThickness"
1221  z="$VWirePitch*($TanVAngle+1/$TanVAngle)*($i+1)-0.01732"
1222  deltaphi="360"
1223  aunit="deg"
1224  lunit="cm"/>
1225 
1226 EOF
1227 
1228  }
1229 
1230  # The wire used many times in the middle of the V plane
1231  # Same subtraction as U common
1232 
1233  print TPC <<EOF;
1234  <tube name="${_[3]}WireVCommon"
1235  rmax="0.5*$TPCWireThickness"
1236  z="$TPCWirePlaneLength/$SinVAngle-0.02598"
1237  deltaphi="360"
1238  aunit="deg"
1239  lunit="cm"/>
1240 EOF
1241 
1242 }
1243 
1244 
1245 
1246 # Begin structure and create the vertical wire logical volume
1247 print TPC <<EOF;
1248 </solids>
1249 <structure>
1250  <volume name="volTPCActive${_[3]}">
1251  <materialref ref="LAr"/>
1252  <solidref ref="${_[3]}Active"/>
1253  </volume>
1254 
1255 EOF
1256 
1257 
1258 if ($wires_on==1)
1259 {
1260  print TPC <<EOF;
1261  <volume name="volTPCWireVert${_[3]}">
1262  <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1263  <solidref ref="${_[3]}WireVert"/>
1264  </volume>
1265 EOF
1266 
1267  # Corner U wires logical volumes
1268  for ($i = 0; $i < $NumberCornerUWires; ++$i)
1269  {
1270  print TPC <<EOF;
1271  <volume name="volTPCWireU$i${_[3]}">
1272  <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1273  <solidref ref="${_[3]}WireU$i"/>
1274  </volume>
1275 EOF
1276 
1277  }
1278 
1279  # Common U wire logical volume, referenced many times
1280  print TPC <<EOF;
1281  <volume name="volTPCWireUCommon${_[3]}">
1282  <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1283  <solidref ref="${_[3]}WireUCommon"/>
1284  </volume>
1285 EOF
1286 
1287  # Corner V wires logical volumes
1288  for ($i = 0; $i < $NumberCornerVWires; ++$i)
1289  {
1290  print TPC <<EOF;
1291  <volume name="volTPCWireV$i${_[3]}">
1292  <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1293  <solidref ref="${_[3]}WireV$i"/>
1294  </volume>
1295 EOF
1296 
1297  }
1298 
1299  # Common V wire logical volume, referenced many times
1300  print TPC <<EOF;
1301  <volume name="volTPCWireVCommon${_[3]}">
1302  <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1303  <solidref ref="${_[3]}WireVCommon"/>
1304  </volume>
1305 EOF
1306 
1307 }
1308 
1309 
1310 
1311 
1312 #+++++++++++++++++++++++++ Position physical wires ++++++++++++++++++++++++++
1313 
1314 # ++++++++++++++++++++++ U Plane +++++++++++++++++++++++
1315 
1316 # Create U plane logical volume
1317 print TPC <<EOF;
1318  <volume name="volTPCPlaneU${_[3]}">
1319  <materialref ref="LAr"/>
1320  <solidref ref="${_[3]}Plane"/>
1321 EOF
1322 
1323 if ($wires_on==1)
1324 {
1325 
1326 # Starting with the bottom left corner wires:
1327  # x=0 to center the wires in the plane
1328  # y positioning: (-0.5*$TPCWirePlaneHeight) starts the incremental increase
1329  # from the bottom of the plane, and trigonometry gives the increment
1330  # z positioning: Looking at the plane from the positive x direction,
1331  # (0.5*$TPCWirePlaneLength) starts the incremental increase from
1332  # the lower left corner.
1333  # rotation: same as common wire in code below
1334 
1335 for ($i = 0; $i < $NumberCornerUWires; ++$i)
1336 {
1337 my $ypos = (-0.5*$TPCWirePlaneHeight)+0.5*($i+1)*$UWire_yint;
1338 my $zpos = (0.5*$TPCWirePlaneLength)-0.5*($i+1)*$UWire_zint;
1339 
1340 my $diff=(0.5*$TPCWirePlaneLength)-0.5*($NumberCornerUWires)*$UWire_zint;
1341 my $zpos=$zpos-$diff;
1342 
1343 print TPC <<EOF;
1344  <physvol>
1345  <volumeref ref="volTPCWireU$i${_[3]}"/>
1346  <position name="pos${_[3]}WireU$i" unit="cm" x="0" y="$ypos " z="$zpos"/>
1347  <rotation name="rUAngle$i" unit="deg" x="90-$UAngle" y="0" z="0"/>
1348  </physvol>
1349 EOF
1350 
1351 }
1352 
1353 
1354 # Moving upwards to the common wires:
1355  # x and z are zero to center the wires along a vertical axis
1356  # y positioning: The trick is positioning the lowest common wire so that the pitch
1357  # is consistent, then the increment is double the increment of
1358  # the corner wires since there is no z incriment.
1359  # rotation: wires in \\\\ direction, so +90deg to bring them to vertical and
1360  # +UAngle counterclockwise to arrive at proper orientation
1361 # Note that the counter maintains wire number (in pos. name) counting bottom to top
1362 
1363 for ($i = $NumberCornerUWires; $i < $NumberSideUWires; ++$i)
1364 {
1365 my $ypos = (-0.5*$TPCWirePlaneHeight)+0.5*($NumberCornerUWires)*$UWire_yint+($i+1-$NumberCornerUWires)*$UWire_yint;
1366 
1367 print TPC <<EOF;
1368  <physvol>
1369  <volumeref ref="volTPCWireUCommon${_[3]}"/>
1370  <position name="pos${_[3]}WireU$i" unit="cm" x="0" y="$ypos " z="0"/>
1371  <rotation name="rUAngle$i" unit="deg" x="90-$UAngle" y="0" z="0"/>
1372  </physvol>
1373 EOF
1374 
1375 }
1376 
1377 
1378 # Finally moving to the corner wires on the top right:
1379  # x=0 to center the wires in the plane
1380  # y positioning: plug wire number into same equation
1381  # z positioning: start at z=0 and go negatively at the same z increment
1382  # rotation: same as common wire in code above
1383 # note that the counter maintains wire number shown in the position name
1384 
1385 for ($i = $NumberSideUWires; $i < $NumberSideUWires+$NumberCornerUWires-1; ++$i)
1386 {
1387  # Make a counter to recall the right logical volume reference:
1388  # We want the last U wire in this loop (the highest wire) to be the
1389  # first wire in the logical volume loop for U wires.
1390 
1391 $j = $NumberSideUWires+$NumberCornerUWires - $i - 2;
1392 
1393  # Note that since we are referencing the same logical volumes/same solids for
1394  # the top wires as well as the bottom, the pattern of "stacking" wire on top of wire
1395  # with an incremental separation is likely to cause the top corner wires to be a
1396  # a little shorter than they can be, but never any longer. There is no immediately
1397  # elegant way to fix this, but at 5mm pitch and around 45deg wire orientation, the
1398  # wires can be at most 1cm shorter than possible which is negligible until the top
1399  # 20 wires or so where 1cm is >5% of their length. This also means that there
1400  # could be one more space for a wire left over, but that is highly unlikely.
1401 
1402 my $ypos = (-0.5*$TPCWirePlaneHeight)+0.5*($NumberCornerUWires)*$UWire_yint+($NumberCommonUWires)*$UWire_yint+0.5*($i+1-$NumberSideUWires)*$UWire_yint;
1403 my $zpos = -0.5*($i+1-$NumberSideUWires)*$UWire_zint;
1404 
1405 print TPC <<EOF;
1406  <physvol>
1407  <volumeref ref="volTPCWireU$j${_[3]}"/>
1408  <position name="pos${_[3]}WireU$i" unit="cm" x="0" y="$ypos " z="$zpos"/>
1409  <rotation name="rUAngle$i" unit="deg" x="90-$UAngle" y="0" z="0"/>
1410  </physvol>
1411 EOF
1412 
1413 }
1414 
1415 } #ends if wires on
1416 
1417 
1418 # ++++++++++++++++++++++ V Plane +++++++++++++++++++++++
1419 
1420 # End U plane and create V plane logical volume
1421 print TPC <<EOF;
1422  </volume>
1423 
1424  <volume name="volTPCPlaneV${_[3]}">
1425  <materialref ref="LAr"/>
1426  <solidref ref="${_[3]}Plane"/>
1427 EOF
1428 
1429 if ($wires_on==1)
1430 {
1431 
1432 
1433 # Starting with the bottom right corner wires:
1434  # x=0 to center the wires in the plane
1435  # y positioning: (-0.5*$TPCWirePlaneHeight) starts the incremental increase
1436  # from the bottom of the plane, and trigonometry gives the increment
1437  # z positioning: Looking at the plane from the positive x direction,
1438  # (-0.5*$TPCWirePlaneLength) starts the incremental increase from
1439  # the lower right corner.
1440  # rotation: same as common wire in code below
1441 
1442 for ($i = 0; $i < $NumberCornerVWires; ++$i)
1443 {
1444 my $ypos = (-0.5*$TPCWirePlaneHeight)+0.5*($i+1)*$VWire_yint;
1445 my $zpos = (-0.5*$TPCWirePlaneLength)+0.5*($i+1)*$VWire_zint;
1446 
1447 my $diff=(-0.5*$TPCWirePlaneLength)+0.5*($NumberCornerVWires)*$VWire_zint;
1448 my $zpos=$zpos-$diff;
1449 
1450 print TPC <<EOF;
1451  <physvol>
1452  <volumeref ref="volTPCWireV$i${_[3]}"/>
1453  <position name="pos${_[3]}WireV$i" unit="cm" x="0" y="$ypos " z="$zpos"/>
1454  <rotation name="rVAngle$i" unit="deg" x="90+$VAngle" y="0" z="0"/>
1455  </physvol>
1456 EOF
1457 
1458 }
1459 
1460 
1461 # Moving upwards to the common wires:
1462  # x and z are zero to center the wires along a vertical axis
1463  # y positioning: Plug wire number into the same corner ypos equation
1464  # rotation: wires in //// direction, so +90deg to bring them to vertical and
1465  # --VAngle counterclockwise to arrive at proper orientation
1466 # Note that the counter maintains wire number in the position name
1467 
1468 for ($i = $NumberCornerVWires; $i < $NumberSideVWires; ++$i)
1469 {
1470 my $ypos = (-0.5*$TPCWirePlaneHeight)-0.5*($NumberCornerVWires)*$VWire_yint+($i+1)*$VWire_yint;
1471 
1472 print TPC <<EOF;
1473  <physvol>
1474  <volumeref ref="volTPCWireVCommon${_[3]}"/>
1475  <position name="pos${_[3]}WireV$i" unit="cm" x="0" y="$ypos " z="0"/>
1476  <rotation name="rVAngle$i" unit="deg" x="90+$VAngle" y="0" z="0"/>
1477  </physvol>
1478 EOF
1479 
1480 }
1481 
1482 
1483 # Finally moving to the corner wires on the top right:
1484  # x=0 to center the wires in the plane
1485  # y positioning: plug wire number into same equation
1486  # z positioning: start at z=0 and go positively at the same z increment
1487  # rotation: same as common wire in code above
1488 # note that the counter maintains wire number shown in the position name
1489 
1490 for ($i = $NumberSideVWires; $i < $NumberSideVWires+$NumberCornerVWires-1; ++$i)
1491 {
1492  # Make a counter to recall the right logical volume reference where the last
1493  # wire in this loop is the smallest, first wire in the logical volume loop, just as in U
1494 
1495 $j = $NumberSideVWires+$NumberCornerVWires - $i - 2;
1496 
1497  # Note that since we are referencing the same logical volumes/same solids for
1498  # the top wires as well as the bottom, the pattern of "stacking" wire on top of wire
1499  # with an incremental separation is likely to cause the top corner wires to be a
1500  # a little shorter than they can be, but never any longer. Just as in U
1501 
1502 my $ypos = (-0.5*$TPCWirePlaneHeight)+0.5*($NumberCornerVWires)*$VWire_yint+($NumberCommonVWires)*$VWire_yint+0.5*($i+1-$NumberSideVWires)*$VWire_yint;
1503 my $zpos = 0.5*($i+1-$NumberSideVWires)*$VWire_zint;
1504 
1505 print TPC <<EOF;
1506  <physvol>
1507  <volumeref ref="volTPCWireV$j${_[3]}"/>
1508  <position name="pos${_[3]}WireV$i" unit="cm" x="0" y="$ypos " z="$zpos"/>
1509  <rotation name="rVAngle$i" unit="deg" x="90+$VAngle" y="0" z="0"/>
1510  </physvol>
1511 EOF
1512 }
1513 
1514 } #ends if wires on
1515 
1516 
1517 
1518 # ++++++++++++++++++++++ X Plane +++++++++++++++++++++++
1519 
1520 # End V plane and create X plane logical volume
1521 print TPC <<EOF;
1522  </volume>
1523 
1524  <volume name="volTPCPlaneX${_[3]}">
1525  <materialref ref="LAr"/>
1526  <solidref ref="${_[3]}Plane"/>
1527 EOF
1528 
1529 if ($wires_on==1)
1530 {
1531 
1532 # This is the simplest plane, one loop creates all of the wires
1533  # x and y position at zero to center the wires
1534  # z position: moving from front of detector to back, in the positive z direction,
1535  # starting at (-0.5*$TPCWirePlaneLength), the right side looking from
1536  # the +x direction
1537 
1538 for ($i=0; $i<$NumberVerticalWires; ++$i)
1539 {
1540 my $zpos = (-0.5*$APAActive_z)+$XWirePitch*($i+0.5)+$TPCWireThickness/2;
1541 
1542 print TPC <<EOF;
1543  <physvol>
1544  <volumeref ref="volTPCWireVert${_[3]}"/>
1545  <position name="pos${_[3]}WireX$i" unit="cm" x="0" y="0 " z="$zpos"/>
1546  <rotationref ref="rPlus90AboutX"/>
1547  </physvol>
1548 EOF
1549 
1550 }
1551 
1552 } #ends if wires on
1553 
1554 print TPC <<EOF;
1555  </volume>
1556 EOF
1557 
1558 #+++++++++++++++++++++ Position physical wires Above +++++++++++++++++++++
1559 
1560 #wrap up the TPC file
1561 print TPC <<EOF;
1562  <volume name="volTPC${_[3]}">
1563  <materialref ref="LAr"/>
1564  <solidref ref="${_[3]}"/>
1565  <physvol>
1566  <volumeref ref="volTPCPlaneU${_[3]}"/>
1567  <position name="pos${_[3]}PlaneU" unit="cm" x="-($_[0]/2)+3*$APAWirePlaneSpacing" y="0" z="0"/>
1568  </physvol>
1569  <physvol>
1570  <volumeref ref="volTPCPlaneV${_[3]}"/>
1571  <position name="pos${_[3]}PlaneV" unit="cm" x="-($_[0]/2)+2*$APAWirePlaneSpacing" y="0" z="0"/>
1572  </physvol>
1573  <physvol>
1574  <volumeref ref="volTPCPlaneX${_[3]}"/>
1575  <position name="pos${_[3]}PlaneX" unit="cm" x="-($_[0]/2)+$APAWirePlaneSpacing" y="0" z="0"/>
1576  </physvol>
1577  <physvol>
1578  <volumeref ref="volTPCActive${_[3]}"/>
1579  <position name="pos${_[3]}Active" unit="cm" x="-($_[0]/2)+$APAWirePlaneSpacing + $TPCActive_x/2" y="0" z="0"/>
1580  </physvol>
1581  </volume>
1582 </structure>
1583 </gdml>
1584 EOF
1585 
1586  close(GDML);
1587 
1588 } #end of sub gen_TPC
1589 
1590 
1591 
1592 
1593 
1594 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1595 #++++++++++++++++++++++++++++++++++++++ gen_Cryostat +++++++++++++++++++++++++++++++++++++
1596 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1597 
1598 sub gen_Cryostat()
1599 {
1600 
1601 # Create the cryostat fragment file name,
1602 # add file to list of output GDML fragments,
1603 # and open it
1604  $CRYO = "35t_Cryostat" . $suffix . ".gdml";
1605  push (@gdmlFiles, $CRYO);
1606  $CRYO = ">" . $CRYO;
1607  open(CRYO) or die("Could not open file $CRYO for writing");
1608 
1609 
1610 # The standard XML prefix and starting the gdml
1611  print CRYO <<EOF;
1612 <?xml version='1.0'?>
1613 <gdml>
1614 EOF
1615 
1616 
1617 # All the cryostat solids.
1618 print CRYO <<EOF;
1619 <solids>
1620  <box name="Cryostat" lunit="cm"
1621  x="$Cryostat_x"
1622  y="$Cryostat_y"
1623  z="$Cryostat_z"/>
1624 
1625  <box name="ArgonInterior" lunit="cm"
1626  x="$Argon_x"
1627  y="$Argon_y"
1628  z="$Argon_z"/>
1629 
1630  <subtraction name="SteelShell">
1631  <first ref="Cryostat"/>
1632  <second ref="ArgonInterior"/>
1633  </subtraction>
1634 
1635  <box name="Cathode" lunit="cm"
1636  x="$CPA_x"
1637  y="$CPA_y"
1638  z="$CPA_z"/>
1639 
1640  <box name="LightPaddle" lunit="cm"
1641  x="$LightPaddle_x"
1642  y="$LightPaddle_y + $SiPM_y"
1643  z="$LightPaddle_z"/>
1644 
1645  <box name="Bar" lunit="cm"
1646  x="0.3"
1647  y="2.54"
1648  z="2.54"/>
1649 
1650  <box name="Plank" lunit="cm"
1651  x="0.2905"
1652  y="2.54"
1653  z="2.75"/>
1654 
1655  <box name="Fiber" lunit="cm"
1656  x="0.3"
1657  y="2.54"
1658  z="0.3"/>
1659 
1660  <box name="FiberTop" lunit="cm"
1661  x="0.3"
1662  y="2.222"
1663  z="0.3"/>
1664 
1665  <para name="FiberRight" x="0.3" y="0.3" z="5.3975/2" alpha="0" theta="3" phi="0" aunit="deg" lunit="cm"/>
1666 
1667  <para name="FiberLeft" x="0.3" y="0.3" z="5.3975/2" alpha="0" theta="-3" phi="0" aunit="deg" lunit="cm"/>
1668 
1669 EOF
1670 
1671 
1672  # Add APA frames and optical detectors (paddles)
1673  solid_APA( 0 );
1674  solid_APA( 1 );
1675  solid_APA( 2 );
1676  solid_APA( 3 );
1677 
1678 
1679 # Cryostat structure
1680 print CRYO <<EOF;
1681 </solids>
1682 <structure>
1683  <volume name="volSteelShell">
1684  <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1685  <solidref ref="SteelShell"/>
1686  </volume>
1687 
1688  <volume name="volCathode">
1689  <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1690  <solidref ref="Cathode"/>
1691  </volume>
1692 
1693  <volume name="volOpDetSensitive_Bar">
1694  <materialref ref="LAr"/>
1695  <solidref ref="Bar"/>
1696  </volume>
1697 
1698  <volume name="volOpDetSensitive_Plank">
1699  <materialref ref="LAr"/>
1700  <solidref ref="Plank"/>
1701  </volume>
1702 
1703  <volume name="volOpDetSensitive_Fiber">
1704  <materialref ref="LAr"/>
1705  <solidref ref="Fiber"/>
1706  </volume>
1707 
1708  <volume name="volOpDetSensitive_Bottom">
1709  <materialref ref="LAr"/>
1710  <solidref ref="Fiber"/>
1711  </volume>
1712 
1713  <volume name="volOpDetSensitive_Top">
1714  <materialref ref="LAr"/>
1715  <solidref ref="FiberTop"/>
1716  </volume>
1717 
1718  <volume name="volOpDetSensitive_Right">
1719  <materialref ref="LAr"/>
1720  <solidref ref="FiberRight"/>
1721  </volume>
1722 
1723  <volume name="volOpDetSensitive_Left">
1724  <materialref ref="LAr"/>
1725  <solidref ref="FiberLeft"/>
1726  </volume>
1727 
1728 EOF
1729 
1730  vol_APA( 0 );
1731  vol_APA( 1 );
1732  vol_APA( 2 );
1733  vol_APA( 3 );
1734 
1735 print CRYO <<EOF;
1736 
1737  <volume name="volCryostat">
1738  <materialref ref="LAr"/>
1739  <solidref ref="Cryostat"/>
1740 
1741  <physvol>
1742  <volumeref ref="volSteelShell"/>
1743  <position name="posSteelShell" unit="cm" x="0" y="0" z="0"/>
1744  </physvol>
1745 
1746 
1747  <physvol>
1748  <volumeref ref="volCathode"/>
1749  <positionref ref="posCathode0"/>
1750  </physvol>
1751  <physvol>
1752  <volumeref ref="volCathode"/>
1753  <positionref ref="posCathode1"/>
1754  </physvol>
1755  <physvol>
1756  <volumeref ref="volCathode"/>
1757  <positionref ref="posCathode2"/>
1758  </physvol>
1759  <physvol>
1760  <volumeref ref="volCathode"/>
1761  <positionref ref="posCathode3"/>
1762  </physvol>
1763 
1764  <physvol>
1765  <volumeref ref="volCathode"/>
1766  <positionref ref="posCathode4"/>
1767  </physvol>
1768  <physvol>
1769  <volumeref ref="volCathode"/>
1770  <positionref ref="posCathode5"/>
1771  </physvol>
1772  <physvol>
1773  <volumeref ref="volCathode"/>
1774  <positionref ref="posCathode6"/>
1775  </physvol>
1776  <physvol>
1777  <volumeref ref="volCathode"/>
1778  <positionref ref="posCathode7"/>
1779  </physvol>
1780 
1781 
1782  <!-- The Smallest APA -->
1783  <physvol>
1784  <volumeref ref="volTPCSmallestLongDrift"/>
1785  <positionref ref="posTPCSmallestLongDrift"/>
1786  <rotationref ref="rIdentity"/>
1787  </physvol>
1788  <physvol>
1789  <volumeref ref="volTPCSmallestShortDrift"/>
1790  <positionref ref="posTPCSmallestShortDrift"/>
1791  <rotationref ref="rPlus180AboutY"/>
1792  </physvol>
1793 
1794 EOF
1795 
1796 place_APA($APACenter[2][0], $APACenter[2][1], $APACenter[2][2], 2);
1797 
1798 
1799 
1800 print CRYO <<EOF;
1801  <!-- The Middle-sized APA -->
1802  <physvol>
1803  <volumeref ref="volTPCMidLongDrift"/>
1804  <positionref ref="posTPCMidLongDrift"/>
1805  <rotationref ref="rIdentity"/>
1806  </physvol>
1807  <physvol>
1808  <volumeref ref="volTPCMidShortDrift"/>
1809  <positionref ref="posTPCMidShortDrift"/>
1810  <rotationref ref="rPlus180AboutY"/>
1811  </physvol>
1812 
1813 EOF
1814 
1815 place_APA($APACenter[1][0], $APACenter[1][1], $APACenter[1][2], 1);
1816 
1817 
1818 
1819 print CRYO <<EOF;
1820  <!-- The Largest APAs, Upstream and Downstream -->
1821  <physvol>
1822  <volumeref ref="volTPCLargestLongDrift"/>
1823  <positionref ref="posTPCLargestLongDrift_Neg"/>
1824  <rotationref ref="rIdentity"/>
1825  </physvol>
1826  <physvol>
1827  <volumeref ref="volTPCLargestShortDrift"/>
1828  <positionref ref="posTPCLargestShortDrift_Neg"/>
1829  <rotationref ref="rPlus180AboutY"/>
1830  </physvol>
1831  <physvol>
1832  <volumeref ref="volTPCLargestLongDrift"/>
1833  <positionref ref="posTPCLargestLongDrift_Pos"/>
1834  <rotationref ref="rIdentity"/>
1835  </physvol>
1836  <physvol>
1837  <volumeref ref="volTPCLargestShortDrift"/>
1838  <positionref ref="posTPCLargestShortDrift_Pos"/>
1839  <rotationref ref="rPlus180AboutY"/>
1840  </physvol>
1841 
1842 EOF
1843 
1844 place_APA($APACenter[0][0], $APACenter[0][1], $APACenter[0][2], 0);
1845 place_APA($APACenter[3][0], $APACenter[3][1], $APACenter[3][2], 3);
1846 
1847 
1848 
1849 print CRYO <<EOF;
1850  </volume>
1851 </structure>
1852 </gdml>
1853 EOF
1854 
1855 close(CRYO);
1856 }
1857 
1858 
1859 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1860 #++++++++++++++++++++++++++++++++++++++ solid_APA ++++++++++++++++++++++++++++++++++++++++
1861 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1862 
1863 
1864 # Must be called only within gen_Cryostat(),
1865 
1866 
1867 # $_[0] = APA number
1868 # convention: 0 is Largest, 1 is Mid, 2 is Smallest
1869 
1870 sub solid_APA()
1871 {
1872 
1873  $APA_i = $_[0];
1874 
1875 ####################################################################
1876 ################# APA Frame and Paddle Dimensions ##################
1877 
1878  $APA_y = $APAHeight[$APA_i];
1879 
1880 $APAFrameZSide_x = $APAFrame_x;
1881 $APAFrameZSide_y = 4*$inch;
1882 $APAFrameZSide_z = $APA_z;
1883 
1884 $APAFrameYSide_x = $APAFrame_x;
1885 $APAFrameYSide_y = $APA_y-2*$APAFrameZSide_y;
1886 $APAFrameYSide_z = 4*$inch;
1887 
1888 # Two outer Y supports will sandwich the light paddles
1889 $APAFrameYOuterSupport_x = ($APAFrame_x-$LightPaddle_x)/2;
1890 $APAFrameYOuterSupport_y = $APA_y-2*$APAFrameZSide_y;
1891 $APAFrameYOuterSupport_z = 4*$inch;
1892 
1893 $EdgeFrameSteelThickness = 0.12*$inch;
1894 $InnerFrameSteelThickness = 0.062*$inch;
1895 
1896 
1897  print CRYO <<EOF;
1898  <box name="APAFrameYSideHollow\-$APA_i" lunit="cm"
1899  x="$APAFrameYSide_x-2*$EdgeFrameSteelThickness"
1900  y="$APAFrameYSide_y-2*$EdgeFrameSteelThickness"
1901  z="$APAFrameYSide_z"/>
1902  <box name="APAFrameYSideShell\-$APA_i" lunit="cm"
1903  x="$APAFrameYSide_x"
1904  y="$APAFrameYSide_y"
1905  z="$APAFrameYSide_z"/>
1906  <subtraction name="APAFrameYSide\-$APA_i">
1907  <first ref="APAFrameYSideShell\-$APA_i"/>
1908  <second ref="APAFrameYSideHollow\-$APA_i"/>
1909  <positionref ref="posCenter"/>
1910  <rotationref ref="rIdentity"/>
1911  </subtraction>
1912 
1913  <box name="APAFrameZSideHollow\-$APA_i" lunit="cm"
1914  x="$APAFrameZSide_x-2*$EdgeFrameSteelThickness"
1915  y="$APAFrameZSide_y-2*$EdgeFrameSteelThickness"
1916  z="$APAFrameZSide_z"/>
1917  <box name="APAFrameZSideShell\-$APA_i" lunit="cm"
1918  x="$APAFrameZSide_x"
1919  y="$APAFrameZSide_y"
1920  z="$APAFrameZSide_z"/>
1921  <subtraction name="APAFrameZSide\-$APA_i">
1922  <first ref="APAFrameZSideShell\-$APA_i"/>
1923  <second ref="APAFrameZSideHollow\-$APA_i"/>
1924  <positionref ref="posCenter"/>
1925  <rotationref ref="rIdentity"/>
1926  </subtraction>
1927 
1928  <box name="APAFrameYOuterSupport\-$APA_i" lunit="cm"
1929  x="$EdgeFrameSteelThickness"
1930  y="$APAFrameYOuterSupport_y"
1931  z="$APAFrameYOuterSupport_z"/>
1932 
1933 
1934 EOF
1935 
1936 }
1937 
1938 
1939 
1940 
1941 
1942 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1943 #++++++++++++++++++++++++++++++++++++++ vol_APA ++++++++++++++++++++++++++++++++++++++++
1944 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1945 
1946 
1947 # Must be called only within gen_Cryostat(),
1948 
1949 
1950 # $_[0] = x APA center
1951 # $_[1] = y APA center
1952 # $_[2] = z APA center
1953 # $_[3] = APA number
1954 # convention: 0 and 3 are Largest, 1 is Mid, 2 is Smallest
1955 
1956 sub vol_APA()
1957 {
1958 
1959  $APA_i = $_[0];
1960 
1961 print CRYO <<EOF;
1962 
1963  <volume name="volAPAFrameYSide\-$APA_i">
1964  <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1965  <solidref ref="APAFrameYSide\-$APA_i"/>
1966  </volume>
1967 
1968  <volume name="volAPAFrameZSide\-$APA_i">
1969  <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1970  <solidref ref="APAFrameZSide\-$APA_i"/>
1971  </volume>
1972 
1973  <volume name="volAPAFrameYOuterSupport\-$APA_i">
1974  <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1975  <solidref ref="APAFrameYOuterSupport\-$APA_i"/>
1976  </volume>
1977 
1978 EOF
1979 
1980 }
1981 
1982 
1983 
1984 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1985 #++++++++++++++++++++++++++++++++++++++ place_APA ++++++++++++++++++++++++++++++++++++++++
1986 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1987 
1988 
1989 # Must be called only within gen_Cryostat(),
1990 
1991 
1992 # $_[0] = x APA center
1993 # $_[1] = y APA center
1994 # $_[2] = z APA center
1995 # $_[3] = APA number
1996 # convention: 0 and 3 are Largest, 1 is Mid, 2 is Smallest
1997 
1998 sub place_APA()
1999 {
2000 
2001  $APA_i = $_[3];
2002 
2003 ####################################################################
2004 ################# APA Frame and Paddle Dimensions ##################
2005 
2006  $APA_y = $APAHeight[$APA_i];
2007 
2008 $APAFrameZSide_x = $APAFrame_x;
2009 $APAFrameZSide_y = 4*$inch;
2010 $APAFrameZSide_z = $APA_z;
2011 
2012 $APAFrameYSide_x = $APAFrame_x;
2013 $APAFrameYSide_y = $APA_y-2*$APAFrameZSide_y;
2014 $APAFrameYSide_z = 4*$inch;
2015 
2016 # Two outer Y supports will sandwich the light paddles
2017 $APAFrameYOuterSupport_x = ($APAFrame_x-$LightPaddle_x)/2;
2018 $APAFrameYOuterSupport_y = $APA_y-2*$APAFrameZSide_y;
2019 $APAFrameYOuterSupport_z = 4*$inch;
2020 
2021 # if there were an inner support to fill the hole
2022 $APAFrameYInnerSupport_x = $LightPaddle_x;
2023 
2024 $EdgeFrameSteelThickness = 0.12*$inch;
2025 $InnerFrameSteelThickness = 0.062*$inch;
2026 
2027 #TODO: Place TPCs in here as well, but for now just do frames and paddles
2028 
2029 
2030 
2031  # First put in the frame
2032  print CRYO <<EOF;
2033  <!-- <physvol>
2034  <volumeref ref="volAPAFrameYOuterSupport\-$APA_i"/>
2035  <position name="posAPAFrameYOuterSupportNeg\-$APA_i" unit="cm"
2036  x="$_[0] - ($APAFrameYOuterSupport_x + $APAFrameYInnerSupport_x/2 - $EdgeFrameSteelThickness/2)"
2037  y="$_[1]"
2038  z="$_[2]"/>
2039  <rotationref ref="rIdentity"/>
2040  </physvol>
2041  <physvol>
2042  <volumeref ref="volAPAFrameYOuterSupport\-$APA_i"/>
2043  <position name="posAPAFrameYOuterSupportPos\-$APA_i" unit="cm"
2044  x="$_[0] + ($APAFrameYOuterSupport_x + $APAFrameYInnerSupport_x/2 - $EdgeFrameSteelThickness/2)"
2045  y="$_[1]"
2046  z="$_[2]"/>
2047  <rotationref ref="rIdentity"/>
2048  </physvol> -->
2049  <physvol>
2050  <volumeref ref="volAPAFrameYSide\-$APA_i"/>
2051  <position name="posAPAFrameYSideNeg\-$_[3]" unit="cm"
2052  x="$_[0]"
2053  y="$_[1]"
2054  z="$_[2] - $APA_z/2 + $APAFrameYSide_z/2"/>
2055  <rotationref ref="rIdentity"/>
2056  </physvol>
2057  <physvol>
2058  <volumeref ref="volAPAFrameYSide\-$APA_i"/>
2059  <position name="posAPAFrameYSidePos\-$_[3]" unit="cm"
2060  x="$_[0]"
2061  y="$_[1]"
2062  z="$_[2] + $APA_z/2 - $APAFrameYSide_z/2"/>
2063  <rotationref ref="rIdentity"/>
2064  </physvol>
2065  <physvol>
2066  <volumeref ref="volAPAFrameZSide\-$APA_i"/>
2067  <position name="posAPAFrameZSidePos\-$_[3]" unit="cm"
2068  x="$_[0]"
2069  y="$_[1] + $APA_y/2 - $APAFrameZSide_y/2"
2070  z="$_[2]"/>
2071  <rotationref ref="rIdentity"/>
2072  </physvol>
2073  <physvol>
2074  <volumeref ref="volAPAFrameZSide\-$APA_i"/>
2075  <position name="posAPAFrameZSideNeg\-$_[3]" unit="cm"
2076  x="$_[0]"
2077  y="$_[1] - $APA_y/2 + $APAFrameZSide_y/2"
2078  z="$_[2]"/>
2079  <rotationref ref="rIdentity"/>
2080  </physvol>
2081 
2082 EOF
2083 
2084 
2085  # Now loop through paddle y positions and place them
2086  #for( $p=0; $p<$nPaddlesInAPA[$APA_i]; $p++ ){
2087 
2088 #if($nPaddlesInAPA[$APA_i]!=1)
2089 #{
2090 #print CRYO <<EOF;
2091 
2092 # <physvol>
2093 # <volumeref ref="volOpDetSensitive"/>
2094 # <position name="posPaddle\-$p\-APA\-$APA_i" unit="cm"
2095 # x="$_[0]"
2096 # y="$_[1] - $APAHeight[$APA_i]/2 + $PaddleYPositions[$APA_i][$p]"
2097 # z="$_[2]"/>
2098 # <rotationref ref="rIdentity"/>
2099 # </physvol>
2100 
2101 #EOF
2102 
2103 switch($APA_i){
2104 case 0 { place_bar(2);
2105  place_fiber(2);
2106  place_bar(3); }
2107 case 1 { place_bar(1); }
2108 case 2 { place_fiber(1); }
2109 case 3 { place_bar(4);
2110  place_fiber(3);
2111  place_plank(); }
2112 }
2113 
2114 
2115 }
2116 
2117 
2118 
2119 
2120 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2121 #+++++++++++++++++++++++++++++++++++++ gen_Enclosure +++++++++++++++++++++++++++++++++++++
2122 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2123 
2124 sub gen_Enclosure()
2125 {
2126 
2127 # Create the detector enclosure fragment file name,
2128 # add file to list of output GDML fragments,
2129 # and open it
2130  $ENCL = "35t_DetEnclosure" . $suffix . ".gdml";
2131  push (@gdmlFiles, $ENCL);
2132  $ENCL = ">" . $ENCL;
2133  open(ENCL) or die("Could not open file $ENCL for writing");
2134 
2135 
2136 # The standard XML prefix and starting the gdml
2137  print ENCL <<EOF;
2138 <?xml version='1.0'?>
2139 <gdml>
2140 EOF
2141 
2142 
2143 # All the detector enclosure solids.
2144 print ENCL <<EOF;
2145 <solids>
2146 
2147  <box name="DetEnclosure" lunit="cm"
2148  x="$DetEnc_x"
2149  y="$DetEnc_y"
2150  z="$DetEnc_z"/>
2151 
2152 </solids>
2153 EOF
2154 
2155 
2156 
2157 # Detector enclosure structure
2158  print ENCL <<EOF;
2159 <structure>
2160 
2161  <volume name="volDetEnclosure">
2162  <materialref ref="Concrete"/>
2163  <solidref ref="DetEnclosure"/>
2164  <physvol>
2165  <volumeref ref="volCryostat"/>
2166  <position name="posCryo" unit="cm" x="0" y="$CryoInDetEnc_ypos" z="0"/>
2167  </physvol>
2168  </volume>
2169 EOF
2170 
2171 print ENCL <<EOF;
2172 </structure>
2173 </gdml>
2174 EOF
2175 
2176 close(ENCL);
2177 }
2178 
2179 
2180 
2181 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2182 #+++++++++++++++++++++++++++++++++++++++ gen_World +++++++++++++++++++++++++++++++++++++++
2183 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2184 
2185 sub gen_World()
2186 {
2187 
2188 # Create the WORLD fragment file name,
2189 # add file to list of output GDML fragments,
2190 # and open it
2191  $WORLD = "35t_World" . $suffix . ".gdml";
2192  push (@gdmlFiles, $WORLD);
2193  $WORLD = ">" . $WORLD;
2194  open(WORLD) or die("Could not open file $WORLD for writing");
2195 
2196 
2197 # The standard XML prefix and starting the gdml
2198  print WORLD <<EOF;
2199 <?xml version='1.0'?>
2200 <gdml>
2201 EOF
2202 
2203 
2204 # All the World solids.
2205 print WORLD <<EOF;
2206 <solids>
2207  <box name="World" lunit="cm"
2208  x="$World_x"
2209  y="$World_y"
2210  z="$World_z"/>
2211 </solids>
2212 EOF
2213 
2214 # World structure
2215 print WORLD <<EOF;
2216 <structure>
2217  <volume name="volWorld" >
2218  <materialref ref="Air"/>
2219  <solidref ref="World"/>
2220  <physvol>
2221  <volumeref ref="volDetEnclosure"/>
2222  <position name="posDetEnclosure" unit="cm" x="$OriginXSet" y="$OriginYSet" z="$OriginZSet"/>
2223  </physvol>
2224  </volume>
2225 </structure>
2226 </gdml>
2227 EOF
2228 
2229 # make_gdml.pl will take care of <setup/>
2230 
2231 close(WORLD);
2232 }
2233 
2234 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2235 #++++++++++++++++++++++++++++++++++++ write_fragments ++++++++++++++++++++++++++++++++++++
2236 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2237 
2238 sub write_fragments()
2239 {
2240  # This subroutine creates an XML file that summarizes the the subfiles output
2241  # by the other sub routines - it is the input file for make_gdml.pl which will
2242  # give the final desired GDML file. Specify its name with the output option.
2243  # (you can change the name when running make_gdml)
2244 
2245  if ( ! defined $output )
2246  {
2247  $output = "-"; # write to STDOUT
2248  }
2249 
2250  # Set up the output file.
2251  $OUTPUT = ">" . $output;
2252  open(OUTPUT) or die("Could not open file $OUTPUT");
2253 
2254  print OUTPUT <<EOF;
2255 <?xml version='1.0'?>
2256 
2257 <!-- Input to Geometry/gdml/make_gdml.pl; define the GDML fragments
2258  that will be zipped together to create a detector description.
2259  -->
2260 
2261 <config>
2262 
2263  <constantfiles>
2264 
2265  <!-- These files contain GDML <constant></constant>
2266  blocks. They are read in separately, so they can be
2267  interpreted into the remaining GDML. See make_gdml.pl for
2268  more information.
2269  -->
2270 
2271 EOF
2272 
2273  foreach $filename (@defFiles)
2274  {
2275  print OUTPUT <<EOF;
2276  <filename> $filename </filename>
2277 EOF
2278  }
2279 
2280  print OUTPUT <<EOF;
2281 
2282  </constantfiles>
2283 
2284  <gdmlfiles>
2285 
2286  <!-- The GDML file fragments to be zipped together. -->
2287 
2288 EOF
2289 
2290  foreach $filename (@gdmlFiles)
2291  {
2292  print OUTPUT <<EOF;
2293  <filename> $filename </filename>
2294 EOF
2295  }
2296 
2297  print OUTPUT <<EOF;
2298 
2299  </gdmlfiles>
2300 
2301 </config>
2302 EOF
2303 
2304  close(OUTPUT);
2305 }
2306 
2307 
2308 sub place_bar()
2309 {
2310 print CRYO <<EOF;
2311  <!-- Bar$_[0]-->
2312 EOF
2313  for($j=1; $j<$numberofbarlayers+1; $j++)
2314  {
2315  for($i=1; $i<$numberofbarsegments+1; $i++)
2316  {
2317  $pos_ref_name="Bar" . $_[0] . "Pos" . $j . "_" . $i;
2318 print CRYO <<EOF;
2319  <physvol>
2320  <volumeref ref="volOpDetSensitive_Bar"/>
2321  <positionref ref="$pos_ref_name"/>
2322  </physvol>
2323 
2324 EOF
2325  }
2326  }
2327 
2328 }
2329 
2330 sub place_plank()
2331 {
2332 print CRYO <<EOF;
2333  <!-- Plank-->
2334 EOF
2335  for($j=1; $j<$numberofbarlayers+1; $j++)
2336  {
2337  for($i=1; $i<$numberofbarsegments+1; $i++)
2338  {
2339  $pos_ref_name="PlankPos" . $j . "_" . $i;
2340 print CRYO <<EOF;
2341  <physvol>
2342  <volumeref ref="volOpDetSensitive_Plank"/>
2343  <positionref ref="$pos_ref_name"/>
2344  </physvol>
2345 EOF
2346  }
2347  }
2348 }
2349 
2350 sub place_fiber()
2351 {
2352 print CRYO <<EOF;
2353  <!-- 32 Fiber Module-->
2354 
2355 EOF
2356 
2357 ############################# Fiber ##############################
2358 $numberoffibersegments=20;
2359 
2360 for ($j=2; $j<$numberoffiberlayers+1; ++$j)
2361 {
2362 
2363  for ($i=1; $i<$numberoffibersegments+1; ++$i)
2364  {
2365  $pos_ref_name="Fiber" . $_[0] . "Pos" . $j . "_" . $i;
2366 print CRYO <<EOF;
2367  <physvol>
2368  <volumeref ref="volOpDetSensitive_Fiber"/>
2369  <positionref ref="$pos_ref_name"/>
2370  </physvol>
2371 
2372 EOF
2373 }
2374 if($j%2!=0) {$j+=2;}
2375 }
2376 
2377 ########################## FiberBottom ###########################
2378 
2379 $numberoffibersegments=17;
2380 
2381 for ($j=1; $j<$numberoffiberlayers+1; ++$j)
2382 {
2383  for ($i=1; $i<$numberoffibersegments+1; ++$i)
2384  {
2385  $pos_ref_name="Fiber" . $_[0] . "PosBottom" . $j . "_" . $i;
2386 print CRYO <<EOF;
2387  <physvol>
2388  <volumeref ref="volOpDetSensitive_Bottom"/>
2389  <positionref ref="$pos_ref_name"/>
2390  </physvol>
2391 
2392 EOF
2393 }
2394 if($j%2!=0) {$j+=2;}
2395 }
2396 
2397 ############################ FiberTop ############################
2398 
2399 for ($j=1; $j<$numberoffiberlayers+1; ++$j)
2400 {
2401 $pos_ref_name="Fiber" . $_[0] . "PosTop" . $j;
2402 print CRYO <<EOF;
2403  <physvol>
2404  <volumeref ref="volOpDetSensitive_Top"/>
2405  <positionref ref="$pos_ref_name"/>
2406  </physvol>
2407 
2408 EOF
2409 if($j%2!=0) {$j+=2;}
2410 }
2411 
2412 ########################### FiberRight ###########################
2413 
2414 $numberoffibersegments=2;
2415 
2416 for ($j=1; $j<$numberoffiberlayers+1; $j+=4)
2417 {
2418  for ($i=1; $i<$numberoffibersegments+1; ++$i)
2419  {
2420  $pos_ref_name="Fiber" . $_[0] . "PosRight" . $j . "_" . $i;
2421 print CRYO <<EOF;
2422  <physvol>
2423  <volumeref ref="volOpDetSensitive_Right"/>
2424  <positionref ref="$pos_ref_name"/>
2425  <rotation name="FiberRotRight" x="90" z="90" unit="deg"/>
2426  </physvol>
2427 
2428 EOF
2429 }
2430 
2431 }
2432 
2433 ########################### FiberLeft ############################
2434 
2435 $numberoffibersegments=2;
2436 
2437 for ($j=4; $j<$numberoffiberlayers+1; $j+=4)
2438 {
2439  for ($i=1; $i<$numberoffibersegments+1; ++$i)
2440  {
2441  $pos_ref_name="Fiber" . $_[0] . "PosLeft" . $j . "_" . $i;
2442 print CRYO <<EOF;
2443  <physvol>
2444  <volumeref ref="volOpDetSensitive_Left"/>
2445  <positionref ref="$pos_ref_name"/>
2446  <rotation name="FiberRotLeft" x="90" z="90" unit="deg"/>
2447  </physvol>
2448 
2449 EOF
2450 }
2451 
2452 }
2453 }