4 # GDML fragment generator for DUNE dual-phase 10kt detector geometry
5 # adapted from single phase cryostat geometry script from Tyler Dalion
6 # by Vyacheslav Galymov < vgalymov@ipnl.in2p3.fr >
8 # !!!NOTE!!!: the readout is on a positive Y
10 #################################################################################
12 # contact tylerdalion@gmail.com for any GDML/generate questions
13 # I would love to help!
15 # Each subroutine generates a fragment GDML file, and the last subroutine
16 # creates an XML file that make_gdml.pl will use to appropriately arrange
17 # the fragment GDML files to create the final desired DUNE GDML file,
18 # to be named by make_gdml output command
20 # If you are playing with different geometries, you can use the
21 # suffix command to help organize your work.
23 # 26/11/2018 - j.soto@cern.ch - This updates are not included in the drift in X geometries!
24 # Added a variable PMT density, to generate new geometries with more PMTs.
25 # TPB foils added to the default geometry, altough they can be deactivated.
26 ##################################################################################
34 Math::BigFloat->precision(-16);
36 GetOptions( "help|h" => \$help,
37 "suffix|s:s" => \$suffix,
38 "output|o:s" => \$output,
39 "wires|w:s" => \$wires,
40 "workspace|k:s" => \$wkspc,
41 "pmtdensity|p:s" => \$PMTDensity,
42 "TPBFoils|f:s" => \$foils);
45 my $FieldCage_switch="on";
46 my $GroundGrid_switch="on";
47 my $Cathode_switch="on";
48 my $ExtractionGrid_switch="on";
50 my $Foils_switch="on";
55 # If the user requested help, print the usage notes and exit.
60 if ( ! defined $suffix )
62 # The user didn't supply a suffix, so append nothing to the file
68 # Otherwise, stick a "-" before the suffix, so that a suffix of
69 # "test" applied to filename.gdml becomes "filename-test.gdml".
70 $suffix = "-" . $suffix;
76 if (defined $wkspc ) # not done
80 elsif ( $workspace != 0 )
82 print "\t\tCreating smaller workspace geometry.\n";
85 # set wires on to be the default, unless given an input by the user
86 $wires_on = 1; # 1=on, 0=off
96 $basename = "dunedphase10kt_v2_driftY";
100 $basename = 'dunedphase10kt_v2_driftY_' . $PMTDensity . 'PMTperM2';
102 if ( $workspace == 1 )
104 $basename = $basename."_workspace";
106 if ( $workspace == 2 )
108 $basename = $basename."_workspace4x2";
110 if ( $workspace == 3 )
112 $basename = $basename."_workspace3x3";
120 $basename = $basename."_Foil";
124 $basename = $basename."_HalfFoil";
126 if ( $wires_on == 0 )
128 $basename = $basename."_nowires";
132 ##################################################################
133 ############## Parameters for Charge Readout Plane ###############
135 # dune10kt dual-phase
136 $wirePitch = 0.3125; # channel pitch
137 $nChannelsViewPerCRM = 960; # channels per collection view
138 $borderCRM = 0.5; # dead space at the border of each CRM
140 # dimensions of a single Charge Readout Module (CRM)
141 $widthCRM_active = $wirePitch * $nChannelsViewPerCRM;
142 $lengthCRM_active = $wirePitch * $nChannelsViewPerCRM;
144 $widthCRM = $widthCRM_active + 2 * $borderCRM;
145 $lengthCRM = $lengthCRM_active + 2 * $borderCRM;
147 # number of CRMs in y and z
151 # create a smaller geometry
152 if( $workspace == 1 )
158 # create a smaller geometry
159 if( $workspace == 2 )
165 # create a smaller geometry
166 if( $workspace == 3 )
173 # calculate tpc area based on number of CRMs and their dimensions
174 $widthTPCActive = $nCRM_x * $widthCRM; # around 1200
175 $lengthTPCActive = $nCRM_z * $lengthCRM; # around 6000
177 # active volume dimensions
178 $driftTPCActive = 1200.0;
180 # model anode strips as wires
182 $ReadoutPlane = 2 * $padWidth;
184 #$padHeight = 0.0035;
186 ##################################################################
187 ############## Parameters for TPC and inner volume ###############
189 # inner volume dimensions of the cryostat
194 if( $workspace != 0 )
196 #active tpc + 1 m buffer on each side
197 $Argon_x = $widthTPCActive + 200;
198 $Argon_z = $lengthTPCActive + 200;
201 # width of gas argon layer on top
202 $HeightGaseousAr = 100;
204 # size of liquid argon buffer
205 $xLArBuffer = 0.5 * ($Argon_x - $widthTPCActive);
206 $yLArBuffer = $Argon_y - $driftTPCActive - $HeightGaseousAr - $ReadoutPlane;
207 $zLArBuffer = 0.5 * ($Argon_z - $lengthTPCActive);
210 $SteelThickness = 0.12; # membrane
212 $Cryostat_x = $Argon_x + 2*$SteelThickness;
213 $Cryostat_y = $Argon_y + 2*$SteelThickness;
214 $Cryostat_z = $Argon_z + 2*$SteelThickness;
216 ##################################################################
217 ############## DetEnc and World relevant parameters #############
219 $SteelSupport_x = 100;
220 $SteelSupport_y = 50;
221 $SteelSupport_z = 100;
222 $FoamPadding = 80; # only 2 layers ???
223 $FracMassOfSteel = 0.5; #The steel support is not a solid block, but a mixture of air and steel
224 $FracMassOfAir = 1 - $FracMassOfSteel;
227 $SpaceSteelSupportToWall = 100;
228 $SpaceSteelSupportToCeiling = 100;
230 $DetEncX = $Cryostat_x
231 + 2*($SteelSupport_x + $FoamPadding) + 2*$SpaceSteelSupportToWall;
233 $DetEncY = $Cryostat_y
234 + 2*($SteelSupport_y + $FoamPadding) + $SpaceSteelSupportToCeiling;
236 $DetEncZ = $Cryostat_z
237 + 2*($SteelSupport_z + $FoamPadding) + 2*$SpaceSteelSupportToWall;
239 $posCryoInDetEnc_y = - $DetEncY/2 + $SteelSupport_y + $FoamPadding + $Cryostat_y/2;
241 $RockThickness = 4000;
243 # We want the world origin to be vertically centered on active TPC
244 # This is to be added to the x and y position of every volume in volWorld
246 $OriginXSet = $DetEncX/2.0
247 -$SpaceSteelSupportToWall
252 -$widthTPCActive/2.0;
254 $OriginYSet = $DetEncY/2.0
259 - $driftTPCActive/2.0;
261 # We want the world origin to be at the very front of the fiducial volume.
262 # move it to the front of the enclosure, then back it up through the concrete/foam,
263 # then through the Cryostat shell, then through the upstream dead LAr (including the
264 # dead LAr on the edge of the TPC)
265 # This is to be added to the z position of every volume in volWorld
267 $OriginZSet = $DetEncZ/2.0
268 - $SpaceSteelSupportToWall
275 ##################################################################
276 ############## Field Cage Parameters ###############
278 $FieldShaperLongTubeLength = $lengthTPCActive+1;
279 $FieldShaperShortTubeLength = $widthTPCActive+1;#plus 1 to give space to the Foils without overlaps
280 $FieldShaperInnerRadius = 1.485;
281 $FieldShaperOuterRadius = 1.685;
282 $FieldShaperTorRad = 1.69;
284 $FieldShaperLength = $FieldShaperLongTubeLength + 2*$FieldShaperOuterRadius+ 2*$FieldShaperTorRad;
285 $FieldShaperWidth = $FieldShaperShortTubeLength + 2*$FieldShaperOuterRadius+ 2*$FieldShaperTorRad;
286 $FieldShaperHeight = 2*$FieldShaperOuterRadius;
288 $FieldShaperSeparation = 5.0;
289 $NFieldShapers = ($driftTPCActive/$FieldShaperSeparation) - 1;
291 $FieldCageSizeX = $FieldShaperWidth+2;
292 $FieldCageSizeY = $FieldShaperSeparation*$NFieldShapers+2;
293 $FieldCageSizeZ = $FieldShaperLength+2;
295 ##################################################################
296 ############## Positioning Parameters ###############
299 $FirstFieldShaperPosY=0.5*$Argon_y-$HeightGaseousAr - 0.5*$FieldShaperHeight;
301 $CathodeGroundGridSeparation=80;
304 #$CathodePosY=-$OriginYSet+50+(-1-$NFieldShapers*0.5)*$FieldShaperSeparation;
306 $CathodePosY=$FirstFieldShaperPosY-$NFieldShapers*$FieldShaperSeparation;
311 $GroundGridPosY= $CathodePosY - $CathodeGroundGridSeparation;
314 #-$OriginYSet+50+($i-$NFieldShapers*0.5)*$FieldShaperSeparation
315 #$FoilPositionY=$FirstFieldShaperPosY - 0.5*$NFieldShapers*$FieldShaperSeparation;
318 $posLEMsY = -0.5*$HeightGaseousAr+0.5+0.5*$LEMsSizeY;
321 $ExtractionGridX = 0;
322 $ExtractionGridY = 0.5*$Argon_y-$HeightGaseousAr-0.5-0.5*$ExtractionGridSizeY;
323 $ExtractionGridZ = 0;
325 ##################################################################
326 ############## Parameters for PMTs ###############
330 $pmtNx=int(0.01*$widthTPCActive*sqrt($PMTDensity));
331 $pmtDistanceX=$widthTPCActive/($pmtNx);
332 $pmtNz=int(0.01*$lengthTPCActive*sqrt($PMTDensity));
333 $pmtDistanceZ=$lengthTPCActive/($pmtNz);
339 $pmtN = $pmtNx*$pmtNz; #keeping 1m2 density of pmts
341 $posPMTy = $CathodePosY - 100.0- 0.5*($HeightPMT); #1m below the cathode
343 @pmt_pos = ('','','');
349 for($i=0;$i<$pmtNx;++$i)
351 for($j=0;$j<$pmtNz;++$j)
353 $pmt_pos[$counter]="x=\"@{[-0.5*($pmtNx-1)*100 + $i*100]}\" y=\"$posPMTy\" z=\"@{[-0.5*($pmtNz-1)*100+$j*100]}\"";
354 $pmt_pos[$counter]="x=\"@{[-0.5*($pmtNx-1)*$pmtDistanceZ + $i*$pmtDistanceX]}\" y=\"$posPMTy\" z=\"@{[-0.5*($pmtNz-1)*$pmtDistanceZ+$j*$pmtDistanceZ]}\"";
358 print "Number of PMTs : $counter (@{[$pmtNx]} x @{[$pmtNz]})\n";
359 print "widthTPCActive : $widthTPCActive \n";
360 ##################################################################
361 ############### Parameters for det elements ######################
364 #$Cathode_x = $widthTPCActive;
366 #$Cathode_z = $lengthTPCActive;
370 #+++++++++++++++++++++++++ End defining variables ++++++++++++++++++++++++++
373 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
374 #+++++++++++++++++++++++++++++++++++++++++ usage +++++++++++++++++++++++++++++++++++++++++
375 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
379 print "Usage: $0 [-h|--help] [-o|--output <fragments-file>] [-s|--suffix <string>]\n";
380 print " if -o is omitted, output goes to STDOUT; <fragments-file> is input to make_gdml.pl\n";
381 print " -s <string> appends the string to the file names; useful for multiple detector versions\n";
382 print " -h prints this message, then quits\n";
387 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
388 #++++++++++++++++++++++++++++++++++++++ gen_Define +++++++++++++++++++++++++++++++++++++++
389 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
394 # Create the <define> fragment file name,
395 # add file to list of fragments,
397 $DEF = $basename."_Def" . $suffix . ".gdml";
398 push (@gdmlFiles, $DEF);
400 open(DEF) or die("Could not open file $DEF for writing");
404 <?xml version='1.0'?>
414 <position name="posCryoInDetEnc" unit="cm" x="0" y="$posCryoInDetEnc_y" z="0"/>
415 <position name="posCenter" unit="cm" x="0" y="0" z="0"/>
416 <rotation name="rPlus90AboutX" unit="deg" x="90" y="0" z="0"/>
417 <rotation name="rPlus90AboutY" unit="deg" x="0" y="90" z="0"/>
418 <rotation name="rPlus90AboutXPlus90AboutY" unit="deg" x="90" y="90" z="0"/>
419 <rotation name="rMinus90AboutX" unit="deg" x="270" y="0" z="0"/>
420 <rotation name="rMinus90AboutY" unit="deg" x="0" y="270" z="0"/>
421 <rotation name="rMinus90AboutYMinus90AboutX" unit="deg" x="270" y="270" z="0"/>
422 <rotation name="rPlus180AboutX" unit="deg" x="180" y="0" z="0"/>
423 <rotation name="rPlus180AboutY" unit="deg" x="0" y="180" z="0"/>
424 <rotation name="rPlus180AboutXPlus180AboutY" unit="deg" x="180" y="180" z="0"/>
425 <rotation name="rIdentity" unit="deg" x="0" y="0" z="0"/>
432 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
433 #+++++++++++++++++++++++++++++++++++++ gen_Materials +++++++++++++++++++++++++++++++++++++
434 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
439 # Create the <materials> fragment file name,
440 # add file to list of output GDML fragments,
442 $MAT = $basename."_Materials" . $suffix . ".gdml";
443 push (@gdmlFiles, $MAT);
446 open(MAT) or die("Could not open file $MAT for writing");
448 # Add any materials special to this geometry by defining a mulitline string
449 # and passing it to the gdmlMaterials::gen_Materials() function.
451 <!-- preliminary values -->
452 <material name="AirSteelMixture" formula="AirSteelMixture">
453 <D value=" 0.001205*(1-$FracMassOfSteel) + 7.9300*$FracMassOfSteel " unit="g/cm3"/>
454 <fraction n="$FracMassOfSteel" ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
455 <fraction n="$FracMassOfAir" ref="Air"/>
457 <material name="vm2000" formula="vm2000">
458 <D value="1.2" unit="g/cm3"/>
459 <composite n="2" ref="carbon"/>
460 <composite n="4" ref="hydrogen"/>
464 # add the general materials used anywere
465 print MAT gdmlMaterials::gen_Materials( $asmix );
470 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
471 #++++++++++++++++++++++++++++++++++++++++ gen_TPC ++++++++++++++++++++++++++++++++++++++++
472 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
476 my $TPCActive_x = $widthCRM_active;
477 my $TPCActive_y = $driftTPCActive;
478 my $TPCActive_z = $lengthCRM_active;
481 my $TPC_x = $widthCRM;
482 my $TPC_y = $TPCActive_y + $ReadoutPlane;
483 my $TPC_z = $lengthCRM;
486 $TPC = $basename."_TPC" . $suffix . ".gdml";
487 push (@gdmlFiles, $TPC);
489 open(TPC) or die("Could not open file $TPC for writing");
491 # The standard XML prefix and starting the gdml
493 <?xml version='1.0'?>
498 # All the TPC solids save the wires.
501 <box name="CRM" lunit="cm"
505 <box name="CRMXPlane" lunit="cm"
509 <box name="CRMZPlane" lunit="cm"
513 <box name="CRMActive" lunit="cm"
520 #++++++++++++++++++++++++++++ Wire Solids ++++++++++++++++++++++++++++++
521 # in principle we only need only one wire solid, since CRM is a square
522 # but to be more general ...
526 <tube name="CRMWireX"
532 <tube name="CRMWireZ"
543 # Begin structure and create wire logical volumes
546 <volume name="volTPCActive">
547 <materialref ref="LAr"/>
548 <solidref ref="CRMActive"/>
549 <auxiliary auxtype="SensDet" auxvalue="SimEnergyDeposit"/>
556 <volume name="volTPCWireX">
557 <materialref ref="Copper_Beryllium_alloy25"/>
558 <solidref ref="CRMWireX"/>
561 <volume name="volTPCWireZ">
562 <materialref ref="Copper_Beryllium_alloy25"/>
563 <solidref ref="CRMWireZ"/>
570 <volume name="volTPCPlaneX">
571 <materialref ref="LAr"/>
572 <solidref ref="CRMXPlane"/>
575 if ($wires_on==1) # add wires to X plane (plane with wires reading x position)
577 for($i=0;$i<$nChannelsViewPerCRM;++$i)
579 my $xpos = -0.5 * $TPCActive_x + ($i+0.5)*$wirePitch + 0.5*$padWidth;
583 <volumeref ref="volTPCWireX"/>
584 <position name="posWireX$i" unit="cm" x="$xpos" y="0" z="0"/>
585 <rotationref ref="rIdentity"/>
594 <volume name="volTPCPlaneZ">
595 <materialref ref="LAr"/>
596 <solidref ref="CRMZPlane"/>
600 if ($wires_on==1) # add wires to Z plane (plane with wires reading z position)
602 for($i=0;$i<$nChannelsViewPerCRM;++$i)
605 my $zpos = -0.5 * $TPCActive_z + ($i+0.5)*$wirePitch + 0.5*$padWidth;
608 <volumeref ref="volTPCWireZ"/>
609 <position name="posWireZ$i" unit="cm" x="0" y="0" z="$zpos"/>
610 <rotationref ref="rPlus90AboutXPlus90AboutY"/>
623 $posXplane[1] = 0.5*$TPC_y - 1.5*$padWidth;
627 $posZplane[1] = 0.5*$TPC_y - 0.5*$padWidth;
630 $posTPCActive[0] = 0;
631 $posTPCActive[1] = -$ReadoutPlane;
632 $posTPCActive[2] = 0;
635 #wrap up the TPC file
638 <volume name="volTPC">
639 <materialref ref="LAr"/>
640 <solidref ref="CRM"/>
642 <volumeref ref="volTPCPlaneX"/>
643 <position name="posPlaneX" unit="cm"
644 x="$posXplane[0]" y="$posXplane[1]" z="$posXplane[2]"/>
645 <rotationref ref="rIdentity"/>
648 <volumeref ref="volTPCPlaneZ"/>
649 <position name="posPlaneZ" unit="cm"
650 x="$posZplane[0]" y="$posZplane[1]" z="$posZplane[2]"/>
651 <rotationref ref="rIdentity"/>
654 <volumeref ref="volTPCActive"/>
655 <position name="posActive" unit="cm"
656 x="$posTPCActive[0]" y="@{[$posTPCActive[1]+$padWidth]}" z="$posTPCActive[2]"/>
657 <rotationref ref="rIdentity"/>
675 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
676 #++++++++++++++++++++++++++++++++++++++ gen_FieldCage +++++++++++++++++++++++++++++++++++++
677 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
681 $FieldCage = $basename."_FieldCage" . $suffix . ".gdml";
682 push (@gdmlFiles, $FieldCage);
683 $FieldCage = ">" . $FieldCage;
684 open(FieldCage) or die("Could not open file $FieldCage for writing");
686 # The standard XML prefix and starting the gdml
687 print FieldCage <<EOF;
688 <?xml version='1.0'?>
691 # The printing solids used in the Field Cage
692 #print "lengthTPCActive : $lengthTPCActive \n";
693 #print "widthTPCActive : $widthTPCActive \n";
696 print FieldCage <<EOF;
698 <torus name="FieldShaperCorner" rmin="$FieldShaperInnerRadius" rmax="$FieldShaperOuterRadius" rtor="$FieldShaperTorRad" deltaphi="90" startphi="0" aunit="deg" lunit="cm"/>
699 <tube name="FieldShaperLongtube" rmin="$FieldShaperInnerRadius" rmax="$FieldShaperOuterRadius" z="$FieldShaperLongTubeLength" deltaphi="360" startphi="0" aunit="deg" lunit="cm"/>
700 <tube name="FieldShaperShorttube" rmin="$FieldShaperInnerRadius" rmax="$FieldShaperOuterRadius" z="$FieldShaperShortTubeLength" deltaphi="360" startphi="0" aunit="deg" lunit="cm"/>
702 <union name="FSunion1">
703 <first ref="FieldShaperLongtube"/>
704 <second ref="FieldShaperCorner"/>
705 <position name="esquinapos1" unit="cm" x="@{[-$FieldShaperTorRad]}" y="0" z="@{[0.5*$FieldShaperLongTubeLength]}"/>
706 <rotation name="rot1" unit="deg" x="90" y="0" z="0" />
709 <union name="FSunion2">
710 <first ref="FSunion1"/>
711 <second ref="FieldShaperShorttube"/>
712 <position name="esquinapos2" unit="cm" x="@{[-0.5*$FieldShaperShortTubeLength-$FieldShaperTorRad]}" y="0" z="@{[+0.5*$FieldShaperLongTubeLength+$FieldShaperTorRad]}"/>
713 <rotation name="rot2" unit="deg" x="0" y="90" z="0" />
716 <union name="FSunion3">
717 <first ref="FSunion2"/>
718 <second ref="FieldShaperCorner"/>
719 <position name="esquinapos3" unit="cm" x="@{[-$FieldShaperShortTubeLength-$FieldShaperTorRad]}" y="0" z="@{[0.5*$FieldShaperLongTubeLength]}"/>
720 <rotation name="rot3" unit="deg" x="90" y="270" z="0" />
723 <union name="FSunion4">
724 <first ref="FSunion3"/>
725 <second ref="FieldShaperLongtube"/>
726 <position name="esquinapos4" unit="cm" x="@{[-$FieldShaperShortTubeLength-2*$FieldShaperTorRad]}" y="0" z="0"/>
729 <union name="FSunion5">
730 <first ref="FSunion4"/>
731 <second ref="FieldShaperCorner"/>
732 <position name="esquinapos5" unit="cm" x="@{[-$FieldShaperShortTubeLength-$FieldShaperTorRad]}" y="0" z="@{[-0.5*$FieldShaperLongTubeLength]}"/>
733 <rotation name="rot5" unit="deg" x="90" y="180" z="0" />
736 <union name="FSunion6">
737 <first ref="FSunion5"/>
738 <second ref="FieldShaperShorttube"/>
739 <position name="esquinapos6" unit="cm" x="@{[-0.5*$FieldShaperShortTubeLength-$FieldShaperTorRad]}" y="0" z="@{[-0.5*$FieldShaperLongTubeLength-$FieldShaperTorRad]}"/>
740 <rotation name="rot6" unit="deg" x="0" y="90" z="0" />
743 <union name="FieldShaperSolid">
744 <first ref="FSunion6"/>
745 <second ref="FieldShaperCorner"/>
746 <position name="esquinapos7" unit="cm" x="@{[-$FieldShaperTorRad]}" y="0" z="@{[-0.5*$FieldShaperLongTubeLength]}"/>
747 <rotation name="rot7" unit="deg" x="90" y="90" z="0" />
753 print FieldCage <<EOF;
756 <volume name="volFieldShaper">
757 <materialref ref="Al2O3"/>
758 <solidref ref="FieldShaperSolid"/>
764 print FieldCage <<EOF;
771 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
772 #++++++++++++++++++++++++++++++++++++++ gen_ExtractionGrid +++++++++++++++++++++++++++++++++++
773 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
775 sub gen_ExtractionGrid {
777 $ExtractionGrid = $basename."_ExtractionGrid" . $suffix . ".gdml";
778 push (@gdmlFiles, $ExtractionGrid);
779 $ExtractionGrid = ">" . $ExtractionGrid;
780 open(ExtractionGrid) or die("Could not open file $ExtractionGrid for writing");
782 # The standard XML prefix and starting the gdml
783 print ExtractionGrid <<EOF;
784 <?xml version='1.0'?>
789 $ExtractionGridRadius = 0.05;
790 $ExtractionGridPitch = 0.3;
792 $ExtractionGridSizeX = $widthTPCActive;
793 $ExtractionGridSizeY = 2*$ExtractionGridRadius;
794 $ExtractionGridSizeZ = $lengthTPCActive;
797 print ExtractionGrid <<EOF;
800 <tube name="solExtractionGridCable" rmin="0" rmax="$ExtractionGridRadius" z="$ExtractionGridSizeZ" deltaphi="360" startphi="0" aunit="deg" lunit="cm"/>
801 <box name="solExtractionGrid" x="@{[$ExtractionGridSizeX]}" y="@{[$ExtractionGridSizeY]}" z="@{[$ExtractionGridSizeZ]}" lunit="cm"/>
807 print ExtractionGrid <<EOF;
811 <volume name="volExtractionGridCable">
812 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
813 <solidref ref="solExtractionGridCable"/>
816 <volume name="volExtractionGrid">
817 <materialref ref="LAr"/>
818 <solidref ref="solExtractionGrid"/>
821 for($ii=0;$ii<$$ExtractionGridSizeX;$ii=$ii+$ExtractionGridPitch)
823 print ExtractionGrid <<EOF;
825 <volumeref ref="volExtractionGridCable"/>
826 <position name="posExtractionGridCable$ii" unit="cm" x="@{[$ii-0.5*$ExtractionGridSizeX]}" y="0" z="0"/>
827 <rotation name="GGrot$ii" unit="deg" x="90" y="0" z="0" />
833 for($jj=0;$jj<$$ExtractionGridSizeZ;$jj=$jj+$ExtractionGridPitch)
835 print ExtractionGrid <<EOF;
837 <volumeref ref="volExtractionGridCable"/>
838 <position name="posExtractionGridCableLat$jj" unit="cm" x="0" y="0" z="@{[$jj-0.5*$ExtractionGridSizeZ]}"/>
839 <rotation name="GGrot2$jj" unit="deg" x="90" y="0" z="0" />
845 print ExtractionGrid <<EOF;
851 close(ExtractionGrid);
855 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
856 #++++++++++++++++++++++++++++++++++++++ gen_LEMs +++++++++++++++++++++++++++++++++++++
857 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
862 $LEMs = $basename."_LEMs" . $suffix . ".gdml";
863 push (@gdmlFiles, $LEMs);
865 open(LEMs) or die("Could not open file $LEMs for writing");
867 # The standard XML prefix and starting the gdml
869 <?xml version='1.0'?>
873 $LEMsSizeX=$widthTPCActive;
875 $LEMsSizeZ=$lengthTPCActive;
880 <box name="solLEMs" x="@{[$LEMsSizeX]}" y="$LEMsSizeY" z="@{[$LEMsSizeZ]}" lunit="cm"/>
889 <volume name="volLEMs">
890 <materialref ref="Copper_Beryllium_alloy25"/>
891 <solidref ref="solLEMs"/>
900 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
901 #++++++++++++++++++++++++++++++++++++++ gen_Foils +++++++++++++++++++++++++++++++++++++
902 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
905 $FoilsHeight=$NFieldShapers*$FieldShaperSeparation-2.;
908 $FoilsHeight=0.5*$NFieldShapers*$FieldShaperSeparation-2.;
911 $FoilsLengthZ=$lengthTPCActive-3.;
912 $FoilsLengthX=$widthTPCActive-3.;
914 $FoilsCoatingWidth=0.02844;
916 $FoilPositionX=0.5*$FoilsLengthZ+1.7;
917 $FoilPositionZ=0.5*$FoilsLengthX+1.7;
918 $FoilPositionY=$FirstFieldShaperPosY - 0.5*$FoilsHeight+1;
923 $Foils = $basename."_Foils" . $suffix . ".gdml";
924 push (@gdmlFiles, $Foils);
925 $Foils = ">" . $Foils;
926 open(Foils) or die("Could not open file $Foils for writing");
928 # The standard XML prefix and starting the gdml
930 <?xml version='1.0'?>
938 <box name="FoilLayerZ" lunit="cm" x="@{[$FoilsWidth]}" y="$FoilsHeight" z="$FoilsLengthZ"/>
939 <box name="FoilTPBZ" lunit="cm" x="@{[$FoilsWidth+$FoilsCoatingWidth]}" y="$FoilsHeight" z="$FoilsLengthZ"/>
941 <box name="FoilLayerX" lunit="cm" x="$FoilsLengthX" y="$FoilsHeight" z="@{[$FoilsWidth]}"/>
942 <box name="FoilTPBX" lunit="cm" x="$FoilsLengthX" y="$FoilsHeight" z="@{[$FoilsWidth+$FoilsCoatingWidth]}"/>
951 <volume name="volFoilLayerZ">
952 <materialref ref="vm2000"/>
953 <solidref ref="FoilLayerZ"/>
956 <volume name="volFoilZ">
957 <materialref ref="TPB"/>
958 <solidref ref="FoilTPBZ"/>
960 <volumeref ref="volFoilLayerZ"/>
961 <position name="posFoilLayerZ" unit="cm" x="@{[-0.5*$FoilsCoatingWidth]}" y="0" z="0"/>
965 <volume name="volFoilLayerX">
966 <materialref ref="vm2000"/>
967 <solidref ref="FoilLayerX"/>
970 <volume name="volFoilX">
971 <materialref ref="TPB"/>
972 <solidref ref="FoilTPBX"/>
974 <volumeref ref="volFoilLayerX"/>
975 <position name="posFoilLayerX" unit="cm" x="0" y="0" z="@{[-0.5*$FoilsCoatingWidth]}"/>
985 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
986 #++++++++++++++++++++++++++++++++++++++ gen_GroundGrid +++++++++++++++++++++++++++++++++++
987 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
991 $GroundGrid = $basename."_GroundGrid" . $suffix . ".gdml";
992 push (@gdmlFiles, $GroundGrid);
993 $GroundGrid = ">" . $GroundGrid;
994 open(GroundGrid) or die("Could not open file $GroundGrid for writing");
996 # The standard XML prefix and starting the gdml
997 print GroundGrid <<EOF;
998 <?xml version='1.0'?>
1003 $GroundGridSizeX = $FieldShaperWidth+2;
1004 $GroundGridSizeY = 2*$FieldShaperOuterRadius+1;
1005 $GroundGridSizeZ = $FieldShaperLength+2;
1007 $GroundGridInnerStructureLength = $widthTPCActive-1;
1008 $GroundGridInnerStructureLengthLat = $lengthTPCActive;
1009 $GroundGridInnerStructureWidth = 2;
1010 $GroundGridInnerStructureHeight = 4;
1011 $GroundGridInnerStructureSeparation = 65.0;
1012 $GroundGridInnerStructureNumberOfBars = int($lengthTPCActive/$GroundGridInnerStructureSeparation - 1);
1013 $GroundGridInnerStructureNumberOfBarsLat = int($widthTPCActive/$GroundGridInnerStructureSeparation - 1);
1014 #print "number of bars $GroundGridInnerStructureNumberOfBars";
1016 $GroundGridInnerStructureNumberOfCablesPerInnerSquare = 5.0;
1017 $GroundGridInnerStructureCableRadius = 0.1;
1018 $GroundGridInnerStructureCableSeparation = $GroundGridInnerStructureSeparation/($GroundGridInnerStructureNumberOfCablesPerInnerSquare+1);
1020 print GroundGrid <<EOF;
1023 <box name="GroundGridInnerBox" x="@{[$GroundGridInnerStructureWidth]}" y="$GroundGridInnerStructureHeight" z="@{[$GroundGridInnerStructureLength]}" lunit="cm"/>
1024 <box name="GroundGridInnerBoxLat" x="@{[$GroundGridInnerStructureWidth]}" y="$GroundGridInnerStructureHeight" z="@{[$GroundGridInnerStructureLengthLat]}" lunit="cm"/>
1026 <tube name="GroundGridCable" rmin="0" rmax="$GroundGridInnerStructureCableRadius" z="@{[$GroundGridInnerStructureLength]}" deltaphi="360" startphi="0" aunit="deg" lunit="cm"/>
1028 <box name="GroundGridModule" x="@{[$GroundGridSizeX]}" y="$GroundGridSizeY" z="@{[$GroundGridSizeZ]}" lunit="cm"/>
1034 print GroundGrid <<EOF;
1038 <volume name="volGroundGridCable">
1039 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1040 <solidref ref="GroundGridCable"/>
1043 <volume name="volGroundGridInnerBox">
1044 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1045 <solidref ref="GroundGridInnerBox"/>
1047 <volume name="volGroundGridInnerBoxLat">
1048 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1049 <solidref ref="GroundGridInnerBoxLat"/>
1052 <volume name="volGGunion">
1053 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni"/>
1054 <solidref ref="FieldShaperSolid"/>
1057 <volume name="volGroundGrid">
1058 <materialref ref="LAr"/>
1059 <solidref ref="GroundGridModule"/>
1062 <volumeref ref="volGGunion"/>
1063 <position name="posGGunion" unit="cm" x="@{[0.5*$GroundGridSizeX-0.5*$FieldShaperOuterRadius-1]}" y="@{[0.0]}" z="@{[0.0]}"/>
1068 $shift = $GroundGridSizeZ - ($GroundGridInnerStructureNumberOfBars+1)*$GroundGridInnerStructureSeparation;
1070 for($ii=0;$ii<$GroundGridInnerStructureNumberOfBars;$ii++)
1072 print GroundGrid <<EOF;
1074 <volumeref ref="volGroundGridInnerBox"/>
1075 <position name="posGGInnerBox$ii" unit="cm" x="@{[0.6]}" y="@{[0]}" z="@{[0.5*$shift-0.5*$GroundGridSizeZ+($ii+1)*$GroundGridInnerStructureSeparation]}"/>
1076 <rotation name="rotGG$ii" unit="deg" x="0" y="90" z="0" />
1082 for($ii=-1;$ii<$GroundGridInnerStructureNumberOfBars;$ii++)
1084 for($jj=0;$jj<$GroundGridInnerStructureNumberOfCablesPerInnerSquare;$jj++)
1086 print GroundGrid <<EOF;
1088 <volumeref ref="volGroundGridCable"/>
1089 <position name="posGGCable$ii$jj" unit="cm" x="@{[0]}" y="@{[0]}" z="@{[0.5*$shift-0.5*$GroundGridSizeZ+($ii+1)*$GroundGridInnerStructureSeparation + ($jj+1)*$GroundGridInnerStructureCableSeparation]}"/>
1090 <rotation name="rotGGcable$ii$jj" unit="deg" x="0" y="90" z="0" />
1098 $shift = $GroundGridSizeX - ($GroundGridInnerStructureNumberOfBarsLat+1)*$GroundGridInnerStructureSeparation;
1100 for($ii=0;$ii<$GroundGridInnerStructureNumberOfBarsLat;$ii++)
1102 print GroundGrid <<EOF;
1104 <volumeref ref="volGroundGridInnerBoxLat"/>
1105 <position name="posGGInnerBoxLat$ii" unit="cm" x="@{[0.5*$shift-0.5*$GroundGridSizeX+($ii+1)*$GroundGridInnerStructureSeparation]}" y="0" z="@{[0.0]}"/>
1111 print GroundGrid <<EOF;
1125 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1126 #++++++++++++++++++++++++++++++++++++++ gen_pmt +++++++++++++++++++++++++++++++++++++
1127 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1134 #$PMT_COATING_THICKNESS=0.2;
1135 #$PMT_PLATE_THICKNESS=0.4;
1136 #$PMT_GLASS_THICKNESS=0.2;
1138 $PMT = $basename."_PMT" . $suffix . ".gdml";
1139 push (@gdmlFiles, $PMT);
1141 open(PMT) or die("Could not open file $PMT for writing");
1143 # The standard XML prefix and starting the gdml
1145 <?xml version='1.0'?>
1151 <tube name="PMTVolume"
1158 <tube name="PMT_AcrylicPlate"
1165 <tube name="PMT_plate_coat"
1173 <tube aunit="deg" deltaphi="360" lunit="mm" name="pmtMiddleCylinder" rmax="102.351822048586" rmin="100.351822048586" startphi="0" z="54"/>
1174 <sphere aunit="deg" deltaphi="360" deltatheta="50" lunit="mm" name="sphPartTop" rmax="133" rmin="131" startphi="0" starttheta="0"/>
1175 <union name="pmt0x7fb8f489dfe0">
1176 <first ref="pmtMiddleCylinder"/>
1177 <second ref="sphPartTop"/>
1178 <position name="pmt0x7fb8f489dfe0_pos" unit="mm" x="0" y="0" z="-57.2051768689367"/>
1180 <sphere aunit="deg" deltaphi="360" deltatheta="31.477975238527" lunit="mm" name="sphPartBtm" rmax="133" rmin="131" startphi="0" starttheta="130"/>
1181 <union name="pmt0x7fb8f48a0d50">
1182 <first ref="pmt0x7fb8f489dfe0"/>
1183 <second ref="sphPartBtm"/>
1184 <position name="pmt0x7fb8f48a0d50_pos" unit="mm" x="0" y="0" z="57.2051768689367"/>
1186 <tube aunit="deg" deltaphi="360" lunit="mm" name="pmtBtmTube" rmax="44.25" rmin="42.25" startphi="0" z="72"/>
1187 <union name="solidpmt">
1188 <first ref="pmt0x7fb8f48a0d50"/>
1189 <second ref="pmtBtmTube"/>
1190 <position name="solidpmt_pos" unit="mm" x="0" y="0" z="-104.905637496842"/>
1192 <sphere aunit="deg" deltaphi="360" deltatheta="50" lunit="mm" name="pmt0x7fb8f48a1eb0" rmax="133.2" rmin="133" startphi="0" starttheta="0"/>
1193 <sphere aunit="deg" deltaphi="360" deltatheta="46.5" lunit="mm" name="pmt0x7fb8f48a4860" rmax="131" rmin="130.999" startphi="0" starttheta="0"/>
1201 <volume name="pmtCoatVol">
1202 <materialref ref="LAr"/>
1203 <solidref ref="pmt0x7fb8f48a1eb0"/>
1204 <auxiliary auxtype="SensDet" auxvalue="PhotonDetector"/>
1207 <volume name="allpmt">
1208 <materialref ref="Glass"/>
1209 <solidref ref="solidpmt"/>
1212 <volume name="volPMT">
1213 <materialref ref="LAr"/>
1214 <solidref ref="PMTVolume"/>
1217 <volumeref ref="allpmt"/>
1218 <position name="posallpmtcoat" unit="cm" x="0" y="0" z="@{[1.27*2.54]}"/>
1221 <physvol name="volOpDetSensitive">
1222 <volumeref ref="pmtCoatVol"/>
1223 <position name="posOpDetSensitiveCoat" unit="cm" x="0" y="0" z="@{[1.27*2.54-(2.23*2.54)]}"/>
1236 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1237 #++++++++++++++++++++++++++++++++++++++ gen_Cryostat +++++++++++++++++++++++++++++++++++++
1238 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1243 # Create the cryostat fragment file name,
1244 # add file to list of output GDML fragments,
1246 $CRYO = $basename."_Cryostat" . $suffix . ".gdml";
1247 push (@gdmlFiles, $CRYO);
1248 $CRYO = ">" . $CRYO;
1249 open(CRYO) or die("Could not open file $CRYO for writing");
1252 # The standard XML prefix and starting the gdml
1254 <?xml version='1.0'?>
1258 # All the cryostat solids.
1261 <box name="Cryostat" lunit="cm"
1266 <box name="ArgonInterior" lunit="cm"
1271 <box name="GaseousArgon" lunit="cm"
1273 y="$HeightGaseousAr"
1276 <subtraction name="SteelShell">
1277 <first ref="Cryostat"/>
1278 <second ref="ArgonInterior"/>
1284 # Cryostat structure
1287 <volume name="volSteelShell">
1288 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni" />
1289 <solidref ref="SteelShell" />
1291 <volume name="volGaseousArgon">
1292 <materialref ref="ArGas"/>
1293 <solidref ref="GaseousArgon"/>
1296 if ( $LEMs_switch eq "on" )
1300 <volumeref ref="volLEMs"/>
1301 <position name="posLEMs" unit="cm" x="$posLEMsX" y="$posLEMsY" z="$posLEMsZ"/>
1308 <volume name="volCryostat">
1309 <materialref ref="LAr" />
1310 <solidref ref="Cryostat" />
1312 <volumeref ref="volGaseousArgon"/>
1313 <position name="posGaseousArgon" unit="cm" x="0" y="@{[$Argon_y/2-$HeightGaseousAr/2]}" z="0"/>
1316 <volumeref ref="volSteelShell"/>
1317 <position name="posSteelShell" unit="cm" x="0" y="0" z="0"/>
1322 if ($tpc_on==1) # place TPC inside croysotat
1325 $posY = $Argon_y/2 - $HeightGaseousAr - 0.5*($driftTPCActive + $ReadoutPlane);
1326 for($ii=0;$ii<$nCRM_z;$ii++)
1328 $posZ = -0.5*$Argon_z + $zLArBuffer + ($ii+0.5)*$lengthCRM;
1330 for($jj=0;$jj<$nCRM_x;$jj++)
1332 $posX = -0.5*$Argon_x + $xLArBuffer + ($jj+0.5)*$widthCRM;
1335 <volumeref ref="volTPC"/>
1336 <position name="posTPC\-$ii\-$jj" unit="cm"
1337 x="$posX" y="$posY" z="$posZ"/>
1345 if ( $pmt_switch eq "on" )
1347 for ( $i=0; $i<$pmtN; $i=$i+1 )
1351 <volumeref ref="volPMT"/>
1352 <position name="posPMT$i" unit="cm" @pmt_pos[$i]/>
1353 <rotationref ref="rPlus90AboutX"/>
1359 #The +50 in the y positions must depend on some other parameter
1360 if ( $FieldCage_switch eq "on" ) {
1361 for ( $i=0; $i<$NFieldShapers; $i=$i+1 ) { # pmts with coating
1362 $posY = $Argon_y/2 - $HeightGaseousAr - 0.5*($driftTPCActive + $ReadoutPlane);
1365 <volumeref ref="volFieldShaper"/>
1366 <position name="posFieldShaper$i" unit="cm" x="@{[-1*(-0.5*$FieldShaperShortTubeLength-$FieldShaperTorRad)]}" y="@{[-$i*$FieldShaperSeparation+$FirstFieldShaperPosY]}" z="0" />
1367 <rotation name="rotFS$i" unit="deg" x="0" y="0" z="0" />
1373 if ( $GroundGrid_switch eq "on" )
1377 <volumeref ref="volGroundGrid"/>
1378 <position name="posGroundGrid01" unit="cm" x="$GroundGridPosX" y="@{[$GroundGridPosY]}" z="@{[$GroundGridPosZ]}"/>
1379 <rotation name="rotGG01" unit="deg" x="0" y="0" z="0" />
1387 if ( $Cathode_switch eq "on" )
1391 <volumeref ref="volGroundGrid"/>
1392 <position name="posGroundGrid01" unit="cm" x="$CathodePosX" y="@{[$CathodePosY]}" z="@{[$CathodePosZ]}"/>
1393 <rotation name="rotGG01" unit="deg" x="0" y="0" z="0" />
1400 if ( $ExtractionGrid_switch eq "on" )
1407 <volumeref ref="volExtractionGrid"/>
1408 <position name="posExtractionGrid" unit="cm" x="$ExtractionGridX" y="$ExtractionGridY" z="$ExtractionGridZ"/>
1415 if ( $Foils_switch eq "on" ) {
1418 <volumeref ref="volFoilZ"/>
1419 <position name="posFoilZpos" unit="cm" x="@{[$FoilPositionZ]}" y="@{[$FoilPositionY]}" z="0" />
1420 <rotation name="rotFoilZpos" unit="deg" x="0" y="180" z="0" />
1423 <volumeref ref="volFoilZ"/>
1424 <position name="posFoilZneg" unit="cm" x="@{[-$FoilPositionZ]}" y="@{[$FoilPositionY]}" z="0" />
1425 <rotation name="rotFoilZneg" unit="deg" x="0" y="0" z="0" />
1428 <volumeref ref="volFoilX"/>
1429 <position name="posFoilXpos" unit="cm" x="0" y="@{[$FoilPositionY]}" z="@{[$FoilPositionX]}" />
1430 <rotation name="rotFoilXpos" unit="deg" x="0" y="180" z="0" />
1433 <volumeref ref="volFoilX"/>
1434 <position name="posFoilXneg" unit="cm" x="0" y="@{[$FoilPositionY]}" z="@{[-$FoilPositionX]}" />
1435 <rotation name="rotFoilXneg" unit="deg" x="0" y="0" z="0" />
1451 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1452 #+++++++++++++++++++++++++++++++++++++ gen_Enclosure +++++++++++++++++++++++++++++++++++++
1453 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1458 # Create the detector enclosure fragment file name,
1459 # add file to list of output GDML fragments,
1461 $ENCL = $basename."_DetEnclosure" . $suffix . ".gdml";
1462 push (@gdmlFiles, $ENCL);
1463 $ENCL = ">" . $ENCL;
1464 open(ENCL) or die("Could not open file $ENCL for writing");
1467 # The standard XML prefix and starting the gdml
1469 <?xml version='1.0'?>
1474 # All the detector enclosure solids.
1478 <box name="FoamPadBlock" lunit="cm"
1479 x="@{[$Cryostat_x + 2*$FoamPadding]}"
1480 y="@{[$Cryostat_y + 2*$FoamPadding]}"
1481 z="@{[$Cryostat_z + 2*$FoamPadding]}" />
1483 <subtraction name="FoamPadding">
1484 <first ref="FoamPadBlock"/>
1485 <second ref="Cryostat"/>
1486 <positionref ref="posCenter"/>
1489 <box name="SteelSupportBlock" lunit="cm"
1490 x="@{[$Cryostat_x + 2*$FoamPadding + 2*$SteelSupport_x]}"
1491 y="@{[$Cryostat_y + 2*$FoamPadding + 2*$SteelSupport_y]}"
1492 z="@{[$Cryostat_z + 2*$FoamPadding + 2*$SteelSupport_z]}" />
1494 <subtraction name="SteelSupport">
1495 <first ref="SteelSupportBlock"/>
1496 <second ref="FoamPadBlock"/>
1497 <positionref ref="posCenter"/>
1500 <box name="DetEnclosure" lunit="cm"
1509 # Detector enclosure structure
1512 <volume name="volFoamPadding">
1513 <materialref ref="fibrous_glass"/>
1514 <solidref ref="FoamPadding"/>
1517 <volume name="volSteelSupport">
1518 <materialref ref="AirSteelMixture"/>
1519 <solidref ref="SteelSupport"/>
1522 <volume name="volDetEnclosure">
1523 <materialref ref="Air"/>
1524 <solidref ref="DetEnclosure"/>
1527 <volumeref ref="volFoamPadding"/>
1528 <positionref ref="posCryoInDetEnc"/>
1531 <volumeref ref="volSteelSupport"/>
1532 <positionref ref="posCryoInDetEnc"/>
1535 <volumeref ref="volCryostat"/>
1536 <positionref ref="posCryoInDetEnc"/>
1555 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1556 #+++++++++++++++++++++++++++++++++++++++ gen_World +++++++++++++++++++++++++++++++++++++++
1557 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1562 # Create the WORLD fragment file name,
1563 # add file to list of output GDML fragments,
1565 $WORLD = $basename."_World" . $suffix . ".gdml";
1566 push (@gdmlFiles, $WORLD);
1567 $WORLD = ">" . $WORLD;
1568 open(WORLD) or die("Could not open file $WORLD for writing");
1571 # The standard XML prefix and starting the gdml
1573 <?xml version='1.0'?>
1578 # All the World solids.
1581 <box name="World" lunit="cm"
1582 x="@{[$DetEncX+2*$RockThickness]}"
1583 y="@{[$DetEncY+2*$RockThickness]}"
1584 z="@{[$DetEncZ+2*$RockThickness]}"/>
1591 <volume name="volWorld" >
1592 <materialref ref="DUSEL_Rock"/>
1593 <solidref ref="World"/>
1596 <volumeref ref="volDetEnclosure"/>
1597 <position name="posDetEnclosure" unit="cm" x="$OriginXSet" y="$OriginYSet" z="$OriginZSet"/>
1605 # make_gdml.pl will take care of <setup/>
1612 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1613 #++++++++++++++++++++++++++++++++++++ write_fragments ++++++++++++++++++++++++++++++++++++
1614 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1616 sub write_fragments()
1618 # This subroutine creates an XML file that summarizes the the subfiles output
1619 # by the other sub routines - it is the input file for make_gdml.pl which will
1620 # give the final desired GDML file. Specify its name with the output option.
1621 # (you can change the name when running make_gdml)
1623 # This code is taken straigh from the similar MicroBooNE generate script, Thank you.
1625 if ( ! defined $output )
1627 $output = "-"; # write to STDOUT
1630 # Set up the output file.
1631 $OUTPUT = ">" . $output;
1632 open(OUTPUT) or die("Could not open file $OUTPUT");
1635 <?xml version='1.0'?>
1637 <!-- Input to Geometry/gdml/make_gdml.pl; define the GDML fragments
1638 that will be zipped together to create a detector description.
1645 <!-- These files contain GDML <constant></constant>
1646 blocks. They are read in separately, so they can be
1647 interpreted into the remaining GDML. See make_gdml.pl for
1653 foreach $filename (@defFiles)
1656 <filename> $filename </filename>
1666 <!-- The GDML file fragments to be zipped together. -->
1670 foreach $filename (@gdmlFiles)
1673 <filename> $filename </filename>
1688 print "Some key parameters for dual-phase LAr TPC (unit cm unless noted otherwise)\n";
1689 print "CRM active area : $widthCRM_active x $lengthCRM_active\n";
1690 print "CRM total area : $widthCRM x $lengthCRM\n";
1691 print "TPC active volume : $driftTPCActive x $widthTPCActive x $lengthTPCActive\n";
1692 print "Argon buffer : ($xLArBuffer, $yLArBuffer, $zLArBuffer) \n";
1693 print "Detector enclosure : $DetEncX x $DetEncY x $DetEncZ\n";
1694 print "TPC Origin : ($OriginXSet, $OriginYSet, $OriginZSet) \n";
1695 print "Field Cage : $FieldCage_switch \n";
1696 print "Cathode : $Cathode_switch \n";
1697 print "GroundGrid : $GroundGrid_switch \n";
1698 print "ExtractionGrid : $ExtractionGrid_switch \n";
1699 print "LEMs : $LEMs_switch \n";
1700 print "PMTs : $pmt_switch \n";
1701 print "Foils : $Foils_switch \n";
1703 # run the sub routines that generate the fragments
1704 if ( $pmt_switch eq "on" ) { gen_pmt(); }
1705 if ( $FieldCage_switch eq "on" ) { gen_FieldCage(); }
1706 if ( $GroundGrid_switch eq "on" ) { gen_GroundGrid(); }
1707 #if ( $Cathode_switch eq "on" ) { gen_Cathode(); } #Cathode for now has the same geometry as the Ground Grid
1708 if ( $ExtractionGrid_switch eq "on" ) { gen_ExtractionGrid(); }
1709 if ( $LEMs_switch eq "on" ) { gen_LEMs(); }
1710 if ( $Foils_switch eq "on" ) { gen_Foils(); }
1713 gen_Define(); # generates definitions at beginning of GDML
1714 gen_Materials(); # generates materials to be used
1715 gen_TPC(); # generate TPC for a given unit CRM
1718 gen_World(); # places the enclosure among DUSEL Rock
1719 write_fragments(); # writes the XML input for make_gdml.pl
1720 # which zips together the final GDML
1721 print "--- done\n\n\n";