Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/electromagnetic/TestEm8/src/DetectorConstruction.cc
이 파일의 문서화 페이지로 가기
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 109102 2018-03-27 07:38:33Z 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(nullptr), fWindowMat(nullptr), fWorldMaterial(nullptr),
79  fSolidWorld(nullptr), fSolidContainer(nullptr), fSolidDetector(nullptr),
80  fPhysWorld(nullptr), fLogicWorld(nullptr), fLogicContainer(nullptr),
81  fLogicDetector(nullptr),fRegGasDet(nullptr)
82 {
83  fGasThickness = 23.0*mm;
84  fGasRadius = 10.*cm;
85  fMaxStep = DBL_MAX;
86 
87  fWindowThick = 51.0*micrometer;
88 
90 
92 
93  G4double cut = 0.7*mm;
95  fGasDetectorCuts->SetProductionCut(cut,"gamma");
98  fGasDetectorCuts->SetProductionCut(cut,"proton");
99 }
100 
101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
102 
104 {
105  delete fDetectorMessenger;
106 }
107 
108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
109 
111 {
112  //This function illustrates the possible ways to define materials
113  G4String name, symbol ;
114  G4double density;
115  G4int nel;
116  G4int ncomponents;
117  G4double fractionmass;
118 
120  //
121  // define Elements
122  //
123  G4Element* elH = manager->FindOrBuildElement(1);
124  G4Element* elC = manager->FindOrBuildElement(6);
125  G4Element* elO = manager->FindOrBuildElement(8);
126  G4Element* elF = manager->FindOrBuildElement(9);
127  G4Element* elNe = manager->FindOrBuildElement(10);
128  G4Element* elXe = manager->FindOrBuildElement(54);
129  //
130  // simple gases at STP conditions
131  //
132  G4Material* Argon = manager->FindOrBuildMaterial("G4_Ar");
133  G4Material* Kr = manager->FindOrBuildMaterial("G4_Kr");
134  G4Material* Xe = manager->FindOrBuildMaterial("G4_Xe");
135  //
136  // gases at STP conditions
137  //
138  G4Material* CarbonDioxide =
139  manager->FindOrBuildMaterial("G4_CARBON_DIOXIDE");
140  G4Material* Mylar = manager->FindOrBuildMaterial("G4_MYLAR");
141  G4Material* Methane= manager->FindOrBuildMaterial("G4_METHANE");
142  G4Material* Propane= manager->FindOrBuildMaterial("G4_PROPANE");
143  G4Material* empty = manager->FindOrBuildMaterial("G4_Galactic");
144 
145  // 93% Kr + 7% CH4, STP
146  density = 3.491*mg/cm3 ;
147  G4Material* Kr7CH4 =
148  new G4Material(name="Kr7CH4" , density,
149  ncomponents=2);
150  Kr7CH4->AddMaterial( Kr, fractionmass = 0.986 ) ;
151  Kr7CH4->AddMaterial( Methane, fractionmass = 0.014 ) ;
152 
153  G4double TRT_Xe_density = 5.485*mg/cm3;
154  G4Material* TRT_Xe =
155  new G4Material(name="TRT_Xe", TRT_Xe_density, nel=1,
156  kStateGas,293.15*kelvin,1.*atmosphere);
157  TRT_Xe->AddElement(elXe,1);
158 
159  G4double TRT_CO2_density = 1.842*mg/cm3;
160  G4Material* TRT_CO2 =
161  new G4Material(name="TRT_CO2", TRT_CO2_density, nel=2,
162  kStateGas,293.15*kelvin,1.*atmosphere);
163  TRT_CO2->AddElement(elC,1);
164  TRT_CO2->AddElement(elO,2);
165 
166  G4double TRT_CF4_density = 3.9*mg/cm3;
167  G4Material* TRT_CF4 =
168  new G4Material(name="TRT_CF4", TRT_CF4_density, nel=2,
169  kStateGas,293.15*kelvin,1.*atmosphere);
170  TRT_CF4->AddElement(elC,1);
171  TRT_CF4->AddElement(elF,4);
172 
173  // ATLAS TRT straw tube gas mixture (20 C, 1 atm)
174  G4double XeCO2CF4_density = 4.76*mg/cm3;
175  G4Material* XeCO2CF4 =
176  new G4Material(name="XeCO2CF4", XeCO2CF4_density,
177  ncomponents=3,
178  kStateGas,293.15*kelvin,1.*atmosphere);
179  XeCO2CF4->AddMaterial(TRT_Xe,0.807);
180  XeCO2CF4->AddMaterial(TRT_CO2,0.039);
181  XeCO2CF4->AddMaterial(TRT_CF4,0.154);
182 
183  // C3H8,20 C, 2 atm
184  density = 3.758*mg/cm3 ;
185  G4Material* C3H8 =
186  new G4Material(name="C3H8",density,nel=2,
187  kStateGas,293.15*kelvin,2.*atmosphere);
188  C3H8->AddElement(elC,3) ;
189  C3H8->AddElement(elH,8) ;
190 
191  // 87.5% Xe + 7.5% CH4 + 5% C3H8, 20 C, 1 atm
192  density = 4.9196*mg/cm3 ;
193  G4Material* XeCH4C3H8 =
194  new G4Material(name="XeCH4C3H8" ,
195  density, ncomponents=3,
197  XeCH4C3H8->AddMaterial( Xe, fractionmass = 0.971 ) ;
198  XeCH4C3H8->AddMaterial( Methane, fractionmass = 0.010 ) ;
199  XeCH4C3H8->AddMaterial( Propane, fractionmass = 0.019 ) ;
200 
201  // 93% Ar + 7% CH4, STP
202  density = 1.709*mg/cm3 ;
203  G4Material* Ar7CH4 =
204  new G4Material(name="Ar7CH4", density, ncomponents=2,
206  Ar7CH4->AddMaterial( Argon, fractionmass = 0.971 ) ;
207  Ar7CH4->AddMaterial( Methane, fractionmass = 0.029 ) ;
208 
209  // 80% Ar + 20% CO2, STP
210  density = 1.8223*mg/cm3 ;
211  G4Material* Ar_80CO2_20 =
212  new G4Material(name="ArCO2" , density, ncomponents=2,
214  Ar_80CO2_20->AddMaterial( Argon, fractionmass = 0.783 ) ;
215  Ar_80CO2_20->AddMaterial( CarbonDioxide, fractionmass = 0.217 ) ;
216 
217  // 80% Xe + 20% CO2, STP
218  density = 5.0818*mg/cm3 ;
219  G4Material* Xe20CO2 =
220  new G4Material(name="Xe20CO2", density, ncomponents=2,
222  Xe20CO2->AddMaterial( Xe, fractionmass = 0.922 ) ;
223  Xe20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.078 ) ;
224 
225  // 80% Kr + 20% CO2, STP
226  density = 3.601*mg/cm3 ;
227  G4Material* Kr20CO2 =
228  new G4Material(name="Kr20CO2", density, ncomponents=2,
230  Kr20CO2->AddMaterial( Kr, fractionmass = 0.89 ) ;
231  Kr20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.11 ) ;
232 
233  // ALICE mixture TPC_Ne-CO2-2
234  density = 0.939*mg/cm3 ;
235  G4Material* NeCO2 =
236  new G4Material(name="TPC_Ne-CO2-2", density, ncomponents=3,
238  NeCO2->AddElement( elNe, fractionmass = 0.8039 ) ;
239  NeCO2->AddElement( elO, fractionmass = 0.1426 ) ;
240  NeCO2->AddElement( elC, fractionmass = 0.0535 ) ;
241 
242  // ALICE TRD mixure 85% Xe + 15% CO2 NTP
243  density = 4.9389*mg/cm3 ;
244  G4Material* Xe15CO2 =
245  new G4Material(name="Xe15CO2", density, ncomponents=2,
247  Xe15CO2->AddMaterial( Xe, fractionmass = 0.944 );
248  Xe15CO2->AddMaterial( CarbonDioxide, fractionmass = 0.056 );
249 
250  fGasMat = XeCH4C3H8;
251  fWindowMat = Mylar;
252  fWorldMaterial = empty;
253 
255 
256 }
257 
258 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
259 
261 {
262  G4double contThick = fWindowThick*2 + fGasThickness;
263  G4double contR = fWindowThick*2 + fGasRadius;
264 
265  G4double worldSizeZ = contThick*1.2;
266  G4double worldSizeR = contR*1.2;
267 
268  TestParameters::GetPointer()->SetPositionZ(-0.55*contThick);
269 
270  // Printout parameters
271  G4cout << "\n The WORLD is made of "
272  << worldSizeZ/mm << "mm of " << fWorldMaterial->GetName() ;
273  G4cout << ", the transverse size (R) of the world is " << worldSizeR/mm
274  << " mm. " << G4endl;
275  G4cout << " The CONTAINER is made of "
276  << fWindowThick/mm << "mm of " << fWindowMat->GetName() << G4endl;
277  G4cout << " The TARGET is made of "
278  << fGasThickness/mm << "mm of " << fGasMat->GetName() ;
279  G4cout << ", the transverse size (R) is " << fGasRadius/mm << " mm. "
280  << G4endl;
281  G4cout << G4endl;
282 
283  // World
284  fSolidWorld =
285  new G4Tubs("World",0.,worldSizeR,worldSizeZ/2.,0.,CLHEP::twopi);
286 
288 
289  fPhysWorld = new G4PVPlacement(0,
290  G4ThreeVector(0.,0.,0.),
291  "World",
292  fLogicWorld,
293  0,
294  false,
295  0);
296 
297  // Window
298  fSolidContainer = new G4Tubs("Absorber",
299  0.,contR,contThick/2.,0.,CLHEP::twopi);
300 
302 
303  G4PVPlacement* PhysWind = new G4PVPlacement(0, G4ThreeVector(0.,0.,0.),
304  "Window", fLogicContainer,
305  fPhysWorld, false, 0);
306 
307  // Detector volume
308  fSolidDetector = new G4Tubs("Gas", 0., fGasRadius, fGasThickness/2.,
309  0., CLHEP::twopi);
310 
312 
313  new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), "Gas", fLogicDetector,
314  PhysWind, false, 0);
315 
316  // defined gas detector region
317  fRegGasDet = new G4Region("GasDetector");
320 
321  // visualisation
323  G4VisAttributes* color1 = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3));
325  G4VisAttributes* color2 = new G4VisAttributes(G4Colour(0.0, 0.3, 0.7));
327 
329  SetPairEnergy(20*eV);
330  }
331  return fPhysWorld;
332 }
333 
334 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
335 
337 {
338  auto sd = new TargetSD("GasSD");
341 }
342 
343 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
344 
346 {
347  // get the pointer to the existing material
348  G4Material* mat = G4Material::GetMaterial(name, false);
349 
350  // create the material by its name
351  if(!mat) { mat = G4NistManager::Instance()->FindOrBuildMaterial(name); }
352 
353  if (mat && mat != fGasMat) {
354  G4cout << "### New target material: " << mat->GetName() << G4endl;
355  fGasMat = mat;
356  if(fLogicDetector) {
359  }
360  }
361 }
362 
363 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
364 
366 {
367  // get the pointer to the existing material
368  G4Material* mat = G4Material::GetMaterial(name, false);
369 
370  // create the material by its name
371  if(!mat) { mat = G4NistManager::Instance()->FindOrBuildMaterial(name); }
372 
373  if (mat && mat != fWindowMat) {
374  G4cout << "### New material for container: " << mat->GetName() << G4endl;
375  fWindowMat = mat;
376  if(fLogicContainer) {
379  }
380  }
381 }
382 
383 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
384 
386 {
387  // get the pointer to the existing material
388  G4Material* mat = G4Material::GetMaterial(name, false);
389 
390  // create the material by its name
391  if(!mat) { mat = G4NistManager::Instance()->FindOrBuildMaterial(name); }
392 
393  if (mat && mat != fWorldMaterial) {
394  G4cout << "### New World material: " << mat->GetName() << G4endl;
396  if(fLogicWorld) {
397  fLogicWorld->SetMaterial(mat);
399  }
400  }
401 }
402 
403 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
404 
406 {
407  fGasThickness = val;
408  if(fPhysWorld) { ChangeGeometry(); }
409 }
410 
411 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
412 
414 {
415  fGasRadius = val;
416  if(fPhysWorld) { ChangeGeometry(); }
417 }
418 
419 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
420 
422 {
423  fWindowThick = val;
424  if(fPhysWorld) { ChangeGeometry(); }
425 }
426 
427 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
428 
430 {
431  if(val > 0.0) {
433  }
434 }
435 
436 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
437 
439 {
440  G4double contThick = fWindowThick*2 + fGasThickness;
441  G4double contR = fWindowThick*2 + fGasRadius;
442 
443  G4double worldSizeZ = contThick*1.2;
444  G4double worldSizeR = contR*1.2;
445 
446  TestParameters::GetPointer()->SetPositionZ(-0.55*contThick);
447 
448  fSolidWorld->SetOuterRadius(worldSizeR);
449  fSolidWorld->SetZHalfLength(worldSizeZ*0.5);
450 
452  fSolidContainer->SetZHalfLength(contThick*0.5);
453 
454  fSolidDetector->SetOuterRadius(fGasRadius);
455  fSolidDetector->SetZHalfLength(fGasThickness*0.5);
456 }
457 
458 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static constexpr double kelvin
Definition: G4SIunits.hh:281
void AddRootLogicalVolume(G4LogicalVolume *lv)
Definition: G4Region.cc:290
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
static constexpr double micrometer
Definition: G4SIunits.hh:100
const XML_Char * name
Definition: expat.h:151
void SetProductionCut(G4double cut, G4int index=-1)
static constexpr double atmosphere
Definition: G4SIunits.hh:237
CLHEP::Hep3Vector G4ThreeVector
void SetOuterRadius(G4double newRMax)
static const G4double NTP_Temperature
Definition: G4Material.hh:117
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
static constexpr double STP_Temperature
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:593
static constexpr double mm
Definition: G4SIunits.hh:115
Definition: G4Tubs.hh:85
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:71
#define G4endl
Definition: G4ios.hh:61
void SetZHalfLength(G4double dz)
Definition: G4Box.cc:183
void SetProductionCuts(G4ProductionCuts *cut)
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:608
static constexpr double STP_Pressure
static const G4VisAttributes & GetInvisible()
void SetMeanEnergyPerIonPair(G4double value)
const G4String & GetName() const
Definition: G4Material.hh:179
G4Element * FindOrBuildElement(G4int Z, G4bool isotopes=true)
void SetWorldMaterial(const G4String &materialName)
double G4double
Definition: G4Types.hh:76
void SetZHalfLength(G4double newDz)
static constexpr double mg
Definition: G4SIunits.hh:184
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
static constexpr double eV
Definition: G4SIunits.hh:215
G4double GetMeanEnergyPerIonPair() const
Float_t mat
void SetVisAttributes(const G4VisAttributes *pVA)
static constexpr double twopi
Definition: SystemOfUnits.h:55
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
int G4int
Definition: G4Types.hh:78
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:368
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:227
void PhysicsHasBeenModified()
G4GLOB_DLL std::ostream G4cout
static constexpr double cm
Definition: G4SIunits.hh:119
void SetMaterial(G4Material *pMaterial)
void AddMaterial(G4Material *material, G4double fraction)
Definition: G4Material.cc:473
#define DBL_MAX
Definition: templates.hh:83
static constexpr double cm3
Definition: G4SIunits.hh:121
static G4NistManager * Instance()