1 | // |
---|
2 | // ******************************************************************** |
---|
3 | // * License and Disclaimer * |
---|
4 | // * * |
---|
5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
7 | // * conditions of the Geant4 Software License, included in the file * |
---|
8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
9 | // * include a list of copyright holders. * |
---|
10 | // * * |
---|
11 | // * Neither the authors of this software system, nor their employing * |
---|
12 | // * institutes,nor the agencies providing financial support for this * |
---|
13 | // * work make any representation or warranty, express or implied, * |
---|
14 | // * regarding this software system or assume any liability for its * |
---|
15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
16 | // * for the full disclaimer and the limitation of liability. * |
---|
17 | // * * |
---|
18 | // * This code implementation is the result of the scientific and * |
---|
19 | // * technical work of the GEANT4 collaboration. * |
---|
20 | // * By using, copying, modifying or distributing the software (or * |
---|
21 | // * any work based on the software) you agree to acknowledge its * |
---|
22 | // * use in resulting scientific publications, and indicate your * |
---|
23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
24 | // ******************************************************************** |
---|
25 | // |
---|
26 | // |
---|
27 | // $Id: F02DetectorConstruction.cc,v 1.13 2009/11/05 01:08:51 gum Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-03-cand-01 $ |
---|
29 | // |
---|
30 | // |
---|
31 | |
---|
32 | #include "F02DetectorConstruction.hh" |
---|
33 | #include "F02DetectorMessenger.hh" |
---|
34 | |
---|
35 | #include "F02CalorimeterSD.hh" |
---|
36 | #include "F02ElectricFieldSetup.hh" |
---|
37 | |
---|
38 | |
---|
39 | #include "G4Material.hh" |
---|
40 | #include "G4Tubs.hh" |
---|
41 | #include "G4LogicalVolume.hh" |
---|
42 | #include "G4PVPlacement.hh" |
---|
43 | #include "G4UniformMagField.hh" |
---|
44 | #include "G4FieldManager.hh" |
---|
45 | #include "G4TransportationManager.hh" |
---|
46 | #include "G4SDManager.hh" |
---|
47 | #include "G4RunManager.hh" |
---|
48 | |
---|
49 | #include "G4GeometryManager.hh" |
---|
50 | #include "G4PhysicalVolumeStore.hh" |
---|
51 | #include "G4LogicalVolumeStore.hh" |
---|
52 | #include "G4SolidStore.hh" |
---|
53 | |
---|
54 | #include "G4ios.hh" |
---|
55 | |
---|
56 | ///////////////////////////////////////////////////////////////////////////// |
---|
57 | // |
---|
58 | // |
---|
59 | |
---|
60 | F02DetectorConstruction::F02DetectorConstruction() |
---|
61 | : solidWorld(0), logicWorld(0), physiWorld(0), |
---|
62 | solidAbsorber(0),logicAbsorber(0), physiAbsorber(0), |
---|
63 | fEmFieldSetup(0), calorimeterSD(0), |
---|
64 | AbsorberMaterial(0), worldchanged(false), WorldMaterial(0) |
---|
65 | { |
---|
66 | // default parameter values of the calorimeter |
---|
67 | |
---|
68 | WorldSizeZ = 80.*cm; |
---|
69 | WorldSizeR = 20.*cm; |
---|
70 | |
---|
71 | AbsorberThickness = 40.0*mm; |
---|
72 | |
---|
73 | AbsorberRadius = 10.*cm; |
---|
74 | zAbsorber = 36.*cm ; |
---|
75 | |
---|
76 | // create commands for interactive definition of the calorimeter |
---|
77 | |
---|
78 | detectorMessenger = new F02DetectorMessenger(this); |
---|
79 | |
---|
80 | DefineMaterials(); |
---|
81 | |
---|
82 | fEmFieldSetup = new F02ElectricFieldSetup() ; |
---|
83 | } |
---|
84 | |
---|
85 | ////////////////////////////////////////////////////////////////////////// |
---|
86 | // |
---|
87 | // |
---|
88 | |
---|
89 | F02DetectorConstruction::~F02DetectorConstruction() |
---|
90 | { |
---|
91 | delete detectorMessenger; |
---|
92 | delete fEmFieldSetup ; |
---|
93 | } |
---|
94 | |
---|
95 | ////////////////////////////////////////////////////////////////////////// |
---|
96 | // |
---|
97 | // |
---|
98 | |
---|
99 | G4VPhysicalVolume* F02DetectorConstruction::Construct() |
---|
100 | { |
---|
101 | return ConstructCalorimeter(); |
---|
102 | } |
---|
103 | |
---|
104 | ////////////////////////////////////////////////////////////////////////////// |
---|
105 | // |
---|
106 | // |
---|
107 | |
---|
108 | void F02DetectorConstruction::DefineMaterials() |
---|
109 | { |
---|
110 | //This function illustrates the possible ways to define materials |
---|
111 | |
---|
112 | G4String name, symbol ; // a=mass of a mole; |
---|
113 | G4double a, z, density ; // z=mean number of protons; |
---|
114 | G4int nel; |
---|
115 | G4int ncomponents; |
---|
116 | G4double fractionmass, pressure, temperature; |
---|
117 | |
---|
118 | // |
---|
119 | // define Elements |
---|
120 | // |
---|
121 | |
---|
122 | a = 1.01*g/mole; |
---|
123 | G4Element* elH = new G4Element(name="Hydrogen",symbol="H" , z= 1., a); |
---|
124 | |
---|
125 | a = 12.01*g/mole; |
---|
126 | G4Element* elC = new G4Element(name="Carbon", symbol="C", z=6., a); |
---|
127 | |
---|
128 | a = 14.01*g/mole; |
---|
129 | G4Element* elN = new G4Element(name="Nitrogen",symbol="N" , z= 7., a); |
---|
130 | |
---|
131 | a = 16.00*g/mole; |
---|
132 | G4Element* elO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a); |
---|
133 | |
---|
134 | a = 39.948*g/mole; |
---|
135 | G4Element* elAr = new G4Element(name="Argon", symbol="Ar", z=18., a); |
---|
136 | |
---|
137 | // |
---|
138 | // define simple materials |
---|
139 | // |
---|
140 | |
---|
141 | // Mylar |
---|
142 | |
---|
143 | density = 1.39*g/cm3; |
---|
144 | G4Material* Mylar = new G4Material(name="Mylar", density, nel=3); |
---|
145 | Mylar->AddElement(elO,2); |
---|
146 | Mylar->AddElement(elC,5); |
---|
147 | Mylar->AddElement(elH,4); |
---|
148 | |
---|
149 | // Polypropelene |
---|
150 | |
---|
151 | G4Material* CH2 = new G4Material ("Polypropelene" , 0.91*g/cm3, 2); |
---|
152 | CH2->AddElement(elH,2); |
---|
153 | CH2->AddElement(elC,1); |
---|
154 | |
---|
155 | // Krypton as detector gas, STP |
---|
156 | |
---|
157 | density = 3.700*mg/cm3 ; |
---|
158 | a = 83.80*g/mole ; |
---|
159 | G4Material* Kr = new G4Material(name="Kr",z=36., a, density ); |
---|
160 | |
---|
161 | // Dry air (average composition) |
---|
162 | |
---|
163 | density = 1.7836*mg/cm3 ; // STP |
---|
164 | G4Material* Argon = new G4Material(name="Argon" , density, ncomponents=1); |
---|
165 | Argon->AddElement(elAr, 1); |
---|
166 | |
---|
167 | density = 1.25053*mg/cm3 ; // STP |
---|
168 | G4Material* Nitrogen = new G4Material(name="N2" , density, ncomponents=1); |
---|
169 | Nitrogen->AddElement(elN, 2); |
---|
170 | |
---|
171 | density = 1.4289*mg/cm3 ; // STP |
---|
172 | G4Material* Oxygen = new G4Material(name="O2" , density, ncomponents=1); |
---|
173 | Oxygen->AddElement(elO, 2); |
---|
174 | |
---|
175 | |
---|
176 | density = 1.2928*mg/cm3 ; // STP |
---|
177 | |
---|
178 | temperature = STP_Temperature; |
---|
179 | pressure = 1.0e-0*STP_Pressure; |
---|
180 | |
---|
181 | G4Material* Air = new G4Material(name="Air" , density, ncomponents=3, |
---|
182 | kStateGas,temperature,pressure); |
---|
183 | Air->AddMaterial( Nitrogen, fractionmass = 0.7557 ) ; |
---|
184 | Air->AddMaterial( Oxygen, fractionmass = 0.2315 ) ; |
---|
185 | Air->AddMaterial( Argon, fractionmass = 0.0128 ) ; |
---|
186 | |
---|
187 | // Xenon as detector gas, STP |
---|
188 | |
---|
189 | density = 5.858*mg/cm3 ; |
---|
190 | a = 131.29*g/mole ; |
---|
191 | G4Material* Xe = new G4Material(name="Xenon",z=54., a, density ); |
---|
192 | |
---|
193 | // Carbon dioxide, STP |
---|
194 | |
---|
195 | density = 1.842*mg/cm3; |
---|
196 | G4Material* CarbonDioxide = new G4Material(name="CO2", density, nel=2); |
---|
197 | CarbonDioxide->AddElement(elC,1); |
---|
198 | CarbonDioxide->AddElement(elO,2); |
---|
199 | |
---|
200 | // 80% Xe + 20% CO2, STP |
---|
201 | |
---|
202 | density = 5.0818*mg/cm3 ; |
---|
203 | G4Material* Xe20CO2 = new G4Material(name="Xe20CO2" , density, ncomponents=2); |
---|
204 | Xe20CO2->AddMaterial( Xe, fractionmass = 0.922 ) ; |
---|
205 | Xe20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.078 ) ; |
---|
206 | |
---|
207 | // 80% Kr + 20% CO2, STP |
---|
208 | |
---|
209 | density = 3.601*mg/cm3 ; |
---|
210 | G4Material* Kr20CO2 = new G4Material(name="Kr20CO2" , density, |
---|
211 | ncomponents=2); |
---|
212 | Kr20CO2->AddMaterial( Kr, fractionmass = 0.89 ) ; |
---|
213 | Kr20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.11 ) ; |
---|
214 | |
---|
215 | |
---|
216 | G4cout << *(G4Material::GetMaterialTable()) << G4endl; |
---|
217 | |
---|
218 | AbsorberMaterial = Kr20CO2 ; // XeCO2CF4 ; |
---|
219 | |
---|
220 | WorldMaterial = Air ; |
---|
221 | } |
---|
222 | |
---|
223 | ///////////////////////////////////////////////////////////////////////// |
---|
224 | // |
---|
225 | // |
---|
226 | |
---|
227 | G4VPhysicalVolume* F02DetectorConstruction::ConstructCalorimeter() |
---|
228 | { |
---|
229 | // complete the Calor parameters definition and Print |
---|
230 | |
---|
231 | ComputeCalorParameters(); |
---|
232 | PrintCalorParameters(); |
---|
233 | |
---|
234 | // Cleanup old geometry |
---|
235 | |
---|
236 | if (physiWorld) |
---|
237 | { |
---|
238 | G4GeometryManager::GetInstance()->OpenGeometry(); |
---|
239 | G4PhysicalVolumeStore::GetInstance()->Clean(); |
---|
240 | G4LogicalVolumeStore::GetInstance()->Clean(); |
---|
241 | G4SolidStore::GetInstance()->Clean(); |
---|
242 | } |
---|
243 | |
---|
244 | // World |
---|
245 | |
---|
246 | solidWorld = new G4Tubs("World", //its name |
---|
247 | 0.,WorldSizeR,WorldSizeZ/2.,0.,twopi); //its size |
---|
248 | |
---|
249 | logicWorld = new G4LogicalVolume(solidWorld, //its solid |
---|
250 | WorldMaterial, //its material |
---|
251 | "World"); //its name |
---|
252 | |
---|
253 | physiWorld = new G4PVPlacement(0, //no rotation |
---|
254 | G4ThreeVector(), //at (0,0,0) |
---|
255 | "World", //its name |
---|
256 | logicWorld, //its logical volume |
---|
257 | 0, //its mother volume |
---|
258 | false, //no boolean operation |
---|
259 | 0); //copy number |
---|
260 | // Absorber |
---|
261 | |
---|
262 | if (AbsorberThickness > 0.) |
---|
263 | { |
---|
264 | solidAbsorber = new G4Tubs("Absorber", |
---|
265 | 0.,AbsorberRadius,AbsorberThickness/2.,0.,twopi); |
---|
266 | |
---|
267 | logicAbsorber = new G4LogicalVolume(solidAbsorber, |
---|
268 | AbsorberMaterial, |
---|
269 | "Absorber"); |
---|
270 | |
---|
271 | physiAbsorber = new G4PVPlacement(0, |
---|
272 | G4ThreeVector(0.,0.,zAbsorber), |
---|
273 | "Absorber", |
---|
274 | logicAbsorber, |
---|
275 | physiWorld, |
---|
276 | false, |
---|
277 | 0); |
---|
278 | } |
---|
279 | |
---|
280 | // Sensitive Detectors: Absorber |
---|
281 | |
---|
282 | G4SDManager* SDman = G4SDManager::GetSDMpointer(); |
---|
283 | |
---|
284 | if(!calorimeterSD) |
---|
285 | { |
---|
286 | calorimeterSD = new F02CalorimeterSD("CalorSD",this); |
---|
287 | SDman->AddNewDetector( calorimeterSD ); |
---|
288 | } |
---|
289 | if (logicAbsorber) logicAbsorber->SetSensitiveDetector(calorimeterSD); |
---|
290 | |
---|
291 | return physiWorld; |
---|
292 | } |
---|
293 | |
---|
294 | //////////////////////////////////////////////////////////////////////////// |
---|
295 | // |
---|
296 | // |
---|
297 | |
---|
298 | void F02DetectorConstruction::PrintCalorParameters() |
---|
299 | { |
---|
300 | G4cout << "\n The WORLD is made of " |
---|
301 | << WorldSizeZ/mm << "mm of " << WorldMaterial->GetName() ; |
---|
302 | G4cout << ", the transverse size (R) of the world is " << WorldSizeR/mm << " mm. " << G4endl; |
---|
303 | G4cout << " The ABSORBER is made of " |
---|
304 | << AbsorberThickness/mm << "mm of " << AbsorberMaterial->GetName() ; |
---|
305 | G4cout << ", the transverse size (R) is " << AbsorberRadius/mm << " mm. " << G4endl; |
---|
306 | G4cout << " Z position of the (middle of the) absorber " << zAbsorber/mm << " mm." << G4endl; |
---|
307 | G4cout << G4endl; |
---|
308 | } |
---|
309 | |
---|
310 | /////////////////////////////////////////////////////////////////////////// |
---|
311 | // |
---|
312 | // |
---|
313 | |
---|
314 | void F02DetectorConstruction::SetAbsorberMaterial(G4String materialChoice) |
---|
315 | { |
---|
316 | // get the pointer to the material table |
---|
317 | const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable(); |
---|
318 | |
---|
319 | // search the material by its name |
---|
320 | G4Material* pttoMaterial; |
---|
321 | for (size_t J=0 ; J<theMaterialTable->size() ; J++) |
---|
322 | { pttoMaterial = (*theMaterialTable)[J]; |
---|
323 | if(pttoMaterial->GetName() == materialChoice) |
---|
324 | { |
---|
325 | AbsorberMaterial = pttoMaterial; |
---|
326 | logicAbsorber->SetMaterial(pttoMaterial); |
---|
327 | } |
---|
328 | } |
---|
329 | } |
---|
330 | |
---|
331 | //////////////////////////////////////////////////////////////////////////// |
---|
332 | // |
---|
333 | // |
---|
334 | |
---|
335 | void F02DetectorConstruction::SetWorldMaterial(G4String materialChoice) |
---|
336 | { |
---|
337 | // get the pointer to the material table |
---|
338 | const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable(); |
---|
339 | |
---|
340 | // search the material by its name |
---|
341 | G4Material* pttoMaterial; |
---|
342 | for (size_t J=0 ; J<theMaterialTable->size() ; J++) |
---|
343 | { pttoMaterial = (*theMaterialTable)[J]; |
---|
344 | if(pttoMaterial->GetName() == materialChoice) |
---|
345 | { |
---|
346 | WorldMaterial = pttoMaterial; |
---|
347 | logicWorld->SetMaterial(pttoMaterial); |
---|
348 | } |
---|
349 | } |
---|
350 | } |
---|
351 | |
---|
352 | /////////////////////////////////////////////////////////////////////////// |
---|
353 | // |
---|
354 | // |
---|
355 | |
---|
356 | void F02DetectorConstruction::SetAbsorberThickness(G4double val) |
---|
357 | { |
---|
358 | // change Absorber thickness and recompute the calorimeter parameters |
---|
359 | AbsorberThickness = val; |
---|
360 | ComputeCalorParameters(); |
---|
361 | } |
---|
362 | |
---|
363 | ///////////////////////////////////////////////////////////////////////////// |
---|
364 | // |
---|
365 | // |
---|
366 | |
---|
367 | void F02DetectorConstruction::SetAbsorberRadius(G4double val) |
---|
368 | { |
---|
369 | // change the transverse size and recompute the calorimeter parameters |
---|
370 | AbsorberRadius = val; |
---|
371 | ComputeCalorParameters(); |
---|
372 | } |
---|
373 | |
---|
374 | //////////////////////////////////////////////////////////////////////////// |
---|
375 | // |
---|
376 | // |
---|
377 | |
---|
378 | void F02DetectorConstruction::SetWorldSizeZ(G4double val) |
---|
379 | { |
---|
380 | worldchanged=true; |
---|
381 | WorldSizeZ = val; |
---|
382 | ComputeCalorParameters(); |
---|
383 | } |
---|
384 | |
---|
385 | /////////////////////////////////////////////////////////////////////////// |
---|
386 | // |
---|
387 | // |
---|
388 | |
---|
389 | void F02DetectorConstruction::SetWorldSizeR(G4double val) |
---|
390 | { |
---|
391 | worldchanged=true; |
---|
392 | WorldSizeR = val; |
---|
393 | ComputeCalorParameters(); |
---|
394 | } |
---|
395 | |
---|
396 | ////////////////////////////////////////////////////////////////////////////// |
---|
397 | // |
---|
398 | // |
---|
399 | |
---|
400 | void F02DetectorConstruction::SetAbsorberZpos(G4double val) |
---|
401 | { |
---|
402 | zAbsorber = val; |
---|
403 | ComputeCalorParameters(); |
---|
404 | } |
---|
405 | |
---|
406 | |
---|
407 | //////////////////////////////////////////////////////////////////////////// |
---|
408 | // |
---|
409 | // |
---|
410 | |
---|
411 | void F02DetectorConstruction::UpdateGeometry() |
---|
412 | { |
---|
413 | G4RunManager::GetRunManager()->DefineWorldVolume(ConstructCalorimeter()); |
---|
414 | } |
---|
415 | |
---|
416 | // |
---|
417 | // |
---|
418 | //////////////////////////////////////////////////////////////////////////// |
---|