3 # contact tylerdalion@gmail.com for any GDML/generate questions
4 # I would love to help!
8 # Basic ICARUS detector, much tweaking to do.
12 # Each subroutine generates a fragment GDML file, and the last subroutine
13 # creates an XML file that make_gdml.pl will use to appropriately arrange
14 # the fragment GDML files to create the final desired DUNE GDML file,
15 # to be named by make_gdml output command
17 # If you are playing with different geometries, you can use the
18 # suffix command to help organize your work.
23 Math::BigFloat->precision(-16);
25 GetOptions( "help|h" => \$help,
26 "suffix|s:s" => \$suffix,
27 "output|o:s" => \$output,
28 "wires|w:s" => \$wires,
29 "helpcube|c" => \$helpcube);
33 # If the user requested help, print the usage notes and exit.
38 if ( ! defined $suffix )
40 # The user didn't supply a suffix, so append nothing to the file
46 # Otherwise, stick a "-" before the suffix, so that a suffix of
47 # "test" applied to filename.gdml becomes "filename-test.gdml".
48 $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
68 ##################################################################
69 ##################### wire plane parameters ######################
79 $SinUAngle = sin( deg2rad($UAngle) );
80 $CosUAngle = cos( deg2rad($UAngle) );
81 $TanUAngle = tan( deg2rad($UAngle) );
83 $SinVAngle = sin( deg2rad($VAngle) );
84 $CosVAngle = cos( deg2rad($VAngle) );
85 $TanVAngle = tan( deg2rad($VAngle) );
87 $UWireCornerInt_y = $UWirePitch * $CosUAngle;
88 $UWireCornerInt_z = $UWirePitch * $SinUAngle;
89 $UWire_ypitch = $UWirePitch / $SinUAngle;
90 $UWire_zpitch = $UWirePitch / $CosUAngle;
93 $VWireCornerInt_y = $VWirePitch * $CosVAngle;
94 $VWireCornerInt_z = $VWirePitch * $SinVAngle;
95 $VWire_ypitch = $VWirePitch / $SinVAngle;
96 $VWire_zpitch = $VWirePitch / $CosVAngle;
99 $TPCWireThickness = 0.015;
101 $TPCWirePlane_x = $TPCWireThickness;
102 #height and length defined lower
105 $nSkipCornerUWires = 0;
106 $nSkipCornerVWires = 0;
109 ###########################################################################
110 ########################### spacing parameters ############################
114 $WirePlaneSpacing = 0.476; # center to center
115 # NOTE: if wire plane spacing is change, GeometeryTest must be modified
117 #MaxDrift is the distance form the edge of the CPA to the edge of the first wire plane
120 #Cryostat space with LAr outside of entire fiducial volume
121 $SpaceWirePlToWall = 50;
122 $SpaceWirePlToWirePl = 85; # edge to edge, like all of these
123 $SpaceTPCToFloor = 50;
124 $SpaceTPCToTopLAr = 50;
125 $UpstreamLArPadding = 50;
126 $DownstreamLArPadding = 50;
132 ##############################################################
133 ############## Cryo and TPC relevant dimensions #############
136 $TPC_x = $MaxDrift + $TPCWirePlane_x + 3*$WirePlaneSpacing;
142 + 2*($CPA_x + $SpaceWirePlToWall)
143 + $SpaceWirePlToWirePl;
148 + $UpstreamLArPadding
149 + $DownstreamLArPadding;
151 $SteelThickness = 0.5*$inch; #half inch
154 $Cryostat_x = $LAr_x + 2*$SteelThickness ;
155 $Cryostat_y = $LAr_y + 2*$SteelThickness + $GaseousAr_y ;
156 $Cryostat_z = $LAr_z + 2*$SteelThickness ;
159 # $TPCWirePlane_x defined higher up
160 $TPCWirePlane_y = $TPC_y ;
161 $TPCWirePlane_z = $TPC_z ;
164 $TPCinCryo_x[0] = - $LAr_x/2 + $SpaceWirePlToWall + 0.5*($TPC_x) ;
165 $TPCinCryo_x[1] = - $LAr_x/2 + $SpaceWirePlToWall + 1.5*($TPC_x) + $CPA_x ;
166 $TPCinCryo_x[2] = $LAr_x/2 - $SpaceWirePlToWall - 1.5*($TPC_x) - $CPA_x ;
167 $TPCinCryo_x[3] = $LAr_x/2 - $SpaceWirePlToWall - 0.5*($TPC_x) ;
170 $posRightCat_x = - $Cryostat_x/2 + 1.0*($TPC_x) + $SpaceWirePlToWall + $CPA_x/2 ;
171 $posLeftCat_x = $Cryostat_x/2 - 1.0*($TPC_x) - $SpaceWirePlToWall - $CPA_x/2 ;
173 $TPCinCryo_y = - $Cryostat_y/2 + $TPC_y/2 + $SpaceTPCToFloor;
174 $TPCinCryo_z = - $Cryostat_z/2 + $TPC_z/2 + $UpstreamLArPadding;
176 $TPCActive_x = $MaxDrift;
177 $TPCActive_y = $TPCWirePlane_y;
178 $TPCActive_z = $TPCWirePlane_z;
181 $posTPCActive_x = $TPC_x/2-$TPCActive_x/2;
188 ##################################################################
189 ############## DetEnc and World relevant parameters #############
191 $ConcretePadding = 50;
193 $TotalPadding = $ConcretePadding+$FoamPadding;
194 $DetEnc_x = $Cryostat_x+2*$TotalPadding;
195 $DetEnc_y = $Cryostat_y+$ConcretePadding;
196 # no foam on bottom or top, no concrete on top
197 $DetEnc_z = $Cryostat_z+2*$TotalPadding;
201 $CryoInDetEnc_y = -$DetEnc_y/2 + $ConcretePadding + $Cryostat_y/2;
205 # We want the world origin to be at the very front of the fiducial volume.
206 # move it to the front of the enclosure, then back it up through the concrete/foam,
207 # then through the Cryostat shell, then through the upstream dead LAr (including the
208 # dead LAr on the edge of the TPC, but this is covered in $UpstreamLArPadding).
209 # This is to be added to the z position of every volume in volWorld
211 $OriginZSet = $DetEnc_z/2
214 - $UpstreamLArPadding;
216 $OriginYSet = $DetEnc_y/2
222 $OriginXSet = $LAr_x/2
224 - 3*$WirePlaneSpacing
229 $World_x = 2*$DetEnc_x;
230 $World_y = 2*$DetEnc_y;
231 $World_z = 2*$DetEnc_z;
236 #+++++++++++++++++++++++++ End defining variables ++++++++++++++++++++++++++
238 # run the sub routines that generate the fragments
240 gen_Define(); # generates definitions at beginning of GDML
241 gen_Materials(); # generates materials to be used
243 gen_TPC(); # generates wires, wire planes, and puts them in volTPC
244 # This is the bulk of the code, and has zero wires option
245 gen_Cryostat(); # places (2*nAPAWide x nAPAHigh x nAPALong) volTPC,
246 # half rotated 180 about Y
247 gen_Enclosure(); # places two cryostats and concrete volumes
249 gen_World(); # places the enclosure among DUSEL Rock
252 write_fragments(); # writes the XML input for make_gdml.pl
253 # which zips together the final GDML
257 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
258 #+++++++++++++++++++++++++++++++++++++++++ usage +++++++++++++++++++++++++++++++++++++++++
259 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
263 print "Usage: $0 [-h|--help] [-o|--output <fragments-file>] [-s|--suffix <string>]\n";
264 print " if -o is omitted, output goes to STDOUT; <fragments-file> is input to make_gdml.pl\n";
265 print " -s <string> appends the string to the file names; useful for multiple detector versions\n";
266 print " -h prints this message, then quits\n";
271 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
272 #++++++++++++++++++++++++++++++++++++++ gen_Define +++++++++++++++++++++++++++++++++++++++
273 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
278 # Create the <define> fragment file name,
279 # add file to list of fragments,
281 $DEF = "dune_10kT_Def" . $suffix . ".gdml";
282 push (@gdmlFiles, $DEF);
284 open(DEF) or die("Could not open file $DEF for writing");
288 <?xml version='1.0'?>
299 <position name="posActiveInTPC" unit="cm" x="$posTPCActive_x" y="$posTPCActive_y" z="$posTPCActive_z"/>
301 <position name="posTPC0inCryo" unit="cm" x="$TPCinCryo_x[0]" y="$TPCinCryo_y" z="$TPCinCryo_z" />
302 <position name="posRightCathode" unit="cm" x="$posRightCat_x" y="$TPCinCryo_y" z="$TPCinCryo_z" />
303 <position name="posTPC1inCryo" unit="cm" x="$TPCinCryo_x[1]" y="$TPCinCryo_y" z="$TPCinCryo_z" />
304 <position name="posTPC2inCryo" unit="cm" x="$TPCinCryo_x[2]" y="$TPCinCryo_y" z="$TPCinCryo_z" />
305 <position name="posLeftCathode" unit="cm" x="$posLeftCat_x" y="$TPCinCryo_y" z="$TPCinCryo_z" />
306 <position name="posTPC3inCryo" unit="cm" x="$TPCinCryo_x[3]" y="$TPCinCryo_y" z="$TPCinCryo_z" />
308 <position name="posCryoInDetEnc" unit="cm" x="$CryoInDetEnc_x" y="$CryoInDetEnc_y" z="$CryoInDetEnc_z" />
309 <position name="posDetEncInWorld" unit="cm" x="$OriginXSet" y="$OriginYSet" z="$OriginZSet"/>
312 <position name="posCenter" unit="cm" x="0" y="0" z="0"/>
313 <rotation name="rPlus90AboutX" unit="deg" x="90" y="0" z="0"/>
314 <rotation name="rMinus90AboutY" unit="deg" x="0" y="270" z="0"/>
315 <rotation name="rMinus90AboutYMinus90AboutX" unit="deg" x="270" y="270" z="0"/>
316 <rotation name="rPlusUAngleAboutX" unit="deg" x="90-$UAngle" y="0" z="0"/>
317 <rotation name="rPlusVAngleAboutX" unit="deg" x="90+$VAngle" y="0" z="0"/>
318 <rotation name="rPlus180AboutY" unit="deg" x="0" y="180" z="0"/>
319 <rotation name="rIdentity" unit="deg" x="0" y="0" z="0"/>
329 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
330 #+++++++++++++++++++++++++++++++++++++ gen_Materials +++++++++++++++++++++++++++++++++++++
331 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
336 # Create the <materials> fragment file name,
337 # add file to list of output GDML fragments,
339 $MAT = "dune_10kT_Materials" . $suffix . ".gdml";
340 push (@gdmlFiles, $MAT);
342 open(MAT) or die("Could not open file $MAT for writing");
347 <element name="videRef" formula="VACUUM" Z="1"> <atom value="1"/> </element>
348 <element name="bromine" formula="Br" Z="35"> <atom value="79.904"/> </element>
349 <element name="hydrogen" formula="H" Z="1"> <atom value="1.0079"/> </element>
350 <element name="nitrogen" formula="N" Z="7"> <atom value="14.0067"/> </element>
351 <element name="oxygen" formula="O" Z="8"> <atom value="15.999"/> </element>
352 <element name="aluminum" formula="Al" Z="13"> <atom value="26.9815"/> </element>
353 <element name="silicon" formula="Si" Z="14"> <atom value="28.0855"/> </element>
354 <element name="carbon" formula="C" Z="6"> <atom value="12.0107"/> </element>
355 <element name="potassium" formula="K" Z="19"> <atom value="39.0983"/> </element>
356 <element name="chromium" formula="Cr" Z="24"> <atom value="51.9961"/> </element>
357 <element name="iron" formula="Fe" Z="26"> <atom value="55.8450"/> </element>
358 <element name="nickel" formula="Ni" Z="28"> <atom value="58.6934"/> </element>
359 <element name="calcium" formula="Ca" Z="20"> <atom value="40.078"/> </element>
360 <element name="magnesium" formula="Mg" Z="12"> <atom value="24.305"/> </element>
361 <element name="sodium" formula="Na" Z="11"> <atom value="22.99"/> </element>
362 <element name="titanium" formula="Ti" Z="22"> <atom value="47.867"/> </element>
363 <element name="argon" formula="Ar" Z="18"> <atom value="39.9480"/> </element>
364 <element name="sulphur" formula="S" Z="16"> <atom value="32.065"/> </element>
365 <element name="phosphorus" formula="P" Z="16"> <atom value="30.973"/> </element>
367 <material name="Vacuum" formula="Vacuum">
368 <D value="1.e-25" unit="g/cm3"/>
369 <fraction n="1.0" ref="videRef"/>
372 <material name="ALUMINUM_Al" formula="ALUMINUM_Al">
373 <D value="2.6990" unit="g/cm3"/>
374 <fraction n="1.0000" ref="aluminum"/>
377 <material name="SILICON_Si" formula="SILICON_Si">
378 <D value="2.3300" unit="g/cm3"/>
379 <fraction n="1.0000" ref="silicon"/>
382 <material name="epoxy_resin" formula="C38H40O6Br4">
383 <D value="1.1250" unit="g/cm3"/>
384 <composite n="38" ref="carbon"/>
385 <composite n="40" ref="hydrogen"/>
386 <composite n="6" ref="oxygen"/>
387 <composite n="4" ref="bromine"/>
390 <material name="SiO2" formula="SiO2">
391 <D value="2.2" unit="g/cm3"/>
392 <composite n="1" ref="silicon"/>
393 <composite n="2" ref="oxygen"/>
396 <material name="Al2O3" formula="Al2O3">
397 <D value="3.97" unit="g/cm3"/>
398 <composite n="2" ref="aluminum"/>
399 <composite n="3" ref="oxygen"/>
402 <material name="Fe2O3" formula="Fe2O3">
403 <D value="5.24" unit="g/cm3"/>
404 <composite n="2" ref="iron"/>
405 <composite n="3" ref="oxygen"/>
408 <material name="CaO" formula="CaO">
409 <D value="3.35" unit="g/cm3"/>
410 <composite n="1" ref="calcium"/>
411 <composite n="1" ref="oxygen"/>
414 <material name="MgO" formula="MgO">
415 <D value="3.58" unit="g/cm3"/>
416 <composite n="1" ref="magnesium"/>
417 <composite n="1" ref="oxygen"/>
420 <material name="Na2O" formula="Na2O">
421 <D value="2.27" unit="g/cm3"/>
422 <composite n="2" ref="sodium"/>
423 <composite n="1" ref="oxygen"/>
426 <material name="TiO2" formula="TiO2">
427 <D value="4.23" unit="g/cm3"/>
428 <composite n="1" ref="titanium"/>
429 <composite n="2" ref="oxygen"/>
432 <material name="FeO" formula="FeO">
433 <D value="5.745" unit="g/cm3"/>
434 <composite n="1" ref="iron"/>
435 <composite n="1" ref="oxygen"/>
438 <material name="CO2" formula="CO2">
439 <D value="1.562" unit="g/cm3"/>
440 <composite n="1" ref="iron"/>
441 <composite n="2" ref="oxygen"/>
444 <material name="P2O5" formula="P2O5">
445 <D value="1.562" unit="g/cm3"/>
446 <composite n="2" ref="phosphorus"/>
447 <composite n="5" ref="oxygen"/>
450 <material formula=" " name="DUSEL_Rock">
451 <D value="2.82" unit="g/cm3"/>
452 <fraction n="0.5267" ref="SiO2"/>
453 <fraction n="0.1174" ref="FeO"/>
454 <fraction n="0.1025" ref="Al2O3"/>
455 <fraction n="0.0473" ref="MgO"/>
456 <fraction n="0.0422" ref="CO2"/>
457 <fraction n="0.0382" ref="CaO"/>
458 <fraction n="0.0240" ref="carbon"/>
459 <fraction n="0.0186" ref="sulphur"/>
460 <fraction n="0.0053" ref="Na2O"/>
461 <fraction n="0.00070" ref="P2O5"/>
462 <fraction n="0.0771" ref="oxygen"/>
465 <material name="fibrous_glass">
466 <D value="2.74351" unit="g/cm3"/>
467 <fraction n="0.600" ref="SiO2"/>
468 <fraction n="0.118" ref="Al2O3"/>
469 <fraction n="0.001" ref="Fe2O3"/>
470 <fraction n="0.224" ref="CaO"/>
471 <fraction n="0.034" ref="MgO"/>
472 <fraction n="0.010" ref="Na2O"/>
473 <fraction n="0.013" ref="TiO2"/>
476 <material name="FR4">
477 <D value="1.98281" unit="g/cm3"/>
478 <fraction n="0.47" ref="epoxy_resin"/>
479 <fraction n="0.53" ref="fibrous_glass"/>
482 <material name="STEEL_STAINLESS_Fe7Cr2Ni" formula="STEEL_STAINLESS_Fe7Cr2Ni">
483 <D value="7.9300" unit="g/cm3"/>
484 <fraction n="0.0010" ref="carbon"/>
485 <fraction n="0.1792" ref="chromium"/>
486 <fraction n="0.7298" ref="iron"/>
487 <fraction n="0.0900" ref="nickel"/>
490 <material name="LAr" formula="LAr">
491 <D value="1.40" unit="g/cm3"/>
492 <fraction n="1.0000" ref="argon"/>
495 <material name="ArGas" formula="ArGas">
496 <D value="0.00166" unit="g/cm3"/>
497 <fraction n="1.0" ref="argon"/>
500 <material formula=" " name="Air">
501 <D value="0.001205" unit="g/cm3"/>
502 <fraction n="0.781154" ref="nitrogen"/>
503 <fraction n="0.209476" ref="oxygen"/>
504 <fraction n="0.00934" ref="argon"/>
507 <material formula=" " name="G10">
508 <D value="1.7" unit="g/cm3"/>
509 <fraction n="0.2805" ref="silicon"/>
510 <fraction n="0.3954" ref="oxygen"/>
511 <fraction n="0.2990" ref="carbon"/>
512 <fraction n="0.0251" ref="hydrogen"/>
515 <material formula=" " name="Granite">
516 <D value="2.7" unit="g/cm3"/>
517 <fraction n="0.438" ref="oxygen"/>
518 <fraction n="0.257" ref="silicon"/>
519 <fraction n="0.222" ref="sodium"/>
520 <fraction n="0.049" ref="aluminum"/>
521 <fraction n="0.019" ref="iron"/>
522 <fraction n="0.015" ref="potassium"/>
525 <material formula=" " name="ShotRock">
526 <D value="2.7*0.6" unit="g/cm3"/>
527 <fraction n="0.438" ref="oxygen"/>
528 <fraction n="0.257" ref="silicon"/>
529 <fraction n="0.222" ref="sodium"/>
530 <fraction n="0.049" ref="aluminum"/>
531 <fraction n="0.019" ref="iron"/>
532 <fraction n="0.015" ref="potassium"/>
535 <material formula=" " name="Dirt">
536 <D value="1.7" unit="g/cm3"/>
537 <fraction n="0.438" ref="oxygen"/>
538 <fraction n="0.257" ref="silicon"/>
539 <fraction n="0.222" ref="sodium"/>
540 <fraction n="0.049" ref="aluminum"/>
541 <fraction n="0.019" ref="iron"/>
542 <fraction n="0.015" ref="potassium"/>
545 <material formula=" " name="Concrete">
546 <D value="2.3" unit="g/cm3"/>
547 <fraction n="0.530" ref="oxygen"/>
548 <fraction n="0.335" ref="silicon"/>
549 <fraction n="0.060" ref="calcium"/>
550 <fraction n="0.015" ref="sodium"/>
551 <fraction n="0.020" ref="iron"/>
552 <fraction n="0.040" ref="aluminum"/>
555 <material formula="H2O" name="Water">
556 <D value="1.0" unit="g/cm3"/>
557 <fraction n="0.1119" ref="hydrogen"/>
558 <fraction n="0.8881" ref="oxygen"/>
561 <material formula="Ti" name="Titanium">
562 <D value="4.506" unit="g/cm3"/>
563 <fraction n="1." ref="titanium"/>
566 <material name="TPB" formula="TPB">
567 <D value="1.40" unit="g/cm3"/>
568 <fraction n="1.0000" ref="argon"/>
571 <material name="Glass">
572 <D value="2.74351" unit="g/cm3"/>
573 <fraction n="0.600" ref="SiO2"/>
574 <fraction n="0.118" ref="Al2O3"/>
575 <fraction n="0.001" ref="Fe2O3"/>
576 <fraction n="0.224" ref="CaO"/>
577 <fraction n="0.034" ref="MgO"/>
578 <fraction n="0.010" ref="Na2O"/>
579 <fraction n="0.013" ref="TiO2"/>
582 <material name="Acrylic">
583 <D value="1.19" unit="g/cm3"/>
584 <fraction n="0.600" ref="carbon"/>
585 <fraction n="0.320" ref="oxygen"/>
586 <fraction n="0.080" ref="hydrogen"/>
598 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
599 #++++++++++++++++++++++++++++++++++++++++ gen_TPC ++++++++++++++++++++++++++++++++++++++++
600 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
606 #constructs everything inside volTPC, namely
607 # (moving from left to right, or from +x to -x)
608 # -volTPCPlaneU: with wires angled from vertical
609 # -volTPCPlaneV: with wires angled from vertical
610 # -volTPCPlaneX: with vertical wires
613 # Create the TPC fragment file name,
614 # add file to list of output GDML fragments,
616 $TPC = "dune_10kT_TPC" . $suffix . ".gdml";
617 push (@gdmlFiles, $TPC);
619 open(TPC) or die("Could not open file $TPC for writing");
622 # The standard XML prefix and starting the gdml
624 <?xml version='1.0'?>
629 # All the TPC solids save the wires.
632 <box name="TPC" lunit="cm"
636 <box name="TPCPlane" lunit="cm"
639 z="$TPCWirePlane_z"/>
640 <box name="TPCActive" lunit="cm"
647 #++++++++++++++++++++++++++++ Wire Solids ++++++++++++++++++++++++++++++
651 <tube name="TPCWireVert"
652 rmax="0.5*$TPCWireThickness"
659 # Set number of wires to default to zero, when $wires_on = 0, for a low memory
660 # version. But if $wires_on = 1, calculate the number of wires on each side of each
661 # plane to be used in the for loops
663 my $NumberCornerUWires = 0;
664 my $NumberSideUWires = 0;
665 my $NumberCommonUWires = 0;
666 my $NumberCornerVWires = 0;
667 my $NumberSideVWires = 0;
668 my $NumberCommonVWires = 0;
669 my $NumberVerticalWires = 0;
673 # Number of wires in one corner
674 $NumberCornerUWires = int( $TPCWirePlane_y/$UWire_ypitch );
675 $NumberCornerVWires = int( $TPCWirePlane_y/$VWire_ypitch );
677 # Total number of wires touching one vertical (longer) side
678 # Note that the total number of wires per plane is this + another set of corner wires
679 $NumberSideUWires = int( $TPCWirePlane_z/$UWire_zpitch );
680 $NumberSideVWires = int( $TPCWirePlane_z/$VWire_zpitch );
682 # Number of wires per side that aren't cut off by the corner
683 $NumberCommonUWires = $NumberSideUWires - $NumberCornerUWires;
684 $NumberCommonVWires = $NumberSideVWires - $NumberCornerVWires;
686 # number of wires on the vertical plane
687 $NumberVerticalWires = int( ($TPCWirePlane_y-$TPCWireThickness)/$XWirePitch );
690 # These XML comments throughout make the GDML file easier to navigate
693 <!--+++++++++++++++++++ U Wire Solids ++++++++++++++++++++++-->
697 # The corner wires for the U plane
700 for ($i = 0; $i < $NumberCornerUWires; ++$i)
703 $length = ($i+1)*$UWire_zpitch / $SinUAngle;
706 <tube name="TPCWireU$i"
707 rmax="0.5*$TPCWireThickness"
717 <tube name="TPCWireUCommon"
718 rmax="0.5*$TPCWireThickness"
719 z="$TPCWirePlane_y/$CosUAngle-0.06"
729 <!-- This GDML version has no wires and uses much less memory -->
745 <!--+++++++++++++++++++ V Wire Solids ++++++++++++++++++++++-->
750 # The corner wires for the V plane
753 for ($i = 0; $i < $NumberCornerVWires; ++$i)
755 $length = ($i+1)*$VWire_zpitch / $SinVAngle;
759 <tube name="TPCWireV$i"
760 rmax="0.5*$TPCWireThickness"
770 # The wire used many times in the middle of the V plane
771 # Same subtraction as U common
774 <tube name="TPCWireVCommon"
775 rmax="0.5*$TPCWireThickness"
776 z="$TPCWirePlane_y/$CosVAngle-0.06"
787 <!-- no wires in this GDML -->
795 # Begin structure and create the vertical wire logical volume
799 <volume name="volTPCActive">
800 <materialref ref="LAr"/>
801 <solidref ref="TPCActive"/>
812 <!--+++++++++++++++++ Wire Logical Volumes ++++++++++++++++++++-->
820 <volume name="volTPCWireVert">
821 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni" />
822 <solidref ref="TPCWireVert" />
826 # Corner U wires logical volumes
827 for ($i = 0; $i < $NumberCornerUWires; ++$i)
830 <volume name="volTPCWireU$i">
831 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni" />
832 <solidref ref="TPCWireU$i" />
838 # Common U wire logical volume, referenced many times
840 <volume name="volTPCWireUCommon">
841 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni" />
842 <solidref ref="TPCWireUCommon" />
846 # Corner V wires logical volumes
847 for ($i = 0; $i < $NumberCornerVWires; ++$i)
850 <volume name="volTPCWireV$i">
851 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni" />
852 <solidref ref="TPCWireV$i" />
858 # Common V wire logical volume, referenced many times
860 <volume name="volTPCWireVCommon">
861 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni" />
862 <solidref ref="TPCWireVCommon" />
871 <!-- This GDML version has no wires and uses much less memory -->
880 #+++++++++++++++++++++++++ Position physical wires ++++++++++++++++++++++++++
882 # ++++++++++++++++++++++ U Plane +++++++++++++++++++++++
884 # Create U plane logical volume
893 <!--+++++++++++++++++++++ U Plane ++++++++++++++++++++++++-->
896 <volume name="volTPCPlaneU">
897 <materialref ref="LAr"/>
898 <solidref ref="TPCPlane"/>
912 for ($i = 0; $i < $NumberCornerUWires; ++$i)
915 if($i<$nSkipCornerUWires){ next; }
916 my $ypos = - $TPCWirePlane_y/2 + (($i+1)*$UWire_ypitch)/2;
917 my $zpos = $TPCWirePlane_z/2 - (($i+1)*$UWire_zpitch)/2;
921 <volumeref ref="volTPCWireU$i"/>
922 <position name="posTPCWireU$i" unit="cm" x="0" y="$ypos " z="$zpos"/>
923 <rotationref ref="rPlusUAngleAboutX"/>
929 for ($i = 0; $i < $NumberSideUWires-$NumberCornerUWires; ++$i)
931 my $zpos = $TPCWirePlane_z/2
932 - ($NumberCornerUWires*$UWire_zpitch)/2
933 - ($i+1)*$UWire_zpitch;
937 <volumeref ref="volTPCWireUCommon"/>
938 <position name="posTPCWireU$i" unit="cm" x="0" y="0 " z="$zpos"/>
939 <rotationref ref="rPlusUAngleAboutX"/>
945 for ($i = 0; $i < $NumberCornerUWires; ++$i)
948 if($i<$nSkipCornerUWires){ next; }
949 my $ypos = $TPCWirePlane_y/2 - (($i+1)*$UWire_ypitch)/2;
950 my $zpos = - $TPCWirePlane_z/2 + (($i+1)*$UWire_zpitch)/2;
954 <volumeref ref="volTPCWireU$i"/>
955 <position name="posTPCWireU$i" unit="cm" x="0" y="$ypos " z="$zpos"/>
956 <rotationref ref="rPlusUAngleAboutX"/>
964 # ++++++++++++++++++++++ V Plane +++++++++++++++++++++++
966 # End U plane and create V plane logical volume
976 <!--+++++++++++++++++++++ V Plane ++++++++++++++++++++++++-->
979 <volume name="volTPCPlaneV">
980 <materialref ref="LAr"/>
981 <solidref ref="TPCPlane"/>
994 for ($i = 0; $i < $NumberCornerVWires; ++$i)
997 if($i<$nSkipCornerVWires){ next; }
998 my $ypos = $TPCWirePlane_y/2 - (($i+1)*$VWire_ypitch)/2;
999 my $zpos = $TPCWirePlane_z/2 - (($i+1)*$VWire_zpitch)/2;
1003 <volumeref ref="volTPCWireV$i"/>
1004 <position name="posTPCWireV$i" unit="cm" x="0" y="$ypos " z="$zpos"/>
1005 <rotationref ref="rPlusVAngleAboutX"/>
1011 for ($i = 0; $i < $NumberSideVWires-$NumberCornerVWires; ++$i)
1013 my $zpos = $TPCWirePlane_z/2
1014 - ($NumberCornerVWires*$VWire_zpitch)/2
1015 - ($i+1)*$VWire_zpitch;
1019 <volumeref ref="volTPCWireVCommon"/>
1020 <position name="posTPCWireV$i" unit="cm" x="0" y="0 " z="$zpos"/>
1021 <rotationref ref="rPlusVAngleAboutX"/>
1027 for ($i = 0; $i < $NumberCornerVWires; ++$i)
1030 if($i<$nSkipCornerVWires){ next; }
1031 my $ypos = - $TPCWirePlane_y/2 + (($i+1)*$VWire_ypitch)/2;
1032 my $zpos = - $TPCWirePlane_z/2 + (($i+1)*$VWire_zpitch)/2;
1036 <volumeref ref="volTPCWireV$i"/>
1037 <position name="posTPCWireV$i" unit="cm" x="0" y="$ypos " z="$zpos"/>
1038 <rotationref ref="rPlusVAngleAboutX"/>
1048 # ++++++++++++++++++++++ X Plane +++++++++++++++++++++++
1050 # End V plane and create X plane logical volume
1059 <!--+++++++++++++++++++++ X Plane ++++++++++++++++++++++++-->
1062 <volume name="volTPCPlaneX">
1063 <materialref ref="LAr"/>
1064 <solidref ref="TPCPlane"/>
1078 for ($i=0; $i<$NumberVerticalWires; ++$i)
1081 my $ypos = (-0.5*$TPCWirePlane_y)+$TPCWireThickness/2+$XWirePitch*($i+0.5);
1085 <volumeref ref="volTPCWireVert"/>
1086 <position name="posTPCWireX$i" unit="cm" x="0" y="$ypos " z="0"/>
1087 <rotationref ref="rIdentity" />
1099 #+++++++++++++++++++++ Position physical wires Above +++++++++++++++++++++
1101 #wrap up the TPC file
1103 <volume name="volTPC">
1104 <materialref ref="LAr" />
1105 <solidref ref="TPC" />
1107 <volumeref ref="volTPCPlaneU" />
1108 <position name="posTPCPlaneU" unit="cm" x="(-$TPC_x/2)+3*$WirePlaneSpacing" y="0" z="0" />
1111 <volumeref ref="volTPCPlaneV" />
1112 <position name="posTPCPlaneV" unit="cm" x="(-$TPC_x/2)+2*$WirePlaneSpacing" y="0" z="0" />
1115 <volumeref ref="volTPCPlaneX" />
1116 <position name="posTPCPlaneX" unit="cm" x="(-$TPC_x/2)+$WirePlaneSpacing" y="0" z="0" />
1119 <volumeref ref="volTPCActive"/>
1120 <positionref ref="posActiveInTPC"/>
1129 } #end of sub gen_TPC
1135 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1136 #++++++++++++++++++++++++++++++++++++++ gen_Cryostat +++++++++++++++++++++++++++++++++++++
1137 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1142 # Create the cryostat fragment file name,
1143 # add file to list of output GDML fragments,
1145 $CRYO = "dune_10kT_Cryostat" . $suffix . ".gdml";
1146 push (@gdmlFiles, $CRYO);
1147 $CRYO = ">" . $CRYO;
1148 open(CRYO) or die("Could not open file $CRYO for writing");
1151 # The standard XML prefix and starting the gdml
1153 <?xml version='1.0'?>
1158 # All the cryostat solids.
1162 <box name="Cryostat" lunit="cm"
1166 <box name="ArgonInterior" lunit="cm"
1170 <box name="GaseousArgon" lunit="cm"
1174 <subtraction name="SteelShell">
1175 <first ref="Cryostat"/>
1176 <second ref="ArgonInterior"/>
1179 <box name="Cathode" lunit="cm"
1187 # Cryostat structure
1190 <volume name="volSteelShell">
1191 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni" />
1192 <solidref ref="SteelShell" />
1194 <volume name="volGaseousArgon">
1195 <materialref ref="ArGas"/>
1196 <solidref ref="GaseousArgon"/>
1199 <volume name="volCathode">
1200 <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni" />
1201 <solidref ref="Cathode" />
1205 <volume name="volCryostat">
1206 <materialref ref="LAr" />
1207 <solidref ref="Cryostat" />
1209 <volumeref ref="volGaseousArgon"/>
1210 <position name="posGaseousArgon" unit="cm" x="0" y="$LAr_y/2-$GaseousAr_y/2" z="0"/>
1213 <volumeref ref="volSteelShell"/>
1214 <position name="posSteelShell" unit="cm" x="0" y="0" z="0"/>
1218 <volumeref ref="volTPC"/>
1219 <positionref ref="posTPC0inCryo"/>
1220 <rotationref ref="rIdentity"/>
1223 <volumeref ref="volCathode" />
1224 <positionref ref="posRightCathode"/>
1227 <volumeref ref="volTPC"/>
1228 <positionref ref="posTPC1inCryo"/>
1229 <rotationref ref="rPlus180AboutY"/>
1233 <volumeref ref="volTPC"/>
1234 <positionref ref="posTPC2inCryo"/>
1235 <rotationref ref="rIdentity"/>
1238 <volumeref ref="volCathode" />
1239 <positionref ref="posLeftCathode"/>
1242 <volumeref ref="volTPC"/>
1243 <positionref ref="posTPC3inCryo"/>
1244 <rotationref ref="rPlus180AboutY"/>
1263 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1264 #+++++++++++++++++++++++++++++++++++++ gen_Enclosure +++++++++++++++++++++++++++++++++++++
1265 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1270 # Create the detector enclosure fragment file name,
1271 # add file to list of output GDML fragments,
1273 $ENCL = "dune_10kT_DetEnclosure" . $suffix . ".gdml";
1274 push (@gdmlFiles, $ENCL);
1275 $ENCL = ">" . $ENCL;
1276 open(ENCL) or die("Could not open file $ENCL for writing");
1279 # The standard XML prefix and starting the gdml
1281 <?xml version='1.0'?>
1286 # All the detector enclosure solids.
1290 <box name="DetEnclosure" lunit="cm"
1300 # Detector enclosure structure
1304 <volume name="volDetEnclosure">
1305 <materialref ref="Concrete"/>
1306 <solidref ref="DetEnclosure"/>
1309 <volumeref ref="volCryostat"/>
1310 <positionref ref="posCryoInDetEnc"/>
1326 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1327 #+++++++++++++++++++++++++++++++++++++++ gen_World +++++++++++++++++++++++++++++++++++++++
1328 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1333 # Create the WORLD fragment file name,
1334 # add file to list of output GDML fragments,
1336 $WORLD = "dune_10kT_World" . $suffix . ".gdml";
1337 push (@gdmlFiles, $WORLD);
1338 $WORLD = ">" . $WORLD;
1339 open(WORLD) or die("Could not open file $WORLD for writing");
1342 # The standard XML prefix and starting the gdml
1344 <?xml version='1.0'?>
1349 # All the World solids.
1352 <box name="World" lunit="cm"
1362 <volume name="volWorld" >
1363 <materialref ref="Air"/>
1364 <solidref ref="World"/>
1367 <volumeref ref="volDetEnclosure"/>
1368 <positionref ref="posDetEncInWorld"/>
1376 # make_gdml.pl will take care of <setup/>
1383 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1384 #++++++++++++++++++++++++++++++++++++ write_fragments ++++++++++++++++++++++++++++++++++++
1385 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1387 sub write_fragments()
1389 # This subroutine creates an XML file that summarizes the the subfiles output
1390 # by the other sub routines - it is the input file for make_gdml.pl which will
1391 # give the final desired GDML file. Specify its name with the output option.
1392 # (you can change the name when running make_gdml)
1394 # This code is taken straigh from the similar MicroBooNE generate script, Thank you.
1396 if ( ! defined $output )
1398 $output = "-"; # write to STDOUT
1401 # Set up the output file.
1402 $OUTPUT = ">" . $output;
1403 open(OUTPUT) or die("Could not open file $OUTPUT");
1406 <?xml version='1.0'?>
1408 <!-- Input to Geometry/gdml/make_gdml.pl; define the GDML fragments
1409 that will be zipped together to create a detector description.
1416 <!-- These files contain GDML <constant></constant>
1417 blocks. They are read in separately, so they can be
1418 interpreted into the remaining GDML. See make_gdml.pl for
1424 foreach $filename (@defFiles)
1427 <filename> $filename </filename>
1437 <!-- The GDML file fragments to be zipped together. -->
1441 foreach $filename (@gdmlFiles)
1444 <filename> $filename </filename>