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