ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ElectronBenchmarkDetector.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ElectronBenchmarkDetector.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 //
26 //
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 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
60 fMaterialPrimFoil(0),
61 fLogPrimFoil(0),
62 fSolidPrimFoil(0),
63 fScorerRingLog(0),
64 fLogWorld(0),
65 fMessenger(0),
66 fWorldVisAtt(0),
67 fWindowVisAtt(0),
68 fPrimFoilVisAtt(0),
69 fMonVisAtt(0),
70 fBagVisAtt(0),
71 fHeliumVisAtt(0),
72 fRingVisAtt(0),
73 fScorerVisAtt(0)
74 {
75  // Exit Window
76  fPosWindow0 = 0.000000*cm;
77  fPosWindow1 = 0.004120*cm;
78 
79  // Scattering Foil
80  fPosPrimFoil = 2.650000*cm;
82 
83  // Monitor Chamber
84  fPosMon0 = 5.000000*cm;
85  fPosMon1 = 5.011270*cm;
86 
87  // Helium Bag
88  fPosBag0 = 6.497500*cm;
89  fPosHelium0 = 6.500000*cm;
90  fPosHelium1 = 116.500000*cm;
91  fPosBag1 = 116.502500*cm;
92  fThicknessRing = 1.4*cm;
93 
94  // Scoring Plane
95  fPosScorer = 118.200000*cm;
96  fThicknessScorer= 0.001*cm;
97  fWidthScorerRing= 0.1*cm;
98 
99  // Radii
100  fRadOverall = 23.3*cm;
101  fRadRingInner = 20.0*cm;
102 
103  // Extra space remaining in world volume around apparatus
104  fPosDelta = 1.*cm;
105  fRadDelta = 0.1*cm;
106 
108  DefineMaterials();
109 }
110 
111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
112 
114 {
115  delete fMessenger;
116 
117  delete fWorldVisAtt;
118  delete fWindowVisAtt;
119  delete fPrimFoilVisAtt;
120  delete fMonVisAtt;
121  delete fBagVisAtt;
122  delete fHeliumVisAtt;
123  delete fRingVisAtt;
124  delete fScorerVisAtt;
125 }
126 
127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
128 
130 {
131  return CreateGeometry();
132 }
133 
134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
135 
137  // Use NIST database for elements and materials whereever possible.
139  man->SetVerbose(1);
140 
141  // Take all elements and materials from NIST
142  man->FindOrBuildMaterial("G4_He");
143  man->FindOrBuildMaterial("G4_Be");
144  man->FindOrBuildMaterial("G4_Al");
145  man->FindOrBuildMaterial("G4_Ti");
146  man->FindOrBuildMaterial("G4_Ta");
147  man->FindOrBuildMaterial("G4_AIR");
148  man->FindOrBuildMaterial("G4_MYLAR");
149 
150  G4Element* C = man->FindOrBuildElement("C");
151  G4Element* Cu = man->FindOrBuildElement("Cu");
152  G4Element* Au = man->FindOrBuildElement("Au");
153  G4Element* Ti = man->FindOrBuildElement("Ti");
154  G4Element* Al = man->FindOrBuildElement("Al");
155  G4Element* V = man->FindOrBuildElement("V");
156 
157  // Define materials not in NIST.
158  // While the NIST database does contain default materials for C, Cu and Au,
159  // those defaults have different densities than the ones used in the
160  // benchmark specification.
161  G4double density;
162  G4int ncomponents;
163  G4double fractionmass;
164 
165  G4Material* G4_C = new G4Material("G4_C", density= 2.18*g/cm3,
166  ncomponents=1);
167  G4_C->AddElement(C, fractionmass=1.00);
168 
169  G4Material* G4_Cu = new G4Material("G4_Cu", density= 8.92*g/cm3,
170  ncomponents=1);
171  G4_Cu->AddElement(Cu, fractionmass=1.00);
172 
173  G4Material* G4_Au = new G4Material("G4_Au", density= 19.30*g/cm3,
174  ncomponents=1);
175  G4_Au->AddElement(Au, fractionmass=1.00);
176 
177  G4Material* TiAlloy = new G4Material("TiAlloy", density= 4.42*g/cm3,
178  ncomponents=3);
179  TiAlloy->AddElement(Ti, fractionmass=0.90);
180  TiAlloy->AddElement(Al, fractionmass=0.06);
181  TiAlloy->AddElement(V, fractionmass=0.04);
182 
183  // Print materials table
185 }
186 
187 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
188 
190  // Clean old geometry, if any
195 
196  // Instantiate the world
197  G4VPhysicalVolume* physiworld = CreateWorld();
198  fLogWorld = physiworld->GetLogicalVolume();
199 
200  // Instantiate the geometry
205 
206  // Create the scorers
208 
209  return physiworld;
210 }
211 
212 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
213 
215  G4double halfLengthWorld = fPosScorer/2. + fPosDelta;
216  G4double radWorld = fRadOverall + fRadDelta;
217  G4VSolid* worldSolid = new G4Tubs("WorldSolid", 0.*cm, radWorld,
218  halfLengthWorld, 0.*deg, 360.*deg);
219  G4LogicalVolume* worldLog = new G4LogicalVolume(worldSolid,
220  G4Material::GetMaterial("G4_AIR"), "WorldLog");
221 
222  fWorldVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,1.0));
223  worldLog->SetVisAttributes(fWorldVisAtt);
224 
225  G4VPhysicalVolume* worldPhys =
226  new G4PVPlacement(0, G4ThreeVector(0.,0.,0.),
227  worldLog,"World", 0, false, 0);
228 
229  return worldPhys;
230 }
231 
232 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
233 
235  G4double halfLengthWorld = fPosScorer/2.;
236  G4double halfThicknessWindow = fPosWindow1/2.;
237  G4VSolid* windowSolid = new G4Tubs("windowSolid", 0.*cm, fRadOverall,
238  halfThicknessWindow, 0.*deg, 360.*deg);
239  G4LogicalVolume* windowLog = new G4LogicalVolume(windowSolid,
240  G4Material::GetMaterial("TiAlloy"),
241  "windowLog");
242 
243  fWindowVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
244  windowLog->SetVisAttributes(fWindowVisAtt);
245 
246  new G4PVPlacement(0,
247  G4ThreeVector(0.,0.,
248  halfThicknessWindow - halfLengthWorld),
249  windowLog,"ExitWindow",worldLog,false,0);
250 }
251 
252 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
253 
255  G4double halfLengthWorld = fPosScorer/2.;
256 
257  // For some energies, we have no Primary Foil.
258  if (fHalfThicknessPrimFoil==0.) return;
259 
260  fSolidPrimFoil = new G4Tubs("PrimFoilSolid", 0.*cm, fRadOverall,
261  fHalfThicknessPrimFoil, 0.*deg, 360.*deg);
263  fMaterialPrimFoil, "PrimFoilLog");
264 
265  fPrimFoilVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
267 
268  new G4PVPlacement(0,
269  G4ThreeVector(0.,0.,
270  fPosPrimFoil + fHalfThicknessPrimFoil - halfLengthWorld),
271  fLogPrimFoil,"ScatteringFoil",worldLog,false,0);
272 }
273 
274 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
275 
277  G4double halfLengthWorld = fPosScorer/2.;
278  G4double halfThicknessMon = (fPosMon1 - fPosMon0) /2.;
279  G4VSolid* monSolid = new G4Tubs("monSolid", 0.*cm, fRadOverall,
280  halfThicknessMon, 0.*deg, 360.*deg);
281  G4LogicalVolume* monLog = new G4LogicalVolume(monSolid,
282  G4Material::GetMaterial("G4_MYLAR"),
283  "monLog");
284 
285  fMonVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
286  monLog->SetVisAttributes(fMonVisAtt);
287 
288  new G4PVPlacement(0,
289  G4ThreeVector(0.,0.,
290  fPosMon0 + halfThicknessMon - halfLengthWorld),
291  monLog,"MonitorChamber",worldLog,false,0);
292 }
293 
294 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
295 
297  G4double halfLengthWorld = fPosScorer/2.;
298 
299  // Construct cylinder of Mylar
300  G4double halfThicknessBag = (fPosBag1 - fPosBag0) /2.;
301  G4VSolid* bagSolid = new G4Tubs("bagSolid", 0.*cm, fRadOverall,
302  halfThicknessBag, 0.*deg, 360.*deg);
303  G4LogicalVolume* bagLog = new G4LogicalVolume(bagSolid,
304  G4Material::GetMaterial("G4_MYLAR"),
305  "bagLog");
306 
307  fBagVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
308  bagLog->SetVisAttributes(fBagVisAtt);
309 
310  new G4PVPlacement(0,
311  G4ThreeVector(0.,0.,
312  fPosBag0 + halfThicknessBag - halfLengthWorld),
313  bagLog,"HeliumBag",worldLog,false,0);
314 
315  // Insert cylinder of Helium into the Cylinder of Mylar
316  G4double halfThicknessHelium = (fPosHelium1 - fPosHelium0) /2.;
317  G4VSolid* heliumSolid = new G4Tubs("heliumSolid", 0.*cm, fRadOverall,
318  halfThicknessHelium, 0.*deg, 360.*deg);
319  G4LogicalVolume* heliumLog = new G4LogicalVolume(heliumSolid,
320  G4Material::GetMaterial("G4_He"),
321  "heliumLog");
322 
323  fHeliumVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
324  heliumLog->SetVisAttributes(fHeliumVisAtt);
325 
326  new G4PVPlacement(0, G4ThreeVector(0.,0.,0.),
327  heliumLog,"Helium",bagLog,false,0);
328 
329  // Insert two rings of Aluminum into the Cylinder of Helium
330  G4double halfThicknessRing = fThicknessRing /2.;
331  G4VSolid* ringSolid = new G4Tubs("ringSolid", fRadRingInner, fRadOverall,
332  halfThicknessRing, 0.*deg, 360.*deg);
333  G4LogicalVolume* ring0Log = new G4LogicalVolume(ringSolid,
334  G4Material::GetMaterial("G4_Al"),
335  "ring0Log");
336  G4LogicalVolume* ring1Log = new G4LogicalVolume(ringSolid,
337  G4Material::GetMaterial("G4_Al"),
338  "ring1Log");
339 
340  fRingVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
341  ring0Log->SetVisAttributes(fRingVisAtt);
342  ring1Log->SetVisAttributes(fRingVisAtt);
343 
344  new G4PVPlacement(0,
345  G4ThreeVector(0.,0.,
346  -halfThicknessHelium + halfThicknessRing),
347  ring0Log,"Ring0",heliumLog,false,0);
348 
349  new G4PVPlacement(0,
350  G4ThreeVector(0.,0.,
351  halfThicknessHelium - halfThicknessRing),
352  ring1Log,"Ring1",heliumLog,false,0);
353 }
354 
355 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
356 
358  G4double halfLengthWorld = fPosScorer/2.;
359  G4double halfThicknessScorer = fThicknessScorer /2.;
360 
361  G4VSolid* scorerSolid = new G4Tubs("scorerSolid", 0.*cm, fRadOverall,
362  halfThicknessScorer, 0.*deg, 360.*deg);
363  G4LogicalVolume* scorerLog = new G4LogicalVolume(scorerSolid,
364  G4Material::GetMaterial("G4_AIR"),
365  "scorerLog");
366 
367  fScorerVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,0.5));
368  scorerLog->SetVisAttributes(fScorerVisAtt);
369  new G4PVPlacement(0,
370  G4ThreeVector(0.,0.,
371  halfLengthWorld - halfThicknessScorer),
372  scorerLog,"Scorer",worldLog,false,0);
373 
374  G4VSolid* scorerRingSolid = new G4Tubs("scorerRingSolid", 0.*cm,
375  fRadOverall,
376  halfThicknessScorer, 0.*deg, 360.*deg);
377  fScorerRingLog = new G4LogicalVolume(scorerRingSolid,
378  G4Material::GetMaterial("G4_AIR"), "scorerRingLog");
379  new G4PVReplica("ScorerRing",fScorerRingLog,scorerLog,kRho,
381 
383 }
384 
385 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
386 
387 // Note that this method is called both at start of job and again after
388 // any command causes a change to detector geometry
390 {
392 
393  // G4Cache mechanism is necessary for multi-threaded operation
394  // as it allows us to store separate detector pointer per thread
395  G4MultiFunctionalDetector*& sensitiveDetector =
397 
398  if (!sensitiveDetector) {
399  sensitiveDetector = new G4MultiFunctionalDetector("MyDetector");
400 
401  G4VPrimitiveScorer* primitive;
402 
403  G4SDParticleFilter* electronFilter =
404  new G4SDParticleFilter("electronFilter", "e-");
405 
406  primitive = new G4PSCellFlux("cell flux");
407  sensitiveDetector->RegisterPrimitive(primitive);
408 
409  primitive = new G4PSCellFlux("e cell flux");
410  primitive->SetFilter(electronFilter);
411  sensitiveDetector->RegisterPrimitive(primitive);
412 
413  primitive = new G4PSPopulation("population");
414  sensitiveDetector->RegisterPrimitive(primitive);
415 
416  primitive = new G4PSPopulation("e population");
417  primitive->SetFilter(electronFilter);
418  sensitiveDetector->RegisterPrimitive(primitive);
419  }
420  G4SDManager::GetSDMpointer()->AddNewDetector(sensitiveDetector);
421  fScorerRingLog->SetSensitiveDetector(sensitiveDetector);
422 }
423 
424 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
425 
428  if (fLogPrimFoil) {
430  }
433 }
434 
435 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
436 
438 {
439  fHalfThicknessPrimFoil = thicknessPrimFoil / 2.;
440  if (fSolidPrimFoil) {
442  }
445 }
446 
447 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......