generate_voltpc.pl
Go to the documentation of this file.
1 #!/usr/bin/perl
2 
3 use Math::Trig;
4 use XML::LibXML;
5 use Getopt::Long;
6 
7 
8 #Specific H,W,L of volTPC
9 $CryostatWidth=200;
10 $CryostatHeight=200;
11 $CryostatLength=1000;
12 
13 #detector variables
14 $SteelThickness=0.5*2.54;
15 $ArgonWidth=$CryostatWidth-2*$SteelThickness;
16 $ArgonHeight=$CryostatHeight-2*$SteelThickness;
17 $ArgonLength=$CryostatLength-2*$SteelThickness;
18 $RockThickness=200;
19 $ConcretePadding=50;
20 $GlassFoamPadding=100;
21 $TotalPadding=$ConcretePadding+$GlassFoamPadding+$SteelThickness;
22 $CavernWidth=$ArgonWidth+2*$TotalPadding;
23 $CavernHeight=$ArgonHeight+$TotalPadding;
24 $CavernLength=$ArgonLength+2*$TotalPadding;
25 $TPCWidth=$CryostatWidth;
26 $TPCHeight=$CryostatHeight;
27 $TPCLength=$CryostatLength;
28 $TPCWireThickness=0.015;
29 
30 
31 gen_header();
32 gen_materials();
33 gen_voltpc();
34 exit;
35 
36 
37 
38 
39 
40 
41 sub gen_voltpc()
42 {
43  # Set up the output file.
44  $volTPC = "voltpc.gdml";
45  $volTPC = ">>" . $volTPC;
46  open(volTPC) or die("Could not open file $volTPC for writing");
47 
48  print volTPC <<EOF;
49  <solids>
50  <box name="World" lunit="cm"
51  x="5*$CryostatWidth"
52  y="5*$CryostatHeight"
53  z="5*$CryostatLength"/>
54  <box name="DetEnclosure" lunit="cm"
55  x="$CryostatWidth+10"
56  y="$CryostatHeight+10"
57  z="$CryostatLength+10"/>
58  <box name="Cryostat" lunit="cm"
59  x="$CryostatWidth"
60  y="$CryostatHeight"
61  z="$CryostatLength"/>
62  <box name="TPC" lunit="cm"
63  x="$TPCWidth"
64  y="$TPCHeight"
65  z="$TPCLength"/>
66  <box name="TPCPlane" lunit="cm"
67  x="0.1"
68  y="0.9*$TPCHeight"
69  z="0.9*$TPCLength"/>
70  <tube name="TPCWire"
71  rmax="0.5*$TPCWireThickness"
72  z="0.89*$TPCHeight"
73  deltaphi="2*3.14159"
74  aunit="rad"
75  lunit="cm"/>
76 
77  </solids>
78  <structure>
79  <volume name="volTPCWire">
80  <materialref ref="STEEL_STAINLESS_Fe7Cr2Ni" />
81  <solidref ref="TPCWire" />
82  </volume>
83  <volume name="volTPCPlane">
84  <materialref ref="LAr"/>
85  <solidref ref="TPCPlane"/>
86 EOF
87 
88 for ( $i=-0.3*$TPCLength ; $i < 0.3*$TPCLength ; $i+=100 ) {
89  $wire_zpos=$i;
90  print volTPC <<EOF;
91  <physvol>
92  <volumeref ref="volTPCWire"/>
93  <position name="posTPCWire$i" unit="cm" x="0" y="0" z="$wire_zpos"/>
94  <rotation name="rTPCWire$i" unit="deg" x="60" y="0" z="0"/>
95  </physvol>
96 EOF
97 }
98  print volTPC <<EOF;
99  </volume>
100  <volume name="volTPC">
101  <materialref ref="LAr" />
102  <solidref ref="TPC" />
103  <physvol>
104  <volumeref ref="volTPCPlane"/>
105  <position name="posTPCPlane1" unit="cm" x="-0.45*$TPCWidth" y="0" z="0"/>
106  </physvol>
107  <physvol>
108  <volumeref ref="volTPCPlane"/>
109  <position name="posTPCPlane2" unit="cm" x="-0.475*$TPCWidth" y="0" z="0"/>
110  <rotation name="rTPCPlane2" unit="deg" x="0" y="180" z="0"/>
111  </physvol>
112  </volume>
113  <volume name="volCryostat">
114  <materialref ref="LAr" />
115  <solidref ref="Cryostat" />
116  <physvol>
117  <volumeref ref="volTPC"/>
118  <position name="posTPC" unit="cm" x="0" y="0" z="0"/>
119  </physvol>
120  </volume>
121  <volume name="volDetEnclosure">
122  <materialref ref="Air"/>
123  <solidref ref="DetEnclosure"/>
124  <physvol>
125  <volumeref ref="volCryostat"/>
126  <position name="posCryostat" unit="cm" x="0" y="0" z="0"/>
127  </physvol>
128  </volume>
129  <volume name="volWorld" >
130  <materialref ref="Air"/>
131  <solidref ref="World"/>
132  <physvol>
133  <volumeref ref="volDetEnclosure"/>
134  <position name="posDetEnclosure" unit="cm" x="0.5*$TPCWidth" y="0" z="0.5*$TPCLength"/>
135  </physvol>
136  </volume>
137  </structure>
138 
139  <setup name="Default" version="1.0">
140  <world ref="volWorld" />
141  </setup>
142 </gdml>
143 EOF
144  close(volTPC);
145 }
146 
147 
148 #generates necessary gd/xml header
149 sub gen_header()
150 {
151 
152  $volTPC = "voltpc.gdml";
153  $volTPC = ">" . $volTPC;
154  open(volTPC) or die("Could not open file $volTPC for writing");
155  print volTPC <<EOF;
156 <?xml version="1.0" encoding="UTF-8" ?>
157 <gdml xmlns:gdml="http://cern.ch/2001/Schemas/GDML"
158  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
159  xsi:noNamespaceSchemaLocation="GDMLSchema/gdml.xsd">
160 EOF
161 }
162 
163 
164 sub gen_materials()
165 {
166 
167 
168  $volTPC = "voltpc.gdml";
169  $volTPC = ">>" . $volTPC;
170  open(volTPC) or die("Could not open file $volTPC for writing");
171  print volTPC <<EOF;
172  <materials>
173  <element name="videRef" formula="VACUUM" Z="1"> <atom value="1"/> </element>
174  <element name="hydrogen" formula="H" Z="1"> <atom value="1.0079"/> </element>
175  <element name="nitrogen" formula="N" Z="7"> <atom value="14.0067"/> </element>
176  <element name="oxygen" formula="O" Z="8"> <atom value="15.999"/> </element>
177  <element name="aluminum" formula="Al" Z="13"> <atom value="26.9815"/> </element>
178  <element name="silicon" formula="Si" Z="14"> <atom value="28.0855"/> </element>
179  <element name="carbon" formula="C" Z="6"> <atom value="12.0107"/> </element>
180  <element name="potassium" formula="K" Z="19"> <atom value="39.0983"/> </element>
181  <element name="chromium" formula="Cr" Z="24"> <atom value="51.9961"/> </element>
182  <element name="iron" formula="Fe" Z="26"> <atom value="55.8450"/> </element>
183  <element name="nickel" formula="Ni" Z="28"> <atom value="58.6934"/> </element>
184  <element name="calcium" formula="Ca" Z="20"> <atom value="40.078"/> </element>
185  <element name="sodium" formula="Na" Z="11"> <atom value="22.99"/> </element>
186  <element name="argon" formula="Ar" Z="18"> <atom value="39.9480"/> </element>
187 
188  <material name="Vacuum" formula="Vacuum">
189  <D value="1.e-25" unit="g/cm3"/>
190  <fraction n="1.0" ref="videRef"/>
191  </material>
192 
193  <material name="STEEL_STAINLESS_Fe7Cr2Ni" formula="STEEL_STAINLESS_Fe7Cr2Ni">
194  <D value="7.9300" unit="g/cm3"/>
195  <fraction n="0.0010" ref="carbon"/>
196  <fraction n="0.1800" ref="chromium"/>
197  <fraction n="0.7298" ref="iron"/>
198  <fraction n="0.0900" ref="nickel"/>
199  </material>
200 
201  <material name="LAr" formula="LAr">
202  <D value="1.40" unit="g/cm3"/>
203  <fraction n="1.0000" ref="argon"/>
204  </material>
205 
206  <material formula=" " name="Air">
207  <D value="0.001205" unit="g/cm3"/>
208  <fraction n="0.78084" ref="nitrogen"/>
209  <fraction n="0.209476" ref="oxygen"/>
210  <fraction n="0.00934" ref="argon"/>
211  </material>
212 
213  <material formula=" " name="Granite">
214  <D value="2.7" unit="g/cm3"/>
215  <fraction n="0.438" ref="oxygen"/>
216  <fraction n="0.257" ref="silicon"/>
217  <fraction n="0.222" ref="sodium"/>
218  <fraction n="0.049" ref="aluminum"/>
219  <fraction n="0.019" ref="iron"/>
220  <fraction n="0.015" ref="potassium"/>
221  </material>
222 
223  <material formula=" " name="Dirt">
224  <D value="1.7" unit="g/cm3"/>
225  <fraction n="0.438" ref="oxygen"/>
226  <fraction n="0.257" ref="silicon"/>
227  <fraction n="0.222" ref="sodium"/>
228  <fraction n="0.049" ref="aluminum"/>
229  <fraction n="0.019" ref="iron"/>
230  <fraction n="0.015" ref="potassium"/>
231  </material>
232 
233  <material formula=" " name="Concrete">
234  <D value="2.3" unit="g/cm3"/>
235  <fraction n="0.530" ref="oxygen"/>
236  <fraction n="0.335" ref="silicon"/>
237  <fraction n="0.060" ref="calcium"/>
238  <fraction n="0.015" ref="sodium"/>
239  <fraction n="0.020" ref="iron"/>
240  <fraction n="0.040" ref="aluminum"/>
241  </material>
242  </materials>
243 EOF
244 }
245