Milestone #14454: Refactoring LArG4
Delivery of replacement code for LArG4.
This is a refractored version of LArG4 that properly refactors and layers the simulation functionality.
It will factor out Geant4 functionality from LArG4 (putting it back in Geant4) and will abstract out photon and electron transport. A new backtracking solution will be provided. Photon transport includes transport within wave-shifters. Need the photons that get to the detector. The next phase of simulation takes that information and turns it into signals.
#2 Updated by Hans-Joachim Wenzel over 3 years ago
- % Done changed from 0 to 10
configured to use the latest version of Geant 4 (10.3.p01) (Lynn provided git feature branch). Make sure that it passes all the tests. Needs some more work since the Geant 4 initialization has to be called twice so there might be some more work to make sure that the initialization is done in the proper order.
#3 Updated by Hans-Joachim Wenzel over 3 years ago
- % Done changed from 10 to 20
- Replacing physics list by the G4PhysListFactory.
- to add optical physics make use of the G4OpticalPhysics constructor. This will make all optical physics processes available to LArG4. (specially more complicated reflection mechanisms and wavelength shifting etc ...)
- adding the G4StepLimiterPhysics() constructor. While we are currently not using this, this will allow to eventually replace the voxel readout should we decide to do so.
- Use the geant 4 routines to calculate the number of produced scintillation photons instead of currently using a hacked function.
- finally use the geant GetfPostStepDoIt to access the number of optical photons in a proper way.
#4 Updated by Hans-Joachim Wenzel over 3 years ago
- Due date changed from 07/12/2017 to 08/17/2017
The original plan was to incrementally replace parts of the LArG4 code with the updated Geant 4 functionality and interfaces. But it looks like it is easier to do a full replacement.
To test that all the functionality that geant 4 now provides works and delivers good performance a stand alone Geant 4 application was developedLArTest. It uses:
- the new extendable physics list factory (access to all reference physics lists, all em options, all physics constructors special physics lists.)
- use of G4opticalPhysics physics constructor
- use of G4StepLimiterPhysics physics constructor
- access to the number of created photons.
- allows to be run in multi threaded mode.
- is instrumented for profiling and performance testing.
LArTest is now used as part of the standard Geant 4 profiling and testing procedure. We found that:
- access to optical photons (no stacking) performs as expected.
- step limiter might be a more performant way to match G4 stepping to the detector readout.
- we also found features that can be improved to improve memory churn and CPU performance. The test indicate that CPU improvement of more than 20 % can be achieved, a patched version of Geant 4 is already written and currently under review.
The plan now is to make LArTest the prototype for the LArSoft geant 4 module. The short term plan includes:
- make sure LarTest runs from within art.
- Define data product that registers (trackid, position,time,dE/dx, #photons at each step).
- Make all the parameters are accessible via fhicl. (e.g. G4opticalPhysics, Step limiter)
- Add electron recombination (box algo.)
- Add drift of electrons to wire planes → wiresim. (this will be moved out into a separate model later)
- Compare results of replacement with current LarSoft.
#5 Updated by Hans-Joachim Wenzel about 3 years ago
- % Done changed from 20 to 40
- looking into nutools G4Helper already has an compiler option which allows to select the new Geant 4 expendable physics list factory. We already tested the use of this factory with lartest. So the only thing missing would be adding the new G4OpticalPhysics constructor to the factory. Tried to build a modified nutools but have problems with the dependencies.
- as part of validation test suite compared geant 4 cross sections of various particles on p with PDG values making sure that we cover the entire energy range. Looks like especially charged K and pbar cross section that geant 4 uses deviate significantly from the experimental (PDG) values. Send the plots to the experts.
- code review of tag proposed by Soon to make the the access to materials properties table more efficient. (important since this is called at every step when using optical physics) We observe the expected 20% improvement in performance. make install doesn't copy the new header file so the cmake configuration files needed some tweaking (adding the new header to the sources.cmake file). Did detailed analysis of the results and within statistics the results with the tag applied are identical. Unfortunately the tag needs to be applied to a geant4 reference release so probably we have to wait until the next release of geant4 before we can benefit from the speed up.
#7 Updated by Hans-Joachim Wenzel about 3 years ago
Hans data product looks good, with just one concern that the number of photons may be misleading should it be updated later. Perhaps “initial_photons” or something like that? Not sure. Also trust that “G4double” is ok, or will be changed to C++ “double”. We’ve identified Bill S. as someone from MicroBooNE who may be able to help implement further downstream changes working with the project. Encourage LArSoft project to reach out to him and formulate a plan.
I guess we should call both the number of photons and the number of electrons as initial. At the moment these numbers are just proportional to the amount of energy deposited as estimated by Geant4. In a separate step we would need a proper model that divides the deposited energy between scintillation and ionization and might also take saturation effects into account (e.g. Birks for Scintillation)
I am fine with changing G4double to double.
Will talk to Bill next week.
#8 Updated by Gianluca Petrillo about 3 years ago
Note that "at the moment" (in
develop) the electrons are not the initial ones, but they include recombination, attenuation and diffusion.
G4double: please turn that into
double: we don't want to force everybody reading that data product from a ROOT file to have Geant4 installed and configured (without which, the class header won't compile).
#9 Updated by Katherine Lato over 2 years ago
4/30/18 status: The work is largely complete, except for two modules that have not yet been written: the fast photon propagation / optical digitization module, and the response and digitization module for AuxDet detector elements (outside the TPC). The latter module is experiment / detector dependent, so needs to be provided by the experiments by re-factoring existing detsim modules into the new structure.
LArSoft realizes that refactored LArG4 is critical for MCC9. Since there have been issues with meeting deadlines in this work, we propose that we integrate Wes’s changes for the time being, and replace it with the factorized code once it is ready. Wes will present his changes at a LArSoft coordination meeting. These code bases can co-exist.