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 //
31 //
32 // DetectorConstruction
33 //
34 // Created: 31.01.2003 V.Ivanchenko
35 //
36 // Modified:
37 // 04.06.2006 Adoptation of Hadr01 (V.Ivanchenko)
38 //
40 //
41 
42 #include "DetectorConstruction.hh"
43 #include "DetectorMessenger.hh"
44 
45 #include "G4Tubs.hh"
46 #include "G4LogicalVolume.hh"
47 #include "G4PVPlacement.hh"
48 
49 #include "G4RunManager.hh"
50 
51 #include "G4GeometryManager.hh"
52 #include "G4PhysicalVolumeStore.hh"
53 #include "G4LogicalVolumeStore.hh"
54 #include "G4SolidStore.hh"
55 
56 #include "G4VisAttributes.hh"
57 #include "G4Colour.hh"
58 
59 #include "G4UnitsTable.hh"
60 #include "G4ios.hh"
61 
62 #include "TargetSD.hh"
63 #include "CheckVolumeSD.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  fTargetMaterial(nullptr),
77  fWorldMaterial(nullptr),
78  fSolidW(nullptr),
79  fSolidA(nullptr),
80  fSolidC(nullptr),
81  fLogicTarget(nullptr),
82  fLogicCheck(nullptr),
83  fLogicWorld(nullptr),
84  fPhysWorld(nullptr),
85  fInitialized(false)
86 {
88 
89  fRadius = 10.*cm;
90 
92  fTargetMaterial = nist->FindOrBuildMaterial("G4_Al");
93  fWorldMaterial = nist->FindOrBuildMaterial("G4_Galactic");
94 
95  //
96  // define battery material using Bugzilla 2175 data
97  //
98  G4Element* elH = nist->FindOrBuildElement(1);
99  G4Element* elLi = nist->FindOrBuildElement(3);
100  G4Element* elC = nist->FindOrBuildElement(6);
101  G4Element* elO = nist->FindOrBuildElement(8);
102  G4Element* elAl = nist->FindOrBuildElement(13);
103  G4Element* elTi = nist->FindOrBuildElement(22);
104  G4Element* elCo = nist->FindOrBuildElement(27);
105  G4Element* elCu = nist->FindOrBuildElement(29);
106  G4Material* bat = new G4Material("Battery",2.165*CLHEP::g/CLHEP::cm3,8);
107  bat->AddElement(elC, 0.19518445618745);
108  bat->AddElement(elAl, 0.398);
109  bat->AddElement(elTi, 0.02);
110  bat->AddElement(elCu, 0.084);
111  bat->AddElement(elLi, 0.0170098229419813);
112  bat->AddElement(elCo, 0.144570016541753);
113  bat->AddElement(elO, 0.134206611504321);
114  bat->AddElement(elH, 0.0070290928244947);
115  bat->GetIonisation()->SetMeanExcitationEnergy(144.88*eV);
116 
118 }
119 
120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
121 
123 {
124  delete fDetectorMessenger;
125 }
126 
128 {
129  // Sizes
135 
138  if(fPhysWorld) {
145  }
146 }
147 
149 {
150  if(fPhysWorld) { return fPhysWorld; }
152 
153  //
154  // World
155  //
156  fSolidW = new G4Tubs("World",0.,fWorldR,fWorldZ,0.,twopi);
158  fPhysWorld = new G4PVPlacement(nullptr,G4ThreeVector(0.,0.,0.),
159  fLogicWorld,"World",nullptr,false,0);
160  //
161  // Check volume
162  //
163  fSolidC = new G4Tubs("Check",0.,fCheckR,fCheckZ,0.,twopi);
165  new G4PVPlacement(nullptr,G4ThreeVector(),fLogicCheck,"Check",
166  fLogicWorld,false,0);
167 
168  //
169  // Target volume
170  //
171  fSolidA = new G4Tubs("Target",0.,fRadius,fSliceZ,0.,twopi);
173 
175 
176  for(G4int i=0; i<fSlices; ++i) {
177  // physC =
178  new G4PVPlacement(nullptr,G4ThreeVector(0.0,0.0,z),fLogicTarget,"Target",
179  fLogicCheck,false,i);
180  z += 2.0*fSliceZ;
181  }
182  G4cout << "### Target consist of " << fSlices
183  << " disks of " << fTargetMaterial->GetName()
184  << " with R(mm)= " << fRadius/mm
185  << " Width(mm)= " << 2.0*fSliceZ/mm
186  << " Total Length(mm)= " << 2.0*fTargetZ/mm
187  << " ###" << G4endl;
188 
189  // colors
192 
193  G4VisAttributes regWcolor(G4Colour(0.3, 0.3, 0.3));
194  fLogicCheck->SetVisAttributes(regWcolor);
195 
196  G4VisAttributes regCcolor(G4Colour(0., 0.3, 0.7));
197  fLogicTarget->SetVisAttributes(regCcolor);
198 
199  G4cout << *(G4Material::GetMaterialTable()) << G4endl;
200 
201  return fPhysWorld;
202 }
203 
205 {
206  if (!fInitialized) {
207  // Prepare sensitive detectors
208  CheckVolumeSD* fCheckSD = new CheckVolumeSD("checkSD");
209  (G4SDManager::GetSDMpointer())->AddNewDetector( fCheckSD );
211 
212  TargetSD* fTargetSD = new TargetSD("targetSD");
213  (G4SDManager::GetSDMpointer())->AddNewDetector( fTargetSD );
215  fInitialized = true;
216  }
217 }
218 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
219 
221 {
222  // search the material by its name
224 
225  if (material && material != fTargetMaterial) {
229  }
230 }
231 
232 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
233 
235 {
236  // search the material by its name
238 
239  if (material && material != fWorldMaterial) {
243  }
244 }
245 
246 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
247 
249 {
250  if(val > 0.0) {
251  fRadius = val;
253  }
254 }
255 
256 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......