Geant4  10.02.p01
DetectorConstruction.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: DetectorConstruction.cc 92047 2015-08-14 07:23:37Z gcosmo $
30 //
32 //
33 // TestEm8: Gaseous detector
34 //
35 // Created: 31.08.2010 V.Ivanchenko ob base of V.Grichine code
36 //
37 // Modified:
38 //
40 //
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42 
43 #include "DetectorConstruction.hh"
44 #include "DetectorMessenger.hh"
45 #include "TargetSD.hh"
46 
47 #include "G4Material.hh"
48 #include "G4Tubs.hh"
49 #include "G4LogicalVolume.hh"
50 #include "G4PVPlacement.hh"
51 
52 #include "G4SDManager.hh"
53 #include "G4GeometryManager.hh"
54 #include "G4RunManager.hh"
55 #include "G4NistManager.hh"
56 
57 #include "G4Region.hh"
58 #include "G4RegionStore.hh"
59 #include "G4PhysicalVolumeStore.hh"
60 #include "G4LogicalVolumeStore.hh"
61 #include "G4SolidStore.hh"
62 #include "G4ProductionCuts.hh"
63 
64 #include "G4VisAttributes.hh"
65 #include "G4Colour.hh"
66 
67 #include "G4UnitsTable.hh"
68 #include "G4PhysicalConstants.hh"
69 #include "G4SystemOfUnits.hh"
70 #include "G4ios.hh"
71 #include "TestParameters.hh"
72 #include "G4PionPlus.hh"
73 
74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
75 
78  fGasMat(0), fWindowMat(0), fWorldMaterial(0),
79  fSolidWorld(0), fSolidContainer(0), fSolidDetector(0),
80  fPhysWorld(0), fLogicWorld(0), fLogicContainer(0), fLogicDetector(0),
81  fDetectorMessenger(0), fGasDetectorCuts(0), fRegGasDet(0)
82 {
83  fGasThickness = 23.0*mm;
84  fGasRadius = 10.*cm;
85 
86  fWindowThick = 51.0*micrometer;
87 
89 
91 
92  G4double cut = 23.*mm;
94  fGasDetectorCuts->SetProductionCut(cut,"gamma");
97  fGasDetectorCuts->SetProductionCut(cut,"proton");
98 }
99 
100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
101 
103 {
104  delete fDetectorMessenger;
105 }
106 
107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
108 
110 {
111  //This function illustrates the possible ways to define materials
112  G4String name, symbol ;
113  G4double density;
114  G4int nel;
115  G4int ncomponents;
116  G4double fractionmass;
117 
119  //
120  // define Elements
121  //
122  G4Element* elH = manager->FindOrBuildElement(1);
123  G4Element* elC = manager->FindOrBuildElement(6);
124  G4Element* elO = manager->FindOrBuildElement(8);
125  G4Element* elF = manager->FindOrBuildElement(9);
126  G4Element* elNe = manager->FindOrBuildElement(10);
127  G4Element* elXe = manager->FindOrBuildElement(54);
128  //
129  // simple gases at STP conditions
130  //
131  G4Material* Argon = manager->FindOrBuildMaterial("G4_Ar");
132  G4Material* Kr = manager->FindOrBuildMaterial("G4_Kr");
133  G4Material* Xe = manager->FindOrBuildMaterial("G4_Xe");
134  //
135  // gases at STP conditions
136  //
137  G4Material* CarbonDioxide =
138  manager->FindOrBuildMaterial("G4_CARBON_DIOXIDE");
139  G4Material* Mylar = manager->FindOrBuildMaterial("G4_MYLAR");
140  G4Material* Methane= manager->FindOrBuildMaterial("G4_METHANE");
141  G4Material* Propane= manager->FindOrBuildMaterial("G4_PROPANE");
142  G4Material* empty = manager->FindOrBuildMaterial("G4_Galactic");
143 
144  // 93% Kr + 7% CH4, STP
145  density = 3.491*mg/cm3 ;
146  G4Material* Kr7CH4 =
147  new G4Material(name="Kr7CH4" , density,
148  ncomponents=2);
149  Kr7CH4->AddMaterial( Kr, fractionmass = 0.986 ) ;
150  Kr7CH4->AddMaterial( Methane, fractionmass = 0.014 ) ;
151 
152  G4double TRT_Xe_density = 5.485*mg/cm3;
153  G4Material* TRT_Xe =
154  new G4Material(name="TRT_Xe", TRT_Xe_density, nel=1,
155  kStateGas,293.15*kelvin,1.*atmosphere);
156  TRT_Xe->AddElement(elXe,1);
157 
158  G4double TRT_CO2_density = 1.842*mg/cm3;
159  G4Material* TRT_CO2 =
160  new G4Material(name="TRT_CO2", TRT_CO2_density, nel=2,
161  kStateGas,293.15*kelvin,1.*atmosphere);
162  TRT_CO2->AddElement(elC,1);
163  TRT_CO2->AddElement(elO,2);
164 
166  G4Material* TRT_CF4 =
167  new G4Material(name="TRT_CF4", TRT_CF4_density, nel=2,
168  kStateGas,293.15*kelvin,1.*atmosphere);
169  TRT_CF4->AddElement(elC,1);
170  TRT_CF4->AddElement(elF,4);
171 
172  // ATLAS TRT straw tube gas mixture (20 C, 1 atm)
174  G4Material* XeCO2CF4 =
175  new G4Material(name="XeCO2CF4", XeCO2CF4_density,
176  ncomponents=3,
177  kStateGas,293.15*kelvin,1.*atmosphere);
178  XeCO2CF4->AddMaterial(TRT_Xe,0.807);
179  XeCO2CF4->AddMaterial(TRT_CO2,0.039);
180  XeCO2CF4->AddMaterial(TRT_CF4,0.154);
181 
182  // C3H8,20 C, 2 atm
183  density = 3.758*mg/cm3 ;
184  G4Material* C3H8 =
185  new G4Material(name="C3H8",density,nel=2,
186  kStateGas,293.15*kelvin,2.*atmosphere);
187  C3H8->AddElement(elC,3) ;
188  C3H8->AddElement(elH,8) ;
189 
190  // 87.5% Xe + 7.5% CH4 + 5% C3H8, 20 C, 1 atm
191  density = 4.9196*mg/cm3 ;
192  G4Material* XeCH4C3H8 =
193  new G4Material(name="XeCH4C3H8" ,
194  density, ncomponents=3,
196  XeCH4C3H8->AddMaterial( Xe, fractionmass = 0.971 ) ;
197  XeCH4C3H8->AddMaterial( Methane, fractionmass = 0.010 ) ;
198  XeCH4C3H8->AddMaterial( Propane, fractionmass = 0.019 ) ;
199 
200  // 93% Ar + 7% CH4, STP
201  density = 1.709*mg/cm3 ;
202  G4Material* Ar7CH4 =
203  new G4Material(name="Ar7CH4", density, ncomponents=2,
204  kStateGas,STP_Temperature,STP_Pressure);
205  Ar7CH4->AddMaterial( Argon, fractionmass = 0.971 ) ;
206  Ar7CH4->AddMaterial( Methane, fractionmass = 0.029 ) ;
207 
208  // 80% Ar + 20% CO2, STP
209  density = 1.8223*mg/cm3 ;
210  G4Material* Ar_80CO2_20 =
211  new G4Material(name="ArCO2" , density, ncomponents=2,
212  kStateGas,STP_Temperature,STP_Pressure);
213  Ar_80CO2_20->AddMaterial( Argon, fractionmass = 0.783 ) ;
214  Ar_80CO2_20->AddMaterial( CarbonDioxide, fractionmass = 0.217 ) ;
215 
216  // 80% Xe + 20% CO2, STP
217  density = 5.0818*mg/cm3 ;
218  G4Material* Xe20CO2 =
219  new G4Material(name="Xe20CO2", density, ncomponents=2,
220  kStateGas,STP_Temperature,STP_Pressure);
221  Xe20CO2->AddMaterial( Xe, fractionmass = 0.922 ) ;
222  Xe20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.078 ) ;
223 
224  // 80% Kr + 20% CO2, STP
225  density = 3.601*mg/cm3 ;
226  G4Material* Kr20CO2 =
227  new G4Material(name="Kr20CO2", density, ncomponents=2,
228  kStateGas,STP_Temperature,STP_Pressure);
229  Kr20CO2->AddMaterial( Kr, fractionmass = 0.89 ) ;
230  Kr20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.11 ) ;
231 
232  // ALICE mixture TPC_Ne-CO2-2
233  density = 0.939*mg/cm3 ;
234  G4Material* NeCO2 =
235  new G4Material(name="TPC_Ne-CO2-2", density, ncomponents=3,
237  NeCO2->AddElement( elNe, fractionmass = 0.8039 ) ;
238  NeCO2->AddElement( elO, fractionmass = 0.1426 ) ;
239  NeCO2->AddElement( elC, fractionmass = 0.0535 ) ;
240 
241  // ALICE TRD mixure 85% Xe + 15% CO2 NTP
242  density = 4.9389*mg/cm3 ;
243  G4Material* Xe15CO2 =
244  new G4Material(name="Xe15CO2", density, ncomponents=2,
246  Xe15CO2->AddMaterial( Xe, fractionmass = 0.944 );
247  Xe15CO2->AddMaterial( CarbonDioxide, fractionmass = 0.056 );
248 
249  fGasMat = XeCH4C3H8;
250  fWindowMat = Mylar;
251  fWorldMaterial = empty;
252 
254 
255 }
256 
257 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
258 
260 {
261  G4double contThick = fWindowThick*2 + fGasThickness;
262  G4double contR = fWindowThick*2 + fGasRadius;
263 
264  G4double worldSizeZ = contThick*1.2;
265  G4double worldSizeR = contR*1.2;
266 
267  TestParameters::GetPointer()->SetPositionZ(-0.55*contThick);
268 
269  // Printout parameters
270  G4cout << "\n The WORLD is made of "
271  << worldSizeZ/mm << "mm of " << fWorldMaterial->GetName() ;
272  G4cout << ", the transverse size (R) of the world is " << worldSizeR/mm
273  << " mm. " << G4endl;
274  G4cout << " The CONTAINER is made of "
275  << fWindowThick/mm << "mm of " << fWindowMat->GetName() << G4endl;
276  G4cout << " The TARGET is made of "
277  << fGasThickness/mm << "mm of " << fGasMat->GetName() ;
278  G4cout << ", the transverse size (R) is " << fGasRadius/mm << " mm. "
279  << G4endl;
280  G4cout << G4endl;
281 
282  // World
283  fSolidWorld =
284  new G4Tubs("World",0.,worldSizeR,worldSizeZ/2.,0.,CLHEP::twopi);
285 
287 
288  fPhysWorld = new G4PVPlacement(0,
289  G4ThreeVector(0.,0.,0.),
290  "World",
291  fLogicWorld,
292  0,
293  false,
294  0);
295 
296  // Window
297  fSolidContainer = new G4Tubs("Absorber",
298  0.,contR,contThick/2.,0.,CLHEP::twopi);
299 
301 
302  G4PVPlacement* PhysWind = new G4PVPlacement(0, G4ThreeVector(0.,0.,0.),
303  "Window", fLogicContainer,
304  fPhysWorld, false, 0);
305 
306  // Detector volume
307  fSolidDetector = new G4Tubs("Gas", 0., fGasRadius, fGasThickness/2.,
308  0., CLHEP::twopi);
309 
311 
312  new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), "Gas", fLogicDetector,
313  PhysWind, false, 0);
314 
315  // defined gas detector region
316  fRegGasDet = new G4Region("GasDetector");
319 
320  // visualisation
322  G4VisAttributes* color1 = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3));
324  G4VisAttributes* color2 = new G4VisAttributes(G4Colour(0.0, 0.3, 0.7));
326 
328  SetPairEnergy(20*eV);
329  }
330  return fPhysWorld;
331 }
332 
333 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
334 
336 {
338 }
339 
340 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
341 
343 {
344  // get the pointer to the existing material
345  G4Material* mat = G4Material::GetMaterial(name, false);
346 
347  // create the material by its name
348  if(!mat) { mat = G4NistManager::Instance()->FindOrBuildMaterial(name); }
349 
350  if (mat && mat != fGasMat) {
351  G4cout << "### New target material: " << mat->GetName() << G4endl;
352  fGasMat = mat;
353  if(fLogicDetector) {
356  }
357  }
358 }
359 
360 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
361 
363 {
364  // get the pointer to the existing material
365  G4Material* mat = G4Material::GetMaterial(name, false);
366 
367  // create the material by its name
368  if(!mat) { mat = G4NistManager::Instance()->FindOrBuildMaterial(name); }
369 
370  if (mat && mat != fWindowMat) {
371  G4cout << "### New material for container: " << mat->GetName() << G4endl;
372  fWindowMat = mat;
373  if(fLogicContainer) {
376  }
377  }
378 }
379 
380 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
381 
383 {
384  // get the pointer to the existing material
385  G4Material* mat = G4Material::GetMaterial(name, false);
386 
387  // create the material by its name
388  if(!mat) { mat = G4NistManager::Instance()->FindOrBuildMaterial(name); }
389 
390  if (mat && mat != fWorldMaterial) {
391  G4cout << "### New World material: " << mat->GetName() << G4endl;
392  fWorldMaterial = mat;
393  if(fLogicWorld) {
394  fLogicWorld->SetMaterial(mat);
396  }
397  }
398 }
399 
400 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
401 
403 {
404  fGasThickness = val;
405  if(fPhysWorld) { ChangeGeometry(); }
406 }
407 
408 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
409 
411 {
412  fGasRadius = val;
413  if(fPhysWorld) { ChangeGeometry(); }
414 }
415 
416 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
417 
419 {
420  fWindowThick = val;
421  if(fPhysWorld) { ChangeGeometry(); }
422 }
423 
424 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
425 
427 {
428  if(val > 0.0) {
430  }
431 }
432 
433 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
434 
436 {
437  G4double contThick = fWindowThick*2 + fGasThickness;
438  G4double contR = fWindowThick*2 + fGasRadius;
439 
440  G4double worldSizeZ = contThick*1.2;
441  G4double worldSizeR = contR*1.2;
442 
443  TestParameters::GetPointer()->SetPositionZ(-0.55*contThick);
444 
445  fSolidWorld->SetOuterRadius(worldSizeR);
446  fSolidWorld->SetZHalfLength(worldSizeZ*0.5);
447 
449  fSolidContainer->SetZHalfLength(contThick*0.5);
450 
451  fSolidDetector->SetOuterRadius(fGasRadius);
452  fSolidDetector->SetZHalfLength(fGasThickness*0.5);
453 
454 }
455 
456 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static const double cm
Definition: G4SIunits.hh:118
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:226
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
G4double TRT_Xe_density
Definition: TRTMaterials.hh:86
G4String symbol
Definition: TRTMaterials.hh:40
G4Material * TRT_Xe
Definition: TRTMaterials.hh:87
void SetZHalfLength(G4double dz)
Definition: G4Box.cc:171
CLHEP::Hep3Vector G4ThreeVector
void AddRootLogicalVolume(G4LogicalVolume *lv)
Definition: G4Region.cc:254
void AddMaterial(G4Material *material, G4double fraction)
Definition: G4Material.cc:469
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:604
G4double GetMeanEnergyPerIonPair() const
G4String name
Definition: TRTMaterials.hh:40
const G4String & GetName() const
Definition: G4Material.hh:178
G4VPhysicalVolume * Construct()
Definition: G4Tubs.hh:85
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:589
G4Element * elC
Definition: TRTMaterials.hh:48
void SetWorldMaterial(const G4String &)
G4Element * elF
Definition: TRTMaterials.hh:54
void SetProductionCut(G4double cut, G4int index=-1)
void SetPositionZ(G4double val)
static const double mg
Definition: G4SIunits.hh:181
G4Material * XeCO2CF4
void SetContainerMaterial(const G4String &)
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
G4Element * elH
Definition: TRTMaterials.hh:50
G4ProductionCuts * fGasDetectorCuts
G4double density
Definition: TRTMaterials.hh:39
virtual void ConstructSDandField()
void SetContainerThickness(G4double)
G4GLOB_DLL std::ostream G4cout
G4Element * elO
Definition: TRTMaterials.hh:46
G4LogicalVolume * fLogicWorld
void PhysicsHasBeenModified()
G4Material * TRT_CO2
Definition: TRTMaterials.hh:92
G4VPhysicalVolume * fPhysWorld
static const double twopi
Definition: G4SIunits.hh:75
static const double cm3
Definition: G4SIunits.hh:120
G4LogicalVolume * fLogicDetector
G4double TRT_CF4_density
Definition: TRTMaterials.hh:97
G4LogicalVolume * fLogicContainer
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
static const double kelvin
Definition: G4SIunits.hh:278
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
static const double micrometer
Definition: G4SIunits.hh:99
void SetOuterRadius(G4double newRMax)
static const double eV
Definition: G4SIunits.hh:212
void SetGasMaterial(const G4String &)
G4Material * TRT_CF4
Definition: TRTMaterials.hh:98
G4Element * elXe
Definition: TRTMaterials.hh:52
G4double XeCO2CF4_density
static const G4VisAttributes Invisible
static const double atmosphere
Definition: G4SIunits.hh:234
G4double TRT_CO2_density
Definition: TRTMaterials.hh:91
static TestParameters * GetPointer()
static const G4double NTP_Temperature
Definition: G4Material.hh:116
#define G4endl
Definition: G4ios.hh:61
void SetProductionCuts(G4ProductionCuts *cut)
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:364
double G4double
Definition: G4Types.hh:76
G4Element * FindOrBuildElement(G4int Z, G4bool isotopes=true)
void SetMaterial(G4Material *pMaterial)
static const double mm
Definition: G4SIunits.hh:114
Messenger class that defines commands for DetectorConstruction.
void SetVisAttributes(const G4VisAttributes *pVA)
G4int nel
Definition: TRTMaterials.hh:41
void SetZHalfLength(G4double newDz)
void SetMeanEnergyPerIonPair(G4double value)
DetectorMessenger * fDetectorMessenger