Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/hadronic/NeutronSource/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 70755 2013-06-05 12:17:48Z ihrivnac $
30 //
31 
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 
35 #include "DetectorConstruction.hh"
36 #include "DetectorMessenger.hh"
37 #include "G4Material.hh"
38 #include "G4NistManager.hh"
39 
40 #include "G4Box.hh"
41 #include "G4Tubs.hh"
42 #include "G4LogicalVolume.hh"
43 #include "G4PVPlacement.hh"
44 
45 #include "G4GeometryManager.hh"
46 #include "G4PhysicalVolumeStore.hh"
47 #include "G4LogicalVolumeStore.hh"
48 #include "G4SolidStore.hh"
49 #include "G4RunManager.hh"
50 
51 #include "G4UnitsTable.hh"
52 #include "G4SystemOfUnits.hh"
53 #include "G4PhysicalConstants.hh"
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
59  fAbsorMaterial(0), fLAbsor(0), fContainMaterial(0), fLContain(0),
60  fWorldMaterial(0), fPWorld(0), fDetectorMessenger(0)
61 {
62  fAbsorRadius = 15*mm;
63  fAbsorLength = 60*mm;
64  fContainThickness = 2.4*mm;
66  SetAbsorMaterial ("BeO");
67  SetContainMaterial("Stainless-Steel");
69 }
70 
71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72 
74 { delete fDetectorMessenger;}
75 
76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
77 
79 {
80  return ConstructVolumes();
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
84 
86 {
87  G4int ncomponents, natoms;
88 
89  G4Element* Be = new G4Element("Beryllium","Be" , 4., 9.01*g/mole);
90  G4Element* N = new G4Element("Nitrogen" ,"N" , 7., 14.01*g/mole);
91  G4Element* O = new G4Element("Oxygen" ,"O" , 8., 16.00*g/mole);
92  G4Element* Cr = new G4Element("Chromium" ,"Cr" , 24., 51.99*g/mole);
93  G4Element* Fe = new G4Element("Iron" ,"Fe" , 26., 55.84*g/mole);
94  G4Element* Ni = new G4Element("Nickel" ,"Ni" , 28., 58.69*g/mole);
95 
96  G4Material* BeO =
97  new G4Material("BeO", 3.05*g/cm3, ncomponents=2);
98  BeO->AddElement(Be, natoms=1);
99  BeO->AddElement( O, natoms=1);
100 
101  G4Material* inox =
102  new G4Material("Stainless-Steel", 8*g/cm3, ncomponents=3);
103  inox->AddElement(Fe, 74*perCent);
104  inox->AddElement(Cr, 18*perCent);
105  inox->AddElement(Ni, 8*perCent);
106 
107  G4Material* Air =
108  new G4Material("Air", 1.290*mg/cm3, ncomponents=2);
109  Air->AddElement(N, 70.*perCent);
110  Air->AddElement(O, 30.*perCent);
111 
112  fWorldMaterial = Air;
113 
115 }
116 
117 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
118 
120  G4String symbol, G4double density, G4int Z, G4int A)
121 {
122  // define a material from an isotope
123  //
124  G4int ncomponents;
125  G4double abundance, massfraction;
126 
127  G4Isotope* isotope = new G4Isotope(symbol, Z, A);
128 
129  G4Element* element = new G4Element(name, symbol, ncomponents=1);
130  element->AddIsotope(isotope, abundance= 100.*perCent);
131 
132  G4Material* material = new G4Material(name, density, ncomponents=1);
133  material->AddElement(element, massfraction=100.*perCent);
134 
135  return material;
136 }
137 
138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
139 
141 {
142  // Cleanup old geometry
147 
148  // compute dimensions
149  G4double ContainRadius = fAbsorRadius + fContainThickness;
150  G4double ContainLength = fAbsorLength + 2*fContainThickness;
151 
152  G4double WorldSizeXY = 2.4*ContainRadius;
153  G4double WorldSizeZ = 1.2*ContainLength;
154 
155  // World
156  //
157  G4Box*
158  sWorld = new G4Box("World", //name
159  0.5*WorldSizeXY,0.5*WorldSizeXY,0.5*WorldSizeZ); //dimensions
160 
162  lWorld = new G4LogicalVolume(sWorld, //shape
163  fWorldMaterial, //material
164  "World"); //name
165 
166  fPWorld = new G4PVPlacement(0, //no rotation
167  G4ThreeVector(), //at (0,0,0)
168  lWorld, //logical volume
169  "World", //name
170  0, //mother volume
171  false, //no boolean operation
172  0); //copy number
173 
174  // Container
175  //
176  G4Tubs*
177  sContain = new G4Tubs("Container", //name
178  0., ContainRadius, 0.5*ContainLength, 0., twopi); //dimensions
179 
180  fLContain = new G4LogicalVolume(sContain, //shape
181  fContainMaterial, //material
182  fContainMaterial->GetName()); //name
183 
184  new G4PVPlacement(0, //no rotation
185  G4ThreeVector(), //at (0,0,0)
186  fLContain, //logical volume
187  fContainMaterial->GetName(), //name
188  lWorld, //mother volume
189  false, //no boolean operation
190  0); //copy number
191 
192  // Absorber
193  //
194  G4Tubs*
195  sAbsor = new G4Tubs("Absorber", //name
196  0., fAbsorRadius, 0.5*fAbsorLength, 0., twopi); //dimensions
197 
198  fLAbsor = new G4LogicalVolume(sAbsor, //shape
199  fAbsorMaterial, //material
200  fAbsorMaterial->GetName()); //name
201 
202  new G4PVPlacement(0, //no rotation
203  G4ThreeVector(), //at (0,0,0)
204  fLAbsor, //logical volume
205  fAbsorMaterial->GetName(), //name
206  fLContain, //mother volume
207  false, //no boolean operation
208  0); //copy number
209 
210  PrintParameters();
211 
212  //always return the root volume
213  //
214  return fPWorld;
215 }
216 
217 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
218 
220 {
221  G4cout << "\n The Absorber is a cylinder of " << fAbsorMaterial->GetName()
222  << " radius = " << G4BestUnit(fAbsorRadius,"Length")
223  << " length = " << G4BestUnit(fAbsorLength,"Length") << G4endl;
224  G4cout << " The Container is a cylinder of " << fContainMaterial->GetName()
225  << " thickness = " << G4BestUnit(fContainThickness,"Length") << G4endl;
226 
227  G4cout << "\n" << fAbsorMaterial << G4endl;
228  G4cout << "\n" << fContainMaterial << G4endl;
229 }
230 
231 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
232 
234 {
235  // search the material by its name
236  G4Material* pttoMaterial =
237  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
238 
239  if (pttoMaterial) {
240  fAbsorMaterial = pttoMaterial;
243  } else {
244  G4cout << "\n--> warning from DetectorConstruction::SetAbsorMaterial : "
245  << materialChoice << " not found" << G4endl;
246  }
247 }
248 
249 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
250 
252 {
253  // search the material by its name
254  G4Material* pttoMaterial =
255  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
256 
257  if (pttoMaterial) {
258  fContainMaterial = pttoMaterial;
261  } else {
262  G4cout << "\n--> warning from DetectorConstruction::SetContainMaterial : "
263  << materialChoice << " not found" << G4endl;
264  }
265 }
266 
267 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
268 
270 {
273 }
274 
275 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
276 
278 {
281 }
282 
283 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
284 
286 {
287  fContainThickness = value;
289 }
290 
291 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
292 
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
const XML_Char * name
Definition: expat.h:151
static void Clean()
Definition: G4SolidStore.cc:73
CLHEP::Hep3Vector G4ThreeVector
static constexpr double mm
Definition: G4SIunits.hh:115
Definition: G4Tubs.hh:85
#define G4endl
Definition: G4ios.hh:61
static constexpr double perCent
Definition: G4SIunits.hh:332
const G4String & GetName() const
Definition: G4Material.hh:179
void AddIsotope(G4Isotope *isotope, G4double RelativeAbundance)
Definition: G4Element.cc:152
Float_t Z
static constexpr double g
Definition: G4SIunits.hh:183
double G4double
Definition: G4Types.hh:76
**D E S C R I P T I O N
const XML_Char int const XML_Char * value
Definition: expat.h:331
static constexpr double mg
Definition: G4SIunits.hh:184
static G4GeometryManager * GetInstance()
Definition: G4Box.hh:64
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
static constexpr double twopi
Definition: G4SIunits.hh:76
double A(double temperature)
void OpenGeometry(G4VPhysicalVolume *vol=0)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
static G4SolidStore * GetInstance()
static G4PhysicalVolumeStore * GetInstance()
int G4int
Definition: G4Types.hh:78
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:368
void PhysicsHasBeenModified()
G4GLOB_DLL std::ostream G4cout
void SetMaterial(G4Material *pMaterial)
static constexpr double mole
Definition: G4SIunits.hh:286
static constexpr double cm3
Definition: G4SIunits.hh:121
static G4LogicalVolumeStore * GetInstance()
static G4NistManager * Instance()
G4Material * MaterialWithSingleIsotope(G4String, G4String, G4double, G4int, G4int)