Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
F01DetectorConstruction.cc
Go to the documentation of this file.
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 //
28 //
29 //
30 // $Id$
31 //
32 //
33 
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
36 
38 #include "F01DetectorMessenger.hh"
39 
40 #include "F01CalorimeterSD.hh"
41 #include "F01FieldSetup.hh"
42 
43 #include "G4Material.hh"
44 #include "G4Tubs.hh"
45 #include "G4LogicalVolume.hh"
46 #include "G4PVPlacement.hh"
47 #include "G4UniformMagField.hh"
48 #include "G4FieldManager.hh"
50 #include "G4SDManager.hh"
51 #include "G4RunManager.hh"
52 
53 #include "G4GeometryManager.hh"
54 #include "G4PhysicalVolumeStore.hh"
55 #include "G4LogicalVolumeStore.hh"
56 #include "G4SolidStore.hh"
57 
58 #include "G4PhysicalConstants.hh"
59 #include "G4SystemOfUnits.hh"
60 #include "G4ios.hh"
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
63 
65  : fSolidWorld(0), fLogicWorld(0), fPhysiWorld(0),
66  fSolidAbsorber(0),fLogicAbsorber(0), fPhysiAbsorber(0),
67  fEmFieldSetup(0), fDetectorMessenger(0), fCalorimeterSD(0),
68  fAbsorberMaterial(0), fAbsorberThickness(0.),fAbsorberRadius(0.),
69  fWorldChanged(false), fZAbsorber(0.), fZStartAbs(0.), fZEndAbs(0.),
70  fWorldMaterial(0), fWorldSizeR(0.), fWorldSizeZ(0.)
71 {
72  // default parameter values of the calorimeter
73 
74  fWorldSizeZ = 44000.*mm;
75  fWorldSizeR = 22000.*mm;
76 
77  fAbsorberThickness = 1.0*mm;
78 
79  fAbsorberRadius = 20000.*mm;
80 
81  fZAbsorber = 21990.0*mm ;
82 
83  // create commands for interactive definition of the calorimeter
84 
85  fDetectorMessenger = new F01DetectorMessenger(this);
86 
87  // create materials
88 
89  DefineMaterials();
90 
91 }
92 
93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
94 
96 {
97  delete fDetectorMessenger;
98  if (fEmFieldSetup) delete fEmFieldSetup;
99 }
100 
101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
102 
104 {
105  G4VPhysicalVolume* calorWorld= ConstructCalorimeter();
106 
107  // Construct the field creator - this will register the field it creates
108  fEmFieldSetup = new F01FieldSetup(G4ThreeVector( 3.3*tesla, 0.0, 0.0 ) ) ;
109  return calorWorld;
110 }
111 
112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
113 
114 void F01DetectorConstruction::DefineMaterials()
115 {
116  //This function illustrates the possible ways to define materials
117 
118  G4String name, symbol ; // a=mass of a mole;
119  G4double a, z, density ; // z=mean number of protons;
120  G4int nel ;
121  G4int ncomponents;
122  G4double fractionmass, pressure, temperature;
123 
124  //
125  // define Elements
126  //
127 
128  a = 1.01*g/mole;
129  G4Element* elH = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);
130 
131  a = 12.01*g/mole;
132  G4Element* elC = new G4Element(name="Carbon", symbol="C", z=6., a);
133 
134  a = 14.01*g/mole;
135  G4Element* elN = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);
136 
137  a = 16.00*g/mole;
138  G4Element* elO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a);
139 
140  a = 39.948*g/mole;
141  G4Element* elAr = new G4Element(name="Argon", symbol="Ar", z=18., a);
142 
143  //
144  // define simple materials
145  //
146 
147  // Mylar
148 
149  density = 1.39*g/cm3;
150  G4Material* Mylar = new G4Material(name="Mylar", density, nel=3);
151  Mylar->AddElement(elO,2);
152  Mylar->AddElement(elC,5);
153  Mylar->AddElement(elH,4);
154 
155  // Polypropelene
156 
157  G4Material* CH2 = new G4Material ("Polypropelene" , 0.91*g/cm3, 2);
158  CH2->AddElement(elH,2);
159  CH2->AddElement(elC,1);
160 
161  // Krypton as detector gas, STP
162 
163  density = 3.700*mg/cm3 ;
164  a = 83.80*g/mole ;
165  G4Material* Kr = new G4Material(name="Kr",z=36., a, density );
166 
167  // Dry air (average composition)
168 
169  density = 1.7836*mg/cm3 ; // STP
170  G4Material* Argon = new G4Material(name="Argon" , density, ncomponents=1);
171  Argon->AddElement(elAr, 1);
172 
173  density = 1.25053*mg/cm3 ; // STP
174  G4Material* Nitrogen = new G4Material(name="N2" , density, ncomponents=1);
175  Nitrogen->AddElement(elN, 2);
176 
177  density = 1.4289*mg/cm3 ; // STP
178  G4Material* Oxygen = new G4Material(name="O2" , density, ncomponents=1);
179  Oxygen->AddElement(elO, 2);
180 
181  density = 1.2928*mg/cm3 ; // STP
182  density *= 1.0e-8 ; // pumped vacuum
183 
184  temperature = STP_Temperature;
185  pressure = 1.0e-8*STP_Pressure;
186 
187  G4Material* Air = new G4Material(name="Air" , density, ncomponents=3,
188  kStateGas,temperature,pressure);
189  Air->AddMaterial( Nitrogen, fractionmass = 0.7557 ) ;
190  Air->AddMaterial( Oxygen, fractionmass = 0.2315 ) ;
191  Air->AddMaterial( Argon, fractionmass = 0.0128 ) ;
192 
193  // Xenon as detector gas, STP
194 
195  density = 5.858*mg/cm3 ;
196  a = 131.29*g/mole ;
197  G4Material* Xe = new G4Material(name="Xenon",z=54., a, density );
198 
199  // Carbon dioxide, STP
200 
201  density = 1.842*mg/cm3;
202  G4Material* CarbonDioxide = new G4Material(name="CO2", density, nel=2);
203  CarbonDioxide->AddElement(elC,1);
204  CarbonDioxide->AddElement(elO,2);
205 
206  // 80% Xe + 20% CO2, STP
207 
208  density = 5.0818*mg/cm3 ;
209  G4Material* Xe20CO2 = new G4Material(name="Xe20CO2", density, ncomponents=2);
210  Xe20CO2->AddMaterial( Xe, fractionmass = 0.922 ) ;
211  Xe20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.078 ) ;
212 
213  // 80% Kr + 20% CO2, STP
214 
215  density = 3.601*mg/cm3 ;
216  G4Material* Kr20CO2 = new G4Material(name="Kr20CO2", density, ncomponents=2);
217  Kr20CO2->AddMaterial( Kr, fractionmass = 0.89 ) ;
218  Kr20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.11 ) ;
219 
220 
222 
223  // default materials of the calorimeter
224 
225  fAbsorberMaterial = Air ; // Kr20CO2 ; // XeCO2CF4 ;
226 
227  fWorldMaterial = Air ;
228 }
229 
230 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
231 
232 G4VPhysicalVolume* F01DetectorConstruction::ConstructCalorimeter()
233 {
234  // complete the Calor parameters definition and Print
235 
236  ComputeCalorParameters();
238 
239  // Cleanup old geometry
240 
241  if (fPhysiWorld)
242  {
247  }
248 
249  // World
250 
251  fSolidWorld = new G4Tubs("World", // its name
252  0.,fWorldSizeR,fWorldSizeZ/2.,0.,twopi);// its size
253 
254  fLogicWorld = new G4LogicalVolume(fSolidWorld, // its solid
255  fWorldMaterial, // its material
256  "World"); // its name
257 
258  fPhysiWorld = new G4PVPlacement(0, // no rotation
259  G4ThreeVector(), // at (0,0,0)
260  "World", // its name
261  fLogicWorld, // its logical volume
262  0, // its mother volume
263  false, // no boolean operation
264  0); // copy number
265  // Absorber
266 
267  if (fAbsorberThickness > 0.)
268  {
269  fSolidAbsorber = new G4Tubs("Absorber", 1.0*mm,
270  fAbsorberRadius,
271  fAbsorberThickness/2.,
272  0.0,twopi);
273 
274  fLogicAbsorber = new G4LogicalVolume(fSolidAbsorber,
275  fAbsorberMaterial,
276  "Absorber");
277 
278  fPhysiAbsorber = new G4PVPlacement(0,
279  G4ThreeVector(0.,0.,fZAbsorber),
280  "Absorber",
281  fLogicAbsorber,
282  fPhysiWorld,
283  false,
284  0);
285  }
286 
287  // Sensitive Detectors: Absorber
288 
290 
291  if(!fCalorimeterSD)
292  {
293  fCalorimeterSD = new F01CalorimeterSD("CalorSD",this);
294  theSDman->AddNewDetector( fCalorimeterSD );
295  }
296  if (fLogicAbsorber) fLogicAbsorber->SetSensitiveDetector(fCalorimeterSD);
297 
298  return fPhysiWorld;
299 }
300 
301 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
302 
304 {
305  G4cout << "\n The WORLD is made of "
306  << fWorldSizeZ/mm << "mm of " << fWorldMaterial->GetName() ;
307  G4cout << ", the transverse size (R) of the world is " << fWorldSizeR/mm << " mm. "
308  << G4endl;
309  G4cout << " The ABSORBER is made of "
310  << fAbsorberThickness/mm << "mm of " << fAbsorberMaterial->GetName() ;
311  G4cout << ", the transverse size (R) is " << fAbsorberRadius/mm << " mm. " << G4endl;
312  G4cout << " Z position of the (middle of the) absorber " << fZAbsorber/mm << " mm."
313  << G4endl;
314  G4cout << G4endl;
315 }
316 
317 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
318 
320 {
321  // get the pointer to the material table
322  const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
323 
324  // search the material by its name
326  for (size_t j=0 ; j<theMaterialTable->size() ; j++)
327  { material = (*theMaterialTable)[j];
328  if (material->GetName() == materialChoice)
329  {
330  fAbsorberMaterial = material;
331  fLogicAbsorber->SetMaterial(material);
332  }
333  }
334 }
335 
336 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
337 
339 {
340  // get the pointer to the material table
341  const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
342 
343  // search the material by its name
345  for (size_t j=0 ; j<theMaterialTable->size() ; j++)
346  { material = (*theMaterialTable)[j];
347  if(material->GetName() == materialChoice)
348  {
349  fWorldMaterial = material;
350  fLogicWorld->SetMaterial(material);
351  }
352  }
353 }
354 
356 //
357 //
358 
360 {
361  // change Absorber thickness and recompute the calorimeter parameters
362  fAbsorberThickness = val;
363  ComputeCalorParameters();
364 }
365 
366 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
367 
368 //
369 //
370 
372 {
373  // change the transverse size and recompute the calorimeter parameters
374  fAbsorberRadius = val;
375  ComputeCalorParameters();
376 }
377 
378 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
379 
381 {
382  fWorldChanged = true;
383  fWorldSizeZ = val;
384  ComputeCalorParameters();
385 }
386 
387 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
388 
390 {
391  fWorldChanged = true;
392  fWorldSizeR = val;
393  ComputeCalorParameters();
394 }
395 
396 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
397 
399 {
400  fZAbsorber = val;
401  ComputeCalorParameters();
402 }
403 
404 
405 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
406 
408 {
409  G4RunManager::GetRunManager()->DefineWorldVolume(ConstructCalorimeter());
410 }
411 
412 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
413