Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 //
28 //
29 
31 
33 
34 #include "G4RunManager.hh"
35 #include "G4UImanager.hh"
36 #include "G4NistManager.hh"
37 #include "G4GeometryManager.hh"
38 #include "G4PhysicalVolumeStore.hh"
39 #include "G4LogicalVolumeStore.hh"
40 #include "G4SolidStore.hh"
41 #include "G4Material.hh"
42 #include "G4Tubs.hh"
43 #include "G4LogicalVolume.hh"
44 #include "G4PVPlacement.hh"
45 #include "G4PVReplica.hh"
46 #include "G4VisAttributes.hh"
47 #include "G4Colour.hh"
48 #include "G4SDManager.hh"
49 #include "G4SDParticleFilter.hh"
51 #include "G4VPrimitiveScorer.hh"
52 #include "G4PSCellFlux.hh"
53 #include "G4PSPopulation.hh"
54 #include "G4SystemOfUnits.hh"
55 
57 :fLogWorld(NULL),
58 fWorldVisAtt(0),
59 fWindowVisAtt(0),
60 fPrimFoilVisAtt(0),
61 fMonVisAtt(0),
62 fBagVisAtt(0),
63 fHeliumVisAtt(0),
64 fRingVisAtt(0),
65 fScorerVisAtt(0)
66 {
67  // Exit Window
68  fPosWindow0 = 0.000000*cm;
69  fPosWindow1 = 0.004120*cm;
70 
71  // Scattering Foil
72  fPosPrimFoil = 2.650000*cm;
73 
74  // Monitor Chamber
75  fPosMon0 = 5.000000*cm;
76  fPosMon1 = 5.011270*cm;
77 
78  // Helium Bag
79  fPosBag0 = 6.497500*cm;
80  fPosHelium0 = 6.500000*cm;
81  fPosHelium1 = 116.500000*cm;
82  fPosBag1 = 116.502500*cm;
83  fThicknessRing = 1.4*cm;
84 
85  // Scoring Plane
86  fPosScorer = 118.200000*cm;
87  fThicknessScorer= 0.001*cm;
88  fWidthScorerRing= 0.1*cm;
89 
90  // Radii
91  fRadOverall = 23.3*cm;
92  fRadRingInner = 20.0*cm;
93 
94  // Extra space remaining in world volume around apparatus
95  fPosDelta = 1.*cm;
96  fRadDelta = 0.1*cm;
97 
98  fMessenger = new ElectronBenchmarkDetectorMessenger(this);
99 }
100 
101 
103 {
104  delete fMessenger;
105 
106  delete fWorldVisAtt;
107  delete fWindowVisAtt;
108  delete fPrimFoilVisAtt;
109  delete fMonVisAtt;
110  delete fBagVisAtt;
111  delete fHeliumVisAtt;
112  delete fRingVisAtt;
113  delete fScorerVisAtt;
114 }
115 
116 
118 {
119  DefineMaterials();
120 
121  G4VPhysicalVolume* physiworld = CreateGeometry();
122  return physiworld;
123 }
124 
125 
127  // Use NIST database for elements and materials whereever possible.
129  man->SetVerbose(1);
130 
131  // Take all elements and materials from NIST
132  man->FindOrBuildMaterial("G4_He");
133  man->FindOrBuildMaterial("G4_Be");
134  man->FindOrBuildMaterial("G4_Al");
135  man->FindOrBuildMaterial("G4_Ti");
136  man->FindOrBuildMaterial("G4_Ta");
137  man->FindOrBuildMaterial("G4_AIR");
138  man->FindOrBuildMaterial("G4_MYLAR");
139 
140  G4Element* C = man->FindOrBuildElement("C");
141  G4Element* Cu = man->FindOrBuildElement("Cu");
142  G4Element* Au = man->FindOrBuildElement("Au");
143  G4Element* Ti = man->FindOrBuildElement("Ti");
144  G4Element* Al = man->FindOrBuildElement("Al");
145  G4Element* V = man->FindOrBuildElement("V");
146 
147  // Define materials not in NIST
148  // While the NIST database does contain default materials for C, Cu and Au, those defaults have different
149  // densities than the ones used in the benchmark specification.
151  G4int ncomponents;
152  G4double fractionmass;
153 
154  G4Material* G4_C = new G4Material("G4_C", density= 2.18*g/cm3, ncomponents=1);
155  G4_C->AddElement(C, fractionmass=1.00);
156 
157  G4Material* G4_Cu = new G4Material("G4_Cu", density= 8.92*g/cm3, ncomponents=1);
158  G4_Cu->AddElement(Cu, fractionmass=1.00);
159 
160  G4Material* G4_Au = new G4Material("G4_Au", density= 19.30*g/cm3, ncomponents=1);
161  G4_Au->AddElement(Au, fractionmass=1.00);
162 
163  G4Material* TiAlloy = new G4Material("TiAlloy", density= 4.42*g/cm3, ncomponents=3);
164  TiAlloy->AddElement(Ti, fractionmass=0.90);
165  TiAlloy->AddElement(Al, fractionmass=0.06);
166  TiAlloy->AddElement(V, fractionmass=0.04);
167 
168  // Print materials table
170 }
171 
172 
174  // Clean old geometry, if any
175  fLogWorld=NULL;
176  fScorerRingLog=NULL;
181 
182  // Instantiate the world
183  G4VPhysicalVolume* physiworld = CreateWorld();
184  fLogWorld = physiworld->GetLogicalVolume();
185 
186  // Instantiate the geometry
187  CreateExitWindow(fLogWorld);
188  CreatePrimaryFoil(fLogWorld);
189  CreateMonitor(fLogWorld);
190  CreateHeliumBag(fLogWorld);
191 
192  // Create and activate the scorers
193  CreateScorer(fLogWorld);
194  ActivateScorer();
195 
196  return physiworld;
197 }
198 
199 
202 }
203 
204 
206  G4double halfLengthWorld = fPosScorer/2. + fPosDelta;
207  G4double radWorld = fRadOverall + fRadDelta;
208  G4VSolid* worldSolid = new G4Tubs("WorldSolid", 0.*cm, radWorld, halfLengthWorld, 0.*deg, 360.*deg);
209  G4LogicalVolume* worldLog = new G4LogicalVolume(worldSolid, G4Material::GetMaterial("G4_AIR"), "WorldLog");
210 
211  fWorldVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,1.0));
212  worldLog->SetVisAttributes(fWorldVisAtt);
213 
214  G4VPhysicalVolume* worldPhys =
215  new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), worldLog,"World", 0, false, 0);
216 
217  return worldPhys;
218 }
219 
220 
222  G4double halfLengthWorld = fPosScorer/2.;
223  G4double halfThicknessWindow = fPosWindow1/2.;
224  G4VSolid* windowSolid = new G4Tubs("windowSolid", 0.*cm, fRadOverall, halfThicknessWindow, 0.*deg, 360.*deg);
225  G4LogicalVolume* windowLog = new G4LogicalVolume(windowSolid, G4Material::GetMaterial("TiAlloy"), "windowLog");
226 
227  fWindowVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
228  windowLog->SetVisAttributes(fWindowVisAtt);
229 
230  new G4PVPlacement(0,
231  G4ThreeVector(0.,0., halfThicknessWindow - halfLengthWorld),
232  windowLog,"ExitWindow",worldLog,false,0);
233 }
234 
235 
237  G4double halfLengthWorld = fPosScorer/2.;
238 
239  // For some energies, we have no Primary Foil.
240  if (fHalfThicknessPrimFoil==0.) return;
241 
242  G4VSolid* primFoilSolid = new G4Tubs("PrimFoilSolid",
243  0.*cm, fRadOverall, fHalfThicknessPrimFoil, 0.*deg, 360.*deg);
244  G4LogicalVolume* primFoilLog = new G4LogicalVolume(primFoilSolid, fMaterialPrimFoil, "PrimFoilLog");
245 
246  fPrimFoilVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
247  primFoilLog->SetVisAttributes(fPrimFoilVisAtt);
248 
249  new G4PVPlacement(0,
250  G4ThreeVector(0.,0.,fPosPrimFoil + fHalfThicknessPrimFoil - halfLengthWorld),
251  primFoilLog,"ScatteringFoil",worldLog,false,0);
252 }
253 
254 
256  G4double halfLengthWorld = fPosScorer/2.;
257  G4double halfThicknessMon = (fPosMon1 - fPosMon0) /2.;
258  G4VSolid* monSolid = new G4Tubs("monSolid", 0.*cm, fRadOverall, halfThicknessMon, 0.*deg, 360.*deg);
259  G4LogicalVolume* monLog = new G4LogicalVolume(monSolid, G4Material::GetMaterial("G4_MYLAR"), "monLog");
260 
261  fMonVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
262  monLog->SetVisAttributes(fMonVisAtt);
263 
264  new G4PVPlacement(0,
265  G4ThreeVector(0.,0., fPosMon0 + halfThicknessMon - halfLengthWorld),
266  monLog,"MonitorChamber",worldLog,false,0);
267 }
268 
269 
271  G4double halfLengthWorld = fPosScorer/2.;
272 // Construct cylinder of Mylar
273  G4double halfThicknessBag = (fPosBag1 - fPosBag0) /2.;
274  G4VSolid* bagSolid = new G4Tubs("bagSolid", 0.*cm, fRadOverall, halfThicknessBag, 0.*deg, 360.*deg);
275  G4LogicalVolume* bagLog = new G4LogicalVolume(bagSolid, G4Material::GetMaterial("G4_MYLAR"), "bagLog");
276 
277  fBagVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
278  bagLog->SetVisAttributes(fBagVisAtt);
279 
280  new G4PVPlacement(0,
281  G4ThreeVector(0.,0., fPosBag0 + halfThicknessBag - halfLengthWorld),
282  bagLog,"HeliumBag",worldLog,false,0);
283 
284 // Insert cylinder of Helium into the Cylinder of Mylar
285  G4double halfThicknessHelium = (fPosHelium1 - fPosHelium0) /2.;
286  G4VSolid* heliumSolid = new G4Tubs("heliumSolid", 0.*cm, fRadOverall, halfThicknessHelium, 0.*deg, 360.*deg);
287  G4LogicalVolume* heliumLog = new G4LogicalVolume(heliumSolid, G4Material::GetMaterial("G4_He"), "heliumLog");
288 
289  fHeliumVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
290  heliumLog->SetVisAttributes(fHeliumVisAtt);
291 
292  new G4PVPlacement(0, G4ThreeVector(0.,0.,0.),heliumLog,"Helium",bagLog,false,0);
293 
294 // Insert two rings of Aluminum into the Cylinder of Helium
295  G4double halfThicknessRing = fThicknessRing /2.;
296  G4VSolid* ringSolid = new G4Tubs("ringSolid", fRadRingInner, fRadOverall, halfThicknessRing, 0.*deg, 360.*deg);
297  G4LogicalVolume* ring0Log = new G4LogicalVolume(ringSolid, G4Material::GetMaterial("G4_Al"), "ring0Log");
298  G4LogicalVolume* ring1Log = new G4LogicalVolume(ringSolid, G4Material::GetMaterial("G4_Al"), "ring1Log");
299 
300  fRingVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
301  ring0Log->SetVisAttributes(fRingVisAtt);
302  ring1Log->SetVisAttributes(fRingVisAtt);
303 
304  new G4PVPlacement(0,
305  G4ThreeVector(0.,0., -halfThicknessHelium + halfThicknessRing),
306  ring0Log,"Ring0",heliumLog,false,0);
307 
308  new G4PVPlacement(0,
309  G4ThreeVector(0.,0., halfThicknessHelium - halfThicknessRing),
310  ring1Log,"Ring1",heliumLog,false,0);
311 }
312 
313 
315  G4double halfLengthWorld = fPosScorer/2.;
316  G4double halfThicknessScorer = fThicknessScorer /2.;
317 
318  G4VSolid* scorerSolid = new G4Tubs("scorerSolid", 0.*cm, fRadOverall, halfThicknessScorer, 0.*deg, 360.*deg);
319  G4LogicalVolume* scorerLog = new G4LogicalVolume(scorerSolid, G4Material::GetMaterial("G4_AIR"), "scorerLog");
320 
321  fScorerVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
322  scorerLog->SetVisAttributes(fScorerVisAtt);
323  new G4PVPlacement(0,
324  G4ThreeVector(0.,0., halfLengthWorld - halfThicknessScorer),
325  scorerLog,"Scorer",worldLog,false,0);
326 
327  G4VSolid* scorerRingSolid = new G4Tubs("scorerRingSolid", 0.*cm, fRadOverall, halfThicknessScorer, 0.*deg, 360.*deg);
328  fScorerRingLog = new G4LogicalVolume(scorerRingSolid, G4Material::GetMaterial("G4_AIR"), "scorerRingLog");
329  new G4PVReplica("ScorerRing",fScorerRingLog,scorerLog,kRho,G4int(fRadOverall/fWidthScorerRing),fWidthScorerRing);
330 }
331 
332 
334 {
335  G4String detName = "MyDetector";
337  G4VSensitiveDetector* sdet = SDman->FindSensitiveDetector(detName,false);
338 
339  if (sdet)
340  {
341  G4cout << "Already have the detector" << G4endl;
342  fScorerRingLog->SetSensitiveDetector(sdet);
343  }
344  else
345  {
347 
349 
350  G4String fltName,particleName;
351  G4SDParticleFilter* electronFilter =
352  new G4SDParticleFilter(fltName="electronFilter", particleName="e-");
353 
354  G4VPrimitiveScorer* primitive;
355 
356  primitive = new G4PSCellFlux("cell flux");
357  det->RegisterPrimitive(primitive);
358 
359  primitive = new G4PSCellFlux("e cell flux");
360  primitive->SetFilter(electronFilter);
361  det->RegisterPrimitive(primitive);
362 
363  primitive = new G4PSPopulation("population");
364  det->RegisterPrimitive(primitive);
365 
366  primitive = new G4PSPopulation("e population");
367  primitive->SetFilter(electronFilter);
368  det->RegisterPrimitive(primitive);
369 
371  fScorerRingLog->SetSensitiveDetector(det);
372 
374  }
375 }
376 
377 
379  fMaterialPrimFoil = G4Material::GetMaterial(matname);
380  UpdateGeometry();
381 }
382 
383 
385  fHalfThicknessPrimFoil = thicknessPrimFoil / 2.;
386  UpdateGeometry();
387 }