Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/extended/medical/electronScattering2/src/ElectronBenchmarkDetector.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/medical/electronScattering2/src/ElectronBenchmarkDetector.cc (Version 11.3.0) and /examples/extended/medical/electronScattering2/src/ElectronBenchmarkDetector.cc (Version 10.1.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
                                                   >>  26 // $Id: ElectronBenchmarkDetector.cc 79741 2014-03-13 09:12:06Z gcosmo $
 26 //                                                 27 //
 27 /// \file medical/electronScattering2/src/Elec     28 /// \file medical/electronScattering2/src/ElectronBenchmarkDetector.cc
 28 /// \brief Implementation of the ElectronBench     29 /// \brief Implementation of the ElectronBenchmarkDetector class
 29                                                    30 
 30 #include "ElectronBenchmarkDetector.hh"            31 #include "ElectronBenchmarkDetector.hh"
 31                                                <<  32     
 32 #include "ElectronBenchmarkDetectorMessenger.h     33 #include "ElectronBenchmarkDetectorMessenger.hh"
 33                                                    34 
 34 #include "G4Colour.hh"                         <<  35 #include "G4RunManager.hh"
                                                   >>  36 #include "G4UImanager.hh"
                                                   >>  37 #include "G4NistManager.hh"
 35 #include "G4GeometryManager.hh"                    38 #include "G4GeometryManager.hh"
 36 #include "G4LogicalVolume.hh"                  <<  39 #include "G4PhysicalVolumeStore.hh"
 37 #include "G4LogicalVolumeStore.hh"                 40 #include "G4LogicalVolumeStore.hh"
                                                   >>  41 #include "G4SolidStore.hh"
 38 #include "G4Material.hh"                           42 #include "G4Material.hh"
 39 #include "G4MultiFunctionalDetector.hh"        <<  43 #include "G4Tubs.hh"
 40 #include "G4NistManager.hh"                    <<  44 #include "G4LogicalVolume.hh"
 41 #include "G4PSCellFlux.hh"                     << 
 42 #include "G4PSPopulation.hh"                   << 
 43 #include "G4PVPlacement.hh"                        45 #include "G4PVPlacement.hh"
 44 #include "G4PVReplica.hh"                          46 #include "G4PVReplica.hh"
 45 #include "G4PhysicalVolumeStore.hh"            <<  47 #include "G4VisAttributes.hh"
 46 #include "G4RunManager.hh"                     <<  48 #include "G4Colour.hh"
 47 #include "G4SDManager.hh"                          49 #include "G4SDManager.hh"
 48 #include "G4SDParticleFilter.hh"                   50 #include "G4SDParticleFilter.hh"
 49 #include "G4SolidStore.hh"                     <<  51 #include "G4MultiFunctionalDetector.hh"
 50 #include "G4SystemOfUnits.hh"                  << 
 51 #include "G4Tubs.hh"                           << 
 52 #include "G4UImanager.hh"                      << 
 53 #include "G4VPrimitiveScorer.hh"                   52 #include "G4VPrimitiveScorer.hh"
 54 #include "G4VisAttributes.hh"                  <<  53 #include "G4PSCellFlux.hh"
                                                   >>  54 #include "G4PSPopulation.hh"
                                                   >>  55 #include "G4SystemOfUnits.hh"
 55                                                    56 
 56 //....oooOO0OOooo........oooOO0OOooo........oo     57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 57                                                    58 
 58 ElectronBenchmarkDetector::ElectronBenchmarkDe <<  59 ElectronBenchmarkDetector::ElectronBenchmarkDetector()
 59 {                                              <<  60 :G4VUserDetectorConstruction(),
 60   // Exit Window                               <<  61 fMaterialPrimFoil(0),
 61   fPosWindow0 = 0.000000 * cm;                 <<  62 fScorerRingLog(0),
 62   fPosWindow1 = 0.004120 * cm;                 <<  63 fLogWorld(0),
 63                                                <<  64 fMessenger(0),
 64   // Scattering Foil                           <<  65 fWorldVisAtt(0),
 65   fPosPrimFoil = 2.650000 * cm;                <<  66 fWindowVisAtt(0),
 66   fHalfThicknessPrimFoil = 0.0 * cm;           <<  67 fPrimFoilVisAtt(0),
 67                                                <<  68 fMonVisAtt(0),
 68   // Monitor Chamber                           <<  69 fBagVisAtt(0),
 69   fPosMon0 = 5.000000 * cm;                    <<  70 fHeliumVisAtt(0),
 70   fPosMon1 = 5.011270 * cm;                    <<  71 fRingVisAtt(0),
 71                                                <<  72 fScorerVisAtt(0)
 72   // Helium Bag                                <<  73 {
 73   fPosBag0 = 6.497500 * cm;                    <<  74     // Exit Window
 74   fPosHelium0 = 6.500000 * cm;                 <<  75     fPosWindow0     =   0.000000*cm;
 75   fPosHelium1 = 116.500000 * cm;               <<  76     fPosWindow1     =   0.004120*cm;
 76   fPosBag1 = 116.502500 * cm;                  <<  77     
 77   fThicknessRing = 1.4 * cm;                   <<  78     // Scattering Foil
 78                                                <<  79     fPosPrimFoil    =   2.650000*cm;
 79   // Scoring Plane                             <<  80     fHalfThicknessPrimFoil = 0.0*cm;
 80   fPosScorer = 118.200000 * cm;                <<  81     
 81   fThicknessScorer = 0.001 * cm;               <<  82     // Monitor Chamber
 82   fWidthScorerRing = 0.1 * cm;                 <<  83     fPosMon0        =   5.000000*cm;
 83                                                <<  84     fPosMon1        =   5.011270*cm;
 84   // Radii                                     <<  85     
 85   fRadOverall = 23.3 * cm;                     <<  86     // Helium Bag
 86   fRadRingInner = 20.0 * cm;                   <<  87     fPosBag0        =   6.497500*cm;
 87                                                <<  88     fPosHelium0     =   6.500000*cm;
 88   // Extra space remaining in world volume aro <<  89     fPosHelium1     = 116.500000*cm;
 89   fPosDelta = 1. * cm;                         <<  90     fPosBag1        = 116.502500*cm;
 90   fRadDelta = 0.1 * 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;
 91                                                   105 
 92   fMessenger = new ElectronBenchmarkDetectorMe << 106     fMessenger = new ElectronBenchmarkDetectorMessenger(this);
 93   DefineMaterials();                           << 107     DefineMaterials();
 94 }                                                 108 }
 95                                                   109 
 96 //....oooOO0OOooo........oooOO0OOooo........oo    110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 97                                                   111 
 98 ElectronBenchmarkDetector::~ElectronBenchmarkD    112 ElectronBenchmarkDetector::~ElectronBenchmarkDetector()
 99 {                                                 113 {
100   delete fMessenger;                           << 114     delete fMessenger;
101                                                << 115     
102   delete fWorldVisAtt;                         << 116     delete fWorldVisAtt;
103   delete fWindowVisAtt;                        << 117     delete fWindowVisAtt;
104   delete fPrimFoilVisAtt;                      << 118     delete fPrimFoilVisAtt;
105   delete fMonVisAtt;                           << 119     delete fMonVisAtt;
106   delete fBagVisAtt;                           << 120     delete fBagVisAtt;
107   delete fHeliumVisAtt;                        << 121     delete fHeliumVisAtt;
108   delete fRingVisAtt;                          << 122     delete fRingVisAtt;
109   delete fScorerVisAtt;                        << 123     delete fScorerVisAtt;
110 }                                                 124 }
111                                                   125 
112 //....oooOO0OOooo........oooOO0OOooo........oo    126 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
113                                                   127 
114 G4VPhysicalVolume* ElectronBenchmarkDetector::    128 G4VPhysicalVolume* ElectronBenchmarkDetector::Construct()
115 {                                                 129 {
116   return CreateGeometry();                     << 130     return CreateGeometry();
117 }                                              << 
118                                                << 
119 //....oooOO0OOooo........oooOO0OOooo........oo << 
120                                                << 
121 void ElectronBenchmarkDetector::DefineMaterial << 
122 {                                              << 
123   // Use NIST database for elements and materi << 
124   G4NistManager* man = G4NistManager::Instance << 
125   man->SetVerbose(1);                          << 
126                                                << 
127   // Take all elements and materials from NIST << 
128   man->FindOrBuildMaterial("G4_He");           << 
129   man->FindOrBuildMaterial("G4_Be");           << 
130   man->FindOrBuildMaterial("G4_Al");           << 
131   man->FindOrBuildMaterial("G4_Ti");           << 
132   man->FindOrBuildMaterial("G4_Ta");           << 
133   man->FindOrBuildMaterial("G4_AIR");          << 
134   man->FindOrBuildMaterial("G4_MYLAR");        << 
135                                                << 
136   G4Element* C = man->FindOrBuildElement("C"); << 
137   G4Element* Cu = man->FindOrBuildElement("Cu" << 
138   G4Element* Au = man->FindOrBuildElement("Au" << 
139   G4Element* Ti = man->FindOrBuildElement("Ti" << 
140   G4Element* Al = man->FindOrBuildElement("Al" << 
141   G4Element* V = man->FindOrBuildElement("V"); << 
142                                                << 
143   // Define materials not in NIST.             << 
144   // While the NIST database does contain defa << 
145   // those defaults have different densities t << 
146   // benchmark specification.                  << 
147   G4double density;                            << 
148   G4int ncomponents;                           << 
149   G4double fractionmass;                       << 
150                                                << 
151   G4Material* G4_C = new G4Material("G4_C", de << 
152   G4_C->AddElement(C, fractionmass = 1.00);    << 
153                                                << 
154   G4Material* G4_Cu = new G4Material("G4_Cu",  << 
155   G4_Cu->AddElement(Cu, fractionmass = 1.00);  << 
156                                                << 
157   G4Material* G4_Au = new G4Material("G4_Au",  << 
158   G4_Au->AddElement(Au, fractionmass = 1.00);  << 
159                                                << 
160   G4Material* TiAlloy = new G4Material("TiAllo << 
161   TiAlloy->AddElement(Ti, fractionmass = 0.90) << 
162   TiAlloy->AddElement(Al, fractionmass = 0.06) << 
163   TiAlloy->AddElement(V, fractionmass = 0.04); << 
164                                                << 
165   // Print materials table                     << 
166   G4cout << *(G4Material::GetMaterialTable())  << 
167 }                                              << 
168                                                << 
169 //....oooOO0OOooo........oooOO0OOooo........oo << 
170                                                << 
171 G4VPhysicalVolume* ElectronBenchmarkDetector:: << 
172 {                                              << 
173   if (fPhysiWorld) return fPhysiWorld;         << 
174                                                << 
175   // Instantiate the world                     << 
176   fPhysiWorld = CreateWorld();                 << 
177   fLogWorld = fPhysiWorld->GetLogicalVolume(); << 
178                                                << 
179   // Instantiate the geometry                  << 
180   CreateExitWindow(fLogWorld);                 << 
181   CreatePrimaryFoil(fLogWorld);                << 
182   CreateMonitor(fLogWorld);                    << 
183   CreateHeliumBag(fLogWorld);                  << 
184                                                << 
185   // Create the scorers                        << 
186   CreateScorer(fLogWorld);                     << 
187                                                << 
188   return fPhysiWorld;                          << 
189 }                                                 131 }
190                                                   132 
191 //....oooOO0OOooo........oooOO0OOooo........oo    133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
192                                                   134 
193 G4VPhysicalVolume* ElectronBenchmarkDetector:: << 135 void ElectronBenchmarkDetector::DefineMaterials(){
194 {                                              << 136     // Use NIST database for elements and materials whereever possible.
195   G4double halfLengthWorld = fPosScorer / 2. + << 137     G4NistManager* man = G4NistManager::Instance();
196   G4double radWorld = fRadOverall + fRadDelta; << 138     man->SetVerbose(1);
197   G4VSolid* worldSolid =                       << 139     
198     new G4Tubs("WorldSolid", 0. * cm, radWorld << 140     // Take all elements and materials from NIST
199   G4LogicalVolume* worldLog =                  << 141     man->FindOrBuildMaterial("G4_He");
200     new G4LogicalVolume(worldSolid, G4Material << 142     man->FindOrBuildMaterial("G4_Be");
201                                                << 143     man->FindOrBuildMaterial("G4_Al");
202   fWorldVisAtt = new G4VisAttributes(G4Colour( << 144     man->FindOrBuildMaterial("G4_Ti");
203   worldLog->SetVisAttributes(fWorldVisAtt);    << 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.
                                                   >> 160     G4double density;
                                                   >> 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
                                                   >> 183     G4cout << *(G4Material::GetMaterialTable()) << G4endl;
                                                   >> 184 }
                                                   >> 185 
                                                   >> 186 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 187 
                                                   >> 188 G4VPhysicalVolume* ElectronBenchmarkDetector::CreateGeometry(){
                                                   >> 189     // Clean old geometry, if any
                                                   >> 190     G4GeometryManager::GetInstance()->OpenGeometry();
                                                   >> 191     G4PhysicalVolumeStore::GetInstance()->Clean();
                                                   >> 192     G4LogicalVolumeStore::GetInstance()->Clean();
                                                   >> 193     G4SolidStore::GetInstance()->Clean();
                                                   >> 194     
                                                   >> 195     // Instantiate the world
                                                   >> 196     G4VPhysicalVolume* physiworld = CreateWorld();
                                                   >> 197     fLogWorld = physiworld->GetLogicalVolume();
                                                   >> 198     
                                                   >> 199     // Instantiate the geometry
                                                   >> 200     CreateExitWindow(fLogWorld);
                                                   >> 201     CreatePrimaryFoil(fLogWorld);
                                                   >> 202     CreateMonitor(fLogWorld);
                                                   >> 203     CreateHeliumBag(fLogWorld);
                                                   >> 204     
                                                   >> 205     // Create the scorers
                                                   >> 206     CreateScorer(fLogWorld);
                                                   >> 207     
                                                   >> 208     return physiworld;
                                                   >> 209 }
                                                   >> 210 
                                                   >> 211 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 212 
                                                   >> 213 void ElectronBenchmarkDetector::UpdateGeometry(){
                                                   >> 214     G4RunManager::GetRunManager()->ReinitializeGeometry();
                                                   >> 215 }
                                                   >> 216 
                                                   >> 217 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 218 
                                                   >> 219 G4VPhysicalVolume* ElectronBenchmarkDetector::CreateWorld(){
                                                   >> 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 
                                                   >> 239 void ElectronBenchmarkDetector::CreateExitWindow(G4LogicalVolume* worldLog){
                                                   >> 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 
                                                   >> 259 void ElectronBenchmarkDetector::CreatePrimaryFoil(G4LogicalVolume* worldLog){
                                                   >> 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 
                                                   >> 281 void ElectronBenchmarkDetector::CreateMonitor(G4LogicalVolume* worldLog){
                                                   >> 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 
                                                   >> 301 void ElectronBenchmarkDetector::CreateHeliumBag(G4LogicalVolume* worldLog){
                                                   >> 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 
                                                   >> 362 void ElectronBenchmarkDetector::CreateScorer(G4LogicalVolume* worldLog){
                                                   >> 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,
                                                   >> 385                     G4int(fRadOverall/fWidthScorerRing),fWidthScorerRing);
204                                                   386 
205   G4VPhysicalVolume* worldPhys =               << 387     ConstructSDandField();
206     new G4PVPlacement(0, G4ThreeVector(0., 0., << 
207                                                << 
208   return worldPhys;                            << 
209 }                                              << 
210                                                << 
211 //....oooOO0OOooo........oooOO0OOooo........oo << 
212                                                << 
213 void ElectronBenchmarkDetector::CreateExitWind << 
214 {                                              << 
215   G4double halfLengthWorld = fPosScorer / 2.;  << 
216   G4double halfThicknessWindow = fPosWindow1 / << 
217   G4VSolid* windowSolid =                      << 
218     new G4Tubs("windowSolid", 0. * cm, fRadOve << 
219   G4LogicalVolume* windowLog =                 << 
220     new G4LogicalVolume(windowSolid, G4Materia << 
221                                                << 
222   fWindowVisAtt = new G4VisAttributes(G4Colour << 
223   windowLog->SetVisAttributes(fWindowVisAtt);  << 
224                                                << 
225   new G4PVPlacement(0, G4ThreeVector(0., 0., h << 
226                     "ExitWindow", worldLog, fa << 
227 }                                              << 
228                                                << 
229 //....oooOO0OOooo........oooOO0OOooo........oo << 
230                                                << 
231 void ElectronBenchmarkDetector::CreatePrimaryF << 
232 {                                              << 
233   G4double halfLengthWorld = fPosScorer / 2.;  << 
234                                                << 
235   // For some energies, we have no Primary Foi << 
236   if (fHalfThicknessPrimFoil == 0.) return;    << 
237                                                << 
238   fSolidPrimFoil =                             << 
239     new G4Tubs("PrimFoilSolid", 0. * cm, fRadO << 
240   fLogPrimFoil = new G4LogicalVolume(fSolidPri << 
241                                                << 
242   fPrimFoilVisAtt = new G4VisAttributes(G4Colo << 
243   fLogPrimFoil->SetVisAttributes(fPrimFoilVisA << 
244                                                << 
245   new G4PVPlacement(0,                         << 
246                     G4ThreeVector(0., 0., fPos << 
247                     fLogPrimFoil, "ScatteringF << 
248 }                                              << 
249                                                << 
250 //....oooOO0OOooo........oooOO0OOooo........oo << 
251                                                << 
252 void ElectronBenchmarkDetector::CreateMonitor( << 
253 {                                              << 
254   G4double halfLengthWorld = fPosScorer / 2.;  << 
255   G4double halfThicknessMon = (fPosMon1 - fPos << 
256   G4VSolid* monSolid =                         << 
257     new G4Tubs("monSolid", 0. * cm, fRadOveral << 
258   G4LogicalVolume* monLog =                    << 
259     new G4LogicalVolume(monSolid, G4Material:: << 
260                                                << 
261   fMonVisAtt = new G4VisAttributes(G4Colour(0. << 
262   monLog->SetVisAttributes(fMonVisAtt);        << 
263                                                << 
264   new G4PVPlacement(0, G4ThreeVector(0., 0., f << 
265                     "MonitorChamber", worldLog << 
266 }                                              << 
267                                                << 
268 //....oooOO0OOooo........oooOO0OOooo........oo << 
269                                                << 
270 void ElectronBenchmarkDetector::CreateHeliumBa << 
271 {                                              << 
272   G4double halfLengthWorld = fPosScorer / 2.;  << 
273                                                << 
274   // Construct cylinder of Mylar               << 
275   G4double halfThicknessBag = (fPosBag1 - fPos << 
276   G4VSolid* bagSolid =                         << 
277     new G4Tubs("bagSolid", 0. * cm, fRadOveral << 
278   G4LogicalVolume* bagLog =                    << 
279     new G4LogicalVolume(bagSolid, G4Material:: << 
280                                                << 
281   fBagVisAtt = new G4VisAttributes(G4Colour(0. << 
282   bagLog->SetVisAttributes(fBagVisAtt);        << 
283                                                << 
284   new G4PVPlacement(0, G4ThreeVector(0., 0., f << 
285                     "HeliumBag", worldLog, fal << 
286                                                << 
287   // Insert cylinder of Helium into the Cylind << 
288   G4double halfThicknessHelium = (fPosHelium1  << 
289   G4VSolid* heliumSolid =                      << 
290     new G4Tubs("heliumSolid", 0. * cm, fRadOve << 
291   G4LogicalVolume* heliumLog =                 << 
292     new G4LogicalVolume(heliumSolid, G4Materia << 
293                                                << 
294   fHeliumVisAtt = new G4VisAttributes(G4Colour << 
295   heliumLog->SetVisAttributes(fHeliumVisAtt);  << 
296                                                << 
297   new G4PVPlacement(0, G4ThreeVector(0., 0., 0 << 
298                                                << 
299   // Insert two rings of Aluminum into the Cyl << 
300   G4double halfThicknessRing = fThicknessRing  << 
301   G4VSolid* ringSolid =                        << 
302     new G4Tubs("ringSolid", fRadRingInner, fRa << 
303   G4LogicalVolume* ring0Log =                  << 
304     new G4LogicalVolume(ringSolid, G4Material: << 
305   G4LogicalVolume* ring1Log =                  << 
306     new G4LogicalVolume(ringSolid, G4Material: << 
307                                                << 
308   fRingVisAtt = new G4VisAttributes(G4Colour(0 << 
309   ring0Log->SetVisAttributes(fRingVisAtt);     << 
310   ring1Log->SetVisAttributes(fRingVisAtt);     << 
311                                                << 
312   new G4PVPlacement(0, G4ThreeVector(0., 0., - << 
313                     "Ring0", heliumLog, false, << 
314                                                << 
315   new G4PVPlacement(0, G4ThreeVector(0., 0., h << 
316                     "Ring1", heliumLog, false, << 
317 }                                              << 
318                                                << 
319 //....oooOO0OOooo........oooOO0OOooo........oo << 
320                                                << 
321 void ElectronBenchmarkDetector::CreateScorer(G << 
322 {                                              << 
323   G4double halfLengthWorld = fPosScorer / 2.;  << 
324   G4double halfThicknessScorer = fThicknessSco << 
325                                                << 
326   G4VSolid* scorerSolid =                      << 
327     new G4Tubs("scorerSolid", 0. * cm, fRadOve << 
328   G4LogicalVolume* scorerLog =                 << 
329     new G4LogicalVolume(scorerSolid, G4Materia << 
330                                                << 
331   fScorerVisAtt = new G4VisAttributes(G4Colour << 
332   scorerLog->SetVisAttributes(fScorerVisAtt);  << 
333   new G4PVPlacement(0, G4ThreeVector(0., 0., h << 
334                     "Scorer", worldLog, false, << 
335                                                << 
336   G4VSolid* scorerRingSolid =                  << 
337     new G4Tubs("scorerRingSolid", 0. * cm, fRa << 
338   fScorerRingLog =                             << 
339     new G4LogicalVolume(scorerRingSolid, G4Mat << 
340   new G4PVReplica("ScorerRing", fScorerRingLog << 
341                   G4int(fRadOverall / fWidthSc << 
342 }                                                 388 }
343                                                   389 
344 //....oooOO0OOooo........oooOO0OOooo........oo    390 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
345                                                   391 
346 // Note that this method is called both at sta    392 // Note that this method is called both at start of job and again after
347 // any command causes a change to detector geo    393 // any command causes a change to detector geometry
348 void ElectronBenchmarkDetector::ConstructSDand    394 void ElectronBenchmarkDetector::ConstructSDandField()
349 {                                                 395 {
350   G4SDManager::GetSDMpointer()->SetVerboseLeve << 396     G4SDManager::GetSDMpointer()->SetVerboseLevel(1);
351                                                << 397     
352   // G4Cache mechanism is necessary for multi- << 398     // G4Cache mechanism is necessary for multi-threaded operation
353   // as it allows us to store separate detecto << 399     // as it allows us to store separate detector pointer per thread
354   G4MultiFunctionalDetector*& sensitiveDetecto << 400     G4MultiFunctionalDetector*& sensitiveDetector =
355                                                << 401     fSensitiveDetectorCache.Get();
356   if (!sensitiveDetector) {                    << 402     
357     sensitiveDetector = new G4MultiFunctionalD << 403     if (!sensitiveDetector) {
358                                                << 404         sensitiveDetector = new G4MultiFunctionalDetector("MyDetector");
359     G4VPrimitiveScorer* primitive;             << 405         
360                                                << 406         G4VPrimitiveScorer* primitive;
361     G4SDParticleFilter* electronFilter = new G << 407         
362                                                << 408         G4SDParticleFilter* electronFilter =
363     primitive = new G4PSCellFlux("cell flux"); << 409         new G4SDParticleFilter("electronFilter", "e-");
364     sensitiveDetector->RegisterPrimitive(primi << 410         
365                                                << 411         primitive = new G4PSCellFlux("cell flux");
366     primitive = new G4PSCellFlux("e cell flux" << 412         sensitiveDetector->RegisterPrimitive(primitive);
367     primitive->SetFilter(electronFilter);      << 413         
368     sensitiveDetector->RegisterPrimitive(primi << 414         primitive = new G4PSCellFlux("e cell flux");
369                                                << 415         primitive->SetFilter(electronFilter);
370     primitive = new G4PSPopulation("population << 416         sensitiveDetector->RegisterPrimitive(primitive);
371     sensitiveDetector->RegisterPrimitive(primi << 417         
372                                                << 418         primitive = new G4PSPopulation("population");
373     primitive = new G4PSPopulation("e populati << 419         sensitiveDetector->RegisterPrimitive(primitive);
374     primitive->SetFilter(electronFilter);      << 420         
375     sensitiveDetector->RegisterPrimitive(primi << 421         primitive = new G4PSPopulation("e population");
376   }                                            << 422         primitive->SetFilter(electronFilter);
377   G4SDManager::GetSDMpointer()->AddNewDetector << 423         sensitiveDetector->RegisterPrimitive(primitive);
378   fScorerRingLog->SetSensitiveDetector(sensiti << 424     }
                                                   >> 425     
                                                   >> 426     SetSensitiveDetector("scorerRingLog",sensitiveDetector);
379 }                                                 427 }
380                                                   428 
381 //....oooOO0OOooo........oooOO0OOooo........oo    429 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
382                                                   430 
383 void ElectronBenchmarkDetector::SetPrimFoilMat << 431 void ElectronBenchmarkDetector::SetPrimFoilMaterial(G4String matname){
384 {                                              << 432     fMaterialPrimFoil = G4Material::GetMaterial(matname);
385   G4Material* material = G4NistManager::Instan << 433     UpdateGeometry();
386                                                << 
387   if (material && material != fMaterialPrimFoi << 
388     fMaterialPrimFoil = material;              << 
389     if (fLogPrimFoil) {                        << 
390       fLogPrimFoil->SetMaterial(fMaterialPrimF << 
391     }                                          << 
392     G4RunManager::GetRunManager()->PhysicsHasB << 
393   }                                            << 
394 }                                                 434 }
395                                                   435 
396 //....oooOO0OOooo........oooOO0OOooo........oo    436 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
397                                                   437 
398 void ElectronBenchmarkDetector::SetPrimFoilThi    438 void ElectronBenchmarkDetector::SetPrimFoilThickness(G4double thicknessPrimFoil)
399 {                                                 439 {
400   fHalfThicknessPrimFoil = thicknessPrimFoil / << 440     fHalfThicknessPrimFoil = thicknessPrimFoil / 2.;
                                                   >> 441     UpdateGeometry();
401 }                                                 442 }
402                                                   443 
403 //....oooOO0OOooo........oooOO0OOooo........oo    444 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
404                                                   445