Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
F03DetectorConstruction.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 
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
34 
36 #include "F03DetectorMessenger.hh"
37 #include "F03CalorimeterSD.hh"
38 #include "F03FieldSetup.hh"
39 
40 #include "G4Material.hh"
41 #include "G4Tubs.hh"
42 #include "G4LogicalVolume.hh"
43 #include "G4PVPlacement.hh"
44 #include "G4UniformMagField.hh"
45 #include "G4FieldManager.hh"
47 #include "G4SDManager.hh"
48 #include "G4RunManager.hh"
49 
50 #include "G4GeometryManager.hh"
51 #include "G4PhysicalVolumeStore.hh"
52 #include "G4LogicalVolumeStore.hh"
53 #include "G4SolidStore.hh"
54 
55 #include "G4PhysicalConstants.hh"
56 #include "G4SystemOfUnits.hh"
57 #include "G4ios.hh"
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
60 
62  : fMagField(0), fEmFieldSetup(0), fDetectorMessenger(0), fCalorimeterSD(0),
63  fSolidWorld(0), fLogicWorld(0), fPhysiWorld(0),
64  fSolidAbsorber(0), fLogicAbsorber(0), fPhysiAbsorber(0),
65  fSolidRadSlice(0), fLogicRadSlice(0), fPhysiRadSlice(0),
66  fSolidRadiator(0), fLogicRadiator(0), fPhysiRadiator(0),
67  fWorldMaterial(0), fAbsorberMaterial(0), fRadiatorMat(0),
68  // default parameter values of the calorimeter
69  fWorldSizeR( 22000.*mm),
70  fWorldSizeZ( 44000.*mm),
71  fAbsorberThickness( 1.*mm),
72  fAbsorberRadius( 20000.*mm),
73  fZAbsorber( 21990.*mm),
74  fZStartAbs( 0.),
75  fZEndAbs( 0.),
76  fRadThickness( 100.*mm),
77  fGasGap( 100.*mm),
78  fDetGap( 1.*mm),
79  fFoilNumber(1),
80  fWorldChanged(false)
81 {
82  // create commands for interactive definition of the calorimeter
83 
84  DefineMaterials();
85 
86  fEmFieldSetup = new F03FieldSetup() ;
87 
88  fDetectorMessenger = new F03DetectorMessenger(this);
89 }
90 
91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
92 
94 {
95  delete fDetectorMessenger;
96  if (fEmFieldSetup) delete fEmFieldSetup ;
97 }
98 
99 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
100 
102 {
103  return ConstructCalorimeter();
104 }
105 
106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
107 
108 void F03DetectorConstruction::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  density = 1.2928*mg/cm3 ; // STP
176  density *= 1.0e-8 ; // pumped vacuum
177  temperature = STP_Temperature;
178  pressure = 1.0e-8*STP_Pressure;
179 
180  G4Material* Air = new G4Material(name="Air" , density, ncomponents=3,
181  kStateGas,temperature,pressure);
182  Air->AddMaterial( Nitrogen, fractionmass = 0.7557 ) ;
183  Air->AddMaterial( Oxygen, fractionmass = 0.2315 ) ;
184  Air->AddMaterial( Argon, fractionmass = 0.0128 ) ;
185 
186  // Xenon as detector gas, STP
187 
188  density = 5.858*mg/cm3 ;
189  a = 131.29*g/mole ;
190  G4Material* Xe = new G4Material(name="Xenon",z=54., a, density );
191 
192  // Carbon dioxide, STP
193 
194  density = 1.842*mg/cm3;
195  G4Material* CarbonDioxide = new G4Material(name="CO2", density, nel=2);
196  CarbonDioxide->AddElement(elC,1);
197  CarbonDioxide->AddElement(elO,2);
198 
199  // 80% Xe + 20% CO2, STP
200 
201  density = 5.0818*mg/cm3 ;
202  G4Material* Xe20CO2 = new G4Material(name="Xe20CO2" , density, ncomponents=2);
203  Xe20CO2->AddMaterial( Xe, fractionmass = 0.922 ) ;
204  Xe20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.078 ) ;
205 
206  // 80% Kr + 20% CO2, STP
207 
208  density = 3.601*mg/cm3 ;
209  G4Material* Kr20CO2 = new G4Material(name="Kr20CO2" , density,
210  ncomponents=2);
211  Kr20CO2->AddMaterial( Kr, fractionmass = 0.89 ) ;
212  Kr20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.11 ) ;
213 
214 
216 
217  //default materials of the calorimeter and TR radiator
218 
219  fRadiatorMat = Air ; // CH2 ; // Mylar ;
220 
221  fAbsorberMaterial = Air ; // Kr20CO2 ; // XeCO2CF4 ;
222 
223  fWorldMaterial = Air ;
224 }
225 
226 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
227 
228 G4VPhysicalVolume* F03DetectorConstruction::ConstructCalorimeter()
229 {
230  G4int j ;
231  G4double zModule, zRadiator;
232 
233  // complete the Calor parameters definition and Print
234 
235  ComputeCalorParameters();
237 
238  // Cleanup old geometry
239 
240  if (fPhysiWorld)
241  {
246  }
247 
248  fSolidWorld = new G4Tubs("World", // its name
249  0.,fWorldSizeR,fWorldSizeZ/2.,0.,twopi);// its size
250 
251  fLogicWorld = new G4LogicalVolume(fSolidWorld, // its solid
252  fWorldMaterial, // its material
253  "World"); // its name
254 
255  fPhysiWorld = new G4PVPlacement(0, // no rotation
256  G4ThreeVector(), // at (0,0,0)
257  "World", // its name
258  fLogicWorld, // its logical volume
259  0, // its mother volume
260  false, // no boolean operation
261  0); // copy number
262 
263  // TR radiator envelope
264 
265  G4double radThick = fFoilNumber*(fRadThickness + fGasGap) + fDetGap ;
266 
267  G4double zRad = fZAbsorber - 20*cm - 0.5*radThick ;
268  G4cout << "zRad = " << zRad/mm << " mm" << G4endl ;
269 
270  radThick *= 1.02 ;
271  G4cout << "radThick = " << radThick/mm << " mm" << G4endl ;
272  G4cout << "fFoilNumber = " << fFoilNumber << G4endl ;
273  G4cout << "fRadiatorMat = " << fRadiatorMat->GetName() << G4endl ;
274  G4cout << "WorldMaterial = " << fWorldMaterial->GetName() << G4endl ;
275 
276  fSolidRadiator = new G4Tubs("Radiator",0.0,
277  1.01*fAbsorberRadius,
278  0.5*radThick,0.0, twopi) ;
279 
280  fLogicRadiator = new G4LogicalVolume(fSolidRadiator,
281  fWorldMaterial,
282  "Radiator");
283 
284  // Set local field manager and local field in radiator and its daughters:
285 
286  G4bool allLocal = true ;
287 
288  fLogicRadiator->SetFieldManager( fEmFieldSetup->GetLocalFieldManager(),
289  allLocal ) ;
290 
291 
292  fPhysiRadiator = new G4PVPlacement(0,
293  G4ThreeVector(0,0,zRad),
294  "Radiator", fLogicRadiator,
295  fPhysiWorld, false, 0);
296 
297  fSolidRadSlice = new G4Tubs("RadSlice",0.0,
298  fAbsorberRadius,0.5*fRadThickness,0.0,twopi ) ;
299 
300  fLogicRadSlice = new G4LogicalVolume(fSolidRadSlice,fRadiatorMat,
301  "RadSlice",0,0,0);
302 
303  zModule = zRad + 0.5*radThick/1.02 ;
304  G4cout << "zModule = " << zModule/mm << " mm" << G4endl ;
305 
306  for (j=0;j<fFoilNumber;j++)
307  {
308 
309  zRadiator = zModule - j*(fRadThickness + fGasGap) ;
310  G4cout << zRadiator/mm << " mm" << "\t" ;
311  // G4cout << "j = " << j << "\t" ;
312 
313  fPhysiRadSlice = new G4PVPlacement(0,G4ThreeVector(0.,0.,zRadiator-zRad),
314  "RadSlice",fLogicRadSlice,
315  fPhysiRadiator,false,j);
316  }
317  G4cout << G4endl ;
318 
319  // Absorber
320 
321  if (fAbsorberThickness > 0.)
322  {
323  fSolidAbsorber = new G4Tubs("Absorber", 1.0*mm,
324  fAbsorberRadius,
325  fAbsorberThickness/2.,
326  0.0,twopi);
327 
328  fLogicAbsorber = new G4LogicalVolume(fSolidAbsorber,
329  fAbsorberMaterial,
330  "Absorber");
331 
332  fPhysiAbsorber = new G4PVPlacement(0,
333  G4ThreeVector(0.,0.,fZAbsorber),
334  "Absorber",
335  fLogicAbsorber,
336  fPhysiWorld,
337  false,
338  0);
339  }
340 
341  // Sensitive Detectors: Absorber
342 
344 
345  if (!fCalorimeterSD)
346  {
347  fCalorimeterSD = new F03CalorimeterSD("CalorSD",this);
348  sdManager->AddNewDetector( fCalorimeterSD );
349  }
350  if (fLogicAbsorber) fLogicAbsorber->SetSensitiveDetector(fCalorimeterSD);
351 
352  return fPhysiWorld;
353 }
354 
355 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
356 
358 {
359  G4cout << "\n The WORLD is made of "
360  << fWorldSizeZ/mm << "mm of " << fWorldMaterial->GetName() ;
361  G4cout << ", the transverse size (R) of the world is " << fWorldSizeR/mm << " mm. " << G4endl;
362  G4cout << " The ABSORBER is made of "
363  << fAbsorberThickness/mm << "mm of " << fAbsorberMaterial->GetName() ;
364  G4cout << ", the transverse size (R) is " << fAbsorberRadius/mm << " mm. " << G4endl;
365  G4cout << " Z position of the (middle of the) absorber " << fZAbsorber/mm << " mm." << G4endl;
366  G4cout << G4endl;
367 }
368 
369 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
370 
372 {
373  // get the pointer to the material table
374  const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
375 
376  // search the material by its name
378  for (size_t j=0 ; j<theMaterialTable->size() ; j++)
379  {
380  material = (*theMaterialTable)[j];
381  if (material->GetName() == materialChoice)
382  {
383  fAbsorberMaterial = material;
384  fLogicAbsorber->SetMaterial(material);
385  }
386  }
387 }
388 
389 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
390 
392 {
393  // get the pointer to the material table
394  const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
395 
396  // search the material by its name
398  for (size_t j=0 ; j<theMaterialTable->size() ; j++)
399  {
400  material = (*theMaterialTable)[j];
401  if (material->GetName() == materialChoice)
402  {
403  fWorldMaterial = material;
404  fLogicWorld->SetMaterial(material);
405  }
406  }
407 }
408 
409 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
410 
412 {
413  // change Absorber thickness and recompute the calorimeter parameters
414  fAbsorberThickness = val;
415  ComputeCalorParameters();
416 }
417 
418 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
419 
421 {
422  // change the transverse size and recompute the calorimeter parameters
423  fAbsorberRadius = val;
424  ComputeCalorParameters();
425 }
426 
427 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
428 
430 {
431  fWorldChanged=true;
432  fWorldSizeZ = val;
433  ComputeCalorParameters();
434 }
435 
436 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
437 
439 {
440  fWorldChanged=true;
441  fWorldSizeR = val;
442  ComputeCalorParameters();
443 }
444 
445 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
446 
448 {
449  fZAbsorber = val;
450  ComputeCalorParameters();
451 }
452 
453 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
454 
456 {
457  G4RunManager::GetRunManager()->DefineWorldVolume(ConstructCalorimeter());
458 }
459 
460 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....