g4system
Loading...
Searching...
No Matches
g4system_example.cc
Go to the documentation of this file.
1
19// gemc
20#include "gworld.h"
21
22// g4system
23#include "g4world.h"
24#include "g4system_options.h"
25
40int main(int argc, char* argv[]) {
41 // Create global option set with g4system options registered.
42 auto gopts = std::make_shared<GOptions>(argc, argv, g4system::defineOptions());
43
44 // Logger used by this example. Verbosity is controlled by the option set.
45 auto log = std::make_shared<GLogger>(gopts, SFUNCTION_NAME, G4SYSTEM_LOGGER);
46
47 // Build the GEMC world definition from the configured options/sources.
48 auto gworld = std::make_shared<GWorld>(gopts);
49
50 // Convert the GEMC world into Geant4 volumes using the g4system module.
51 auto g4world = std::make_shared<G4World>(gworld.get(), gopts);
52
53 // Print the number of volumes in the GEMC world definition.
54 log->info(2, "Number of volumes in the gworld: ", gworld->get_number_of_volumes());
55
56 // Print the list of sensitive detectors declared by the world definition.
57 auto sensitiveDetectors = gworld->getSensitiveDetectorsList();
58 for (const auto& sd : sensitiveDetectors) {
59 log->info(2, "Sensitive detector: ", sd);
60 }
61
62 return EXIT_SUCCESS;
63}
Option definitions for the g4system module (geometry/material construction layer).
constexpr const char * G4SYSTEM_LOGGER
Logger name used by the module-level builder (e.g. G4World).
High-level builder that turns a GEMC world description into Geant4 geometry.
#define SFUNCTION_NAME
GOptions defineOptions()
Define command-line/configuration options for the g4system module.
int main(int argc, char *argv[])