New techniques in Monte Carlo simulation:
experience with a prototype of generic programming
application to Geant4 physics processes
Maria Grazia Pia
INFN Genova, Italy
Maria Grazia Pia1, Mauro Augelli2, Marcia Begalli3, Lina Quintieri4,
Paolo Saracco1, Manju Sudhakar1, Georg Weidenspointner5, Andreas Zoglauer6
Sezione di Genova, Italy – 2 CNES, France
3 State University Rio de Janeiro, Brazil – 4 INFN Laboratori Nazionali di Frascati, Italy
5 MPE and MPI Halbleiterlabor, Germany – 6 University of California at Berkeley, USA
1 INFN
SNA + MC 2010
Joint International Conference on
Supercomputing in Nuclear Applications + Monte Carlo 2010
Maria Grazia Pia, INFN Genova
Acknowledgments
The physics models and original implementations of the physics
processes mentioned in this talk derive from Geant4 Standard and Low
Energy Electromagnetic packages as in Geant4 9.1 (9.2)
Thanks to
Sergio Bertolucci (INFN and CERN)
Tom Evans (ORNL)
Simone Giani (CERN)
Alessandro Montanari (INFN Bologna)
Andreas Pfeiffer (CERN)
for helpful discussions and advice
The performance results concerning Compton scattering in Geant4 are
published in IEEE NSS 2008 proceedings (F. Longo, L. Pandola and M.G. Pia)
Maria Grazia Pia, INFN Genova
Courtesy CMS Collaboration
Courtesy ATLAS Collaboration
Courtesy H. Araujo and
A. Howard, IC London
S. Agostinelli et al.
GEANT4 - a simulation toolkit
NIM A 506 (2003) 250-303
Born from the requirements of
large scale HEP experiments
>140000 papers
Widely used also in
since 1990
 Space science and astronomy
 Medical physics, nuclear medicine
nd most cited
2
 Radiation protection
CERN/INFN paper
 Accelerator physics
 Humanitarian projects, security
“Modern classic”
 etc.
Courtesy GATE
Technology transfer to industry, hospitals…
Collaboration
ZEPLIN III
Courtesy R. Nartallo et al.,ESA
Maria Grazia Pia, INFN Genova
Courtesy Borexino
Most cited
“Nuclear Science
and Technology”
publication!
πάντα ῥεῖ
Geant4 is a mature Monte Carlo system nowadays
Widely used in a variety of experimental applications
LHC has entered production phase
1994 – 1998
Pioneering project in HEP environment
Cutting-edge technology
Rigorous software development methodologies
New software technologies have emerged since then
Could Geant4 profit from them?
More than one decade’s growth since RD44
Could Geant4 be rejuvenated by pruning ?
Maria Grazia Pia, INFN Genova
Generic programming
Powerful paradigm
“Bringing aspects of generic programming into the mainstream is most
likely C++’s greatest contribution to the software development community
during this period.” B. Stroustrup, Proc. 3rd ACM SIGPLAN Conf. on History of
programming languages, 2007
Drawbacks
code bloat
compiler support
poor error messages, cumbersome debugging
Explore pro and contra by means of a prototype
Small enough to require relatively limited investment
Large enough for the exercise to be meaningful
Quantitative metrics
Maria Grazia Pia, INFN Genova
First introduced in Geant4
S. Chauvie et al., Geant4 physics processes for
microdosimetry simulation: design foundation
and implementation of the first set of models
Policy-based design
IEEE Trans. Nucl. Sci., vol. 54, no. 6, 2619-2628, 2007
A policy defines a class or class template interface
Policy host classes are parameterised classes
Advantages
Policies are not required to inherit from a base class
The code is bound at compile time
 No need of virtual methods, resulting in faster execution
