generate_ICARUS.pl
Go to the documentation of this file.
1 #!/usr/bin/perl
2 
3 # contact tylerdalion@gmail.com for any GDML/generate questions
4 # I would love to help!
5 
6 
7 #
8 # Basic ICARUS detector, much tweaking to do.
9 #
10 
11 
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
16 
17 # If you are playing with different geometries, you can use the
18 # suffix command to help organize your work.
19 
20 use Math::Trig;
21 use Getopt::Long;
22 use Math::BigFloat;
23 Math::BigFloat->precision(-16);
24 
25 GetOptions( "help|h" => \$help,
26  "suffix|s:s" => \$suffix,
27  "output|o:s" => \$output,
28  "wires|w:s" => \$wires,
29  "helpcube|c" => \$helpcube);
30 
31 if ( defined $help )
32 {
33  # If the user requested help, print the usage notes and exit.
34  usage();
35  exit;
36 }
37 
38 if ( ! defined $suffix )
39 {
40  # The user didn't supply a suffix, so append nothing to the file
41  # names.
42  $suffix = "";
43 }
44 else
45 {
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;
49 }
50 
51 
52 #++++++++++++++++++++++++ Begin defining variables +++++++++++++++++++++++++
53 
54 # Define detector geometry variables - later to be put in a parameters
55 # XML file to be parsed as an input?
56 
57 # set wires on to be the default, unless given an input by the user
58 $wires_on = 1; # 1=on, 0=off
59 if (defined $wires)
60 {
61  $wires_on = $wires;
62 }
63 
64 $tpc_on=1;
65 $inch = 2.54;
66 
67 
68 ##################################################################
69 ##################### wire plane parameters ######################
70 
71 $UWirePitch = 0.3;
72 $VWirePitch = 0.3;
73 $XWirePitch = 0.3;
74 
75 $UAngle = 60;
76 $VAngle = 60;
77 
78 
79 $SinUAngle = sin( deg2rad($UAngle) );
80 $CosUAngle = cos( deg2rad($UAngle) );
81 $TanUAngle = tan( deg2rad($UAngle) );
82 
83 $SinVAngle = sin( deg2rad($VAngle) );
84 $CosVAngle = cos( deg2rad($VAngle) );
85 $TanVAngle = tan( deg2rad($VAngle) );
86 
87 $UWireCornerInt_y = $UWirePitch * $CosUAngle;
88 $UWireCornerInt_z = $UWirePitch * $SinUAngle;
89 $UWire_ypitch = $UWirePitch / $SinUAngle;
90 $UWire_zpitch = $UWirePitch / $CosUAngle;
91 
92 
93 $VWireCornerInt_y = $VWirePitch * $CosVAngle;
94 $VWireCornerInt_z = $VWirePitch * $SinVAngle;
95 $VWire_ypitch = $VWirePitch / $SinVAngle;
96 $VWire_zpitch = $VWirePitch / $CosVAngle;
97 
98 
99 $TPCWireThickness = 0.015;
100 
101 $TPCWirePlane_x = $TPCWireThickness;
102 #height and length defined lower
103 
104 
105 $nSkipCornerUWires = 0;
106 $nSkipCornerVWires = 0;
107 
108 
109 ###########################################################################
110 ########################### spacing parameters ############################
111 
112 
113 $CPA_x = 5.1;
114 $WirePlaneSpacing = 0.476; # center to center
115  # NOTE: if wire plane spacing is change, GeometeryTest must be modified
116 $MaxDrift = 150;
117  #MaxDrift is the distance form the edge of the CPA to the edge of the first wire plane
118 
119 
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;
127 
128 
129 
130 
131 
132 ##############################################################
133 ############## Cryo and TPC relevant dimensions #############
134 
135 
136 $TPC_x = $MaxDrift + $TPCWirePlane_x + 3*$WirePlaneSpacing;
137 $TPC_y = 390;
138 $TPC_z = 1990;
139 
140 
141 $LAr_x = 4*($TPC_x)
142  + 2*($CPA_x + $SpaceWirePlToWall)
143  + $SpaceWirePlToWirePl;
144 $LAr_y = $TPC_y
145  + $SpaceTPCToFloor
146  + $SpaceTPCToTopLAr;
147 $LAr_z = $TPC_z
148  + $UpstreamLArPadding
149  + $DownstreamLArPadding;
150 
151 $SteelThickness = 0.5*$inch; #half inch
152 $GaseousAr_y = 20;
153 
154 $Cryostat_x = $LAr_x + 2*$SteelThickness ;
155 $Cryostat_y = $LAr_y + 2*$SteelThickness + $GaseousAr_y ;
156 $Cryostat_z = $LAr_z + 2*$SteelThickness ;
157 
158 
159 # $TPCWirePlane_x defined higher up
160 $TPCWirePlane_y = $TPC_y ;
161 $TPCWirePlane_z = $TPC_z ;
162 
163 
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) ;
168 
169 
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 ;
172 
173 $TPCinCryo_y = - $Cryostat_y/2 + $TPC_y/2 + $SpaceTPCToFloor;
174 $TPCinCryo_z = - $Cryostat_z/2 + $TPC_z/2 + $UpstreamLArPadding;
175 
176 $TPCActive_x = $MaxDrift;
177 $TPCActive_y = $TPCWirePlane_y;
178 $TPCActive_z = $TPCWirePlane_z;
179 
180 
181 $posTPCActive_x = $TPC_x/2-$TPCActive_x/2;
182 $posTPCActive_y = 0;
183 $posTPCActive_z = 0;
184 
185 
186 
187 
188 ##################################################################
189 ############## DetEnc and World relevant parameters #############
190 
191 $ConcretePadding = 50;
192 $FoamPadding = 80;
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;
198 
199 
200 $CryoInDetEnc_x = 0;
201 $CryoInDetEnc_y = -$DetEnc_y/2 + $ConcretePadding + $Cryostat_y/2;
202 $CryoInDetEnc_z = 0;
203 
204 
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
210 
211 $OriginZSet = $DetEnc_z/2
212  - $TotalPadding
213  - $SteelThickness
214  - $UpstreamLArPadding;
215 
216 $OriginYSet = $DetEnc_y/2
217  - $ConcretePadding
218  - $SteelThickness
219  - $SpaceTPCToFloor
220  - $TPC_y/2;
221 
222 $OriginXSet = $LAr_x/2
223  - $SpaceWirePlToWall
224  - 3*$WirePlaneSpacing
225  - $TPCWirePlane_x;
226 
227 
228 
229 $World_x = 2*$DetEnc_x;
230 $World_y = 2*$DetEnc_y;
231 $World_z = 2*$DetEnc_z;
232 
233 
234 
235 
236 #+++++++++++++++++++++++++ End defining variables ++++++++++++++++++++++++++
237 
238 # run the sub routines that generate the fragments
239 
240 gen_Define(); # generates definitions at beginning of GDML
241 gen_Materials(); # generates materials to be used
242 
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
248 
249 gen_World(); # places the enclosure among DUSEL Rock
250 
251 
252 write_fragments(); # writes the XML input for make_gdml.pl
253  # which zips together the final GDML
254 exit;
255 
256 
257 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
258 #+++++++++++++++++++++++++++++++++++++++++ usage +++++++++++++++++++++++++++++++++++++++++
259 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
260 
261 sub usage()
262 {
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";
267 }
268 
269 
270 
271 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
272 #++++++++++++++++++++++++++++++++++++++ gen_Define +++++++++++++++++++++++++++++++++++++++
273 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
274 
275 sub gen_Define()
276 {
277 
278 # Create the <define> fragment file name,
279 # add file to list of fragments,
280 # and open it
281  $DEF = "dune_10kT_Def" . $suffix . ".gdml";
282  push (@gdmlFiles, $DEF);
283  $DEF = ">" . $DEF;
284  open(DEF) or die("Could not open file $DEF for writing");
285 
286 
287 print DEF <<EOF;
288 <?xml version='1.0'?>
289 <gdml>
290 <define>
291 
292 <!--
293 
294 
295 
296 -->
297 
298 
299  <position name="posActiveInTPC" unit="cm" x="$posTPCActive_x" y="$posTPCActive_y" z="$posTPCActive_z"/>
300 
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" />
307 
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"/>
310 
311 
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"/>
320 </define>
321 </gdml>
322 EOF
323  close (DEF);
324 }
325 
326 
327 
328 
329 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
330 #+++++++++++++++++++++++++++++++++++++ gen_Materials +++++++++++++++++++++++++++++++++++++
331 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
332 
333 sub gen_Materials()
334 {
335 
336 # Create the <materials> fragment file name,
337 # add file to list of output GDML fragments,
338 # and open it
339  $MAT = "dune_10kT_Materials" . $suffix . ".gdml";
340  push (@gdmlFiles, $MAT);
341  $MAT = ">" . $MAT;
342  open(MAT) or die("Could not open file $MAT for writing");
343 
344 
345  print MAT <<EOF;
346 <materials>
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>
366 
367  <material name="Vacuum" formula="Vacuum">
368  <D value="1.e-25" unit="g/cm3"/>
369  <fraction n="1.0" ref="videRef"/>
370  </material>
371 
372  <material name="ALUMINUM_Al" formula="ALUMINUM_Al">
373  <D value="2.6990" unit="g/cm3"/>
374  <fraction n="1.0000" ref="aluminum"/>
375  </material>
376 
377  <material name="SILICON_Si" formula="SILICON_Si">
378  <D value="2.3300" unit="g/cm3"/>
379  <fraction n="1.0000" ref="silicon"/>
380  </material>
381 
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"/>
388  </material>
389 
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"/>
394  </material>
395 
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"/>
400  </material>
401 
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"/>
406  </material>
407 
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"/>
412  </material>
413 
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"/>
418  </material>
419 
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"/>
424  </material>
425 
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"/>
430  </material>
431 
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"/>
436  </material>
437 
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"/>
442  </material>
443 
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"/>
448  </material>
449 
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"/>
463  </material>
464 
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"/>
474  </material>
475 
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"/>
480  </material>
481 
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"/>
488  </material>
489 
490  <material name="LAr" formula="LAr">
491  <D value="1.40" unit="g/cm3"/>
492  <fraction n="1.0000" ref="argon"/>
493  </material>
494 
495  <material name="ArGas" formula="ArGas">
496  <D value="0.00166" unit="g/cm3"/>
497  <fraction n="1.0" ref="argon"/>
498  </material>
499 
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"/>
505  </material>
506 
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"/>
513  </material>
514 
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"/>
523  </material>
524 
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"/>
533  </material>
534 
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"/>
543  </material>
544 
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"/>
553  </material>
554 
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"/>
559  </material>
560 
561  <material formula="Ti" name="Titanium">
562  <D value="4.506" unit="g/cm3"/>
563  <fraction n="1." ref="titanium"/>
564  </material>
565 
566  <material name="TPB" formula="TPB">
567  <D value="1.40" unit="g/cm3"/>
568  <fraction n="1.0000" ref="argon"/>
569  </material>
570 
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"/>
580  </material>
581 
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"/>
587  </material>
588 
589 </materials>
590 EOF
591 
592 close(MAT);
593 }
594 
595 
596 
597 
598 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
599 #++++++++++++++++++++++++++++++++++++++++ gen_TPC ++++++++++++++++++++++++++++++++++++++++
600 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
601 
602 
603 sub gen_TPC()
604 {
605 
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
611 
612 
613 # Create the TPC fragment file name,
614 # add file to list of output GDML fragments,
615 # and open it
616  $TPC = "dune_10kT_TPC" . $suffix . ".gdml";
617  push (@gdmlFiles, $TPC);
618  $TPC = ">" . $TPC;
619  open(TPC) or die("Could not open file $TPC for writing");
620 
621 
622 # The standard XML prefix and starting the gdml
623  print TPC <<EOF;
624 <?xml version='1.0'?>
625 <gdml>
626 EOF
627 
628 
629 # All the TPC solids save the wires.
630 print TPC <<EOF;
631 <solids>
632  <box name="TPC" lunit="cm"
633  x="$TPC_x"
634  y="$TPC_y"
635  z="$TPC_z"/>
636  <box name="TPCPlane" lunit="cm"
637  x="$TPCWirePlane_x"
638  y="$TPCWirePlane_y"
639  z="$TPCWirePlane_z"/>
640  <box name="TPCActive" lunit="cm"
641  x="$TPCActive_x"
642  y="$TPCActive_y"
643  z="$TPCActive_z"/>
644 EOF
645 
646 
647 #++++++++++++++++++++++++++++ Wire Solids ++++++++++++++++++++++++++++++
648 
649 print TPC <<EOF;
650 
651  <tube name="TPCWireVert"
652  rmax="0.5*$TPCWireThickness"
653  z="$TPCWirePlane_z"
654  deltaphi="360"
655  aunit="deg"
656  lunit="cm"/>
657 EOF
658 
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
662 
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;
670 
671 if ($wires_on == 1)
672 {
673  # Number of wires in one corner
674  $NumberCornerUWires = int( $TPCWirePlane_y/$UWire_ypitch );
675  $NumberCornerVWires = int( $TPCWirePlane_y/$VWire_ypitch );
676 
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 );
681 
682  # Number of wires per side that aren't cut off by the corner
683  $NumberCommonUWires = $NumberSideUWires - $NumberCornerUWires;
684  $NumberCommonVWires = $NumberSideVWires - $NumberCornerVWires;
685 
686  # number of wires on the vertical plane
687  $NumberVerticalWires = int( ($TPCWirePlane_y-$TPCWireThickness)/$XWirePitch );
688 }
689 
690 # These XML comments throughout make the GDML file easier to navigate
691 print TPC <<EOF;
692 
693 <!--+++++++++++++++++++ U Wire Solids ++++++++++++++++++++++-->
694 
695 EOF
696 
697 # The corner wires for the U plane
698 if ($wires_on==1)
699 {
700  for ($i = 0; $i < $NumberCornerUWires; ++$i)
701  {
702 
703  $length = ($i+1)*$UWire_zpitch / $SinUAngle;
704 
705  print TPC <<EOF;
706  <tube name="TPCWireU$i"
707  rmax="0.5*$TPCWireThickness"
708  z="$length-0.06"
709  deltaphi="360"
710  aunit="deg"
711  lunit="cm"/>
712 EOF
713 
714  }
715 
716  print TPC <<EOF;
717  <tube name="TPCWireUCommon"
718  rmax="0.5*$TPCWireThickness"
719  z="$TPCWirePlane_y/$CosUAngle-0.06"
720  deltaphi="360"
721  aunit="deg"
722  lunit="cm"/>
723 EOF
724 
725 } else {
726 
727 print TPC <<EOF;
728 
729  <!-- This GDML version has no wires and uses much less memory -->
730 
731 EOF
732 
733 }
734 
735 print TPC <<EOF;
736 
737 
738 
739 
740 
741 
742 
743 
744 
745 <!--+++++++++++++++++++ V Wire Solids ++++++++++++++++++++++-->
746 
747 
748 EOF
749 
750 # The corner wires for the V plane
751 if ($wires_on==1)
752 {
753  for ($i = 0; $i < $NumberCornerVWires; ++$i)
754  {
755  $length = ($i+1)*$VWire_zpitch / $SinVAngle;
756 
757  print TPC <<EOF;
758 
759  <tube name="TPCWireV$i"
760  rmax="0.5*$TPCWireThickness"
761  z="$length-0.06"
762  deltaphi="360"
763  aunit="deg"
764  lunit="cm"/>
765 
766 EOF
767 
768  }
769 
770  # The wire used many times in the middle of the V plane
771  # Same subtraction as U common
772 
773  print TPC <<EOF;
774  <tube name="TPCWireVCommon"
775  rmax="0.5*$TPCWireThickness"
776  z="$TPCWirePlane_y/$CosVAngle-0.06"
777  deltaphi="360"
778  aunit="deg"
779  lunit="cm"/>
780 EOF
781 
782 } else {
783 
784 print TPC <<EOF;
785 
786 
787  <!-- no wires in this GDML -->
788 
789 EOF
790 
791 }
792 
793 
794 
795 # Begin structure and create the vertical wire logical volume
796 print TPC <<EOF;
797 </solids>
798 <structure>
799  <volume name="volTPCActive">
800  <materialref ref="LAr"/>
801  <solidref ref="TPCActive"/>
802  </volume>
803 
804 
805 
806 
807 
808 
809 
810 
811 
812 <!--+++++++++++++++++ Wire Logical Volumes ++++++++++++++++++++-->
813 
814 EOF
815 
816 
817 if ($wires_on==1)
818 {
819  print TPC <<EOF;
820  <volume name="volTPCWireVert">
821  <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni" />
822  <solidref ref="TPCWireVert" />
823  </volume>
824 EOF
825 
826  # Corner U wires logical volumes
827  for ($i = 0; $i < $NumberCornerUWires; ++$i)
828  {
829  print TPC <<EOF;
830  <volume name="volTPCWireU$i">
831  <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni" />
832  <solidref ref="TPCWireU$i" />
833  </volume>
834 EOF
835 
836  }
837 
838  # Common U wire logical volume, referenced many times
839  print TPC <<EOF;
840  <volume name="volTPCWireUCommon">
841  <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni" />
842  <solidref ref="TPCWireUCommon" />
843  </volume>
844 EOF
845 
846  # Corner V wires logical volumes
847  for ($i = 0; $i < $NumberCornerVWires; ++$i)
848  {
849  print TPC <<EOF;
850  <volume name="volTPCWireV$i">
851  <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni" />
852  <solidref ref="TPCWireV$i" />
853  </volume>
854 EOF
855 
856  }
857 
858  # Common V wire logical volume, referenced many times
859  print TPC <<EOF;
860  <volume name="volTPCWireVCommon">
861  <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni" />
862  <solidref ref="TPCWireVCommon" />
863  </volume>
864 EOF
865 
866 } else {
867 
868 
869 print TPC <<EOF;
870 
871  <!-- This GDML version has no wires and uses much less memory -->
872 
873 EOF
874 
875 }
876 
877 
878 
879 
880 #+++++++++++++++++++++++++ Position physical wires ++++++++++++++++++++++++++
881 
882 # ++++++++++++++++++++++ U Plane +++++++++++++++++++++++
883 
884 # Create U plane logical volume
885 print TPC <<EOF;
886 
887 
888 
889 
890 
891 
892 
893 <!--+++++++++++++++++++++ U Plane ++++++++++++++++++++++++-->
894 
895 
896  <volume name="volTPCPlaneU">
897  <materialref ref="LAr"/>
898  <solidref ref="TPCPlane"/>
899 EOF
900 
901 if ($wires_on==0)
902 {
903 print TPC <<EOF;
904 
905  <!-- no wires -->
906 
907 EOF
908 
909 } else {
910 
911 
912  for ($i = 0; $i < $NumberCornerUWires; ++$i)
913  {
914 
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;
918 
919 print TPC <<EOF;
920  <physvol>
921  <volumeref ref="volTPCWireU$i"/>
922  <position name="posTPCWireU$i" unit="cm" x="0" y="$ypos " z="$zpos"/>
923  <rotationref ref="rPlusUAngleAboutX"/>
924  </physvol>
925 EOF
926  }
927 
928 
929  for ($i = 0; $i < $NumberSideUWires-$NumberCornerUWires; ++$i)
930  {
931  my $zpos = $TPCWirePlane_z/2
932  - ($NumberCornerUWires*$UWire_zpitch)/2
933  - ($i+1)*$UWire_zpitch;
934 
935 print TPC <<EOF;
936  <physvol>
937  <volumeref ref="volTPCWireUCommon"/>
938  <position name="posTPCWireU$i" unit="cm" x="0" y="0 " z="$zpos"/>
939  <rotationref ref="rPlusUAngleAboutX"/>
940  </physvol>
941 EOF
942  }
943 
944 
945  for ($i = 0; $i < $NumberCornerUWires; ++$i)
946  {
947 
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;
951 
952 print TPC <<EOF;
953  <physvol>
954  <volumeref ref="volTPCWireU$i"/>
955  <position name="posTPCWireU$i" unit="cm" x="0" y="$ypos " z="$zpos"/>
956  <rotationref ref="rPlusUAngleAboutX"/>
957  </physvol>
958 EOF
959  }
960 
961 } #ends else
962 
963 
964 # ++++++++++++++++++++++ V Plane +++++++++++++++++++++++
965 
966 # End U plane and create V plane logical volume
967 print TPC <<EOF;
968  </volume>
969 
970 
971 
972 
973 
974 
975 
976 <!--+++++++++++++++++++++ V Plane ++++++++++++++++++++++++-->
977 
978 
979  <volume name="volTPCPlaneV">
980  <materialref ref="LAr"/>
981  <solidref ref="TPCPlane"/>
982 EOF
983 
984 if ($wires_on==0)
985 {
986 print TPC <<EOF;
987 
988  <!-- no wires -->
989 
990 EOF
991 
992 } else {
993 
994  for ($i = 0; $i < $NumberCornerVWires; ++$i)
995  {
996 
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;
1000 
1001 print TPC <<EOF;
1002  <physvol>
1003  <volumeref ref="volTPCWireV$i"/>
1004  <position name="posTPCWireV$i" unit="cm" x="0" y="$ypos " z="$zpos"/>
1005  <rotationref ref="rPlusVAngleAboutX"/>
1006  </physvol>
1007 EOF
1008  }
1009 
1010 
1011  for ($i = 0; $i < $NumberSideVWires-$NumberCornerVWires; ++$i)
1012  {
1013  my $zpos = $TPCWirePlane_z/2
1014  - ($NumberCornerVWires*$VWire_zpitch)/2
1015  - ($i+1)*$VWire_zpitch;
1016 
1017 print TPC <<EOF;
1018  <physvol>
1019  <volumeref ref="volTPCWireVCommon"/>
1020  <position name="posTPCWireV$i" unit="cm" x="0" y="0 " z="$zpos"/>
1021  <rotationref ref="rPlusVAngleAboutX"/>
1022  </physvol>
1023 EOF
1024  }
1025 
1026 
1027  for ($i = 0; $i < $NumberCornerVWires; ++$i)
1028  {
1029 
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;
1033 
1034 print TPC <<EOF;
1035  <physvol>
1036  <volumeref ref="volTPCWireV$i"/>
1037  <position name="posTPCWireV$i" unit="cm" x="0" y="$ypos " z="$zpos"/>
1038  <rotationref ref="rPlusVAngleAboutX"/>
1039  </physvol>
1040 EOF
1041  }
1042 
1043 
1044 } #ends else
1045 
1046 
1047 
1048 # ++++++++++++++++++++++ X Plane +++++++++++++++++++++++
1049 
1050 # End V plane and create X plane logical volume
1051 print TPC <<EOF;
1052  </volume>
1053 
1054 
1055 
1056 
1057 
1058 
1059 <!--+++++++++++++++++++++ X Plane ++++++++++++++++++++++++-->
1060 
1061 
1062  <volume name="volTPCPlaneX">
1063  <materialref ref="LAr"/>
1064  <solidref ref="TPCPlane"/>
1065 EOF
1066 
1067 if ($wires_on==0)
1068 {
1069 print TPC <<EOF;
1070 
1071  <!-- no wires -->
1072 
1073 EOF
1074 
1075 } else {
1076 
1077 
1078 for ($i=0; $i<$NumberVerticalWires; ++$i)
1079 {
1080 
1081 my $ypos = (-0.5*$TPCWirePlane_y)+$TPCWireThickness/2+$XWirePitch*($i+0.5);
1082 
1083 print TPC <<EOF;
1084  <physvol>
1085  <volumeref ref="volTPCWireVert"/>
1086  <position name="posTPCWireX$i" unit="cm" x="0" y="$ypos " z="0"/>
1087  <rotationref ref="rIdentity" />
1088  </physvol>
1089 EOF
1090 
1091 }
1092 
1093 } #ends else
1094 
1095 print TPC <<EOF;
1096  </volume>
1097 EOF
1098 
1099 #+++++++++++++++++++++ Position physical wires Above +++++++++++++++++++++
1100 
1101 #wrap up the TPC file
1102 print TPC <<EOF;
1103  <volume name="volTPC">
1104  <materialref ref="LAr" />
1105  <solidref ref="TPC" />
1106  <physvol>
1107  <volumeref ref="volTPCPlaneU" />
1108  <position name="posTPCPlaneU" unit="cm" x="(-$TPC_x/2)+3*$WirePlaneSpacing" y="0" z="0" />
1109  </physvol>
1110  <physvol>
1111  <volumeref ref="volTPCPlaneV" />
1112  <position name="posTPCPlaneV" unit="cm" x="(-$TPC_x/2)+2*$WirePlaneSpacing" y="0" z="0" />
1113  </physvol>
1114  <physvol>
1115  <volumeref ref="volTPCPlaneX" />
1116  <position name="posTPCPlaneX" unit="cm" x="(-$TPC_x/2)+$WirePlaneSpacing" y="0" z="0" />
1117  </physvol>
1118  <physvol>
1119  <volumeref ref="volTPCActive"/>
1120  <positionref ref="posActiveInTPC"/>
1121  </physvol>
1122  </volume>
1123 </structure>
1124 </gdml>
1125 EOF
1126 
1127  close(GDML);
1128 
1129 } #end of sub gen_TPC
1130 
1131 
1132 
1133 
1134 
1135 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1136 #++++++++++++++++++++++++++++++++++++++ gen_Cryostat +++++++++++++++++++++++++++++++++++++
1137 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1138 
1139 sub gen_Cryostat()
1140 {
1141 
1142 # Create the cryostat fragment file name,
1143 # add file to list of output GDML fragments,
1144 # and open it
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");
1149 
1150 
1151 # The standard XML prefix and starting the gdml
1152  print CRYO <<EOF;
1153 <?xml version='1.0'?>
1154 <gdml>
1155 EOF
1156 
1157 
1158 # All the cryostat solids.
1159 print CRYO <<EOF;
1160 <solids>
1161 
1162  <box name="Cryostat" lunit="cm"
1163  x="$Cryostat_x"
1164  y="$Cryostat_y"
1165  z="$Cryostat_z"/>
1166  <box name="ArgonInterior" lunit="cm"
1167  x="$LAr_x"
1168  y="$LAr_y"
1169  z="$LAr_z"/>
1170  <box name="GaseousArgon" lunit="cm"
1171  x="$LAr_x"
1172  y="$GaseousAr_y"
1173  z="$LAr_z"/>
1174  <subtraction name="SteelShell">
1175  <first ref="Cryostat"/>
1176  <second ref="ArgonInterior"/>
1177  </subtraction>
1178 
1179  <box name="Cathode" lunit="cm"
1180  x="$CPA_x"
1181  y="$TPC_y"
1182  z="$TPC_z"/>
1183 
1184 </solids>
1185 EOF
1186 
1187 # Cryostat structure
1188 print CRYO <<EOF;
1189 <structure>
1190  <volume name="volSteelShell">
1191  <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni" />
1192  <solidref ref="SteelShell" />
1193  </volume>
1194  <volume name="volGaseousArgon">
1195  <materialref ref="ArGas"/>
1196  <solidref ref="GaseousArgon"/>
1197  </volume>
1198 
1199  <volume name="volCathode">
1200  <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni" />
1201  <solidref ref="Cathode" />
1202  </volume>
1203 
1204 
1205  <volume name="volCryostat">
1206  <materialref ref="LAr" />
1207  <solidref ref="Cryostat" />
1208  <physvol>
1209  <volumeref ref="volGaseousArgon"/>
1210  <position name="posGaseousArgon" unit="cm" x="0" y="$LAr_y/2-$GaseousAr_y/2" z="0"/>
1211  </physvol>
1212  <physvol>
1213  <volumeref ref="volSteelShell"/>
1214  <position name="posSteelShell" unit="cm" x="0" y="0" z="0"/>
1215  </physvol>
1216 
1217  <physvol>
1218  <volumeref ref="volTPC"/>
1219  <positionref ref="posTPC0inCryo"/>
1220  <rotationref ref="rIdentity"/>
1221  </physvol>
1222  <physvol>
1223  <volumeref ref="volCathode" />
1224  <positionref ref="posRightCathode"/>
1225  </physvol>
1226  <physvol>
1227  <volumeref ref="volTPC"/>
1228  <positionref ref="posTPC1inCryo"/>
1229  <rotationref ref="rPlus180AboutY"/>
1230  </physvol>
1231 
1232  <physvol>
1233  <volumeref ref="volTPC"/>
1234  <positionref ref="posTPC2inCryo"/>
1235  <rotationref ref="rIdentity"/>
1236  </physvol>
1237  <physvol>
1238  <volumeref ref="volCathode" />
1239  <positionref ref="posLeftCathode"/>
1240  </physvol>
1241  <physvol>
1242  <volumeref ref="volTPC"/>
1243  <positionref ref="posTPC3inCryo"/>
1244  <rotationref ref="rPlus180AboutY"/>
1245  </physvol>
1246 
1247 EOF
1248 
1249 
1250 
1251 print CRYO <<EOF;
1252  </volume>
1253 </structure>
1254 </gdml>
1255 EOF
1256 
1257 close(CRYO);
1258 }
1259 
1260 
1261 
1262 
1263 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1264 #+++++++++++++++++++++++++++++++++++++ gen_Enclosure +++++++++++++++++++++++++++++++++++++
1265 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1266 
1267 sub gen_Enclosure()
1268 {
1269 
1270 # Create the detector enclosure fragment file name,
1271 # add file to list of output GDML fragments,
1272 # and open it
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");
1277 
1278 
1279 # The standard XML prefix and starting the gdml
1280  print ENCL <<EOF;
1281 <?xml version='1.0'?>
1282 <gdml>
1283 EOF
1284 
1285 
1286 # All the detector enclosure solids.
1287 print ENCL <<EOF;
1288 <solids>
1289 
1290  <box name="DetEnclosure" lunit="cm"
1291  x="$DetEnc_x"
1292  y="$DetEnc_y"
1293  z="$DetEnc_z"/>
1294 
1295 </solids>
1296 EOF
1297 
1298 
1299 
1300 # Detector enclosure structure
1301  print ENCL <<EOF;
1302 <structure>
1303 
1304  <volume name="volDetEnclosure">
1305  <materialref ref="Concrete"/>
1306  <solidref ref="DetEnclosure"/>
1307 
1308  <physvol>
1309  <volumeref ref="volCryostat"/>
1310  <positionref ref="posCryoInDetEnc"/>
1311  </physvol>
1312 
1313  </volume>
1314 EOF
1315 
1316 print ENCL <<EOF;
1317 </structure>
1318 </gdml>
1319 EOF
1320 
1321 close(ENCL);
1322 }
1323 
1324 
1325 
1326 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1327 #+++++++++++++++++++++++++++++++++++++++ gen_World +++++++++++++++++++++++++++++++++++++++
1328 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1329 
1330 sub gen_World()
1331 {
1332 
1333 # Create the WORLD fragment file name,
1334 # add file to list of output GDML fragments,
1335 # and open it
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");
1340 
1341 
1342 # The standard XML prefix and starting the gdml
1343  print WORLD <<EOF;
1344 <?xml version='1.0'?>
1345 <gdml>
1346 EOF
1347 
1348 
1349 # All the World solids.
1350 print WORLD <<EOF;
1351 <solids>
1352  <box name="World" lunit="cm"
1353  x="$World_x"
1354  y="$World_y"
1355  z="$World_z"/>
1356 </solids>
1357 EOF
1358 
1359 # World structure
1360 print WORLD <<EOF;
1361 <structure>
1362  <volume name="volWorld" >
1363  <materialref ref="Air"/>
1364  <solidref ref="World"/>
1365 
1366  <physvol>
1367  <volumeref ref="volDetEnclosure"/>
1368  <positionref ref="posDetEncInWorld"/>
1369  </physvol>
1370 
1371  </volume>
1372 </structure>
1373 </gdml>
1374 EOF
1375 
1376 # make_gdml.pl will take care of <setup/>
1377 
1378 close(WORLD);
1379 }
1380 
1381 
1382 
1383 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1384 #++++++++++++++++++++++++++++++++++++ write_fragments ++++++++++++++++++++++++++++++++++++
1385 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1386 
1387 sub write_fragments()
1388 {
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)
1393 
1394  # This code is taken straigh from the similar MicroBooNE generate script, Thank you.
1395 
1396  if ( ! defined $output )
1397  {
1398  $output = "-"; # write to STDOUT
1399  }
1400 
1401  # Set up the output file.
1402  $OUTPUT = ">" . $output;
1403  open(OUTPUT) or die("Could not open file $OUTPUT");
1404 
1405  print OUTPUT <<EOF;
1406 <?xml version='1.0'?>
1407 
1408 <!-- Input to Geometry/gdml/make_gdml.pl; define the GDML fragments
1409  that will be zipped together to create a detector description.
1410  -->
1411 
1412 <config>
1413 
1414  <constantfiles>
1415 
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
1419  more information.
1420  -->
1421 
1422 EOF
1423 
1424  foreach $filename (@defFiles)
1425  {
1426  print OUTPUT <<EOF;
1427  <filename> $filename </filename>
1428 EOF
1429  }
1430 
1431  print OUTPUT <<EOF;
1432 
1433  </constantfiles>
1434 
1435  <gdmlfiles>
1436 
1437  <!-- The GDML file fragments to be zipped together. -->
1438 
1439 EOF
1440 
1441  foreach $filename (@gdmlFiles)
1442  {
1443  print OUTPUT <<EOF;
1444  <filename> $filename </filename>
1445 EOF
1446  }
1447 
1448  print OUTPUT <<EOF;
1449 
1450  </gdmlfiles>
1451 
1452 </config>
1453 EOF
1454 
1455  close(OUTPUT);
1456 }