gdynamicDigitization
Loading...
Searching...
No Matches
plugin_load_example.cc File Reference

Example demonstrating how to load and use a gdynamic digitization plugin. More...

Include dependency graph for plugin_load_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 > &gopt, const std::shared_ptr< GLogger > &log, const std::shared_ptr< const gdynamicdigitization::dRoutinesMap > &dynamicRoutinesMap) -> std::vector< std::unique_ptr< GEventDataCollection > >
 Runs a small simulated event loop using multiple worker threads.
 
int main (int argc, char *argv[])
 Example program entry point.
 

Variables

const std::string plugin_name = "test_gdynamic_plugin"
 

Detailed Description

This example shows:

Note
This is an example program, so it intentionally favors clarity over performance tuning.

Definition in file plugin_load_example.cc.

Function Documentation

◆ main()

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

Steps:

  1. Create options using gdynamicdigitization::defineOptions().
  2. Create a logger for this example process.
  3. Load the dynamic routine map.
  4. Load constants for the selected plugin.
  5. Run a short multi-threaded simulation loop.
Parameters
argcStandard argc.
argvStandard argv.
Returns
EXIT_SUCCESS on success.

Definition at line 127 of file plugin_load_example.cc.

◆ run_simulation_in_threads()

auto run_simulation_in_threads ( int nevents,
int nthreads,
const std::shared_ptr< GOptions > & gopt,
const std::shared_ptr< GLogger > & log,
const std::shared_ptr< const gdynamicdigitization::dRoutinesMap > & dynamicRoutinesMap ) -> std::vector<std::unique_ptr<GEventDataCollection>>

Each worker thread repeatedly claims the next event number from an atomic counter, constructs a fresh event container, creates a few hits, and processes them through the loaded dynamic routine.

The routine collects at most two events into the shared output vector to keep the example output small (this also reduces destructor chatter in logs).

Threading model:

  • Uses an atomic counter (next) to distribute unique event numbers
  • Uses a mutex to protect the shared output vector
  • Uses per-thread storage (thread_local) to accumulate events before acquiring the lock
Parameters
neventsNumber of events to simulate (upper bound; some may not be collected).
nthreadsNumber of worker threads to launch.
goptShared options.
logLogger used for informational output.
dynamicRoutinesMapMap of loaded dynamic routines.
Returns
A vector of collected events (limited to two in this example).

Definition at line 48 of file plugin_load_example.cc.

Variable Documentation

◆ plugin_name

const std::string plugin_name = "test_gdynamic_plugin"

Definition at line 24 of file plugin_load_example.cc.