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