Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/analysis/shared/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 //
30 // $Id: DetectorConstruction.cc 101905 2016-12-07 11:34:39Z gunter $
31 //
32 //
33 
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
36 
37 #include "DetectorConstruction.hh"
38 #include "DetectorMessenger.hh"
39 
40 #include "G4Material.hh"
41 #include "G4NistManager.hh"
42 
43 #include "G4Box.hh"
44 #include "G4LogicalVolume.hh"
45 #include "G4PVPlacement.hh"
46 #include "G4PVReplica.hh"
47 
48 #include "G4GeometryManager.hh"
49 #include "G4PhysicalVolumeStore.hh"
50 #include "G4LogicalVolumeStore.hh"
51 #include "G4SolidStore.hh"
52 
53 #include "G4VisAttributes.hh"
54 #include "G4Colour.hh"
55 #include "G4SystemOfUnits.hh"
56 #include "G4RunManager.hh"
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
62  fAbsorberMaterial(0),fGapMaterial(0),fDefaultMaterial(0),
63  fSolidWorld(0),fLogicWorld(0),fPhysiWorld(0),
64  fSolidCalor(0),fLogicCalor(0),fPhysiCalor(0),
65  fSolidLayer(0),fLogicLayer(0),fPhysiLayer(0),
66  fSolidAbsorber(0),fLogicAbsorber(0),fPhysiAbsorber(0),
67  fSolidGap (0),fLogicGap (0),fPhysiGap (0),
68  fDetectorMessenger(0)
69 {
70  // default parameter values of the calorimeter
71  fAbsorberThickness = 10.*mm;
72  fGapThickness = 5.*mm;
73  fNbOfLayers = 10;
74  fCalorSizeYZ = 10.*cm;
76 
77  // materials
79  SetAbsorberMaterial("G4_Pb");
80  SetGapMaterial("G4_lAr");
81 
82  // create commands for interactive definition of the calorimeter
84 }
85 
86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
87 
89 { delete fDetectorMessenger;}
90 
91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
92 
94 {
95  return ConstructCalorimeter();
96 }
97 
98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
99 
101 {
102 // use G4-NIST materials data base
103 //
105 fDefaultMaterial = man->FindOrBuildMaterial("G4_Galactic");
106 man->FindOrBuildMaterial("G4_Pb");
107 man->FindOrBuildMaterial("G4_lAr");
108 
109 // print table
110 //
112 }
113 
114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
115 
117 {
118 
119  // Clean old geometry, if any
120  //
125 
126  // complete the Calor parameters definition
128 
129  //
130  // World
131  //
132  fSolidWorld = new G4Box("World", //its name
133  fWorldSizeX/2,fWorldSizeYZ/2,fWorldSizeYZ/2); //its size
134 
135  fLogicWorld = new G4LogicalVolume(fSolidWorld, //its solid
136  fDefaultMaterial, //its material
137  "World"); //its name
138 
139  fPhysiWorld = new G4PVPlacement(0, //no rotation
140  G4ThreeVector(), //at (0,0,0)
141  fLogicWorld, //its logical volume
142  "World", //its name
143  0, //its mother volume
144  false, //no boolean operation
145  0); //copy number
146 
147  //
148  // Calorimeter
149  //
152 
153  if (fCalorThickness > 0.)
154  { fSolidCalor = new G4Box("Calorimeter", //its name
156 
157  fLogicCalor = new G4LogicalVolume(fSolidCalor, //its solid
158  fDefaultMaterial, //its material
159  "Calorimeter"); //its name
160 
161  fPhysiCalor = new G4PVPlacement(0, //no rotation
162  G4ThreeVector(), //at (0,0,0)
163  fLogicCalor, //its logical volume
164  "Calorimeter", //its name
165  fLogicWorld, //its mother volume
166  false, //no boolean operation
167  0); //copy number
168 
169  //
170  // Layer
171  //
172  fSolidLayer = new G4Box("Layer", //its name
174 
175  fLogicLayer = new G4LogicalVolume(fSolidLayer, //its solid
176  fDefaultMaterial, //its material
177  "Layer"); //its name
178  if (fNbOfLayers > 1)
179  fPhysiLayer = new G4PVReplica("Layer", //its name
180  fLogicLayer, //its logical volume
181  fLogicCalor, //its mother
182  kXAxis, //axis of replication
183  fNbOfLayers, //number of replica
184  fLayerThickness); //witdth of replica
185  else
186  fPhysiLayer = new G4PVPlacement(0, //no rotation
187  G4ThreeVector(), //at (0,0,0)
188  fLogicLayer, //its logical volume
189  "Layer", //its name
190  fLogicCalor, //its mother volume
191  false, //no boolean operation
192  0); //copy number
193  }
194 
195  //
196  // Absorber
197  //
199 
200  if (fAbsorberThickness > 0.)
201  { fSolidAbsorber = new G4Box("Absorber", //its name
203 
205  fAbsorberMaterial, //its material
206  fAbsorberMaterial->GetName());//name
207 
208  fPhysiAbsorber = new G4PVPlacement(0, //no rotation
209  G4ThreeVector(-fGapThickness/2,0.,0.), //its position
210  fLogicAbsorber, //its logical volume
211  fAbsorberMaterial->GetName(), //its name
212  fLogicLayer, //its mother
213  false, //no boulean operat
214  0); //copy number
215 
216  }
217 
218  //
219  // Gap
220  //
221  fSolidGap=0; fLogicGap=0; fPhysiGap=0;
222 
223  if (fGapThickness > 0.)
224  { fSolidGap = new G4Box("Gap",
226 
228  fGapMaterial,
229  fGapMaterial->GetName());
230 
231  fPhysiGap = new G4PVPlacement(0, //no rotation
232  G4ThreeVector(fAbsorberThickness/2,0.,0.), //its position
233  fLogicGap, //its logical volume
234  fGapMaterial->GetName(), //its name
235  fLogicLayer, //its mother
236  false, //no boulean operat
237  0); //copy number
238  }
239 
241 
242  //
243  // Visualization attributes
244  //
246 
247  G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
248  simpleBoxVisAtt->SetVisibility(true);
249  fLogicCalor->SetVisAttributes(simpleBoxVisAtt);
250 
251  //
252  //always return the physical World
253  //
254  return fPhysiWorld;
255 }
256 
257 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
258 
260 {
261  G4cout << "\n------------------------------------------------------------"
262  << "\n---> The calorimeter is " << fNbOfLayers << " layers of: [ "
263  << fAbsorberThickness/mm << "mm of " << fAbsorberMaterial->GetName()
264  << " + "
265  << fGapThickness/mm << "mm of " << fGapMaterial->GetName() << " ] "
266  << "\n------------------------------------------------------------\n";
267 }
268 
269 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
270 
272 {
273  // search the material by its name
274  G4Material* pttoMaterial =
275  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
276  if (pttoMaterial)
277  {
278  fAbsorberMaterial = pttoMaterial;
279  if ( fLogicAbsorber )
280  {
283  }
284  }
285 }
286 
287 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
288 
290 {
291  // search the material by its name
292  G4Material* pttoMaterial =
293  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
294  if (pttoMaterial)
295  {
296  fGapMaterial = pttoMaterial;
297  if ( fLogicGap )
298  {
301  }
302  }
303 }
304 
305 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
306 
308 {
309  // change Absorber thickness and recompute the calorimeter parameters
310  fAbsorberThickness = val;
312 }
313 
314 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
315 
317 {
318  // change Gap thickness and recompute the calorimeter parameters
319  fGapThickness = val;
321 }
322 
323 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
324 
326 {
327  // change the transverse size and recompute the calorimeter parameters
328  fCalorSizeYZ = val;
330 }
331 
332 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
333 
335 {
336  fNbOfLayers = val;
338 }
339 
340 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
static void Clean()
Definition: G4SolidStore.cc:73
CLHEP::Hep3Vector G4ThreeVector
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:593
static constexpr double mm
Definition: G4SIunits.hh:115
#define G4endl
Definition: G4ios.hh:61
static const G4VisAttributes & GetInvisible()
const G4String & GetName() const
Definition: G4Material.hh:179
double G4double
Definition: G4Types.hh:76
static G4GeometryManager * GetInstance()
Definition: G4Box.hh:64
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
void OpenGeometry(G4VPhysicalVolume *vol=0)
void SetVisAttributes(const G4VisAttributes *pVA)
static G4SolidStore * GetInstance()
void SetVisibility(G4bool=true)
static G4PhysicalVolumeStore * GetInstance()
int G4int
Definition: G4Types.hh:78
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
void PhysicsHasBeenModified()
G4GLOB_DLL std::ostream G4cout
static constexpr double cm
Definition: G4SIunits.hh:119
void SetMaterial(G4Material *pMaterial)
static G4LogicalVolumeStore * GetInstance()
static G4NistManager * Instance()