3 ##################################################################################
5 # This script is based on generate_dunedphase10kt_v2.pl (see description
6 # in there file for more info). Some parameters were changed to generate
7 # a first version of the 3x1x1 dual phase geometry (e.g. driftTPCActive
8 # and number of CRM's).
9 # More detector elements are going to be added (e.g. PMTs, field cage, ...)
10 # For more info, please contact Christoph Alt: christoph.alt@cern.ch
12 # !!!NOTE!!!: the readout is on a positive Y
13 ##################################################################################
15 # 26/11/2018 - j.soto@cern.ch - This updates are not included in the drift in X geometries!
16 # Added Field Cage, Ground Grid, LEMS, Extraction Grid, Cathode and corrected the PMT positions.
17 # All these new elements are included by default.
18 ##################################################################################
26 Math::BigFloat->precision(-16);
28 GetOptions( "help|h" => \$help,
29 "suffix|s:s" => \$suffix,
30 "output|o:s" => \$output,
31 "wires|w:s" => \$wires);
34 my $FieldCage_switch="on";
35 my $Cathode_switch="on";
36 my $GroundGrid_switch="on";
37 my $ExtractionGrid_switch="on";
43 # If the user requested help, print the usage notes and exit.
48 if ( ! defined $suffix )
50 # The user didn't supply a suffix, so append nothing to the file
56 # Otherwise, stick a "-" before the suffix, so that a suffix of
57 # "test" applied to filename.gdml becomes "filename-test.gdml".
58 $suffix = "-" . $suffix;
61 #if ( ! defined $workspace ) # not done
65 #elsif ( $workspace == 1)
67 # print "\t\tCreating smaller workspace geometry.\n";
70 # set wires on to be the default, unless given an input by the user
71 $wires_on = 1; # 1=on, 0=off
79 $basename = "3x1x1dphase_driftY";
82 $basename = $basename."_nowires";
85 #if ( $workspace == 1 )
87 # $basename = $basename."_workspace";
91 ##################################################################
92 ############## Parameters for Charge Readout Plane ###############
95 $wirePitch = 0.3125; # channel pitch
96 $nChannelsLengthPerCRM = 960; # channels along the length of the CRM
97 $nChannelsWidthPerCRM = 320; # channels along the width of the CRM
98 $borderCRM = 0.5; # dead space at the border of each CRM
100 # dimensions of a single Charge Readout Module (CRM)
101 $widthCRM_active = $wirePitch * $nChannelsWidthPerCRM;
102 $lengthCRM_active = $wirePitch * $nChannelsLengthPerCRM;
104 $widthCRM = $widthCRM_active + 2 * $borderCRM;
105 $lengthCRM = $lengthCRM_active + 2 * $borderCRM;
107 # number of CRMs in y and z
111 # calculate tpc area based on number of CRMs and their dimensions
112 $widthTPCActive = $nCRM_x * $widthCRM; # around 100
113 $lengthTPCActive = $nCRM_z * $lengthCRM; # around 300
115 # active volume dimensions
116 $driftTPCActive = 100.0;
118 # model anode strips as wires
120 $ReadoutPlane = 2 * $padWidth;
122 #$padHeight = 0.0035;
124 ##################################################################
125 ############## Parameters for TPC and inner volume ###############
127 # inner volume dimensions of the cryostat
132 # height of gas argon layer on top
133 $HeightGaseousAr = 50.8;
135 # size of liquid argon buffer
136 $xLArBuffer = 0.5 * ($Argon_x - $widthTPCActive);
137 $yLArBuffer = $Argon_y - $driftTPCActive - $HeightGaseousAr - $ReadoutPlane;
138 $zLArBuffer = 0.5 * ($Argon_z - $lengthTPCActive);
141 $SteelThickness = 0.12; # membrane
143 $Cryostat_x = $Argon_x + 2*$SteelThickness;
144 $Cryostat_y = $Argon_y + 2*$SteelThickness;
145 $Cryostat_z = $Argon_z + 2*$SteelThickness;
147 ##################################################################
148 ############## DetEnc and World relevant parameters #############
150 $SteelSupport_x = 0.6;
151 $SteelSupport_y = 0.6;
152 $SteelSupport_z = 0.6;
153 $FoamPadding = 102.3;
154 $FracMassOfSteel = 0.5; #The steel support is not a solid block, but a mixture of air and steel
155 $FracMassOfAir = 1 - $FracMassOfSteel;
158 $SpaceSteelSupportToWall = 0;
159 $SpaceSteelSupportToCeiling = 0;
161 $DetEncX = $Cryostat_x
162 + 2*($SteelSupport_x + $FoamPadding) + 2*$SpaceSteelSupportToWall;
164 $DetEncY = $Cryostat_y
165 + 2*($SteelSupport_y + $FoamPadding) + $SpaceSteelSupportToCeiling;
167 $DetEncZ = $Cryostat_z
168 + 2*($SteelSupport_z + $FoamPadding) + 2*$SpaceSteelSupportToWall;
170 $posCryoInDetEnc_y = - $DetEncY/2 + $SteelSupport_y + $FoamPadding + $Cryostat_y/2;
173 # 2*AirThickness is added to the world volume in x, y and z
174 $AirThickness = 3000;
176 # We want the world origin to be vertically centered on active TPC
177 # This is to be added to the x and y position of every volume in volWorld
179 $OriginXSet = $DetEncX/2.0
180 -$SpaceSteelSupportToWall
185 -$widthTPCActive/2.0;
187 $OriginYSet = $DetEncY/2.0
192 - $driftTPCActive/2.0;
194 # We want the world origin to be at the very front of the fiducial volume.
195 # move it to the front of the enclosure, then back it up through the concrete/foam,
196 # then through the Cryostat shell, then through the upstream dead LAr (including the
197 # dead LAr on the edge of the TPC)
198 # This is to be added to the z position of every volume in volWorld
200 $OriginZSet = $DetEncZ/2.0
201 - $SpaceSteelSupportToWall
209 ##################################################################
210 ############### Parameters for det elements ######################
211 ##################################################################
212 ############## Field Cage, Cathode and Ground Grid Parameters ###############
214 $FieldShaperLongTubeLength = 312.17;
215 $FieldShaperShortTubeLength = 112.17;
216 $FieldShaperInnerRadius = 1.485;
217 $FieldShaperOuterRadius = 1.685;
218 $FieldShaperTorRad = 1.69;
220 $FieldShaperLength = $FieldShaperLongTubeLength + 2*$FieldShaperOuterRadius+ 2*$FieldShaperTorRad;
221 $FieldShaperWidth = $FieldShaperShortTubeLength + 2*$FieldShaperOuterRadius+ 2*$FieldShaperTorRad;
223 $FieldShaperSeparation = 5.0;
224 $NFieldShapers = ($driftTPCActive/$FieldShaperSeparation) - 1;
226 $FieldCageSizeX = $FieldShaperWidth+2;
227 $FieldCageSizeY = $FieldShaperSeparation*$NFieldShapers+2;
228 $FieldCageSizeZ = $FieldShaperLength+2;
230 $CathodeCableRadius=0.38;
231 $CathodeCableSeparation=4;
232 $CathodeCableLength=112.18;
233 $CathodeNumberOfCables=76;
235 $CathodeHeight=2*$FieldShaperOuterRadius+0.05;
236 $CathodeLength=$FieldShaperLength+0.5;
237 $CathodeWidth=$FieldShaperWidth+0.5;
238 $CathodeGroundGridSeparation=20;
239 $GroundPMTSeparation=1.727;
242 $LEMsFFSSeparation=3.0;
243 $FFSPositionHeight=$Argon_y/2-$HeightGaseousAr-$LEMsFFSSeparation+0.5;
244 $CathodePositionHeight=$FFSPositionHeight-($NFieldShapers*$FieldShaperSeparation);
245 $GroundGridPositionHeight=$CathodePositionHeight-$CathodeGroundGridSeparation;
246 $PMTposHeight=$CathodePositionHeight-$CathodeGroundGridSeparation-$GroundPMTSeparation;
247 $PMTposHeight=-65.114;
249 #-$OriginYSet+(1+$i-$NFieldShapers*0.5)*$FieldShaperSeparation
252 ##################################################################
253 ############## Parameters for PMTs ###############
255 #pos in cm inside the cryostat X coordinate: 2.3cm from the ground grid
256 @pmt_pos = ( " x=\"0\" y=\"$PMTposHeight\" z=\"-92.246\"", #-92.246"', #PMT1 - negative base - direct coating #x="-50-4.5+5.5*2.54-1.27*2.54-2.3"
257 " x=\"0\" y=\"$PMTposHeight\" z=\"-46.123\"", #-46.123"', #PMT2- negative base - plate
258 " x=\"0\" y=\"$PMTposHeight\" z=\"0\"", #PMT3 - positive base - direct coating
259 " x=\"0\" y=\"$PMTposHeight\" z=\"46.123\"", #46.123"', #PMT4 - positive base - plate
260 " x=\"0\" y=\"$PMTposHeight\" z=\"92.246\""); #92.246"'); #PMT5 - negative base - direct coating
263 #+++++++++++++++++++++++++ End defining variables ++++++++++++++++++++++++++
266 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
267 #+++++++++++++++++++++++++++++++++++++++++ usage +++++++++++++++++++++++++++++++++++++++++
268 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
272 print "Usage: $0 [-h|--help] [-o|--output <fragments-file>] [-s|--suffix <string>]\n";
273 print " if -o is omitted, output goes to STDOUT; <fragments-file> is input to make_gdml.pl\n";
274 print " -s <string> appends the string to the file names; useful for multiple detector versions\n";
275 print " -h prints this message, then quits\n";
280 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
281 #++++++++++++++++++++++++++++++++++++++ gen_Define +++++++++++++++++++++++++++++++++++++++
282 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
287 # Create the <define> fragment file name,
288 # add file to list of fragments,
290 $DEF = $basename."_Def" . $suffix . ".gdml";
291 push (@gdmlFiles, $DEF);
293 open(DEF) or die("Could not open file $DEF for writing");
297 <?xml version='1.0'?>
307 <position name="posCryoInDetEnc" unit="cm" x="0" y="$posCryoInDetEnc_y" z="0"/>
308 <position name="posCenter" unit="cm" x="0" y="0" z="0"/>
309 <rotation name="rPlus90AboutX" unit="deg" x="90" y="0" z="0"/>
310 <rotation name="rPlus90AboutY" unit="deg" x="0" y="90" z="0"/>
311 <rotation name="rPlus90AboutXPlus90AboutY" unit="deg" x="90" y="90" z="0"/>
312 <rotation name="rMinus90AboutX" unit="deg" x="270" y="0" z="0"/>
313 <rotation name="rMinus90AboutY" unit="deg" x="0" y="270" z="0"/>
314 <rotation name="rMinus90AboutYMinus90AboutX" unit="deg" x="270" y="270" z="0"/>
315 <rotation name="rPlus180AboutX" unit="deg" x="180" y="0" z="0"/>
316 <rotation name="rPlus180AboutY" unit="deg" x="0" y="180" z="0"/>
317 <rotation name="rPlus180AboutXPlus180AboutY" unit="deg" x="180" y="180" z="0"/>
318 <rotation name="rIdentity" unit="deg" x="0" y="0" z="0"/>
325 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
326 #+++++++++++++++++++++++++++++++++++++ gen_Materials +++++++++++++++++++++++++++++++++++++
327 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
332 # Create the <materials> fragment file name,
333 # add file to list of output GDML fragments,
335 $MAT = $basename."_Materials" . $suffix . ".gdml";
336 push (@gdmlFiles, $MAT);
339 open(MAT) or die("Could not open file $MAT for writing");
341 # Add any materials special to this geometry by defining a mulitline string
342 # and passing it to the gdmlMaterials::gen_Materials() function.
344 <!-- preliminary values -->
345 <material name="AirSteelMixture" formula="AirSteelMixture">
346 <D value=" @{[0.001205*(1-$FracMassOfSteel) + 7.9300*$FracMassOfSteel]} " unit="g/cm3"/>
347 <fraction n="$FracMassOfSteel" ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
348 <fraction n="$FracMassOfAir" ref="Air"/>
352 # add the general materials used anywere
353 print MAT gdmlMaterials::gen_Materials( $asmix );
358 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
359 #++++++++++++++++++++++++++++++++++++++++ gen_TPC ++++++++++++++++++++++++++++++++++++++++
360 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
364 my $TPCActive_x = $widthCRM_active;
365 my $TPCActive_y = $driftTPCActive;
366 my $TPCActive_z = $lengthCRM_active;
369 my $TPC_x = $widthCRM;
370 my $TPC_y = $TPCActive_y + $ReadoutPlane;
371 my $TPC_z = $lengthCRM;
374 $TPC = $basename."_TPC" . $suffix . ".gdml";
375 push (@gdmlFiles, $TPC);
377 open(TPC) or die("Could not open file $TPC for writing");
379 # The standard XML prefix and starting the gdml
381 <?xml version='1.0'?>
386 # All the TPC solids save the wires.
389 <box name="CRM" lunit="cm"
393 <box name="CRMXPlane" lunit="cm"
397 <box name="CRMZPlane" lunit="cm"
401 <box name="CRMActive" lunit="cm"
408 #++++++++++++++++++++++++++++ Wire Solids ++++++++++++++++++++++++++++++
409 # in principle we only need only one wire solid, since CRM is a square
410 # but to be more general ...
414 <tube name="CRMWireX"
415 rmax="@{[0.5*$padWidth]}"
420 <tube name="CRMWireZ"
421 rmax="@{[0.5*$padWidth]}"
431 # Begin structure and create wire logical volumes
434 <volume name="volTPCActive">
435 <materialref ref="LAr"/>
436 <solidref ref="CRMActive"/>
437 <auxiliary auxtype="SensDet" auxvalue="SimEnergyDeposit"/>
444 <volume name="volTPCWireX">
445 <materialref ref="Copper_Beryllium_alloy25"/>
446 <solidref ref="CRMWireX"/>
449 <volume name="volTPCWireZ">
450 <materialref ref="Copper_Beryllium_alloy25"/>
451 <solidref ref="CRMWireZ"/>
458 <volume name="volTPCPlaneX">
459 <materialref ref="LAr"/>
460 <solidref ref="CRMXPlane"/>
463 if ($wires_on==1) # add wires to X plane (plane with wires reading x position)
465 for($i=0;$i<$nChannelsWidthPerCRM;++$i)
467 my $xpos = -0.5 * $TPCActive_x + ($i+0.5)*$wirePitch + 0.5*$padWidth;
471 <volumeref ref="volTPCWireX"/>
472 <position name="posWireX$i" unit="cm" x="$xpos" y="0" z="0"/>
473 <rotationref ref="rIdentity"/>
482 <volume name="volTPCPlaneZ">
483 <materialref ref="LAr"/>
484 <solidref ref="CRMZPlane"/>
488 if ($wires_on==1) # add wires to Z plane (plane with wires reading z position)
490 for($i=0;$i<$nChannelsLengthPerCRM;++$i)
493 my $zpos = -0.5 * $TPCActive_z + ($i+0.5)*$wirePitch + 0.5*$padWidth;
496 <volumeref ref="volTPCWireZ"/>
497 <position name="posWireZ$i" unit="cm" x="0" y="0" z="$zpos"/>
498 <rotationref ref="rPlus90AboutXPlus90AboutY"/>
511 $posXplane[1] = 0.5*$TPC_y - 1.5*$padWidth;
515 $posZplane[1] = 0.5*$TPC_y - 0.5*$padWidth;
518 $posTPCActive[0] = 0;
519 $posTPCActive[1] = -$ReadoutPlane;
520 $posTPCActive[2] = 0;
523 #wrap up the TPC file
526 <volume name="volTPC">
527 <materialref ref="LAr"/>
528 <solidref ref="CRM"/>
530 <volumeref ref="volTPCPlaneX"/>
531 <position name="posPlaneX" unit="cm"
532 x="$posXplane[0]" y="$posXplane[1]" z="$posXplane[2]"/>
533 <rotationref ref="rIdentity"/>
536 <volumeref ref="volTPCPlaneZ"/>
537 <position name="posPlaneZ" unit="cm"
538 x="$posZplane[0]" y="$posZplane[1]" z="$posZplane[2]"/>
539 <rotationref ref="rIdentity"/>
542 <volumeref ref="volTPCActive"/>
543 <position name="posActive" unit="cm"
544 x="$posTPCActive[0]" y="@{[$posTPCActive[1]+$padWidth]}" z="$posTPCActive[2]"/>
545 <rotationref ref="rIdentity"/>
559 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
560 #++++++++++++++++++++++++++++++++++++++ gen_FieldCage +++++++++++++++++++++++++++++++++++++
561 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
565 $FieldCage = $basename."_FieldCage" . $suffix . ".gdml";
566 push (@gdmlFiles, $FieldCage);
567 $FieldCage = ">" . $FieldCage;
568 open(FieldCage) or die("Could not open file $FieldCage for writing");
570 # The standard XML prefix and starting the gdml
571 print FieldCage <<EOF;
572 <?xml version='1.0'?>
575 # The printing solids used in the Field Cage
576 #print "lengthTPCActive : $lengthTPCActive \n";
577 #print "widthTPCActive : $widthTPCActive \n";
580 print FieldCage <<EOF;
582 <torus name="FieldShaperCorner" rmin="$FieldShaperInnerRadius" rmax="$FieldShaperOuterRadius" rtor="$FieldShaperTorRad" deltaphi="90" startphi="0" aunit="deg" lunit="cm"/>
583 <tube name="FieldShaperLongtube" rmin="$FieldShaperInnerRadius" rmax="$FieldShaperOuterRadius" z="$FieldShaperLongTubeLength" deltaphi="360" startphi="0" aunit="deg" lunit="cm"/>
584 <tube name="FieldShaperShorttube" rmin="$FieldShaperInnerRadius" rmax="$FieldShaperOuterRadius" z="$FieldShaperShortTubeLength" deltaphi="360" startphi="0" aunit="deg" lunit="cm"/>
586 <union name="FSunion1">
587 <first ref="FieldShaperLongtube"/>
588 <second ref="FieldShaperCorner"/>
589 <position name="esquinapos1" unit="cm" x="@{[-$FieldShaperTorRad]}" y="0" z="@{[0.5*$FieldShaperLongTubeLength]}"/>
590 <rotation name="rot1" unit="deg" x="90" y="0" z="0" />
593 <union name="FSunion2">
594 <first ref="FSunion1"/>
595 <second ref="FieldShaperShorttube"/>
596 <position name="esquinapos2" unit="cm" x="@{[-0.5*$FieldShaperShortTubeLength-$FieldShaperTorRad]}" y="0" z="@{[+0.5*$FieldShaperLongTubeLength+$FieldShaperTorRad]}"/>
597 <rotation name="rot2" unit="deg" x="0" y="90" z="0" />
600 <union name="FSunion3">
601 <first ref="FSunion2"/>
602 <second ref="FieldShaperCorner"/>
603 <position name="esquinapos3" unit="cm" x="@{[-$FieldShaperShortTubeLength-$FieldShaperTorRad]}" y="0" z="@{[0.5*$FieldShaperLongTubeLength]}"/>
604 <rotation name="rot3" unit="deg" x="90" y="270" z="0" />
607 <union name="FSunion4">
608 <first ref="FSunion3"/>
609 <second ref="FieldShaperLongtube"/>
610 <position name="esquinapos4" unit="cm" x="@{[-$FieldShaperShortTubeLength-2*$FieldShaperTorRad]}" y="0" z="0"/>
613 <union name="FSunion5">
614 <first ref="FSunion4"/>
615 <second ref="FieldShaperCorner"/>
616 <position name="esquinapos5" unit="cm" x="@{[-$FieldShaperShortTubeLength-$FieldShaperTorRad]}" y="0" z="@{[-0.5*$FieldShaperLongTubeLength]}"/>
617 <rotation name="rot5" unit="deg" x="90" y="180" z="0" />
620 <union name="FSunion6">
621 <first ref="FSunion5"/>
622 <second ref="FieldShaperShorttube"/>
623 <position name="esquinapos6" unit="cm" x="@{[-0.5*$FieldShaperShortTubeLength-$FieldShaperTorRad]}" y="0" z="@{[-0.5*$FieldShaperLongTubeLength-$FieldShaperTorRad]}"/>
624 <rotation name="rot6" unit="deg" x="0" y="90" z="0" />
627 <union name="FieldShaperSolid">
628 <first ref="FSunion6"/>
629 <second ref="FieldShaperCorner"/>
630 <position name="esquinapos7" unit="cm" x="@{[-$FieldShaperTorRad]}" y="0" z="@{[-0.5*$FieldShaperLongTubeLength]}"/>
631 <rotation name="rot7" unit="deg" x="90" y="90" z="0" />
637 print FieldCage <<EOF;
640 <volume name="volFieldShaper">
641 <materialref ref="Al2O3"/>
642 <solidref ref="FieldShaperSolid"/>
648 print FieldCage <<EOF;
655 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
656 #++++++++++++++++++++++++++++++++++++++ gen_Cathode +++++++++++++++++++++++++++++++++++++
657 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
661 $Cathode = $basename."_Cathode" . $suffix . ".gdml";
662 push (@gdmlFiles, $Cathode);
663 $Cathode = ">" . $Cathode;
664 open(Cathode) or die("Could not open file $Cathode for writing");
666 # The standard XML prefix and starting the gdml
668 <?xml version='1.0'?>
675 <tube name="solCathodeCable" rmin="0" rmax="@{[$CathodeCableRadius]}" z="@{[$CathodeCableLength]}" deltaphi="360" startphi="0" aunit="deg" lunit="cm"/>
676 <box name="solCathode" x="@{[$CathodeWidth]}" y="@{[$CathodeHeight]}" z="@{[$CathodeLength]}" lunit="cm"/>
686 <volume name="volCathodeCable">
687 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
688 <solidref ref="solCathodeCable"/>
691 <volume name="volCathode">
692 <materialref ref="LAr"/>
693 <solidref ref="solCathode"/>
696 <volumeref ref="volFieldShaper"/>
697 <position name="posFS" unit="cm" x="@{[0.5*$FieldShaperShortTubeLength+$FieldShaperTorRad]}" y="@{[0]}" z="@{[0]}"/>
700 for($ii=0;$ii<$CathodeNumberOfCables;$ii++)
704 <volumeref ref="volCathodeCable"/>
705 <position name="posCathodeCable$ii" unit="cm" x="@{[0]}" y="@{[0]}" z="@{[-0.5*$CathodeCableSeparation*$CathodeNumberOfCables+($ii)*$CathodeCableSeparation]}"/>
706 <rotation name="rotCC$ii" unit="deg" x="0" y="90" z="0" />
724 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
725 #++++++++++++++++++++++++++++++++++++++ gen_pmt +++++++++++++++++++++++++++++++++++++
726 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
733 #$PMT_COATING_THICKNESS=0.2;
734 #$PMT_PLATE_THICKNESS=0.4;
735 #$PMT_GLASS_THICKNESS=0.2;
737 $PMT = $basename."_PMT" . $suffix . ".gdml";
738 push (@gdmlFiles, $PMT);
740 open(PMT) or die("Could not open file $PMT for writing");
746 <tube name="PMTVolume"
753 <tube name="PMT_AcrylicPlate"
760 <tube name="PMT_plate_coat"
768 <tube aunit="deg" deltaphi="360" lunit="mm" name="pmtMiddleCylinder" rmax="102.351822048586" rmin="100.351822048586" startphi="0" z="54"/>
769 <sphere aunit="deg" deltaphi="360" deltatheta="50" lunit="mm" name="sphPartTop" rmax="133" rmin="131" startphi="0" starttheta="0"/>
770 <union name="pmt0x7fb8f489dfe0">
771 <first ref="pmtMiddleCylinder"/>
772 <second ref="sphPartTop"/>
773 <position name="pmt0x7fb8f489dfe0_pos" unit="mm" x="0" y="0" z="-57.2051768689367"/>
775 <sphere aunit="deg" deltaphi="360" deltatheta="31.477975238527" lunit="mm" name="sphPartBtm" rmax="133" rmin="131" startphi="0" starttheta="130"/>
776 <union name="pmt0x7fb8f48a0d50">
777 <first ref="pmt0x7fb8f489dfe0"/>
778 <second ref="sphPartBtm"/>
779 <position name="pmt0x7fb8f48a0d50_pos" unit="mm" x="0" y="0" z="57.2051768689367"/>
781 <tube aunit="deg" deltaphi="360" lunit="mm" name="pmtBtmTube" rmax="44.25" rmin="42.25" startphi="0" z="72"/>
782 <union name="solidpmt">
783 <first ref="pmt0x7fb8f48a0d50"/>
784 <second ref="pmtBtmTube"/>
785 <position name="solidpmt_pos" unit="mm" x="0" y="0" z="-104.905637496842"/>
787 <sphere aunit="deg" deltaphi="360" deltatheta="50" lunit="mm" name="pmt0x7fb8f48a1eb0" rmax="133.2" rmin="133" startphi="0" starttheta="0"/>
788 <sphere aunit="deg" deltaphi="360" deltatheta="46.5" lunit="mm" name="pmt0x7fb8f48a4860" rmax="131" rmin="130.999" startphi="0" starttheta="0"/>
795 <volume name="volPMTplatecoat">
796 <materialref ref="TPB"/>
797 <solidref ref="PMT_plate_coat"/>
798 <auxiliary auxtype="SensDet" auxvalue="PhotonDetector"/>
801 <volume name="vol_PMT_AcrylicPlate">
802 <materialref ref="Acrylic"/>
803 <solidref ref="PMT_AcrylicPlate"/>
806 <volume name="pmtCoatVol">
807 <materialref ref="TPB"/>
808 <solidref ref="pmt0x7fb8f48a1eb0"/>
809 <auxiliary auxtype="SensDet" auxvalue="PhotonDetector"/>
812 <volume name="allpmt">
813 <materialref ref="Glass"/>
814 <solidref ref="solidpmt"/>
819 <volume name="volPMT_plate">
820 <materialref ref="LAr"/>
821 <solidref ref="PMTVolume"/>
824 <volumeref ref="allpmt"/>
825 <position name="posallpmt" unit="cm" x="0" y="0" z="1.27*2.54+2.5"/>
828 <physvol name="volOpDetSensitive">
829 <volumeref ref="volPMTplatecoat"/>
830 <position name="posOpDetSensitive" unit="cm" x="0" y="0" z="1.27*2.54+2.5*2.54 + 1.7+2.5"/>
834 <volumeref ref="vol_PMT_AcrylicPlate"/>
835 <position name="pos_PMT_AcrylicPlate" unit="cm" x="0" y="0" z="1.27*2.54+2.5*2.54 + 1.5+2.5"/>
839 <volume name="volPMT_coated">
840 <materialref ref="LAr"/>
841 <solidref ref="PMTVolume"/>
844 <volumeref ref="allpmt"/>
845 <position name="posallpmt" unit="cm" x="0" y="0" z="1.27*2.54+2.5"/>
848 <physvol name="volOpDetSensitive">
849 <volumeref ref="pmtCoatVol"/>
850 <position name="posOpDetSensitive" unit="cm" x="0" y="0" z="1.27*2.54- (2.23*2.54)+2.5"/>
862 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
863 #++++++++++++++++++++++++++++++++++++++ gen_ExtractionGrid +++++++++++++++++++++++++++++++++++
864 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
866 sub gen_ExtractionGrid {
868 $ExtractionGrid = $basename."_ExtractionGrid" . $suffix . ".gdml";
869 push (@gdmlFiles, $ExtractionGrid);
870 $ExtractionGrid = ">" . $ExtractionGrid;
871 open(ExtractionGrid) or die("Could not open file $ExtractionGrid for writing");
873 # The standard XML prefix and starting the gdml
874 print ExtractionGrid <<EOF;
875 <?xml version='1.0'?>
879 $ExtractionGridRadius = 0.05;
880 $ExtractionGridPitch = 0.3;
882 $ExtractionGridSizeX = $widthTPCActive;
883 $ExtractionGridSizeY = 2*$ExtractionGridRadius;
884 $ExtractionGridSizeZ = $lengthTPCActive;
887 print ExtractionGrid <<EOF;
890 <tube name="solExtractionGridCable" rmin="0" rmax="$ExtractionGridRadius" z="$ExtractionGridSizeZ" deltaphi="360" startphi="0" aunit="deg" lunit="cm"/>
891 <box name="solExtractionGrid" x="@{[$ExtractionGridSizeX]}" y="@{[$ExtractionGridSizeY]}" z="@{[$ExtractionGridSizeZ]}" lunit="cm"/>
897 print ExtractionGrid <<EOF;
901 <volume name="volExtractionGridCable">
902 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
903 <solidref ref="solExtractionGridCable"/>
906 <volume name="volExtractionGrid">
907 <materialref ref="LAr"/>
908 <solidref ref="solExtractionGrid"/>
911 for($ii=0;$ii<$$ExtractionGridSizeX;$ii=$ii+$ExtractionGridPitch)
913 print ExtractionGrid <<EOF;
915 <volumeref ref="volExtractionGridCable"/>
916 <position name="posExtractionGridCable$ii" unit="cm" x="@{[$ii-0.5*$ExtractionGridSizeX]}" y="0" z="0"/>
917 <rotation name="GGrot$aux2" unit="deg" x="90" y="0" z="0" />
923 for($jj=0;$jj<$$ExtractionGridSizeZ;$jj=$jj+$ExtractionGridPitch)
925 print ExtractionGrid <<EOF;
927 <volumeref ref="volExtractionGridCable"/>
928 <position name="posExtractionGridCableLat$jj" unit="cm" x="0" y="0" z="@{[$jj-0.5*$ExtractionGridSizeZ]}"/>
929 <rotation name="GGrot$aux2" unit="deg" x="90" y="0" z="0" />
935 print ExtractionGrid <<EOF;
941 close(ExtractionGrid);
945 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
946 #++++++++++++++++++++++++++++++++++++++ gen_LEMs +++++++++++++++++++++++++++++++++++++
947 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
952 $LEMs = $basename."_LEMs" . $suffix . ".gdml";
953 push (@gdmlFiles, $LEMs);
955 open(LEMs) or die("Could not open file $LEMs for writing");
957 # The standard XML prefix and starting the gdml
959 <?xml version='1.0'?>
963 $LEMsSizeX=$widthTPCActive;
965 $LEMsSizeZ=$lengthTPCActive;
970 <box name="solLEMs" x="@{[$LEMsSizeX]}" y="$LEMsSizeY" z="@{[$LEMsSizeZ]}" lunit="cm"/>
979 <volume name="volLEMs">
980 <materialref ref="Copper_Beryllium_alloy25"/>
981 <solidref ref="solLEMs"/>
990 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
991 #++++++++++++++++++++++++++++++++++++++ gen_Cryostat +++++++++++++++++++++++++++++++++++++
992 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
997 # Create the cryostat fragment file name,
998 # add file to list of output GDML fragments,
1000 $CRYO = $basename."_Cryostat" . $suffix . ".gdml";
1001 push (@gdmlFiles, $CRYO);
1002 $CRYO = ">" . $CRYO;
1003 open(CRYO) or die("Could not open file $CRYO for writing");
1006 # The standard XML prefix and starting the gdml
1008 <?xml version='1.0'?>
1012 # All the cryostat solids.
1015 <box name="Cryostat" lunit="cm"
1020 <box name="ArgonInterior" lunit="cm"
1025 <box name="GaseousArgon" lunit="cm"
1027 y="$HeightGaseousAr"
1030 <subtraction name="SteelShell">
1031 <first ref="Cryostat"/>
1032 <second ref="ArgonInterior"/>
1038 # Cryostat structure
1041 <volume name="volSteelShell">
1042 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni" />
1043 <solidref ref="SteelShell" />
1045 <volume name="volGaseousArgon">
1046 <materialref ref="ArGas"/>
1047 <solidref ref="GaseousArgon"/>
1049 if ( $LEMs_switch eq "on" )
1052 $posLEMsY = -0.5*$HeightGaseousAr+0.5+0.5*$LEMsSizeY;
1057 <volumeref ref="volLEMs"/>
1058 <position name="posLEMs" unit="cm" x="$posLEMsX" y="$posLEMsY" z="$posLEMsZ"/>
1066 <volume name="volCryostat">
1067 <materialref ref="LAr" />
1068 <solidref ref="Cryostat" />
1070 <volumeref ref="volGaseousArgon"/>
1071 <position name="posGaseousArgon" unit="cm" x="0" y="$Argon_y/2-$HeightGaseousAr/2" z="0"/>
1074 <volumeref ref="volSteelShell"/>
1075 <position name="posSteelShell" unit="cm" x="0" y="0" z="0"/>
1080 if ($tpc_on==1) # place TPC inside croysotat
1083 $posY = $Argon_y/2 - $HeightGaseousAr - 0.5*($driftTPCActive + $ReadoutPlane);
1084 for($ii=0;$ii<$nCRM_z;$ii++)
1086 $posZ = -0.5*$Argon_z + $zLArBuffer + ($ii+0.5)*$lengthCRM;
1088 for($jj=0;$jj<$nCRM_x;$jj++)
1090 $posX = -0.5*$Argon_x + $xLArBuffer + ($jj+0.5)*$widthCRM;
1093 <volumeref ref="volTPC"/>
1094 <position name="posTPC\-$ii\-$jj" unit="cm"
1095 x="$posX" y="$posY" z="$posZ"/>
1104 if ( $pmt_switch eq "on" ) {
1105 for ( $i=0; $i<5; $i=$i+1 ) { # pmts with coating
1109 if ( $i eq "1" || $i eq "3") {
1111 <volumeref ref="volPMT_plate"/>
1116 <volumeref ref="volPMT_coated"/>
1121 <position name="posPMT$i" unit="cm" @pmt_pos[$i]/>
1122 <rotationref ref="rPlus90AboutX"/>
1130 #The +50 in the y positions must depend on some other parameter
1131 if ( $FieldCage_switch eq "on" ) {
1132 for ( $i=0; $i<$NFieldShapers; $i=$i+1 ) { # pmts with coating
1133 $posY = $Argon_y/2 - $HeightGaseousAr - 0.5*($driftTPCActive + $ReadoutPlane);
1137 <volumeref ref="volFieldShaper"/>
1138 <position name="posFieldShaper$i" unit="cm" x="@{[-1*(-0.5*$FieldShaperShortTubeLength-$FieldShaperTorRad)]}" y="@{[$FFSPositionHeight-$i*$FieldShaperSeparation]}" z="0" />
1139 <rotation name="rotFS$i" unit="deg" x="0" y="0" z="0" />
1145 if ( $Cathode_switch eq "on" ) {
1146 $posY = $Argon_y/2 - $HeightGaseousAr - 0.5*($driftTPCActive + $ReadoutPlane);
1149 <volumeref ref="volCathode"/>
1150 <position name="posCathode" unit="cm" x="@{[0]}" y="@{[$CathodePositionHeight]}" z="0" />
1151 <rotation name="rotCath" unit="deg" x="0" y="0" z="0" />
1156 if ( $GroundGrid_switch eq "on" ) {
1157 $posY = $Argon_y/2 - $HeightGaseousAr - 0.5*($driftTPCActive + $ReadoutPlane);
1160 <volumeref ref="volCathode"/>
1161 <position name="posGroundGrid" unit="cm" x="@{[0]}" y="@{[$GroundGridPositionHeight]}" z="0" />
1162 <rotation name="rotGroundGrid" unit="deg" x="0" y="0" z="0" />
1167 if ( $ExtractionGrid_switch eq "on" )
1170 $ExtractionGridX = 0;
1171 $ExtractionGridY = 0.5*$Argon_y-$HeightGaseousAr-0.5-0.5*$ExtractionGridSizeY;
1172 $ExtractionGridZ = 0;
1176 <volumeref ref="volExtractionGrid"/>
1177 <position name="posExtractionGrid" unit="cm" x="$ExtractionGridX" y="$ExtractionGridY" z="$ExtractionGridZ"/>
1197 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1198 #+++++++++++++++++++++++++++++++++++++ gen_Enclosure +++++++++++++++++++++++++++++++++++++
1199 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1204 # Create the detector enclosure fragment file name,
1205 # add file to list of output GDML fragments,
1207 $ENCL = $basename."_DetEnclosure" . $suffix . ".gdml";
1208 push (@gdmlFiles, $ENCL);
1209 $ENCL = ">" . $ENCL;
1210 open(ENCL) or die("Could not open file $ENCL for writing");
1213 # The standard XML prefix and starting the gdml
1215 <?xml version='1.0'?>
1220 # All the detector enclosure solids.
1224 <box name="FoamPadBlock" lunit="cm"
1225 x="@{[$Cryostat_x + 2*$FoamPadding]}"
1226 y="@{[$Cryostat_y + 2*$FoamPadding]}"
1227 z="@{[$Cryostat_z + 2*$FoamPadding]}" />
1229 <subtraction name="FoamPadding">
1230 <first ref="FoamPadBlock"/>
1231 <second ref="Cryostat"/>
1232 <positionref ref="posCenter"/>
1235 <box name="SteelSupportBlock" lunit="cm"
1236 x="@{[$Cryostat_x + 2*$FoamPadding + 2*$SteelSupport_x]}"
1237 y="@{[$Cryostat_y + 2*$FoamPadding + 2*$SteelSupport_y]}"
1238 z="@{[$Cryostat_z + 2*$FoamPadding + 2*$SteelSupport_z]}" />
1240 <subtraction name="SteelSupport">
1241 <first ref="SteelSupportBlock"/>
1242 <second ref="FoamPadBlock"/>
1243 <positionref ref="posCenter"/>
1246 <box name="DetEnclosure" lunit="cm"
1255 # Detector enclosure structure
1258 <volume name="volFoamPadding">
1259 <materialref ref="foam_3x1x1dp"/>
1260 <solidref ref="FoamPadding"/>
1263 <volume name="volSteelSupport">
1264 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1265 <solidref ref="SteelSupport"/>
1268 <volume name="volDetEnclosure">
1269 <materialref ref="Air"/>
1270 <solidref ref="DetEnclosure"/>
1273 <volumeref ref="volFoamPadding"/>
1274 <positionref ref="posCryoInDetEnc"/>
1277 <volumeref ref="volSteelSupport"/>
1278 <positionref ref="posCryoInDetEnc"/>
1281 <volumeref ref="volCryostat"/>
1282 <positionref ref="posCryoInDetEnc"/>
1301 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1302 #+++++++++++++++++++++++++++++++++++++++ gen_World +++++++++++++++++++++++++++++++++++++++
1303 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1308 # Create the WORLD fragment file name,
1309 # add file to list of output GDML fragments,
1311 $WORLD = $basename."_World" . $suffix . ".gdml";
1312 push (@gdmlFiles, $WORLD);
1313 $WORLD = ">" . $WORLD;
1314 open(WORLD) or die("Could not open file $WORLD for writing");
1317 # The standard XML prefix and starting the gdml
1319 <?xml version='1.0'?>
1324 # All the World solids.
1327 <box name="World" lunit="cm"
1328 x="@{[$DetEncX+2*$AirThickness]}"
1329 y="@{[$DetEncY+2*$AirThickness]}"
1330 z="@{[$DetEncZ+2*$AirThickness]}"/>
1337 <volume name="volWorld" >
1338 <materialref ref="Air"/>
1339 <solidref ref="World"/>
1342 <volumeref ref="volDetEnclosure"/>
1343 <position name="posDetEnclosure" unit="cm" x="$OriginXSet" y="$OriginYSet" z="$OriginZSet"/>
1351 # make_gdml.pl will take care of <setup/>
1358 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1359 #++++++++++++++++++++++++++++++++++++ write_fragments ++++++++++++++++++++++++++++++++++++
1360 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1362 sub write_fragments()
1364 # This subroutine creates an XML file that summarizes the the subfiles output
1365 # by the other sub routines - it is the input file for make_gdml.pl which will
1366 # give the final desired GDML file. Specify its name with the output option.
1367 # (you can change the name when running make_gdml)
1369 # This code is taken straigh from the similar MicroBooNE generate script, Thank you.
1371 if ( ! defined $output )
1373 $output = "-"; # write to STDOUT
1376 # Set up the output file.
1377 $OUTPUT = ">" . $output;
1378 open(OUTPUT) or die("Could not open file $OUTPUT");
1381 <?xml version='1.0'?>
1383 <!-- Input to Geometry/gdml/make_gdml.pl; define the GDML fragments
1384 that will be zipped together to create a detector description.
1391 <!-- These files contain GDML <constant></constant>
1392 blocks. They are read in separately, so they can be
1393 interpreted into the remaining GDML. See make_gdml.pl for
1399 foreach $filename (@defFiles)
1402 <filename> $filename </filename>
1412 <!-- The GDML file fragments to be zipped together. -->
1416 foreach $filename (@gdmlFiles)
1419 <filename> $filename </filename>
1434 print "Some key parameters for dual-phase LAr TPC (unit cm unless noted otherwise)\n";
1435 print "CRM active area : $widthCRM_active x $lengthCRM_active\n";
1436 print "CRM total area : $widthCRM x $lengthCRM\n";
1437 print "TPC active volume : $driftTPCActive x $widthTPCActive x $lengthTPCActive\n";
1438 print "Argon buffer : ($xLArBuffer, $yLArBuffer, $zLArBuffer) \n";
1439 print "Detector enclosure : $DetEncX x $DetEncY x $DetEncZ\n";
1440 print "TPC Origin : ($OriginXSet, $OriginYSet, $OriginZSet) \n";
1441 print "PMTs : $pmt_switch \n";
1443 # run the sub routines that generate the fragments
1444 if ( $pmt_switch eq "on" ) { gen_pmt(); }
1445 if ( $FieldCage_switch eq "on" ) { gen_FieldCage(); }
1446 if ( $Cathode_switch eq "on" ) { gen_Cathode(); }
1447 if ( $ExtractionGrid_switch eq "on" ) { gen_ExtractionGrid(); }
1448 if ( $LEMs_switch eq "on" ) { gen_LEMs(); }
1451 gen_Define(); # generates definitions at beginning of GDML
1452 gen_Materials(); # generates materials to be used
1453 gen_TPC(); # generate TPC for a given unit CRM
1456 gen_World(); # places the enclosure among DUSEL Rock
1459 write_fragments(); # writes the XML input for make_gdml.pl
1460 # which zips together the final GDML