Weak dependency of the policy and the
policy based class on the policy interface
C++ is capable of a
Turing machine
at two levels
Syntax-oriented rather than signature-oriented
Highly customizable design
Maria Grazia Pia, INFN Genova
R&D!
Exploit both
Mix and match
R&D on generic programming techniques
in Geant4 physics
UP: iterative and incremental software process
1st cycle: propaedeutic exploration
Problem domain
analysis
Dismount Geant4 physics processes
Identify objects subject to mutability
Added complexity
Deterioration of performance?
Side requirements
Agility of configuration
Transparency
Easy verification & validation
Technology
Support to requirements
Maria Grazia Pia, INFN Genova
Vision
Metrics
Software development process
Software performance
Extension to charged particle interactions
Metrics
I2: Low Energy Electrons and Photons
Design, development and validation of electron ionisation models for nano-scale simulation
Evaluation on satellite domains
Metrics
G3: Information Technology and its Applications
Physics data management tools: computational evolutions and benchmarks
b-testing in concrete use cases
Metrics
Maria Grazia Pia, INFN Genova
Some of these processes are concurrent
1st prototype: photon interactions
TCrossSection
TGenerator
G4TRDPhotonProcess
<<bind>>
G4CrossSectionComptonStandard,G4GeneratorComptonDataLib
<<bind>>
G4CrossSectionDataLib, G4GeneratorComptonDataLib
<<typedef>>
G4ComptonStandardDataLib
<<typedef>>
G4ComptonDataLib
<<bind>>
G4CrossSectionComptonStandard,G4GeneratorComptonStandard
etc.
<<bind>>
G4CrossSectionComptonPenelope,G4GeneratorComptonPenelope
<<typedef>>
G4ComptonPenelope
Maria Grazia Pia, INFN Genova
<<typedef>>
G4ComptonStandard
A condition of complete simplicity
(Costing not less than everything)
T.S. Eliot, Four Quartets (Little Gidding)
Interface: only
mandatory inherited
pure virtual functions
Maria Grazia
Pia, INFN Genova
typedef
G4PhotonProcess<G4CrossSectionComptonStandard,G4GeneratorComptonStandard>
G4ComptonStandard>
Minimalism…
G4VEMModel
G4VEMProcess
Maria Grazia Pia, INFN Genova
Compton cross section % difference
Library-Penelope
Different
scale!
Si, Z=14
Library-Standard
Agility
Si, Z=14
Example: Compton in Si
1 keV – 100 GeV
Different
scale!
c2 test NIST Phys. Ref. Data
Penelope-Standard
p-value
Library
0.982
Penelope
<0.001
0.993 excluding 1 keV
0.189
Standard
Maria Grazia Pia, INFN Genova
Different
scale!
Si, Z=14
There is only the fight to recover what has been lost
And found and lost again and again: and now, under conditions
That seem unpropitious.
T.S. Eliot, Four Quartets (East Coker)
Doppler broadening in Compton scattering
Si, 40 keV
Cs, 400 keV
Validation on
experimental data
by Namito et al.
Library Penelope Standard final state Generators
Maria Grazia
Pia, INFN does
Genova make sense. And is transparently exposed.
Yes,
physics
Performance improvement
(where no improvement is expected)
Example: Penelope Compton
NO ATTEMPT [yet] TO IMPROVE THE IMPLEMENTATION
40 keV, 106 events, Intel Core2 Duo Processor E6420, 2.13 GZ, 4 GB RAM
C
Si
Cu
W
Policy-based design Geant4 9.1
4.15
6.08
6.23
8.37
7.64
10.78
14.06
19.18
Gain
32%
26%
29%
27%
Move lowenergy-Penelope to Standard package design: ~10% gain,
including implementation improvements
Source: L. Pandola, http://workgroup.lngs.infn.it/geant4lns/group-meetings-directory/l.pandola
Low Energy – Library: 28% gain with policy-based design
Maria Grazia Pia, INFN Genova
Metrics
Photon cross sections test
K. Amako et al.,
Comparison of Geant4 electromagnetic physics models against the NIST reference data
IEEE Trans. Nucl. Sci., vol. 52, no. 4, pp. 910-918, Aug. 2005
Old G4-NIST comparison test
Test
with new design
Maria Grazia Pia, INFN Genova
4134 LoC*
O(months) CPU+human time
<50 LoC*, O(human minutes)
Adopt best practices, build on existing body of knowledge
Maria Grazia Pia, INFN Genova
Physics on a diet
Strive for
simplicity, transparency, agility
The design exposes the physics at very fine granularity
Unprecedented opportunity for thorough validation
Identification of epistemic uncertainties
Only a fraction of Geant4
physics has documented
validation in the literature
Similarities and differences among Geant4 models
Accuracy
Computational performance
Toolkit nature of Geant4: provide a variety of models
Replicas of the same physics functionality?
Often result of evolution: initially they were different
Pruning keeps trees healthier!
Cost of maintenance of a complex software system
Long time scale of LHC operation (various developers will be retired)
Maria Grazia Pia, INFN Genova
No charged photons
Maria Grazia Pia, INFN Genova
No nostalgia of FORTRAN common block…
G4VEMProcess
Encapsulation
robustness, transparency
G4VEMModel
Maria Grazia Pia, INFN Genova
Design, design, design…
src/G4BetheBlochModel.cc:
fParticleChange = reinterpret_cast<G4ParticleChangeForLoss*>
src/G4BetheHeitlerModel.cc: fParticleChange = reinterpret_cast<G4ParticleChangeForGamma*>(pParticleChange);
src/G4BraggIonModel.cc: reinterpret_cast<G4ParticleChangeForLoss*>(pParticleChange);
src/G4BraggModel.cc: reinterpret_cast<G4ParticleChangeForLoss*>(pParticleChange);
src/G4eBremsstrahlungModel.cc: fParticleChange = reinterpret_cast<G4ParticleChangeForLoss*>(pParticleChange);
src/G4eBremsstrahlungRelModel.cc: fParticleChange = reinterpret_cast<G4ParticleChangeForLoss*>(pParticleChange);
src/G4eCoulombScatteringModel.cc:
reinterpret_cast<G4ParticleChangeForGamma*>(pParticleChange);
src/G4KleinNishinaCompton.cc: fParticleChange = reinterpret_cast<G4ParticleChangeForGamma*>(pParticleChange);
src/G4MollerBhabhaModel.cc: fParticleChange = reinterpret_cast<G4ParticleChangeForLoss*>
src/G4MscModel71.cc: fParticleChange = reinterpret_cast<G4ParticleChangeForMSC*>(pParticleChange);
src/G4MultipleScattering71.cc: model = dynamic_cast<G4MscModel71*>(SelectModel(e));
src/G4PEEffectModel.cc: fParticleChange = reinterpret_cast<G4ParticleChangeForGamma*>(pParticleChange);
src/G4UrbanMscModel2.cc: fParticleChange = reinterpret_cast<G4ParticleChangeForMSC*>(pParticleChange);
src/G4UrbanMscModel90.cc: fParticleChange = reinterpret_cast<G4ParticleChangeForMSC*>(pParticleChange);
src/G4UrbanMscModel.cc: fParticleChange = reinterpret_cast<G4ParticleChangeForMSC*>(pParticleChange);
Maria Grazia Pia, INFN Genova
The only wisdom we can hope to acquire
Is the wisdom of humility: humility is endless.
T.S. Eliot, Four Quartets (East Coker)
First considerations
The technology looks promising for application to a large,
complex, computationally intensive physics simulation domain
Enormous gain in
Transparency
Agility
Easy verification and validation
Maintenance effort
Significant performance improvement
At a very early stage of the project, still room for further improvement
But there is still a long way to go…
Maria Grazia Pia, INFN Genova
Scarica

Geant4 Space Workshop - DNA