gdynamicDigitization
Loading...
Searching...
No Matches
gplugin_test_example.cc
Go to the documentation of this file.
2
3
5
6 double timeWindow = 10; // electronic readout time-window of the detector
7 double gridStartTime = 0; // defines the window grid
8 auto hitBitSet = HitBitSet("100000"); // defines what information to be stored in the hit
9
10 readoutSpecs = std::make_shared<GReadoutSpecs>(timeWindow, gridStartTime, hitBitSet, log);
11
12 return true;
13}
14
15
16bool GPlugin_test_example::loadConstantsImpl(int runno, [[maybe_unused]] std::string const& variation) {
17
18 var1 = 2.0;
19 var2[0] = 1;
20 var2[0] = 2;
21
22 var3.push_back(3.0);
23 var3.push_back(4.0);
24 var3.push_back(5.0);
25 var3.push_back(6.0);
26
27 var4 = "hello";
28
29 log->info(0, " Constants loaded for run number ", runno, " for ctof. var1 is ", var1,
30 ", var2 pointer is ", var2, ", variation is ", variation);
31
32 return true;
33}
34
35
36bool GPlugin_test_example::loadTTImpl([[maybe_unused]] int runno, [[maybe_unused]] std::string const& variation) {
37
38 std::vector<int> element1 = {1, 2, 3, 4, 5};
39 std::vector<int> element2 = {2, 2, 3, 4, 5};
40
41 GElectronic crate1(2, 1, 3, 2);
42 GElectronic crate2(2, 1, 4, 2);
43
44 translationTable = std::make_shared<GTranslationTable>(gopts);
45
46 translationTable->addGElectronicWithIdentity(element1, crate1);
47 translationTable->addGElectronicWithIdentity(element2, crate2);
48
49 auto retrievedElectronic = translationTable->getElectronics(element1);
50
51 return true;
52}
53
54
55
56[[nodiscard]] std::unique_ptr<GDigitizedData> GPlugin_test_example::digitizeHitImpl(GHit* ghit, [[maybe_unused]] size_t hitn) {
57 // return a new GDigitizedData object with some data derived from the hit
58 auto digitizedData = std::make_unique<GDigitizedData>(gopts, ghit);
59
60 auto edep = ghit->getTotalEnergyDeposited();
61
62 double digi_time = 0;
63
64 for (auto& time : ghit->getTimes()) { digi_time += time * 10; }
65
66 digitizedData->includeVariable("edep", edep);
67 digitizedData->includeVariable("digi_time", digi_time);
68
69 return digitizedData;
70}
71
72
73// tells the DLL how to create a GPlugin_test_example in each plugin .so/.dylib
74extern "C" GDynamicDigitization* GDynamicDigitizationFactory(const std::shared_ptr<GOptions>& g) {
75 return static_cast<GDynamicDigitization*> (new GPlugin_test_example(g));
76}
Abstract base class for dynamic digitization functionality.
std::shared_ptr< GOptions > gopts
Optional pointer to GOptions.
std::shared_ptr< const GReadoutSpecs > readoutSpecs
After init, we never mutate these:
bool loadConstantsImpl(int runno, std::string const &variation) override
bool loadTTImpl(int runno, std::string const &variation) override
std::unique_ptr< GDigitizedData > digitizeHitImpl(GHit *ghit, size_t hitn) override
bool defineReadoutSpecsImpl() override
GDynamicDigitization * GDynamicDigitizationFactory(const std::shared_ptr< GOptions > &g)