Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/hadronic/Hadr02/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 109656 2018-05-04 09:00:14Z 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 "G4SDManager.hh"
65 #include "HistoManager.hh"
66 #include "G4NistManager.hh"
67 
68 #include "G4PhysicalConstants.hh"
69 #include "G4SystemOfUnits.hh"
70 
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 
76  fRadius(10.*cm),
77  fTargetMaterial(0),
78  fWorldMaterial(0),
79  fTargetSD(0),
80  fLogicTarget(0),
81  fLogicWorld (0),
82  fDetectorMessenger(0)
83 
84 {
86 
92 
93  // Prepare sensitive detectors
94  fTargetSD = new TargetSD("targetSD");
96 }
97 
98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
99 
101 {
102  delete fDetectorMessenger;
103 }
104 
106 {
107  // Cleanup old geometry
112 
113  // Sizes
114  G4double checkR = fRadius + mm;
115  G4double worldR = fRadius + cm;
116  G4double targetZ = HistoManager::GetPointer()->Length()*0.5;
117  G4double checkZ = targetZ + mm;
118  G4double worldZ = targetZ + cm;
119 
121  G4double sliceZ = targetZ/G4double(nSlices);
122 
123  //
124  // World
125  G4Tubs* solidW = new G4Tubs("World",0.,worldR,worldZ,0.,twopi);
126  fLogicWorld = new G4LogicalVolume( solidW,fWorldMaterial,"World");
128  fLogicWorld,"World",0,false,0);
129  //
130  // Check volume
131  //
132  G4Tubs* solidC = new G4Tubs("Check",0.,checkR,checkZ,0.,twopi);
133  G4LogicalVolume* logicCheck
134  = new G4LogicalVolume( solidC,fWorldMaterial,"World");
135  new G4PVPlacement(0,G4ThreeVector(),logicCheck,"World",fLogicWorld,false,0);
136 
137  //
138  // Target volume
139  //
140  G4Tubs* solidA = new G4Tubs("Target",0.,fRadius,sliceZ,0.,twopi);
141  fLogicTarget = new G4LogicalVolume( solidA,fTargetMaterial,"Target");
143 
144  G4double z = sliceZ - targetZ;
145 
146  for(G4int i=0; i<nSlices; i++) {
147  // physC =
148  new G4PVPlacement(0,G4ThreeVector(0.0,0.0,z),fLogicTarget,
149  "Target",logicCheck,false,i);
150  z += 2.0*sliceZ;
151  }
152  G4cout << "### Target consist of " << nSlices
153  << " of " << fTargetMaterial->GetName()
154  << " disks with R(mm)= " << fRadius/mm
155  << " Width(mm)= " << 2.0*sliceZ/mm
156  << " Total Length(mm)= " << 2.0*targetZ/mm
157  << " ###" << G4endl;
158 
159  // colors
162 
163  G4VisAttributes regWcolor(G4Colour(0.3, 0.3, 0.3));
164  logicCheck->SetVisAttributes(regWcolor);
165 
166  G4VisAttributes regCcolor(G4Colour(0., 0.3, 0.7));
167  fLogicTarget->SetVisAttributes(regCcolor);
168 
169  G4cout << *(G4Material::GetMaterialTable()) << G4endl;
170 
171  return world;
172 }
173 
174 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
175 
177 {
178  // search the material by its name
180 
181  if (material && material != fTargetMaterial) {
183  fTargetMaterial = material;
186  }
187 }
188 
189 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
190 
192 {
193  // search the material by its name
195 
196  if (material && material != fWorldMaterial) {
197  fWorldMaterial = material;
200  }
201 }
202 
203 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
204 
206 {
207  if(val > 0.0) {
208  fRadius = val;
210  }
211 }
212 
213 //....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
Definition: G4Tubs.hh:85
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:71
#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)
double G4double
Definition: G4Types.hh:76
static G4GeometryManager * GetInstance()
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
static constexpr double twopi
Definition: G4SIunits.hh:76
Float_t mat
void OpenGeometry(G4VPhysicalVolume *vol=0)
void SetVisAttributes(const G4VisAttributes *pVA)
void GeometryHasBeenModified(G4bool prop=true)
static G4SolidStore * GetInstance()
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
static G4PhysicalVolumeStore * GetInstance()
int G4int
Definition: G4Types.hh:78
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()
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)