gtranslationTable
Loading...
Searching...
No Matches
tt_example.cc
Go to the documentation of this file.
1
22// translationTable
23#include "gtranslationTable.h"
25
26// gemc
27#include "glogger.h"
28
29using std::vector;
30
41int main(int argc, char* argv[]) {
42 // Build the module options and bind them to the project options infrastructure.
43 auto gopts = std::make_shared<GOptions>(argc, argv, gtranslationTable::defineOptions());
44
45 // Create a logger instance for this example.
46 // Note: this logger is separate from the logger used internally by GTranslationTable via GBase.
47 auto log = std::make_shared<GLogger>(gopts, SFUNCTION_NAME, TRANSLATIONTABLE_LOGGER); // duplicate logger
48
49 // Two distinct identity vectors. In realistic scenarios these may represent detector/channel addressing.
50 vector<int> element1 = {1, 2, 3, 4, 5};
51 vector<int> element2 = {2, 2, 3, 4, 5};
52
53 // Two example electronics configurations to associate with the identities.
54 GElectronic crate1(2, 1, 3, 2);
55 GElectronic crate2(2, 1, 4, 2);
56
57 // Construct the translation table. It will use the same options object for its internal logger setup.
58 GTranslationTable translationTable(gopts);
59
60 // Register both electronics configurations.
61 translationTable.addGElectronicWithIdentity(element1, crate1);
62 translationTable.addGElectronicWithIdentity(element2, crate2);
63
64 // Retrieve one configuration and print it.
65 GElectronic retrievedElectronic = translationTable.getElectronics(element1);
66
67 // Level 0: essential output for a user running the example.
68 log->info(0, "Retrieved electronic: ", retrievedElectronic);
69
70 return EXIT_SUCCESS;
71}
Stores and retrieves GElectronic configurations by a vector-based identity.
GElectronic getElectronics(const std::vector< int > &identity) const
Retrieves the electronics configuration associated with a given identity vector.
void addGElectronicWithIdentity(const std::vector< int > &identity, const GElectronic &gtron)
Registers an electronics configuration for a given identity vector.
#define SFUNCTION_NAME
Option definitions for the Translation Table module.
constexpr const char * TRANSLATIONTABLE_LOGGER
GOptions defineOptions()
Defines the module option set for gtranslationTable.
int main(int argc, char *argv[])