ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DetectorConstruction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file 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 //
30 
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "DetectorConstruction.hh"
35 #include "DetectorMessenger.hh"
36 
37 #include "G4Material.hh"
38 #include "G4NistManager.hh"
39 
40 #include "G4Tubs.hh"
41 #include "G4LogicalVolume.hh"
42 #include "G4PVPlacement.hh"
43 
44 #include "G4GeometryManager.hh"
45 #include "G4PhysicalVolumeStore.hh"
46 #include "G4LogicalVolumeStore.hh"
47 #include "G4SolidStore.hh"
48 #include "G4RunManager.hh"
49 
50 #include "G4SystemOfUnits.hh"
51 #include "G4PhysicalConstants.hh"
52 #include "G4UnitsTable.hh"
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
58  fTargetMater(0), fLogicTarget(0),
59  fDetectorMater(0), fLogicDetector(0),
60  fWorldMater(0), fPhysiWorld(0),
61  fDetectorMessenger(0)
62 {
63  fTargetLength = 1*cm;
64  fTargetRadius = 0.5*cm;
65  fDetectorLength = 5*cm;
67 
70 
72 
74 }
75 
76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
77 
79 { delete fDetectorMessenger;}
80 
81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82 
84 {
85  return ConstructVolumes();
86 }
87 
88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
89 
91 {
92  // build materials
93  //
95  new G4Material("Germanium", 32, 72.61*g/mole, 5.323*g/cm3);
96 
97 
98  G4Element* N = new G4Element("Nitrogen", "N", 7, 14.01*g/mole);
99  G4Element* O = new G4Element("Oxygen", "O", 8, 16.00*g/mole);
100  //
101  G4int ncomponents; G4double fractionmass;
102  G4Material* Air20 = new G4Material("Air", 1.205*mg/cm3, ncomponents=2,
103  kStateGas, 293.*kelvin, 1.*atmosphere);
104  Air20->AddElement(N, fractionmass=0.7);
105  Air20->AddElement(O, fractionmass=0.3);
106  //
107  fWorldMater = Air20;
108 
109  // or use G4 materials data base
110  //
112  fTargetMater = man->FindOrBuildMaterial("G4_CESIUM_IODIDE");
113 
115 }
116 
117 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
118 
120 {
121  // Cleanup old geometry
126 
127  // World
128  //
129  // (re) compute World dimensions if necessary
132 
133  G4Tubs*
134  sWorld = new G4Tubs("World", //name
135  0.,fWorldRadius, 0.5*fWorldLength, 0.,twopi); //dimensions
136 
138  lWorld = new G4LogicalVolume(sWorld, //shape
139  fWorldMater, //material
140  "World"); //name
141 
142  fPhysiWorld = new G4PVPlacement(0, //no rotation
143  G4ThreeVector(), //at (0,0,0)
144  lWorld, //logical volume
145  "World", //name
146  0, //mother volume
147  false, //no boolean operation
148  0); //copy number
149 
150  // Target
151  //
152  G4Tubs*
153  sTarget = new G4Tubs("Target", //name
154  0., fTargetRadius, 0.5*fTargetLength, 0.,twopi); //dimensions
155 
156 
157  fLogicTarget = new G4LogicalVolume(sTarget, //shape
158  fTargetMater, //material
159  "Target"); //name
160 
161  new G4PVPlacement(0, //no rotation
162  G4ThreeVector(), //at (0,0,0)
163  fLogicTarget, //logical volume
164  "Target", //name
165  lWorld, //mother volume
166  false, //no boolean operation
167  0); //copy number
168 
169  // Detector
170  //
171  G4Tubs*
172  sDetector = new G4Tubs("Detector",
174 
175 
176  fLogicDetector = new G4LogicalVolume(sDetector, //shape
177  fDetectorMater, //material
178  "Detector"); //name
179 
180  new G4PVPlacement(0, //no rotation
181  G4ThreeVector(), //at (0,0,0)
182  fLogicDetector, //logical volume
183  "Detector", //name
184  lWorld, //mother volume
185  false, //no boolean operation
186  0); //copy number
187 
188 
189  PrintParameters();
190 
191  //always return the root volume
192  //
193  return fPhysiWorld;
194 }
195 
196 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
197 
199 {
200  G4cout << "\n Target : Length = " << G4BestUnit(fTargetLength,"Length")
201  << " Radius = " << G4BestUnit(fTargetRadius,"Length")
202  << " Material = " << fTargetMater->GetName();
203  G4cout << "\n Detector : Length = " << G4BestUnit(fDetectorLength,"Length")
204  << " Tickness = " << G4BestUnit(fDetectorThickness,"Length")
205  << " Material = " << fDetectorMater->GetName() << G4endl;
206  G4cout << "\n" << fTargetMater << "\n" << fDetectorMater << G4endl;
207 }
208 
209 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
210 
212 {
213  // search the material by its name
214  G4Material* pttoMaterial =
215  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
216 
217  if (pttoMaterial) {
218  fTargetMater = pttoMaterial;
221  } else {
222  G4cout << "\n--> warning from DetectorConstruction::SetTargetMaterial : "
223  << materialChoice << " not found" << G4endl;
224  }
225 }
226 
227 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
228 
230 {
231  // search the material by its name
232  G4Material* pttoMaterial =
233  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
234 
235  if (pttoMaterial) {
236  fDetectorMater = pttoMaterial;
239  } else {
240  G4cout << "\n--> warning from DetectorConstruction::SetDetectorMaterial : "
241  << materialChoice << " not found" << G4endl;
242  }
243 }
244 
245 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
246 
248 {
251 }
252 
253 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
254 
256 {
259 }
260 
261 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
262 
264 {
265  fDetectorThickness = value;
267 }
268 
269 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
270 
272 {
275 }
276 
277 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
278 
280 {
281  return fTargetLength;
282 }
283 
284 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
285 
287 {
288  return fTargetRadius;
289 }
290 
291 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
292 
294 {
295  return fTargetMater;
296 }
297 
298 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
299 
301 {
302  return fLogicTarget;
303 }
304 
305 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
306 
308 {
309  return fDetectorLength;
310 }
311 
312 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
313 
315 {
316  return fDetectorThickness;
317 }
318 
319 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
320 
322 {
323  return fDetectorMater;
324 }
325 
326 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
327 
329 {
330  return fLogicDetector;
331 }
332 
333 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......