gdetector
Loading...
Searching...
No Matches

Example: build detector geometry, load digitization routines, and run a small multi-threaded digitization loop. More...

#include "gdetectorConstruction.h"
#include "gdetector_options.h"
#include "glogger.h"
#include "event/gEventDataCollection.h"
#include "gdynamicdigitizationConventions.h"
#include "gthreads.h"
#include "G4RunManagerFactory.hh"
#include "QBBC.hh"
#include <atomic>
#include <vector>
#include <memory>
Include dependency graph for gdetector_example.cc:

Go to the source code of this file.

Functions

auto run_simulation_in_threads (int nevents, int nthreads, const std::shared_ptr< GOptions > &gopts, const std::shared_ptr< GLogger > &log, const std::shared_ptr< const GDetectorConstruction > &gdetector) -> std::vector< std::shared_ptr< GEventDataCollection > >
 Runs a digitization loop across multiple worker threads and collects event data.
 
int main (int argc, char *argv[])
 Example program entry point.
 

Detailed Description

This example demonstrates:

  • Constructing aggregated module options via gdetector::defineOptions()
  • Creating GDetectorConstruction and reloading geometry from systems
  • Using digitization routines to load constants/translation tables and process hits
  • Collecting per-event data from multiple worker threads

Definition in file gdetector_example.cc.

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

This program:

  • Builds a GOptions instance using gdetector::defineOptions()
  • Creates a module logger using the gdetector logger name
  • Configures a Geant4 run manager and a reference physics list
  • Constructs GDetectorConstruction and reloads geometry from system definitions
  • Runs a small multi-threaded digitization loop
Parameters
argcStandard program argument count.
argvStandard program argument vector.
Returns
Process exit code.

Definition at line 170 of file gdetector_example.cc.

◆ run_simulation_in_threads()

auto run_simulation_in_threads ( int nevents,
int nthreads,
const std::shared_ptr< GOptions > & gopts,
const std::shared_ptr< GLogger > & log,
const std::shared_ptr< const GDetectorConstruction > & gdetector ) -> std::vector<std::shared_ptr<GEventDataCollection>>

Each worker thread:

  • Claims the next event number via an atomic counter
  • Instantiates an event header and event data container
  • Retrieves the digitization routine for the chosen sensitive detector name
  • Loads constants and translation tables for the chosen (run, variation)
  • Creates a fixed number of synthetic hits and digitizes them
  • Optionally logs a summary of digitized hit counts
Parameters
neventsTotal number of events to process.
nthreadsNumber of worker threads to run.
goptsShared options instance used to configure created objects.
logShared logger instance used for informational and debug output.
gdetectorDetector-construction object providing digitization routines.
Returns
Vector of collected event data objects.
Note
This function demonstrates the threading pattern only; the example uses a fixed sensitive detector name ("flux") and synthetic hit generation for clarity.

Definition at line 59 of file gdetector_example.cc.