ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B03ImportanceDetectorConstruction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file B03ImportanceDetectorConstruction.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 
32 #include "globals.hh"
33 #include <sstream>
34 
36 
37 #include "G4Material.hh"
38 #include "G4Tubs.hh"
39 #include "G4LogicalVolume.hh"
40 #include "G4ThreeVector.hh"
41 #include "G4PVPlacement.hh"
42 #include "G4PhysicalConstants.hh"
43 #include "G4SystemOfUnits.hh"
44 
45 // For Primitive Scorers
46 #include "G4SDManager.hh"
48 #include "G4SDParticleFilter.hh"
49 #include "G4PSNofCollision.hh"
50 #include "G4PSPopulation.hh"
51 #include "G4PSTrackCounter.hh"
52 #include "G4PSTrackLength.hh"
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
58 :G4VUserParallelWorld(worldName),fLogicalVolumeVector()
59 {
60  // Construct();
61 }
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64 
66 {
67  fLogicalVolumeVector.clear();
68 }
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71 
73 {
74  G4cout << " constructing parallel world " << G4endl;
75 
76  G4Material* dummyMat = 0;
77 
78  //GetWorld methods create a clone of the mass world to the parallel world (!)
79  // via the transportation manager
81  G4cout << " B03ImportanceDetectorConstruction:: ghostWorldName = "
82  << fGhostWorld->GetName() << G4endl;
83  G4LogicalVolume* worldLogical = fGhostWorld->GetLogicalVolume();
84  fLogicalVolumeVector.push_back(worldLogical);
85 
86  G4String name("none");
87  // fPVolumeStore.AddPVolume(G4GeometryCell(*pWorldVolume, 0));
89 
90  // creating 18 slobs of 10 cm thicknes
91 
92  G4double innerRadiusShield = 0*cm;
93  G4double outerRadiusShield = 100*cm;
94  G4double heightShield = 5*cm;
95  G4double startAngleShield = 0*deg;
96  G4double spanningAngleShield = 360*deg;
97 
98  G4Tubs *aShield = new G4Tubs("aShield",
99  innerRadiusShield,
100  outerRadiusShield,
101  heightShield,
102  startAngleShield,
103  spanningAngleShield);
104 
105  // logical parallel cells
106 
107  G4LogicalVolume *aShield_log_imp =
108  new G4LogicalVolume(aShield, dummyMat, "aShield_log_imp");
109  fLogicalVolumeVector.push_back(aShield_log_imp);
110 
111  // physical parallel cells
112 
113  G4int i = 1;
114  G4double startz = -85*cm;
115  // for (i=1; i<=18; ++i) {
116  for (i=1; i<=18; i++) {
117 
118  name = GetCellName(i);
119 
120  G4double pos_x = 0*cm;
121  G4double pos_y = 0*cm;
122  G4double pos_z = startz + (i-1) * (2*heightShield);
123  G4VPhysicalVolume *pvol =
124  new G4PVPlacement(0,
125  G4ThreeVector(pos_x, pos_y, pos_z),
126  aShield_log_imp,
127  name,
128  worldLogical,
129  false,
130  i);
131  // 0);
132  G4GeometryCell cell(*pvol, i);
133  // G4GeometryCell cell(*pvol, 0);
135  }
136 
137  // filling the rest of the world volumr behind the concrete with
138  // another slob which should get the same importance value as the
139  // last slob
140  innerRadiusShield = 0*cm;
141  // outerRadiusShield = 110*cm; exceeds world volume!!!!
142  outerRadiusShield = 100*cm;
143  // heightShield = 10*cm;
144  heightShield = 5*cm;
145  startAngleShield = 0*deg;
146  spanningAngleShield = 360*deg;
147 
148  G4Tubs *aRest = new G4Tubs("Rest",
149  innerRadiusShield,
150  outerRadiusShield,
151  heightShield,
152  startAngleShield,
153  spanningAngleShield);
154 
155  G4LogicalVolume *aRest_log =
156  new G4LogicalVolume(aRest, dummyMat, "aRest_log");
157 
158  fLogicalVolumeVector.push_back(aRest_log);
159 
160  name = GetCellName(19);
161 
162  G4double pos_x = 0*cm;
163  G4double pos_y = 0*cm;
164  // G4double pos_z = 100*cm;
165  G4double pos_z = 95*cm;
166  G4VPhysicalVolume *pvol =
167  new G4PVPlacement(0,
168  G4ThreeVector(pos_x, pos_y, pos_z),
169  aRest_log,
170  name,
171  worldLogical,
172  false,
173  19);
174  // 0);
175  G4GeometryCell cell(*pvol, 19);
176  // G4GeometryCell cell(*pvol, 0);
178 
179  SetSensitive();
180 
181 }
182 
183 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
184 
187  return *fPVolumeStore.GetPVolume(name);
188 }
189 
190 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
191 
194  return names;
195 }
196 
197 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
198 
200  std::ostringstream os;
201  os << "cell_";
202  if (i<10) {
203  os << "0";
204  }
205  os << i;
206  G4String name = os.str();
207  return name;
208 }
209 
210 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
211 
214  const G4VPhysicalVolume *p=0;
215  p = fPVolumeStore.GetPVolume(name);
216  if (p) {
217  return G4GeometryCell(*p,0);
218  }
219  else {
220  G4cout << "B03ImportanceDetectorConstruction::GetGeometryCell: " << G4endl
221  << " couldn't get G4GeometryCell" << G4endl;
222  return G4GeometryCell(*fGhostWorld,-2);
223  }
224 }
225 
226 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
227 
230  return *fGhostWorld;
231 }
232 
233 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
234 
236  return fGhostWorld;
237 }
238 
239 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
240 
242 
243  // -------------------------------------------------
244  // The collection names of defined Primitives are
245  // 0 ConcreteSD/Collisions
246  // 1 ConcreteSD/CollWeight
247  // 2 ConcreteSD/Population
248  // 3 ConcreteSD/TrackEnter
249  // 4 ConcreteSD/SL
250  // 5 ConcreteSD/SLW
251  // 6 ConcreteSD/SLWE
252  // 7 ConcreteSD/SLW_V
253  // 8 ConcreteSD/SLWE_V
254  // -------------------------------------------------
255 
256  //now moved to ConstructSD()
257 
258 }
259 
260 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
262 {
263 
265  //
266  // Sensitive Detector Name
267  G4String concreteSDname = "ConcreteSD";
268 
269  //------------------------
270  // MultiFunctionalDetector
271  //------------------------
272  //
273  // Define MultiFunctionalDetector with name.
274  G4MultiFunctionalDetector* MFDet =
275  new G4MultiFunctionalDetector(concreteSDname);
276  SDman->AddNewDetector( MFDet ); // Register SD to SDManager
277 
278  G4String fltName,particleName;
279  G4SDParticleFilter* neutronFilter =
280  new G4SDParticleFilter(fltName="neutronFilter", particleName="neutron");
281 
282  MFDet->SetFilter(neutronFilter);
283 
284  for (std::vector<G4LogicalVolume *>::iterator it =
285  fLogicalVolumeVector.begin();
286  it != fLogicalVolumeVector.end(); it++){
287  // (*it)->SetSensitiveDetector(MFDet);
288  SetSensitiveDetector((*it)->GetName(), MFDet);
289  }
290 
291  G4String psName;
292  G4PSNofCollision* scorer0 = new G4PSNofCollision(psName="Collisions");
293  MFDet->RegisterPrimitive(scorer0);
294 
295  G4PSNofCollision* scorer1 = new G4PSNofCollision(psName="CollWeight");
296  scorer1->Weighted(true);
297  MFDet->RegisterPrimitive(scorer1);
298 
299  G4PSPopulation* scorer2 = new G4PSPopulation(psName="Population");
300  MFDet->RegisterPrimitive(scorer2);
301 
302  G4PSTrackCounter* scorer3 =
303  new G4PSTrackCounter(psName="TrackEnter",fCurrent_In);
304  MFDet->RegisterPrimitive(scorer3);
305 
306  G4PSTrackLength* scorer4 = new G4PSTrackLength(psName="SL");
307  MFDet->RegisterPrimitive(scorer4);
308 
309  G4PSTrackLength* scorer5 = new G4PSTrackLength(psName="SLW");
310  scorer5->Weighted(true);
311  MFDet->RegisterPrimitive(scorer5);
312 
313  G4PSTrackLength* scorer6 = new G4PSTrackLength(psName="SLWE");
314  scorer6->Weighted(true);
315  scorer6->MultiplyKineticEnergy(true);
316  MFDet->RegisterPrimitive(scorer6);
317 
318  G4PSTrackLength* scorer7 = new G4PSTrackLength(psName="SLW_V");
319  scorer7->Weighted(true);
320  scorer7->DivideByVelocity(true);
321  MFDet->RegisterPrimitive(scorer7);
322 
323  G4PSTrackLength* scorer8 = new G4PSTrackLength(psName="SLWE_V");
324  scorer8->Weighted(true);
325  scorer8->MultiplyKineticEnergy(true);
326  scorer8->DivideByVelocity(true);
327  MFDet->RegisterPrimitive(scorer8);
328 }
329 
330 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......