Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
B3b/src/B3DetectorConstruction.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: B3DetectorConstruction.cc 101905 2016-12-07 11:34:39Z gunter $
27 //
30 
31 #include "B3DetectorConstruction.hh"
32 
33 #include "G4NistManager.hh"
34 #include "G4Box.hh"
35 #include "G4Tubs.hh"
36 #include "G4LogicalVolume.hh"
37 #include "G4PVPlacement.hh"
38 #include "G4RotationMatrix.hh"
39 #include "G4Transform3D.hh"
40 #include "G4SDManager.hh"
42 #include "G4VPrimitiveScorer.hh"
43 #include "G4PSEnergyDeposit.hh"
44 #include "G4PSDoseDeposit.hh"
45 #include "G4VisAttributes.hh"
46 #include "G4PhysicalConstants.hh"
47 #include "G4SystemOfUnits.hh"
48 
49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
50 
53  fCheckOverlaps(true)
54 {
56 }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61 { }
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64 
66 {
68 
69  G4bool isotopes = false;
70 
71  G4Element* O = man->FindOrBuildElement("O" , isotopes);
72  G4Element* Si = man->FindOrBuildElement("Si", isotopes);
73  G4Element* Lu = man->FindOrBuildElement("Lu", isotopes);
74 
75  G4Material* LSO = new G4Material("Lu2SiO5", 7.4*g/cm3, 3);
76  LSO->AddElement(Lu, 2);
77  LSO->AddElement(Si, 1);
78  LSO->AddElement(O , 5);
79 }
80 
81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82 
84 {
85  // Gamma detector Parameters
86  //
87  G4double cryst_dX = 6*cm, cryst_dY = 6*cm, cryst_dZ = 3*cm;
88  G4int nb_cryst = 32;
89  G4int nb_rings = 9;
90  //
91  G4double dPhi = twopi/nb_cryst, half_dPhi = 0.5*dPhi;
92  G4double cosdPhi = std::cos(half_dPhi);
93  G4double tandPhi = std::tan(half_dPhi);
94  //
95  G4double ring_R1 = 0.5*cryst_dY/tandPhi;
96  G4double ring_R2 = (ring_R1+cryst_dZ)/cosdPhi;
97  //
98  G4double detector_dZ = nb_rings*cryst_dX;
99  //
101  G4Material* default_mat = nist->FindOrBuildMaterial("G4_AIR");
102  G4Material* cryst_mat = nist->FindOrBuildMaterial("Lu2SiO5");
103 
104  //
105  // World
106  //
107  G4double world_sizeXY = 2.4*ring_R2;
108  G4double world_sizeZ = 1.2*detector_dZ;
109 
110  G4Box* solidWorld =
111  new G4Box("World", //its name
112  0.5*world_sizeXY, 0.5*world_sizeXY, 0.5*world_sizeZ); //its size
113 
114  G4LogicalVolume* logicWorld =
115  new G4LogicalVolume(solidWorld, //its solid
116  default_mat, //its material
117  "World"); //its name
118 
119  G4VPhysicalVolume* physWorld =
120  new G4PVPlacement(0, //no rotation
121  G4ThreeVector(), //at (0,0,0)
122  logicWorld, //its logical volume
123  "World", //its name
124  0, //its mother volume
125  false, //no boolean operation
126  0, //copy number
127  fCheckOverlaps); // checking overlaps
128 
129  //
130  // ring
131  //
132  G4Tubs* solidRing =
133  new G4Tubs("Ring", ring_R1, ring_R2, 0.5*cryst_dX, 0., twopi);
134 
135  G4LogicalVolume* logicRing =
136  new G4LogicalVolume(solidRing, //its solid
137  default_mat, //its material
138  "Ring"); //its name
139 
140  //
141  // define crystal
142  //
143  G4double gap = 0.5*mm; //a gap for wrapping
144  G4double dX = cryst_dX - gap, dY = cryst_dY - gap;
145  G4Box* solidCryst = new G4Box("crystal", dX/2, dY/2, cryst_dZ/2);
146 
147  G4LogicalVolume* logicCryst =
148  new G4LogicalVolume(solidCryst, //its solid
149  cryst_mat, //its material
150  "CrystalLV"); //its name
151 
152  // place crystals within a ring
153  //
154  for (G4int icrys = 0; icrys < nb_cryst ; icrys++) {
155  G4double phi = icrys*dPhi;
157  rotm.rotateY(90*deg);
158  rotm.rotateZ(phi);
159  G4ThreeVector uz = G4ThreeVector(std::cos(phi), std::sin(phi),0.);
160  G4ThreeVector position = (ring_R1+0.5*cryst_dZ)*uz;
161  G4Transform3D transform = G4Transform3D(rotm,position);
162 
163  new G4PVPlacement(transform, //rotation,position
164  logicCryst, //its logical volume
165  "crystal", //its name
166  logicRing, //its mother volume
167  false, //no boolean operation
168  icrys, //copy number
169  fCheckOverlaps); // checking overlaps
170  }
171 
172  //
173  // full detector
174  //
175  G4Tubs* solidDetector =
176  new G4Tubs("Detector", ring_R1, ring_R2, 0.5*detector_dZ, 0., twopi);
177 
178  G4LogicalVolume* logicDetector =
179  new G4LogicalVolume(solidDetector, //its solid
180  default_mat, //its material
181  "Detector"); //its name
182 
183  //
184  // place rings within detector
185  //
186  G4double OG = -0.5*(detector_dZ + cryst_dX);
187  for (G4int iring = 0; iring < nb_rings ; iring++) {
188  OG += cryst_dX;
189  new G4PVPlacement(0, //no rotation
190  G4ThreeVector(0,0,OG), //position
191  logicRing, //its logical volume
192  "ring", //its name
193  logicDetector, //its mother volume
194  false, //no boolean operation
195  iring, //copy number
196  fCheckOverlaps); // checking overlaps
197  }
198 
199  //
200  // place detector in world
201  //
202  new G4PVPlacement(0, //no rotation
203  G4ThreeVector(), //at (0,0,0)
204  logicDetector, //its logical volume
205  "Detector", //its name
206  logicWorld, //its mother volume
207  false, //no boolean operation
208  0, //copy number
209  fCheckOverlaps); // checking overlaps
210 
211  //
212  // patient
213  //
214  G4double patient_radius = 8*cm;
215  G4double patient_dZ = 10*cm;
216  G4Material* patient_mat = nist->FindOrBuildMaterial("G4_BRAIN_ICRP");
217 
218  G4Tubs* solidPatient =
219  new G4Tubs("Patient", 0., patient_radius, 0.5*patient_dZ, 0., twopi);
220 
221  G4LogicalVolume* logicPatient =
222  new G4LogicalVolume(solidPatient, //its solid
223  patient_mat, //its material
224  "PatientLV"); //its name
225 
226  //
227  // place patient in world
228  //
229  new G4PVPlacement(0, //no rotation
230  G4ThreeVector(), //at (0,0,0)
231  logicPatient, //its logical volume
232  "Patient", //its name
233  logicWorld, //its mother volume
234  false, //no boolean operation
235  0, //copy number
236  fCheckOverlaps); // checking overlaps
237 
238  // Visualization attributes
239  //
242 
243  // Print materials
245 
246  //always return the physical World
247  //
248  return physWorld;
249 }
250 
251 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
252 
254 {
256 
257  // declare crystal as a MultiFunctionalDetector scorer
258  //
261  G4VPrimitiveScorer* primitiv1 = new G4PSEnergyDeposit("edep");
262  cryst->RegisterPrimitive(primitiv1);
263  SetSensitiveDetector("CrystalLV",cryst);
264 
265  // declare patient as a MultiFunctionalDetector scorer
266  //
267  G4MultiFunctionalDetector* patient = new G4MultiFunctionalDetector("patient");
269  G4VPrimitiveScorer* primitiv2 = new G4PSDoseDeposit("dose");
270  patient->RegisterPrimitive(primitiv2);
271  SetSensitiveDetector("PatientLV",patient);
272 }
273 
274 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
CLHEP::Hep3Vector G4ThreeVector
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:593
HepGeom::Transform3D G4Transform3D
static constexpr double mm
Definition: G4SIunits.hh:115
Definition: G4Tubs.hh:85
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:71
CLHEP::HepRotation G4RotationMatrix
#define G4endl
Definition: G4ios.hh:61
void SetVerboseLevel(G4int vl)
Definition: G4SDManager.hh:90
static const G4VisAttributes & GetInvisible()
virtual G4VPhysicalVolume * Construct()
G4Element * FindOrBuildElement(G4int Z, G4bool isotopes=true)
static constexpr double g
Definition: G4SIunits.hh:183
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
static constexpr double deg
Definition: G4SIunits.hh:152
Definition: G4Box.hh:64
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
static constexpr double twopi
Definition: G4SIunits.hh:76
G4bool RegisterPrimitive(G4VPrimitiveScorer *)
void SetVisAttributes(const G4VisAttributes *pVA)
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
HepRotation & rotateY(double delta)
Definition: Rotation.cc:79
int G4int
Definition: G4Types.hh:78
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:368
HepRotation & rotateZ(double delta)
Definition: Rotation.cc:92
G4GLOB_DLL std::ostream G4cout
static constexpr double cm
Definition: G4SIunits.hh:119
static constexpr double cm3
Definition: G4SIunits.hh:121
static G4NistManager * Instance()