ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B3DetectorConstruction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file 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 //
29 
30 #include "B3DetectorConstruction.hh"
31 
32 #include "G4NistManager.hh"
33 #include "G4Box.hh"
34 #include "G4Tubs.hh"
35 #include "G4LogicalVolume.hh"
36 #include "G4PVPlacement.hh"
37 #include "G4RotationMatrix.hh"
38 #include "G4Transform3D.hh"
39 #include "G4SDManager.hh"
41 #include "G4VPrimitiveScorer.hh"
42 #include "G4PSEnergyDeposit.hh"
43 #include "G4PSDoseDeposit.hh"
44 #include "G4VisAttributes.hh"
45 #include "G4PhysicalConstants.hh"
46 #include "G4SystemOfUnits.hh"
47 
48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49 
52  fCheckOverlaps(true)
53 {
55 }
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
60 { }
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
65 {
67 
68  G4bool isotopes = false;
69 
70  G4Element* O = man->FindOrBuildElement("O" , isotopes);
71  G4Element* Si = man->FindOrBuildElement("Si", isotopes);
72  G4Element* Lu = man->FindOrBuildElement("Lu", isotopes);
73 
74  G4Material* LSO = new G4Material("Lu2SiO5", 7.4*g/cm3, 3);
75  LSO->AddElement(Lu, 2);
76  LSO->AddElement(Si, 1);
77  LSO->AddElement(O , 5);
78 }
79 
80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
81 
83 {
84  // Gamma detector Parameters
85  //
86  G4double cryst_dX = 6*cm, cryst_dY = 6*cm, cryst_dZ = 3*cm;
87  G4int nb_cryst = 32;
88  G4int nb_rings = 9;
89  //
90  G4double dPhi = twopi/nb_cryst, half_dPhi = 0.5*dPhi;
91  G4double cosdPhi = std::cos(half_dPhi);
92  G4double tandPhi = std::tan(half_dPhi);
93  //
94  G4double ring_R1 = 0.5*cryst_dY/tandPhi;
95  G4double ring_R2 = (ring_R1+cryst_dZ)/cosdPhi;
96  //
97  G4double detector_dZ = nb_rings*cryst_dX;
98  //
100  G4Material* default_mat = nist->FindOrBuildMaterial("G4_AIR");
101  G4Material* cryst_mat = nist->FindOrBuildMaterial("Lu2SiO5");
102 
103  //
104  // World
105  //
106  G4double world_sizeXY = 2.4*ring_R2;
107  G4double world_sizeZ = 1.2*detector_dZ;
108 
109  G4Box* solidWorld =
110  new G4Box("World", //its name
111  0.5*world_sizeXY, 0.5*world_sizeXY, 0.5*world_sizeZ); //its size
112 
113  G4LogicalVolume* logicWorld =
114  new G4LogicalVolume(solidWorld, //its solid
115  default_mat, //its material
116  "World"); //its name
117 
119  new G4PVPlacement(0, //no rotation
120  G4ThreeVector(), //at (0,0,0)
121  logicWorld, //its logical volume
122  "World", //its name
123  0, //its mother volume
124  false, //no boolean operation
125  0, //copy number
126  fCheckOverlaps); // checking overlaps
127 
128  //
129  // ring
130  //
131  G4Tubs* solidRing =
132  new G4Tubs("Ring", ring_R1, ring_R2, 0.5*cryst_dX, 0., twopi);
133 
134  G4LogicalVolume* logicRing =
135  new G4LogicalVolume(solidRing, //its solid
136  default_mat, //its material
137  "Ring"); //its name
138 
139  //
140  // define crystal
141  //
142  G4double gap = 0.5*mm; //a gap for wrapping
143  G4double dX = cryst_dX - gap, dY = cryst_dY - gap;
144  G4Box* solidCryst = new G4Box("crystal", dX/2, dY/2, cryst_dZ/2);
145 
146  G4LogicalVolume* logicCryst =
147  new G4LogicalVolume(solidCryst, //its solid
148  cryst_mat, //its material
149  "CrystalLV"); //its name
150 
151  // place crystals within a ring
152  //
153  for (G4int icrys = 0; icrys < nb_cryst ; icrys++) {
154  G4double phi = icrys*dPhi;
156  rotm.rotateY(90*deg);
157  rotm.rotateZ(phi);
158  G4ThreeVector uz = G4ThreeVector(std::cos(phi), std::sin(phi),0.);
159  G4ThreeVector position = (ring_R1+0.5*cryst_dZ)*uz;
160  G4Transform3D transform = G4Transform3D(rotm,position);
161 
162  new G4PVPlacement(transform, //rotation,position
163  logicCryst, //its logical volume
164  "crystal", //its name
165  logicRing, //its mother volume
166  false, //no boolean operation
167  icrys, //copy number
168  fCheckOverlaps); // checking overlaps
169  }
170 
171  //
172  // full detector
173  //
174  G4Tubs* solidDetector =
175  new G4Tubs("Detector", ring_R1, ring_R2, 0.5*detector_dZ, 0., twopi);
176 
177  G4LogicalVolume* logicDetector =
178  new G4LogicalVolume(solidDetector, //its solid
179  default_mat, //its material
180  "Detector"); //its name
181 
182  //
183  // place rings within detector
184  //
185  G4double OG = -0.5*(detector_dZ + cryst_dX);
186  for (G4int iring = 0; iring < nb_rings ; iring++) {
187  OG += cryst_dX;
188  new G4PVPlacement(0, //no rotation
189  G4ThreeVector(0,0,OG), //position
190  logicRing, //its logical volume
191  "ring", //its name
192  logicDetector, //its mother volume
193  false, //no boolean operation
194  iring, //copy number
195  fCheckOverlaps); // checking overlaps
196  }
197 
198  //
199  // place detector in world
200  //
201  new G4PVPlacement(0, //no rotation
202  G4ThreeVector(), //at (0,0,0)
203  logicDetector, //its logical volume
204  "Detector", //its name
205  logicWorld, //its mother volume
206  false, //no boolean operation
207  0, //copy number
208  fCheckOverlaps); // checking overlaps
209 
210  //
211  // patient
212  //
213  G4double patient_radius = 8*cm;
214  G4double patient_dZ = 10*cm;
215  G4Material* patient_mat = nist->FindOrBuildMaterial("G4_BRAIN_ICRP");
216 
217  G4Tubs* solidPatient =
218  new G4Tubs("Patient", 0., patient_radius, 0.5*patient_dZ, 0., twopi);
219 
220  G4LogicalVolume* logicPatient =
221  new G4LogicalVolume(solidPatient, //its solid
222  patient_mat, //its material
223  "PatientLV"); //its name
224 
225  //
226  // place patient in world
227  //
228  new G4PVPlacement(0, //no rotation
229  G4ThreeVector(), //at (0,0,0)
230  logicPatient, //its logical volume
231  "Patient", //its name
232  logicWorld, //its mother volume
233  false, //no boolean operation
234  0, //copy number
235  fCheckOverlaps); // checking overlaps
236 
237  // Visualization attributes
238  //
241 
242  // Print materials
244 
245  //always return the physical World
246  //
247  return physWorld;
248 }
249 
250 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
251 
253 {
255 
256  // declare crystal as a MultiFunctionalDetector scorer
257  //
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");
268  G4VPrimitiveScorer* primitiv2 = new G4PSDoseDeposit("dose");
269  patient->RegisterPrimitive(primitiv2);
270  SetSensitiveDetector("PatientLV",patient);
271 }
272 
273 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......