Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/hadronic/Hadr01/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 109654 2018-05-04 08:57:00Z gcosmo $
30 //
32 //
33 // DetectorConstruction
34 //
35 // Created: 31.01.2003 V.Ivanchenko
36 //
37 // Modified:
38 // 04.06.2006 Adoptation of Hadr01 (V.Ivanchenko)
39 //
41 //
42 
43 #include "DetectorConstruction.hh"
44 #include "DetectorMessenger.hh"
45 
46 #include "G4Tubs.hh"
47 #include "G4LogicalVolume.hh"
48 #include "G4PVPlacement.hh"
49 
50 #include "G4RunManager.hh"
51 
52 #include "G4GeometryManager.hh"
53 #include "G4PhysicalVolumeStore.hh"
54 #include "G4LogicalVolumeStore.hh"
55 #include "G4SolidStore.hh"
56 
57 #include "G4VisAttributes.hh"
58 #include "G4Colour.hh"
59 
60 #include "G4UnitsTable.hh"
61 #include "G4ios.hh"
62 
63 #include "TargetSD.hh"
64 #include "CheckVolumeSD.hh"
65 #include "G4SDManager.hh"
66 #include "HistoManager.hh"
67 #include "G4NistManager.hh"
68 
69 #include "G4PhysicalConstants.hh"
70 #include "G4SystemOfUnits.hh"
71 
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74 
77  fTargetMaterial(nullptr),
78  fWorldMaterial(nullptr),
79  fSolidW(nullptr),
80  fSolidA(nullptr),
81  fSolidC(nullptr),
82  fLogicTarget(nullptr),
83  fLogicCheck(nullptr),
84  fLogicWorld(nullptr),
85  fPhysWorld(nullptr),
86  fInitialized(false)
87 {
89 
90  fRadius = 10.*cm;
91 
96 }
97 
98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
99 
101 {
102  delete fDetectorMessenger;
103 }
104 
106 {
107  // Sizes
113 
116  if(fPhysWorld) {
123  }
124 }
125 
127 {
128  if(fPhysWorld) { return fPhysWorld; }
130 
131  //
132  // World
133  //
134  fSolidW = new G4Tubs("World",0.,fWorldR,fWorldZ,0.,twopi);
136  fPhysWorld = new G4PVPlacement(nullptr,G4ThreeVector(0.,0.,0.),
137  fLogicWorld,"World",nullptr,false,0);
138  //
139  // Check volume
140  //
141  fSolidC = new G4Tubs("Check",0.,fCheckR,fCheckZ,0.,twopi);
143  new G4PVPlacement(nullptr,G4ThreeVector(),fLogicCheck,"Check",
144  fLogicWorld,false,0);
145 
146  //
147  // Target volume
148  //
149  fSolidA = new G4Tubs("Target",0.,fRadius,fSliceZ,0.,twopi);
151 
153 
154  for(G4int i=0; i<fSlices; ++i) {
155  // physC =
156  new G4PVPlacement(nullptr,G4ThreeVector(0.0,0.0,z),fLogicTarget,"Target",
157  fLogicCheck,false,i);
158  z += 2.0*fSliceZ;
159  }
160  G4cout << "### Target consist of " << fSlices
161  << " of " << fTargetMaterial->GetName()
162  << " disks with R(mm)= " << fRadius/mm
163  << " Width(mm)= " << 2.0*fSliceZ/mm
164  << " Total Length(mm)= " << 2.0*fTargetZ/mm
165  << " ###" << G4endl;
166 
167  // colors
170 
171  G4VisAttributes regWcolor(G4Colour(0.3, 0.3, 0.3));
172  fLogicCheck->SetVisAttributes(regWcolor);
173 
174  G4VisAttributes regCcolor(G4Colour(0., 0.3, 0.7));
175  fLogicTarget->SetVisAttributes(regCcolor);
176 
177  G4cout << *(G4Material::GetMaterialTable()) << G4endl;
178 
179  return fPhysWorld;
180 }
181 
183 {
184  if (!fInitialized) {
185  // Prepare sensitive detectors
186  CheckVolumeSD* fCheckSD = new CheckVolumeSD("checkSD");
187  (G4SDManager::GetSDMpointer())->AddNewDetector( fCheckSD );
189 
190  TargetSD* fTargetSD = new TargetSD("targetSD");
191  (G4SDManager::GetSDMpointer())->AddNewDetector( fTargetSD );
193  fInitialized = true;
194  }
195 }
196 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
197 
199 {
200  // search the material by its name
202 
203  if (material && material != fTargetMaterial) {
204  fTargetMaterial = material;
207  }
208 }
209 
210 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
211 
213 {
214  // search the material by its name
216 
217  if (material && material != fWorldMaterial) {
218  fWorldMaterial = material;
221  }
222 }
223 
224 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
225 
227 {
228  if(val > 0.0) {
229  fRadius = val;
231  }
232 }
233 
234 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
CLHEP::Hep3Vector G4ThreeVector
void SetOuterRadius(G4double newRMax)
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:593
static constexpr double mm
Definition: G4SIunits.hh:115
Definition: G4Tubs.hh:85
#define G4endl
Definition: G4ios.hh:61
Double_t z
static const G4VisAttributes & GetInvisible()
const G4String & GetName() const
Definition: G4Material.hh:179
void SetWorldMaterial(const G4String &materialName)
static constexpr double cm
Definition: SystemOfUnits.h:99
double G4double
Definition: G4Types.hh:76
void SetZHalfLength(G4double newDz)
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
static constexpr double twopi
Definition: G4SIunits.hh:76
Float_t mat
void SetVisAttributes(const G4VisAttributes *pVA)
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
int G4int
Definition: G4Types.hh:78
static constexpr double mm
Definition: SystemOfUnits.h:95
void PhysicsHasBeenModified()
G4GLOB_DLL std::ostream G4cout
static constexpr double cm
Definition: G4SIunits.hh:119
void SetMaterial(G4Material *pMaterial)
static G4NistManager * Instance()
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)