Geant4  10.01.p03
ElectronBenchmarkDetector.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 //
26 // $Id: ElectronBenchmarkDetector.cc 79741 2014-03-13 09:12:06Z gcosmo $
27 //
30 
32 
34 
35 #include "G4RunManager.hh"
36 #include "G4UImanager.hh"
37 #include "G4NistManager.hh"
38 #include "G4GeometryManager.hh"
39 #include "G4PhysicalVolumeStore.hh"
40 #include "G4LogicalVolumeStore.hh"
41 #include "G4SolidStore.hh"
42 #include "G4Material.hh"
43 #include "G4Tubs.hh"
44 #include "G4LogicalVolume.hh"
45 #include "G4PVPlacement.hh"
46 #include "G4PVReplica.hh"
47 #include "G4VisAttributes.hh"
48 #include "G4Colour.hh"
49 #include "G4SDManager.hh"
50 #include "G4SDParticleFilter.hh"
52 #include "G4VPrimitiveScorer.hh"
53 #include "G4PSCellFlux.hh"
54 #include "G4PSPopulation.hh"
55 #include "G4SystemOfUnits.hh"
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
61 fMaterialPrimFoil(0),
62 fScorerRingLog(0),
63 fLogWorld(0),
64 fMessenger(0),
65 fWorldVisAtt(0),
66 fWindowVisAtt(0),
67 fPrimFoilVisAtt(0),
68 fMonVisAtt(0),
69 fBagVisAtt(0),
70 fHeliumVisAtt(0),
71 fRingVisAtt(0),
72 fScorerVisAtt(0)
73 {
74  // Exit Window
75  fPosWindow0 = 0.000000*cm;
76  fPosWindow1 = 0.004120*cm;
77 
78  // Scattering Foil
79  fPosPrimFoil = 2.650000*cm;
81 
82  // Monitor Chamber
83  fPosMon0 = 5.000000*cm;
84  fPosMon1 = 5.011270*cm;
85 
86  // Helium Bag
87  fPosBag0 = 6.497500*cm;
88  fPosHelium0 = 6.500000*cm;
89  fPosHelium1 = 116.500000*cm;
90  fPosBag1 = 116.502500*cm;
91  fThicknessRing = 1.4*cm;
92 
93  // Scoring Plane
94  fPosScorer = 118.200000*cm;
95  fThicknessScorer= 0.001*cm;
96  fWidthScorerRing= 0.1*cm;
97 
98  // Radii
99  fRadOverall = 23.3*cm;
100  fRadRingInner = 20.0*cm;
101 
102  // Extra space remaining in world volume around apparatus
103  fPosDelta = 1.*cm;
104  fRadDelta = 0.1*cm;
105 
107  DefineMaterials();
108 }
109 
110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
111 
113 {
114  delete fMessenger;
115 
116  delete fWorldVisAtt;
117  delete fWindowVisAtt;
118  delete fPrimFoilVisAtt;
119  delete fMonVisAtt;
120  delete fBagVisAtt;
121  delete fHeliumVisAtt;
122  delete fRingVisAtt;
123  delete fScorerVisAtt;
124 }
125 
126 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
127 
129 {
130  return CreateGeometry();
131 }
132 
133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
134 
136  // Use NIST database for elements and materials whereever possible.
138  man->SetVerbose(1);
139 
140  // Take all elements and materials from NIST
141  man->FindOrBuildMaterial("G4_He");
142  man->FindOrBuildMaterial("G4_Be");
143  man->FindOrBuildMaterial("G4_Al");
144  man->FindOrBuildMaterial("G4_Ti");
145  man->FindOrBuildMaterial("G4_Ta");
146  man->FindOrBuildMaterial("G4_AIR");
147  man->FindOrBuildMaterial("G4_MYLAR");
148 
149  G4Element* C = man->FindOrBuildElement("C");
150  G4Element* Cu = man->FindOrBuildElement("Cu");
151  G4Element* Au = man->FindOrBuildElement("Au");
152  G4Element* Ti = man->FindOrBuildElement("Ti");
153  G4Element* Al = man->FindOrBuildElement("Al");
154  G4Element* V = man->FindOrBuildElement("V");
155 
156  // Define materials not in NIST.
157  // While the NIST database does contain default materials for C, Cu and Au,
158  // those defaults have different densities than the ones used in the
159  // benchmark specification.
161  G4int ncomponents;
162  G4double fractionmass;
163 
164  G4Material* G4_C = new G4Material("G4_C", density= 2.18*g/cm3,
165  ncomponents=1);
166  G4_C->AddElement(C, fractionmass=1.00);
167 
168  G4Material* G4_Cu = new G4Material("G4_Cu", density= 8.92*g/cm3,
169  ncomponents=1);
170  G4_Cu->AddElement(Cu, fractionmass=1.00);
171 
172  G4Material* G4_Au = new G4Material("G4_Au", density= 19.30*g/cm3,
173  ncomponents=1);
174  G4_Au->AddElement(Au, fractionmass=1.00);
175 
176  G4Material* TiAlloy = new G4Material("TiAlloy", density= 4.42*g/cm3,
177  ncomponents=3);
178  TiAlloy->AddElement(Ti, fractionmass=0.90);
179  TiAlloy->AddElement(Al, fractionmass=0.06);
180  TiAlloy->AddElement(V, fractionmass=0.04);
181 
182  // Print materials table
184 }
185 
186 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
187 
189  // Clean old geometry, if any
194 
195  // Instantiate the world
196  G4VPhysicalVolume* physiworld = CreateWorld();
197  fLogWorld = physiworld->GetLogicalVolume();
198 
199  // Instantiate the geometry
204 
205  // Create the scorers
207 
208  return physiworld;
209 }
210 
211 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
212 
215 }
216 
217 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
218 
220  G4double halfLengthWorld = fPosScorer/2. + fPosDelta;
221  G4double radWorld = fRadOverall + fRadDelta;
222  G4VSolid* worldSolid = new G4Tubs("WorldSolid", 0.*cm, radWorld,
223  halfLengthWorld, 0.*deg, 360.*deg);
224  G4LogicalVolume* worldLog = new G4LogicalVolume(worldSolid,
225  G4Material::GetMaterial("G4_AIR"), "WorldLog");
226 
227  fWorldVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,1.0));
228  worldLog->SetVisAttributes(fWorldVisAtt);
229 
230  G4VPhysicalVolume* worldPhys =
231  new G4PVPlacement(0, G4ThreeVector(0.,0.,0.),
232  worldLog,"World", 0, false, 0);
233 
234  return worldPhys;
235 }
236 
237 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
238 
240  G4double halfLengthWorld = fPosScorer/2.;
241  G4double halfThicknessWindow = fPosWindow1/2.;
242  G4VSolid* windowSolid = new G4Tubs("windowSolid", 0.*cm, fRadOverall,
243  halfThicknessWindow, 0.*deg, 360.*deg);
244  G4LogicalVolume* windowLog = new G4LogicalVolume(windowSolid,
245  G4Material::GetMaterial("TiAlloy"),
246  "windowLog");
247 
248  fWindowVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
249  windowLog->SetVisAttributes(fWindowVisAtt);
250 
251  new G4PVPlacement(0,
252  G4ThreeVector(0.,0.,
253  halfThicknessWindow - halfLengthWorld),
254  windowLog,"ExitWindow",worldLog,false,0);
255 }
256 
257 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
258 
260  G4double halfLengthWorld = fPosScorer/2.;
261 
262  // For some energies, we have no Primary Foil.
263  if (fHalfThicknessPrimFoil==0.) return;
264 
265  G4VSolid* primFoilSolid = new G4Tubs("PrimFoilSolid", 0.*cm, fRadOverall,
266  fHalfThicknessPrimFoil, 0.*deg, 360.*deg);
267  G4LogicalVolume* primFoilLog = new G4LogicalVolume(primFoilSolid,
268  fMaterialPrimFoil, "PrimFoilLog");
269 
270  fPrimFoilVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
271  primFoilLog->SetVisAttributes(fPrimFoilVisAtt);
272 
273  new G4PVPlacement(0,
274  G4ThreeVector(0.,0.,
275  fPosPrimFoil + fHalfThicknessPrimFoil - halfLengthWorld),
276  primFoilLog,"ScatteringFoil",worldLog,false,0);
277 }
278 
279 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
280 
282  G4double halfLengthWorld = fPosScorer/2.;
283  G4double halfThicknessMon = (fPosMon1 - fPosMon0) /2.;
284  G4VSolid* monSolid = new G4Tubs("monSolid", 0.*cm, fRadOverall,
285  halfThicknessMon, 0.*deg, 360.*deg);
286  G4LogicalVolume* monLog = new G4LogicalVolume(monSolid,
287  G4Material::GetMaterial("G4_MYLAR"),
288  "monLog");
289 
290  fMonVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
291  monLog->SetVisAttributes(fMonVisAtt);
292 
293  new G4PVPlacement(0,
294  G4ThreeVector(0.,0.,
295  fPosMon0 + halfThicknessMon - halfLengthWorld),
296  monLog,"MonitorChamber",worldLog,false,0);
297 }
298 
299 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
300 
302  G4double halfLengthWorld = fPosScorer/2.;
303 
304  // Construct cylinder of Mylar
305  G4double halfThicknessBag = (fPosBag1 - fPosBag0) /2.;
306  G4VSolid* bagSolid = new G4Tubs("bagSolid", 0.*cm, fRadOverall,
307  halfThicknessBag, 0.*deg, 360.*deg);
308  G4LogicalVolume* bagLog = new G4LogicalVolume(bagSolid,
309  G4Material::GetMaterial("G4_MYLAR"),
310  "bagLog");
311 
312  fBagVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
313  bagLog->SetVisAttributes(fBagVisAtt);
314 
315  new G4PVPlacement(0,
316  G4ThreeVector(0.,0.,
317  fPosBag0 + halfThicknessBag - halfLengthWorld),
318  bagLog,"HeliumBag",worldLog,false,0);
319 
320  // Insert cylinder of Helium into the Cylinder of Mylar
321  G4double halfThicknessHelium = (fPosHelium1 - fPosHelium0) /2.;
322  G4VSolid* heliumSolid = new G4Tubs("heliumSolid", 0.*cm, fRadOverall,
323  halfThicknessHelium, 0.*deg, 360.*deg);
324  G4LogicalVolume* heliumLog = new G4LogicalVolume(heliumSolid,
325  G4Material::GetMaterial("G4_He"),
326  "heliumLog");
327 
328  fHeliumVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
329  heliumLog->SetVisAttributes(fHeliumVisAtt);
330 
331  new G4PVPlacement(0, G4ThreeVector(0.,0.,0.),
332  heliumLog,"Helium",bagLog,false,0);
333 
334  // Insert two rings of Aluminum into the Cylinder of Helium
335  G4double halfThicknessRing = fThicknessRing /2.;
336  G4VSolid* ringSolid = new G4Tubs("ringSolid", fRadRingInner, fRadOverall,
337  halfThicknessRing, 0.*deg, 360.*deg);
338  G4LogicalVolume* ring0Log = new G4LogicalVolume(ringSolid,
339  G4Material::GetMaterial("G4_Al"),
340  "ring0Log");
341  G4LogicalVolume* ring1Log = new G4LogicalVolume(ringSolid,
342  G4Material::GetMaterial("G4_Al"),
343  "ring1Log");
344 
345  fRingVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
346  ring0Log->SetVisAttributes(fRingVisAtt);
347  ring1Log->SetVisAttributes(fRingVisAtt);
348 
349  new G4PVPlacement(0,
350  G4ThreeVector(0.,0.,
351  -halfThicknessHelium + halfThicknessRing),
352  ring0Log,"Ring0",heliumLog,false,0);
353 
354  new G4PVPlacement(0,
355  G4ThreeVector(0.,0.,
356  halfThicknessHelium - halfThicknessRing),
357  ring1Log,"Ring1",heliumLog,false,0);
358 }
359 
360 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
361 
363  G4double halfLengthWorld = fPosScorer/2.;
364  G4double halfThicknessScorer = fThicknessScorer /2.;
365 
366  G4VSolid* scorerSolid = new G4Tubs("scorerSolid", 0.*cm, fRadOverall,
367  halfThicknessScorer, 0.*deg, 360.*deg);
368  G4LogicalVolume* scorerLog = new G4LogicalVolume(scorerSolid,
369  G4Material::GetMaterial("G4_AIR"),
370  "scorerLog");
371 
372  fScorerVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
373  scorerLog->SetVisAttributes(fScorerVisAtt);
374  new G4PVPlacement(0,
375  G4ThreeVector(0.,0.,
376  halfLengthWorld - halfThicknessScorer),
377  scorerLog,"Scorer",worldLog,false,0);
378 
379  G4VSolid* scorerRingSolid = new G4Tubs("scorerRingSolid", 0.*cm,
380  fRadOverall,
381  halfThicknessScorer, 0.*deg, 360.*deg);
382  fScorerRingLog = new G4LogicalVolume(scorerRingSolid,
383  G4Material::GetMaterial("G4_AIR"), "scorerRingLog");
384  new G4PVReplica("ScorerRing",fScorerRingLog,scorerLog,kRho,
386 
388 }
389 
390 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
391 
392 // Note that this method is called both at start of job and again after
393 // any command causes a change to detector geometry
395 {
397 
398  // G4Cache mechanism is necessary for multi-threaded operation
399  // as it allows us to store separate detector pointer per thread
400  G4MultiFunctionalDetector*& sensitiveDetector =
402 
403  if (!sensitiveDetector) {
404  sensitiveDetector = new G4MultiFunctionalDetector("MyDetector");
405 
406  G4VPrimitiveScorer* primitive;
407 
408  G4SDParticleFilter* electronFilter =
409  new G4SDParticleFilter("electronFilter", "e-");
410 
411  primitive = new G4PSCellFlux("cell flux");
412  sensitiveDetector->RegisterPrimitive(primitive);
413 
414  primitive = new G4PSCellFlux("e cell flux");
415  primitive->SetFilter(electronFilter);
416  sensitiveDetector->RegisterPrimitive(primitive);
417 
418  primitive = new G4PSPopulation("population");
419  sensitiveDetector->RegisterPrimitive(primitive);
420 
421  primitive = new G4PSPopulation("e population");
422  primitive->SetFilter(electronFilter);
423  sensitiveDetector->RegisterPrimitive(primitive);
424  }
425 
426  SetSensitiveDetector("scorerRingLog",sensitiveDetector);
427 }
428 
429 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
430 
433  UpdateGeometry();
434 }
435 
436 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
437 
439 {
440  fHalfThicknessPrimFoil = thicknessPrimFoil / 2.;
441  UpdateGeometry();
442 }
443 
444 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static const double cm
Definition: G4SIunits.hh:106
G4bool RegisterPrimitive(G4VPrimitiveScorer *)
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
const G4Cache< G4MultiFunctionalDetector * > fSensitiveDetectorCache
virtual G4VPhysicalVolume * Construct()
CLHEP::Hep3Vector G4ThreeVector
ElectronBenchmarkDetectorMessenger * fMessenger
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:603
void SetPrimFoilThickness(G4double thicknessPrimFoil)
void SetVerboseLevel(G4int vl)
Definition: G4SDManager.hh:90
void CreateScorer(G4LogicalVolume *logicWorld)
value_type & Get() const
Definition: G4Cache.hh:282
Definition: G4Tubs.hh:85
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:588
void SetFilter(G4VSDFilter *f)
static void Clean()
Definition: G4SolidStore.cc:79
Definition of the ElectronBenchmarkDetectorMessenger class.
void CreatePrimaryFoil(G4LogicalVolume *logicWorld)
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
static G4PhysicalVolumeStore * GetInstance()
G4double density
Definition: TRTMaterials.hh:39
void CreateHeliumBag(G4LogicalVolume *logicWorld)
G4GLOB_DLL std::ostream G4cout
void CreateMonitor(G4LogicalVolume *logicWorld)
static const double deg
Definition: G4SIunits.hh:133
void SetVerbose(G4int)
static G4LogicalVolumeStore * GetInstance()
static const double cm3
Definition: G4SIunits.hh:108
static G4SolidStore * GetInstance()
void CreateExitWindow(G4LogicalVolume *logicWorld)
static G4GeometryManager * GetInstance()
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
void SetPrimFoilMaterial(G4String matname)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
G4LogicalVolume * GetLogicalVolume() const
static const double g
Definition: G4SIunits.hh:162
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
Definition of the ElectronBenchmarkDetector class.
#define G4endl
Definition: G4ios.hh:61
void OpenGeometry(G4VPhysicalVolume *vol=0)
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:364
double G4double
Definition: G4Types.hh:76
Definition: geomdefs.hh:54
G4Element * FindOrBuildElement(G4int Z, G4bool isotopes=true)
void SetVisAttributes(const G4VisAttributes *pVA)
G4Material * Al
Definition: TRTMaterials.hh:74