Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/hadronic/Hadr07/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 77288 2013-11-22 10:52:58Z gcosmo $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "DetectorConstruction.hh"
35 #include "DetectorMessenger.hh"
36 
37 #include "G4NistManager.hh"
38 #include "G4Material.hh"
39 #include "G4Box.hh"
40 #include "G4LogicalVolume.hh"
41 #include "G4PVPlacement.hh"
42 #include "G4PVReplica.hh"
43 #include "G4UniformMagField.hh"
44 
45 #include "G4GeometryManager.hh"
46 #include "G4PhysicalVolumeStore.hh"
47 #include "G4LogicalVolumeStore.hh"
48 #include "G4SolidStore.hh"
49 
50 #include "G4UImanager.hh"
51 #include "G4UnitsTable.hh"
52 #include "G4PhysicalConstants.hh"
53 #include "G4SystemOfUnits.hh"
55 #include "G4AutoDelete.hh"
56 #include "G4RunManager.hh"
57 #include <iomanip>
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60 
62 :G4VUserDetectorConstruction(),fDefaultMaterial(0),fPhysiWorld(0),
63  fDetectorMessenger(0)
64 {
65  // default parameter values of the absorbers
66  fNbOfAbsor = 1;
67  fAbsorThickness[0] = 0*mm; //dummy, for initialization
68  fAbsorThickness[1] = 1*mm;
69  fAbsorSizeYZ = 1*mm;
70 
72 
73  // materials
75  SetAbsorMaterial(1,"G4_Si");
76 
77  // create commands for interactive definition of the calorimeter
79 }
80 
81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82 
84 {
85  delete fDetectorMessenger;
86 }
87 
88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
89 
91 {
92  return ConstructVolumes();
93 }
94 
95 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
96 
98 {
100 
101  man->FindOrBuildMaterial("G4_AIR");
102 
103  G4Element* H = man->FindOrBuildElement("H");
104  G4Element* O = man->FindOrBuildElement("O");
105 
106  G4Material* H2O =
107  new G4Material("Water", 1.000*g/cm3, 2);
108  H2O->AddElement(H, 2);
109  H2O->AddElement(O, 1);
111 
112  G4Element* Hf = man->FindOrBuildElement("Hf");
113 
114  G4Material* HfO2 = new G4Material("HfO2", 9.68*g/cm3, 2);
115  HfO2->AddElement(Hf, 1);
116  HfO2->AddElement(O , 2);
117 
118  // example of vacuum
119  G4double density = universe_mean_density; //from PhysicalConstants.h
120  G4double pressure = 3.e-18*pascal;
121  G4double temperature = 2.73*kelvin;
122  G4Material* Galactic =
123  new G4Material("Galactic", 1., 1.008*g/mole, density,
124  kStateGas,temperature,pressure);
125 
126  fDefaultMaterial = Galactic;
127 
128  // G4cout << *(G4Material::GetMaterialTable()) << G4endl;
129 }
130 
131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
132 
134  G4String symbol, G4double density, G4int Z, G4int A)
135 {
136  // define a material from an isotope
137  //
138  G4int ncomponents;
139  G4double abundance, massfraction;
140 
141  G4Isotope* isotope = new G4Isotope(symbol, Z, A);
142 
143  G4Element* element = new G4Element(name, symbol, ncomponents=1);
144  element->AddIsotope(isotope, abundance= 100.*perCent);
145 
146  G4Material* material = new G4Material(name, density, ncomponents=1);
147  material->AddElement(element, massfraction=100.*perCent);
148 
149  return material;
150 }
151 
152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
153 
155 {
156  // Compute total thickness of absorbers
157  fAbsorSizeX = 0.;
158  for (G4int iAbs=1; iAbs<=fNbOfAbsor; iAbs++) {
159  fAbsorSizeX += fAbsorThickness[iAbs];
160  }
161  fWorldSizeX = 1.2*fAbsorSizeX;
163 }
164 
165 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
166 
168 {
169  // complete the Calor parameters definition
171 
172  // Cleanup old geometry
177 
178  //
179  // World
180  //
181  G4Box* solidWorld =
182  new G4Box("World", //name
183  fWorldSizeX/2,fWorldSizeYZ/2,fWorldSizeYZ/2); //size
184 
185  G4LogicalVolume* logicWorld =
186  new G4LogicalVolume(solidWorld, //solid
187  fDefaultMaterial, //material
188  "World"); //name
189 
190  fPhysiWorld =
191  new G4PVPlacement(0, //no rotation
192  G4ThreeVector(), //at (0,0,0)
193  logicWorld, //logical volume
194  "World", //name
195  0, //mother volume
196  false, //no boolean operation
197  0); //copy number
198 
199  //
200  // Absorbers
201  //
202  fXfront[0] = -0.5*fAbsorSizeX;
203  //
204  for (G4int k=1; k<=fNbOfAbsor; k++) {
205  G4Material* material = fAbsorMaterial[k];
206  G4String matname = material->GetName();
207 
208  G4Box* solidAbsor =
209  new G4Box(matname,fAbsorThickness[k]/2,fAbsorSizeYZ/2,fAbsorSizeYZ/2);
210 
211  G4LogicalVolume* logicAbsor =
212  new G4LogicalVolume(solidAbsor, // solid
213  material, // material
214  matname); // name
215 
216  fXfront[k] = fXfront[k-1] + fAbsorThickness[k-1];
217  G4double xcenter = fXfront[k]+0.5*fAbsorThickness[k];
218  G4ThreeVector position = G4ThreeVector(xcenter,0.,0.);
219 
220  new G4PVPlacement(0, //no rotation
221  position, //position
222  logicAbsor, //logical volume
223  matname, //name
224  logicWorld, //mother
225  false, //no boulean operat
226  k); //copy number
227  }
228 
229  PrintParameters();
230 
231  //always return the physical World
232  //
233  return fPhysiWorld;
234 }
235 
236 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
237 
239 {
240  G4cout << "\n-------------------------------------------------------------"
241  << "\n ---> The Absorber is " << fNbOfAbsor << " layers of:";
242  for (G4int i=1; i<=fNbOfAbsor; i++)
243  {
244  G4cout << "\n \t" << std::setw(12) << fAbsorMaterial[i]->GetName() <<": "
245  << std::setw(6) << G4BestUnit(fAbsorThickness[i],"Length");
246  }
247  G4cout << "\n-------------------------------------------------------------\n"
248  << G4endl;
249 }
250 
251 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
252 
254 {
255  // set the number of Absorbers
256  //
257  if (ival < 1 || ival > (kMaxAbsor-1))
258  { G4cout << "\n ---> warning from SetfNbOfAbsor: "
259  << ival << " must be at least 1 and and most " << kMaxAbsor-1
260  << ". Command refused" << G4endl;
261  return;
262  }
263  fNbOfAbsor = ival;
265 }
266 
267 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
268 
269 void DetectorConstruction::SetAbsorMaterial(G4int iabs,const G4String& material)
270 {
271  // search the material by its name
272  //
273  if (iabs > fNbOfAbsor || iabs <= 0)
274  { G4cout << "\n --->warning from SetfAbsorMaterial: absor number "
275  << iabs << " out of range. Command refused" << G4endl;
276  return;
277  }
278 
279  G4Material* pttoMaterial =
281  if (pttoMaterial) {
282  fAbsorMaterial[iabs] = pttoMaterial;
284  }
285 }
286 
287 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
288 
290 {
291  // change Absorber thickness
292  //
293  if (iabs > fNbOfAbsor || iabs <= 0)
294  { G4cout << "\n --->warning from SetfAbsorThickness: absor number "
295  << iabs << " out of range. Command refused" << G4endl;
296  return;
297  }
298  if (val <= DBL_MIN)
299  { G4cout << "\n --->warning from SetfAbsorThickness: thickness "
300  << val << " out of range. Command refused" << G4endl;
301  return;
302  }
303  fAbsorThickness[iabs] = val;
305 }
306 
307 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
308 
310 {
311  // change the transverse size
312  //
313  if (val <= DBL_MIN)
314  { G4cout << "\n --->warning from SetfAbsorSizeYZ: thickness "
315  << val << " out of range. Command refused" << G4endl;
316  return;
317  }
318  fAbsorSizeYZ = val;
320 }
321 
322 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
323 
325 {
326  if ( fFieldMessenger.Get() == 0 ) {
327  // Create global magnetic field messenger.
328  // Uniform magnetic field is then created automatically if
329  // the field value is not zero.
330  G4ThreeVector fieldValue = G4ThreeVector();
332  new G4GlobalMagFieldMessenger(fieldValue);
333  //msg->SetVerboseLevel(1);
335  fFieldMessenger.Put( msg );
336  }
337 }
338 
339 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
340 
static constexpr double kelvin
Definition: G4SIunits.hh:281
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
#define G4endl
Definition: G4ios.hh:61
static constexpr double perCent
Definition: G4SIunits.hh:332
void SetMeanExcitationEnergy(G4double value)
static constexpr double universe_mean_density
void Register(T *inst)
Definition: G4AutoDelete.hh:65
const G4String & GetName() const
Definition: G4Material.hh:179
void AddIsotope(G4Isotope *isotope, G4double RelativeAbundance)
Definition: G4Element.cc:152
Float_t Z
G4Element * FindOrBuildElement(G4int Z, G4bool isotopes=true)
static constexpr double g
Definition: G4SIunits.hh:183
double G4double
Definition: G4Types.hh:76
static G4GeometryManager * GetInstance()
Definition: G4Box.hh:64
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
double A(double temperature)
static constexpr double eV
Definition: G4SIunits.hh:215
value_type & Get() const
Definition: G4Cache.hh:314
void OpenGeometry(G4VPhysicalVolume *vol=0)
void Put(const value_type &val) const
Definition: G4Cache.hh:318
#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
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:227
#define DBL_MIN
Definition: templates.hh:75
void PhysicsHasBeenModified()
G4Cache< G4GlobalMagFieldMessenger * > fFieldMessenger
G4GLOB_DLL std::ostream G4cout
static constexpr double mole
Definition: G4SIunits.hh:286
#define pascal
static constexpr double cm3
Definition: G4SIunits.hh:121
static G4LogicalVolumeStore * GetInstance()
static G4NistManager * Instance()
G4Material * MaterialWithSingleIsotope(G4String, G4String, G4double, G4int, G4int)