Electron scattering benchmark variant 2 (Joseph Perl)
The two examples, electronScattering and electronScattering2 demonstrate how two alternate approaches can be taken to simulating the same electron scattering benchmark experiment.
ElectronScattering2 simulates the experiment with a minimum of user code, whereas the other version of this example shows how to do more of the work directly as the user.
In ElectronScattering2:
Both electronScattering and electronScattering2 simulate a precision electron scattering benchmark experiment performed at NRCC Canada and published as: "Measurement of multiple scattering of 13 and 20 MeV electrons by thin foils," by C. K. Ross, M. R. McEwen, A. F. McDonald, C. D. Cojocaru and B. A. Faddegon, Med. Phys. Volume 35, Issue 9, pp. 4121-4131 (September 2008), DOI: 10.1118/1.2968095
The experiment represents the most accurate benchmark of its type.
A schematic of the experimental setup is shown in NRCC_electron_scat.pdf
The experimental data was itself published, as document number E-MPHYA6-35-034809 at http://www.aip.org/pubservs/epaps.html
The testing of three Monte Carlo simulation codes against this experimental benchmark has been publshed as: "The accuracy of EGSnrc, Geant4 and PENELOPE Monte Carlo systems for the simulation of electron scatter in external beam radiotherapy," by Bruce A Faddegon, Iwan Kawrakow, Yuri Kubyshin, Joseph Perl, Josep Sempau and Laszlo Urban, Phys. Med. Biol. 54 (2009) 6151-6163, DOI:10.1088/0031-9155/54/20/008
This present example, electronScattering2, was the Geant4 code used for this publication.
The geometry is described in the enclosed documument: NRCC_electron_scat.pdf
The default geometry is constructed in the DetectorConstruction class. The parameters of the Primary Foil (material and thickness) are defined from macro commands.
Physics lists are based on modular design. Several modules are instantiated:
EM physics builders are from the G4 kernel physics_lists subdirectory.
Physics lists and options can be (re)set with UI commands
Note that options set through G4EmProcessOptions are global, eg for all particle types. In G4 builders, it is shown how to set options per particle type.
All of the work of the primary event generation is deferred to the G4GeneralParticleSource. The specific characteristics of the source are configured from the macro file, using /gps commands.
Visualization is controlled by the standard G4VisExecutive. The standard set of visualization options is supported. Example macros use HepRepFile.
All of the work of the scoring is done by the standard Geant4 scorers, G4PSCellFlux and G4PSPopulation.
Because the geometry may need to be updated after various /primfoil commands, ElectronBenchmarkDetector is written in such a way that the sensitive detector can have its scorer ring logical volume updated after geometry changes. After any geometry change, ConstructSDandField is again called, setting the sensitive detector to use the logical volume of the updated scorer ring. The same sensitive detector is reused, but the manner in which the sensitive detector pointer is stored for this reuse is complicated by the fact that this example may be run in multi-threaded mode (in which each worker thread has its own sensitive detector). We therefore store the sensitive detector pointer in a G4Cache rather than in a direct pointer.
Macros are provided for all of the 37 different combinations of scattering foils and beam energies that were used in the actual experiment. Separate directories of these macros are provided for the different EM Physics options, Opt0, 1, 2 and 3.
Execute electornScattering2 in 'batch' mode from macro files:
% electronScattering2 <macro_file> <starting_seed> <output_file>
for example, to run the Al1_13MeV case with physics option 2 and a starting random seed of 1:
% electronScattering2 macros/Opt2/Al1_13MeV.mac 1 output/Opt2/Al1_13MeV_1
run.csh Opt2/Al1_13MeV 1
% electronScattering2 macros/vis.mac
Results are given as comma-separated values (csv) files.
This example supports multi-threading. To run in multi-threaded mode, build your Geant4 with the cmake option:
-DGEANT4_BUILD_MULTITHREADED=ON and then set the desired number of threads by inserting the /run/numberOfThreads command into your macro file just before /run/initialize, as in:
/run/numberOfThreads 8
You may also find the output more readable if you use the following command to make output from each thread be collected together:
/control/cout/useBuffer
The visualization macro, /macros/vis.mac demonstrates use of the above two commands. Output from the multiple worker threads is merged by the Merge method at the end of ElectronRun.cc