3 # Much of this program is taken straight from generate_gdml.pl that
4 # generates MicroBooNE fragment files (Thank you.)
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
11 # If you are playing with different geometries, you can use the
12 # suffix command to help organize your work.
19 Math::BigFloat->precision(-15);
21 GetOptions( "help|h" => \$help,
22 "suffix|s:s" => \$suffix,
23 "output|o:s" => \$output,
24 "wires|w:s" => \$wires,
25 "helpcube|c" => \$helpcube);
29 # If the user requested help, print the usage notes and exit.
34 if ( ! defined $suffix )
36 # The user didn't supply a suffix, so append nothing to the file
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;
50 #++++++++++++++++++++++++ Begin defining variables +++++++++++++++++++++++++
52 # Define detector geometry variables - later to be put in a parameters
53 # XML file to be parsed as an input?
55 # set wires on to be the default, unless given an input by the user
56 $wires_on = 1; # 1=on, 0=off
67 #################################################
68 #### 4APA 35t parameters from DocDb 7550 ####
69 #################################################
73 ##################################################################
74 ##################### wire plane parameters ######################
97 ##################################################################
98 ######################## TPC parameters ##########################
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)
105 $TPCWireThickness = 0.015;
106 $TPCWirePlaneThickness = $TPCWireThickness;
108 $APA_z = 51.99; # DocDb 7550: "overall width"
111 $APAActive_z = 49.95; # DocDb 7550: "active width"
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
119 # Let APAs be numbered as follows
124 # Here are the APA heights indexed by APA number (lengths, z, are constant)
126 $APAHeight[0] = 196.0;
127 $APAHeight[1] = 112.0;
128 $APAHeight[2] = 84.0;
129 $APAHeight[3] = $APAHeight[0];
132 $APALongGap = 1.5; #separation between APAs along the incident beam axis
133 $APAVerticalGap = 2.5; #separation between APAs along the vertical axis
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.
139 $TPCSmallestLongDrift_x = $LongDrift + 3*$APAWirePlaneSpacing + $TPCWirePlaneThickness;
140 $TPCSmallestLongDrift_y = $APAHeight[2] + $APAVerticalGap;
141 $TPCSmallestLongDrift_z = $APA_z + $APALongGap;
143 $TPCMidLongDrift_x = $LongDrift + 3*$APAWirePlaneSpacing + $TPCWirePlaneThickness;
144 $TPCMidLongDrift_y = $APAHeight[1] + $APAVerticalGap;
145 $TPCMidLongDrift_z = $APA_z + $APALongGap;
147 $TPCLargestLongDrift_x = $LongDrift + 3*$APAWirePlaneSpacing + $TPCWirePlaneThickness;
148 $TPCLargestLongDrift_y = $APAHeight[0];
149 $TPCLargestLongDrift_z = $APA_z + $APALongGap;
151 $TPCSmallestShortDrift_x = $ShortDrift + 3*$APAWirePlaneSpacing + $TPCWirePlaneThickness;
152 $TPCSmallestShortDrift_y = $APAHeight[2] + $APAVerticalGap;
153 $TPCSmallestShortDrift_z = $APA_z + $APALongGap;
155 $TPCMidShortDrift_x = $ShortDrift + 3*$APAWirePlaneSpacing + $TPCWirePlaneThickness;
156 $TPCMidShortDrift_y = $APAHeight[1] + $APAVerticalGap;
157 $TPCMidShortDrift_z = $APA_z + $APALongGap;
159 $TPCLargestShortDrift_x = $ShortDrift + 3*$APAWirePlaneSpacing + $TPCWirePlaneThickness;
160 $TPCLargestShortDrift_y = $APAHeight[0];
161 $TPCLargestShortDrift_z = $APA_z + $APALongGap;
165 ############################################################
166 ############### Optical Detector parameters ################
168 # TODO: while the structure is exactly what we need, the parameters for
169 # paddle height and positioning are all placeholders
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
177 $LightPaddle_x = 0.476;
178 $LightPaddle_y = 56; # in cm from docDb 7803
179 $LightPaddle_z = 4*$inch;
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#]
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];
191 $PaddleYPositions[0][1] = $APAHeight[0] - 4*$inch - $LightPaddle_y/2;
192 $PaddleYPositions[3][1] = $PaddleYPositions[0][1];
194 $PaddleYPositions[0][2] = 4*$inch + $LightPaddle_y/2;
195 $PaddleYPositions[3][2] = $PaddleYPositions[0][2];
199 ##################################################################
200 ###################### Cryostat parameters #######################
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;
210 #$APALongGap = 1.5; #separation between APAs along the incident beam axis
211 #$APAVerticalGap = 2.5; #separation between APAs along the vertical axis
214 $CPA_y = ( $APAHeight[1]
216 + $APAHeight[2] ) / 2;
219 # Liquid and Gaseous Argon dimensions
220 $Argon_x = $TPCLargestShortDrift_x
222 + $TPCLargestLongDrift_x
224 + 2*$SpaceCPAToCryoWall;
225 $Argon_y = $APAHeight[1]
230 + $HeightGaseousAr; # assuming mid_y+smallest_y > largest_y
231 $Argon_z = 3*$APA_z + 2*$APALongGap
232 + $UpstreamLArPadding
233 + $DownstreamLArPadding;
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;
243 ##################################################################
244 ################# Detector Enclosure parameters ##################
246 $ConcretePadding = 50;
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;
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
260 $OriginZSet = $DetEnc_z/2
263 - $UpstreamLArPadding;
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
273 $OriginYSet = $DetEnc_y/2
277 - $APAHeight[2] #using tpc heights would include gap, we dont want to
280 $OriginYSetCheck = - $DetEnc_y/2
289 $OriginXSet = - $DetEnc_x/2
292 + $SpaceCPAToCryoWall
298 if (defined $helpcube)
300 $PosDirCubeSide = $ArToAr; #seems to be a good proportion
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
309 $World_x = 100*$DetEnc_x;
310 $World_y = 100*$DetEnc_y;
311 $World_z = 100*$DetEnc_z;
316 ##################################################################
317 ######################### CPA positions ##########################
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;
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;
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;
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;
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;
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;
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;
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;
365 ##################################################################
366 ######################### TPC positions ##########################
370 # Largest Short Drift
371 $posTPClsd_x = - $Argon_x/2
372 + $SpaceCPAToCryoWall
374 + $TPCLargestShortDrift_x/2;
375 $posTPClsd_y = $Argon_y/2
378 - $TPCLargestShortDrift_y/2;
381 $posTPClld_x = $Argon_x/2
382 - $SpaceCPAToCryoWall
384 - $TPCLargestLongDrift_x/2;
385 $posTPClld_y = $Argon_y/2
388 - $TPCLargestLongDrift_y/2;
390 $posTPCl_z_upstream = - $Argon_z/2
391 + $UpstreamLArPadding ## this already steps into the APALongGap/2 space on outside of TPC...
393 $posTPCl_z_downstream = $Argon_z/2
394 - $DownstreamLArPadding ## ...as well as this
399 # Smallest Long Drift
400 $posTPCsld_x = $Argon_x/2
401 - $SpaceCPAToCryoWall
403 - $TPCSmallestLongDrift_x/2;
404 $posTPCsld_y = - $Argon_y/2
407 $posTPCsld_z = $Argon_z/2
408 - $DownstreamLArPadding
414 $posTPCmld_x = $Argon_x/2
415 - $SpaceCPAToCryoWall
417 - $TPCMidLongDrift_x/2;
418 $posTPCmld_y = $Argon_y/2
422 $posTPCmld_z = $Argon_z/2
423 - $DownstreamLArPadding
430 # Smallest Short Drift
431 $posTPCssd_x = - $Argon_x/2
432 + $SpaceCPAToCryoWall
434 + $TPCSmallestShortDrift_x/2;
435 $posTPCssd_y = - $Argon_y/2
438 $posTPCssd_z = $Argon_z/2
439 - $DownstreamLArPadding
445 $posTPCmsd_x = - $Argon_x/2
446 + $SpaceCPAToCryoWall
448 + $TPCMidShortDrift_x/2;
449 $posTPCmsd_y = $Argon_y/2
453 $posTPCmsd_z = $Argon_z/2
454 - $DownstreamLArPadding
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
465 - $TPCLargestLongDrift_x
468 $APACenter[0][0] = $APA_Xcenter;
469 $APACenter[0][1] = $posTPClld_y;
470 $APACenter[0][2] = $posTPCl_z_upstream;
472 $APACenter[1][0] = $APA_Xcenter;
473 $APACenter[1][1] = $posTPCmld_y;
474 $APACenter[1][2] = $posTPCmld_z;
476 $APACenter[2][0] = $APA_Xcenter;
477 $APACenter[2][1] = $posTPCsld_y;
478 $APACenter[2][2] = $posTPCsld_z;
480 $APACenter[3][0] = $APACenter[0][0];
481 $APACenter[3][1] = $APACenter[0][1];
482 $APACenter[3][2] = $posTPCl_z_downstream;
485 ##################################################################
486 #################### Bar Fiber Module numbers ####################
487 $numberofbarlayers=4;
488 $numberofbarsegments=20;
489 $numberofplanklayers=4;
490 $numberofplanksegments=20;
491 $numberoffiberlayers=32;
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];
512 #+++++++++++++++++++++++++ End defining variables ++++++++++++++++++++++++++
516 # run the sub routines that generate the fragments
518 gen_Define(); # generates definitions at beginning of GDML
519 gen_Materials(); # generates materials to be used
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);
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);
536 write_fragments(); # writes the XML input for make_gdml.pl
537 # which zips together the final GDML
541 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
542 #+++++++++++++++++++++++++++++++++++++++++ usage +++++++++++++++++++++++++++++++++++++++++
543 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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";
555 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
556 #++++++++++++++++++++++++++++++++++++++ gen_Define +++++++++++++++++++++++++++++++++++++++
557 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
562 # Create the <define> fragment file name,
563 # add file to list of fragments,
565 $DEF = "dune_10kT_Def" . $suffix . ".gdml";
566 push (@gdmlFiles, $DEF);
568 open(DEF) or die("Could not open file $DEF for writing");
572 <?xml version='1.0'?>
582 <position name="posOriginSet" unit="cm" x="$OriginXSet" y="$OriginYSet" z="$OriginZSet"/>
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"/>
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"/>
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"/>
611 ##################################################################
612 ###################### Bar Module Position #######################
613 for ($k=1; $k<$numberofbars+1; ++$k)
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;}
620 for ($j=1; $j<$numberofbarlayers+1; ++$j)
622 $bar_z=-4.11 + 2.74*($j-1)+$PaddleCenterZ[$APA_i];
623 for ($i=1; $i<$numberofbarsegments+1; ++$i)
625 $bar_y=9.5*$inch + $PaddleCenterY[$APA_i][$p] - 2.54*($i-1);
626 $bar_name="Bar" . $k . "Pos" . $j . "_" . $i;
628 <position name="$bar_name" x="$PaddleCenterX" y="$bar_y" z="$bar_z" unit="cm"/>
634 ##################################################################
635 ##################### Plank Module Position ######################
636 for ($k=1; $k<$numberofplanks+1; ++$k)
638 if($k==1) {$APA_i=3;$p=2;}
640 for ($j=1; $j<$numberofplanklayers+1; ++$j)
642 $plank_z=-4.125 + 2.75*($j-1)+$PaddleCenterZ[$APA_i];
643 for ($i=1; $i<$numberofplanksegments+1; ++$i)
645 $plank_y=9.5*$inch + $PaddleCenterY[$APA_i][$p] - 2.54*($i-1);
646 $plank_name="PlankPos" . $j . "_" . $i;
648 <position name="$plank_name" x="$PaddleCenterX" y="$plank_y" z="$plank_z" unit="cm"/>
653 ##################################################################
654 ##################### Fiber Module Position ######################
656 for ($k=1; $k<$numberoffibers+1; ++$k)
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;}
662 ############################# Fiber ##############################
663 $numberoffibersegments=20;
665 for ($j=2; $j<$numberoffiberlayers+1; ++$j)
667 if($j%2==0) {$fiber_x=$PaddleCenterX-0.15;}
668 else {$fiber_x=$PaddleCenterX+0.15;}
670 $fiber_z=-4.65+0.3*($j-1)+$PaddleCenterZ[$APA_i];
671 for ($i=1; $i<$numberoffibersegments+1; ++$i)
673 $fiber_y=$PaddleCenterY[$APA_i][$p]-9.5*$inch+ 2.54*($i-1);
674 $fiber_name="Fiber" . $k . "Pos" . $j . "_" . $i;
676 <position name="$fiber_name" x="$fiber_x" y="$fiber_y" z="$fiber_z" unit="cm"/>
682 ########################## FiberBottom ###########################
684 $numberoffibersegments=17;
686 for ($j=1; $j<$numberoffiberlayers+1; ++$j)
688 if($j%2==0) {$fiber_x=$PaddleCenterX-0.15;}
689 else {$fiber_x=$PaddleCenterX+0.15;}
691 $fiber_z=-4.65+0.3*($j-1)+$PaddleCenterZ[$APA_i];
692 for ($i=1; $i<$numberoffibersegments+1; ++$i)
694 $fiber_y=$PaddleCenterY[$APA_i][$p]-9.5*$inch+ 2.54*($i-1);
695 $fiber_name="Fiber" . $k . "PosBottom" . $j . "_" . $i;
697 <position name="$fiber_name" x="$fiber_x" y="$fiber_y" z="$fiber_z" unit="cm"/>
703 ############################ FiberTop ############################
705 for ($j=1; $j<$numberoffiberlayers+1; ++$j)
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;
713 <position name="$fiber_name" x="$fiber_x" y="$fiber_y" z="$fiber_z" unit="cm"/>
718 ########################### FiberRight ###########################
720 $numberoffibersegments=2;
722 for ($j=1; $j<$numberoffiberlayers+1; $j+=4)
724 $fiber_x=$PaddleCenterX+0.15;
725 for ($i=1; $i<$numberoffibersegments+1; ++$i)
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;
732 <position name="$fiber_name" x="$fiber_x" y="$fiber_y" z="$fiber_z" unit="cm"/>
738 ########################### FiberLeft ############################
740 $numberoffibersegments=2;
742 for ($j=4; $j<$numberoffiberlayers+1; $j+=4)
744 $fiber_x=$PaddleCenterX-0.15;
745 for ($i=1; $i<$numberoffibersegments+1; ++$i)
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;
752 <position name="$fiber_name" x="$fiber_x" y="$fiber_y" z="$fiber_z" unit="cm"/>
771 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
772 #+++++++++++++++++++++++++++++++++++++ gen_Materials +++++++++++++++++++++++++++++++++++++
773 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
778 # Create the <materials> fragment file name,
779 # add file to list of output GDML fragments,
781 $MAT = "dune_10kT_Materials" . $suffix . ".gdml";
782 push (@gdmlFiles, $MAT);
784 open(MAT) or die("Could not open file $MAT for writing");
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>
809 <material name="Vacuum" formula="Vacuum">
810 <D value="1.e-25" unit="g/cm3"/>
811 <fraction n="1.0" ref="videRef"/>
814 <material name="ALUMINUM_Al" formula="ALUMINUM_Al">
815 <D value="2.6990" unit="g/cm3"/>
816 <fraction n="1.0000" ref="aluminum"/>
819 <material name="SILICON_Si" formula="SILICON_Si">
820 <D value="2.3300" unit="g/cm3"/>
821 <fraction n="1.0000" ref="silicon"/>
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"/>
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"/>
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"/>
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"/>
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"/>
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"/>
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"/>
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"/>
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"/>
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"/>
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"/>
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"/>
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"/>
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"/>
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"/>
932 <material name="LAr" formula="LAr">
933 <D value="1.40" unit="g/cm3"/>
934 <fraction n="1.0000" ref="argon"/>
937 <material name="ArGas" formula="ArGas">
938 <D value="0.00166" unit="g/cm3"/>
939 <fraction n="1.0" ref="argon"/>
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"/>
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"/>
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"/>
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"/>
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"/>
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"/>
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"/>
1003 <material formula="Ti" name="Titanium">
1004 <D value="4.506" unit="g/cm3"/>
1005 <fraction n="1." ref="titanium"/>
1008 <material name="TPB" formula="TPB">
1009 <D value="1.40" unit="g/cm3"/>
1010 <fraction n="1.0000" ref="argon"/>
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"/>
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"/>
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"/>
1046 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1047 #++++++++++++++++++++++++++++++++++++++++ gen_TPC ++++++++++++++++++++++++++++++++++++++++
1048 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1059 my $TPCWirePlaneHeight = $_[1] - $APAVerticalGap;
1060 my $TPCWirePlaneLength = $_[2] - $APALongGap;
1062 my $TPCActive_x = $_[0]-(4*$APAWirePlaneSpacing);
1063 my $TPCActive_y = $TPCWirePlaneHeight;
1064 my $TPCActive_z = $TPCWirePlaneLength;
1066 my $UAngle = $UAng[$_[4]];
1067 my $VAngle = $VAng[$_[4]];
1069 my $SinUAngle = sin( deg2rad($UAngle) );
1070 my $CosUAngle = cos( deg2rad($UAngle) );
1071 my $TanUAngle = tan( deg2rad($UAngle) );
1073 my $SinVAngle = sin( deg2rad($VAngle) );
1074 my $CosVAngle = cos( deg2rad($VAngle) );
1075 my $TanVAngle = tan( deg2rad($VAngle) );
1077 my $UWire_yint = $UWirePitch/$SinUAngle;
1078 my $UWire_zint = $UWirePitch/$CosUAngle;
1080 my $VWire_yint = $VWirePitch/$SinVAngle;
1081 my $VWire_zint = $VWirePitch/$CosVAngle;
1083 #constructs everything inside volTPC, namely
1084 # (moving from left to right, or from +x to -x)
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
1091 # Create the TPC fragment file name,
1092 # add file to list of output GDML fragments,
1094 $TPC = "35t_TPC_${_[3]}" . $suffix . ".gdml";
1095 push (@gdmlFiles, $TPC);
1097 open(TPC) or die("Could not open file $TPC for writing");
1100 # The standard XML prefix and starting the gdml
1102 <?xml version='1.0'?>
1107 # All the TPC solids save the wires.
1110 <box name="$_[3]" lunit="cm"
1114 <box name="${_[3]}Plane" lunit="cm"
1115 x="$TPCWirePlaneThickness"
1116 y="$TPCWirePlaneHeight"
1117 z="$TPCWirePlaneLength"/>
1118 <box name="${_[3]}Active" lunit="cm"
1125 #++++++++++++++++++++++++++++ Wire Solids ++++++++++++++++++++++++++++++
1129 <tube name="${_[3]}WireVert"
1130 rmax="0.5*$TPCWireThickness"
1131 z="$TPCWirePlaneHeight"
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
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;
1151 # Number of wires in one corner
1152 $NumberCornerUWires = int( $TPCWirePlaneLength/($UWirePitch/$CosUAngle) );
1154 $NumberCornerVWires = int( $TPCWirePlaneLength/($VWirePitch/$CosVAngle) );
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) );
1160 $NumberSideVWires = int( $TPCWirePlaneHeight/($VWirePitch/$SinVAngle) );
1162 # Number of wires per side that aren't cut off by the corner
1163 $NumberCommonUWires = $NumberSideUWires - $NumberCornerUWires;
1165 $NumberCommonVWires = $NumberSideVWires - $NumberCornerVWires;
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 );
1174 # The corner wires for the U plane
1177 for ($i = 0; $i < $NumberCornerUWires; ++$i)
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
1184 <tube name="${_[3]}WireU$i"
1185 rmax="0.5*$TPCWireThickness"
1186 z="$UWirePitch*($TanUAngle+1/$TanUAngle)*($i+1)-0.01732"
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
1198 <tube name="${_[3]}WireUCommon"
1199 rmax="0.5*$TPCWireThickness"
1200 z="$TPCWirePlaneLength/$SinUAngle-0.02598"
1209 # The corner wires for the V plane
1212 for ($i = 0; $i < $NumberCornerVWires; ++$i)
1214 # Same subtraction to avoid corners of wires overlapping
1215 # the TPCPlane sides
1219 <tube name="${_[3]}WireV$i"
1220 rmax="0.5*$TPCWireThickness"
1221 z="$VWirePitch*($TanVAngle+1/$TanVAngle)*($i+1)-0.01732"
1230 # The wire used many times in the middle of the V plane
1231 # Same subtraction as U common
1234 <tube name="${_[3]}WireVCommon"
1235 rmax="0.5*$TPCWireThickness"
1236 z="$TPCWirePlaneLength/$SinVAngle-0.02598"
1246 # Begin structure and create the vertical wire logical volume
1250 <volume name="volTPCActive${_[3]}">
1251 <materialref ref="LAr"/>
1252 <solidref ref="${_[3]}Active"/>
1261 <volume name="volTPCWireVert${_[3]}">
1262 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1263 <solidref ref="${_[3]}WireVert"/>
1267 # Corner U wires logical volumes
1268 for ($i = 0; $i < $NumberCornerUWires; ++$i)
1271 <volume name="volTPCWireU$i${_[3]}">
1272 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1273 <solidref ref="${_[3]}WireU$i"/>
1279 # Common U wire logical volume, referenced many times
1281 <volume name="volTPCWireUCommon${_[3]}">
1282 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1283 <solidref ref="${_[3]}WireUCommon"/>
1287 # Corner V wires logical volumes
1288 for ($i = 0; $i < $NumberCornerVWires; ++$i)
1291 <volume name="volTPCWireV$i${_[3]}">
1292 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1293 <solidref ref="${_[3]}WireV$i"/>
1299 # Common V wire logical volume, referenced many times
1301 <volume name="volTPCWireVCommon${_[3]}">
1302 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1303 <solidref ref="${_[3]}WireVCommon"/>
1312 #+++++++++++++++++++++++++ Position physical wires ++++++++++++++++++++++++++
1314 # ++++++++++++++++++++++ U Plane +++++++++++++++++++++++
1316 # Create U plane logical volume
1318 <volume name="volTPCPlaneU${_[3]}">
1319 <materialref ref="LAr"/>
1320 <solidref ref="${_[3]}Plane"/>
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
1335 for ($i = 0; $i < $NumberCornerUWires; ++$i)
1337 my $ypos = (-0.5*$TPCWirePlaneHeight)+0.5*($i+1)*$UWire_yint;
1338 my $zpos = (0.5*$TPCWirePlaneLength)-0.5*($i+1)*$UWire_zint;
1340 my $diff=(0.5*$TPCWirePlaneLength)-0.5*($NumberCornerUWires)*$UWire_zint;
1341 my $zpos=$zpos-$diff;
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"/>
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
1363 for ($i = $NumberCornerUWires; $i < $NumberSideUWires; ++$i)
1365 my $ypos = (-0.5*$TPCWirePlaneHeight)+0.5*($NumberCornerUWires)*$UWire_yint+($i+1-$NumberCornerUWires)*$UWire_yint;
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"/>
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
1385 for ($i = $NumberSideUWires; $i < $NumberSideUWires+$NumberCornerUWires-1; ++$i)
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.
1391 $j = $NumberSideUWires+$NumberCornerUWires - $i - 2;
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.
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;
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"/>
1418 # ++++++++++++++++++++++ V Plane +++++++++++++++++++++++
1420 # End U plane and create V plane logical volume
1424 <volume name="volTPCPlaneV${_[3]}">
1425 <materialref ref="LAr"/>
1426 <solidref ref="${_[3]}Plane"/>
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
1442 for ($i = 0; $i < $NumberCornerVWires; ++$i)
1444 my $ypos = (-0.5*$TPCWirePlaneHeight)+0.5*($i+1)*$VWire_yint;
1445 my $zpos = (-0.5*$TPCWirePlaneLength)+0.5*($i+1)*$VWire_zint;
1447 my $diff=(-0.5*$TPCWirePlaneLength)+0.5*($NumberCornerVWires)*$VWire_zint;
1448 my $zpos=$zpos-$diff;
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"/>
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
1468 for ($i = $NumberCornerVWires; $i < $NumberSideVWires; ++$i)
1470 my $ypos = (-0.5*$TPCWirePlaneHeight)-0.5*($NumberCornerVWires)*$VWire_yint+($i+1)*$VWire_yint;
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"/>
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
1490 for ($i = $NumberSideVWires; $i < $NumberSideVWires+$NumberCornerVWires-1; ++$i)
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
1495 $j = $NumberSideVWires+$NumberCornerVWires - $i - 2;
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
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;
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"/>
1518 # ++++++++++++++++++++++ X Plane +++++++++++++++++++++++
1520 # End V plane and create X plane logical volume
1524 <volume name="volTPCPlaneX${_[3]}">
1525 <materialref ref="LAr"/>
1526 <solidref ref="${_[3]}Plane"/>
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
1538 for ($i=0; $i<$NumberVerticalWires; ++$i)
1540 my $zpos = (-0.5*$APAActive_z)+$XWirePitch*($i+0.5)+$TPCWireThickness/2;
1544 <volumeref ref="volTPCWireVert${_[3]}"/>
1545 <position name="pos${_[3]}WireX$i" unit="cm" x="0" y="0 " z="$zpos"/>
1546 <rotationref ref="rPlus90AboutX"/>
1558 #+++++++++++++++++++++ Position physical wires Above +++++++++++++++++++++
1560 #wrap up the TPC file
1562 <volume name="volTPC${_[3]}">
1563 <materialref ref="LAr"/>
1564 <solidref ref="${_[3]}"/>
1566 <volumeref ref="volTPCPlaneU${_[3]}"/>
1567 <position name="pos${_[3]}PlaneU" unit="cm" x="-($_[0]/2)+3*$APAWirePlaneSpacing" y="0" z="0"/>
1570 <volumeref ref="volTPCPlaneV${_[3]}"/>
1571 <position name="pos${_[3]}PlaneV" unit="cm" x="-($_[0]/2)+2*$APAWirePlaneSpacing" y="0" z="0"/>
1574 <volumeref ref="volTPCPlaneX${_[3]}"/>
1575 <position name="pos${_[3]}PlaneX" unit="cm" x="-($_[0]/2)+$APAWirePlaneSpacing" y="0" z="0"/>
1578 <volumeref ref="volTPCActive${_[3]}"/>
1579 <position name="pos${_[3]}Active" unit="cm" x="-($_[0]/2)+$APAWirePlaneSpacing + $TPCActive_x/2" y="0" z="0"/>
1588 } #end of sub gen_TPC
1594 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1595 #++++++++++++++++++++++++++++++++++++++ gen_Cryostat +++++++++++++++++++++++++++++++++++++
1596 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1601 # Create the cryostat fragment file name,
1602 # add file to list of output GDML fragments,
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");
1610 # The standard XML prefix and starting the gdml
1612 <?xml version='1.0'?>
1617 # All the cryostat solids.
1620 <box name="Cryostat" lunit="cm"
1625 <box name="ArgonInterior" lunit="cm"
1630 <subtraction name="SteelShell">
1631 <first ref="Cryostat"/>
1632 <second ref="ArgonInterior"/>
1635 <box name="Cathode" lunit="cm"
1640 <box name="LightPaddle" lunit="cm"
1642 y="$LightPaddle_y + $SiPM_y"
1643 z="$LightPaddle_z"/>
1645 <box name="Bar" lunit="cm"
1650 <box name="Plank" lunit="cm"
1655 <box name="Fiber" lunit="cm"
1660 <box name="FiberTop" lunit="cm"
1665 <para name="FiberRight" x="0.3" y="0.3" z="5.3975/2" alpha="0" theta="3" phi="0" aunit="deg" lunit="cm"/>
1667 <para name="FiberLeft" x="0.3" y="0.3" z="5.3975/2" alpha="0" theta="-3" phi="0" aunit="deg" lunit="cm"/>
1672 # Add APA frames and optical detectors (paddles)
1679 # Cryostat structure
1683 <volume name="volSteelShell">
1684 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1685 <solidref ref="SteelShell"/>
1688 <volume name="volCathode">
1689 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1690 <solidref ref="Cathode"/>
1693 <volume name="volOpDetSensitive_Bar">
1694 <materialref ref="LAr"/>
1695 <solidref ref="Bar"/>
1698 <volume name="volOpDetSensitive_Plank">
1699 <materialref ref="LAr"/>
1700 <solidref ref="Plank"/>
1703 <volume name="volOpDetSensitive_Fiber">
1704 <materialref ref="LAr"/>
1705 <solidref ref="Fiber"/>
1708 <volume name="volOpDetSensitive_Bottom">
1709 <materialref ref="LAr"/>
1710 <solidref ref="Fiber"/>
1713 <volume name="volOpDetSensitive_Top">
1714 <materialref ref="LAr"/>
1715 <solidref ref="FiberTop"/>
1718 <volume name="volOpDetSensitive_Right">
1719 <materialref ref="LAr"/>
1720 <solidref ref="FiberRight"/>
1723 <volume name="volOpDetSensitive_Left">
1724 <materialref ref="LAr"/>
1725 <solidref ref="FiberLeft"/>
1737 <volume name="volCryostat">
1738 <materialref ref="LAr"/>
1739 <solidref ref="Cryostat"/>
1742 <volumeref ref="volSteelShell"/>
1743 <position name="posSteelShell" unit="cm" x="0" y="0" z="0"/>
1748 <volumeref ref="volCathode"/>
1749 <positionref ref="posCathode0"/>
1752 <volumeref ref="volCathode"/>
1753 <positionref ref="posCathode1"/>
1756 <volumeref ref="volCathode"/>
1757 <positionref ref="posCathode2"/>
1760 <volumeref ref="volCathode"/>
1761 <positionref ref="posCathode3"/>
1765 <volumeref ref="volCathode"/>
1766 <positionref ref="posCathode4"/>
1769 <volumeref ref="volCathode"/>
1770 <positionref ref="posCathode5"/>
1773 <volumeref ref="volCathode"/>
1774 <positionref ref="posCathode6"/>
1777 <volumeref ref="volCathode"/>
1778 <positionref ref="posCathode7"/>
1782 <!-- The Smallest APA -->
1784 <volumeref ref="volTPCSmallestLongDrift"/>
1785 <positionref ref="posTPCSmallestLongDrift"/>
1786 <rotationref ref="rIdentity"/>
1789 <volumeref ref="volTPCSmallestShortDrift"/>
1790 <positionref ref="posTPCSmallestShortDrift"/>
1791 <rotationref ref="rPlus180AboutY"/>
1796 place_APA($APACenter[2][0], $APACenter[2][1], $APACenter[2][2], 2);
1801 <!-- The Middle-sized APA -->
1803 <volumeref ref="volTPCMidLongDrift"/>
1804 <positionref ref="posTPCMidLongDrift"/>
1805 <rotationref ref="rIdentity"/>
1808 <volumeref ref="volTPCMidShortDrift"/>
1809 <positionref ref="posTPCMidShortDrift"/>
1810 <rotationref ref="rPlus180AboutY"/>
1815 place_APA($APACenter[1][0], $APACenter[1][1], $APACenter[1][2], 1);
1820 <!-- The Largest APAs, Upstream and Downstream -->
1822 <volumeref ref="volTPCLargestLongDrift"/>
1823 <positionref ref="posTPCLargestLongDrift_Neg"/>
1824 <rotationref ref="rIdentity"/>
1827 <volumeref ref="volTPCLargestShortDrift"/>
1828 <positionref ref="posTPCLargestShortDrift_Neg"/>
1829 <rotationref ref="rPlus180AboutY"/>
1832 <volumeref ref="volTPCLargestLongDrift"/>
1833 <positionref ref="posTPCLargestLongDrift_Pos"/>
1834 <rotationref ref="rIdentity"/>
1837 <volumeref ref="volTPCLargestShortDrift"/>
1838 <positionref ref="posTPCLargestShortDrift_Pos"/>
1839 <rotationref ref="rPlus180AboutY"/>
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);
1859 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1860 #++++++++++++++++++++++++++++++++++++++ solid_APA ++++++++++++++++++++++++++++++++++++++++
1861 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1864 # Must be called only within gen_Cryostat(),
1867 # $_[0] = APA number
1868 # convention: 0 is Largest, 1 is Mid, 2 is Smallest
1875 ####################################################################
1876 ################# APA Frame and Paddle Dimensions ##################
1878 $APA_y = $APAHeight[$APA_i];
1880 $APAFrameZSide_x = $APAFrame_x;
1881 $APAFrameZSide_y = 4*$inch;
1882 $APAFrameZSide_z = $APA_z;
1884 $APAFrameYSide_x = $APAFrame_x;
1885 $APAFrameYSide_y = $APA_y-2*$APAFrameZSide_y;
1886 $APAFrameYSide_z = 4*$inch;
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;
1893 $EdgeFrameSteelThickness = 0.12*$inch;
1894 $InnerFrameSteelThickness = 0.062*$inch;
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"/>
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"/>
1928 <box name="APAFrameYOuterSupport\-$APA_i" lunit="cm"
1929 x="$EdgeFrameSteelThickness"
1930 y="$APAFrameYOuterSupport_y"
1931 z="$APAFrameYOuterSupport_z"/>
1942 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1943 #++++++++++++++++++++++++++++++++++++++ vol_APA ++++++++++++++++++++++++++++++++++++++++
1944 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1947 # Must be called only within gen_Cryostat(),
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
1963 <volume name="volAPAFrameYSide\-$APA_i">
1964 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1965 <solidref ref="APAFrameYSide\-$APA_i"/>
1968 <volume name="volAPAFrameZSide\-$APA_i">
1969 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1970 <solidref ref="APAFrameZSide\-$APA_i"/>
1973 <volume name="volAPAFrameYOuterSupport\-$APA_i">
1974 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1975 <solidref ref="APAFrameYOuterSupport\-$APA_i"/>
1984 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1985 #++++++++++++++++++++++++++++++++++++++ place_APA ++++++++++++++++++++++++++++++++++++++++
1986 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1989 # Must be called only within gen_Cryostat(),
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
2003 ####################################################################
2004 ################# APA Frame and Paddle Dimensions ##################
2006 $APA_y = $APAHeight[$APA_i];
2008 $APAFrameZSide_x = $APAFrame_x;
2009 $APAFrameZSide_y = 4*$inch;
2010 $APAFrameZSide_z = $APA_z;
2012 $APAFrameYSide_x = $APAFrame_x;
2013 $APAFrameYSide_y = $APA_y-2*$APAFrameZSide_y;
2014 $APAFrameYSide_z = 4*$inch;
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;
2021 # if there were an inner support to fill the hole
2022 $APAFrameYInnerSupport_x = $LightPaddle_x;
2024 $EdgeFrameSteelThickness = 0.12*$inch;
2025 $InnerFrameSteelThickness = 0.062*$inch;
2027 #TODO: Place TPCs in here as well, but for now just do frames and paddles
2031 # First put in the frame
2034 <volumeref ref="volAPAFrameYOuterSupport\-$APA_i"/>
2035 <position name="posAPAFrameYOuterSupportNeg\-$APA_i" unit="cm"
2036 x="$_[0] - ($APAFrameYOuterSupport_x + $APAFrameYInnerSupport_x/2 - $EdgeFrameSteelThickness/2)"
2039 <rotationref ref="rIdentity"/>
2042 <volumeref ref="volAPAFrameYOuterSupport\-$APA_i"/>
2043 <position name="posAPAFrameYOuterSupportPos\-$APA_i" unit="cm"
2044 x="$_[0] + ($APAFrameYOuterSupport_x + $APAFrameYInnerSupport_x/2 - $EdgeFrameSteelThickness/2)"
2047 <rotationref ref="rIdentity"/>
2050 <volumeref ref="volAPAFrameYSide\-$APA_i"/>
2051 <position name="posAPAFrameYSideNeg\-$_[3]" unit="cm"
2054 z="$_[2] - $APA_z/2 + $APAFrameYSide_z/2"/>
2055 <rotationref ref="rIdentity"/>
2058 <volumeref ref="volAPAFrameYSide\-$APA_i"/>
2059 <position name="posAPAFrameYSidePos\-$_[3]" unit="cm"
2062 z="$_[2] + $APA_z/2 - $APAFrameYSide_z/2"/>
2063 <rotationref ref="rIdentity"/>
2066 <volumeref ref="volAPAFrameZSide\-$APA_i"/>
2067 <position name="posAPAFrameZSidePos\-$_[3]" unit="cm"
2069 y="$_[1] + $APA_y/2 - $APAFrameZSide_y/2"
2071 <rotationref ref="rIdentity"/>
2074 <volumeref ref="volAPAFrameZSide\-$APA_i"/>
2075 <position name="posAPAFrameZSideNeg\-$_[3]" unit="cm"
2077 y="$_[1] - $APA_y/2 + $APAFrameZSide_y/2"
2079 <rotationref ref="rIdentity"/>
2085 # Now loop through paddle y positions and place them
2086 #for( $p=0; $p<$nPaddlesInAPA[$APA_i]; $p++ ){
2088 #if($nPaddlesInAPA[$APA_i]!=1)
2093 # <volumeref ref="volOpDetSensitive"/>
2094 # <position name="posPaddle\-$p\-APA\-$APA_i" unit="cm"
2096 # y="$_[1] - $APAHeight[$APA_i]/2 + $PaddleYPositions[$APA_i][$p]"
2098 # <rotationref ref="rIdentity"/>
2104 case 0 { place_bar(2);
2107 case 1 { place_bar(1); }
2108 case 2 { place_fiber(1); }
2109 case 3 { place_bar(4);
2120 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2121 #+++++++++++++++++++++++++++++++++++++ gen_Enclosure +++++++++++++++++++++++++++++++++++++
2122 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2127 # Create the detector enclosure fragment file name,
2128 # add file to list of output GDML fragments,
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");
2136 # The standard XML prefix and starting the gdml
2138 <?xml version='1.0'?>
2143 # All the detector enclosure solids.
2147 <box name="DetEnclosure" lunit="cm"
2157 # Detector enclosure structure
2161 <volume name="volDetEnclosure">
2162 <materialref ref="Concrete"/>
2163 <solidref ref="DetEnclosure"/>
2165 <volumeref ref="volCryostat"/>
2166 <position name="posCryo" unit="cm" x="0" y="$CryoInDetEnc_ypos" z="0"/>
2181 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2182 #+++++++++++++++++++++++++++++++++++++++ gen_World +++++++++++++++++++++++++++++++++++++++
2183 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2188 # Create the WORLD fragment file name,
2189 # add file to list of output GDML fragments,
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");
2197 # The standard XML prefix and starting the gdml
2199 <?xml version='1.0'?>
2204 # All the World solids.
2207 <box name="World" lunit="cm"
2217 <volume name="volWorld" >
2218 <materialref ref="Air"/>
2219 <solidref ref="World"/>
2221 <volumeref ref="volDetEnclosure"/>
2222 <position name="posDetEnclosure" unit="cm" x="$OriginXSet" y="$OriginYSet" z="$OriginZSet"/>
2229 # make_gdml.pl will take care of <setup/>
2234 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2235 #++++++++++++++++++++++++++++++++++++ write_fragments ++++++++++++++++++++++++++++++++++++
2236 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2238 sub write_fragments()
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)
2245 if ( ! defined $output )
2247 $output = "-"; # write to STDOUT
2250 # Set up the output file.
2251 $OUTPUT = ">" . $output;
2252 open(OUTPUT) or die("Could not open file $OUTPUT");
2255 <?xml version='1.0'?>
2257 <!-- Input to Geometry/gdml/make_gdml.pl; define the GDML fragments
2258 that will be zipped together to create a detector description.
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
2273 foreach $filename (@defFiles)
2276 <filename> $filename </filename>
2286 <!-- The GDML file fragments to be zipped together. -->
2290 foreach $filename (@gdmlFiles)
2293 <filename> $filename </filename>
2313 for($j=1; $j<$numberofbarlayers+1; $j++)
2315 for($i=1; $i<$numberofbarsegments+1; $i++)
2317 $pos_ref_name="Bar" . $_[0] . "Pos" . $j . "_" . $i;
2320 <volumeref ref="volOpDetSensitive_Bar"/>
2321 <positionref ref="$pos_ref_name"/>
2335 for($j=1; $j<$numberofbarlayers+1; $j++)
2337 for($i=1; $i<$numberofbarsegments+1; $i++)
2339 $pos_ref_name="PlankPos" . $j . "_" . $i;
2342 <volumeref ref="volOpDetSensitive_Plank"/>
2343 <positionref ref="$pos_ref_name"/>
2353 <!-- 32 Fiber Module-->
2357 ############################# Fiber ##############################
2358 $numberoffibersegments=20;
2360 for ($j=2; $j<$numberoffiberlayers+1; ++$j)
2363 for ($i=1; $i<$numberoffibersegments+1; ++$i)
2365 $pos_ref_name="Fiber" . $_[0] . "Pos" . $j . "_" . $i;
2368 <volumeref ref="volOpDetSensitive_Fiber"/>
2369 <positionref ref="$pos_ref_name"/>
2374 if($j%2!=0) {$j+=2;}
2377 ########################## FiberBottom ###########################
2379 $numberoffibersegments=17;
2381 for ($j=1; $j<$numberoffiberlayers+1; ++$j)
2383 for ($i=1; $i<$numberoffibersegments+1; ++$i)
2385 $pos_ref_name="Fiber" . $_[0] . "PosBottom" . $j . "_" . $i;
2388 <volumeref ref="volOpDetSensitive_Bottom"/>
2389 <positionref ref="$pos_ref_name"/>
2394 if($j%2!=0) {$j+=2;}
2397 ############################ FiberTop ############################
2399 for ($j=1; $j<$numberoffiberlayers+1; ++$j)
2401 $pos_ref_name="Fiber" . $_[0] . "PosTop" . $j;
2404 <volumeref ref="volOpDetSensitive_Top"/>
2405 <positionref ref="$pos_ref_name"/>
2409 if($j%2!=0) {$j+=2;}
2412 ########################### FiberRight ###########################
2414 $numberoffibersegments=2;
2416 for ($j=1; $j<$numberoffiberlayers+1; $j+=4)
2418 for ($i=1; $i<$numberoffibersegments+1; ++$i)
2420 $pos_ref_name="Fiber" . $_[0] . "PosRight" . $j . "_" . $i;
2423 <volumeref ref="volOpDetSensitive_Right"/>
2424 <positionref ref="$pos_ref_name"/>
2425 <rotation name="FiberRotRight" x="90" z="90" unit="deg"/>
2433 ########################### FiberLeft ############################
2435 $numberoffibersegments=2;
2437 for ($j=4; $j<$numberoffiberlayers+1; $j+=4)
2439 for ($i=1; $i<$numberoffibersegments+1; ++$i)
2441 $pos_ref_name="Fiber" . $_[0] . "PosLeft" . $j . "_" . $i;
2444 <volumeref ref="volOpDetSensitive_Left"/>
2445 <positionref ref="$pos_ref_name"/>
2446 <rotation name="FiberRotLeft" x="90" z="90" unit="deg"/>