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 #################################################
77 ##################################################################
78 ##################### wire plane parameters ######################
81 $UVReadoutBoardPitch = 0.698516;
82 #$UVReadoutBoardPitch = 0.7;
102 if($Pitch3mmVersion==1){
107 $UWirePitch = $UVReadoutBoardPitch*cos(deg2rad($UAng[0]));
108 $VWirePitch = $UVReadoutBoardPitch*cos(deg2rad($VAng[0]));
109 $XWirePitch = 0.449055;
113 ##################################################################
114 ######################## TPC parameters ##########################
116 $G10thickness = 0.3155;
118 #$G10thickness = $inch/8;
119 #$WrapCover = $inch/16;
123 $APAFrame_x = 5.0661; # ~2in -- this does not include the wire spacing
125 $TPCWireThickness = 0.015;
126 $TPCWirePlaneThickness = $TPCWireThickness;
128 if($Pitch3mmVersion==1){
129 $APAWirePlaneSpacing = 0.3;
131 $APAWirePlaneSpacing = 0.4730488 + $TPCWirePlaneThickness; # center to center spacing between all of the wire planes (g, u, v, and x)
134 # At creation of the plane volumes, the y and z boundaries will be increased
135 # by this much at each of the 4 edges. this is so the corners of the wire
136 # tubes don't extrude. For all other purposes, the plane dimensions stay as originally defined
137 $UVPlaneBoundNudge = $TPCWireThickness;
139 # The following are all widths about the same z center,
140 # namely the center of the corresponding APA
141 if($Pitch3mmVersion==1){
142 $Zactive_z = 49.8441 + $TPCWireThickness;
144 $Zactive_z = 112*$XWirePitch + $TPCWireThickness;
146 $APAFrame_z = 50.2619;
147 #$Vactive_z = 50.8929 - 2*$G10thickness;
148 #$Uactive_z = 51.5240 - 2*$G10thickness;
149 $Vactive_z = $APAFrame_z;
150 $Uactive_z = $APAFrame_z + 2*$G10thickness;
151 $APAphys_z = 51.8395;
154 # NUMBER VERTICAL WIRES = (Zview_z / pitch) + 1
155 # Since Zview_z is defined in docdb 7550 to be distance
156 # between outer vertical wires, + 1 since the floor of this
157 # division will be one under, giveing the amt of spaces, not wires
158 # POSITIONING: plane centered between +/- APAActive_z/2
160 # Let APAs be numbered as follows
162 # 1 - Middle (Middle Top)
163 # 2 - Smallest (Middle Bottom)
164 # APA heights and positions will be indexed by APA number
166 $ReadoutBoardOverlap = 7.61; #board overlaps wires, chop this off of their active height
168 $APAFrame_y[0] = 203.06;
169 $APAFrame_y[1] = 119.29;
170 $APAFrame_y[2] = 91.37;
171 $APAFrame_y[3] = $APAFrame_y[0];
173 for($apa = 0; $apa < 4; ++$apa){
175 # each view has its own G10 board to wrap around at the bottom
176 # and is covered by the readout board at the top
177 $Zactive_y[$apa] = $APAFrame_y[$apa] + 0*$G10thickness - $ReadoutBoardOverlap;
178 $Vactive_y[$apa] = $APAFrame_y[$apa] + 1*$G10thickness - $ReadoutBoardOverlap;
179 $Uactive_y[$apa] = $APAFrame_y[$apa] + 2*$G10thickness - $ReadoutBoardOverlap;
181 # the last G10 board for the grid, then a cover. This is not "covered" by the board
182 $APAphys_y[$apa] = $APAFrame_y[$apa] + 4*$G10thickness + $WrapCover;
186 $APAGap_y = 0.0845; #separation between APAs along the incident beam axis
187 $APAGap_z = 0.0845; #separation between APAs along the vertical axis
190 # include APA spacing in y and z so volTPCs touch in y and z directions with correct APA
191 # spacing - this makes for smoother event generation.
193 $TPCLongDrift_x = $LongDrift + 3*$APAWirePlaneSpacing + $TPCWirePlaneThickness;
194 $TPCShortDrift_x = $ShortDrift + 3*$APAWirePlaneSpacing + $TPCWirePlaneThickness;
195 #$TPC_z = $APAphys_z + $APAGap_z;
197 # height is the same for each
198 for($apa = 0; $apa < 4; ++$apa){
199 $TPC_y[$apa] = $APAphys_y[$apa] + $APAGap_y;
203 ############################################################
204 #################### AuxDet parameters #####################
206 $AuxDetHousingHeight = 27.72*$inch;
207 $AuxDetHousingLongSide = 13.07*$inch;
208 $AuxDetHousingShortSide = 10.64*$inch;
209 $AuxDetHousingThickness = 3;
210 $AuxDetScintillatorHeight = 24.80*$inch;
211 $AuxDetScintillatorLongSide = 12.82*$inch;
212 $AuxDetScintillatorShortSide = 10.65*$inch;
213 $AuxDetScintillatorThickness = 0.95;
215 # email from Michelle:
216 # the housing (AL box) is 13.07/10.64 x 27.72 (inches)
217 # the actual scintillator is 12.82/10.65 x 24.80 (inches)
220 # AuxDet configuration:
222 # / \ _______ / \ _______ } This spacing is only in the housing,
223 # / \\ // \\ / so it is not implimented in AuDet
224 #/______\\ //______\\ / which only represents the scintillator
228 # email from Michelle:
229 # Assume that the telescope scintillator is a rectangle, 64 3/4" x 6 5/8" x 3/4".
231 $AuxDetBSUScintWidth = (6+5/8)*$inch;
232 $AuxDetBSUScintHeight = 0.75*$inch;
233 $AuxDetBSUScintLength = 64.75*$inch;
236 # these positions pulled from a coordinate system with positive x and z are reversed
237 # positions are from a particular corner of the scintillators
238 ############################
239 ############################
240 @BSULayer1_xpos = ( 16.21, 9.46, 2.71, -4.04,
241 -17.33, -24.08, -30.83, -37.58,
242 -44.33, -51.08, -57.83, -64.58, -71.33 );
243 for($i = 0; $i < 13; ++$i){
244 $BSULayer1_xpos[$i] *= -$inch; # negative reverses coordinate system back
245 $BSULayer1_xpos[$i] -= $AuxDetBSUScintWidth/2; # move to center of volume
247 $BSULayer1_ypos = 75.14*$inch;
248 $BSULayer1_zpos = -1.21*$inch;
249 $BSULayer1_zpos = -1*$BSULayer1_zpos + $AuxDetBSUScintLength/2; # correct coordinates and move to center of scint
250 ############################
251 ############################
252 $BSULayer2_xpos = -67.24*$inch;
253 $BSULayer2_xpos = -1*$BSULayer2_xpos - $AuxDetBSUScintLength/2;
254 $BSULayer2_ypos = 89.49*$inch;
255 #@BSULayer2_zpos = ( -0.56, -7.31, -18.84, -25.59,
256 # -32.34, -39.09, -45.84, -52.59, -59.34 );
257 # assume pitch of 6.75:
258 @BSULayer2_zpos = ( 6.19, -0.56, -7.31, -18.84, -25.59,
259 -32.34, -39.09, -45.84, -52.59, -59.34 );
260 for($i = 0; $i < 10; ++$i){
261 $BSULayer2_zpos[$i] *= -$inch;
262 $BSULayer2_zpos[$i] -= $AuxDetBSUScintWidth/2;
264 ############################
265 ############################
266 @BSULayer3_xpos = ( 16.21, 9.46, 2.71, -4.04,
267 -10.79, -17.54, -24.29, -31.04,
268 -37.79, -44.54, -51.29, -58.04,
269 -64.79, -71.54, -78.29, -85.04 );
270 for($i = 0; $i < 16; ++$i){
271 $BSULayer3_xpos[$i] *= -$inch;
272 $BSULayer3_xpos[$i] -= $AuxDetBSUScintWidth/2;
274 $BSULayer3_ypos = 306.55*$inch;
275 $BSULayer3_zpos = -1.21*$inch;
276 $BSULayer3_zpos = -1*$BSULayer3_zpos + $AuxDetBSUScintLength/2;
277 ############################
278 ############################
279 $BSULayer4_xpos = -67.24*$inch;
280 $BSULayer4_xpos = -1*$BSULayer4_xpos - $AuxDetBSUScintLength/2;
281 $BSULayer4_ypos = 310.80*$inch;
282 @BSULayer4_zpos = ( 1.42, -5.34, -12.09, -18.84,
283 -25.59, -32.34, -39.09, -45.84,
285 for($i = 0; $i < 10; ++$i){
286 $BSULayer4_zpos[$i] *= -$inch;
287 $BSULayer4_zpos[$i] -= $AuxDetBSUScintWidth/2;
289 ############################
290 ## Layer 5 is not included in the final gdml
291 ############################
292 @BSULayer5_xpos = ( 16.21, 9.46, 2.71, -4.04,
293 -10.79, -17.54, -24.29, -31.04,
294 -37.79, -44.54, -51.29, -58.04,
295 -64.79, -71.54, -78.29, -85.04 );
296 for($i = 0; $i < 16; ++$i){
297 $BSULayer5_xpos[$i] *= -$inch;
298 $BSULayer5_xpos[$i] -= $AuxDetBSUScintWidth/2;
300 $BSULayer5_ypos = 314.55*$inch;
301 $BSULayer5_zpos = -1.21*$inch;
302 $BSULayer5_zpos = -1*$BSULayer5_zpos + $AuxDetBSUScintLength/2;
306 ############################################################
307 ############### Optical Detector parameters ################
309 # TODO: while the structure is exactly what we need, the parameters for
310 # paddle height and positioning are all placeholders
312 $nPaddlesInAPA[0] = 3;
313 $nPaddlesInAPA[1] = 1;
314 $nPaddlesInAPA[2] = 1;
315 $nPaddlesInAPA[3] = $nPaddlesInAPA[0]; # for now, this one is the same as 0
318 $LightPaddle_x = 0.476;
319 $LightPaddle_y = 56; # in cm from docDb 7803
320 $LightPaddle_z = 4*$inch;
322 # z and x are given by APA frame center.
323 # Hardcode y distance of each paddle from the
324 # bottom of the APA to the paddle y-center.
325 # To be used in make_APA like [apa#][paddle#]
327 $PaddleYPositions[0][0] = $APAFrame_y[0]/2; # this puts it in the y center
328 $PaddleYPositions[1][0] = $APAFrame_y[1] - 4*$inch - $LightPaddle_y/2;
329 $PaddleYPositions[2][0] = $APAFrame_y[2] - 4*$inch - $LightPaddle_y/2;
330 $PaddleYPositions[3][0] = $PaddleYPositions[0][0];
332 $PaddleYPositions[0][1] = $APAFrame_y[0] - 4*$inch - $LightPaddle_y/2;
333 $PaddleYPositions[3][1] = $PaddleYPositions[0][1];
335 $PaddleYPositions[0][2] = 4*$inch + $LightPaddle_y/2;
336 $PaddleYPositions[3][2] = $PaddleYPositions[0][2];
340 ##################################################################
341 ###################### Cryostat parameters #######################
344 $HeightGaseousAr = 14;
345 $FloorToSmallAPAFrame = 22.432;
346 $APAToTopCryo = 34.441;
347 $ClosestAPAToEastWall = 33.225; # To G10 cover, places all of the APAs in z
350 # Drift __________ Drift
353 # South | | | North Wall
358 $CPAToFloor = 26.955;
359 $CPAToCeiling = 36.010;
360 $CPAToEastWall = 27.994;
361 $CPAToWestWall = 76.234;
362 $CPAToSouthWall = 121.945;
363 $CPAToNorthWall = 22.907;
371 $CPATubeYSide_CenterToCenter = 166.269; # length in *z* direction
372 $CPATubeZSide_CenterToCenter = 207.532; # height in *y* direction
375 $Cathode_y = $CPATubeZSide_CenterToCenter - $CPATube_OD;
376 $Cathode_z = $CPATubeYSide_CenterToCenter - $CPATube_OD;
378 # Liquid and Gaseous Argon dimensions
379 $Argon_x = $TPCShortDrift_x
383 + $CPAToSouthWall + $CPATube_OD;
384 # note that the height y includes liquid and gaseous argon
385 $Argon_y = $APAphys_y[1]
389 + $FloorToSmallAPAFrame; # assuming mid_y+smallest_y > largest_y
391 $Argon_z = $CPATubeYSide_CenterToCenter
396 # try hardcoding parameters now that placements/dimensions are more accurate
397 # inside cryostat parameters
404 # Cryostat Dimensions
405 $SteelShellThickness = 0.5*$inch;
407 $Cryostat_x = $Argon_x; # move the steel shell out of volCryostat
408 $Cryostat_y = $Argon_y;
409 $Cryostat_z = $Argon_z;
413 ##################################################################
414 ################# Detector Enclosure parameters ##################
417 # Around the cryostat
418 $ConcretePadding = 30;
419 $FoamPadding = 39.75148;
420 $TotalPadding = $ConcretePadding + $FoamPadding;
421 $CryoWithPadding_x = $Argon_x + 2*$SteelShellThickness + 2*$TotalPadding;
422 $CryoWithPadding_y_noneck = $Argon_y + 2*$SteelShellThickness + 2*$FoamPadding + $ConcretePadding;
423 $CryoWithPadding_y_neck = ($Argon_y + $NeckInside_y) + 2*$SteelShellThickness + $TotalPadding;
424 $CryoWithPadding_z = $Argon_z + 2*$SteelShellThickness + 2*$TotalPadding;
426 print "CryoWithPadding: x=$CryoWithPadding_x, y=$CryoWithPadding_y_noneck ($CryoWithPadding_y_neck), z=$CryoWithPadding_z\n";
427 print "Cryo: x=$Argon_x, y=$Argon_y (+$NeckInside_y), z=$Argon_z\n";
430 # The actual enclosure
431 $TrenchLength = 9*$CryoWithPadding_x; # make this a reasonable length, still guessing
432 # quick measurments by Michelle Stancari, definitely good enough for now
433 $TrenchWallThickness = 14*$inch;
434 $WalkwayWidth = 34.5*$inch;
435 $EastWallToTrench = 10*$inch;
436 $PlateAToGroundLevel = 50*$inch;
439 # Bird's eye view of trench, walkway is on the west side
446 # | W|______||E +z <---| (+y out of screen)
454 # the container volume dimensions
455 $DetEnc_x = $TrenchLength;
456 $DetEnc_y = $TrenchWallThickness # use this for thickness of floor too
457 + $CryoWithPadding_y_noneck
458 + $PlateAToGroundLevel; # Make ground level the top of the DetEnc
459 $DetEnc_z = $CryoWithPadding_z
460 + $WalkwayWidth + $EastWallToTrench
461 + 2*$TrenchWallThickness;
464 $posCryoInDetEnc_x = 0;
465 $posCryoInDetEnc_y = - $DetEnc_y/2 + $TrenchWallThickness + $TotalPadding + $SteelShellThickness + $Argon_y/2;
466 $posCryoInDetEnc_z = - $DetEnc_z/2 + $TrenchWallThickness + $EastWallToTrench + $CryoWithPadding_z/2;
472 if (defined $helpcube)
474 $PosDirCubeSide = $ArToAr; #seems to be a good proportion
478 # The world dimensions are critical in the CRY cosmics generator
479 # following uboone's lead, make world much larger
480 # the cry helper needs a lot of room
483 $World_x = 5*$DetEnc_x;
484 $World_y = 25*$DetEnc_y;
485 $World_z = 25*$DetEnc_z;
487 $BermRadius = 5*12*$inch;
493 ##################################################################
494 ######################### TPC positions ##########################
497 $APA_Xcenter = $Argon_x/2
498 - $CPAToSouthWall # to center CPATube
503 # 0: One of the 2 identical tall APAs (Largest), call it the "upstream" one
504 $APACenter[0][0] = $APA_Xcenter;
505 $APACenter[0][1] = $Argon_y/2
506 - $APAToTopCryo # This subsumes the half vertical gap on the top...
507 - $APAphys_y[0]/2; # ... so use APAphys_y instead of TPC_y
508 $APACenter[0][2] = - $Argon_z/2
509 + $ClosestAPAToEastWall # ..Similarly, this already steps into the APAGap_z/2
513 # 1: The top middle APA (Mid)
514 $APACenter[1][0] = $APA_Xcenter;
515 $APACenter[1][1] = $Argon_y/2
518 $APACenter[1][2] = $APACenter[0][2]
519 + $APAphys_z + $APAGap_z;
521 # 2: The bottom middle APA (Smallest)
522 $APACenter[2][0] = $APA_Xcenter;
523 $APACenter[2][1] = $APACenter[1][1] # place relative to APA above it
527 $APACenter[2][2] = $APACenter[0][2]
528 + $APAphys_z + $APAGap_z;
530 # 3: The other tall APA, call it the "downstream" one
531 $APACenter[3][0] = $APACenter[0][0];
532 $APACenter[3][1] = $APACenter[0][1];
533 $APACenter[3][2] = $APACenter[1][2]
534 + $APAphys_z + $APAGap_z;
536 $posTPCShortDrift_x = $APACenter[0][0]
538 - $TPCShortDrift_x/2;
540 $posTPCLongDrift_x = $APACenter[0][0]
545 # see the define section
548 $OuterWireToCage = 2.33; # email from Russ
550 $TPCActive_z[0] = $APAphys_z
551 - ($APAphys_z-$Zactive_z)/2
554 $TPCActive_z[1] = $APAphys_z + $APAGap_z;
555 $TPCActive_z[2] = $APAphys_z + $APAGap_z;
556 $TPCActive_z[3] = $TPCActive_z[0];
558 $TPCCenter[0][2] = $APACenter[0][2]
562 $TPCCenter[1][2] = $APACenter[1][2];
563 $TPCCenter[2][2] = $APACenter[2][2];
564 $TPCCenter[3][2] = $APACenter[3][2]
572 # We want the world origin to be at the very front of the fiducial volume.
573 # move it to the front of the enclosure, then back it up through the concrete/foam,
574 # then through the Cryostat shell, then through the upstream dead LAr (including the
575 # dead LAr on the edge of the TPC, but this is covered in $UpstreamLArPadding).
576 # This is to be added to the z position of every volume in volWorld
580 + $TrenchWallThickness
583 + $SteelShellThickness
584 + $Argon_z/2 # at this point, we are at the center of the cryostat...
585 - $APACenter[0][2] # ... and now at the center of the East-most APA
588 # We want the world origin to be vertically centered between the two stacked APAs.
589 # (for now, that is, so the sorting works. this is quite asymetric, but then again
590 # so is the entire 35t geometry. this may be kept.)
591 # the cryostat sits on top of concrete padding, move the detector enclosure back
592 # and then move the world origin to the bottom of the smallest/lowest TPC, then
593 # and then up through the TPC, then back up to being centered between the stacked APAs.
594 # This is to be added to the y/x position of every volume in volWorld
598 - $TrenchWallThickness
600 - $SteelShellThickness
609 #$OriginXSet = $DetEnc_x/2
611 # - $SteelShellThickness
614 # - $ShortDrift ... through APA frame
617 - $CryoWithPadding_x/2
619 + $SteelShellThickness
620 + $Argon_x/2 # at this point, we are at the center of the cryostat...
621 - $APA_Xcenter # ... and now at the APA's center x coordinate
623 - 3*$APAWirePlaneSpacing
624 - $TPCWirePlaneThickness;
629 ## Correct Telescope Aux Det vertical position if necessary
631 if( $posCryoInDetEnc_y
633 + $SteelShellThickness
635 + $AuxDetBSUScintHeight/2 > $BSULayer1_ypos - $OriginYSet ){
637 $nudge_y = ( $posCryoInDetEnc_y
639 + $SteelShellThickness
641 + $AuxDetBSUScintHeight/2
642 + $OriginYSet ) - $BSULayer1_ypos;
644 print "--- NOTE: nudging telescope counters $nudge_y cm up to sit on top of GDML cryostat\n";
646 $BSULayer1_ypos += $nudge_y;
647 $BSULayer2_ypos += $nudge_y;
648 $BSULayer3_ypos += $nudge_y;
649 $BSULayer4_ypos += $nudge_y;
650 $BSULayer5_ypos += $nudge_y;
656 ##################################################################
657 ######################### CPA positions ##########################
660 # Drift __________ Drift
663 # South | | | North Wall
668 #$posCPAShortDrift_x = - $Argon_x/2 + $CPAToNorthWall + $CPATube_OD/2;
669 #$posCPALongDrift_x = $Argon_x/2 - $CPAToSouthWall - $CPATube_OD/2;
671 # ^^^ these would be ideal, but quick fix to check in
672 # v3 without overlaps:
674 #$posCPAShortDrift_x = - $Argon_x/2 + $CPAToNorthWall + $CPATube_OD/2;
675 #$posCPALongDrift_x = $Argon_x/2 - $CPAToSouthWall - $CPATube_OD/2;
676 $posCPAShortDrift_x = $posTPCShortDrift_x - $TPCShortDrift_x/2
677 - $CPATube_OD; #<-- temp overlap fix
678 $posCPALongDrift_x = $posTPCLongDrift_x + $TPCLongDrift_x/2
679 + $CPATube_OD; #<-- temp overlap fix
682 $posCPAShortDrift_y = - $Argon_y/2 + $CPAToFloor
683 + ($CPATubeZSide_CenterToCenter + $CPATube_OD)/2;
684 $posCPAShortDrift_z = - $Argon_z/2 + $CPAToEastWall
685 + ($CPATubeYSide_CenterToCenter + $CPATube_OD)/2;
687 $posCPALongDrift_y = $posCPAShortDrift_y;
688 $posCPALongDrift_z = $posCPAShortDrift_z;
694 ##################################################################
695 #################### Bar Fiber Module numbers ####################
696 $numberofbarmodules=4;
697 $numberoffibermodules=3;
698 $numberofplankmodules=1;
700 $PaddleCenterX=$APA_Xcenter;
701 $PaddleCenterY[0][0]=$APACenter[0][1]-$APAFrame_y[0]/2+ $PaddleYPositions[0][0];
702 $PaddleCenterY[0][1]=$APACenter[0][1]-$APAFrame_y[0]/2+ $PaddleYPositions[0][1];
703 $PaddleCenterY[0][2]=$APACenter[0][1]-$APAFrame_y[0]/2+ $PaddleYPositions[0][2];
704 $PaddleCenterY[1][0]=$APACenter[1][1]-$APAFrame_y[1]/2+ $PaddleYPositions[1][0];
705 $PaddleCenterY[2][0]=$APACenter[2][1]-$APAFrame_y[2]/2+ $PaddleYPositions[2][0];
706 $PaddleCenterY[3][0]=$PaddleCenterY[0][0];
707 $PaddleCenterY[3][1]=$PaddleCenterY[0][1];
708 $PaddleCenterY[3][2]=$PaddleCenterY[0][2];
709 $PaddleCenterZ[0]=$APACenter[0][2];
710 $PaddleCenterZ[1]=$APACenter[1][2];
711 $PaddleCenterZ[2]=$APACenter[2][2];
712 $PaddleCenterZ[3]=$APACenter[3][2];
715 #+++++++++++++++++++++++++ End defining variables ++++++++++++++++++++++++++
719 # run the sub routines that generate the fragments
721 gen_Define(); # generates definitions at beginning of GDML
722 gen_Materials(); # generates materials to be used
725 # gen_TPC( x dimension, y, z, string appended to TPC for name, APA number)
726 # generate the short drift and long drift sides of the APA as seperate TPCs
728 open(my $wout, '>', 'gdmlWireCenters.txt');
730 gen_TPC( $TPCLongDrift_x, $TPC_y[0], $TPCActive_z[0], 'LargestLongDriftUpstream', 0);
731 gen_TPC( $TPCShortDrift_x, $TPC_y[0], $TPCActive_z[0], 'LargestShortDriftUpstream', 0);
733 gen_TPC( $TPCLongDrift_x, $TPC_y[2], $TPCActive_z[2], 'SmallestLongDrift', 2);
734 gen_TPC( $TPCShortDrift_x, $TPC_y[2], $TPCActive_z[2], 'SmallestShortDrift', 2);
736 gen_TPC( $TPCLongDrift_x, $TPC_y[1], $TPCActive_z[1], 'MidLongDrift', 1);
737 gen_TPC( $TPCShortDrift_x, $TPC_y[1], $TPCActive_z[1], 'MidShortDrift', 1);
739 gen_TPC( $TPCLongDrift_x, $TPC_y[0], $TPCActive_z[3], 'LargestLongDriftDownstream', 3);
740 gen_TPC( $TPCShortDrift_x, $TPC_y[0], $TPCActive_z[3], 'LargestShortDriftDownstream', 3);
749 write_fragments(); # writes the XML input for make_gdml.pl
750 # which zips together the final GDML
754 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
755 #+++++++++++++++++++++++++++++++++++++++++ usage +++++++++++++++++++++++++++++++++++++++++
756 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
760 print "Usage: $0 [-h|--help] [-o|--output <fragments-file>] [-s|--suffix <string>]\n";
761 print " if -o is omitted, output goes to STDOUT; <fragments-file> is input to make_gdml.pl\n";
762 print " -s <string> appends the string to the file names; useful for multiple detector versions\n";
763 print " -h prints this message, then quits\n";
768 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
769 #++++++++++++++++++++++++++++++++++++++ gen_Define +++++++++++++++++++++++++++++++++++++++
770 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
775 # Create the <define> fragment file name,
776 # add file to list of fragments,
778 $DEF = "dune_10kT_Def" . $suffix . ".gdml";
779 push (@gdmlFiles, $DEF);
781 open(DEF) or die("Could not open file $DEF for writing");
785 <?xml version='1.0'?>
795 <position name="posOriginSet" unit="cm" x="$OriginXSet" y="$OriginYSet" z="$OriginZSet"/>
797 <position name="posTPCLargestShortDrift_Pos" unit="cm" x="$posTPCShortDrift_x" y="$APACenter[3][1]" z="$TPCCenter[3][2]"/>
798 <position name="posTPCLargestLongDrift_Pos" unit="cm" x="$posTPCLongDrift_x" y="$APACenter[3][1]" z="$TPCCenter[3][2]"/>
799 <position name="posTPCLargestShortDrift_Neg" unit="cm" x="$posTPCShortDrift_x" y="$APACenter[0][1]" z="$TPCCenter[0][2]"/>
800 <position name="posTPCLargestLongDrift_Neg" unit="cm" x="$posTPCLongDrift_x" y="$APACenter[0][1]" z="$TPCCenter[0][2]"/>
801 <position name="posTPCSmallestShortDrift" unit="cm" x="$posTPCShortDrift_x" y="$APACenter[2][1]" z="$TPCCenter[2][2]"/>
802 <position name="posTPCSmallestLongDrift" unit="cm" x="$posTPCLongDrift_x" y="$APACenter[2][1]" z="$TPCCenter[2][2]"/>
803 <position name="posTPCMidShortDrift" unit="cm" x="$posTPCShortDrift_x" y="$APACenter[1][1]" z="$TPCCenter[1][2]"/>
804 <position name="posTPCMidLongDrift" unit="cm" x="$posTPCLongDrift_x" y="$APACenter[1][1]" z="$TPCCenter[1][2]"/>
807 <position name="posCathodeLongDrift" unit="cm" x="$posCPAShortDrift_x" y="$posCPAShortDrift_y" z="$posCPAShortDrift_z"/>
808 <position name="posCathodeShortDrift" unit="cm" x="$posCPALongDrift_x" y="$posCPALongDrift_y" z="$posCPALongDrift_z"/>
810 <rotation name="rAuxDetNSWallUp" unit="deg" x="90" y="0" z="90"/>
811 <rotation name="rAuxDetNSWallDown" unit="deg" x="270" y="0" z="90"/>
812 <rotation name="rAuxDetEWWallUp" unit="deg" x="90" y="0" z="0"/>
813 <rotation name="rAuxDetEWWallDown" unit="deg" x="270" y="0" z="0"/>
815 <position name="posCenter" unit="cm" x="0" y="0" z="0"/>
816 <rotation name="rPlus90AboutX" unit="deg" x="90" y="0" z="0"/>
817 <rotation name="rPlus90AboutY" unit="deg" x="0" y="90" z="0"/>
818 <rotation name="rMinus90AboutY" unit="deg" x="0" y="270" z="0"/>
819 <rotation name="rMinus90AboutYMinus90AboutX" unit="deg" x="270" y="270" z="0"/>
820 <rotation name="rPlus180AboutY" unit="deg" x="0" y="180" z="0"/>
821 <rotation name="rPlus180AboutX" unit="deg" x="180" y="0" z="0"/>
822 <rotation name="rPlus180AboutXandY" unit="deg" x="180" y="180" z="0"/>
823 <rotation name="rIdentity" unit="deg" x="0" y="0" z="0"/>
826 ##################################################################
827 ###################### Bar Module Position #######################
828 for ($k=1; $k<$numberofbarmodules+1; ++$k)
830 if($k==1) {$APA_i=1;$p=0;$PD_zoffset=0;}
831 elsif($k==2) {$APA_i=0;$p=1;$PD_zoffset=0;}
832 elsif($k==3) {$APA_i=0;$p=2;$PD_zoffset=-0.00051;}
833 elsif($k==4) {$APA_i=3;$p=0;$PD_zoffset=0;}
835 #for ($j=1; $j<$numberofbars+1; ++$j)
837 #$bar_z=-4.11 + 2.74*($j-1)+$PaddleCenterZ[$APA_i];
838 $bar_z=$PaddleCenterZ[$APA_i]+2.794*1.5+$PD_zoffset;
839 $bar_name="Bar" . $k . "Pos";
841 <position name="$bar_name" x="$PaddleCenterX" y="$PaddleCenterY[$APA_i][$p]" z="$bar_z" unit="cm"/>
846 ##################################################################
847 ##################### Plank Module Position ######################
848 for ($k=1; $k<$numberofplankmodules+1; ++$k)
850 if($k==1) {$APA_i=3;$p=2;}
852 $plank_name="PlankPos";
854 <position name="$plank_name" x="$PaddleCenterX" y="$PaddleCenterY[$APA_i][$p]" z="$PaddleCenterZ[$APA_i]" unit="cm"/>
858 ##################################################################
859 ##################### Fiber Module Position ######################
861 for ($k=1; $k<$numberoffibermodules+1; ++$k)
863 if($k==1) {$APA_i=2;$p=0;$PD_zoffset=0;}
864 elsif($k==2) {$APA_i=0;$p=0;$PD_zoffset=0;}
865 elsif($k==3) {$APA_i=3;$p=1;$PD_zoffset=0.00051;}
867 $fiber_x=$PaddleCenterX+0.1445;
868 $fiber_y=$PaddleCenterY[$APA_i][$p];
869 $fiber_z=$PaddleCenterZ[$APA_i]+4.1905+$PD_zoffset;
871 $fiber_name="Fiber" . $k. "Pos";
873 <position name="$fiber_name" x="$fiber_x" y="$fiber_y" z="$fiber_z" unit="cm"/>
888 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
889 #+++++++++++++++++++++++++++++++++++++ gen_Materials +++++++++++++++++++++++++++++++++++++
890 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
895 # Create the <materials> fragment file name,
896 # add file to list of output GDML fragments,
898 $MAT = "dune_10kT_Materials" . $suffix . ".gdml";
899 push (@gdmlFiles, $MAT);
901 open(MAT) or die("Could not open file $MAT for writing");
906 <element name="videRef" formula="VACUUM" Z="1"> <atom value="1"/> </element>
907 <element name="hydrogen" formula="H" Z="1"> <atom value="1.0079"/> </element>
908 <element name="beryllium" formula="Be" Z="4"> <atom value="9.0121831"/> </element>
909 <element name="carbon" formula="C" Z="6"> <atom value="12.0107"/> </element>
910 <element name="nitrogen" formula="N" Z="7"> <atom value="14.0067"/> </element>
911 <element name="oxygen" formula="O" Z="8"> <atom value="15.999"/> </element>
912 <element name="sodium" formula="Na" Z="11"> <atom value="22.99"/> </element>
913 <element name="magnesium" formula="Mg" Z="12"> <atom value="24.305"/> </element>
914 <element name="aluminum" formula="Al" Z="13"> <atom value="26.9815"/> </element>
915 <element name="silicon" formula="Si" Z="14"> <atom value="28.0855"/> </element>
916 <element name="phosphorus" formula="P" Z="15"> <atom value="30.973"/> </element>
917 <element name="sulphur" formula="S" Z="16"> <atom value="32.065"/> </element>
918 <element name="argon" formula="Ar" Z="18"> <atom value="39.9480"/> </element>
919 <element name="potassium" formula="K" Z="19"> <atom value="39.0983"/> </element>
920 <element name="calcium" formula="Ca" Z="20"> <atom value="40.078"/> </element>
921 <element name="titanium" formula="Ti" Z="22"> <atom value="47.867"/> </element>
922 <element name="chromium" formula="Cr" Z="24"> <atom value="51.9961"/> </element>
923 <element name="iron" formula="Fe" Z="26"> <atom value="55.8450"/> </element>
924 <element name="nickel" formula="Ni" Z="28"> <atom value="58.6934"/> </element>
925 <element name="copper" formula="Cu" Z="29"> <atom value="63.546"/> </element>
926 <element name="bromine" formula="Br" Z="35"> <atom value="79.904"/> </element>
928 <material name="Vacuum" formula="Vacuum">
929 <D value="1.e-25" unit="g/cm3"/>
930 <fraction n="1.0" ref="videRef"/>
933 <material name="ALUMINUM_Al" formula="ALUMINUM_Al">
934 <D value="2.6990" unit="g/cm3"/>
935 <fraction n="1.0000" ref="aluminum"/>
938 <material name="SILICON_Si" formula="SILICON_Si">
939 <D value="2.3300" unit="g/cm3"/>
940 <fraction n="1.0000" ref="silicon"/>
943 <material name="epoxy_resin" formula="C38H40O6Br4">
944 <D value="1.1250" unit="g/cm3"/>
945 <composite n="38" ref="carbon"/>
946 <composite n="40" ref="hydrogen"/>
947 <composite n="6" ref="oxygen"/>
948 <composite n="4" ref="bromine"/>
951 <material name="SiO2" formula="SiO2">
952 <D value="2.2" unit="g/cm3"/>
953 <composite n="1" ref="silicon"/>
954 <composite n="2" ref="oxygen"/>
957 <material name="Al2O3" formula="Al2O3">
958 <D value="3.97" unit="g/cm3"/>
959 <composite n="2" ref="aluminum"/>
960 <composite n="3" ref="oxygen"/>
963 <material name="Polystyrene" formula="C8H8">
964 <D value="1.05" unit="g/cm3"/>
965 <composite n="8" ref="carbon"/>
966 <composite n="8" ref="hydrogen"/>
969 <material name="Fe2O3" formula="Fe2O3">
970 <D value="5.24" unit="g/cm3"/>
971 <composite n="2" ref="iron"/>
972 <composite n="3" ref="oxygen"/>
975 <material name="CaO" formula="CaO">
976 <D value="3.35" unit="g/cm3"/>
977 <composite n="1" ref="calcium"/>
978 <composite n="1" ref="oxygen"/>
981 <material name="MgO" formula="MgO">
982 <D value="3.58" unit="g/cm3"/>
983 <composite n="1" ref="magnesium"/>
984 <composite n="1" ref="oxygen"/>
987 <material name="Na2O" formula="Na2O">
988 <D value="2.27" unit="g/cm3"/>
989 <composite n="2" ref="sodium"/>
990 <composite n="1" ref="oxygen"/>
993 <material name="TiO2" formula="TiO2">
994 <D value="4.23" unit="g/cm3"/>
995 <composite n="1" ref="titanium"/>
996 <composite n="2" ref="oxygen"/>
999 <material name="FeO" formula="FeO">
1000 <D value="5.745" unit="g/cm3"/>
1001 <composite n="1" ref="iron"/>
1002 <composite n="1" ref="oxygen"/>
1005 <material name="CO2" formula="CO2">
1006 <D value="1.562" unit="g/cm3"/>
1007 <composite n="1" ref="carbon"/>
1008 <composite n="2" ref="oxygen"/>
1011 <material name="P2O5" formula="P2O5">
1012 <D value="1.562" unit="g/cm3"/>
1013 <composite n="2" ref="phosphorus"/>
1014 <composite n="5" ref="oxygen"/>
1017 <material formula=" " name="DUSEL_Rock">
1018 <D value="2.82" unit="g/cm3"/>
1019 <fraction n="0.5267" ref="SiO2"/>
1020 <fraction n="0.1174" ref="FeO"/>
1021 <fraction n="0.1025" ref="Al2O3"/>
1022 <fraction n="0.0473" ref="MgO"/>
1023 <fraction n="0.0422" ref="CO2"/>
1024 <fraction n="0.0382" ref="CaO"/>
1025 <fraction n="0.0240" ref="carbon"/>
1026 <fraction n="0.0186" ref="sulphur"/>
1027 <fraction n="0.0053" ref="Na2O"/>
1028 <fraction n="0.00070" ref="P2O5"/>
1029 <fraction n="0.0771" ref="oxygen"/>
1032 <material name="fibrous_glass">
1033 <D value="2.58" unit="g/cm3"/>
1034 <fraction n="0.600" ref="SiO2"/>
1035 <fraction n="0.118" ref="Al2O3"/>
1036 <fraction n="0.001" ref="Fe2O3"/>
1037 <fraction n="0.224" ref="CaO"/>
1038 <fraction n="0.034" ref="MgO"/>
1039 <fraction n="0.010" ref="Na2O"/>
1040 <fraction n="0.013" ref="TiO2"/>
1043 <!-- The following fractional components are placeholders,
1044 to be fixed (though they have very little effect,
1045 as long as the density is correct) -->
1046 <material name="polyurethane_foam">
1047 <D value=".13" unit="g/cm3"/>
1048 <fraction n="0.600" ref="SiO2"/>
1049 <fraction n="0.118" ref="Al2O3"/>
1050 <fraction n="0.001" ref="Fe2O3"/>
1051 <fraction n="0.224" ref="CaO"/>
1052 <fraction n="0.034" ref="MgO"/>
1053 <fraction n="0.010" ref="Na2O"/>
1054 <fraction n="0.013" ref="TiO2"/>
1057 <!-- for the cryostat foam insulation -->
1058 <material name="R-PUF">
1059 <D value=".2525" unit="g/cm3"/>
1060 <fraction n="0.95" ref="polyurethane_foam"/>
1061 <fraction n="0.05" ref="fibrous_glass"/>
1064 <material name="FR4">
1065 <D value="1.98281" unit="g/cm3"/>
1066 <fraction n="0.47" ref="epoxy_resin"/>
1067 <fraction n="0.53" ref="fibrous_glass"/>
1070 <material name="STEEL_STAINLESS_Fe7Cr2Ni" formula="STEEL_STAINLESS_Fe7Cr2Ni">
1071 <D value="7.9300" unit="g/cm3"/>
1072 <fraction n="0.0010" ref="carbon"/>
1073 <fraction n="0.1792" ref="chromium"/>
1074 <fraction n="0.7298" ref="iron"/>
1075 <fraction n="0.0900" ref="nickel"/>
1078 <material name="Copper_Beryllium_alloy25" formula="Copper_Beryllium_alloy25">
1079 <D value="8.26" unit="g/cm3"/>
1080 <fraction n="0.981" ref="copper"/>
1081 <fraction n="0.019" ref="beryllium"/>
1084 <material name="LAr" formula="LAr">
1085 <D value="1.40" unit="g/cm3"/>
1086 <fraction n="1.0000" ref="argon"/>
1089 <material name="ArGas" formula="ArGas">
1090 <D value="0.00166" unit="g/cm3"/>
1091 <fraction n="1.0" ref="argon"/>
1094 <material formula=" " name="Air">
1095 <D value="0.001205" unit="g/cm3"/>
1096 <fraction n="0.781154" ref="nitrogen"/>
1097 <fraction n="0.209476" ref="oxygen"/>
1098 <fraction n="0.00934" ref="argon"/>
1101 <material formula=" " name="G10">
1102 <D value="1.7" unit="g/cm3"/>
1103 <fraction n="0.2805" ref="silicon"/>
1104 <fraction n="0.3954" ref="oxygen"/>
1105 <fraction n="0.2990" ref="carbon"/>
1106 <fraction n="0.0251" ref="hydrogen"/>
1109 <material formula=" " name="Granite">
1110 <D value="2.7" unit="g/cm3"/>
1111 <fraction n="0.438" ref="oxygen"/>
1112 <fraction n="0.257" ref="silicon"/>
1113 <fraction n="0.222" ref="sodium"/>
1114 <fraction n="0.049" ref="aluminum"/>
1115 <fraction n="0.019" ref="iron"/>
1116 <fraction n="0.015" ref="potassium"/>
1119 <material formula=" " name="ShotRock">
1120 <D value="2.7*0.6" unit="g/cm3"/>
1121 <fraction n="0.438" ref="oxygen"/>
1122 <fraction n="0.257" ref="silicon"/>
1123 <fraction n="0.222" ref="sodium"/>
1124 <fraction n="0.049" ref="aluminum"/>
1125 <fraction n="0.019" ref="iron"/>
1126 <fraction n="0.015" ref="potassium"/>
1129 <material formula=" " name="Dirt">
1130 <D value="1.7" unit="g/cm3"/>
1131 <fraction n="0.438" ref="oxygen"/>
1132 <fraction n="0.257" ref="silicon"/>
1133 <fraction n="0.222" ref="sodium"/>
1134 <fraction n="0.049" ref="aluminum"/>
1135 <fraction n="0.019" ref="iron"/>
1136 <fraction n="0.015" ref="potassium"/>
1139 <material formula=" " name="Concrete">
1140 <D value="2.3" unit="g/cm3"/>
1141 <fraction n="0.530" ref="oxygen"/>
1142 <fraction n="0.335" ref="silicon"/>
1143 <fraction n="0.060" ref="calcium"/>
1144 <fraction n="0.015" ref="sodium"/>
1145 <fraction n="0.020" ref="iron"/>
1146 <fraction n="0.040" ref="aluminum"/>
1149 <material formula="H2O" name="Water">
1150 <D value="1.0" unit="g/cm3"/>
1151 <fraction n="0.1119" ref="hydrogen"/>
1152 <fraction n="0.8881" ref="oxygen"/>
1155 <material formula="Ti" name="Titanium">
1156 <D value="4.506" unit="g/cm3"/>
1157 <fraction n="1." ref="titanium"/>
1160 <material name="TPB" formula="TPB">
1161 <D value="1.40" unit="g/cm3"/>
1162 <fraction n="1.0000" ref="argon"/>
1165 <material name="Glass">
1166 <D value="2.74351" unit="g/cm3"/>
1167 <fraction n="0.600" ref="SiO2"/>
1168 <fraction n="0.118" ref="Al2O3"/>
1169 <fraction n="0.001" ref="Fe2O3"/>
1170 <fraction n="0.224" ref="CaO"/>
1171 <fraction n="0.034" ref="MgO"/>
1172 <fraction n="0.010" ref="Na2O"/>
1173 <fraction n="0.013" ref="TiO2"/>
1176 <material name="Acrylic">
1177 <D value="1.19" unit="g/cm3"/>
1178 <fraction n="0.600" ref="carbon"/>
1179 <fraction n="0.320" ref="oxygen"/>
1180 <fraction n="0.080" ref="hydrogen"/>
1183 <material name="Plastic" formula="Plastic">
1184 <D value="1.032" unit="g/cm3"/>
1185 <fraction n=".474" ref="carbon"/>
1186 <fraction n=".526" ref="hydrogen"/>
1198 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1199 #++++++++++++++++++++++++++++++++++++++++ gen_TPC ++++++++++++++++++++++++++++++++++++++++
1200 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1210 # $_[4] = APA number
1214 my $TPCActive_x = $_[0]-(3*$APAWirePlaneSpacing);
1215 my $TPCActive_y = $_[1] - $APAGap_y/2 - $ReadoutBoardOverlap ; #TODO: make the Active height more accurate
1216 #print " APA $apa TPCActive xyz dimensions = ($TPCActive_x, $TPCActive_y, $TPCActive_z[$apa])\n";
1219 my $UAngle = $UAng[$apa];
1220 my $VAngle = $VAng[$apa];
1222 my $SinUAngle = sin( deg2rad($UAngle) );
1223 my $CosUAngle = cos( deg2rad($UAngle) );
1224 my $TanUAngle = tan( deg2rad($UAngle) );
1226 my $SinVAngle = sin( deg2rad($VAngle) );
1227 my $CosVAngle = cos( deg2rad($VAngle) );
1228 my $TanVAngle = tan( deg2rad($VAngle) );
1230 my $UWire_yint = $UWirePitch/$SinUAngle;
1231 my $VWire_yint = $VWirePitch/$SinVAngle;
1233 if($Pitch3mmVersion==1){
1234 $UWire_zint = $UWirePitch/$CosUAngle;
1235 $VWire_zint = $VWirePitch/$CosVAngle;
1237 $UWire_zint = $UVReadoutBoardPitch;
1238 $VWire_zint = $UVReadoutBoardPitch;
1241 #constructs everything inside volTPC, namely
1242 # (moving from left to right, or from +x to -x)
1244 # -volTPCPlaneU: with wires angled from vertical slightly different than in V
1245 # -volTPCPlaneV: with wires angled from vertical slightly differently than in U
1246 # -volTPCPlaneX: with vertical wires
1249 # Create the TPC fragment file name,
1250 # add file to list of output GDML fragments,
1252 $TPC = "35t_TPC_${_[3]}" . $suffix . ".gdml";
1253 push (@gdmlFiles, $TPC);
1255 open(TPC) or die("Could not open file $TPC for writing");
1258 print $wout "\n\n\n----- Wires for $_[3] -----\n\n\n";
1261 # The standard XML prefix and starting the gdml
1263 <?xml version='1.0'?>
1268 # All the TPC solids save the wires.
1271 <box name="$_[3]" lunit="cm"
1275 <box name="${_[3]}UPlane" lunit="cm"
1276 x="$TPCWirePlaneThickness"
1277 y="$Uactive_y[$apa] + $UVPlaneBoundNudge"
1278 z="$Uactive_z + $UVPlaneBoundNudge"/>
1279 <box name="${_[3]}VPlane" lunit="cm"
1280 x="$TPCWirePlaneThickness"
1281 y="$Vactive_y[$apa] + $UVPlaneBoundNudge"
1282 z="$Vactive_z + $UVPlaneBoundNudge"/>
1283 <box name="${_[3]}ZPlane" lunit="cm"
1284 x="$TPCWirePlaneThickness"
1285 y="$Zactive_y[$apa]"
1287 <box name="${_[3]}Active" lunit="cm"
1290 z="$TPCActive_z[$apa]"/>
1294 #++++++++++++++++++++++++++++ Wire Solids ++++++++++++++++++++++++++++++
1298 <tube name="${_[3]}WireVert"
1299 rmax="0.5*$TPCWireThickness"
1300 z="$Zactive_y[$apa]"
1306 # Set number of wires to default to zero, when $wires_on = 0, for a low memory
1307 # version. But if $wires_on = 1, calculate the number of wires on each side of each
1308 # plane to be used in the for loops
1310 my $NumberCornerUWires = 0;
1311 my $NumberSideUWires = 0;
1312 my $NumberCommonUWires = 0;
1313 my $NumberCornerVWires = 0;
1314 my $NumberSideVWires = 0;
1315 my $NumberCommonVWires = 0;
1316 my $NumberVerticalWires = 0;
1320 # Number of wires in one corner
1321 if($Pitch3mmVersion==1){
1322 $NumberCornerUWires = int( $APAFrame_z/($UWirePitch/$CosUAngle) );
1324 $NumberCornerUWires = 72;
1327 if($Pitch3mmVersion==1){
1328 $NumberCornerVWires = int( $APAFrame_z/($VWirePitch/$CosVAngle) );
1330 $NumberCornerVWires = 72;
1333 # Total number of wires touching one vertical (longer) side
1334 # Note that the total number of wires per plane is this + another set of corner wires
1335 $NumberSideUWires = int( $Uactive_y[$apa]/($UWirePitch/$SinUAngle) );
1337 $NumberSideVWires = int( $Vactive_y[$apa]/($VWirePitch/$SinVAngle) );
1339 # Number of wires per side that aren't cut off by the corner
1340 $NumberCommonUWires = $NumberSideUWires - $NumberCornerUWires;
1342 $NumberCommonVWires = $NumberSideVWires - $NumberCornerVWires;
1344 # Number of wires on the vertical plane
1345 # Since APA Active z is defined in docdb 7550 to be distance
1346 # between outer vertical wires, + 1 since the floor of this
1347 # division will be one under, giveing the amt of spaces, not wires
1348 if($Pitch3mmVersion==1){
1349 $NumberVerticalWires = int( $Zactive_z/$XWirePitch ) + 1;
1351 $NumberVerticalWires = 112; # Zactive now defined in terms of 112,
1354 $nUchans = 2*$NumberCornerUWires;
1355 $nVchans = 2*$NumberCornerVWires;
1356 $nUwires = 2*$NumberCornerUWires+$NumberSideUWires;
1357 $nVwires = 2*$NumberCornerVWires+$NumberSideVWires;
1359 print $wout "$nUchans U channels\n";
1360 print $wout "$nVchans V channels\n";
1361 print $wout "$NumberVerticalWires Z channels per side\n";
1362 print $wout "$nUwires U wire segments per plane\n";
1363 print $wout "$nVwires V wire segments per plane\n";
1368 if($Pitch3mmVersion==1){
1369 $FirstUWireOffset = .15 + $G10thickness + 2*$G10thickness*$TanUAngle - $UWire_zint;
1370 $FirstVWireOffset = .15;
1372 $FirstUWireOffset = .35 + $G10thickness + 2*$G10thickness*$TanUAngle - $UWire_zint;
1373 $FirstVWireOffset = .35; # doesnt include a G10 board in width
1376 my $FirstTopUWire_yspan =
1378 - ( - $Uactive_y[$apa]/2
1379 + $FirstUWireOffset/$TanUAngle # walk us up to the first wire
1380 + $UWire_yint*($NumberSideUWires-1) # up to the top of the top common wire
1381 - $Uactive_z/$TanUAngle # back to the bottom of the top common wire
1382 + $UWire_yint); # nudge up to bottom of the first top corner wire
1384 my $FirstTopVWire_yspan =
1386 - ( - $Vactive_y[$apa]/2
1387 + $FirstVWireOffset/$TanVAngle # walk us up to the first wire
1388 + $VWire_yint*($NumberSideVWires-1) # up to the top of the top common wire
1389 - $Vactive_z/$TanVAngle # back to the bottom of the top common wire
1390 + $VWire_yint); # nudge up to bottom of the first top corner wire
1392 # The corner wires for the U plane
1395 for ($i = 0; $i < $NumberCornerUWires; $i++)
1397 $CornerUWireLength[$i] = ($FirstUWireOffset + $i*$UWire_zint)/$SinUAngle;
1400 <tube name="${_[3]}WireU$i"
1401 rmax="0.5*$TPCWireThickness"
1402 z="$CornerUWireLength[$i]"
1410 $CommonUWireLength = $Uactive_z/$SinUAngle;
1413 <tube name="${_[3]}WireUCommon"
1414 rmax="0.5*$TPCWireThickness"
1415 z="$CommonUWireLength"
1421 for ($i = 0; $i < $NumberCornerUWires; $i++)
1424 $TopCornerUWireLength[$i] = ($FirstTopUWire_yspan - $i*$UWire_yint)/$CosUAngle;
1426 $j = $i + $NumberSideUWires;
1429 <tube name="${_[3]}WireU$j"
1430 rmax="0.5*$TPCWireThickness"
1431 z="$TopCornerUWireLength[$i]"
1442 # The corner wires for the V plane
1445 for ($i = 0; $i < $NumberCornerVWires; ++$i)
1447 $CornerVWireLength[$i] = ($FirstVWireOffset + $i*$VWire_zint)/$SinVAngle;
1451 <tube name="${_[3]}WireV$i"
1452 rmax="0.5*$TPCWireThickness"
1453 z="$CornerVWireLength[$i]"
1462 # The wire used many times in the middle of the V plane
1463 # Same subtraction as U common
1465 $CommonVWireLength = $Vactive_z/$SinVAngle;
1468 <tube name="${_[3]}WireVCommon"
1469 rmax="0.5*$TPCWireThickness"
1470 z="$CommonVWireLength"
1476 for ($i = 0; $i < $NumberCornerVWires; $i++)
1479 $TopCornerVWireLength[$i] = ($FirstTopVWire_yspan - $i*$VWire_yint)/$CosVAngle;
1481 $j = $i + $NumberSideVWires;
1484 <tube name="${_[3]}WireV$j"
1485 rmax="0.5*$TPCWireThickness"
1486 z="$TopCornerVWireLength[$i]"
1497 # make the solids only once per APA
1498 # (here only from the lang drift TPC)
1499 if($_[0]>100){ solid_TPCG10( $_[4], $_[0], $_[1], $_[2]); }
1501 # Begin structure and create the vertical wire logical volume
1505 <volume name="volTPCActive${_[3]}">
1506 <materialref ref="LAr"/>
1507 <solidref ref="${_[3]}Active"/>
1516 <volume name="volTPCWireVert${_[3]}">
1517 <materialref ref="Copper_Beryllium_alloy25"/>
1518 <solidref ref="${_[3]}WireVert"/>
1522 # Corner U wires logical volumes
1523 for ($i = 0; $i < $NumberCornerUWires; ++$i)
1526 <volume name="volTPCWireU$i${_[3]}">
1527 <materialref ref="Copper_Beryllium_alloy25"/>
1528 <solidref ref="${_[3]}WireU$i"/>
1534 # Top Corner U wires logical volumes
1535 for ($j = $NumberSideUWires; $j < $NumberSideUWires + $NumberCornerUWires; ++$j)
1538 <volume name="volTPCWireU$j${_[3]}">
1539 <materialref ref="Copper_Beryllium_alloy25"/>
1540 <solidref ref="${_[3]}WireU$j"/>
1546 # Common U wire logical volume, referenced many times
1548 <volume name="volTPCWireUCommon${_[3]}">
1549 <materialref ref="Copper_Beryllium_alloy25"/>
1550 <solidref ref="${_[3]}WireUCommon"/>
1554 # Corner V wires logical volumes
1555 for ($i = 0; $i < $NumberCornerVWires; ++$i)
1558 <volume name="volTPCWireV$i${_[3]}">
1559 <materialref ref="Copper_Beryllium_alloy25"/>
1560 <solidref ref="${_[3]}WireV$i"/>
1566 # Top Corner V wires logical volumes
1567 for ($j = $NumberSideVWires; $j < $NumberSideVWires + $NumberCornerVWires; ++$j)
1570 <volume name="volTPCWireV$j${_[3]}">
1571 <materialref ref="Copper_Beryllium_alloy25"/>
1572 <solidref ref="${_[3]}WireV$j"/>
1577 # Common V wire logical volume, referenced many times
1579 <volume name="volTPCWireVCommon${_[3]}">
1580 <materialref ref="Copper_Beryllium_alloy25"/>
1581 <solidref ref="${_[3]}WireVCommon"/>
1587 # generate the G10 board solids and logical volumes
1588 # make the volumes only once per APA
1589 # (here only from the lang drift TPC)
1590 if($_[0]>100){ vol_TPCG10( $_[4] ); }
1596 #+++++++++++++++++++++++++ Position physical wires ++++++++++++++++++++++++++
1598 # ++++++++++++++++++++++ U Plane +++++++++++++++++++++++
1600 # Create U plane logical volume
1602 <volume name="volTPCPlaneU${_[3]}">
1603 <materialref ref="LAr"/>
1604 <solidref ref="${_[3]}UPlane"/>
1608 print $wout "\n- Wires for U plane -\n\n";
1609 print $wout " Uplane_y: $Uactive_y[$apa]\n";
1610 print $wout " Uplane_z: $Uactive_z\n";
1616 # Starting with the bottom left corner wires:
1617 # x=0 to center the wires in the plane
1618 # y positioning: (-0.5*$TPCWirePlaneHeight) starts the incremental increase
1619 # from the bottom of the plane, and trigonometry gives the increment
1620 # z positioning: Looking at the plane from the positive x direction,
1621 # (0.5*$TPCWirePlaneLength) starts the incremental increase from
1622 # the lower left corner.
1623 # rotation: same as common wire in code below
1625 $FirstU_ypos = - $Uactive_y[$apa]/2 + $FirstUWireOffset/$TanUAngle/2;
1626 $FirstU_zpos = + $Uactive_z/2 - $FirstUWireOffset/2;
1628 for ($i = 0; $i < $NumberCornerUWires; ++$i)
1631 my $ypos = $FirstU_ypos + ($i)*0.5*$UWire_yint;
1632 my $zpos = $FirstU_zpos - ($i)*0.5*$UWire_zint;
1634 # cant actually define like this:
1635 # my $ypos = (-0.5*$Uactive_y[$apa]) + $CornerUWireLength[$i]*$CosUAngle/2;
1636 # my $zpos = (+0.5*$Uactive_z) - $CornerUWireLength[$i]*$SinUAngle/2;
1637 # since the wire lengths need to be slightly reduced to avoid the
1638 # wire corner's overlap with the plane boundary
1643 <volumeref ref="volTPCWireU$i${_[3]}"/>
1644 <position name="pos${_[3]}WireU$i" unit="cm" x="0" y="$ypos " z="$zpos"/>
1645 <rotation name="rUAngle$i" unit="deg" x="90-$UAngle" y="0" z="0"/>
1650 $topY = $ypos + ($CosUAngle*$CornerUWireLength[$i]/2);
1651 $bottomY = $ypos - ($CosUAngle*$CornerUWireLength[$i]/2);
1652 $edgeZ_p = $zpos + ($SinUAngle*$CornerUWireLength[$i]/2);
1653 $edgeZ_m = $zpos - ($SinUAngle*$CornerUWireLength[$i]/2);
1654 print $wout "U$i: ( $ypos , $zpos ) \n";
1655 print $wout " -- Y: $bottomY to $topY -- Z: $edgeZ_m to $edgeZ_p \n";
1663 # Moving upwards to the common wires:
1664 # x and z are zero to center the wires along a vertical axis
1665 # y positioning: The trick is positioning the lowest common wire so that the pitch
1666 # is consistent, then the increment is double the increment of
1667 # the corner wires since there is no z incriment.
1668 # rotation: wires in \\\\ direction, so +90deg to bring them to vertical and
1669 # +UAngle counterclockwise to arrive at proper orientation
1670 # Note that the counter maintains wire number (in pos. name) counting bottom to top
1673 my $StartCommonUWires_ypos = $lastYpos + $UWire_yint - abs( $lastZpos )/$TanUAngle;
1676 for ($i = $NumberCornerUWires; $i < $NumberSideUWires; ++$i)
1679 $j = $i - $NumberCornerUWires;
1681 #my $ypos = (-0.5*$Uactive_y[$apa])
1682 # + 0.5*($NumberCornerUWires)*$UWire_yint+($i+1-$NumberCornerUWires)*$UWire_yint;
1683 my $ypos = $StartCommonUWires_ypos + $UWire_yint*($j);
1687 <volumeref ref="volTPCWireUCommon${_[3]}"/>
1688 <position name="pos${_[3]}WireU$i" unit="cm" x="0" y="$ypos " z="0"/>
1689 <rotation name="rUAngle$i" unit="deg" x="90-$UAngle" y="0" z="0"/>
1693 $topY = $ypos + ($CosUAngle*$CommonUWireLength/2);
1694 $bottomY = $ypos - ($CosUAngle*$CommonUWireLength/2);
1695 $edgeZ_p = + ($SinUAngle*$CommonUWireLength/2);
1696 $edgeZ_m = - ($SinUAngle*$CommonUWireLength/2);
1697 print $wout "U$i: ( $ypos , 0 ) \n";
1698 print $wout " -- Y: $bottomY to $topY -- Z: $edgeZ_m to $edgeZ_p \n";
1701 #$lastZpos = $zpos; always 0
1707 my $FirstTopUWire_zspan = $FirstTopUWire_yspan*$TanUAngle;
1708 my $StartTopUWires_ypos = + $Uactive_y[$apa]/2 - $FirstTopUWire_yspan/2;
1709 my $StartTopUWires_zpos = - $Uactive_z/2 + $FirstTopUWire_zspan/2;
1711 # Finally moving to the corner wires on the top right:
1712 # x=0 to center the wires in the plane
1713 # y positioning: plug wire number into same equation
1714 # z positioning: start at z=0 and go negatively at the same z increment
1715 # rotation: same as common wire in code above
1716 # note that the counter maintains wire number shown in the position name
1718 for ($j = $NumberSideUWires; $j < $NumberSideUWires+$NumberCornerUWires; ++$j)
1721 $i = $j - $NumberSideUWires;
1723 my $ypos = $StartTopUWires_ypos + ($i)*0.5*$UWire_yint;
1724 my $zpos = $StartTopUWires_zpos - ($i)*0.5*$UWire_zint;
1729 <volumeref ref="volTPCWireU$j${_[3]}"/>
1730 <position name="pos${_[3]}WireU$j" unit="cm" x="0" y="$ypos " z="$zpos"/>
1731 <rotation name="rUAngle$j" unit="deg" x="90-$UAngle" y="0" z="0"/>
1735 $topY = $ypos + ($CosUAngle*$TopCornerUWireLength[$i]/2);
1736 $bottomY = $ypos - ($CosUAngle*$TopCornerUWireLength[$i]/2);
1737 $edgeZ_p = $zpos + ($SinUAngle*$TopCornerUWireLength[$i]/2);
1738 $edgeZ_m = $zpos - ($SinUAngle*$TopCornerUWireLength[$i]/2);
1739 print $wout "U$i: ( $ypos , $zpos ) \n";
1740 print $wout " -- Y: $bottomY to $topY -- Z: $edgeZ_m to $edgeZ_p \n";
1747 # ++++++++++++++++++++++ V Plane +++++++++++++++++++++++
1749 # End U plane and create V plane logical volume
1753 <volume name="volTPCPlaneV${_[3]}">
1754 <materialref ref="LAr"/>
1755 <solidref ref="${_[3]}VPlane"/>
1758 print $wout "\n- Wires for V plane -\n\n";
1759 print $wout " Vplane_y: $Vactive_y[$apa]\n";
1760 print $wout " Vplane_z: $Vactive_z\n";
1766 # Starting with the bottom right corner wires:
1767 # x=0 to center the wires in the plane
1768 # y positioning: (-0.5*$TPCWirePlaneHeight) starts the incremental increase
1769 # from the bottom of the plane, and trigonometry gives the increment
1770 # z positioning: Looking at the plane from the positive x direction,
1771 # (-0.5*$TPCWirePlaneLength) starts the incremental increase from
1772 # the lower right corner.
1773 # rotation: same as common wire in code below
1775 $FirstV_ypos = - $Vactive_y[$apa]/2 + $FirstVWireOffset/$TanVAngle/2;
1776 $FirstV_zpos = - $Vactive_z/2 + $FirstVWireOffset/2;
1778 for ($i = 0; $i < $NumberCornerVWires; ++$i)
1781 my $ypos = $FirstV_ypos + ($i)*0.5*$VWire_yint;
1782 my $zpos = $FirstV_zpos + ($i)*0.5*$VWire_zint;
1786 <volumeref ref="volTPCWireV$i${_[3]}"/>
1787 <position name="pos${_[3]}WireV$i" unit="cm" x="0" y="$ypos " z="$zpos"/>
1788 <rotation name="rVAngle$i" unit="deg" x="90+$VAngle" y="0" z="0"/>
1792 $topY = $ypos + ($CosVAngle*$CornerVWireLength[$i]/2);
1793 $bottomY = $ypos - ($CosVAngle*$CornerVWireLength[$i]/2);
1794 $edgeZ_p = $zpos + ($SinVAngle*$CornerVWireLength[$i]/2);
1795 $edgeZ_m = $zpos - ($SinVAngle*$CornerVWireLength[$i]/2);
1796 print $wout "V$i: ( $ypos , $zpos ) \n";
1797 print $wout " -- Y: $bottomY to $topY -- Z: $edgeZ_m to $edgeZ_p \n";
1805 # Moving upwards to the common wires:
1806 # x and z are zero to center the wires along a vertical axis
1807 # y positioning: Plug wire number into the same corner ypos equation
1808 # rotation: wires in //// direction, so +90deg to bring them to vertical and
1809 # --VAngle counterclockwise to arrive at proper orientation
1810 # Note that the counter maintains wire number in the position name
1812 my $StartCommonVWires_ypos = $lastYpos + $VWire_yint - abs( $lastZpos )/$TanVAngle;
1814 for ($i = $NumberCornerVWires; $i < $NumberSideVWires; ++$i)
1817 $j = $i - $NumberCornerVWires;
1818 my $ypos = $StartCommonVWires_ypos + $VWire_yint*($j);
1822 <volumeref ref="volTPCWireVCommon${_[3]}"/>
1823 <position name="pos${_[3]}WireV$i" unit="cm" x="0" y="$ypos " z="0"/>
1824 <rotation name="rVAngle$i" unit="deg" x="90+$VAngle" y="0" z="0"/>
1828 $topY = $ypos + ($CosVAngle*$CommonVWireLength/2);
1829 $bottomY = $ypos - ($CosVAngle*$CommonVWireLength/2);
1830 $edgeZ_p = + ($SinVAngle*$CommonVWireLength/2);
1831 $edgeZ_m = - ($SinVAngle*$CommonVWireLength/2);
1832 print $wout "V$i: ( $ypos , 0 ) \n";
1833 print $wout " -- Y: $bottomY to $topY -- Z: $edgeZ_m to $edgeZ_p \n";
1836 #$lastZpos = $zpos; always 0
1841 my $FirstTopVWire_zspan = $FirstTopVWire_yspan*$TanVAngle;
1842 my $StartTopVWires_ypos = + $Vactive_y[$apa]/2 - $FirstTopVWire_yspan/2;
1843 my $StartTopVWires_zpos = + $Vactive_z/2 - $FirstTopVWire_zspan/2;
1845 # Finally moving to the corner wires on the top right:
1846 # x=0 to center the wires in the plane
1847 # y positioning: plug wire number into same equation
1848 # z positioning: start at z=0 and go positively at the same z increment
1849 # rotation: same as common wire in code above
1850 # note that the counter maintains wire number shown in the position name
1852 for ($j = $NumberSideVWires; $j < $NumberSideVWires+$NumberCornerVWires; ++$j)
1855 $i = $j - $NumberSideVWires;
1857 my $ypos = $StartTopVWires_ypos + ($i)*0.5*$VWire_yint;
1858 my $zpos = $StartTopVWires_zpos + ($i)*0.5*$VWire_zint;
1862 <volumeref ref="volTPCWireV$j${_[3]}"/>
1863 <position name="pos${_[3]}WireV$j" unit="cm" x="0" y="$ypos " z="$zpos"/>
1864 <rotation name="rVAngle$j" unit="deg" x="90+$VAngle" y="0" z="0"/>
1868 $topY = $ypos + ($CosVAngle*$TopCornerVWireLength[$i]/2);
1869 $bottomY = $ypos - ($CosVAngle*$TopCornerVWireLength[$i]/2);
1870 $edgeZ_p = $zpos + ($SinVAngle*$TopCornerVWireLength[$i]/2);
1871 $edgeZ_m = $zpos - ($SinVAngle*$TopCornerVWireLength[$i]/2);
1872 print $wout "V$i: ( $ypos , $zpos ) \n";
1873 print $wout " -- Y: $bottomY to $topY -- Z: $edgeZ_m to $edgeZ_p \n";
1886 # ++++++++++++++++++++++ Z Plane +++++++++++++++++++++++
1888 # End V plane and create Z plane logical volume
1892 <volume name="volTPCPlaneZ${_[3]}">
1893 <materialref ref="LAr"/>
1894 <solidref ref="${_[3]}ZPlane"/>
1900 # This is the simplest plane, one loop creates all of the wires
1901 # x and y position at zero to center the wires
1902 # z position: moving from front of detector to back, in the positive z direction,
1903 # starting at (-0.5*$TPCWirePlaneLength), the right side looking from
1906 for ($i=0; $i<$NumberVerticalWires; ++$i)
1908 my $zpos = (-0.5*$Zactive_z) + $i*$XWirePitch + $TPCWireThickness/2;
1912 <volumeref ref="volTPCWireVert${_[3]}"/>
1913 <position name="pos${_[3]}WireZ$i" unit="cm" x="0" y="0 " z="$zpos"/>
1914 <rotationref ref="rPlus90AboutX"/>
1926 #+++++++++++++++++++++ ^^ Position physical wires Above ^^ +++++++++++++++++++++
1928 ## make the TPC active volume extend down to the G10 for the grid
1930 my $BottomOfAPA = - $TPC_y[$apa]/2 + $APAGap_y/2;
1933 if ($apa==0){ $zz = -1; }
1934 elsif($apa==1){ $zz = 0; }
1935 elsif($apa==2){ $zz = 0; }
1936 elsif($apa==3){ $zz = 1; }
1938 if ($TPCActive_x<100){ $xx = -1; }
1941 $posZplane[0] = $xx*(-$_[0]/2 + $APAWirePlaneSpacing - $TPCWirePlaneThickness/2);
1942 $posZplane[1] = $BottomOfAPA + $WrapCover + 4*$G10thickness + $Zactive_y[$apa]/2;
1943 $posZplane[2] = $zz*(-$_[2]/2 + $APAGap_z/2 + $APAphys_z/2);
1945 $posVplane[0] = $posZplane[0] + $xx*$APAWirePlaneSpacing;
1946 $posVplane[1] = $BottomOfAPA + $WrapCover + 3*$G10thickness + $Vactive_y[$apa]/2;
1947 $posVplane[2] = $posZplane[2];
1949 $posUplane[0] = $posVplane[0] + $xx*$APAWirePlaneSpacing;
1950 $posUplane[1] = $BottomOfAPA + $WrapCover + 2*$G10thickness + $Uactive_y[$apa]/2;
1951 $posUplane[2] = $posZplane[2];
1953 $posTPCActive[0] = $posUplane[0] + $xx*($TPCWirePlaneThickness/2 + $TPCActive_x/2);
1954 $posTPCActive[1] = -$_[1]/2 + $TPCActive_y/2;
1955 $posTPCActive[2] = 0;
1957 if ($TPCActive_x<100){ $planeRot = "rIdentity"; }
1958 else { $planeRot = "rPlus180AboutY"; }
1961 #wrap up the TPC file
1963 <volume name="volTPC${_[3]}">
1964 <materialref ref="LAr"/>
1965 <solidref ref="${_[3]}"/>
1967 <volumeref ref="volTPCPlaneZ${_[3]}"/>
1968 <position name="pos${_[3]}PlaneZ" unit="cm"
1969 x="$posZplane[0]" y="$posZplane[1]" z="$posZplane[2]"/>
1970 <rotationref ref="$planeRot"/>
1973 <volumeref ref="volTPCPlaneV${_[3]}"/>
1974 <position name="pos${_[3]}PlaneV" unit="cm"
1975 x="$posVplane[0]" y="$posVplane[1]" z="$posVplane[2]"/>
1976 <rotationref ref="$planeRot"/>
1979 <volumeref ref="volTPCPlaneU${_[3]}"/>
1980 <position name="pos${_[3]}PlaneU" unit="cm"
1981 x="$posUplane[0]" y="$posUplane[1]" z="$posUplane[2]"/>
1982 <rotationref ref="$planeRot"/>
1985 <volumeref ref="volTPCActive${_[3]}"/>
1986 <position name="pos${_[3]}Active" unit="cm"
1987 x="$posTPCActive[0]" y="$posTPCActive[1]" z="$posTPCActive[2]"/>
1991 # place the G10 board extensions to the portions placed directly in volCryostat
1992 #place_TPCG10( $_[4], $_[0], $_[1], $_[2] );
2002 } #end of sub gen_TPC
2005 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2006 #++++++++++++++++++++++++++++++++++++++ solid_TPCG10 +++++++++++++++++++++++++++++++++++++
2007 #++++++++++++++++++++++++++++++++++++++++ vol_TPCG10 +++++++++++++++++++++++++++++++++++++
2008 #++++++++++++++++++++++++++++++++++++++ place_TPCG10 +++++++++++++++++++++++++++++++++++++
2009 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2012 # Must be called only within gen_TPC(),
2015 # $_[0] = APA number
2016 # convention: 0 is Largest, 1 is Mid, 2 is Smallest
2024 $G10BoardYSide_V_x = 2*$APAWirePlaneSpacing; # The rest of the x-direction extension
2025 # out to the V plane wires
2026 $G10BoardYSide_V_y = $APAFrame_y[$apa]; # Y and Z are the same as the center
2027 $G10BoardYSide_V_z = $G10thickness; # parts placed in volCryostat
2030 $G10BoardYSide_U_x = 3*$APAWirePlaneSpacing; # The rest of the x-direction extension
2031 # out to the U plane wires
2032 $G10BoardYSide_U_y = $APAFrame_y[$apa]; # Y and Z are the same as the center
2033 $G10BoardYSide_U_z = $G10thickness; # parts placed in volCryostat
2036 $G10BoardZSide_V_x = 2*$APAWirePlaneSpacing;
2037 $G10BoardZSide_V_y = $G10thickness;
2038 $G10BoardZSide_V_z = $APAFrame_z;
2039 $G10BoardZSide_U_x = 3*$APAWirePlaneSpacing;
2040 $G10BoardZSide_U_y = $G10thickness;
2041 $G10BoardZSide_U_z = $APAFrame_z;
2042 $G10BoardZSide_Grid_x = 4*$APAWirePlaneSpacing;
2043 $G10BoardZSide_Grid_y = $G10thickness;
2044 $G10BoardZSide_Grid_z = $APAFrame_z;
2048 <box name="G10BoardYSideVSeg\-$apa" lunit="cm"
2049 x="$G10BoardYSide_V_x"
2050 y="$G10BoardYSide_V_y"
2051 z="$G10BoardYSide_V_z"/>
2053 <box name="G10BoardYSideUSeg\-$apa" lunit="cm"
2054 x="$G10BoardYSide_U_x"
2055 y="$G10BoardYSide_U_y"
2056 z="$G10BoardYSide_U_z"/>
2058 <box name="G10BoardZSideVSeg\-$apa" lunit="cm"
2059 x="$G10BoardZSide_V_x"
2060 y="$G10BoardZSide_V_y"
2061 z="$G10BoardZSide_V_z"/>
2063 <box name="G10BoardZSideUSeg\-$apa" lunit="cm"
2064 x="$G10BoardZSide_U_x"
2065 y="$G10BoardZSide_U_y"
2066 z="$G10BoardZSide_U_z"/>
2068 <box name="G10BoardZSideGridSeg\-$apa" lunit="cm"
2069 x="$G10BoardZSide_Grid_x"
2070 y="$G10BoardZSide_Grid_y"
2071 z="$G10BoardZSide_Grid_z"/>
2085 <volume name="volG10BoardYSideVSeg\-$apa">
2086 <materialref ref="G10"/>
2087 <solidref ref="G10BoardYSideVSeg\-$apa"/>
2089 <volume name="volG10BoardYSideUSeg\-$apa">
2090 <materialref ref="G10"/>
2091 <solidref ref="G10BoardYSideUSeg\-$apa"/>
2094 <volume name="volG10BoardZSideVSeg\-$apa">
2095 <materialref ref="G10"/>
2096 <solidref ref="G10BoardZSideVSeg\-$apa"/>
2098 <volume name="volG10BoardZSideUSeg\-$apa">
2099 <materialref ref="G10"/>
2100 <solidref ref="G10BoardZSideUSeg\-$apa"/>
2102 <volume name="volG10BoardZSideGridSeg\-$apa">
2103 <materialref ref="G10"/>
2104 <solidref ref="G10BoardZSideGridSeg\-$apa"/>
2122 $G10BoardYSide_V_x = 1*$APAWirePlaneSpacing; # The rest of the x-direction extension
2123 # out to the V plane wires
2124 $G10BoardYSide_V_y = $APAFrame_y[$APA_i]; # Y and Z are the same as the center
2125 $G10BoardYSide_V_z = $G10thickness; # parts placed in volCryostat
2128 $G10BoardYSide_U_x = 2*$APAWirePlaneSpacing; # The rest of the x-direction extension
2129 # out to the U plane wires
2130 $G10BoardYSide_U_y = $APAFrame_y[$APA_i]; # Y and Z are the same as the center
2131 $G10BoardYSide_U_z = $G10thickness; # parts placed in volCryostat
2134 $G10BoardZSide_V_x = 1*$APAWirePlaneSpacing;
2135 $G10BoardZSide_V_y = $G10thickness;
2136 $G10BoardZSide_V_z = $APAFrame_z;
2137 $G10BoardZSide_U_x = 2*$APAWirePlaneSpacing;
2138 $G10BoardZSide_U_y = $G10thickness;
2139 $G10BoardZSide_U_z = $APAFrame_z;
2140 $G10BoardZSide_Grid_x = 3*$APAWirePlaneSpacing;
2141 $G10BoardZSide_Grid_y = $G10thickness;
2142 $G10BoardZSide_Grid_z = $APAFrame_z;
2145 $posG10ZSideZ_y = $APAFrameCenter_y - $APAFrame_y[$APA_i]/2 - (0+.5)*($G10BoardZSide_y);
2146 $posG10ZSideV_y = $APAFrameCenter_y - $APAFrame_y[$APA_i]/2 - (1+.5)*($G10BoardZSide_y);
2147 $posG10ZSideU_y = $APAFrameCenter_y - $APAFrame_y[$APA_i]/2 - (2+.5)*($G10BoardZSide_y);
2148 $posG10ZSideGrid_y = $APAFrameCenter_y - $APAFrame_y[$APA_i]/2 - (3+.5)*($G10BoardZSide_y);
2150 # ... but the smallest APA is upside-down, so put the G10 boards at the top in that case
2153 $posG10ZSideZ_y = $APAFrameCenter_y + $APAFrame_y[$APA_i]/2 + (0+.5)*($G10BoardZSide_y);
2154 $posG10ZSideV_y = $APAFrameCenter_y + $APAFrame_y[$APA_i]/2 + (1+.5)*($G10BoardZSide_y);
2155 $posG10ZSideU_y = $APAFrameCenter_y + $APAFrame_y[$APA_i]/2 + (2+.5)*($G10BoardZSide_y);
2156 $posG10ZSideGrid_y = $APAFrameCenter_y + $APAFrame_y[$APA_i]/2 + (3+.5)*($G10BoardZSide_y);
2162 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2163 - Add the *parts* of the G10 boards that extend those directly in volCryostat.
2164 - There are two side boards on each the up and downstream end,
2165 one each to wrap the U and V views around the APA frame
2166 - There are 4 on the bottom which anchor the U V and Z wires and the grid plane
2167 - The center parts of the G10 boards must be placed directly in volCryostat
2174 <volumeref ref="volG10BoardYSideVSeg\-$apa"/>
2175 <position name="posG10BoardYSideVSeg\-up\-$apa" unit="cm"
2176 x=" - $ThisTPC_x/2 + $G10BoardYSide_V_x/2"
2177 y=" - $APAphys_y[$apa]/2 + $WrapCover + 4*$G10thickness + $APAFrame_y[$apa]/2 "
2178 z=" - $APAFrame_z/2 - (0+.5)*($G10BoardYSide_V_z)"/>
2179 <rotationref ref="rIdentity"/>
2182 <volumeref ref="volG10BoardYSideUSeg\-$apa"/>
2183 <position name="posG10BoardYSideUSeg\-up\-$apa" unit="cm"
2184 x=" - $ThisTPC_x/2 + $G10BoardYSide_U_x/2"
2185 y=" - $APAphys_y[$apa]/2 + $WrapCover + 4*$G10thickness + $APAFrame_y[$apa]/2"
2186 z=" - $APAFrame_z/2 - (1+.5)*($G10BoardYSide_U_z)"/>
2187 <rotationref ref="rIdentity"/>
2191 <volumeref ref="volG10BoardYSideVSeg\-$apa"/>
2192 <position name="posG10BoardYSideVSeg\-down\-$apa" unit="cm"
2193 x=" - $ThisTPC_x/2 + $G10BoardYSide_V_x/2"
2194 y=" - $APAphys_y[$apa]/2 + $WrapCover + 4*$G10thickness + $APAFrame_y[$apa]/2 "
2195 z=" + $APAFrame_z/2 + (0+.5)*($G10BoardYSide_V_z)"/>
2196 <rotationref ref="rIdentity"/>
2199 <volumeref ref="volG10BoardYSideUSeg\-$apa"/>
2200 <position name="posG10BoardYSideUSeg\-down\-$apa" unit="cm"
2201 x=" - $ThisTPC_x/2 + $G10BoardYSide_U_x/2"
2202 y=" - $APAphys_y[$apa]/2 + $WrapCover + 4*$G10thickness + $APAFrame_y[$apa]/2"
2203 z=" + $APAFrame_z/2 + (1+.5)*($G10BoardYSide_U_z)"/>
2204 <rotationref ref="rIdentity"/>
2210 <volumeref ref="volG10BoardZSideVSeg\-$apa"/>
2211 <position name="posG10BoardZSideVSeg\-$apa" unit="cm"
2212 x=" - $ThisTPC_x/2 + $G10BoardZSide_V_x/2"
2213 y=" - $APAphys_y[$apa]/2 + $WrapCover + 2.5*$G10thickness"
2215 <rotationref ref="rIdentity"/>
2218 <volumeref ref="volG10BoardZSideUSeg\-$apa"/>
2219 <position name="posG10BoardZSideUSeg\-$apa" unit="cm"
2220 x=" - $ThisTPC_x/2 + $G10BoardZSide_U_x/2"
2221 y=" - $APAphys_y[$apa]/2 + $WrapCover + 1.5*$G10thickness"
2223 <rotationref ref="rIdentity"/>
2226 <volumeref ref="volG10BoardZSideGridSeg\-$apa"/>
2227 <position name="posG10BoardZSideGridSeg\-$apa" unit="cm"
2228 x=" - $ThisTPC_x/2 + $G10BoardZSide_Grid_x/2"
2229 y=" - $APAphys_y[$apa]/2 + $WrapCover + 0.5*$G10thickness"
2231 <rotationref ref="rIdentity"/>
2243 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2244 #++++++++++++++++++++++++++++++++++++++ gen_Cryostat +++++++++++++++++++++++++++++++++++++
2245 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2250 # Create the cryostat fragment file name,
2251 # add file to list of output GDML fragments,
2253 $CRYO = "35t_Cryostat" . $suffix . ".gdml";
2254 push (@gdmlFiles, $CRYO);
2255 $CRYO = ">" . $CRYO;
2256 open(CRYO) or die("Could not open file $CRYO for writing");
2259 # The standard XML prefix and starting the gdml
2261 <?xml version='1.0'?>
2266 # All the cryostat solids.
2269 <box name="Cryostat" lunit="cm"
2274 <box name="GaseousArgon" lunit="cm"
2276 y="$HeightGaseousAr"
2279 <box name="LightPaddle" lunit="cm"
2281 y="$LightPaddle_y + $SiPM_y"
2282 z="$LightPaddle_z"/>
2284 <box name="Bar" lunit="cm"
2289 <union name="TwoBars">
2290 <first ref="Bar"/> <second ref="Bar"/>
2291 <position name="bs2" z="-2.794" unit="cm"/>
2294 <union name="FourBars">
2295 <first ref="TwoBars"/> <second ref="TwoBars"/>
2296 <position name="bs4" z="-5.588" unit="cm"/>
2299 <box name="Plank" lunit="cm"
2304 <box name="Fiber" lunit="cm"
2309 <box name="FiberBottom" lunit="cm"
2314 <box name="FiberTop" lunit="cm"
2319 <para name="FiberRight" x="0.289" y="0.289" z="5.3975" alpha="0" theta="3.0649" phi="0" aunit="deg" lunit="cm"/>
2321 <para name="FiberLeft" x="0.289" y="0.289" z="5.3975" alpha="0" theta="-3.0649" phi="0" aunit="deg" lunit="cm"/>
2324 <first ref="Fiber"/> <second ref="Fiber"/>
2325 <position name="ff" x="-0.289" z="-0.289" unit="cm"/>
2329 <first ref="FF"/> <second ref="FiberBottom"/>
2330 <position name="ffb" x="-0.289" y="-3.81" z="0.289" unit="cm"/>
2334 <first ref="FFB"/> <second ref="FiberBottom"/>
2335 <position name="ffbb" y="-3.81" z="-0.578" unit="cm"/>
2338 <union name="FFBBT">
2339 <first ref="FFBB"/> <second ref="FiberTop"/>
2340 <position name="ffbbt" x="-0.289" y="24.28875" unit="cm"/>
2343 <union name="FFBBTT">
2344 <first ref="FFBBT"/> <second ref="FiberTop"/>
2345 <position name="ffbbtt" y="24.28875" z="-0.289" unit="cm"/>
2348 <union name="FFBBTTL">
2349 <first ref="FFBBTT"/> <second ref="FiberLeft"/>
2350 <position name="ffbbttl" x="0" y="20.47875" z="-0.4335" unit="cm"/> <rotation name="FiberRotLeft" x="-90" y="90" unit="deg"/>
2353 <union name="FourFibers">
2354 <first ref="FFBBTTL"/> <second ref="FiberRight"/>
2355 <position name="fs4" x="-0.289" y="20.47875" z="0.1445" unit="cm"/> <rotation name="FiberRotRight" x="-90" y="90" unit="deg"/>
2358 <union name="EightFibers">
2359 <first ref="FourFibers"/> <second ref="FourFibers"/>
2360 <position name="fs8" z="-1.2" unit="cm"/>
2363 <union name="SixteenFibers">
2364 <first ref="EightFibers"/> <second ref="EightFibers"/>
2365 <position name="fs16" z="-2.4" unit="cm"/>
2368 <union name="ThirtyTwoFibers">
2369 <first ref="SixteenFibers"/> <second ref="SixteenFibers"/>
2370 <position name="fs32" z="-4.8" unit="cm"/>
2376 # Add APA frames with G10 boards on them
2382 solid_CPA(); # no need for multiple sets of solids, the only 2 CPAs are identical
2385 # Cryostat structure
2390 <volume name="volGaseousArgon">
2391 <materialref ref="ArGas"/>
2392 <solidref ref="GaseousArgon"/>
2395 <volume name="volOpDetSensitive_Bar">
2396 <materialref ref="LAr"/>
2397 <solidref ref="FourBars"/>
2400 <volume name="volOpDetSensitive_Plank">
2401 <materialref ref="LAr"/>
2402 <solidref ref="Plank"/>
2405 <volume name="volOpDetSensitive_Fiber">
2406 <materialref ref="LAr"/>
2407 <solidref ref="ThirtyTwoFibers"/>
2421 <volume name="volCryostat">
2422 <materialref ref="LAr"/>
2423 <solidref ref="Cryostat"/>
2426 <volumeref ref="volGaseousArgon"/>
2427 <position name="posGaseousArgon" unit="cm" x="0" y="$Argon_y/2 - $HeightGaseousAr/2" z="0"/>
2431 <volumeref ref="volCathode"/>
2432 <positionref ref="posCathodeShortDrift"/>
2435 <volumeref ref="volCathode"/>
2436 <positionref ref="posCathodeLongDrift"/>
2442 <!-- The Smallest APA -->
2443 <!-- Note this is the only APA with a readout
2444 at the bottom. TPCs are constructed with
2445 readouts at the top, so rotate the two APAs
2446 180 around X to flip upside down -->
2449 <volumeref ref="volTPCSmallestLongDrift"/>
2450 <positionref ref="posTPCSmallestLongDrift"/>
2451 <rotationref ref="rPlus180AboutX"/>
2454 <volumeref ref="volTPCSmallestShortDrift"/>
2455 <positionref ref="posTPCSmallestShortDrift"/>
2456 <rotationref ref="rPlus180AboutX"/>
2462 place_APA($APACenter[2][0], $APACenter[2][1], $APACenter[2][2], 2);
2467 <!-- The Middle-sized APA -->
2470 <volumeref ref="volTPCMidLongDrift"/>
2471 <positionref ref="posTPCMidLongDrift"/>
2472 <rotationref ref="rIdentity"/>
2475 <volumeref ref="volTPCMidShortDrift"/>
2476 <positionref ref="posTPCMidShortDrift"/>
2477 <rotationref ref="rIdentity"/>
2483 place_APA($APACenter[1][0], $APACenter[1][1], $APACenter[1][2], 1);
2488 <!-- The Largest APAs, Upstream and Downstream -->
2491 <volumeref ref="volTPCLargestLongDriftUpstream"/>
2492 <positionref ref="posTPCLargestLongDrift_Neg"/>
2493 <rotationref ref="rIdentity"/>
2496 <volumeref ref="volTPCLargestShortDriftUpstream"/>
2497 <positionref ref="posTPCLargestShortDrift_Neg"/>
2498 <rotationref ref="rIdentity"/>
2502 <volumeref ref="volTPCLargestLongDriftDownstream"/>
2503 <positionref ref="posTPCLargestLongDrift_Pos"/>
2504 <rotationref ref="rIdentity"/>
2507 <volumeref ref="volTPCLargestShortDriftDownstream"/>
2508 <positionref ref="posTPCLargestShortDrift_Pos"/>
2509 <rotationref ref="rIdentity"/>
2514 place_APA($APACenter[0][0], $APACenter[0][1], $APACenter[0][2], 0);
2515 place_APA($APACenter[3][0], $APACenter[3][1], $APACenter[3][2], 3);
2517 place_CPA(0, $posCPAShortDrift_x, $posCPAShortDrift_y, $posCPAShortDrift_z);
2518 place_CPA(1, $posCPALongDrift_x, $posCPALongDrift_y, $posCPALongDrift_z);
2531 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2532 #++++++++++++++++++++++++++++++++++++++ solid_APA ++++++++++++++++++++++++++++++++++++++++
2533 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2536 # Must be called only within gen_Cryostat(),
2539 # $_[0] = APA number
2540 # convention: 0 is Largest, 1 is Mid, 2 is Smallest
2547 ####################################################################
2548 ################# APA Frame and Paddle Dimensions ##################
2550 $APA_y = $APAFrame_y[$APA_i];
2552 $APAFrameZSide_x = $APAFrame_x;
2553 $APAFrameZSide_y = 4*$inch;
2554 $APAFrameZSide_z = $APAFrame_z;
2556 $APAFrameYSide_x = $APAFrame_x;
2557 $APAFrameYSide_y = $APA_y-2*$APAFrameZSide_y;
2558 $APAFrameYSide_z = 4*$inch;
2560 # Two outer Y supports will sandwich the light paddles
2561 $APAFrameYOuterSupport_x = ($APAFrame_x-$LightPaddle_x)/2;
2562 $APAFrameYOuterSupport_y = $APA_y-2*$APAFrameZSide_y;
2563 $APAFrameYOuterSupport_z = 4*$inch;
2565 $EdgeFrameSteelThickness = 0.12*$inch;
2566 $InnerFrameSteelThickness = 0.062*$inch;
2569 $G10BoardYSide_x = $APAFrame_x;
2570 $G10BoardYSide_y = $APAFrame_y[$APA_i];
2571 $G10BoardYSide_z = $G10thickness;
2573 $G10BoardZSide_x = $APAFrame_x;
2574 $G10BoardZSide_y = $G10thickness;
2575 $G10BoardZSide_z = $APAFrame_z;
2579 <box name="APAFrameYSideHollow\-$APA_i" lunit="cm"
2580 x="$APAFrameYSide_x-2*$EdgeFrameSteelThickness"
2581 y="$APAFrameYSide_y-2*$EdgeFrameSteelThickness"
2582 z="$APAFrameYSide_z"/>
2583 <box name="APAFrameYSideShell\-$APA_i" lunit="cm"
2584 x="$APAFrameYSide_x"
2585 y="$APAFrameYSide_y"
2586 z="$APAFrameYSide_z"/>
2587 <subtraction name="APAFrameYSide\-$APA_i">
2588 <first ref="APAFrameYSideShell\-$APA_i"/>
2589 <second ref="APAFrameYSideHollow\-$APA_i"/>
2590 <positionref ref="posCenter"/>
2591 <rotationref ref="rIdentity"/>
2594 <box name="APAFrameZSideHollow\-$APA_i" lunit="cm"
2595 x="$APAFrameZSide_x-2*$EdgeFrameSteelThickness"
2596 y="$APAFrameZSide_y-2*$EdgeFrameSteelThickness"
2597 z="$APAFrameZSide_z"/>
2598 <box name="APAFrameZSideShell\-$APA_i" lunit="cm"
2599 x="$APAFrameZSide_x"
2600 y="$APAFrameZSide_y"
2601 z="$APAFrameZSide_z"/>
2602 <subtraction name="APAFrameZSide\-$APA_i">
2603 <first ref="APAFrameZSideShell\-$APA_i"/>
2604 <second ref="APAFrameZSideHollow\-$APA_i"/>
2605 <positionref ref="posCenter"/>
2606 <rotationref ref="rIdentity"/>
2609 <box name="APAFrameYOuterSupport\-$APA_i" lunit="cm"
2610 x="$EdgeFrameSteelThickness"
2611 y="$APAFrameYOuterSupport_y"
2612 z="$APAFrameYOuterSupport_z"/>
2615 <box name="G10BoardYSideCenterSeg\-$APA_i" lunit="cm"
2616 x="$G10BoardYSide_x"
2617 y="$G10BoardYSide_y"
2618 z="$G10BoardYSide_z"/>
2620 <box name="G10BoardZSideCenterSeg\-$APA_i" lunit="cm"
2621 x="$G10BoardZSide_x"
2622 y="$G10BoardZSide_y"
2623 z="$G10BoardZSide_z"/>
2633 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2634 #++++++++++++++++++++++++++++++++++++++ vol_APA ++++++++++++++++++++++++++++++++++++++++
2635 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2638 # Must be called only within gen_Cryostat(),
2641 # $_[0] = x APA center
2642 # $_[1] = y APA center
2643 # $_[2] = z APA center
2644 # $_[3] = APA number
2645 # convention: 0 and 3 are Largest, 1 is Mid, 2 is Smallest
2654 <volume name="volAPAFrameYSide\-$APA_i">
2655 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
2656 <solidref ref="APAFrameYSide\-$APA_i"/>
2659 <volume name="volAPAFrameZSide\-$APA_i">
2660 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
2661 <solidref ref="APAFrameZSide\-$APA_i"/>
2664 <volume name="volAPAFrameYOuterSupport\-$APA_i">
2665 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
2666 <solidref ref="APAFrameYOuterSupport\-$APA_i"/>
2669 <volume name="volG10BoardYSideCenterSeg\-$APA_i">
2670 <materialref ref="G10"/>
2671 <solidref ref="G10BoardYSideCenterSeg\-$APA_i"/>
2674 <volume name="volG10BoardZSideCenterSeg\-$APA_i">
2675 <materialref ref="G10"/>
2676 <solidref ref="G10BoardZSideCenterSeg\-$APA_i"/>
2686 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2687 #++++++++++++++++++++++++++++++++++++++ place_APA ++++++++++++++++++++++++++++++++++++++++
2688 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2691 # Must be called only within gen_Cryostat(),
2694 # $_[0] = x APA physical center
2695 # $_[1] = y APA physical center
2696 # $_[2] = z APA physical center
2697 # $_[3] = APA number
2698 # convention: 0 and 3 are Largest, 1 is Mid, 2 is Smallest
2705 ####################################################################
2706 ################# APA Frame and Paddle Dimensions ##################
2708 $APA_y = $APAFrame_y[$APA_i];
2711 # The center passed to this function is the physical APA center,
2712 # which is not quite the frame's center, since there are more boards
2713 # at the bottom. Transform them:
2715 $APAFrameCenter_x = $_[0];
2716 $APAFrameCenter_y = $_[1] - $APAphys_y[$APA_i]/2
2717 + $WrapCover + 4*$G10thickness
2718 + $APAFrame_y[$APA_i]/2;
2719 $APAFrameCenter_z = $_[2];
2721 # the smallest APA is different (upside down)
2724 $APAFrameCenter_y = $_[1] + $APAphys_y[$APA_i]/2
2725 - $WrapCover - 4*$G10thickness
2726 - $APAFrame_y[$APA_i]/2;
2730 $APAFrameZSide_x = $APAFrame_x;
2731 $APAFrameZSide_y = 4*$inch;
2732 $APAFrameZSide_z = $APAFrame_z;
2734 $APAFrameYSide_x = $APAFrame_x;
2735 $APAFrameYSide_y = $APA_y-2*$APAFrameZSide_y;
2736 $APAFrameYSide_z = 4*$inch;
2738 # Two outer Y supports will sandwich the light paddles
2739 $APAFrameYOuterSupport_x = ($APAFrame_x-$LightPaddle_x)/2;
2740 $APAFrameYOuterSupport_y = $APA_y-2*$APAFrameZSide_y;
2741 $APAFrameYOuterSupport_z = 4*$inch;
2743 # if there were an inner support to fill the hole
2744 $APAFrameYInnerSupport_x = $LightPaddle_x;
2746 $EdgeFrameSteelThickness = 0.12*$inch;
2747 $InnerFrameSteelThickness = 0.062*$inch;
2750 $G10BoardYSide_x = $APAFrame_x;
2751 $G10BoardYSide_y = $APAFrame_y[$APA_i];
2752 $G10BoardYSide_z = $G10thickness;
2754 $G10BoardZSide_x = $APAFrame_x;
2755 $G10BoardZSide_y = $G10thickness;
2756 $G10BoardZSide_z = $APAFrame_z;
2758 $posG10ZSideZ_y = $APAFrameCenter_y - $APAFrame_y[$APA_i]/2 - (0+.5)*($G10BoardZSide_y);
2759 $posG10ZSideV_y = $APAFrameCenter_y - $APAFrame_y[$APA_i]/2 - (1+.5)*($G10BoardZSide_y);
2760 $posG10ZSideU_y = $APAFrameCenter_y - $APAFrame_y[$APA_i]/2 - (2+.5)*($G10BoardZSide_y);
2761 $posG10ZSideGrid_y = $APAFrameCenter_y - $APAFrame_y[$APA_i]/2 - (3+.5)*($G10BoardZSide_y);
2763 # ... but the smallest APA is upside-down, so put the G10 boards at the top in that case
2766 $posG10ZSideZ_y = $APAFrameCenter_y + $APAFrame_y[$APA_i]/2 + (0+.5)*($G10BoardZSide_y);
2767 $posG10ZSideV_y = $APAFrameCenter_y + $APAFrame_y[$APA_i]/2 + (1+.5)*($G10BoardZSide_y);
2768 $posG10ZSideU_y = $APAFrameCenter_y + $APAFrame_y[$APA_i]/2 + (2+.5)*($G10BoardZSide_y);
2769 $posG10ZSideGrid_y = $APAFrameCenter_y + $APAFrame_y[$APA_i]/2 + (3+.5)*($G10BoardZSide_y);
2772 # First put in the frame
2782 <volumeref ref="volAPAFrameYOuterSupport\-$APA_i"/>
2783 <position name="posAPAFrameYOuterSupportNeg\-$APA_i" unit="cm"
2784 x="$APAFrameCenter_x - ($APAFrameYOuterSupport_x + $APAFrameYInnerSupport_x/2 - $EdgeFrameSteelThickness/2)"
2785 y="$APAFrameCenter_y"
2786 z="$APAFrameCenter_z"/>
2787 <rotationref ref="rIdentity"/>
2790 <volumeref ref="volAPAFrameYOuterSupport\-$APA_i"/>
2791 <position name="posAPAFrameYOuterSupportPos\-$APA_i" unit="cm"
2792 x="$APAFrameCenter_x + ($APAFrameYOuterSupport_x + $APAFrameYInnerSupport_x/2 - $EdgeFrameSteelThickness/2)"
2793 y="$APAFrameCenter_y"
2794 z="$APAFrameCenter_z"/>
2795 <rotationref ref="rIdentity"/>
2800 <volumeref ref="volAPAFrameYSide\-$APA_i"/>
2801 <position name="posAPAFrameYSideNeg\-$_[3]" unit="cm"
2802 x="$APAFrameCenter_x"
2803 y="$APAFrameCenter_y"
2804 z="$APAFrameCenter_z - $APAFrame_z/2 + $APAFrameYSide_z/2"/>
2805 <rotationref ref="rIdentity"/>
2808 <volumeref ref="volAPAFrameYSide\-$APA_i"/>
2809 <position name="posAPAFrameYSidePos\-$_[3]" unit="cm"
2810 x="$APAFrameCenter_x"
2811 y="$APAFrameCenter_y"
2812 z="$APAFrameCenter_z + $APAFrame_z/2 - $APAFrameYSide_z/2"/>
2813 <rotationref ref="rIdentity"/>
2816 <volumeref ref="volAPAFrameZSide\-$APA_i"/>
2817 <position name="posAPAFrameZSidePos\-$_[3]" unit="cm"
2818 x="$APAFrameCenter_x"
2819 y="$APAFrameCenter_y + $APAFrame_y[$APA_i]/2 - $APAFrameZSide_y/2"
2820 z="$APAFrameCenter_z"/>
2821 <rotationref ref="rIdentity"/>
2824 <volumeref ref="volAPAFrameZSide\-$APA_i"/>
2825 <position name="posAPAFrameZSideNeg\-$_[3]" unit="cm"
2826 x="$APAFrameCenter_x"
2827 y="$APAFrameCenter_y - $APAFrame_y[$APA_i]/2 + $APAFrameZSide_y/2"
2828 z="$APAFrameCenter_z"/>
2829 <rotationref ref="rIdentity"/>
2833 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2834 - Add the *parts* of the G10 boards that exist directly in volCryostat.
2835 - There are two boards on each the up and downstream end,
2836 one each to wrap the U and V views around the APA frame
2837 - There are 4 on the bottom which anchor the U V and Z wires and the grid plane
2838 - The rest of the parts of the G10 boards must be placed directly in volTPC -->
2841 <volumeref ref="volG10BoardYSideCenterSeg\-$APA_i"/>
2842 <position name="posG10BoardYSideCenterSeg\-Vup\-$APA_i" unit="cm"
2843 x="$APAFrameCenter_x"
2844 y="$APAFrameCenter_y"
2845 z="$APAFrameCenter_z - $APAFrame_z/2 - (0+.5)*($G10BoardYSide_z)"/>
2846 <rotationref ref="rIdentity"/>
2849 <volumeref ref="volG10BoardYSideCenterSeg\-$APA_i"/>
2850 <position name="posG10BoardYSideCenterSeg\-Uup\-$APA_i" unit="cm"
2851 x="$APAFrameCenter_x"
2852 y="$APAFrameCenter_y"
2853 z="$APAFrameCenter_z - $APAFrame_z/2 - (1+.5)*($G10BoardYSide_z)"/>
2854 <rotationref ref="rIdentity"/>
2858 <volumeref ref="volG10BoardYSideCenterSeg\-$APA_i"/>
2859 <position name="posG10BoardYSideCenterSeg\-Vdown\-$APA_i" unit="cm"
2860 x="$APAFrameCenter_x"
2861 y="$APAFrameCenter_y"
2862 z="$APAFrameCenter_z + $APAFrame_z/2 + (0+.5)*($G10BoardYSide_z)"/>
2863 <rotationref ref="rIdentity"/>
2866 <volumeref ref="volG10BoardYSideCenterSeg\-$APA_i"/>
2867 <position name="posG10BoardYSideCenterSeg\-Udown\-$APA_i" unit="cm"
2868 x="$APAFrameCenter_x"
2869 y="$APAFrameCenter_y"
2870 z="$APAFrameCenter_z + $APAFrame_z/2 + (1+.5)*($G10BoardYSide_z)"/>
2871 <rotationref ref="rIdentity"/>
2875 <volumeref ref="volG10BoardZSideCenterSeg\-$APA_i"/>
2876 <position name="posG10BoardZSideCenterSeg\-Z\-$APA_i" unit="cm"
2877 x="$APAFrameCenter_x"
2879 z="$APAFrameCenter_z"/>
2880 <rotationref ref="rIdentity"/>
2883 <volumeref ref="volG10BoardZSideCenterSeg\-$APA_i"/>
2884 <position name="posG10BoardZSideCenterSeg\-V\-$APA_i" unit="cm"
2885 x="$APAFrameCenter_x"
2887 z="$APAFrameCenter_z"/>
2888 <rotationref ref="rIdentity"/>
2891 <volumeref ref="volG10BoardZSideCenterSeg\-$APA_i"/>
2892 <position name="posG10BoardZSideCenterSeg\-U\-$APA_i" unit="cm"
2893 x="$APAFrameCenter_x"
2895 z="$APAFrameCenter_z"/>
2896 <rotationref ref="rIdentity"/>
2899 <volumeref ref="volG10BoardZSideCenterSeg\-$APA_i"/>
2900 <position name="posG10BoardZSideCenterSeg\-Grid\-$APA_i" unit="cm"
2901 x="$APAFrameCenter_x"
2902 y="$posG10ZSideGrid_y"
2903 z="$APAFrameCenter_z"/>
2904 <rotationref ref="rIdentity"/>
2912 # Now loop through paddle y positions and place them
2913 #for( $p=0; $p<$nPaddlesInAPA[$APA_i]; $p++ ){
2915 #if($nPaddlesInAPA[$APA_i]!=1)
2920 # <volumeref ref="volOpDetSensitive"/>
2921 # <position name="posPaddle\-$p\-APA\-$APA_i" unit="cm"
2922 # x="$APAFrameCenter_x"
2923 # y="$APAFrameCenter_y - $APAHeight[$APA_i]/2 + $PaddleYPositions[$APA_i][$p]"
2924 # z="$APAFrameCenter_z"/>
2925 # <rotationref ref="rIdentity"/>
2931 case 0 { place_bar(2);
2934 case 1 { place_bar(1); }
2935 case 2 { place_fiber(1); }
2936 case 3 { place_bar(4);
2949 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2950 #++++++++++++++++++++++++++++++++++++++ solid_CPA +++++++++++++++++++++++++++++++++++++
2951 #++++++++++++++++++++++++++++++++++++++++ vol_CPA +++++++++++++++++++++++++++++++++++++
2952 #++++++++++++++++++++++++++++++++++++++ place_CPA +++++++++++++++++++++++++++++++++++++
2953 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2955 # Must be called only within gen_Cryostat(),
2964 <box name="Cathode" lunit="cm"
2969 <tube name="CPATubeYSide"
2977 <tube name="CPATubeZSide"
2995 <volume name="volCathode">
2996 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
2997 <solidref ref="Cathode"/>
2999 <volume name="volCPATubeYSide">
3000 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
3001 <solidref ref="CPATubeYSide"/>
3003 <volume name="volCPATubeZSide">
3004 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
3005 <solidref ref="CPATubeZSide"/>
3018 $cpaCenter_x = $_[1];
3019 $cpaCenter_y = $_[2];
3020 $cpaCenter_z = $_[3];
3026 <volumeref ref="volCathode"/>
3027 <position name="posCathode\-$cpa" unit="cm"
3028 x="$cpaCenter_x - $Cathode_x/2"
3031 <rotationref ref="rIdentity"/>
3035 Curious... The CPATube_OD used here should be CPATube_OD/2,
3036 but that causes a baffling overlap. look into later!
3040 <volumeref ref="volCPATubeYSide"/>
3041 <position name="posCPATubeYSideUp\-$cpa" unit="cm"
3044 z="$cpaCenter_z - $Cathode_z/2 - $CPATube_OD"/>
3045 <rotationref ref="rPlus90AboutX"/>
3048 <volumeref ref="volCPATubeYSide"/>
3049 <position name="posCPATubeYSideDown\-$cpa" unit="cm"
3052 z="$cpaCenter_z + $Cathode_z/2 + $CPATube_OD"/>
3053 <rotationref ref="rPlus90AboutX"/>
3057 <volumeref ref="volCPATubeZSide"/>
3058 <position name="posCPATubeZSideBottom\-$cpa" unit="cm"
3060 y="$cpaCenter_y - $Cathode_y/2 - $CPATube_OD"
3062 <rotationref ref="rIdentity"/>
3065 <volumeref ref="volCPATubeZSide"/>
3066 <position name="posCPATubeZSideTop\-$cpa" unit="cm"
3068 y="$cpaCenter_y + $Cathode_y/2 + $CPATube_OD"
3070 <rotationref ref="rIdentity"/>
3083 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3084 #+++++++++++++++++++++++++++++++++++++ gen_Enclosure +++++++++++++++++++++++++++++++++++++
3085 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3090 # Create the detector enclosure fragment file name,
3091 # add file to list of output GDML fragments,
3093 $ENCL = "35t_DetEnclosure" . $suffix . ".gdml";
3094 push (@gdmlFiles, $ENCL);
3095 $ENCL = ">" . $ENCL;
3096 open(ENCL) or die("Could not open file $ENCL for writing");
3099 # The standard XML prefix and starting the gdml
3101 <?xml version='1.0'?>
3107 $TopSteelShell_x = $Argon_x - $NeckInside_x;
3109 $FoamSouth_y = $Argon_y + $NeckInside_y + 2*$SteelShellThickness;
3110 $FoamTop_x = $Argon_x - $NeckInside_x;
3111 $NeckConcreteShell_x = $TotalPadding + 2*$SteelShellThickness + $NeckInside_x + $FoamPadding;
3113 $TrenchTopConcrete_x = ($DetEnc_x - $CryoWithPadding_x)/2;
3115 # All the detector enclosure solids.
3119 <box name="DetEnclosure" lunit="cm"
3124 <trd name="AuxDetTrap" lunit="cm"
3125 x1="$AuxDetScintillatorLongSide" x2="$AuxDetScintillatorShortSide"
3126 y1="$AuxDetScintillatorThickness" y2="$AuxDetScintillatorThickness"
3127 z="$AuxDetScintillatorHeight"/>
3129 <box name="TrenchBottomConcrete" lunit="cm"
3133 <box name="TrenchBottomConcreteSubtract" lunit="cm"
3135 y="$DetEnc_y - $TrenchWallThickness"
3136 z="$DetEnc_z - 2*$TrenchWallThickness"/>
3137 <subtraction name="TrenchBottomConcreteShell">
3138 <first ref="TrenchBottomConcrete"/>
3139 <second ref="TrenchBottomConcreteSubtract"/>
3140 <position name="posHoleInTrench" unit="cm" x="0" y="$TrenchWallThickness/2" z="0"/>
3143 <box name="TrenchTopConcrete" lunit="cm"
3144 x="$TrenchTopConcrete_x"
3145 y="$TrenchWallThickness"
3146 z="$DetEnc_z - 2*$TrenchWallThickness"/>
3149 <box name="BottomSteel" lunit="cm"
3150 x="$Cryostat_x + 2*$SteelShellThickness"
3151 y="$Cryostat_y + $SteelShellThickness"
3152 z="$Cryostat_z + 2*$SteelShellThickness"/>
3153 <subtraction name="BottomSteelShell">
3154 <first ref="BottomSteel"/>
3155 <second ref="Cryostat"/>
3156 <position name="posLArInShell" unit="cm" x="0" y="$SteelShellThickness/2" z="0"/>
3160 <box name="Neck" lunit="cm"
3161 x="$NeckInside_x + 2*$SteelShellThickness"
3162 y="$NeckInside_y + $SteelShellThickness"
3163 z="$Cryostat_z + 2*$SteelShellThickness"/>
3164 <box name="NeckArgon" lunit="cm"
3168 <subtraction name="NeckSteelShell">
3170 <second ref="NeckArgon"/>
3171 <position name="posLArInNeckShell" unit="cm" x="0" y="-$SteelShellThickness/2" z="0"/>
3175 <box name="TopSteelShell" lunit="cm"
3176 x="$TopSteelShell_x"
3177 y="$SteelShellThickness"
3178 z="$Cryostat_z + 2*$SteelShellThickness"/>
3181 <box name="FoamSouth" lunit="cm"
3184 z="$Argon_z + 2*$SteelShellThickness + 2*$FoamPadding"/>
3186 <box name="FoamNorth" lunit="cm"
3188 y="$Argon_y + 2*$SteelShellThickness"
3189 z="$Argon_z + 2*$SteelShellThickness + 2*$FoamPadding"/>
3191 <box name="FoamEastWest" lunit="cm"
3192 x="$Argon_x + 2*$SteelShellThickness"
3193 y="$Argon_y + 2*$SteelShellThickness"
3196 <box name="FoamEastWestNeck" lunit="cm"
3197 x="$NeckInside_x + 2*$SteelShellThickness"
3198 y="$NeckInside_y + $SteelShellThickness"
3201 <box name="FoamBottom" lunit="cm"
3202 x="$Argon_x + 2*$SteelShellThickness + 2*$FoamPadding"
3204 z="$Argon_z + 2*$SteelShellThickness + 2*$FoamPadding"/>
3206 <box name="FoamTop" lunit="cm"
3209 z="$Argon_z + 2*$SteelShellThickness + 2*$FoamPadding"/>
3211 <box name="FoamNorthNeck" lunit="cm"
3214 z="$Argon_z + 2*$SteelShellThickness + 2*$FoamPadding"/>
3217 <box name="BottomConcrete" lunit="cm"
3218 x="$Argon_x + 2*($SteelShellThickness+$FoamPadding) + 2*$ConcretePadding"
3219 y="$Argon_y + 2*($SteelShellThickness+$FoamPadding) + $ConcretePadding"
3220 z="$Argon_z + 2*($SteelShellThickness+$FoamPadding) + 2*$ConcretePadding"/>
3221 <box name="BottomConcreteSubtract" lunit="cm"
3222 x="$Argon_x + 2*($SteelShellThickness+$FoamPadding)"
3223 y="$Argon_y + 2*($SteelShellThickness+$FoamPadding)"
3224 z="$Argon_z + 2*($SteelShellThickness+$FoamPadding)"/>
3225 <subtraction name="BottomConcreteShell">
3226 <first ref="BottomConcrete"/>
3227 <second ref="BottomConcreteSubtract"/>
3228 <position name="posHoleInConcrete" unit="cm" x="0" y="$ConcretePadding/2" z="0"/>
3232 <box name="NeckConcrete" lunit="cm"
3233 x="$NeckConcreteShell_x"
3234 y="$NeckInside_y + $SteelShellThickness - $FoamPadding"
3235 z="$Cryostat_z + 2*($SteelShellThickness+$FoamPadding) + 2*$ConcretePadding"/>
3236 <box name="NeckConcreteSubtract" lunit="cm"
3237 x="$NeckInside_x + 2*($SteelShellThickness+$FoamPadding)"
3238 y="$NeckInside_y + $SteelShellThickness - $FoamPadding"
3239 z="$Cryostat_z + 2*($SteelShellThickness+$FoamPadding)"/>
3240 <subtraction name="NeckConcreteShell">
3241 <first ref="NeckConcrete"/>
3242 <second ref="NeckConcreteSubtract"/>
3243 <position name="posHoleInNeckConcrete" unit="cm" x="-$ConcretePadding/2" y="0" z="0"/>
3253 # Detector enclosure structure
3257 <volume name="volBotSteelShell">
3258 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
3259 <solidref ref="BottomSteelShell"/>
3262 <volume name="volTopSteelShell">
3263 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
3264 <solidref ref="TopSteelShell"/>
3267 <volume name="volNeckSteelShell">
3268 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
3269 <solidref ref="NeckSteelShell"/>
3272 <volume name="volNeck">
3273 <materialref ref="ArGas"/>
3274 <solidref ref="Neck"/>
3276 <volumeref ref="volNeckSteelShell"/>
3277 <position name="posNeckSteelShell" unit="cm" x="0" y="0" z="0"/>
3282 <volume name="volFoamSouth">
3283 <materialref ref="polyurethane_foam"/>
3284 <solidref ref="FoamSouth"/>
3286 <volume name="volFoamNorth">
3287 <materialref ref="polyurethane_foam"/>
3288 <solidref ref="FoamNorth"/>
3290 <volume name="volFoamEastWest">
3291 <materialref ref="polyurethane_foam"/>
3292 <solidref ref="FoamEastWest"/>
3294 <volume name="volFoamEastWestNeck">
3295 <materialref ref="polyurethane_foam"/>
3296 <solidref ref="FoamEastWestNeck"/>
3298 <volume name="volFoamBottom">
3299 <materialref ref="polyurethane_foam"/>
3300 <solidref ref="FoamBottom"/>
3302 <volume name="volFoamTop">
3303 <materialref ref="polyurethane_foam"/>
3304 <solidref ref="FoamTop"/>
3306 <volume name="volFoamNorthNeck">
3307 <materialref ref="polyurethane_foam"/>
3308 <solidref ref="FoamNorthNeck"/>
3311 <volume name="volBottomConcreteShell">
3312 <materialref ref="Concrete"/>
3313 <solidref ref="BottomConcreteShell"/>
3315 <volume name="volNeckConcreteShell">
3316 <materialref ref="Concrete"/>
3317 <solidref ref="NeckConcreteShell"/>
3320 <volume name="volTrenchBottomConcreteShell">
3321 <materialref ref="Concrete"/>
3322 <solidref ref="TrenchBottomConcreteShell"/>
3324 <volume name="volTrenchTopConcrete">
3325 <materialref ref="Concrete"/>
3326 <solidref ref="TrenchTopConcrete"/>
3330 for($i = 1; $i <= 13; ++$i){
3332 <volume name="volAuxDetBoxBSU-L1-$i" >
3333 <materialref ref="Acrylic"/>
3334 <solidref ref="AuxDetBoxBSU"/>
3338 for($i = 1; $i <= 10; ++$i){
3340 <volume name="volAuxDetBoxBSU-L2-$i" >
3341 <materialref ref="Acrylic"/>
3342 <solidref ref="AuxDetBoxBSU"/>
3346 for($i = 1; $i <= 16; ++$i){
3348 <volume name="volAuxDetBoxBSU-L3-$i" >
3349 <materialref ref="Acrylic"/>
3350 <solidref ref="AuxDetBoxBSU"/>
3354 for($i = 1; $i <= 10; ++$i){
3356 <volume name="volAuxDetBoxBSU-L4-$i" >
3357 <materialref ref="Acrylic"/>
3358 <solidref ref="AuxDetBoxBSU"/>
3363 for ($i=1; $i<=12; ++$i) {
3365 <volume name="volAuxDetTrap-South-$i" >
3366 <materialref ref="Acrylic"/>
3367 <solidref ref="AuxDetTrap"/>
3369 <volume name="volAuxDetTrap-North-$i" >
3370 <materialref ref="Acrylic"/>
3371 <solidref ref="AuxDetTrap"/>
3375 for ($i=1; $i<=10; ++$i) {
3377 <volume name="volAuxDetTrap-East-$i" >
3378 <materialref ref="Acrylic"/>
3379 <solidref ref="AuxDetTrap"/>
3381 <volume name="volAuxDetTrap-West-$i" >
3382 <materialref ref="Acrylic"/>
3383 <solidref ref="AuxDetTrap"/>
3389 <volume name="volDetEnclosure">
3390 <materialref ref="Air"/>
3391 <solidref ref="DetEnclosure"/>
3394 <volumeref ref="volCryostat"/>
3395 <position name="posCryo" unit="cm" x="$posCryoInDetEnc_x" y="$posCryoInDetEnc_y" z="$posCryoInDetEnc_z"/>
3399 <volumeref ref="volNeck"/>
3400 <position name="posNeck" unit="cm"
3401 x="$posCryoInDetEnc_x + $Argon_x/2 - $NeckInside_x/2"
3402 y="$posCryoInDetEnc_y + $Argon_y/2 + ($NeckInside_y + $SteelShellThickness)/2"
3403 z="$posCryoInDetEnc_z"/>
3406 <volumeref ref="volTopSteelShell"/>
3407 <position name="posTopSteelShell" unit="cm"
3408 x="$posCryoInDetEnc_x - $Argon_x/2 - $SteelShellThickness + $TopSteelShell_x/2"
3409 y="$posCryoInDetEnc_y + $Argon_y/2 + $SteelShellThickness/2"
3410 z="$posCryoInDetEnc_z"/>
3413 <volumeref ref="volBotSteelShell"/>
3414 <position name="posBotSteelShell" unit="cm"
3415 x="$posCryoInDetEnc_x"
3416 y="$posCryoInDetEnc_y - $SteelShellThickness/2"
3417 z="$posCryoInDetEnc_z"/>
3422 <volumeref ref="volFoamSouth"/>
3423 <position name="posFoamSouth" unit="cm"
3424 x="$posCryoInDetEnc_x + $Argon_x/2 + $SteelShellThickness + $FoamPadding/2"
3425 y="$posCryoInDetEnc_y - $Argon_y/2 - $SteelShellThickness + $FoamSouth_y/2"
3426 z="$posCryoInDetEnc_z"/>
3429 <volumeref ref="volFoamNorth"/>
3430 <position name="posFoamNorth" unit="cm"
3431 x="$posCryoInDetEnc_x - $Argon_x/2 - $SteelShellThickness - $FoamPadding/2"
3432 y="$posCryoInDetEnc_y"
3433 z="$posCryoInDetEnc_z"/>
3436 <volumeref ref="volFoamEastWest"/>
3437 <position name="posFoamEast" unit="cm"
3438 x="$posCryoInDetEnc_x"
3439 y="$posCryoInDetEnc_y"
3440 z="$posCryoInDetEnc_z - $Argon_z/2 - $SteelShellThickness - $FoamPadding/2"/>
3443 <volumeref ref="volFoamEastWest"/>
3444 <position name="posFoamWest" unit="cm"
3445 x="$posCryoInDetEnc_x"
3446 y="$posCryoInDetEnc_y"
3447 z="$posCryoInDetEnc_z + $Argon_z/2 + $SteelShellThickness + $FoamPadding/2"/>
3450 <volumeref ref="volFoamEastWestNeck"/>
3451 <position name="posFoamEastNeck" unit="cm"
3452 x="$posCryoInDetEnc_x + $Argon_x/2 - $NeckInside_x/2"
3453 y="$posCryoInDetEnc_y + $Argon_y/2 + ($NeckInside_y + $SteelShellThickness)/2"
3454 z="$posCryoInDetEnc_z - $Argon_z/2 - $SteelShellThickness - $FoamPadding/2"/>
3457 <volumeref ref="volFoamEastWestNeck"/>
3458 <position name="posFoamWestNeck" unit="cm"
3459 x="$posCryoInDetEnc_x + $Argon_x/2 - $NeckInside_x/2"
3460 y="$posCryoInDetEnc_y + $Argon_y/2 + ($NeckInside_y + $SteelShellThickness)/2"
3461 z="$posCryoInDetEnc_z + $Argon_z/2 + $SteelShellThickness + $FoamPadding/2"/>
3464 <volumeref ref="volFoamBottom"/>
3465 <position name="posFoamBottom" unit="cm"
3466 x="$posCryoInDetEnc_x"
3467 y="$posCryoInDetEnc_y - $Argon_y/2 - $SteelShellThickness - $FoamPadding/2"
3468 z="$posCryoInDetEnc_z"/>
3471 <volumeref ref="volFoamTop"/>
3472 <position name="posFoamTop" unit="cm"
3473 x="$posCryoInDetEnc_x - $Argon_x/2 - $SteelShellThickness - $FoamPadding + $FoamTop_x/2"
3474 y="$posCryoInDetEnc_y + $Argon_y/2 + $SteelShellThickness + $FoamPadding/2"
3475 z="$posCryoInDetEnc_z"/>
3478 <volumeref ref="volFoamNorthNeck"/>
3479 <position name="posFoamNorthNeck" unit="cm"
3480 x="$posCryoInDetEnc_x + $Argon_x/2 - $NeckInside_x - $SteelShellThickness - $FoamPadding/2"
3481 y="$posCryoInDetEnc_y + $Argon_y/2 + $SteelShellThickness + $NeckInside_y/2"
3482 z="$posCryoInDetEnc_z"/>
3487 <volumeref ref="volBottomConcreteShell"/>
3488 <position name="posBottomConcreteShell" unit="cm"
3489 x="$posCryoInDetEnc_x"
3490 y="$posCryoInDetEnc_y - $ConcretePadding/2"
3491 z="$posCryoInDetEnc_z"/>
3494 <volumeref ref="volNeckConcreteShell"/>
3495 <position name="posNeckConcreteShell" unit="cm"
3496 x="$posCryoInDetEnc_x + $Argon_x/2 +$SteelShellThickness + $TotalPadding - $NeckConcreteShell_x/2"
3497 y="$posCryoInDetEnc_y + $Argon_y/2 + $FoamPadding + ($NeckInside_y + $SteelShellThickness - $FoamPadding)/2"
3498 z="$posCryoInDetEnc_z"/>
3504 <volumeref ref="volTrenchBottomConcreteShell"/>
3505 <position name="posTrenchConcrete" unit="cm" x="0" y="0" z="0"/>
3507 <!-- Concrete is too heavy for the roof
3509 <volumeref ref="volTrenchTopConcrete"/>
3510 <position name="posTrenchConcreteTop_Pos" unit="cm"
3511 x=" + $DetEnc_x/2 - $TrenchTopConcrete_x/2"
3512 y="$DetEnc_y/2 - $TrenchWallThickness/2"
3516 <volumeref ref="volTrenchTopConcrete"/>
3517 <position name="posTrenchConcreteTop_Neg" unit="cm"
3518 x=" - $DetEnc_x/2 + $TrenchTopConcrete_x/2"
3519 y="$DetEnc_y/2 - $TrenchWallThickness/2"
3528 # place the 12 North Wall AuxDets
3529 #$NorthWallInt_z = ((95+108)/2 - (35+48)/2)*$inch/5;
3530 $NorthWallInt_z = ( 274.32-(274.32-213.36)/4 - (88.9+121.92)/2 )/5;
3531 for ($i=1; $i<=12; ++$i)
3533 #$FromCryoCorner_z = (35+48)/2*$inch + (($i-1) % 6)*$NorthWallInt_z;
3534 $FromCryoCorner_z = (88.9+121.92)/2 + (($i-1) % 6)*$NorthWallInt_z;
3536 $rotation = "rAuxDetNSWallUp";
3537 if($i>6) { $FromCryoCorner_y = (259.08 + 0.12*$inch) + $AuxDetScintillatorHeight/2; }
3538 else { $FromCryoCorner_y = (66.04 + 0.12*$inch) + $AuxDetScintillatorHeight/2; }
3541 $rotation = "rAuxDetNSWallDown";
3542 if($i>6) { $FromCryoCorner_y = (325.12 - 0.12*$inch) - $AuxDetScintillatorHeight/2; }
3543 else { $FromCryoCorner_y = (132.08 - 0.12*$inch) - $AuxDetScintillatorHeight/2; }
3546 $posAuxDet_y = $posCryoInDetEnc_y - 375.92/2 + $FromCryoCorner_y;
3550 <volumeref ref="volAuxDetTrap-North-$i"/>
3551 <position name="posAuxDet-North-$i" unit="cm"
3552 x=" $posCryoInDetEnc_x - $CryoWithPadding_x/2 - $AuxDetHousingThickness/2"
3554 z=" $posCryoInDetEnc_z - 411.99/2 + $FromCryoCorner_z"/>
3555 <rotationref ref="$rotation"/>
3561 # place the 12 South Wall AuxDets
3562 #$SouthWallInt_z = ((96.5+109.6)/2 - (36.8+49.5)/2)*$inch/5;
3563 $SouthWallInt_z = ( (245.11+278.38)/2 - (93.47+(153.67-93.47)/4) )/5;
3564 for ($i=1; $i<=12; ++$i)
3566 #$FromCryoCorner_z = (96.5+109.6)/2*$inch - (($i-1) % 6)*$SouthWallInt_z;
3567 $FromCryoCorner_z = (245.11+278.38)/2 - (($i-1) % 6)*$SouthWallInt_z;
3569 $rotation = "rAuxDetNSWallUp";
3570 if($i>6) { $FromCryoCorner_y = (272.11 + 0.12*$inch) + $AuxDetScintillatorHeight/2; }
3571 else { $FromCryoCorner_y = (31.5 + 0.12*$inch) + $AuxDetScintillatorHeight/2; }
3574 $rotation = "rAuxDetNSWallDown";
3575 if($i>6) { $FromCryoCorner_y = (335.61 - 0.12*$inch) - $AuxDetScintillatorHeight/2; }
3576 else { $FromCryoCorner_y = (93.98 - 0.12*$inch) - $AuxDetScintillatorHeight/2; }
3579 $posAuxDet_y = $posCryoInDetEnc_y - 375.92/2 + $FromCryoCorner_y;
3583 <volumeref ref="volAuxDetTrap-South-$i"/>
3584 <position name="posAuxDet-South-$i" unit="cm"
3585 x=" $posCryoInDetEnc_x + $CryoWithPadding_x/2 + $AuxDetHousingThickness/2"
3587 z=" $posCryoInDetEnc_z - 411.99/2 + $FromCryoCorner_z"/>
3588 <rotationref ref="$rotation"/>
3594 # place the 10 East Wall AuxDets
3595 #$EastWallInt_x = ((136.7+149.9)/2 - (28.4+41.4)/2)*$inch/9;
3596 $EastWallInt_x = ( (347.48+380.75)/2 - (72.14+(133.1-72.14)/4) )/9;
3597 for ($i=1; $i<=10; ++$i)
3600 # +6cm shift (towards the south wall) as requested by Michelle Stancari
3601 $FromCryoCorner_x = (347.48+380.75)/2 - ($i-1)*$EastWallInt_x + 6;
3602 if($i%2==1){ $rotation = "rAuxDetEWWallUp";
3603 $FromCryoCorner_y = ( 47 + 0.12*$inch) + $AuxDetScintillatorHeight/2; }
3604 else { $rotation = "rAuxDetEWWallDown";
3605 $FromCryoCorner_y = (112.45 - 0.12*$inch) - $AuxDetScintillatorHeight/2; }
3607 $posAuxDet_y = $posCryoInDetEnc_y - 375.92/2 + $FromCryoCorner_y;
3611 <volumeref ref="volAuxDetTrap-East-$i"/>
3612 <position name="posAuxDet-East-$i" unit="cm"
3613 x=" $posCryoInDetEnc_x - 541.53/2 + $FromCryoCorner_x"
3615 z=" $posCryoInDetEnc_z - $CryoWithPadding_z/2 - $AuxDetHousingThickness/2"/>
3616 <rotationref ref="$rotation"/>
3623 # place the 10 West Wall AuxDets
3624 #$WestWallInt_x = ((134+147)/2 - (26.3+39.3)/2)*$inch/9;
3625 $WestWallInt_x = ( (373.38-(373.38-312.42)/2) - (66.11+99.82)/2 )/9;
3626 for ($i=1; $i<=10; ++$i)
3629 # +6cm shift (towards the south wall) as requested by Michelle Stancari
3630 $FromCryoCorner_x = (66.11+99.82)/2 + ($i-1)*$WestWallInt_x + 6;
3631 if($i%2==1){ $rotation = "rAuxDetEWWallUp";
3632 $FromCryoCorner_y = (264.44 + 0.12*$inch) + $AuxDetScintillatorHeight/2 }
3633 else { $rotation = "rAuxDetEWWallDown";
3634 $FromCryoCorner_y = (329.95 - 0.12*$inch) - $AuxDetScintillatorHeight/2 }
3636 $posAuxDet_y = $posCryoInDetEnc_y - 375.92/2 + $FromCryoCorner_y;
3640 <volumeref ref="volAuxDetTrap-West-$i"/>
3641 <position name="posAuxDet-West-$i" unit="cm"
3642 x=" $posCryoInDetEnc_x - 541.53/2 + $FromCryoCorner_x"
3644 z=" $posCryoInDetEnc_z + $CryoWithPadding_z/2 + $AuxDetHousingThickness/2"/>
3645 <rotationref ref="$rotation"/>
3651 # place the 13 Layer 1 telescope counters
3652 for ($i=1; $i<=13; ++$i)
3656 <volumeref ref="volAuxDetBoxBSU-L1-$i"/>
3657 <position name="posAuxDet-BSU-L1-$i" unit="cm"
3658 x="$BSULayer1_xpos[$i-1] - $OriginXSet"
3659 y="$BSULayer1_ypos - $OriginYSet"
3660 z="$BSULayer1_zpos - $OriginZSet"/>
3665 # place the 9 Layer 2 telescope counters
3666 for ($i=1; $i<=10; ++$i)
3670 <volumeref ref="volAuxDetBoxBSU-L2-$i"/>
3671 <position name="posAuxDet-BSU-L2-$i" unit="cm"
3672 x="$BSULayer2_xpos - $OriginXSet"
3673 y="$BSULayer2_ypos - $OriginYSet"
3674 z="$BSULayer2_zpos[$i-1] - $OriginZSet"/>
3675 <rotationref ref="rPlus90AboutY"/>
3693 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3694 #+++++++++++++++++++++++++++++++++++++++ gen_World +++++++++++++++++++++++++++++++++++++++
3695 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3700 # Create the WORLD fragment file name,
3701 # add file to list of output GDML fragments,
3703 $WORLD = "35t_World" . $suffix . ".gdml";
3704 push (@gdmlFiles, $WORLD);
3705 $WORLD = ">" . $WORLD;
3706 open(WORLD) or die("Could not open file $WORLD for writing");
3709 # The standard XML prefix and starting the gdml
3711 <?xml version='1.0'?>
3715 $Dirt_y = $OriginYSet + $World_y/2 + $DetEnc_y/2;
3717 # All the World solids.
3720 <box name="World" lunit="cm"
3725 <box name="AuxDetBoxBSU" lunit="cm"
3726 x="$AuxDetBSUScintWidth"
3727 y="$AuxDetBSUScintHeight"
3728 z="$AuxDetBSUScintLength"/>
3730 <box name="DirtBlock" lunit="cm"
3734 <subtraction name="DirtWithHole">
3735 <first ref="DirtBlock"/>
3736 <second ref="DetEnclosure"/>
3737 <position name="posHoleInDirt" unit="cm"
3739 y="$Dirt_y/2 - $DetEnc_y/2"
3758 <volume name="volDirtWithHole" >
3759 <materialref ref="Dirt"/>
3760 <solidref ref="DirtWithHole"/>
3762 <volume name="volBerm" >
3763 <materialref ref="Dirt"/>
3764 <solidref ref="Berm"/>
3767 <volume name="volWorld" >
3768 <materialref ref="Air"/>
3769 <solidref ref="World"/>
3771 <volumeref ref="volDetEnclosure"/>
3772 <position name="posDetEnclosure" unit="cm"
3778 <volumeref ref="volDirtWithHole"/>
3779 <position name="posDirtWithHole" unit="cm"
3781 y=" -$World_y/2 + $Dirt_y/2 "
3785 <volumeref ref="volBerm"/>
3786 <position name="posBerm" unit="cm"
3788 y="$OriginYSet + $DetEnc_y/2 "
3789 z="$OriginZSet + $DetEnc_z/2 + $BermRadius"/>
3790 <rotationref ref="rPlus90AboutY"/>
3796 # place the 16 Layer 3 telescope counters
3797 for ($i=1; $i<=16; ++$i)
3801 <volumeref ref="volAuxDetBoxBSU-L3-$i"/>
3802 <position name="posAuxDetBox-BSU-L3-$i" unit="cm"
3803 x="$BSULayer3_xpos[$i-1]"
3805 z="$BSULayer3_zpos"/>
3810 # place the 10 Layer 4 telescope counters
3811 for ($i=1; $i<=10; ++$i)
3815 <volumeref ref="volAuxDetBoxBSU-L4-$i"/>
3816 <position name="posAuxDetBox-BSU-L4-$i" unit="cm"
3819 z="$BSULayer4_zpos[$i-1]"/>
3820 <rotationref ref="rPlus90AboutY"/>
3825 # place the 16 Layer 5 telescope counters
3826 #for ($i=1; $i<=16; ++$i)
3831 # <volumeref ref="volAuxDetBoxBSU-L5-$i"/>
3832 # <position name="posAuxDet-BSU-L5-$i" unit="cm"
3833 # x="$BSULayer5_xpos[$i-1]"
3834 # y="$BSULayer5_ypos"
3835 # z="$BSULayer5_zpos"/>
3848 # make_gdml.pl will take care of <setup/>
3853 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3854 #++++++++++++++++++++++++++++++++++++ write_fragments ++++++++++++++++++++++++++++++++++++
3855 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3857 sub write_fragments()
3859 # This subroutine creates an XML file that summarizes the the subfiles output
3860 # by the other sub routines - it is the input file for make_gdml.pl which will
3861 # give the final desired GDML file. Specify its name with the output option.
3862 # (you can change the name when running make_gdml)
3864 if ( ! defined $output )
3866 $output = "-"; # write to STDOUT
3869 # Set up the output file.
3870 $OUTPUT = ">" . $output;
3871 open(OUTPUT) or die("Could not open file $OUTPUT");
3874 <?xml version='1.0'?>
3876 <!-- Input to Geometry/gdml/make_gdml.pl; define the GDML fragments
3877 that will be zipped together to create a detector description.
3884 <!-- These files contain GDML <constant></constant>
3885 blocks. They are read in separately, so they can be
3886 interpreted into the remaining GDML. See make_gdml.pl for
3892 foreach $filename (@defFiles)
3895 <filename> $filename </filename>
3905 <!-- The GDML file fragments to be zipped together. -->
3909 foreach $filename (@gdmlFiles)
3912 <filename> $filename </filename>
3927 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3928 #++++++++++++++++++++++++++++++++++++++ place_bars +++++++++++++++++++++++++++++++++++++++
3929 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3936 # for($j=1; $j<$numberofbars+1; $j++)
3939 $pos_ref_name="Bar" . $_[0] . "Pos";
3942 <volumeref ref="volOpDetSensitive_Bar"/>
3943 <positionref ref="$pos_ref_name"/>
3951 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3952 #++++++++++++++++++++++++++++++++++++++ place_plank ++++++++++++++++++++++++++++++++++++++
3953 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3961 $pos_ref_name="PlankPos";
3964 <volumeref ref="volOpDetSensitive_Plank"/>
3965 <positionref ref="$pos_ref_name"/>
3970 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3971 #++++++++++++++++++++++++++++++++++++++ place_fibers +++++++++++++++++++++++++++++++++++++
3972 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3977 <!-- 32 Fiber Module $_[0]-->
3981 ############################# Fiber ##############################
3982 $pos_ref_name="Fiber" . $_[0] . "Pos";
3985 <volumeref ref="volOpDetSensitive_Fiber"/>
3986 <positionref ref="$pos_ref_name"/>