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.
21 Math::BigFloat->precision(-15);
23 GetOptions( "help|h" => \$help,
24 "suffix|s:s" => \$suffix,
25 "output|o:s" => \$output,
26 "wires|w:s" => \$wires,
27 "helpcube|c" => \$helpcube);
31 # If the user requested help, print the usage notes and exit.
36 if ( ! defined $suffix )
38 # The user didn't supply a suffix, so append nothing to the file
44 # Otherwise, stick a "-" before the suffix, so that a suffix of
45 # "test" applied to filename.gdml becomes "filename-test.gdml".
46 $suffix = "-" . $suffix;
52 #++++++++++++++++++++++++ Begin defining variables +++++++++++++++++++++++++
54 # Define detector geometry variables - later to be put in a parameters
55 # XML file to be parsed as an input?
57 # set wires on to be the default, unless given an input by the user
58 $wires_on = 1; # 1=on, 0=off
69 #################################################
70 #### 4APA 35t parameters from DocDb 7550 ####
71 #################################################
75 ##################################################################
76 ##################### wire plane parameters ######################
79 $UVReadoutBoardPitch = 0.698516;
80 #$UVReadoutBoardPitch = 0.7;
100 $UWirePitch = $UVReadoutBoardPitch*cos(deg2rad($UAng[0]));
101 $VWirePitch = $UVReadoutBoardPitch*cos(deg2rad($VAng[0]));
102 $XWirePitch = 0.449055;
105 ##################################################################
106 ######################## TPC parameters ##########################
108 $G10thickness = 0.3155;
110 #$G10thickness = $inch/8;
111 #$WrapCover = $inch/16;
115 $APAFrame_x = 5.0661; # ~2in -- this does not include the wire spacing
117 $TPCWireThickness = 0.015;
118 $TPCWirePlaneThickness = $TPCWireThickness;
119 $APAWirePlaneSpacing = 0.4730488 + $TPCWirePlaneThickness; # center to center spacing between all of the wire planes (g, u, v, and x)
121 # At creation of the plane volumes, the y and z boundaries will be increased
122 # by this much at each of the 4 edges. this is so the corners of the wire
123 # tubes don't extrude. For all other purposes, the plane dimensions stay as originally defined
124 $UVPlaneBoundNudge = $TPCWireThickness;
126 # The following are all widths about the same z center,
127 # namely the center of the corresponding APA
128 #$Zactive_z = 49.8441 + $TPCWireThickness;
129 $Zactive_z = 112*$XWirePitch + $TPCWireThickness;
130 $APAFrame_z = 50.2619;
131 #$Vactive_z = 50.8929 - 2*$G10thickness;
132 #$Uactive_z = 51.5240 - 2*$G10thickness;
133 $Vactive_z = $APAFrame_z;
134 $Uactive_z = $APAFrame_z + 2*$G10thickness;
135 $APAphys_z = 51.8395;
138 # NUMBER VERTICAL WIRES = (Zview_z / pitch) + 1
139 # Since Zview_z is defined in docdb 7550 to be distance
140 # between outer vertical wires, + 1 since the floor of this
141 # division will be one under, giveing the amt of spaces, not wires
142 # POSITIONING: plane centered between +/- APAActive_z/2
144 # Let APAs be numbered as follows
146 # 1 - Middle (Middle Top)
147 # 2 - Smallest (Middle Bottom)
148 # APA heights and positions will be indexed by APA number
150 $ReadoutBoardOverlap = 7.61; #board overlaps wires, chop this off of their active height
152 $APAFrame_y[0] = 203.06;
153 $APAFrame_y[1] = 119.29;
154 $APAFrame_y[2] = 91.37;
155 $APAFrame_y[3] = $APAFrame_y[0];
157 for($apa = 0; $apa < 4; ++$apa){
159 # each view has its own G10 board to wrap around at the bottom
160 # and is covered by the readout board at the top
161 $Zactive_y[$apa] = $APAFrame_y[$apa] + 0*$G10thickness - $ReadoutBoardOverlap;
162 $Vactive_y[$apa] = $APAFrame_y[$apa] + 1*$G10thickness - $ReadoutBoardOverlap;
163 $Uactive_y[$apa] = $APAFrame_y[$apa] + 2*$G10thickness - $ReadoutBoardOverlap;
165 # the last G10 board for the grid, then a cover. This is not "covered" by the board
166 $APAphys_y[$apa] = $APAFrame_y[$apa] + 4*$G10thickness + $WrapCover;
170 $APAGap_y = 0.0845; #separation between APAs along the incident beam axis
171 $APAGap_z = 0.0845; #separation between APAs along the vertical axis
174 # include APA spacing in y and z so volTPCs touch in y and z directions with correct APA
175 # spacing - this makes for smoother event generation.
177 $TPCLongDrift_x = $LongDrift + 3*$APAWirePlaneSpacing + $TPCWirePlaneThickness;
178 $TPCShortDrift_x = $ShortDrift + 3*$APAWirePlaneSpacing + $TPCWirePlaneThickness;
179 #$TPC_z = $APAphys_z + $APAGap_z;
181 # height is the same for each
182 for($apa = 0; $apa < 4; ++$apa){
183 $TPC_y[$apa] = $APAphys_y[$apa] + $APAGap_y;
187 ############################################################
188 #################### AuxDet parameters #####################
190 $AuxDetHousingHeight = 27.72*$inch;
191 $AuxDetHousingLongSide = 13.07*$inch;
192 $AuxDetHousingShortSide = 10.64*$inch;
193 $AuxDetHousingThickness = 3;
194 $AuxDetScintillatorHeight = 24.80*$inch;
195 $AuxDetScintillatorLongSide = 12.82*$inch;
196 $AuxDetScintillatorShortSide = 10.65*$inch;
197 $AuxDetScintillatorThickness = 0.95;
199 # email from Michelle:
200 # the housing (AL box) is 13.07/10.64 x 27.72 (inches)
201 # the actual scintillator is 12.82/10.65 x 24.80 (inches)
204 # AuxDet configuration:
206 # / \ _______ / \ _______ } This spacing is only in the housing,
207 # / \\ // \\ / so it is not implimented in AuDet
208 #/______\\ //______\\ / which only represents the scintillator
212 # email from Michelle:
213 # Assume that the telescope scintillator is a rectangle, 64 3/4" x 6 5/8" x 3/4".
215 $AuxDetBSUScintWidth = (6+5/8)*$inch;
216 $AuxDetBSUScintHeight = 0.75*$inch;
217 $AuxDetBSUScintLength = 64.75*$inch;
220 # these positions pulled from a coordinate system with positive x and z are reversed
221 # positions are from a particular corner of the scintillators
222 ############################
223 ############################
224 @BSULayer1_xpos = ( 16.21, 9.46, 2.71, -4.04,
225 -17.33, -24.08, -30.83, -37.58,
226 -44.33, -51.08, -57.83, -64.58, -71.33 );
227 for($i = 0; $i < 13; ++$i){
228 $BSULayer1_xpos[$i] *= -$inch; # negative reverses coordinate system back
229 $BSULayer1_xpos[$i] -= $AuxDetBSUScintWidth/2; # move to center of volume
231 $BSULayer1_ypos = 75.14*$inch;
232 $BSULayer1_zpos = -1.21*$inch;
233 $BSULayer1_zpos = -1*$BSULayer1_zpos + $AuxDetBSUScintLength/2; # correct coordinates and move to center of scint
234 ############################
235 ############################
236 $BSULayer2_xpos = -67.24*$inch;
237 $BSULayer2_xpos = -1*$BSULayer2_xpos - $AuxDetBSUScintLength/2;
238 $BSULayer2_ypos = 89.49*$inch;
239 @BSULayer2_zpos = ( -0.56, -7.31, -18.84, -25.59,
240 -32.34, -39.09, -45.84, -52.59, -59.34 );
241 for($i = 0; $i < 9; ++$i){
242 $BSULayer2_zpos[$i] *= -$inch;
243 $BSULayer2_zpos[$i] -= $AuxDetBSUScintWidth/2;
245 ############################
246 ############################
247 @BSULayer3_xpos = ( 16.21, 9.46, 2.71, -4.04,
248 -10.79, -17.54, -24.29, -31.04,
249 -37.79, -44.54, -51.29, -58.04,
250 -64.79, -71.54, -78.29, -85.04 );
251 for($i = 0; $i < 16; ++$i){
252 $BSULayer3_xpos[$i] *= -$inch;
253 $BSULayer3_xpos[$i] -= $AuxDetBSUScintWidth/2;
255 $BSULayer3_ypos = 306.55*$inch;
256 $BSULayer3_zpos = -1.21*$inch;
257 $BSULayer3_zpos = -1*$BSULayer3_zpos + $AuxDetBSUScintLength/2;
258 ############################
259 ############################
260 $BSULayer4_xpos = -67.24*$inch;
261 $BSULayer4_xpos = -1*$BSULayer4_xpos - $AuxDetBSUScintLength/2;
262 $BSULayer4_ypos = 310.80*$inch;
263 @BSULayer4_zpos = ( 1.42, -5.34, -12.09, -18.84,
264 -25.59, -32.34, -39.09, -45.84,
266 for($i = 0; $i < 10; ++$i){
267 $BSULayer4_zpos[$i] *= -$inch;
268 $BSULayer4_zpos[$i] -= $AuxDetBSUScintWidth/2;
270 ############################
271 ## Layer 5 is not included in the final gdml
272 ############################
273 @BSULayer5_xpos = ( 16.21, 9.46, 2.71, -4.04,
274 -10.79, -17.54, -24.29, -31.04,
275 -37.79, -44.54, -51.29, -58.04,
276 -64.79, -71.54, -78.29, -85.04 );
277 for($i = 0; $i < 16; ++$i){
278 $BSULayer5_xpos[$i] *= -$inch;
279 $BSULayer5_xpos[$i] -= $AuxDetBSUScintWidth/2;
281 $BSULayer5_ypos = 314.55*$inch;
282 $BSULayer5_zpos = -1.21*$inch;
283 $BSULayer5_zpos = -1*$BSULayer5_zpos + $AuxDetBSUScintLength/2;
287 ############################################################
288 ############### Optical Detector parameters ################
290 # TODO: while the structure is exactly what we need, the parameters for
291 # paddle height and positioning are all placeholders
293 $nPaddlesInAPA[0] = 3;
294 $nPaddlesInAPA[1] = 1;
295 $nPaddlesInAPA[2] = 1;
296 $nPaddlesInAPA[3] = $nPaddlesInAPA[0]; # for now, this one is the same as 0
299 $LightPaddle_x = 0.476;
300 $LightPaddle_y = 56; # in cm from docDb 7803
301 $LightPaddle_z = 4*$inch;
303 # z and x are given by APA frame center.
304 # Hardcode y distance of each paddle from the
305 # bottom of the APA to the paddle y-center.
306 # To be used in make_APA like [apa#][paddle#]
308 $PaddleYPositions[0][0] = $APAFrame_y[0]/2; # this puts it in the y center
309 $PaddleYPositions[1][0] = $APAFrame_y[1] - 4*$inch - $LightPaddle_y/2;
310 $PaddleYPositions[2][0] = $APAFrame_y[2] - 4*$inch - $LightPaddle_y/2;
311 $PaddleYPositions[3][0] = $PaddleYPositions[0][0];
313 $PaddleYPositions[0][1] = $APAFrame_y[0] - 4*$inch - $LightPaddle_y/2;
314 $PaddleYPositions[3][1] = $PaddleYPositions[0][1];
316 $PaddleYPositions[0][2] = 4*$inch + $LightPaddle_y/2;
317 $PaddleYPositions[3][2] = $PaddleYPositions[0][2];
321 ##################################################################
322 ###################### Cryostat parameters #######################
325 $HeightGaseousAr = 14;
326 $FloorToSmallAPAFrame = 22.432;
327 $APAToTopCryo = 34.441;
328 $ClosestAPAToEastWall = 33.225; # To G10 cover, places all of the APAs in z
331 # Drift __________ Drift
334 # South | | | North Wall
339 $CPAToFloor = 26.955;
340 $CPAToCeiling = 36.010;
341 $CPAToEastWall = 27.994;
342 $CPAToWestWall = 76.234;
343 $CPAToSouthWall = 121.945;
344 $CPAToNorthWall = 22.907;
352 $CPATubeYSide_CenterToCenter = 166.269; # length in *z* direction
353 $CPATubeZSide_CenterToCenter = 207.532; # height in *y* direction
356 $Cathode_y = $CPATubeZSide_CenterToCenter - $CPATube_OD;
357 $Cathode_z = $CPATubeYSide_CenterToCenter - $CPATube_OD;
359 # Liquid and Gaseous Argon dimensions
360 $Argon_x = $TPCShortDrift_x
364 + $CPAToSouthWall + $CPATube_OD;
365 # note that the height y includes liquid and gaseous argon
366 $Argon_y = $APAphys_y[1]
370 + $FloorToSmallAPAFrame; # assuming mid_y+smallest_y > largest_y
372 $Argon_z = $CPATubeYSide_CenterToCenter
377 # try hardcoding parameters now that placements/dimensions are more accurate
378 # inside cryostat parameters
385 # Cryostat Dimensions
386 $SteelShellThickness = 0.5*$inch;
388 $Cryostat_x = $Argon_x; # move the steel shell out of volCryostat
389 $Cryostat_y = $Argon_y;
390 $Cryostat_z = $Argon_z;
394 ##################################################################
395 ################# Detector Enclosure parameters ##################
398 # Around the cryostat
399 $ConcretePadding = 30;
400 $FoamPadding = 39.75148;
401 $TotalPadding = $ConcretePadding + $FoamPadding;
402 $CryoWithPadding_x = $Argon_x + 2*$SteelShellThickness + 2*$TotalPadding;
403 $CryoWithPadding_y_noneck = $Argon_y + 2*$SteelShellThickness + 2*$FoamPadding + $ConcretePadding;
404 $CryoWithPadding_y_neck = ($Argon_y + $NeckInside_y) + 2*$SteelShellThickness + $TotalPadding;
405 $CryoWithPadding_z = $Argon_z + 2*$SteelShellThickness + 2*$TotalPadding;
407 print "CryoWithPadding: x=$CryoWithPadding_x, y=$CryoWithPadding_y_noneck ($CryoWithPadding_y_neck), z=$CryoWithPadding_z\n";
408 print "Cryo: x=$Argon_x, y=$Argon_y (+$NeckInside_y), z=$Argon_z\n";
411 # The actual enclosure
412 $TrenchLength = 9*$CryoWithPadding_x; # make this a reasonable length, still guessing
413 # quick measurments by Michelle Stancari, definitely good enough for now
414 $TrenchWallThickness = 14*$inch;
415 $WalkwayWidth = 34.5*$inch;
416 $EastWallToTrench = 10*$inch;
417 $PlateAToGroundLevel = 50*$inch;
420 # Bird's eye view of trench, walkway is on the west side
427 # | W|______||E +z <---| (+y out of screen)
435 # the container volume dimensions
436 $DetEnc_x = $TrenchLength;
437 $DetEnc_y = $TrenchWallThickness # use this for thickness of floor too
438 + $CryoWithPadding_y_noneck
439 + $PlateAToGroundLevel; # Make ground level the top of the DetEnc
440 $DetEnc_z = $CryoWithPadding_z
441 + $WalkwayWidth + $EastWallToTrench
442 + 2*$TrenchWallThickness;
445 $posCryoInDetEnc_x = 0;
446 $posCryoInDetEnc_y = - $DetEnc_y/2 + $TrenchWallThickness + $TotalPadding + $SteelShellThickness + $Argon_y/2;
447 $posCryoInDetEnc_z = - $DetEnc_z/2 + $TrenchWallThickness + $EastWallToTrench + $CryoWithPadding_z/2;
453 if (defined $helpcube)
455 $PosDirCubeSide = $ArToAr; #seems to be a good proportion
459 # The world dimensions are critical in the CRY cosmics generator
460 # following uboone's lead, make world much larger
461 # the cry helper needs a lot of room
464 $World_x = 5*$DetEnc_x;
465 $World_y = 25*$DetEnc_y;
466 $World_z = 25*$DetEnc_z;
468 $BermRadius = 5*12*$inch;
474 ##################################################################
475 ######################### TPC positions ##########################
478 $APA_Xcenter = $Argon_x/2
479 - $CPAToSouthWall # to center CPATube
484 # 0: One of the 2 identical tall APAs (Largest), call it the "upstream" one
485 $APACenter[0][0] = $APA_Xcenter;
486 $APACenter[0][1] = $Argon_y/2
487 - $APAToTopCryo # This subsumes the half vertical gap on the top...
488 - $APAphys_y[0]/2; # ... so use APAphys_y instead of TPC_y
489 $APACenter[0][2] = - $Argon_z/2
490 + $ClosestAPAToEastWall # ..Similarly, this already steps into the APAGap_z/2
494 # 1: The top middle APA (Mid)
495 $APACenter[1][0] = $APA_Xcenter;
496 $APACenter[1][1] = $Argon_y/2
499 $APACenter[1][2] = $APACenter[0][2]
500 + $APAphys_z + $APAGap_z;
502 # 2: The bottom middle APA (Smallest)
503 $APACenter[2][0] = $APA_Xcenter;
504 $APACenter[2][1] = $APACenter[1][1] # place relative to APA above it
508 $APACenter[2][2] = $APACenter[0][2]
509 + $APAphys_z + $APAGap_z;
511 # 3: The other tall APA, call it the "downstream" one
512 $APACenter[3][0] = $APACenter[0][0];
513 $APACenter[3][1] = $APACenter[0][1];
514 $APACenter[3][2] = $APACenter[1][2]
515 + $APAphys_z + $APAGap_z;
517 $posTPCShortDrift_x = $APACenter[0][0]
519 - $TPCShortDrift_x/2;
521 $posTPCLongDrift_x = $APACenter[0][0]
526 # see the define section
529 $OuterWireToCage = 2.33; # email from Russ
531 $TPCActive_z[0] = $APAphys_z
532 - ($APAphys_z-$Zactive_z)/2
535 $TPCActive_z[1] = $APAphys_z + $APAGap_z;
536 $TPCActive_z[2] = $APAphys_z + $APAGap_z;
537 $TPCActive_z[3] = $TPCActive_z[0];
539 $TPCCenter[0][2] = $APACenter[0][2]
543 $TPCCenter[1][2] = $APACenter[1][2];
544 $TPCCenter[2][2] = $APACenter[2][2];
545 $TPCCenter[3][2] = $APACenter[3][2]
553 # We want the world origin to be at the very front of the fiducial volume.
554 # move it to the front of the enclosure, then back it up through the concrete/foam,
555 # then through the Cryostat shell, then through the upstream dead LAr (including the
556 # dead LAr on the edge of the TPC, but this is covered in $UpstreamLArPadding).
557 # This is to be added to the z position of every volume in volWorld
561 + $TrenchWallThickness
564 + $SteelShellThickness
565 + $Argon_z/2 # at this point, we are at the center of the cryostat...
566 - $APACenter[0][2] # ... and now at the center of the East-most APA
569 # We want the world origin to be vertically centered between the two stacked APAs.
570 # (for now, that is, so the sorting works. this is quite asymetric, but then again
571 # so is the entire 35t geometry. this may be kept.)
572 # the cryostat sits on top of concrete padding, move the detector enclosure back
573 # and then move the world origin to the bottom of the smallest/lowest TPC, then
574 # and then up through the TPC, then back up to being centered between the stacked APAs.
575 # This is to be added to the y/x position of every volume in volWorld
579 - $TrenchWallThickness
581 - $SteelShellThickness
590 #$OriginXSet = $DetEnc_x/2
592 # - $SteelShellThickness
595 # - $ShortDrift ... through APA frame
598 - $CryoWithPadding_x/2
600 + $SteelShellThickness
601 + $Argon_x/2 # at this point, we are at the center of the cryostat...
602 - $APA_Xcenter # ... and now at the APA's center x coordinate
604 - 3*$APAWirePlaneSpacing
605 - $TPCWirePlaneThickness;
610 ## Correct Telescope Aux Det vertical position if necessary
612 if( $posCryoInDetEnc_y
614 + $SteelShellThickness
616 + $AuxDetBSUScintHeight/2 > $BSULayer1_ypos - $OriginYSet ){
618 $nudge_y = ( $posCryoInDetEnc_y
620 + $SteelShellThickness
622 + $AuxDetBSUScintHeight/2
623 + $OriginYSet ) - $BSULayer1_ypos;
625 print "--- NOTE: nudging telescope counters $nudge_y cm up to sit on top of GDML cryostat\n";
627 $BSULayer1_ypos += $nudge_y;
628 $BSULayer2_ypos += $nudge_y;
629 $BSULayer3_ypos += $nudge_y;
630 $BSULayer4_ypos += $nudge_y;
631 $BSULayer5_ypos += $nudge_y;
637 ##################################################################
638 ######################### CPA positions ##########################
641 # Drift __________ Drift
644 # South | | | North Wall
649 #$posCPAShortDrift_x = - $Argon_x/2 + $CPAToNorthWall + $CPATube_OD/2;
650 #$posCPALongDrift_x = $Argon_x/2 - $CPAToSouthWall - $CPATube_OD/2;
652 # ^^^ these would be ideal, but quick fix to check in
653 # v3 without overlaps:
655 #$posCPAShortDrift_x = - $Argon_x/2 + $CPAToNorthWall + $CPATube_OD/2;
656 #$posCPALongDrift_x = $Argon_x/2 - $CPAToSouthWall - $CPATube_OD/2;
657 $posCPAShortDrift_x = $posTPCShortDrift_x - $TPCShortDrift_x/2
658 - $CPATube_OD; #<-- temp overlap fix
659 $posCPALongDrift_x = $posTPCLongDrift_x + $TPCLongDrift_x/2
660 + $CPATube_OD; #<-- temp overlap fix
663 $posCPAShortDrift_y = - $Argon_y/2 + $CPAToFloor
664 + ($CPATubeZSide_CenterToCenter + $CPATube_OD)/2;
665 $posCPAShortDrift_z = - $Argon_z/2 + $CPAToEastWall
666 + ($CPATubeYSide_CenterToCenter + $CPATube_OD)/2;
668 $posCPALongDrift_y = $posCPAShortDrift_y;
669 $posCPALongDrift_z = $posCPAShortDrift_z;
675 ##################################################################
676 #################### Bar Fiber Module numbers ####################
677 $numberofbarmodules=4;
678 $numberoffibermodules=3;
679 $numberofplankmodules=1;
681 $PaddleCenterX=$APA_Xcenter;
682 $PaddleCenterY[0][0]=$APACenter[0][1]-$APAFrame_y[0]/2+ $PaddleYPositions[0][0];
683 $PaddleCenterY[0][1]=$APACenter[0][1]-$APAFrame_y[0]/2+ $PaddleYPositions[0][1];
684 $PaddleCenterY[0][2]=$APACenter[0][1]-$APAFrame_y[0]/2+ $PaddleYPositions[0][2];
685 $PaddleCenterY[1][0]=$APACenter[1][1]-$APAFrame_y[1]/2+ $PaddleYPositions[1][0];
686 $PaddleCenterY[2][0]=$APACenter[2][1]-$APAFrame_y[2]/2+ $PaddleYPositions[2][0];
687 $PaddleCenterY[3][0]=$PaddleCenterY[0][0];
688 $PaddleCenterY[3][1]=$PaddleCenterY[0][1];
689 $PaddleCenterY[3][2]=$PaddleCenterY[0][2];
690 $PaddleCenterZ[0]=$APACenter[0][2];
691 $PaddleCenterZ[1]=$APACenter[1][2];
692 $PaddleCenterZ[2]=$APACenter[2][2];
693 $PaddleCenterZ[3]=$APACenter[3][2];
696 #+++++++++++++++++++++++++ End defining variables ++++++++++++++++++++++++++
700 # run the sub routines that generate the fragments
702 gen_Define(); # generates definitions at beginning of GDML
703 gen_Materials(); # generates materials to be used
706 # gen_TPC( x dimension, y, z, string appended to TPC for name, APA number)
707 # generate the short drift and long drift sides of the APA as seperate TPCs
709 open(my $wout, '>', 'gdmlWireCenters.txt');
711 gen_TPC( $TPCLongDrift_x, $TPC_y[0], $TPCActive_z[0], 'LargestLongDriftUpstream', 0);
712 gen_TPC( $TPCShortDrift_x, $TPC_y[0], $TPCActive_z[0], 'LargestShortDriftUpstream', 0);
714 gen_TPC( $TPCLongDrift_x, $TPC_y[2], $TPCActive_z[2], 'SmallestLongDrift', 2);
715 gen_TPC( $TPCShortDrift_x, $TPC_y[2], $TPCActive_z[2], 'SmallestShortDrift', 2);
717 gen_TPC( $TPCLongDrift_x, $TPC_y[1], $TPCActive_z[1], 'MidLongDrift', 1);
718 gen_TPC( $TPCShortDrift_x, $TPC_y[1], $TPCActive_z[1], 'MidShortDrift', 1);
720 gen_TPC( $TPCLongDrift_x, $TPC_y[0], $TPCActive_z[3], 'LargestLongDriftDownstream', 3);
721 gen_TPC( $TPCShortDrift_x, $TPC_y[0], $TPCActive_z[3], 'LargestShortDriftDownstream', 3);
730 write_fragments(); # writes the XML input for make_gdml.pl
731 # which zips together the final GDML
735 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
736 #+++++++++++++++++++++++++++++++++++++++++ usage +++++++++++++++++++++++++++++++++++++++++
737 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
741 print "Usage: $0 [-h|--help] [-o|--output <fragments-file>] [-s|--suffix <string>]\n";
742 print " if -o is omitted, output goes to STDOUT; <fragments-file> is input to make_gdml.pl\n";
743 print " -s <string> appends the string to the file names; useful for multiple detector versions\n";
744 print " -h prints this message, then quits\n";
749 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
750 #++++++++++++++++++++++++++++++++++++++ gen_Define +++++++++++++++++++++++++++++++++++++++
751 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
756 # Create the <define> fragment file name,
757 # add file to list of fragments,
759 $DEF = "dune_10kT_Def" . $suffix . ".gdml";
760 push (@gdmlFiles, $DEF);
762 open(DEF) or die("Could not open file $DEF for writing");
766 <?xml version='1.0'?>
776 <position name="posOriginSet" unit="cm" x="$OriginXSet" y="$OriginYSet" z="$OriginZSet"/>
778 <position name="posTPCLargestShortDrift_Pos" unit="cm" x="$posTPCShortDrift_x" y="$APACenter[3][1]" z="$TPCCenter[3][2]"/>
779 <position name="posTPCLargestLongDrift_Pos" unit="cm" x="$posTPCLongDrift_x" y="$APACenter[3][1]" z="$TPCCenter[3][2]"/>
780 <position name="posTPCLargestShortDrift_Neg" unit="cm" x="$posTPCShortDrift_x" y="$APACenter[0][1]" z="$TPCCenter[0][2]"/>
781 <position name="posTPCLargestLongDrift_Neg" unit="cm" x="$posTPCLongDrift_x" y="$APACenter[0][1]" z="$TPCCenter[0][2]"/>
782 <position name="posTPCSmallestShortDrift" unit="cm" x="$posTPCShortDrift_x" y="$APACenter[2][1]" z="$TPCCenter[2][2]"/>
783 <position name="posTPCSmallestLongDrift" unit="cm" x="$posTPCLongDrift_x" y="$APACenter[2][1]" z="$TPCCenter[2][2]"/>
784 <position name="posTPCMidShortDrift" unit="cm" x="$posTPCShortDrift_x" y="$APACenter[1][1]" z="$TPCCenter[1][2]"/>
785 <position name="posTPCMidLongDrift" unit="cm" x="$posTPCLongDrift_x" y="$APACenter[1][1]" z="$TPCCenter[1][2]"/>
788 <position name="posCathodeLongDrift" unit="cm" x="$posCPAShortDrift_x" y="$posCPAShortDrift_y" z="$posCPAShortDrift_z"/>
789 <position name="posCathodeShortDrift" unit="cm" x="$posCPALongDrift_x" y="$posCPALongDrift_y" z="$posCPALongDrift_z"/>
791 <rotation name="rAuxDetNSWallUp" unit="deg" x="90" y="0" z="90"/>
792 <rotation name="rAuxDetNSWallDown" unit="deg" x="270" y="0" z="90"/>
793 <rotation name="rAuxDetEWWallUp" unit="deg" x="90" y="0" z="0"/>
794 <rotation name="rAuxDetEWWallDown" unit="deg" x="270" y="0" z="0"/>
796 <position name="posCenter" unit="cm" x="0" y="0" z="0"/>
797 <rotation name="rPlus90AboutX" unit="deg" x="90" y="0" z="0"/>
798 <rotation name="rPlus90AboutY" unit="deg" x="0" y="90" z="0"/>
799 <rotation name="rMinus90AboutY" unit="deg" x="0" y="270" z="0"/>
800 <rotation name="rMinus90AboutYMinus90AboutX" unit="deg" x="270" y="270" z="0"/>
801 <rotation name="rPlus180AboutY" unit="deg" x="0" y="180" z="0"/>
802 <rotation name="rPlus180AboutX" unit="deg" x="180" y="0" z="0"/>
803 <rotation name="rPlus180AboutXandY" unit="deg" x="180" y="180" z="0"/>
804 <rotation name="rIdentity" unit="deg" x="0" y="0" z="0"/>
807 ##################################################################
808 ###################### Bar Module Position #######################
809 for ($k=1; $k<$numberofbarmodules+1; ++$k)
811 if($k==1) {$APA_i=1;$p=0;$PD_zoffset=0;}
812 elsif($k==2) {$APA_i=0;$p=1;$PD_zoffset=0;}
813 elsif($k==3) {$APA_i=0;$p=2;$PD_zoffset=-0.00051;}
814 elsif($k==4) {$APA_i=3;$p=0;$PD_zoffset=0;}
816 #for ($j=1; $j<$numberofbars+1; ++$j)
818 #$bar_z=-4.11 + 2.74*($j-1)+$PaddleCenterZ[$APA_i];
819 $bar_z=$PaddleCenterZ[$APA_i]+2.794*1.5+$PD_zoffset;
820 $bar_name="Bar" . $k . "Pos";
822 <position name="$bar_name" x="$PaddleCenterX" y="$PaddleCenterY[$APA_i][$p]" z="$bar_z" unit="cm"/>
827 ##################################################################
828 ##################### Plank Module Position ######################
829 for ($k=1; $k<$numberofplankmodules+1; ++$k)
831 if($k==1) {$APA_i=3;$p=2;}
833 $plank_name="PlankPos";
835 <position name="$plank_name" x="$PaddleCenterX" y="$PaddleCenterY[$APA_i][$p]" z="$PaddleCenterZ[$APA_i]" unit="cm"/>
839 ##################################################################
840 ##################### Fiber Module Position ######################
842 for ($k=1; $k<$numberoffibermodules+1; ++$k)
844 if($k==1) {$APA_i=2;$p=0;$PD_zoffset=0;}
845 elsif($k==2) {$APA_i=0;$p=0;$PD_zoffset=0;}
846 elsif($k==3) {$APA_i=3;$p=1;$PD_zoffset=0.00051;}
848 $fiber_x=$PaddleCenterX+0.1445;
849 $fiber_y=$PaddleCenterY[$APA_i][$p];
850 $fiber_z=$PaddleCenterZ[$APA_i]+4.1905+$PD_zoffset;
852 $fiber_name="Fiber" . $k. "Pos";
854 <position name="$fiber_name" x="$fiber_x" y="$fiber_y" z="$fiber_z" unit="cm"/>
869 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
870 #+++++++++++++++++++++++++++++++++++++ gen_Materials +++++++++++++++++++++++++++++++++++++
871 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
876 # Create the <materials> fragment file name,
877 # add file to list of output GDML fragments,
879 $MAT = "dune_10kT_Materials" . $suffix . ".gdml";
880 push (@gdmlFiles, $MAT);
882 open(MAT) or die("Could not open file $MAT for writing");
887 <element name="videRef" formula="VACUUM" Z="1"> <atom value="1"/> </element>
888 <element name="hydrogen" formula="H" Z="1"> <atom value="1.0079"/> </element>
889 <element name="beryllium" formula="Be" Z="4"> <atom value="9.0121831"/> </element>
890 <element name="carbon" formula="C" Z="6"> <atom value="12.0107"/> </element>
891 <element name="nitrogen" formula="N" Z="7"> <atom value="14.0067"/> </element>
892 <element name="oxygen" formula="O" Z="8"> <atom value="15.999"/> </element>
893 <element name="sodium" formula="Na" Z="11"> <atom value="22.99"/> </element>
894 <element name="magnesium" formula="Mg" Z="12"> <atom value="24.305"/> </element>
895 <element name="aluminum" formula="Al" Z="13"> <atom value="26.9815"/> </element>
896 <element name="silicon" formula="Si" Z="14"> <atom value="28.0855"/> </element>
897 <element name="phosphorus" formula="P" Z="15"> <atom value="30.973"/> </element>
898 <element name="sulphur" formula="S" Z="16"> <atom value="32.065"/> </element>
899 <element name="argon" formula="Ar" Z="18"> <atom value="39.9480"/> </element>
900 <element name="potassium" formula="K" Z="19"> <atom value="39.0983"/> </element>
901 <element name="calcium" formula="Ca" Z="20"> <atom value="40.078"/> </element>
902 <element name="titanium" formula="Ti" Z="22"> <atom value="47.867"/> </element>
903 <element name="chromium" formula="Cr" Z="24"> <atom value="51.9961"/> </element>
904 <element name="iron" formula="Fe" Z="26"> <atom value="55.8450"/> </element>
905 <element name="nickel" formula="Ni" Z="28"> <atom value="58.6934"/> </element>
906 <element name="copper" formula="Cu" Z="29"> <atom value="63.546"/> </element>
907 <element name="bromine" formula="Br" Z="35"> <atom value="79.904"/> </element>
909 <material name="Vacuum" formula="Vacuum">
910 <D value="1.e-25" unit="g/cm3"/>
911 <fraction n="1.0" ref="videRef"/>
914 <material name="ALUMINUM_Al" formula="ALUMINUM_Al">
915 <D value="2.6990" unit="g/cm3"/>
916 <fraction n="1.0000" ref="aluminum"/>
919 <material name="SILICON_Si" formula="SILICON_Si">
920 <D value="2.3300" unit="g/cm3"/>
921 <fraction n="1.0000" ref="silicon"/>
924 <material name="epoxy_resin" formula="C38H40O6Br4">
925 <D value="1.1250" unit="g/cm3"/>
926 <composite n="38" ref="carbon"/>
927 <composite n="40" ref="hydrogen"/>
928 <composite n="6" ref="oxygen"/>
929 <composite n="4" ref="bromine"/>
932 <material name="SiO2" formula="SiO2">
933 <D value="2.2" unit="g/cm3"/>
934 <composite n="1" ref="silicon"/>
935 <composite n="2" ref="oxygen"/>
938 <material name="Al2O3" formula="Al2O3">
939 <D value="3.97" unit="g/cm3"/>
940 <composite n="2" ref="aluminum"/>
941 <composite n="3" ref="oxygen"/>
944 <material name="Polystyrene" formula="C8H8">
945 <D value="1.05" unit="g/cm3"/>
946 <composite n="8" ref="carbon"/>
947 <composite n="8" ref="hydrogen"/>
950 <material name="Fe2O3" formula="Fe2O3">
951 <D value="5.24" unit="g/cm3"/>
952 <composite n="2" ref="iron"/>
953 <composite n="3" ref="oxygen"/>
956 <material name="CaO" formula="CaO">
957 <D value="3.35" unit="g/cm3"/>
958 <composite n="1" ref="calcium"/>
959 <composite n="1" ref="oxygen"/>
962 <material name="MgO" formula="MgO">
963 <D value="3.58" unit="g/cm3"/>
964 <composite n="1" ref="magnesium"/>
965 <composite n="1" ref="oxygen"/>
968 <material name="Na2O" formula="Na2O">
969 <D value="2.27" unit="g/cm3"/>
970 <composite n="2" ref="sodium"/>
971 <composite n="1" ref="oxygen"/>
974 <material name="TiO2" formula="TiO2">
975 <D value="4.23" unit="g/cm3"/>
976 <composite n="1" ref="titanium"/>
977 <composite n="2" ref="oxygen"/>
980 <material name="FeO" formula="FeO">
981 <D value="5.745" unit="g/cm3"/>
982 <composite n="1" ref="iron"/>
983 <composite n="1" ref="oxygen"/>
986 <material name="CO2" formula="CO2">
987 <D value="1.562" unit="g/cm3"/>
988 <composite n="1" ref="carbon"/>
989 <composite n="2" ref="oxygen"/>
992 <material name="P2O5" formula="P2O5">
993 <D value="1.562" unit="g/cm3"/>
994 <composite n="2" ref="phosphorus"/>
995 <composite n="5" ref="oxygen"/>
998 <material formula=" " name="DUSEL_Rock">
999 <D value="2.82" unit="g/cm3"/>
1000 <fraction n="0.5267" ref="SiO2"/>
1001 <fraction n="0.1174" ref="FeO"/>
1002 <fraction n="0.1025" ref="Al2O3"/>
1003 <fraction n="0.0473" ref="MgO"/>
1004 <fraction n="0.0422" ref="CO2"/>
1005 <fraction n="0.0382" ref="CaO"/>
1006 <fraction n="0.0240" ref="carbon"/>
1007 <fraction n="0.0186" ref="sulphur"/>
1008 <fraction n="0.0053" ref="Na2O"/>
1009 <fraction n="0.00070" ref="P2O5"/>
1010 <fraction n="0.0771" ref="oxygen"/>
1013 <material name="fibrous_glass">
1014 <D value="2.58" 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 <!-- The following fractional components are placeholders,
1025 to be fixed (though they have very little effect,
1026 as long as the density is correct) -->
1027 <material name="polyurethane_foam">
1028 <D value=".13" unit="g/cm3"/>
1029 <fraction n="0.600" ref="SiO2"/>
1030 <fraction n="0.118" ref="Al2O3"/>
1031 <fraction n="0.001" ref="Fe2O3"/>
1032 <fraction n="0.224" ref="CaO"/>
1033 <fraction n="0.034" ref="MgO"/>
1034 <fraction n="0.010" ref="Na2O"/>
1035 <fraction n="0.013" ref="TiO2"/>
1038 <!-- for the cryostat foam insulation -->
1039 <material name="R-PUF">
1040 <D value=".2525" unit="g/cm3"/>
1041 <fraction n="0.95" ref="polyurethane_foam"/>
1042 <fraction n="0.05" ref="fibrous_glass"/>
1045 <material name="FR4">
1046 <D value="1.98281" unit="g/cm3"/>
1047 <fraction n="0.47" ref="epoxy_resin"/>
1048 <fraction n="0.53" ref="fibrous_glass"/>
1051 <material name="STEEL_STAINLESS_Fe7Cr2Ni" formula="STEEL_STAINLESS_Fe7Cr2Ni">
1052 <D value="7.9300" unit="g/cm3"/>
1053 <fraction n="0.0010" ref="carbon"/>
1054 <fraction n="0.1792" ref="chromium"/>
1055 <fraction n="0.7298" ref="iron"/>
1056 <fraction n="0.0900" ref="nickel"/>
1059 <material name="Copper_Beryllium_alloy25" formula="Copper_Beryllium_alloy25">
1060 <D value="8.26" unit="g/cm3"/>
1061 <fraction n="0.981" ref="copper"/>
1062 <fraction n="0.019" ref="beryllium"/>
1065 <material name="LAr" formula="LAr">
1066 <D value="1.40" unit="g/cm3"/>
1067 <fraction n="1.0000" ref="argon"/>
1070 <material name="ArGas" formula="ArGas">
1071 <D value="0.00166" unit="g/cm3"/>
1072 <fraction n="1.0" ref="argon"/>
1075 <material formula=" " name="Air">
1076 <D value="0.001205" unit="g/cm3"/>
1077 <fraction n="0.781154" ref="nitrogen"/>
1078 <fraction n="0.209476" ref="oxygen"/>
1079 <fraction n="0.00934" ref="argon"/>
1082 <material formula=" " name="G10">
1083 <D value="1.7" unit="g/cm3"/>
1084 <fraction n="0.2805" ref="silicon"/>
1085 <fraction n="0.3954" ref="oxygen"/>
1086 <fraction n="0.2990" ref="carbon"/>
1087 <fraction n="0.0251" ref="hydrogen"/>
1090 <material formula=" " name="Granite">
1091 <D value="2.7" unit="g/cm3"/>
1092 <fraction n="0.438" ref="oxygen"/>
1093 <fraction n="0.257" ref="silicon"/>
1094 <fraction n="0.222" ref="sodium"/>
1095 <fraction n="0.049" ref="aluminum"/>
1096 <fraction n="0.019" ref="iron"/>
1097 <fraction n="0.015" ref="potassium"/>
1100 <material formula=" " name="ShotRock">
1101 <D value="2.7*0.6" unit="g/cm3"/>
1102 <fraction n="0.438" ref="oxygen"/>
1103 <fraction n="0.257" ref="silicon"/>
1104 <fraction n="0.222" ref="sodium"/>
1105 <fraction n="0.049" ref="aluminum"/>
1106 <fraction n="0.019" ref="iron"/>
1107 <fraction n="0.015" ref="potassium"/>
1110 <material formula=" " name="Dirt">
1111 <D value="1.7" unit="g/cm3"/>
1112 <fraction n="0.438" ref="oxygen"/>
1113 <fraction n="0.257" ref="silicon"/>
1114 <fraction n="0.222" ref="sodium"/>
1115 <fraction n="0.049" ref="aluminum"/>
1116 <fraction n="0.019" ref="iron"/>
1117 <fraction n="0.015" ref="potassium"/>
1120 <material formula=" " name="Concrete">
1121 <D value="2.3" unit="g/cm3"/>
1122 <fraction n="0.530" ref="oxygen"/>
1123 <fraction n="0.335" ref="silicon"/>
1124 <fraction n="0.060" ref="calcium"/>
1125 <fraction n="0.015" ref="sodium"/>
1126 <fraction n="0.020" ref="iron"/>
1127 <fraction n="0.040" ref="aluminum"/>
1130 <material formula="H2O" name="Water">
1131 <D value="1.0" unit="g/cm3"/>
1132 <fraction n="0.1119" ref="hydrogen"/>
1133 <fraction n="0.8881" ref="oxygen"/>
1136 <material formula="Ti" name="Titanium">
1137 <D value="4.506" unit="g/cm3"/>
1138 <fraction n="1." ref="titanium"/>
1141 <material name="TPB" formula="TPB">
1142 <D value="1.40" unit="g/cm3"/>
1143 <fraction n="1.0000" ref="argon"/>
1146 <material name="Glass">
1147 <D value="2.74351" unit="g/cm3"/>
1148 <fraction n="0.600" ref="SiO2"/>
1149 <fraction n="0.118" ref="Al2O3"/>
1150 <fraction n="0.001" ref="Fe2O3"/>
1151 <fraction n="0.224" ref="CaO"/>
1152 <fraction n="0.034" ref="MgO"/>
1153 <fraction n="0.010" ref="Na2O"/>
1154 <fraction n="0.013" ref="TiO2"/>
1157 <material name="Acrylic">
1158 <D value="1.19" unit="g/cm3"/>
1159 <fraction n="0.600" ref="carbon"/>
1160 <fraction n="0.320" ref="oxygen"/>
1161 <fraction n="0.080" ref="hydrogen"/>
1164 <material name="Plastic" formula="Plastic">
1165 <D value="1.032" unit="g/cm3"/>
1166 <fraction n=".474" ref="carbon"/>
1167 <fraction n=".526" ref="hydrogen"/>
1179 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1180 #++++++++++++++++++++++++++++++++++++++++ gen_TPC ++++++++++++++++++++++++++++++++++++++++
1181 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1191 # $_[4] = APA number
1195 my $TPCActive_x = $_[0]-(3*$APAWirePlaneSpacing);
1196 my $TPCActive_y = $_[1] - $APAGap_y/2 - $ReadoutBoardOverlap ; #TODO: make the Active height more accurate
1197 #print " APA $apa TPCActive xyz dimensions = ($TPCActive_x, $TPCActive_y, $TPCActive_z[$apa])\n";
1200 my $UAngle = $UAng[$apa];
1201 my $VAngle = $VAng[$apa];
1203 my $SinUAngle = sin( deg2rad($UAngle) );
1204 my $CosUAngle = cos( deg2rad($UAngle) );
1205 my $TanUAngle = tan( deg2rad($UAngle) );
1207 my $SinVAngle = sin( deg2rad($VAngle) );
1208 my $CosVAngle = cos( deg2rad($VAngle) );
1209 my $TanVAngle = tan( deg2rad($VAngle) );
1211 my $UWire_yint = $UWirePitch/$SinUAngle;
1212 my $UWire_zint = $UVReadoutBoardPitch ;
1214 my $VWire_yint = $VWirePitch/$SinVAngle;
1215 my $VWire_zint = $UVReadoutBoardPitch ;
1217 #constructs everything inside volTPC, namely
1218 # (moving from left to right, or from +x to -x)
1220 # -volTPCPlaneU: with wires angled from vertical slightly different than in V
1221 # -volTPCPlaneV: with wires angled from vertical slightly differently than in U
1222 # -volTPCPlaneX: with vertical wires
1225 # Create the TPC fragment file name,
1226 # add file to list of output GDML fragments,
1228 $TPC = "35t_TPC_${_[3]}" . $suffix . ".gdml";
1229 push (@gdmlFiles, $TPC);
1231 open(TPC) or die("Could not open file $TPC for writing");
1234 print $wout "\n\n\n----- Wires for $_[3] -----\n\n\n";
1237 # The standard XML prefix and starting the gdml
1239 <?xml version='1.0'?>
1244 # All the TPC solids save the wires.
1247 <box name="$_[3]" lunit="cm"
1251 <box name="${_[3]}UPlane" lunit="cm"
1252 x="$TPCWirePlaneThickness"
1253 y="$Uactive_y[$apa] + $UVPlaneBoundNudge"
1254 z="$Uactive_z + $UVPlaneBoundNudge"/>
1255 <box name="${_[3]}VPlane" lunit="cm"
1256 x="$TPCWirePlaneThickness"
1257 y="$Vactive_y[$apa] + $UVPlaneBoundNudge"
1258 z="$Vactive_z + $UVPlaneBoundNudge"/>
1259 <box name="${_[3]}ZPlane" lunit="cm"
1260 x="$TPCWirePlaneThickness"
1261 y="$Zactive_y[$apa]"
1263 <box name="${_[3]}Active" lunit="cm"
1266 z="$TPCActive_z[$apa]"/>
1270 #++++++++++++++++++++++++++++ Wire Solids ++++++++++++++++++++++++++++++
1274 <tube name="${_[3]}WireVert"
1275 rmax="0.5*$TPCWireThickness"
1276 z="$Zactive_y[$apa]"
1282 # Set number of wires to default to zero, when $wires_on = 0, for a low memory
1283 # version. But if $wires_on = 1, calculate the number of wires on each side of each
1284 # plane to be used in the for loops
1286 my $NumberCornerUWires = 0;
1287 my $NumberSideUWires = 0;
1288 my $NumberCommonUWires = 0;
1289 my $NumberCornerVWires = 0;
1290 my $NumberSideVWires = 0;
1291 my $NumberCommonVWires = 0;
1292 my $NumberVerticalWires = 0;
1296 # Number of wires in one corner
1297 #$NumberCornerUWires = int( $APAFrame_z/($UWirePitch/$CosUAngle) );
1298 $NumberCornerUWires = 72;
1300 #$NumberCornerVWires = int( $APAFrame_z/($VWirePitch/$CosVAngle) );
1301 $NumberCornerVWires = 72;
1303 # Total number of wires touching one vertical (longer) side
1304 # Note that the total number of wires per plane is this + another set of corner wires
1305 $NumberSideUWires = int( $Uactive_y[$apa]/($UWirePitch/$SinUAngle) );
1307 $NumberSideVWires = int( $Vactive_y[$apa]/($VWirePitch/$SinVAngle) );
1309 # Number of wires per side that aren't cut off by the corner
1310 $NumberCommonUWires = $NumberSideUWires - $NumberCornerUWires;
1312 $NumberCommonVWires = $NumberSideVWires - $NumberCornerVWires;
1314 # Number of wires on the vertical plane
1315 # Since APA Active z is defined in docdb 7550 to be distance
1316 # between outer vertical wires, + 1 since the floor of this
1317 # division will be one under, giveing the amt of spaces, not wires
1318 # $NumberVerticalWires = int( $Zactive_z/$XWirePitch ) + 1;
1319 $NumberVerticalWires = 112; # Zactive now defined in terms of 112,
1322 $nUchans = 2*$NumberCornerUWires;
1323 $nVchans = 2*$NumberCornerVWires;
1325 print $wout "$nUchans U channels\n";
1326 print $wout "$nVchans V channels\n";
1327 print $wout "$NumberVerticalWires Z channels per side\n";
1332 my $FirstUWireOffset = .35 + $G10thickness + 2*$G10thickness*$TanUAngle - $UVReadoutBoardPitch;
1333 my $FirstVWireOffset = .35; # doesnt include a G10 board in width
1335 my $FirstTopUWire_yspan =
1337 - ( - $Uactive_y[$apa]/2
1338 + $FirstUWireOffset/$TanUAngle # walk us up to the first wire
1339 + $UWire_yint*($NumberSideUWires-1) # up to the top of the top common wire
1340 - $Uactive_z/$TanUAngle # back to the bottom of the top common wire
1341 + $UWire_yint); # nudge up to bottom of the first top corner wire
1343 my $FirstTopVWire_yspan =
1345 - ( - $Vactive_y[$apa]/2
1346 + $FirstVWireOffset/$TanVAngle # walk us up to the first wire
1347 + $VWire_yint*($NumberSideVWires-1) # up to the top of the top common wire
1348 - $Vactive_z/$TanVAngle # back to the bottom of the top common wire
1349 + $VWire_yint); # nudge up to bottom of the first top corner wire
1351 # The corner wires for the U plane
1354 for ($i = 0; $i < $NumberCornerUWires; $i++)
1356 $CornerUWireLength[$i] = ($FirstUWireOffset + $i*$UVReadoutBoardPitch)/$SinUAngle;
1359 <tube name="${_[3]}WireU$i"
1360 rmax="0.5*$TPCWireThickness"
1361 z="$CornerUWireLength[$i]"
1369 $CommonUWireLength = $Uactive_z/$SinUAngle;
1372 <tube name="${_[3]}WireUCommon"
1373 rmax="0.5*$TPCWireThickness"
1374 z="$CommonUWireLength"
1380 for ($i = 0; $i < $NumberCornerUWires; $i++)
1383 $TopCornerUWireLength[$i] = ($FirstTopUWire_yspan - $i*$UWire_yint)/$CosUAngle;
1385 $j = $i + $NumberSideUWires;
1388 <tube name="${_[3]}WireU$j"
1389 rmax="0.5*$TPCWireThickness"
1390 z="$TopCornerUWireLength[$i]"
1401 # The corner wires for the V plane
1404 for ($i = 0; $i < $NumberCornerVWires; ++$i)
1406 $CornerVWireLength[$i] = ($FirstVWireOffset + $i*$UVReadoutBoardPitch)/$SinVAngle;
1410 <tube name="${_[3]}WireV$i"
1411 rmax="0.5*$TPCWireThickness"
1412 z="$CornerVWireLength[$i]"
1421 # The wire used many times in the middle of the V plane
1422 # Same subtraction as U common
1424 $CommonVWireLength = $Vactive_z/$SinVAngle;
1427 <tube name="${_[3]}WireVCommon"
1428 rmax="0.5*$TPCWireThickness"
1429 z="$CommonVWireLength"
1435 for ($i = 0; $i < $NumberCornerVWires; $i++)
1438 $TopCornerVWireLength[$i] = ($FirstTopVWire_yspan - $i*$VWire_yint)/$CosVAngle;
1440 $j = $i + $NumberSideVWires;
1443 <tube name="${_[3]}WireV$j"
1444 rmax="0.5*$TPCWireThickness"
1445 z="$TopCornerVWireLength[$i]"
1456 # make the solids only once per APA
1457 # (here only from the lang drift TPC)
1458 if($_[0]>100){ solid_TPCG10( $_[4], $_[0], $_[1], $_[2]); }
1460 # Begin structure and create the vertical wire logical volume
1464 <volume name="volTPCActive${_[3]}">
1465 <materialref ref="LAr"/>
1466 <solidref ref="${_[3]}Active"/>
1475 <volume name="volTPCWireVert${_[3]}">
1476 <materialref ref="Copper_Beryllium_alloy25"/>
1477 <solidref ref="${_[3]}WireVert"/>
1481 # Corner U wires logical volumes
1482 for ($i = 0; $i < $NumberCornerUWires; ++$i)
1485 <volume name="volTPCWireU$i${_[3]}">
1486 <materialref ref="Copper_Beryllium_alloy25"/>
1487 <solidref ref="${_[3]}WireU$i"/>
1493 # Top Corner U wires logical volumes
1494 for ($j = $NumberSideUWires; $j < $NumberSideUWires + $NumberCornerUWires; ++$j)
1497 <volume name="volTPCWireU$j${_[3]}">
1498 <materialref ref="Copper_Beryllium_alloy25"/>
1499 <solidref ref="${_[3]}WireU$j"/>
1505 # Common U wire logical volume, referenced many times
1507 <volume name="volTPCWireUCommon${_[3]}">
1508 <materialref ref="Copper_Beryllium_alloy25"/>
1509 <solidref ref="${_[3]}WireUCommon"/>
1513 # Corner V wires logical volumes
1514 for ($i = 0; $i < $NumberCornerVWires; ++$i)
1517 <volume name="volTPCWireV$i${_[3]}">
1518 <materialref ref="Copper_Beryllium_alloy25"/>
1519 <solidref ref="${_[3]}WireV$i"/>
1525 # Top Corner V wires logical volumes
1526 for ($j = $NumberSideVWires; $j < $NumberSideVWires + $NumberCornerVWires; ++$j)
1529 <volume name="volTPCWireV$j${_[3]}">
1530 <materialref ref="Copper_Beryllium_alloy25"/>
1531 <solidref ref="${_[3]}WireV$j"/>
1536 # Common V wire logical volume, referenced many times
1538 <volume name="volTPCWireVCommon${_[3]}">
1539 <materialref ref="Copper_Beryllium_alloy25"/>
1540 <solidref ref="${_[3]}WireVCommon"/>
1546 # generate the G10 board solids and logical volumes
1547 # make the volumes only once per APA
1548 # (here only from the lang drift TPC)
1549 if($_[0]>100){ vol_TPCG10( $_[4] ); }
1555 #+++++++++++++++++++++++++ Position physical wires ++++++++++++++++++++++++++
1557 # ++++++++++++++++++++++ U Plane +++++++++++++++++++++++
1559 # Create U plane logical volume
1561 <volume name="volTPCPlaneU${_[3]}">
1562 <materialref ref="LAr"/>
1563 <solidref ref="${_[3]}UPlane"/>
1567 print $wout "\n- Wires for U plane -\n\n";
1568 print $wout " Uplane_y: $Uactive_y[$apa]\n";
1569 print $wout " Uplane_z: $Uactive_z\n";
1575 # Starting with the bottom left corner wires:
1576 # x=0 to center the wires in the plane
1577 # y positioning: (-0.5*$TPCWirePlaneHeight) starts the incremental increase
1578 # from the bottom of the plane, and trigonometry gives the increment
1579 # z positioning: Looking at the plane from the positive x direction,
1580 # (0.5*$TPCWirePlaneLength) starts the incremental increase from
1581 # the lower left corner.
1582 # rotation: same as common wire in code below
1584 $FirstU_ypos = - $Uactive_y[$apa]/2 + $FirstUWireOffset/$TanUAngle/2;
1585 $FirstU_zpos = + $Uactive_z/2 - $FirstUWireOffset/2;
1587 for ($i = 0; $i < $NumberCornerUWires; ++$i)
1590 my $ypos = $FirstU_ypos + ($i)*0.5*$UWire_yint;
1591 my $zpos = $FirstU_zpos - ($i)*0.5*$UVReadoutBoardPitch;
1593 # cant actually define like this:
1594 # my $ypos = (-0.5*$Uactive_y[$apa]) + $CornerUWireLength[$i]*$CosUAngle/2;
1595 # my $zpos = (+0.5*$Uactive_z) - $CornerUWireLength[$i]*$SinUAngle/2;
1596 # since the wire lengths need to be slightly reduced to avoid the
1597 # wire corner's overlap with the plane boundary
1601 <volumeref ref="volTPCWireU$i${_[3]}"/>
1602 <position name="pos${_[3]}WireU$i" unit="cm" x="0" y="$ypos " z="$zpos"/>
1603 <rotation name="rUAngle$i" unit="deg" x="90-$UAngle" y="0" z="0"/>
1607 $topY = $ypos + ($CosUAngle*$CornerUWireLength[$i]/2);
1608 $bottomY = $ypos - ($CosUAngle*$CornerUWireLength[$i]/2);
1609 $edgeZ_p = $zpos + ($SinUAngle*$CornerUWireLength[$i]/2);
1610 $edgeZ_m = $zpos - ($SinUAngle*$CornerUWireLength[$i]/2);
1611 print $wout "U$i: ( $ypos , $zpos ) \n";
1612 print $wout " -- Y: $bottomY to $topY -- Z: $edgeZ_m to $edgeZ_p \n";
1620 # Moving upwards to the common wires:
1621 # x and z are zero to center the wires along a vertical axis
1622 # y positioning: The trick is positioning the lowest common wire so that the pitch
1623 # is consistent, then the increment is double the increment of
1624 # the corner wires since there is no z incriment.
1625 # rotation: wires in \\\\ direction, so +90deg to bring them to vertical and
1626 # +UAngle counterclockwise to arrive at proper orientation
1627 # Note that the counter maintains wire number (in pos. name) counting bottom to top
1630 my $StartCommonUWires_ypos = $lastYpos + $UWire_yint - abs( $lastZpos )/$TanUAngle;
1631 #print "$StartCommonUWires_ypos = $lastYpos + $UWire_yint - abs( $lastZpos )/$TanUAngle\n";
1634 for ($i = $NumberCornerUWires; $i < $NumberSideUWires; ++$i)
1637 $j = $i - $NumberCornerUWires;
1639 #my $ypos = (-0.5*$Uactive_y[$apa])
1640 # + 0.5*($NumberCornerUWires)*$UWire_yint+($i+1-$NumberCornerUWires)*$UWire_yint;
1641 my $ypos = $StartCommonUWires_ypos + $UWire_yint*($j);
1645 <volumeref ref="volTPCWireUCommon${_[3]}"/>
1646 <position name="pos${_[3]}WireU$i" unit="cm" x="0" y="$ypos " z="0"/>
1647 <rotation name="rUAngle$i" unit="deg" x="90-$UAngle" y="0" z="0"/>
1651 $topY = $ypos + ($CosUAngle*$CommonUWireLength/2);
1652 $bottomY = $ypos - ($CosUAngle*$CommonUWireLength/2);
1653 $edgeZ_p = + ($SinUAngle*$CommonUWireLength/2);
1654 $edgeZ_m = - ($SinUAngle*$CommonUWireLength/2);
1655 print $wout "U$i: ( $ypos , 0 ) \n";
1656 print $wout " -- Y: $bottomY to $topY -- Z: $edgeZ_m to $edgeZ_p \n";
1659 #$lastZpos = $zpos; always 0
1665 my $FirstTopUWire_zspan = $FirstTopUWire_yspan*$TanUAngle;
1666 my $StartTopUWires_ypos = + $Uactive_y[$apa]/2 - $FirstTopUWire_yspan/2;
1667 my $StartTopUWires_zpos = - $Uactive_z/2 + $FirstTopUWire_zspan/2;
1669 # Finally moving to the corner wires on the top right:
1670 # x=0 to center the wires in the plane
1671 # y positioning: plug wire number into same equation
1672 # z positioning: start at z=0 and go negatively at the same z increment
1673 # rotation: same as common wire in code above
1674 # note that the counter maintains wire number shown in the position name
1676 for ($j = $NumberSideUWires; $j < $NumberSideUWires+$NumberCornerUWires; ++$j)
1679 $i = $j - $NumberSideUWires;
1681 my $ypos = $StartTopUWires_ypos + ($i)*0.5*$UWire_yint;
1682 my $zpos = $StartTopUWires_zpos - ($i)*0.5*$UVReadoutBoardPitch;
1687 <volumeref ref="volTPCWireU$j${_[3]}"/>
1688 <position name="pos${_[3]}WireU$j" unit="cm" x="0" y="$ypos " z="$zpos"/>
1689 <rotation name="rUAngle$j" unit="deg" x="90-$UAngle" y="0" z="0"/>
1693 $topY = $ypos + ($CosUAngle*$TopCornerUWireLength[$i]/2);
1694 $bottomY = $ypos - ($CosUAngle*$TopCornerUWireLength[$i]/2);
1695 $edgeZ_p = $zpos + ($SinUAngle*$TopCornerUWireLength[$i]/2);
1696 $edgeZ_m = $zpos - ($SinUAngle*$TopCornerUWireLength[$i]/2);
1697 print $wout "U$i: ( $ypos , $zpos ) \n";
1698 print $wout " -- Y: $bottomY to $topY -- Z: $edgeZ_m to $edgeZ_p \n";
1705 # ++++++++++++++++++++++ V Plane +++++++++++++++++++++++
1707 # End U plane and create V plane logical volume
1711 <volume name="volTPCPlaneV${_[3]}">
1712 <materialref ref="LAr"/>
1713 <solidref ref="${_[3]}VPlane"/>
1716 print $wout "\n- Wires for V plane -\n\n";
1717 print $wout " Vplane_y: $Vactive_y[$apa]\n";
1718 print $wout " Vplane_z: $Vactive_z\n";
1724 # Starting with the bottom right corner wires:
1725 # x=0 to center the wires in the plane
1726 # y positioning: (-0.5*$TPCWirePlaneHeight) starts the incremental increase
1727 # from the bottom of the plane, and trigonometry gives the increment
1728 # z positioning: Looking at the plane from the positive x direction,
1729 # (-0.5*$TPCWirePlaneLength) starts the incremental increase from
1730 # the lower right corner.
1731 # rotation: same as common wire in code below
1733 $FirstV_ypos = - $Vactive_y[$apa]/2 + $FirstVWireOffset/$TanVAngle/2;
1734 $FirstV_zpos = - $Vactive_z/2 + $FirstVWireOffset/2;
1736 for ($i = 0; $i < $NumberCornerVWires; ++$i)
1739 my $ypos = $FirstV_ypos + ($i)*0.5*$VWire_yint;
1740 my $zpos = $FirstV_zpos + ($i)*0.5*$UVReadoutBoardPitch;
1744 <volumeref ref="volTPCWireV$i${_[3]}"/>
1745 <position name="pos${_[3]}WireV$i" unit="cm" x="0" y="$ypos " z="$zpos"/>
1746 <rotation name="rVAngle$i" unit="deg" x="90+$VAngle" y="0" z="0"/>
1750 $topY = $ypos + ($CosVAngle*$CornerVWireLength[$i]/2);
1751 $bottomY = $ypos - ($CosVAngle*$CornerVWireLength[$i]/2);
1752 $edgeZ_p = $zpos + ($SinVAngle*$CornerVWireLength[$i]/2);
1753 $edgeZ_m = $zpos - ($SinVAngle*$CornerVWireLength[$i]/2);
1754 print $wout "V$i: ( $ypos , $zpos ) \n";
1755 print $wout " -- Y: $bottomY to $topY -- Z: $edgeZ_m to $edgeZ_p \n";
1763 # Moving upwards to the common wires:
1764 # x and z are zero to center the wires along a vertical axis
1765 # y positioning: Plug wire number into the same corner ypos equation
1766 # rotation: wires in //// direction, so +90deg to bring them to vertical and
1767 # --VAngle counterclockwise to arrive at proper orientation
1768 # Note that the counter maintains wire number in the position name
1770 my $StartCommonVWires_ypos = $lastYpos + $VWire_yint - abs( $lastZpos )/$TanVAngle;
1772 for ($i = $NumberCornerVWires; $i < $NumberSideVWires; ++$i)
1775 $j = $i - $NumberCornerVWires;
1776 my $ypos = $StartCommonVWires_ypos + $VWire_yint*($j);
1780 <volumeref ref="volTPCWireVCommon${_[3]}"/>
1781 <position name="pos${_[3]}WireV$i" unit="cm" x="0" y="$ypos " z="0"/>
1782 <rotation name="rVAngle$i" unit="deg" x="90+$VAngle" y="0" z="0"/>
1786 $topY = $ypos + ($CosVAngle*$CommonVWireLength/2);
1787 $bottomY = $ypos - ($CosVAngle*$CommonVWireLength/2);
1788 $edgeZ_p = + ($SinVAngle*$CommonVWireLength/2);
1789 $edgeZ_m = - ($SinVAngle*$CommonVWireLength/2);
1790 print $wout "V$i: ( $ypos , 0 ) \n";
1791 print $wout " -- Y: $bottomY to $topY -- Z: $edgeZ_m to $edgeZ_p \n";
1794 #$lastZpos = $zpos; always 0
1799 my $FirstTopVWire_zspan = $FirstTopVWire_yspan*$TanVAngle;
1800 my $StartTopVWires_ypos = + $Vactive_y[$apa]/2 - $FirstTopVWire_yspan/2;
1801 my $StartTopVWires_zpos = + $Vactive_z/2 - $FirstTopVWire_zspan/2;
1803 # Finally moving to the corner wires on the top right:
1804 # x=0 to center the wires in the plane
1805 # y positioning: plug wire number into same equation
1806 # z positioning: start at z=0 and go positively at the same z increment
1807 # rotation: same as common wire in code above
1808 # note that the counter maintains wire number shown in the position name
1810 for ($j = $NumberSideVWires; $j < $NumberSideVWires+$NumberCornerVWires; ++$j)
1813 $i = $j - $NumberSideVWires;
1815 my $ypos = $StartTopVWires_ypos + ($i)*0.5*$VWire_yint;
1816 my $zpos = $StartTopVWires_zpos + ($i)*0.5*$UVReadoutBoardPitch;
1820 <volumeref ref="volTPCWireV$j${_[3]}"/>
1821 <position name="pos${_[3]}WireV$j" unit="cm" x="0" y="$ypos " z="$zpos"/>
1822 <rotation name="rVAngle$j" unit="deg" x="90+$VAngle" y="0" z="0"/>
1826 $topY = $ypos + ($CosVAngle*$TopCornerVWireLength[$i]/2);
1827 $bottomY = $ypos - ($CosVAngle*$TopCornerVWireLength[$i]/2);
1828 $edgeZ_p = $zpos + ($SinVAngle*$TopCornerVWireLength[$i]/2);
1829 $edgeZ_m = $zpos - ($SinVAngle*$TopCornerVWireLength[$i]/2);
1830 print $wout "V$i: ( $ypos , $zpos ) \n";
1831 print $wout " -- Y: $bottomY to $topY -- Z: $edgeZ_m to $edgeZ_p \n";
1844 # ++++++++++++++++++++++ Z Plane +++++++++++++++++++++++
1846 # End V plane and create Z plane logical volume
1850 <volume name="volTPCPlaneZ${_[3]}">
1851 <materialref ref="LAr"/>
1852 <solidref ref="${_[3]}ZPlane"/>
1858 # This is the simplest plane, one loop creates all of the wires
1859 # x and y position at zero to center the wires
1860 # z position: moving from front of detector to back, in the positive z direction,
1861 # starting at (-0.5*$TPCWirePlaneLength), the right side looking from
1864 for ($i=0; $i<$NumberVerticalWires; ++$i)
1866 my $zpos = (-0.5*$Zactive_z) + $i*$XWirePitch + $TPCWireThickness/2;
1870 <volumeref ref="volTPCWireVert${_[3]}"/>
1871 <position name="pos${_[3]}WireZ$i" unit="cm" x="0" y="0 " z="$zpos"/>
1872 <rotationref ref="rPlus90AboutX"/>
1884 #+++++++++++++++++++++ ^^ Position physical wires Above ^^ +++++++++++++++++++++
1886 ## make the TPC active volume extend down to the G10 for the grid
1888 my $BottomOfAPA = - $TPC_y[$apa]/2 + $APAGap_y/2;
1891 if ($apa==0){ $zz = -1; }
1892 elsif($apa==1){ $zz = 0; }
1893 elsif($apa==2){ $zz = 0; }
1894 elsif($apa==3){ $zz = 1; }
1896 if ($TPCActive_x<100){ $xx = -1; }
1899 $posZplane[0] = $xx*(-$_[0]/2 + $APAWirePlaneSpacing - $TPCWirePlaneThickness/2);
1900 $posZplane[1] = $BottomOfAPA + $WrapCover + 4*$G10thickness + $Zactive_y[$apa]/2;
1901 $posZplane[2] = $zz*(-$_[2]/2 + $APAGap_z/2 + $APAphys_z/2);
1903 $posVplane[0] = $posZplane[0] + $xx*$APAWirePlaneSpacing;
1904 $posVplane[1] = $BottomOfAPA + $WrapCover + 3*$G10thickness + $Vactive_y[$apa]/2;
1905 $posVplane[2] = $posZplane[2];
1907 $posUplane[0] = $posVplane[0] + $xx*$APAWirePlaneSpacing;
1908 $posUplane[1] = $BottomOfAPA + $WrapCover + 2*$G10thickness + $Uactive_y[$apa]/2;
1909 $posUplane[2] = $posZplane[2];
1911 $posTPCActive[0] = $posUplane[0] + $xx*($TPCWirePlaneThickness/2 + $TPCActive_x/2);
1912 $posTPCActive[1] = -$_[1]/2 + $TPCActive_y/2;
1913 $posTPCActive[2] = 0;
1915 if ($TPCActive_x<100){ $planeRot = "rIdentity"; }
1916 else { $planeRot = "rPlus180AboutY"; }
1919 #wrap up the TPC file
1921 <volume name="volTPC${_[3]}">
1922 <materialref ref="LAr"/>
1923 <solidref ref="${_[3]}"/>
1925 <volumeref ref="volTPCPlaneZ${_[3]}"/>
1926 <position name="pos${_[3]}PlaneZ" unit="cm"
1927 x="$posZplane[0]" y="$posZplane[1]" z="$posZplane[2]"/>
1928 <rotationref ref="$planeRot"/>
1931 <volumeref ref="volTPCPlaneV${_[3]}"/>
1932 <position name="pos${_[3]}PlaneV" unit="cm"
1933 x="$posVplane[0]" y="$posVplane[1]" z="$posVplane[2]"/>
1934 <rotationref ref="$planeRot"/>
1937 <volumeref ref="volTPCPlaneU${_[3]}"/>
1938 <position name="pos${_[3]}PlaneU" unit="cm"
1939 x="$posUplane[0]" y="$posUplane[1]" z="$posUplane[2]"/>
1940 <rotationref ref="$planeRot"/>
1943 <volumeref ref="volTPCActive${_[3]}"/>
1944 <position name="pos${_[3]}Active" unit="cm"
1945 x="$posTPCActive[0]" y="$posTPCActive[1]" z="$posTPCActive[2]"/>
1949 # place the G10 board extensions to the portions placed directly in volCryostat
1950 #place_TPCG10( $_[4], $_[0], $_[1], $_[2] );
1960 } #end of sub gen_TPC
1963 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1964 #++++++++++++++++++++++++++++++++++++++ solid_TPCG10 +++++++++++++++++++++++++++++++++++++
1965 #++++++++++++++++++++++++++++++++++++++++ vol_TPCG10 +++++++++++++++++++++++++++++++++++++
1966 #++++++++++++++++++++++++++++++++++++++ place_TPCG10 +++++++++++++++++++++++++++++++++++++
1967 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1970 # Must be called only within gen_TPC(),
1973 # $_[0] = APA number
1974 # convention: 0 is Largest, 1 is Mid, 2 is Smallest
1982 $G10BoardYSide_V_x = 2*$APAWirePlaneSpacing; # The rest of the x-direction extension
1983 # out to the V plane wires
1984 $G10BoardYSide_V_y = $APAFrame_y[$apa]; # Y and Z are the same as the center
1985 $G10BoardYSide_V_z = $G10thickness; # parts placed in volCryostat
1988 $G10BoardYSide_U_x = 3*$APAWirePlaneSpacing; # The rest of the x-direction extension
1989 # out to the U plane wires
1990 $G10BoardYSide_U_y = $APAFrame_y[$apa]; # Y and Z are the same as the center
1991 $G10BoardYSide_U_z = $G10thickness; # parts placed in volCryostat
1994 $G10BoardZSide_V_x = 2*$APAWirePlaneSpacing;
1995 $G10BoardZSide_V_y = $G10thickness;
1996 $G10BoardZSide_V_z = $APAFrame_z;
1997 $G10BoardZSide_U_x = 3*$APAWirePlaneSpacing;
1998 $G10BoardZSide_U_y = $G10thickness;
1999 $G10BoardZSide_U_z = $APAFrame_z;
2000 $G10BoardZSide_Grid_x = 4*$APAWirePlaneSpacing;
2001 $G10BoardZSide_Grid_y = $G10thickness;
2002 $G10BoardZSide_Grid_z = $APAFrame_z;
2006 <box name="G10BoardYSideVSeg\-$apa" lunit="cm"
2007 x="$G10BoardYSide_V_x"
2008 y="$G10BoardYSide_V_y"
2009 z="$G10BoardYSide_V_z"/>
2011 <box name="G10BoardYSideUSeg\-$apa" lunit="cm"
2012 x="$G10BoardYSide_U_x"
2013 y="$G10BoardYSide_U_y"
2014 z="$G10BoardYSide_U_z"/>
2016 <box name="G10BoardZSideVSeg\-$apa" lunit="cm"
2017 x="$G10BoardZSide_V_x"
2018 y="$G10BoardZSide_V_y"
2019 z="$G10BoardZSide_V_z"/>
2021 <box name="G10BoardZSideUSeg\-$apa" lunit="cm"
2022 x="$G10BoardZSide_U_x"
2023 y="$G10BoardZSide_U_y"
2024 z="$G10BoardZSide_U_z"/>
2026 <box name="G10BoardZSideGridSeg\-$apa" lunit="cm"
2027 x="$G10BoardZSide_Grid_x"
2028 y="$G10BoardZSide_Grid_y"
2029 z="$G10BoardZSide_Grid_z"/>
2043 <volume name="volG10BoardYSideVSeg\-$apa">
2044 <materialref ref="G10"/>
2045 <solidref ref="G10BoardYSideVSeg\-$apa"/>
2047 <volume name="volG10BoardYSideUSeg\-$apa">
2048 <materialref ref="G10"/>
2049 <solidref ref="G10BoardYSideUSeg\-$apa"/>
2052 <volume name="volG10BoardZSideVSeg\-$apa">
2053 <materialref ref="G10"/>
2054 <solidref ref="G10BoardZSideVSeg\-$apa"/>
2056 <volume name="volG10BoardZSideUSeg\-$apa">
2057 <materialref ref="G10"/>
2058 <solidref ref="G10BoardZSideUSeg\-$apa"/>
2060 <volume name="volG10BoardZSideGridSeg\-$apa">
2061 <materialref ref="G10"/>
2062 <solidref ref="G10BoardZSideGridSeg\-$apa"/>
2080 $G10BoardYSide_V_x = 1*$APAWirePlaneSpacing; # The rest of the x-direction extension
2081 # out to the V plane wires
2082 $G10BoardYSide_V_y = $APAFrame_y[$APA_i]; # Y and Z are the same as the center
2083 $G10BoardYSide_V_z = $G10thickness; # parts placed in volCryostat
2086 $G10BoardYSide_U_x = 2*$APAWirePlaneSpacing; # The rest of the x-direction extension
2087 # out to the U plane wires
2088 $G10BoardYSide_U_y = $APAFrame_y[$APA_i]; # Y and Z are the same as the center
2089 $G10BoardYSide_U_z = $G10thickness; # parts placed in volCryostat
2092 $G10BoardZSide_V_x = 1*$APAWirePlaneSpacing;
2093 $G10BoardZSide_V_y = $G10thickness;
2094 $G10BoardZSide_V_z = $APAFrame_z;
2095 $G10BoardZSide_U_x = 2*$APAWirePlaneSpacing;
2096 $G10BoardZSide_U_y = $G10thickness;
2097 $G10BoardZSide_U_z = $APAFrame_z;
2098 $G10BoardZSide_Grid_x = 3*$APAWirePlaneSpacing;
2099 $G10BoardZSide_Grid_y = $G10thickness;
2100 $G10BoardZSide_Grid_z = $APAFrame_z;
2103 $posG10ZSideZ_y = $APAFrameCenter_y - $APAFrame_y[$APA_i]/2 - (0+.5)*($G10BoardZSide_y);
2104 $posG10ZSideV_y = $APAFrameCenter_y - $APAFrame_y[$APA_i]/2 - (1+.5)*($G10BoardZSide_y);
2105 $posG10ZSideU_y = $APAFrameCenter_y - $APAFrame_y[$APA_i]/2 - (2+.5)*($G10BoardZSide_y);
2106 $posG10ZSideGrid_y = $APAFrameCenter_y - $APAFrame_y[$APA_i]/2 - (3+.5)*($G10BoardZSide_y);
2108 # ... but the smallest APA is upside-down, so put the G10 boards at the top in that case
2111 $posG10ZSideZ_y = $APAFrameCenter_y + $APAFrame_y[$APA_i]/2 + (0+.5)*($G10BoardZSide_y);
2112 $posG10ZSideV_y = $APAFrameCenter_y + $APAFrame_y[$APA_i]/2 + (1+.5)*($G10BoardZSide_y);
2113 $posG10ZSideU_y = $APAFrameCenter_y + $APAFrame_y[$APA_i]/2 + (2+.5)*($G10BoardZSide_y);
2114 $posG10ZSideGrid_y = $APAFrameCenter_y + $APAFrame_y[$APA_i]/2 + (3+.5)*($G10BoardZSide_y);
2120 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2121 - Add the *parts* of the G10 boards that extend those directly in volCryostat.
2122 - There are two side boards on each the up and downstream end,
2123 one each to wrap the U and V views around the APA frame
2124 - There are 4 on the bottom which anchor the U V and Z wires and the grid plane
2125 - The center parts of the G10 boards must be placed directly in volCryostat
2132 <volumeref ref="volG10BoardYSideVSeg\-$apa"/>
2133 <position name="posG10BoardYSideVSeg\-up\-$apa" unit="cm"
2134 x=" - $ThisTPC_x/2 + $G10BoardYSide_V_x/2"
2135 y=" - $APAphys_y[$apa]/2 + $WrapCover + 4*$G10thickness + $APAFrame_y[$apa]/2 "
2136 z=" - $APAFrame_z/2 - (0+.5)*($G10BoardYSide_V_z)"/>
2137 <rotationref ref="rIdentity"/>
2140 <volumeref ref="volG10BoardYSideUSeg\-$apa"/>
2141 <position name="posG10BoardYSideUSeg\-up\-$apa" unit="cm"
2142 x=" - $ThisTPC_x/2 + $G10BoardYSide_U_x/2"
2143 y=" - $APAphys_y[$apa]/2 + $WrapCover + 4*$G10thickness + $APAFrame_y[$apa]/2"
2144 z=" - $APAFrame_z/2 - (1+.5)*($G10BoardYSide_U_z)"/>
2145 <rotationref ref="rIdentity"/>
2149 <volumeref ref="volG10BoardYSideVSeg\-$apa"/>
2150 <position name="posG10BoardYSideVSeg\-down\-$apa" unit="cm"
2151 x=" - $ThisTPC_x/2 + $G10BoardYSide_V_x/2"
2152 y=" - $APAphys_y[$apa]/2 + $WrapCover + 4*$G10thickness + $APAFrame_y[$apa]/2 "
2153 z=" + $APAFrame_z/2 + (0+.5)*($G10BoardYSide_V_z)"/>
2154 <rotationref ref="rIdentity"/>
2157 <volumeref ref="volG10BoardYSideUSeg\-$apa"/>
2158 <position name="posG10BoardYSideUSeg\-down\-$apa" unit="cm"
2159 x=" - $ThisTPC_x/2 + $G10BoardYSide_U_x/2"
2160 y=" - $APAphys_y[$apa]/2 + $WrapCover + 4*$G10thickness + $APAFrame_y[$apa]/2"
2161 z=" + $APAFrame_z/2 + (1+.5)*($G10BoardYSide_U_z)"/>
2162 <rotationref ref="rIdentity"/>
2168 <volumeref ref="volG10BoardZSideVSeg\-$apa"/>
2169 <position name="posG10BoardZSideVSeg\-$apa" unit="cm"
2170 x=" - $ThisTPC_x/2 + $G10BoardZSide_V_x/2"
2171 y=" - $APAphys_y[$apa]/2 + $WrapCover + 2.5*$G10thickness"
2173 <rotationref ref="rIdentity"/>
2176 <volumeref ref="volG10BoardZSideUSeg\-$apa"/>
2177 <position name="posG10BoardZSideUSeg\-$apa" unit="cm"
2178 x=" - $ThisTPC_x/2 + $G10BoardZSide_U_x/2"
2179 y=" - $APAphys_y[$apa]/2 + $WrapCover + 1.5*$G10thickness"
2181 <rotationref ref="rIdentity"/>
2184 <volumeref ref="volG10BoardZSideGridSeg\-$apa"/>
2185 <position name="posG10BoardZSideGridSeg\-$apa" unit="cm"
2186 x=" - $ThisTPC_x/2 + $G10BoardZSide_Grid_x/2"
2187 y=" - $APAphys_y[$apa]/2 + $WrapCover + 0.5*$G10thickness"
2189 <rotationref ref="rIdentity"/>
2201 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2202 #++++++++++++++++++++++++++++++++++++++ gen_Cryostat +++++++++++++++++++++++++++++++++++++
2203 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2208 # Create the cryostat fragment file name,
2209 # add file to list of output GDML fragments,
2211 $CRYO = "35t_Cryostat" . $suffix . ".gdml";
2212 push (@gdmlFiles, $CRYO);
2213 $CRYO = ">" . $CRYO;
2214 open(CRYO) or die("Could not open file $CRYO for writing");
2217 # The standard XML prefix and starting the gdml
2219 <?xml version='1.0'?>
2224 # All the cryostat solids.
2227 <box name="Cryostat" lunit="cm"
2232 <box name="GaseousArgon" lunit="cm"
2234 y="$HeightGaseousAr"
2237 <box name="LightPaddle" lunit="cm"
2239 y="$LightPaddle_y + $SiPM_y"
2240 z="$LightPaddle_z"/>
2242 <box name="Bar" lunit="cm"
2247 <union name="TwoBars">
2248 <first ref="Bar"/> <second ref="Bar"/>
2249 <position name="bs2" z="-2.794" unit="cm"/>
2252 <union name="FourBars">
2253 <first ref="TwoBars"/> <second ref="TwoBars"/>
2254 <position name="bs4" z="-5.588" unit="cm"/>
2257 <box name="Plank" lunit="cm"
2262 <box name="Fiber" lunit="cm"
2267 <box name="FiberBottom" lunit="cm"
2272 <box name="FiberTop" lunit="cm"
2277 <para name="FiberRight" x="0.289" y="0.289" z="5.3975" alpha="0" theta="3.0649" phi="0" aunit="deg" lunit="cm"/>
2279 <para name="FiberLeft" x="0.289" y="0.289" z="5.3975" alpha="0" theta="-3.0649" phi="0" aunit="deg" lunit="cm"/>
2282 <first ref="Fiber"/> <second ref="Fiber"/>
2283 <position name="ff" x="-0.289" z="-0.289" unit="cm"/>
2287 <first ref="FF"/> <second ref="FiberBottom"/>
2288 <position name="ffb" x="-0.289" y="-3.81" z="0.289" unit="cm"/>
2292 <first ref="FFB"/> <second ref="FiberBottom"/>
2293 <position name="ffbb" y="-3.81" z="-0.578" unit="cm"/>
2296 <union name="FFBBT">
2297 <first ref="FFBB"/> <second ref="FiberTop"/>
2298 <position name="ffbbt" x="-0.289" y="24.28875" unit="cm"/>
2301 <union name="FFBBTT">
2302 <first ref="FFBBT"/> <second ref="FiberTop"/>
2303 <position name="ffbbtt" y="24.28875" z="-0.289" unit="cm"/>
2306 <union name="FFBBTTL">
2307 <first ref="FFBBTT"/> <second ref="FiberLeft"/>
2308 <position name="ffbbttl" x="0" y="20.47875" z="-0.4335" unit="cm"/> <rotation name="FiberRotLeft" x="-90" y="90" unit="deg"/>
2311 <union name="FourFibers">
2312 <first ref="FFBBTTL"/> <second ref="FiberRight"/>
2313 <position name="fs4" x="-0.289" y="20.47875" z="0.1445" unit="cm"/> <rotation name="FiberRotRight" x="-90" y="90" unit="deg"/>
2316 <union name="EightFibers">
2317 <first ref="FourFibers"/> <second ref="FourFibers"/>
2318 <position name="fs8" z="-1.2" unit="cm"/>
2321 <union name="SixteenFibers">
2322 <first ref="EightFibers"/> <second ref="EightFibers"/>
2323 <position name="fs16" z="-2.4" unit="cm"/>
2326 <union name="ThirtyTwoFibers">
2327 <first ref="SixteenFibers"/> <second ref="SixteenFibers"/>
2328 <position name="fs32" z="-4.8" unit="cm"/>
2334 # Add APA frames with G10 boards on them
2340 solid_CPA(); # no need for multiple sets of solids, the only 2 CPAs are identical
2343 # Cryostat structure
2348 <volume name="volGaseousArgon">
2349 <materialref ref="ArGas"/>
2350 <solidref ref="GaseousArgon"/>
2353 <volume name="volOpDetSensitive_Bar">
2354 <materialref ref="LAr"/>
2355 <solidref ref="FourBars"/>
2358 <volume name="volOpDetSensitive_Plank">
2359 <materialref ref="LAr"/>
2360 <solidref ref="Plank"/>
2363 <volume name="volOpDetSensitive_Fiber">
2364 <materialref ref="LAr"/>
2365 <solidref ref="ThirtyTwoFibers"/>
2379 <volume name="volCryostat">
2380 <materialref ref="LAr"/>
2381 <solidref ref="Cryostat"/>
2384 <volumeref ref="volGaseousArgon"/>
2385 <position name="posGaseousArgon" unit="cm" x="0" y="$Argon_y/2 - $HeightGaseousAr/2" z="0"/>
2389 <volumeref ref="volCathode"/>
2390 <positionref ref="posCathodeShortDrift"/>
2393 <volumeref ref="volCathode"/>
2394 <positionref ref="posCathodeLongDrift"/>
2400 <!-- The Smallest APA -->
2401 <!-- Note this is the only APA with a readout
2402 at the bottom. TPCs are constructed with
2403 readouts at the top, so rotate the two APAs
2404 180 around X to flip upside down -->
2407 <volumeref ref="volTPCSmallestLongDrift"/>
2408 <positionref ref="posTPCSmallestLongDrift"/>
2409 <rotationref ref="rPlus180AboutX"/>
2413 <volumeref ref="volTPCSmallestShortDrift"/>
2414 <positionref ref="posTPCSmallestShortDrift"/>
2415 <rotationref ref="rPlus180AboutX"/>
2421 place_APA($APACenter[2][0], $APACenter[2][1], $APACenter[2][2], 2);
2426 <!-- The Middle-sized APA -->
2429 <volumeref ref="volTPCMidLongDrift"/>
2430 <positionref ref="posTPCMidLongDrift"/>
2431 <rotationref ref="rIdentity"/>
2435 <volumeref ref="volTPCMidShortDrift"/>
2436 <positionref ref="posTPCMidShortDrift"/>
2437 <rotationref ref="rIdentity"/>
2443 place_APA($APACenter[1][0], $APACenter[1][1], $APACenter[1][2], 1);
2448 <!-- The Largest APAs, Upstream and Downstream -->
2451 <volumeref ref="volTPCLargestLongDriftUpstream"/>
2452 <positionref ref="posTPCLargestLongDrift_Neg"/>
2453 <rotationref ref="rIdentity"/>
2456 <volumeref ref="volTPCLargestShortDriftUpstream"/>
2457 <positionref ref="posTPCLargestShortDrift_Neg"/>
2458 <rotationref ref="rIdentity"/>
2462 <volumeref ref="volTPCLargestLongDriftDownstream"/>
2463 <positionref ref="posTPCLargestLongDrift_Pos"/>
2464 <rotationref ref="rIdentity"/>
2467 <volumeref ref="volTPCLargestShortDriftDownstream"/>
2468 <positionref ref="posTPCLargestShortDrift_Pos"/>
2469 <rotationref ref="rIdentity"/>
2474 place_APA($APACenter[0][0], $APACenter[0][1], $APACenter[0][2], 0);
2475 place_APA($APACenter[3][0], $APACenter[3][1], $APACenter[3][2], 3);
2477 place_CPA(0, $posCPAShortDrift_x, $posCPAShortDrift_y, $posCPAShortDrift_z);
2478 place_CPA(1, $posCPALongDrift_x, $posCPALongDrift_y, $posCPALongDrift_z);
2491 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2492 #++++++++++++++++++++++++++++++++++++++ solid_APA ++++++++++++++++++++++++++++++++++++++++
2493 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2496 # Must be called only within gen_Cryostat(),
2499 # $_[0] = APA number
2500 # convention: 0 is Largest, 1 is Mid, 2 is Smallest
2507 ####################################################################
2508 ################# APA Frame and Paddle Dimensions ##################
2510 $APA_y = $APAFrame_y[$APA_i];
2512 $APAFrameZSide_x = $APAFrame_x;
2513 $APAFrameZSide_y = 4*$inch;
2514 $APAFrameZSide_z = $APAFrame_z;
2516 $APAFrameYSide_x = $APAFrame_x;
2517 $APAFrameYSide_y = $APA_y-2*$APAFrameZSide_y;
2518 $APAFrameYSide_z = 4*$inch;
2520 # Two outer Y supports will sandwich the light paddles
2521 $APAFrameYOuterSupport_x = ($APAFrame_x-$LightPaddle_x)/2;
2522 $APAFrameYOuterSupport_y = $APA_y-2*$APAFrameZSide_y;
2523 $APAFrameYOuterSupport_z = 4*$inch;
2525 $EdgeFrameSteelThickness = 0.12*$inch;
2526 $InnerFrameSteelThickness = 0.062*$inch;
2529 $G10BoardYSide_x = $APAFrame_x;
2530 $G10BoardYSide_y = $APAFrame_y[$APA_i];
2531 $G10BoardYSide_z = $G10thickness;
2533 $G10BoardZSide_x = $APAFrame_x;
2534 $G10BoardZSide_y = $G10thickness;
2535 $G10BoardZSide_z = $APAFrame_z;
2539 <box name="APAFrameYSideHollow\-$APA_i" lunit="cm"
2540 x="$APAFrameYSide_x-2*$EdgeFrameSteelThickness"
2541 y="$APAFrameYSide_y-2*$EdgeFrameSteelThickness"
2542 z="$APAFrameYSide_z"/>
2543 <box name="APAFrameYSideShell\-$APA_i" lunit="cm"
2544 x="$APAFrameYSide_x"
2545 y="$APAFrameYSide_y"
2546 z="$APAFrameYSide_z"/>
2547 <subtraction name="APAFrameYSide\-$APA_i">
2548 <first ref="APAFrameYSideShell\-$APA_i"/>
2549 <second ref="APAFrameYSideHollow\-$APA_i"/>
2550 <positionref ref="posCenter"/>
2551 <rotationref ref="rIdentity"/>
2554 <box name="APAFrameZSideHollow\-$APA_i" lunit="cm"
2555 x="$APAFrameZSide_x-2*$EdgeFrameSteelThickness"
2556 y="$APAFrameZSide_y-2*$EdgeFrameSteelThickness"
2557 z="$APAFrameZSide_z"/>
2558 <box name="APAFrameZSideShell\-$APA_i" lunit="cm"
2559 x="$APAFrameZSide_x"
2560 y="$APAFrameZSide_y"
2561 z="$APAFrameZSide_z"/>
2562 <subtraction name="APAFrameZSide\-$APA_i">
2563 <first ref="APAFrameZSideShell\-$APA_i"/>
2564 <second ref="APAFrameZSideHollow\-$APA_i"/>
2565 <positionref ref="posCenter"/>
2566 <rotationref ref="rIdentity"/>
2569 <box name="APAFrameYOuterSupport\-$APA_i" lunit="cm"
2570 x="$EdgeFrameSteelThickness"
2571 y="$APAFrameYOuterSupport_y"
2572 z="$APAFrameYOuterSupport_z"/>
2575 <box name="G10BoardYSideCenterSeg\-$APA_i" lunit="cm"
2576 x="$G10BoardYSide_x"
2577 y="$G10BoardYSide_y"
2578 z="$G10BoardYSide_z"/>
2580 <box name="G10BoardZSideCenterSeg\-$APA_i" lunit="cm"
2581 x="$G10BoardZSide_x"
2582 y="$G10BoardZSide_y"
2583 z="$G10BoardZSide_z"/>
2593 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2594 #++++++++++++++++++++++++++++++++++++++ vol_APA ++++++++++++++++++++++++++++++++++++++++
2595 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2598 # Must be called only within gen_Cryostat(),
2601 # $_[0] = x APA center
2602 # $_[1] = y APA center
2603 # $_[2] = z APA center
2604 # $_[3] = APA number
2605 # convention: 0 and 3 are Largest, 1 is Mid, 2 is Smallest
2614 <volume name="volAPAFrameYSide\-$APA_i">
2615 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
2616 <solidref ref="APAFrameYSide\-$APA_i"/>
2619 <volume name="volAPAFrameZSide\-$APA_i">
2620 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
2621 <solidref ref="APAFrameZSide\-$APA_i"/>
2624 <volume name="volAPAFrameYOuterSupport\-$APA_i">
2625 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
2626 <solidref ref="APAFrameYOuterSupport\-$APA_i"/>
2629 <volume name="volG10BoardYSideCenterSeg\-$APA_i">
2630 <materialref ref="G10"/>
2631 <solidref ref="G10BoardYSideCenterSeg\-$APA_i"/>
2634 <volume name="volG10BoardZSideCenterSeg\-$APA_i">
2635 <materialref ref="G10"/>
2636 <solidref ref="G10BoardZSideCenterSeg\-$APA_i"/>
2646 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2647 #++++++++++++++++++++++++++++++++++++++ place_APA ++++++++++++++++++++++++++++++++++++++++
2648 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2651 # Must be called only within gen_Cryostat(),
2654 # $_[0] = x APA physical center
2655 # $_[1] = y APA physical center
2656 # $_[2] = z APA physical center
2657 # $_[3] = APA number
2658 # convention: 0 and 3 are Largest, 1 is Mid, 2 is Smallest
2665 ####################################################################
2666 ################# APA Frame and Paddle Dimensions ##################
2668 $APA_y = $APAFrame_y[$APA_i];
2671 # The center passed to this function is the physical APA center,
2672 # which is not quite the frame's center, since there are more boards
2673 # at the bottom. Transform them:
2675 $APAFrameCenter_x = $_[0];
2676 $APAFrameCenter_y = $_[1] - $APAphys_y[$APA_i]/2
2677 + $WrapCover + 4*$G10thickness
2678 + $APAFrame_y[$APA_i]/2;
2679 $APAFrameCenter_z = $_[2];
2681 # the smallest APA is different (upside down)
2684 $APAFrameCenter_y = $_[1] + $APAphys_y[$APA_i]/2
2685 - $WrapCover - 4*$G10thickness
2686 - $APAFrame_y[$APA_i]/2;
2690 $APAFrameZSide_x = $APAFrame_x;
2691 $APAFrameZSide_y = 4*$inch;
2692 $APAFrameZSide_z = $APAFrame_z;
2694 $APAFrameYSide_x = $APAFrame_x;
2695 $APAFrameYSide_y = $APA_y-2*$APAFrameZSide_y;
2696 $APAFrameYSide_z = 4*$inch;
2698 # Two outer Y supports will sandwich the light paddles
2699 $APAFrameYOuterSupport_x = ($APAFrame_x-$LightPaddle_x)/2;
2700 $APAFrameYOuterSupport_y = $APA_y-2*$APAFrameZSide_y;
2701 $APAFrameYOuterSupport_z = 4*$inch;
2703 # if there were an inner support to fill the hole
2704 $APAFrameYInnerSupport_x = $LightPaddle_x;
2706 $EdgeFrameSteelThickness = 0.12*$inch;
2707 $InnerFrameSteelThickness = 0.062*$inch;
2710 $G10BoardYSide_x = $APAFrame_x;
2711 $G10BoardYSide_y = $APAFrame_y[$APA_i];
2712 $G10BoardYSide_z = $G10thickness;
2714 $G10BoardZSide_x = $APAFrame_x;
2715 $G10BoardZSide_y = $G10thickness;
2716 $G10BoardZSide_z = $APAFrame_z;
2718 $posG10ZSideZ_y = $APAFrameCenter_y - $APAFrame_y[$APA_i]/2 - (0+.5)*($G10BoardZSide_y);
2719 $posG10ZSideV_y = $APAFrameCenter_y - $APAFrame_y[$APA_i]/2 - (1+.5)*($G10BoardZSide_y);
2720 $posG10ZSideU_y = $APAFrameCenter_y - $APAFrame_y[$APA_i]/2 - (2+.5)*($G10BoardZSide_y);
2721 $posG10ZSideGrid_y = $APAFrameCenter_y - $APAFrame_y[$APA_i]/2 - (3+.5)*($G10BoardZSide_y);
2723 # ... but the smallest APA is upside-down, so put the G10 boards at the top in that case
2726 $posG10ZSideZ_y = $APAFrameCenter_y + $APAFrame_y[$APA_i]/2 + (0+.5)*($G10BoardZSide_y);
2727 $posG10ZSideV_y = $APAFrameCenter_y + $APAFrame_y[$APA_i]/2 + (1+.5)*($G10BoardZSide_y);
2728 $posG10ZSideU_y = $APAFrameCenter_y + $APAFrame_y[$APA_i]/2 + (2+.5)*($G10BoardZSide_y);
2729 $posG10ZSideGrid_y = $APAFrameCenter_y + $APAFrame_y[$APA_i]/2 + (3+.5)*($G10BoardZSide_y);
2732 # First put in the frame
2742 <volumeref ref="volAPAFrameYOuterSupport\-$APA_i"/>
2743 <position name="posAPAFrameYOuterSupportNeg\-$APA_i" unit="cm"
2744 x="$APAFrameCenter_x - ($APAFrameYOuterSupport_x + $APAFrameYInnerSupport_x/2 - $EdgeFrameSteelThickness/2)"
2745 y="$APAFrameCenter_y"
2746 z="$APAFrameCenter_z"/>
2747 <rotationref ref="rIdentity"/>
2750 <volumeref ref="volAPAFrameYOuterSupport\-$APA_i"/>
2751 <position name="posAPAFrameYOuterSupportPos\-$APA_i" unit="cm"
2752 x="$APAFrameCenter_x + ($APAFrameYOuterSupport_x + $APAFrameYInnerSupport_x/2 - $EdgeFrameSteelThickness/2)"
2753 y="$APAFrameCenter_y"
2754 z="$APAFrameCenter_z"/>
2755 <rotationref ref="rIdentity"/>
2760 <volumeref ref="volAPAFrameYSide\-$APA_i"/>
2761 <position name="posAPAFrameYSideNeg\-$_[3]" unit="cm"
2762 x="$APAFrameCenter_x"
2763 y="$APAFrameCenter_y"
2764 z="$APAFrameCenter_z - $APAFrame_z/2 + $APAFrameYSide_z/2"/>
2765 <rotationref ref="rIdentity"/>
2768 <volumeref ref="volAPAFrameYSide\-$APA_i"/>
2769 <position name="posAPAFrameYSidePos\-$_[3]" unit="cm"
2770 x="$APAFrameCenter_x"
2771 y="$APAFrameCenter_y"
2772 z="$APAFrameCenter_z + $APAFrame_z/2 - $APAFrameYSide_z/2"/>
2773 <rotationref ref="rIdentity"/>
2776 <volumeref ref="volAPAFrameZSide\-$APA_i"/>
2777 <position name="posAPAFrameZSidePos\-$_[3]" unit="cm"
2778 x="$APAFrameCenter_x"
2779 y="$APAFrameCenter_y + $APAFrame_y[$APA_i]/2 - $APAFrameZSide_y/2"
2780 z="$APAFrameCenter_z"/>
2781 <rotationref ref="rIdentity"/>
2784 <volumeref ref="volAPAFrameZSide\-$APA_i"/>
2785 <position name="posAPAFrameZSideNeg\-$_[3]" unit="cm"
2786 x="$APAFrameCenter_x"
2787 y="$APAFrameCenter_y - $APAFrame_y[$APA_i]/2 + $APAFrameZSide_y/2"
2788 z="$APAFrameCenter_z"/>
2789 <rotationref ref="rIdentity"/>
2793 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2794 - Add the *parts* of the G10 boards that exist directly in volCryostat.
2795 - There are two boards on each the up and downstream end,
2796 one each to wrap the U and V views around the APA frame
2797 - There are 4 on the bottom which anchor the U V and Z wires and the grid plane
2798 - The rest of the parts of the G10 boards must be placed directly in volTPC -->
2801 <volumeref ref="volG10BoardYSideCenterSeg\-$APA_i"/>
2802 <position name="posG10BoardYSideCenterSeg\-Vup\-$APA_i" unit="cm"
2803 x="$APAFrameCenter_x"
2804 y="$APAFrameCenter_y"
2805 z="$APAFrameCenter_z - $APAFrame_z/2 - (0+.5)*($G10BoardYSide_z)"/>
2806 <rotationref ref="rIdentity"/>
2809 <volumeref ref="volG10BoardYSideCenterSeg\-$APA_i"/>
2810 <position name="posG10BoardYSideCenterSeg\-Uup\-$APA_i" unit="cm"
2811 x="$APAFrameCenter_x"
2812 y="$APAFrameCenter_y"
2813 z="$APAFrameCenter_z - $APAFrame_z/2 - (1+.5)*($G10BoardYSide_z)"/>
2814 <rotationref ref="rIdentity"/>
2818 <volumeref ref="volG10BoardYSideCenterSeg\-$APA_i"/>
2819 <position name="posG10BoardYSideCenterSeg\-Vdown\-$APA_i" unit="cm"
2820 x="$APAFrameCenter_x"
2821 y="$APAFrameCenter_y"
2822 z="$APAFrameCenter_z + $APAFrame_z/2 + (0+.5)*($G10BoardYSide_z)"/>
2823 <rotationref ref="rIdentity"/>
2826 <volumeref ref="volG10BoardYSideCenterSeg\-$APA_i"/>
2827 <position name="posG10BoardYSideCenterSeg\-Udown\-$APA_i" unit="cm"
2828 x="$APAFrameCenter_x"
2829 y="$APAFrameCenter_y"
2830 z="$APAFrameCenter_z + $APAFrame_z/2 + (1+.5)*($G10BoardYSide_z)"/>
2831 <rotationref ref="rIdentity"/>
2835 <volumeref ref="volG10BoardZSideCenterSeg\-$APA_i"/>
2836 <position name="posG10BoardZSideCenterSeg\-Z\-$APA_i" unit="cm"
2837 x="$APAFrameCenter_x"
2839 z="$APAFrameCenter_z"/>
2840 <rotationref ref="rIdentity"/>
2843 <volumeref ref="volG10BoardZSideCenterSeg\-$APA_i"/>
2844 <position name="posG10BoardZSideCenterSeg\-V\-$APA_i" unit="cm"
2845 x="$APAFrameCenter_x"
2847 z="$APAFrameCenter_z"/>
2848 <rotationref ref="rIdentity"/>
2851 <volumeref ref="volG10BoardZSideCenterSeg\-$APA_i"/>
2852 <position name="posG10BoardZSideCenterSeg\-U\-$APA_i" unit="cm"
2853 x="$APAFrameCenter_x"
2855 z="$APAFrameCenter_z"/>
2856 <rotationref ref="rIdentity"/>
2859 <volumeref ref="volG10BoardZSideCenterSeg\-$APA_i"/>
2860 <position name="posG10BoardZSideCenterSeg\-Grid\-$APA_i" unit="cm"
2861 x="$APAFrameCenter_x"
2862 y="$posG10ZSideGrid_y"
2863 z="$APAFrameCenter_z"/>
2864 <rotationref ref="rIdentity"/>
2872 # Now loop through paddle y positions and place them
2873 #for( $p=0; $p<$nPaddlesInAPA[$APA_i]; $p++ ){
2875 #if($nPaddlesInAPA[$APA_i]!=1)
2880 # <volumeref ref="volOpDetSensitive"/>
2881 # <position name="posPaddle\-$p\-APA\-$APA_i" unit="cm"
2882 # x="$APAFrameCenter_x"
2883 # y="$APAFrameCenter_y - $APAHeight[$APA_i]/2 + $PaddleYPositions[$APA_i][$p]"
2884 # z="$APAFrameCenter_z"/>
2885 # <rotationref ref="rIdentity"/>
2891 case 0 { place_bar(2);
2894 case 1 { place_bar(1); }
2895 case 2 { place_fiber(1); }
2896 case 3 { place_bar(4);
2909 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2910 #++++++++++++++++++++++++++++++++++++++ solid_CPA +++++++++++++++++++++++++++++++++++++
2911 #++++++++++++++++++++++++++++++++++++++++ vol_CPA +++++++++++++++++++++++++++++++++++++
2912 #++++++++++++++++++++++++++++++++++++++ place_CPA +++++++++++++++++++++++++++++++++++++
2913 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2915 # Must be called only within gen_Cryostat(),
2924 <box name="Cathode" lunit="cm"
2929 <tube name="CPATubeYSide"
2937 <tube name="CPATubeZSide"
2955 <volume name="volCathode">
2956 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
2957 <solidref ref="Cathode"/>
2959 <volume name="volCPATubeYSide">
2960 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
2961 <solidref ref="CPATubeYSide"/>
2963 <volume name="volCPATubeZSide">
2964 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
2965 <solidref ref="CPATubeZSide"/>
2978 $cpaCenter_x = $_[1];
2979 $cpaCenter_y = $_[2];
2980 $cpaCenter_z = $_[3];
2986 <volumeref ref="volCathode"/>
2987 <position name="posCathode\-$cpa" unit="cm"
2988 x="$cpaCenter_x - $Cathode_x/2"
2991 <rotationref ref="rIdentity"/>
2995 Curious... The CPATube_OD used here should be CPATube_OD/2,
2996 but that causes a baffling overlap. look into later!
3000 <volumeref ref="volCPATubeYSide"/>
3001 <position name="posCPATubeYSideUp\-$cpa" unit="cm"
3004 z="$cpaCenter_z - $Cathode_z/2 - $CPATube_OD"/>
3005 <rotationref ref="rPlus90AboutX"/>
3008 <volumeref ref="volCPATubeYSide"/>
3009 <position name="posCPATubeYSideDown\-$cpa" unit="cm"
3012 z="$cpaCenter_z + $Cathode_z/2 + $CPATube_OD"/>
3013 <rotationref ref="rPlus90AboutX"/>
3017 <volumeref ref="volCPATubeZSide"/>
3018 <position name="posCPATubeZSideBottom\-$cpa" unit="cm"
3020 y="$cpaCenter_y - $Cathode_y/2 - $CPATube_OD"
3022 <rotationref ref="rIdentity"/>
3025 <volumeref ref="volCPATubeZSide"/>
3026 <position name="posCPATubeZSideTop\-$cpa" unit="cm"
3028 y="$cpaCenter_y + $Cathode_y/2 + $CPATube_OD"
3030 <rotationref ref="rIdentity"/>
3043 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3044 #+++++++++++++++++++++++++++++++++++++ gen_Enclosure +++++++++++++++++++++++++++++++++++++
3045 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3050 # Create the detector enclosure fragment file name,
3051 # add file to list of output GDML fragments,
3053 $ENCL = "35t_DetEnclosure" . $suffix . ".gdml";
3054 push (@gdmlFiles, $ENCL);
3055 $ENCL = ">" . $ENCL;
3056 open(ENCL) or die("Could not open file $ENCL for writing");
3059 # The standard XML prefix and starting the gdml
3061 <?xml version='1.0'?>
3067 $TopSteelShell_x = $Argon_x - $NeckInside_x;
3069 $FoamSouth_y = $Argon_y + $NeckInside_y + 2*$SteelShellThickness;
3070 $FoamTop_x = $Argon_x - $NeckInside_x;
3071 $NeckConcreteShell_x = $TotalPadding + 2*$SteelShellThickness + $NeckInside_x + $FoamPadding;
3073 $TrenchTopConcrete_x = ($DetEnc_x - $CryoWithPadding_x)/2;
3075 # All the detector enclosure solids.
3079 <box name="DetEnclosure" lunit="cm"
3084 <trd name="AuxDetTrap" lunit="cm"
3085 x1="$AuxDetScintillatorLongSide" x2="$AuxDetScintillatorShortSide"
3086 y1="$AuxDetScintillatorThickness" y2="$AuxDetScintillatorThickness"
3087 z="$AuxDetScintillatorHeight"/>
3089 <box name="TrenchBottomConcrete" lunit="cm"
3093 <box name="TrenchBottomConcreteSubtract" lunit="cm"
3095 y="$DetEnc_y - $TrenchWallThickness"
3096 z="$DetEnc_z - 2*$TrenchWallThickness"/>
3097 <subtraction name="TrenchBottomConcreteShell">
3098 <first ref="TrenchBottomConcrete"/>
3099 <second ref="TrenchBottomConcreteSubtract"/>
3100 <position name="posHoleInTrench" unit="cm" x="0" y="$TrenchWallThickness/2" z="0"/>
3103 <box name="TrenchTopConcrete" lunit="cm"
3104 x="$TrenchTopConcrete_x"
3105 y="$TrenchWallThickness"
3106 z="$DetEnc_z - 2*$TrenchWallThickness"/>
3109 <box name="BottomSteel" lunit="cm"
3110 x="$Cryostat_x + 2*$SteelShellThickness"
3111 y="$Cryostat_y + $SteelShellThickness"
3112 z="$Cryostat_z + 2*$SteelShellThickness"/>
3113 <subtraction name="BottomSteelShell">
3114 <first ref="BottomSteel"/>
3115 <second ref="Cryostat"/>
3116 <position name="posLArInShell" unit="cm" x="0" y="$SteelShellThickness/2" z="0"/>
3120 <box name="Neck" lunit="cm"
3121 x="$NeckInside_x + 2*$SteelShellThickness"
3122 y="$NeckInside_y + $SteelShellThickness"
3123 z="$Cryostat_z + 2*$SteelShellThickness"/>
3124 <box name="NeckArgon" lunit="cm"
3128 <subtraction name="NeckSteelShell">
3130 <second ref="NeckArgon"/>
3131 <position name="posLArInNeckShell" unit="cm" x="0" y="-$SteelShellThickness/2" z="0"/>
3135 <box name="TopSteelShell" lunit="cm"
3136 x="$TopSteelShell_x"
3137 y="$SteelShellThickness"
3138 z="$Cryostat_z + 2*$SteelShellThickness"/>
3141 <box name="FoamSouth" lunit="cm"
3144 z="$Argon_z + 2*$SteelShellThickness + 2*$FoamPadding"/>
3146 <box name="FoamNorth" lunit="cm"
3148 y="$Argon_y + 2*$SteelShellThickness"
3149 z="$Argon_z + 2*$SteelShellThickness + 2*$FoamPadding"/>
3151 <box name="FoamEastWest" lunit="cm"
3152 x="$Argon_x + 2*$SteelShellThickness"
3153 y="$Argon_y + 2*$SteelShellThickness"
3156 <box name="FoamEastWestNeck" lunit="cm"
3157 x="$NeckInside_x + 2*$SteelShellThickness"
3158 y="$NeckInside_y + $SteelShellThickness"
3161 <box name="FoamBottom" lunit="cm"
3162 x="$Argon_x + 2*$SteelShellThickness + 2*$FoamPadding"
3164 z="$Argon_z + 2*$SteelShellThickness + 2*$FoamPadding"/>
3166 <box name="FoamTop" lunit="cm"
3169 z="$Argon_z + 2*$SteelShellThickness + 2*$FoamPadding"/>
3171 <box name="FoamNorthNeck" lunit="cm"
3174 z="$Argon_z + 2*$SteelShellThickness + 2*$FoamPadding"/>
3177 <box name="BottomConcrete" lunit="cm"
3178 x="$Argon_x + 2*($SteelShellThickness+$FoamPadding) + 2*$ConcretePadding"
3179 y="$Argon_y + 2*($SteelShellThickness+$FoamPadding) + $ConcretePadding"
3180 z="$Argon_z + 2*($SteelShellThickness+$FoamPadding) + 2*$ConcretePadding"/>
3181 <box name="BottomConcreteSubtract" lunit="cm"
3182 x="$Argon_x + 2*($SteelShellThickness+$FoamPadding)"
3183 y="$Argon_y + 2*($SteelShellThickness+$FoamPadding)"
3184 z="$Argon_z + 2*($SteelShellThickness+$FoamPadding)"/>
3185 <subtraction name="BottomConcreteShell">
3186 <first ref="BottomConcrete"/>
3187 <second ref="BottomConcreteSubtract"/>
3188 <position name="posHoleInConcrete" unit="cm" x="0" y="$ConcretePadding/2" z="0"/>
3192 <box name="NeckConcrete" lunit="cm"
3193 x="$NeckConcreteShell_x"
3194 y="$NeckInside_y + $SteelShellThickness - $FoamPadding"
3195 z="$Cryostat_z + 2*($SteelShellThickness+$FoamPadding) + 2*$ConcretePadding"/>
3196 <box name="NeckConcreteSubtract" lunit="cm"
3197 x="$NeckInside_x + 2*($SteelShellThickness+$FoamPadding)"
3198 y="$NeckInside_y + $SteelShellThickness - $FoamPadding"
3199 z="$Cryostat_z + 2*($SteelShellThickness+$FoamPadding)"/>
3200 <subtraction name="NeckConcreteShell">
3201 <first ref="NeckConcrete"/>
3202 <second ref="NeckConcreteSubtract"/>
3203 <position name="posHoleInNeckConcrete" unit="cm" x="-$ConcretePadding/2" y="0" z="0"/>
3213 # Detector enclosure structure
3217 <volume name="volBotSteelShell">
3218 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
3219 <solidref ref="BottomSteelShell"/>
3222 <volume name="volTopSteelShell">
3223 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
3224 <solidref ref="TopSteelShell"/>
3227 <volume name="volNeckSteelShell">
3228 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
3229 <solidref ref="NeckSteelShell"/>
3232 <volume name="volNeck">
3233 <materialref ref="ArGas"/>
3234 <solidref ref="Neck"/>
3236 <volumeref ref="volNeckSteelShell"/>
3237 <position name="posNeckSteelShell" unit="cm" x="0" y="0" z="0"/>
3242 <volume name="volFoamSouth">
3243 <materialref ref="polyurethane_foam"/>
3244 <solidref ref="FoamSouth"/>
3246 <volume name="volFoamNorth">
3247 <materialref ref="polyurethane_foam"/>
3248 <solidref ref="FoamNorth"/>
3250 <volume name="volFoamEastWest">
3251 <materialref ref="polyurethane_foam"/>
3252 <solidref ref="FoamEastWest"/>
3254 <volume name="volFoamEastWestNeck">
3255 <materialref ref="polyurethane_foam"/>
3256 <solidref ref="FoamEastWestNeck"/>
3258 <volume name="volFoamBottom">
3259 <materialref ref="polyurethane_foam"/>
3260 <solidref ref="FoamBottom"/>
3262 <volume name="volFoamTop">
3263 <materialref ref="polyurethane_foam"/>
3264 <solidref ref="FoamTop"/>
3266 <volume name="volFoamNorthNeck">
3267 <materialref ref="polyurethane_foam"/>
3268 <solidref ref="FoamNorthNeck"/>
3271 <volume name="volBottomConcreteShell">
3272 <materialref ref="Concrete"/>
3273 <solidref ref="BottomConcreteShell"/>
3275 <volume name="volNeckConcreteShell">
3276 <materialref ref="Concrete"/>
3277 <solidref ref="NeckConcreteShell"/>
3280 <volume name="volTrenchBottomConcreteShell">
3281 <materialref ref="Concrete"/>
3282 <solidref ref="TrenchBottomConcreteShell"/>
3284 <volume name="volTrenchTopConcrete">
3285 <materialref ref="Concrete"/>
3286 <solidref ref="TrenchTopConcrete"/>
3290 for($i = 1; $i <= 13; ++$i){
3292 <volume name="volAuxDetBoxBSU-L1-$i" >
3293 <materialref ref="Acrylic"/>
3294 <solidref ref="AuxDetBoxBSU"/>
3298 for($i = 1; $i <= 9; ++$i){
3300 <volume name="volAuxDetBoxBSU-L2-$i" >
3301 <materialref ref="Acrylic"/>
3302 <solidref ref="AuxDetBoxBSU"/>
3306 for($i = 1; $i <= 16; ++$i){
3308 <volume name="volAuxDetBoxBSU-L3-$i" >
3309 <materialref ref="Acrylic"/>
3310 <solidref ref="AuxDetBoxBSU"/>
3314 for($i = 1; $i <= 10; ++$i){
3316 <volume name="volAuxDetBoxBSU-L4-$i" >
3317 <materialref ref="Acrylic"/>
3318 <solidref ref="AuxDetBoxBSU"/>
3323 for ($i=1; $i<=12; ++$i) {
3325 <volume name="volAuxDetTrap-South-$i" >
3326 <materialref ref="Acrylic"/>
3327 <solidref ref="AuxDetTrap"/>
3329 <volume name="volAuxDetTrap-North-$i" >
3330 <materialref ref="Acrylic"/>
3331 <solidref ref="AuxDetTrap"/>
3335 for ($i=1; $i<=10; ++$i) {
3337 <volume name="volAuxDetTrap-East-$i" >
3338 <materialref ref="Acrylic"/>
3339 <solidref ref="AuxDetTrap"/>
3341 <volume name="volAuxDetTrap-West-$i" >
3342 <materialref ref="Acrylic"/>
3343 <solidref ref="AuxDetTrap"/>
3349 <volume name="volDetEnclosure">
3350 <materialref ref="Air"/>
3351 <solidref ref="DetEnclosure"/>
3354 <volumeref ref="volCryostat"/>
3355 <position name="posCryo" unit="cm" x="$posCryoInDetEnc_x" y="$posCryoInDetEnc_y" z="$posCryoInDetEnc_z"/>
3359 <volumeref ref="volNeck"/>
3360 <position name="posNeck" unit="cm"
3361 x="$posCryoInDetEnc_x + $Argon_x/2 - $NeckInside_x/2"
3362 y="$posCryoInDetEnc_y + $Argon_y/2 + ($NeckInside_y + $SteelShellThickness)/2"
3363 z="$posCryoInDetEnc_z"/>
3366 <volumeref ref="volTopSteelShell"/>
3367 <position name="posTopSteelShell" unit="cm"
3368 x="$posCryoInDetEnc_x - $Argon_x/2 - $SteelShellThickness + $TopSteelShell_x/2"
3369 y="$posCryoInDetEnc_y + $Argon_y/2 + $SteelShellThickness/2"
3370 z="$posCryoInDetEnc_z"/>
3373 <volumeref ref="volBotSteelShell"/>
3374 <position name="posBotSteelShell" unit="cm"
3375 x="$posCryoInDetEnc_x"
3376 y="$posCryoInDetEnc_y - $SteelShellThickness/2"
3377 z="$posCryoInDetEnc_z"/>
3382 <volumeref ref="volFoamSouth"/>
3383 <position name="posFoamSouth" unit="cm"
3384 x="$posCryoInDetEnc_x + $Argon_x/2 + $SteelShellThickness + $FoamPadding/2"
3385 y="$posCryoInDetEnc_y - $Argon_y/2 - $SteelShellThickness + $FoamSouth_y/2"
3386 z="$posCryoInDetEnc_z"/>
3389 <volumeref ref="volFoamNorth"/>
3390 <position name="posFoamNorth" unit="cm"
3391 x="$posCryoInDetEnc_x - $Argon_x/2 - $SteelShellThickness - $FoamPadding/2"
3392 y="$posCryoInDetEnc_y"
3393 z="$posCryoInDetEnc_z"/>
3396 <volumeref ref="volFoamEastWest"/>
3397 <position name="posFoamEast" unit="cm"
3398 x="$posCryoInDetEnc_x"
3399 y="$posCryoInDetEnc_y"
3400 z="$posCryoInDetEnc_z - $Argon_z/2 - $SteelShellThickness - $FoamPadding/2"/>
3403 <volumeref ref="volFoamEastWest"/>
3404 <position name="posFoamWest" unit="cm"
3405 x="$posCryoInDetEnc_x"
3406 y="$posCryoInDetEnc_y"
3407 z="$posCryoInDetEnc_z + $Argon_z/2 + $SteelShellThickness + $FoamPadding/2"/>
3410 <volumeref ref="volFoamEastWestNeck"/>
3411 <position name="posFoamEastNeck" unit="cm"
3412 x="$posCryoInDetEnc_x + $Argon_x/2 - $NeckInside_x/2"
3413 y="$posCryoInDetEnc_y + $Argon_y/2 + ($NeckInside_y + $SteelShellThickness)/2"
3414 z="$posCryoInDetEnc_z - $Argon_z/2 - $SteelShellThickness - $FoamPadding/2"/>
3417 <volumeref ref="volFoamEastWestNeck"/>
3418 <position name="posFoamWestNeck" unit="cm"
3419 x="$posCryoInDetEnc_x + $Argon_x/2 - $NeckInside_x/2"
3420 y="$posCryoInDetEnc_y + $Argon_y/2 + ($NeckInside_y + $SteelShellThickness)/2"
3421 z="$posCryoInDetEnc_z + $Argon_z/2 + $SteelShellThickness + $FoamPadding/2"/>
3424 <volumeref ref="volFoamBottom"/>
3425 <position name="posFoamBottom" unit="cm"
3426 x="$posCryoInDetEnc_x"
3427 y="$posCryoInDetEnc_y - $Argon_y/2 - $SteelShellThickness - $FoamPadding/2"
3428 z="$posCryoInDetEnc_z"/>
3431 <volumeref ref="volFoamTop"/>
3432 <position name="posFoamTop" unit="cm"
3433 x="$posCryoInDetEnc_x - $Argon_x/2 - $SteelShellThickness - $FoamPadding + $FoamTop_x/2"
3434 y="$posCryoInDetEnc_y + $Argon_y/2 + $SteelShellThickness + $FoamPadding/2"
3435 z="$posCryoInDetEnc_z"/>
3438 <volumeref ref="volFoamNorthNeck"/>
3439 <position name="posFoamNorthNeck" unit="cm"
3440 x="$posCryoInDetEnc_x + $Argon_x/2 - $NeckInside_x - $SteelShellThickness - $FoamPadding/2"
3441 y="$posCryoInDetEnc_y + $Argon_y/2 + $SteelShellThickness + $NeckInside_y/2"
3442 z="$posCryoInDetEnc_z"/>
3447 <volumeref ref="volBottomConcreteShell"/>
3448 <position name="posBottomConcreteShell" unit="cm"
3449 x="$posCryoInDetEnc_x"
3450 y="$posCryoInDetEnc_y - $ConcretePadding/2"
3451 z="$posCryoInDetEnc_z"/>
3454 <volumeref ref="volNeckConcreteShell"/>
3455 <position name="posNeckConcreteShell" unit="cm"
3456 x="$posCryoInDetEnc_x + $Argon_x/2 +$SteelShellThickness + $TotalPadding - $NeckConcreteShell_x/2"
3457 y="$posCryoInDetEnc_y + $Argon_y/2 + $FoamPadding + ($NeckInside_y + $SteelShellThickness - $FoamPadding)/2"
3458 z="$posCryoInDetEnc_z"/>
3464 <volumeref ref="volTrenchBottomConcreteShell"/>
3465 <position name="posTrenchConcrete" unit="cm" x="0" y="0" z="0"/>
3467 <!-- Concrete is too heavy for the roof
3469 <volumeref ref="volTrenchTopConcrete"/>
3470 <position name="posTrenchConcreteTop_Pos" unit="cm"
3471 x=" + $DetEnc_x/2 - $TrenchTopConcrete_x/2"
3472 y="$DetEnc_y/2 - $TrenchWallThickness/2"
3476 <volumeref ref="volTrenchTopConcrete"/>
3477 <position name="posTrenchConcreteTop_Neg" unit="cm"
3478 x=" - $DetEnc_x/2 + $TrenchTopConcrete_x/2"
3479 y="$DetEnc_y/2 - $TrenchWallThickness/2"
3488 # place the 12 North Wall AuxDets
3489 #$NorthWallInt_z = ((95+108)/2 - (35+48)/2)*$inch/5;
3490 $NorthWallInt_z = ( 274.32-(274.32-213.36)/4 - (88.9+121.92)/2 )/5;
3491 for ($i=1; $i<=12; ++$i)
3493 #$FromCryoCorner_z = (35+48)/2*$inch + (($i-1) % 6)*$NorthWallInt_z;
3494 $FromCryoCorner_z = (88.9+121.92)/2 + (($i-1) % 6)*$NorthWallInt_z;
3496 $rotation = "rAuxDetNSWallUp";
3497 if($i>6) { $FromCryoCorner_y = (259.08 + 0.12*$inch) + $AuxDetScintillatorHeight/2; }
3498 else { $FromCryoCorner_y = (66.04 + 0.12*$inch) + $AuxDetScintillatorHeight/2; }
3501 $rotation = "rAuxDetNSWallDown";
3502 if($i>6) { $FromCryoCorner_y = (325.12 - 0.12*$inch) - $AuxDetScintillatorHeight/2; }
3503 else { $FromCryoCorner_y = (132.08 - 0.12*$inch) - $AuxDetScintillatorHeight/2; }
3506 $posAuxDet_y = $posCryoInDetEnc_y - 375.92/2 + $FromCryoCorner_y;
3510 <volumeref ref="volAuxDetTrap-North-$i"/>
3511 <position name="posAuxDet-North-$i" unit="cm"
3512 x=" $posCryoInDetEnc_x - $CryoWithPadding_x/2 - $AuxDetHousingThickness/2"
3514 z=" $posCryoInDetEnc_z - 411.99/2 + $FromCryoCorner_z"/>
3515 <rotationref ref="$rotation"/>
3521 # place the 12 South Wall AuxDets
3522 #$SouthWallInt_z = ((96.5+109.6)/2 - (36.8+49.5)/2)*$inch/5;
3523 $SouthWallInt_z = ( (245.11+278.38)/2 - (93.47+(153.67-93.47)/4) )/5;
3524 for ($i=1; $i<=12; ++$i)
3526 #$FromCryoCorner_z = (96.5+109.6)/2*$inch - (($i-1) % 6)*$SouthWallInt_z;
3527 $FromCryoCorner_z = (245.11+278.38)/2 - (($i-1) % 6)*$SouthWallInt_z;
3529 $rotation = "rAuxDetNSWallUp";
3530 if($i>6) { $FromCryoCorner_y = (272.11 + 0.12*$inch) + $AuxDetScintillatorHeight/2; }
3531 else { $FromCryoCorner_y = (31.5 + 0.12*$inch) + $AuxDetScintillatorHeight/2; }
3534 $rotation = "rAuxDetNSWallDown";
3535 if($i>6) { $FromCryoCorner_y = (335.61 - 0.12*$inch) - $AuxDetScintillatorHeight/2; }
3536 else { $FromCryoCorner_y = (93.98 - 0.12*$inch) - $AuxDetScintillatorHeight/2; }
3539 $posAuxDet_y = $posCryoInDetEnc_y - 375.92/2 + $FromCryoCorner_y;
3543 <volumeref ref="volAuxDetTrap-South-$i"/>
3544 <position name="posAuxDet-South-$i" unit="cm"
3545 x=" $posCryoInDetEnc_x + $CryoWithPadding_x/2 + $AuxDetHousingThickness/2"
3547 z=" $posCryoInDetEnc_z - 411.99/2 + $FromCryoCorner_z"/>
3548 <rotationref ref="$rotation"/>
3554 # place the 10 East Wall AuxDets
3555 #$EastWallInt_x = ((136.7+149.9)/2 - (28.4+41.4)/2)*$inch/9;
3556 $EastWallInt_x = ( (347.48+380.75)/2 - (72.14+(133.1-72.14)/4) )/9;
3557 for ($i=1; $i<=10; ++$i)
3559 $FromCryoCorner_x = (347.48+380.75)/2 - ($i-1)*$EastWallInt_x;
3560 if($i%2==1){ $rotation = "rAuxDetEWWallUp";
3561 $FromCryoCorner_y = ( 47 + 0.12*$inch) + $AuxDetScintillatorHeight/2; }
3562 else { $rotation = "rAuxDetEWWallDown";
3563 $FromCryoCorner_y = (112.45 - 0.12*$inch) - $AuxDetScintillatorHeight/2; }
3565 $posAuxDet_y = $posCryoInDetEnc_y - 375.92/2 + $FromCryoCorner_y;
3569 <volumeref ref="volAuxDetTrap-East-$i"/>
3570 <position name="posAuxDet-East-$i" unit="cm"
3571 x=" $posCryoInDetEnc_x - 541.53/2 + $FromCryoCorner_x"
3573 z=" $posCryoInDetEnc_z - $CryoWithPadding_z/2 - $AuxDetHousingThickness/2"/>
3574 <rotationref ref="$rotation"/>
3581 # place the 10 West Wall AuxDets
3582 #$WestWallInt_x = ((134+147)/2 - (26.3+39.3)/2)*$inch/9;
3583 $WestWallInt_x = ( (373.38-(373.38-312.42)/2) - (66.11+99.82)/2 )/9;
3584 for ($i=1; $i<=10; ++$i)
3586 $FromCryoCorner_x = (66.11+99.82)/2 + ($i-1)*$WestWallInt_x;
3587 if($i%2==1){ $rotation = "rAuxDetEWWallUp";
3588 $FromCryoCorner_y = (264.44 + 0.12*$inch) + $AuxDetScintillatorHeight/2 }
3589 else { $rotation = "rAuxDetEWWallDown";
3590 $FromCryoCorner_y = (329.95 - 0.12*$inch) - $AuxDetScintillatorHeight/2 }
3592 $posAuxDet_y = $posCryoInDetEnc_y - 375.92/2 + $FromCryoCorner_y;
3596 <volumeref ref="volAuxDetTrap-West-$i"/>
3597 <position name="posAuxDet-West-$i" unit="cm"
3598 x=" $posCryoInDetEnc_x - 541.53/2 + $FromCryoCorner_x"
3600 z=" $posCryoInDetEnc_z + $CryoWithPadding_z/2 + $AuxDetHousingThickness/2"/>
3601 <rotationref ref="$rotation"/>
3607 # place the 13 Layer 1 telescope counters
3608 for ($i=1; $i<=13; ++$i)
3612 <volumeref ref="volAuxDetBoxBSU-L1-$i"/>
3613 <position name="posAuxDet-BSU-L1-$i" unit="cm"
3614 x="$BSULayer1_xpos[$i-1] - $OriginXSet"
3615 y="$BSULayer1_ypos - $OriginYSet"
3616 z="$BSULayer1_zpos - $OriginZSet"/>
3621 # place the 9 Layer 2 telescope counters
3622 for ($i=1; $i<=9; ++$i)
3626 <volumeref ref="volAuxDetBoxBSU-L2-$i"/>
3627 <position name="posAuxDet-BSU-L2-$i" unit="cm"
3628 x="$BSULayer2_xpos - $OriginXSet"
3629 y="$BSULayer2_ypos - $OriginYSet"
3630 z="$BSULayer2_zpos[$i-1] - $OriginZSet"/>
3631 <rotationref ref="rPlus90AboutY"/>
3649 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3650 #+++++++++++++++++++++++++++++++++++++++ gen_World +++++++++++++++++++++++++++++++++++++++
3651 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3656 # Create the WORLD fragment file name,
3657 # add file to list of output GDML fragments,
3659 $WORLD = "35t_World" . $suffix . ".gdml";
3660 push (@gdmlFiles, $WORLD);
3661 $WORLD = ">" . $WORLD;
3662 open(WORLD) or die("Could not open file $WORLD for writing");
3665 # The standard XML prefix and starting the gdml
3667 <?xml version='1.0'?>
3671 $Dirt_y = $OriginYSet + $World_y/2 + $DetEnc_y/2;
3673 # All the World solids.
3676 <box name="World" lunit="cm"
3681 <box name="AuxDetBoxBSU" lunit="cm"
3682 x="$AuxDetBSUScintWidth"
3683 y="$AuxDetBSUScintHeight"
3684 z="$AuxDetBSUScintLength"/>
3686 <box name="DirtBlock" lunit="cm"
3690 <subtraction name="DirtWithHole">
3691 <first ref="DirtBlock"/>
3692 <second ref="DetEnclosure"/>
3693 <position name="posHoleInDirt" unit="cm"
3695 y="$Dirt_y/2 - $DetEnc_y/2"
3714 <volume name="volDirtWithHole" >
3715 <materialref ref="Dirt"/>
3716 <solidref ref="DirtWithHole"/>
3718 <volume name="volBerm" >
3719 <materialref ref="Dirt"/>
3720 <solidref ref="Berm"/>
3723 <volume name="volWorld" >
3724 <materialref ref="Air"/>
3725 <solidref ref="World"/>
3727 <volumeref ref="volDetEnclosure"/>
3728 <position name="posDetEnclosure" unit="cm"
3734 <volumeref ref="volDirtWithHole"/>
3735 <position name="posDirtWithHole" unit="cm"
3737 y=" -$World_y/2 + $Dirt_y/2 "
3741 <volumeref ref="volBerm"/>
3742 <position name="posBerm" unit="cm"
3744 y="$OriginYSet + $DetEnc_y/2 "
3745 z="$OriginZSet + $DetEnc_z/2 + $BermRadius"/>
3746 <rotationref ref="rPlus90AboutY"/>
3752 # place the 16 Layer 3 telescope counters
3753 for ($i=1; $i<=16; ++$i)
3757 <volumeref ref="volAuxDetBoxBSU-L3-$i"/>
3758 <position name="posAuxDetBox-BSU-L3-$i" unit="cm"
3759 x="$BSULayer3_xpos[$i-1]"
3761 z="$BSULayer3_zpos"/>
3766 # place the 10 Layer 4 telescope counters
3767 for ($i=1; $i<=10; ++$i)
3771 <volumeref ref="volAuxDetBoxBSU-L4-$i"/>
3772 <position name="posAuxDetBox-BSU-L4-$i" unit="cm"
3775 z="$BSULayer4_zpos[$i-1]"/>
3776 <rotationref ref="rPlus90AboutY"/>
3781 # place the 16 Layer 5 telescope counters
3782 #for ($i=1; $i<=16; ++$i)
3787 # <volumeref ref="volAuxDetBoxBSU-L5-$i"/>
3788 # <position name="posAuxDet-BSU-L5-$i" unit="cm"
3789 # x="$BSULayer5_xpos[$i-1]"
3790 # y="$BSULayer5_ypos"
3791 # z="$BSULayer5_zpos"/>
3804 # make_gdml.pl will take care of <setup/>
3809 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3810 #++++++++++++++++++++++++++++++++++++ write_fragments ++++++++++++++++++++++++++++++++++++
3811 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3813 sub write_fragments()
3815 # This subroutine creates an XML file that summarizes the the subfiles output
3816 # by the other sub routines - it is the input file for make_gdml.pl which will
3817 # give the final desired GDML file. Specify its name with the output option.
3818 # (you can change the name when running make_gdml)
3820 if ( ! defined $output )
3822 $output = "-"; # write to STDOUT
3825 # Set up the output file.
3826 $OUTPUT = ">" . $output;
3827 open(OUTPUT) or die("Could not open file $OUTPUT");
3830 <?xml version='1.0'?>
3832 <!-- Input to Geometry/gdml/make_gdml.pl; define the GDML fragments
3833 that will be zipped together to create a detector description.
3840 <!-- These files contain GDML <constant></constant>
3841 blocks. They are read in separately, so they can be
3842 interpreted into the remaining GDML. See make_gdml.pl for
3848 foreach $filename (@defFiles)
3851 <filename> $filename </filename>
3861 <!-- The GDML file fragments to be zipped together. -->
3865 foreach $filename (@gdmlFiles)
3868 <filename> $filename </filename>
3883 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3884 #++++++++++++++++++++++++++++++++++++++ place_bars +++++++++++++++++++++++++++++++++++++++
3885 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3892 # for($j=1; $j<$numberofbars+1; $j++)
3895 $pos_ref_name="Bar" . $_[0] . "Pos";
3898 <volumeref ref="volOpDetSensitive_Bar"/>
3899 <positionref ref="$pos_ref_name"/>
3907 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3908 #++++++++++++++++++++++++++++++++++++++ place_plank ++++++++++++++++++++++++++++++++++++++
3909 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3917 $pos_ref_name="PlankPos";
3920 <volumeref ref="volOpDetSensitive_Plank"/>
3921 <positionref ref="$pos_ref_name"/>
3926 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3927 #++++++++++++++++++++++++++++++++++++++ place_fibers +++++++++++++++++++++++++++++++++++++
3928 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3933 <!-- 32 Fiber Module $_[0]-->
3937 ############################# Fiber ##############################
3938 $pos_ref_name="Fiber" . $_[0] . "Pos";
3941 <volumeref ref="volOpDetSensitive_Fiber"/>
3942 <positionref ref="$pos_ref_name"/>