MinGLE: A Minimalist, Configurable, and Pedagogical Geant4 Application Template Journal: Computer Physics Communications
Jing Liu · 2026
Read MinGLE: A Minimalist, Configurable, and Pedagogical Geant4 Application Template Journal: Computer Physics Communications by Jing Liu (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2601-08469.txt.
Introduction
Jing Liu introduces MinGLE, a minimalist template for learning the Geant4 simulation toolkit. The 2026 arXiv paper notes that Geant4 is the standard for simulating particle transport through matter. Its steep learning curve often hinders novice developers, though. MinGLE bridges the gap between being a Geant4 end user and becoming a developer. A small, clear example can teach the toolkit's structure without a huge codebase. Physics students and lab programmers could reach working simulations faster with such a pedagogical starting point.
Catalog record
| CREATOR | Jing Liu |
|---|---|
| YEAR | 2026 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 58 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2601-08469
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
MinGLE: A Minimalist, Configurable, and Pedagogical Geant4 Application Template Journal: Computer Physics Communications Jing Liu Abstract The Geant4 toolkit is the standard for simulating particle transport through matter, yet its steep learning curve often hinders novice developers. This paper introduces MinGLE (Mini Geant4 Learning Example), a minimalist application template designed to bridge the gap between being a Geant4 end user and a developer. By leveraging modern factory classes, text geometry syntax, and the general particle source, MinGLE provides a complete, functional simulation kernel in under 70 lines of C++ code. Its pedagogical innovation lies in an incremental development roadmap formalized through ten testable Git branches and tags. Each stage introduces a core Geant4 component, from user interfaces and physics to scoring and magnetic fields, ensuring that every line of code is motivated by a specific requirement. MinGLE serves as both a powerful, universal starting point for new projects and a step-by-step educational resource, transforming passive documentation into an active, hands-on development experience. 1 Introduction Geant4 [ 1 , 2 , 3 ] is the standard software for simulating the passage of particles through matter, serving as a critical resource for detector design and data analysis across various scientific disciplines. Geant4 positions itself explicitly as a toolkit, obligating users to act as Geant4 application developers instead of end users in that they must understand and correctly assemble several core Geant4 components (run management, physics, geometry, etc.) to create a functional executable. Consequently, the initial learning curve for Geant4 is steep. Official Geant4 examples are designed primarily to demonstrate assembly of various Geant4 components but are frequently tied to specific detector models, requiring significant effort to deconstruct into a universal template. To lower this entry barrier, projects like the Geant4 Example Application with Rich features yet Small footprint (GEARS) [ 4 ] have sought to shield users from C++ development altogether. By enabling the comprehensive configuration of a simulation through external text files, GEARS allows beginners to operate as end users of a pre-built application rather than as developers tasked with assembling a toolkit from scratch. The Geant4 Collaboration has also recognized that the traditional reliance on complex, low-level component assembly is error-prone and requires users to master excessive specific knowledge. Modern components, such as factory classes (e.g., for physics lists and run managers), provide a cleaner, abstracted interface, effectively performing some of this assembly internally. However, these classes are still components of the toolkit. They need to be explicitly called and assembled in C++ code, and this does not convert Geant4 into an end-user-proof application like GEARS. This paper introduces MinGLE (Mini Geant4 Learning Example) [ 5 ] , an application template designed to bridge the gap between being a Geant4 end user and a Geant4 application developer . MinGLE is similar to GEARS in that all essential configurations are done at runtime through macro and text files. However, unlike GEARS, MinGLE contains no Geant4 extension code; it relies exclusively on standard Geant4 components and interfaces. MinGLE serves two primary purposes: • To provide a clean, accessible starting point for developers who prefer a minimalist, standard Geant4 application core. • To act as a transitional learning tool for end users familiar with runtime configuration (e.g., from using GEARS) who now wish to understand and modify the underlying C++ source code. MinGLE provides a complete, contemporary Geant4 application template, mingle.cc , with fewer than 70 lines of C++ code shown entirely in Listing 1 . This minimalism is achieved by leveraging modern Geant4 factory classes and external configuration files, ensuring the program is highly configurable, universal, and easily studied. It is worth noting that even though MinGLE is primarily provided as a template for extension, it already includes all Geant4 essential components to perform a variety of simulation and analysis tasks as it is. ⬇ 1 #include ␣ < G4VUserDetectorConstruction . hh> 2 #include ␣ < G4GlobalMagFieldMessenger . hh> 3 #include ␣ < G4tgbVolumeMgr . hh> 4 #include ␣ < G4AutoDelete . hh> 5 class␣Detector␣ : ␣public␣G4VUserDetectorConstruction 6 { 7 ␣␣public : 8 ␣␣␣␣G4VPhysicalVolume * ␣Construct () ␣ { 9 ␣␣␣␣␣␣G4tgbVolumeMgr :: GetInstance () ->AddTextFile ( "detector.tg" ); 10 ␣␣␣␣␣␣return␣G4tgbVolumeMgr :: GetInstance () ->ReadAndConstructDetector (); 11 ␣␣␣␣ } ␣ ///< load detector definition from a text file "detector.tg" 12 ␣␣␣␣void␣ConstructSDandField () ␣ { 13 ␣␣␣␣␣␣G4AutoDelete :: Register ( new␣G4GlobalMagFieldMessenger ()); 14 ␣␣␣␣ } ␣ ///< enable /globalField/ to set uniform B-field 15 }; 16 17 #include ␣ < G4VUserPrimaryGeneratorAction . hh> 18 #include ␣ < G4GeneralParticleSource . hh> 19 class␣Generator␣ : ␣public␣G4VUserPrimaryGeneratorAction 20 { 21 ␣␣private : 22 ␣␣␣␣G4GeneralParticleSource * ␣fGPS ; 23 ␣␣public : 24 ␣␣␣␣Generator () ␣ : ␣G4VUserPrimaryGeneratorAction () ␣ { ␣fGPS␣ = ␣new␣G4GeneralParticleSource ; ␣ } 25 ␣␣␣␣ ~ Generator () ␣ { ␣delete␣fGPS ; ␣ } 26 ␣␣␣␣void␣GeneratePrimaries ( G4Event␣ * evt ) ␣ { ␣fGPS->GeneratePrimaryVertex ( evt ); ␣ } 27 }; 28 29 #include ␣ < G4VUserActionInitialization . hh> 30 class␣Action␣ : ␣public␣G4VUserActionInitialization 31 { 32 ␣␣public : 33 ␣␣␣␣void␣Build () ␣const␣ { ␣SetUserAction ( new␣Generator ); ␣ } 34 }; 35 36 #include ␣ < G4TScoreNtupleWriter . hh> 37 #include ␣ < G4RunManagerFactory . hh> 38 #include ␣ < G4PhysListFactory . hh> 39 #include ␣ < G4AnalysisManager . hh> 40 #include ␣ < G4ScoringManager . hh> 41 #include ␣ < G4VisExecutive . hh> 42 #include ␣ < G4UIExecutive . hh> 43 #include ␣ < G4UImanager . hh> 44 int␣main ( int␣argc,␣char ** ␣argv ) 45 { 46 ␣␣auto␣run␣ = ␣G4RunManagerFactory :: CreateRunManager (); 47 ␣␣G4ScoringManager :: GetScoringManager (); ␣␣ // activate command-based scorer 48 ␣␣G4TScoreNtupleWriter < G4AnalysisManager>␣writer ; ␣ // enable ntuple recording 49 ␣␣if␣ ( run->GetRunManagerType () ␣ != ␣G4RunManager :: sequentialRM ) 50 ␣␣␣␣writer . SetNtupleMerging ( true ); ␣ // merge ntuples created in multi-threads 51 ␣␣ // load default physics list, or the one specified by $PHYSLIST 52 ␣␣G4PhysListFactory␣f ; ␣run->SetUserInitialization ( f . ReferencePhysList ()); 53 ␣␣run->SetUserInitialization ( new␣Detector ); ␣ // load detector definition 54 ␣␣run->SetUserInitialization ( new␣Action ); ␣ // load particle generator 55 56 ␣␣G4UIExecutive * ␣ui␣ = ␣nullptr ; ␣ // assume batch mode by default 57 ␣␣if␣ ( argc ==1) ␣ui␣ = ␣new␣G4UIExecutive ( argc,␣argv ); ␣ // interactive mode 58 ␣␣ // enable visialization between UI creation and session start 59 ␣␣auto␣vis␣ = ␣new␣G4VisExecutive ( "quiet" ); ␣vis->Initialize (); 60 ␣␣if␣ ( ui ) ␣ { ␣ // start an interactive UI session 61 ␣␣␣␣ui->SessionStart (); ␣delete␣ui ; ␣ // clear memory at the end of UI session 62 ␣␣ } ␣else␣ { ␣ // run a macro file in batch mode 63 ␣␣␣␣G4String␣cmd␣ = ␣ "/control/execute " ,␣macroFile␣ = ␣argv [1]; 64 ␣␣␣␣G4UImanager :: GetUIpointer () ->ApplyCommand ( cmd␣ + ␣macroFile ); 65 ␣␣ } 66 ␣␣delete␣vis ; 67 ␣␣delete␣run ; 68 } Listing 1: Universal, single-file Geant4 application template, mingle.cc , in its entirety. Table 1: Guided Geant4 application development roadmap labeled with Git branches and tags. Stage Milestone Branch Tag Focus 0 user interface ui v0 interact with Geant4 via TUI/GUI and navigate the macro command tree 1 batch execution batch v1 transition from interactive exploration to automated batch-mode execution 2 run manager run v2 initialize the simulation kernel and understand the lifecycle of a simulation 3 physics list physics