Fermilab Computing Division

CS Document 5076-v1

ArtG4: A generic framework for Geant4 simulations (CHEP2013)

Document #:
Document type:
Submitted by:
Adam Lyon
Updated by:
Adam Lyon
Document Created:
31 Mar 2013, 18:10
Contents Revised:
31 Mar 2013, 18:10
Metadata Revised:
29 Oct 2013, 00:19
Viewable by:
  • Public document
Modifiable by:

Quick Links:
Latest Version

Other Versions:
29 Oct 2013, 11:22
Flexibility in producing simulations is a highly desirable, but difficult to attain feature. A simulation program may be written for a particular purpose, such as studying a detector or aspect of an experimental apparatus, but adapting that program to answer different questions about that detector or apparatus under different situations may require recoding or a separate fork of the program. The Fermilab Muon g-2 collaboration faced this problem and has written a generic framework for Geant4 simulations that provides the desired flexibility and has had a large positive impact on our ability to quickly produce valuable and effective simulation code.

A stand-alone Geant4 simulation of the Muon g-2 storage ring and detectors, called g2migtrace, had been written previously to test muon storage acceptance and detector response for different apparatus options [1]. This simulation is extremely detailed and contained enormously valuable code describing ring and detector geometry as well as detector response, especially for the crystal calorimeters. Last year a test beam was performed to test different calorimeter designs. In an effort to simulate the test beam conditions but utilize the extensive library of Geant4 code in g2migtrace, a collaborator introduced #ifdef compilation switches to turn the storage ring simulation into a test beam simulation, and checked that code back in to the main branch of the source. These switches make the code extremely difficult to maintain and inflexible. How do we simulate future different test beams? We now have to do tests with these switches. In fact, when built with full compiler optimizations, the code suffered a segmentation fault from a variable left uninitialized due to a poorly placed #ifdef.

The right way to introduce flexibility into the simulation code is to build it in from the start. We have written “ArtG4”, a completely generic framework on top of the Fermilab Art infrastructure [2] used by many Intensity Frontier experiments at Fermilab. Modules defining geometry and response for particular detectors as well as user written Geant4 actions may be arranged into a simulation program with a configuration file. With this system, we can write simulations of the entire muon storage ring as well as test individual detectors in a test beam situation all with the same library of code. This system allows us to work together and rapidly produce many simulations, answering a variety of questions much more easily than before. This system will be fully explained and several examples will be provided.

[1] g2migtrace: Kevin Lynch and Zach Hartwig
[2] C Green et. al., 2012 J. Phys.: Conf. Ser. 396 022020 (CHEP 2012)

Files in Document:
Associated with Events:
CHEP 2013 held on 14 Oct 2013 in Amsterdam, The Netherlands
DocDB Home ]  [ Search ] [ Authors ] [ Events ] [ Topics ]

DocDB Version 8.8.9, contact Document Database Administrators