Geant4  10.01
B3DetectorConstruction.cc
Go to the documentation of this file.
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 71323 2013-06-13 16:54:23Z gcosmo $
27 //
30 
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  //
260  G4VPrimitiveScorer* primitiv1 = new G4PSEnergyDeposit("edep");
261  cryst->RegisterPrimitive(primitiv1);
262  SetSensitiveDetector("CrystalLV",cryst);
263 
264  // declare patient as a MultiFunctionalDetector scorer
265  //
266  G4MultiFunctionalDetector* patient = new G4MultiFunctionalDetector("patient");
267  G4VPrimitiveScorer* primitiv2 = new G4PSDoseDeposit("dose");
268  patient->RegisterPrimitive(primitiv2);
269  SetSensitiveDetector("PatientLV",patient);
270 }
271 
272 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static const double cm
Definition: G4SIunits.hh:106
G4bool RegisterPrimitive(G4VPrimitiveScorer *)
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
Definition of the B3DetectorConstruction class.
CLHEP::Hep3Vector G4ThreeVector
CLHEP::HepRotation G4RotationMatrix
Definition: G4Box.hh:64
void SetVerboseLevel(G4int vl)
Definition: G4SDManager.hh:90
Definition: G4Tubs.hh:85
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:588
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
#define position
Definition: xmlparse.cc:605
G4GLOB_DLL std::ostream G4cout
virtual G4VPhysicalVolume * Construct()
static const double deg
Definition: G4SIunits.hh:133
bool G4bool
Definition: G4Types.hh:79
G4Material * Si
Definition: TRTMaterials.hh:78
static const double cm3
Definition: G4SIunits.hh:108
HepGeom::Transform3D G4Transform3D
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
static const double g
Definition: G4SIunits.hh:162
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
static const G4VisAttributes Invisible
#define G4endl
Definition: G4ios.hh:61
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:364
double G4double
Definition: G4Types.hh:76
G4Element * FindOrBuildElement(G4int Z, G4bool isotopes=true)
static const double mm
Definition: G4SIunits.hh:102
void SetVisAttributes(const G4VisAttributes *pVA)