gparticle
Loading...
Searching...
No Matches
gparticle_example.cc
Go to the documentation of this file.
1
24// gparticle
25#include "gparticle_options.h"
26
27// geant4
28#include "G4RunManagerFactory.hh"
29#include "QBBC.hh"
30
31
47int main(int argc, char* argv[]) {
48 // Build options with the gparticle schema so -gparticle can be parsed.
49 auto gopts = std::make_shared<GOptions>(argc, argv, gparticle::defineOptions());
50
51 // Create a module logger; verbosity controls how much configuration is printed.
52 auto log = std::make_shared<GLogger>(gopts, FUNCTION_NAME, GPARTICLE_LOGGER);
53
54 // Create a Geant4 run manager and install a basic physics list.
55 auto runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
56
57 auto physicsList = new QBBC;
58 runManager->SetUserInitialization(physicsList);
59
60 // Build particles from the structured -gparticle option node.
61 auto particles = gparticle::getGParticles(gopts, log);
62
63 // This example does not execute events; it demonstrates construction and parsing only.
64 delete runManager;
65
66 return EXIT_SUCCESS;
67}
#define FUNCTION_NAME
Public API for defining and parsing gparticle-related options.
constexpr const char * GPARTICLE_LOGGER
vector< GparticlePtr > getGParticles(const std::shared_ptr< GOptions > &gopts, std::shared_ptr< GLogger > &logger)
Builds the list of generator particles from structured options.
GOptions defineOptions()
Defines the structured options used by the gparticle module.
int main(int argc, char *argv[])