Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/electromagnetic/TestEm11/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 98749 2016-08-09 13:43:36Z 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  for (G4int iAbs=0; iAbs<kMaxAbsor; iAbs++) {
71  fNbOfDivisions[iAbs] = 1;
72  }
74 
75  // materials
77  SetAbsorMaterial(1,"G4_Si");
78 
79  // create commands for interactive definition of the calorimeter
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
84 
86 {
87  delete fDetectorMessenger;
88 }
89 
90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
91 
93 {
94  return ConstructVolumes();
95 }
96 
97 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
98 
100 {
102 
103  man->FindOrBuildMaterial("G4_Al");
104  man->FindOrBuildMaterial("G4_Si");
105  man->FindOrBuildMaterial("G4_Fe");
106  man->FindOrBuildMaterial("G4_Cu");
107  man->FindOrBuildMaterial("G4_Ge");
108  man->FindOrBuildMaterial("G4_Mo");
109  man->FindOrBuildMaterial("G4_Ta");
110  man->FindOrBuildMaterial("G4_W");
111  man->FindOrBuildMaterial("G4_Au");
112  man->FindOrBuildMaterial("G4_Pb");
113  man->FindOrBuildMaterial("G4_PbWO4");
114  man->FindOrBuildMaterial("G4_SODIUM_IODIDE");
115 
116  man->FindOrBuildMaterial("G4_AIR");
117  man->FindOrBuildMaterial("G4_WATER");
118 
119  G4Element* H = man->FindOrBuildElement("H");
120  G4Element* O = man->FindOrBuildElement("O");
121 
122  G4Material* H2O =
123  new G4Material("Water", 1.000*g/cm3, 2);
124  H2O->AddElement(H, 2);
125  H2O->AddElement(O, 1);
127 
128  G4double density = universe_mean_density; //from PhysicalConstants.h
129  G4double pressure = 3.e-18*pascal;
130  G4double temperature = 2.73*kelvin;
131  G4Material* Galactic =
132  new G4Material("Galactic", 1., 1.008*g/mole, density,
133  kStateGas,temperature,pressure);
134 
135  fDefaultMaterial = Galactic;
136 
137  // G4cout << *(G4Material::GetMaterialTable()) << G4endl;
138 }
139 
140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
141 
143 {
144  // Compute total thickness of absorbers
145  fAbsorSizeX = 0.;
146  for (G4int iAbs=1; iAbs<=fNbOfAbsor; iAbs++) {
147  fAbsorSizeX += fAbsorThickness[iAbs];
148  }
149 }
150 
151 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
152 
154 {
155  // complete the Calor parameters definition
157 
158  // Cleanup old geometry
163 
164  //
165  // World
166  //
167  G4Box* solidWorld =
168  new G4Box("World", //name
169  fAbsorSizeX/2,fAbsorSizeYZ/2,fAbsorSizeYZ/2); //size
170 
171  G4LogicalVolume* logicWorld =
172  new G4LogicalVolume(solidWorld, //solid
173  fDefaultMaterial, //material
174  "World"); //name
175 
176  fPhysiWorld =
177  new G4PVPlacement(0, //no rotation
178  G4ThreeVector(), //at (0,0,0)
179  logicWorld, //logical volume
180  "World", //name
181  0, //mother volume
182  false, //no boolean operation
183  0); //copy number
184 
185  //
186  // Absorbers
187  //
188  fXfront[0] = -0.5*fAbsorSizeX;
189  //
190  for (G4int k=1; k<=fNbOfAbsor; k++) {
191  G4Material* material = fAbsorMaterial[k];
192  G4String matname = material->GetName();
193 
194  G4Box* solidAbsor =
195  new G4Box(matname,fAbsorThickness[k]/2,fAbsorSizeYZ/2,fAbsorSizeYZ/2);
196 
197  G4LogicalVolume* logicAbsor =
198  new G4LogicalVolume(solidAbsor, // solid
199  material, // material
200  matname); // name
201 
202  fXfront[k] = fXfront[k-1] + fAbsorThickness[k-1];
203  G4double xcenter = fXfront[k]+0.5*fAbsorThickness[k];
204  G4ThreeVector position = G4ThreeVector(xcenter,0.,0.);
205 
206  new G4PVPlacement(0, //no rotation
207  position, //position
208  logicAbsor, //logical volume
209  matname, //name
210  logicWorld, //mother
211  false, //no boulean operat
212  k); //copy number
213 
214  // divisions, if any
215  //
216  G4double LayerThickness = fAbsorThickness[k]/fNbOfDivisions[k];
217  G4Box* solidLayer =
218  new G4Box(matname,LayerThickness/2,fAbsorSizeYZ/2,fAbsorSizeYZ/2);
219 
220  G4LogicalVolume* logicLayer =
221  new G4LogicalVolume(solidLayer, //solid
222  material, //material
223  matname); //name
224 
225  new G4PVReplica(matname, //name
226  logicLayer, //logical volume
227  logicAbsor, //mother
228  kXAxis, //axis of replication
229  fNbOfDivisions[k], //number of replica
230  LayerThickness); //witdth of replica
231  }
232 
233  PrintParameters();
234 
235  //always return the physical World
236  //
237  return fPhysiWorld;
238 }
239 
240 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
241 
243 {
244  G4cout << "\n-------------------------------------------------------------"
245  << "\n ---> The Absorber is " << fNbOfAbsor << " layers of:";
246  for (G4int i=1; i<=fNbOfAbsor; i++)
247  {
248  G4cout << "\n \t" << std::setw(12) << fAbsorMaterial[i]->GetName() <<": "
249  << std::setw(6) << G4BestUnit(fAbsorThickness[i],"Length")
250  << " divided in " << fNbOfDivisions[i] << " slices";
251  }
252  G4cout << "\n-------------------------------------------------------------\n"
253  << G4endl;
254 }
255 
256 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
257 
259 {
260  // set the number of Absorbers
261  //
262  if (ival < 1 || ival > (kMaxAbsor-1))
263  { G4cout << "\n ---> warning from SetfNbOfAbsor: "
264  << ival << " must be at least 1 and and most " << kMaxAbsor-1
265  << ". Command refused" << G4endl;
266  return;
267  }
268  fNbOfAbsor = ival;
270 }
271 
272 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
273 
275 {
276  // search the material by its name
277  //
278  if (iabs > fNbOfAbsor || iabs <= 0)
279  { G4cout << "\n --->warning from SetfAbsorMaterial: absor number "
280  << iabs << " out of range. Command refused" << G4endl;
281  return;
282  }
283 
284  G4Material* pttoMaterial =
286  if (pttoMaterial) {
287  fAbsorMaterial[iabs] = pttoMaterial;
289  }
290 }
291 
292 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
293 
295 {
296  // change Absorber thickness
297  //
298  if (iabs > fNbOfAbsor || iabs <= 0)
299  { G4cout << "\n --->warning from SetfAbsorThickness: absor number "
300  << iabs << " out of range. Command refused" << G4endl;
301  return;
302  }
303  if (val <= DBL_MIN)
304  { G4cout << "\n --->warning from SetfAbsorThickness: thickness "
305  << val << " out of range. Command refused" << G4endl;
306  return;
307  }
308  fAbsorThickness[iabs] = val;
310 }
311 
312 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
313 
315 {
316  // change the transverse size
317  //
318  if (val <= DBL_MIN)
319  { G4cout << "\n --->warning from SetfAbsorSizeYZ: thickness "
320  << val << " out of range. Command refused" << G4endl;
321  return;
322  }
323  fAbsorSizeYZ = val;
325 }
326 
327 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
328 
330 {
331  // set the number of divisions
332  //
333  if (iabs > fNbOfAbsor || iabs < 1)
334  { G4cout << "\n --->warning from SetNbOfDivisions: absor number "
335  << iabs << " out of range. Command refused" << G4endl;
336  return;
337  }
338 
339  if (ival < 1)
340  { G4cout << "\n --->warning from SetNbOfDivisions: "
341  << ival << " must be at least 1. Command refused" << G4endl;
342  return;
343  }
344  fNbOfDivisions[iabs] = ival;
346 }
347 
348 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
349 
351 {
352  if ( fFieldMessenger.Get() == 0 ) {
353  // Create global magnetic field messenger.
354  // Uniform magnetic field is then created automatically if
355  // the field value is not zero.
356  G4ThreeVector fieldValue = G4ThreeVector();
358  new G4GlobalMagFieldMessenger(fieldValue);
359  //msg->SetVerboseLevel(1);
361  fFieldMessenger.Put( msg );
362  }
363 }
364 
365 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
366 
static constexpr double kelvin
Definition: G4SIunits.hh:281
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
static void Clean()
Definition: G4SolidStore.cc:73
CLHEP::Hep3Vector G4ThreeVector
static constexpr double mm
Definition: G4SIunits.hh:115
#define G4endl
Definition: G4ios.hh:61
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
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)
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()