gtranslationTable
Loading...
Searching...
No Matches
tt_example.cc
Go to the documentation of this file.
1
22
// translationTable
23
#include "
gtranslationTable.h
"
24
#include "
gtranslationTable_options.h
"
25
26
// gemc
27
#include "
glogger.h
"
28
29
using
std::vector;
30
41
int
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
}
GTranslationTable
Stores and retrieves GElectronic configurations by a vector-based identity.
Definition
gtranslationTable.h:36
GTranslationTable::getElectronics
GElectronic getElectronics(const std::vector< int > &identity) const
Retrieves the electronics configuration associated with a given identity vector.
Definition
gtranslationTable.cc:53
GTranslationTable::addGElectronicWithIdentity
void addGElectronicWithIdentity(const std::vector< int > &identity, const GElectronic >ron)
Registers an electronics configuration for a given identity vector.
Definition
gtranslationTable.cc:27
glogger.h
SFUNCTION_NAME
#define SFUNCTION_NAME
gtranslationTable.h
gtranslationTable_options.h
Option definitions for the Translation Table module.
TRANSLATIONTABLE_LOGGER
constexpr const char * TRANSLATIONTABLE_LOGGER
Definition
gtranslationTable_options.h:15
gtranslationTable::defineOptions
GOptions defineOptions()
Defines the module option set for gtranslationTable.
Definition
gtranslationTable_options.cc:6
main
int main(int argc, char *argv[])
GElectronic
examples
tt_example.cc
Generated by
1.10.0