Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/physicslists/factory/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 //
26 // $Id: DetectorConstruction 101905 2016-12-07 11:34:39Z gunter $
27 //
30 
31 #include "DetectorConstruction.hh"
32 #include "ScreenSD.hh"
33 
34 #include "G4Material.hh"
35 #include "G4NistManager.hh"
36 #include "G4Box.hh"
37 #include "G4LogicalVolume.hh"
38 #include "G4PVPlacement.hh"
40 #include "G4SDManager.hh"
41 
42 #include "G4VisAttributes.hh"
43 #include "G4Colour.hh"
44 #include "G4SystemOfUnits.hh"
45 #include "G4AutoDelete.hh"
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
56 {}
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61 {}
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64 
66 {
67  // Get nist material manager
68  G4NistManager* nistManager = G4NistManager::Instance();
69 
70  // Build materials
71  G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
72  G4Material* csi = nistManager->FindOrBuildMaterial("G4_CESIUM_IODIDE");
73  // There is no need to test if materials were built/found
74  // as G4NistManager would issue an error otherwise
75  // Try the code with "XYZ".
76 
77  // Print all materials
79 
80  // Option to switch on/off checking of volumes overlaps
81  G4bool checkOverlaps = true;
82 
83  //
84  // World
85  //
86 
87  // The world dimensions
88  G4double worldHxyz = 2.*m;
89 
90  // world volume
91  G4Box* worldS = new G4Box("World", worldHxyz, worldHxyz, worldHxyz);
92 
93  G4LogicalVolume* worldLV = new G4LogicalVolume(worldS, air, "World");
94 
95  G4VPhysicalVolume* worldPV
96  = new G4PVPlacement(
97  0, G4ThreeVector(), worldLV, "World", 0, false, 0, checkOverlaps);
98 
99  //
100  // Box
101  //
102 
103  // The box dimensions
104  G4double boxHxy = 1.*m;
105  G4double boxHz = 10.*cm;
106 
107  // box volume
108  G4Box* boxS = new G4Box("World", boxHxy, boxHxy, boxHz);
109 
110  G4LogicalVolume* boxLV = new G4LogicalVolume(boxS, csi, "Box");
111 
112  // The box position
113  G4double posz = 0.*m;
114 
115  new G4PVPlacement(
116  0, G4ThreeVector(0, 0, posz),
117  boxLV, "Box", worldLV, false, 0, checkOverlaps);
118 
119  //
120  // Scoring screen
121  //
122  // The screen dimensions
123  G4double screenHxy = 1.999*m;
124  G4double screenHz = 1.*mm;
125 
126  // Screen volume
127  G4Box* screenS = new G4Box("World", screenHxy, screenHxy, screenHz);
128 
129  G4LogicalVolume* screenLV = new G4LogicalVolume(screenS, air, "Screen");
130 
131  // The screen position
132  posz += boxHz + screenHz;
133 
134  new G4PVPlacement(
135  0, G4ThreeVector(0, 0, posz),
136  screenLV, "Screen", worldLV, false, 0, checkOverlaps);
137 
138  //
139  // Visualization attributes
140  //
142 
143  auto simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
144  simpleBoxVisAtt->SetVisibility(true);
145  boxLV->SetVisAttributes(simpleBoxVisAtt);
146  screenLV->SetVisAttributes(simpleBoxVisAtt);
147 
148  //
149  // Always return the physical World
150  //
151  return worldPV;
152 }
153 
154 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
155 
157 {
158  // G4SDManager::GetSDMpointer()->SetVerboseLevel(1);
159 
160  //
161  // Sensitive detectors
162  //
163  auto screenSD = new ScreenSD("ScreenSD");
165  SetSensitiveDetector("Screen", screenSD);
166 
167  //
168  // Magnetic field
169  //
170  // Create global magnetic field messenger.
171  // Uniform magnetic field is then created automatically if
172  // the field value is not zero.
173  G4ThreeVector fieldValue;
176 
177  // Register the field messenger for deleting
179 }
180 
181 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
CLHEP::Hep3Vector G4ThreeVector
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:593
static constexpr double mm
Definition: G4SIunits.hh:115
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:71
#define G4endl
Definition: G4ios.hh:61
void SetVerboseLevel(G4int verboseLevel)
#define G4ThreadLocal
Definition: tls.hh:69
void Register(T *inst)
Definition: G4AutoDelete.hh:65
static const G4VisAttributes & GetInvisible()
static constexpr double m
Definition: G4SIunits.hh:129
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
Definition: G4Box.hh:64
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
void SetVisAttributes(const G4VisAttributes *pVA)
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
static constexpr double cm
Definition: G4SIunits.hh:119
G4GLOB_DLL std::ostream G4cout
static G4NistManager * Instance()