gtouchable
Loading...
Searching...
No Matches
gtouchable_example.cc
Go to the documentation of this file.
1// gtouchable example
2//
3// Demonstrates basic usage of the gtouchable module:
4// - Create a module option set and logger.
5// - Build a reference GTouchable from a digitization type and identity string.
6// - Create additional test touchables via GTouchable::create() and compare them.
7
8#include "gtouchable.h"
10
11// gemc
12#include "glogger.h"
13
14using std::string;
15using std::vector;
16
17int main(int argc, char* argv[]) {
18 // Build module options and create a logger instance dedicated to this example.
19 // The logger is configured with the gtouchable module logger name (TOUCHABLE_LOGGER).
20 auto gopts = std::make_shared<GOptions>(argc, argv, gtouchable::defineOptions());
21 auto log = std::make_shared<GLogger>(gopts, SFUNCTION_NAME, TOUCHABLE_LOGGER); // duplicate a touchable logger
22
23 // Reference touchable used for comparisons.
24 auto a_ctof_gtouchable = GTouchable(gopts, "readout", "sector: 5, paddle: 5", {10.0, 20.0, 30.0}, 100.0*CLHEP::g);
25
26 for (unsigned i = 1; i < 10; i++) {
27 // Create a synthetic test touchable with a deterministic identity pattern.
28 GTouchable ctof = *GTouchable::create(log);
29
30 // Compare using GTouchable::operator== semantics:
31 // - identity values first
32 // - then a type-specific discriminator
33 bool is_equal = ctof == a_ctof_gtouchable;
34
35 log->info(" GTouchable: ", ctof, " is equal: ", is_equal ? "true" : "false");
36 }
37
38 return EXIT_SUCCESS;
39}
Represents a touchable sensitive detector element used as a hit-collection discriminator.
Definition gtouchable.h:148
static std::shared_ptr< GTouchable > create(const std::shared_ptr< GOptions > &gopt)
Creates a synthetic readout touchable for testing (options-based).
Definition gtouchable.h:343
#define SFUNCTION_NAME
Options definition entry point for the gtouchable module.
constexpr const char * TOUCHABLE_LOGGER
Logger name used by the gtouchable module.
GOptions defineOptions()
Defines the module options supported by gtouchable.
int main(int argc, char *argv[])