Belle II Software development
TRGGDLModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#define TRGGDL_SHORT_NAMES
10
11#include <iostream>
12
13#include "trg/trg/Debug.h"
14#include "trg/gdl/modules/trggdl/TRGGDLModule.h"
15//framework
16#include <framework/logging/Logger.h>
17
18using namespace std;
19
20namespace Belle2 {
26 REG_MODULE(TRGGDL);
27
28 TRGGDL*
30
31 string
33 {
34 return string("TRGGDLModule 0.00");
35 }
36
38//TRGGDLModule::TRGGDLModule()
39// : Module::Module(),
40 _debugLevel(0),
41 _configFilename("TRGGDLConfig.dat"),
42 _simulationMode(1),
43 _fastSimulationMode(0),
44 _firmwareSimulationMode(0),
45 _Phase("Phase2"),
46 _algFilePath("ftd.alg")
47 {
48
49 string desc = "TRGGDLModule(" + version() + ")";
50 setDescription(desc);
52
53 addParam("debugLevel", _debugLevel, "Debug Level", _debugLevel);
54 addParam("Belle2Phase", _Phase, "Phase2 or Phase3", _Phase);
55 addParam("ConfigFile",
57 "The filename of CDC trigger config file",
59 addParam("SimulationMode",
61 "TRGGDL simulation switch",
63 addParam("FastSimulationMode",
65 "TRGGDL fast simulation mode",
67 addParam("FirmwareSimulationMode",
69 "TRGGDL firmware simulation mode",
71
72 addParam("algFromDB",
74 "Set false when alg is taken from local file.",
75 true);
76
77 addParam("algFilePath",
78 _algFilePath,
79 ".alg file path",
80 _algFilePath);
81
82 addParam("timquality_threshold_sfin",
84 "Threshold to determine timing quality flag with MC truth: superfine",
85 -1.0);
86
87 addParam("timquality_threshold_fine",
89 "Threshold to determine timing quality flag with MC truth: fine",
90 10.0);
91
92 addParam("simulateT0jitter",
94 "if True, L1 jitter is simulated by EventT0Generator.",
95 false);
96
97 B2DEBUG(100, "TRGGDLModule ... created");
98 }
99
101 {
102
103 if (_gdl)
104 B2DEBUG(100, "good-bye");
105
106 B2DEBUG(100, "TRGGDLModule ... destructed ");
107 }
108
110 {
111
112 oldDir = gDirectory;
113 newDir = gDirectory;
114 oldDir->mkdir("TRGGDLModule");
115 newDir->cd("TRGGDLModule");
116
117 h_inp = new TH1I("hTRGGDL_inp", "input bits from TRGGDLModule", 200, 0, 200);
118 h_ftd = new TH1I("hTRGGDL_ftd", "ftdl bits from TRGGDLModule", 200, 0, 200);
119 h_psn = new TH1I("hTRGGDL_psn", "psnm bits from TRGGDLModule", 200, 0, 200);
120
121 oldDir->cd();
122
123 }
124
125 void
127 {
128
129 REG_HISTOGRAM
130 defineHisto();
131
132// m_TRGSummary.isRequired();
134
135 B2INFO("TRGGDLModule::initialize. simulationMode=" << _simulationMode);
136 if (_simulationMode != 3) {
137 m_TRGGRLInfo.isRequired("TRGGRLObjects");
138 }
139
141 m_simClockState.isRequired();
142
143 m_TRGSummary.registerInDataStore();
144 }
145
146 void
148 {
149
150 //...GDL config. name...
151 string cfn = _configFilename;
152
153 //...GDL...
154 if (_gdl == 0) {
159 _Phase,
161 _algFilePath,
165 } else if (cfn != _gdl->configFile()) {
170 _Phase,
172 _algFilePath,
176 }
177 if (_debugLevel > 9) printf("TRGGDLModule::beginRun() ends.\n");
178
180
181 B2DEBUG(100, "TRGGDLModule ... beginRun called configFile = " << cfn);
182 }
183
184 void
186 {
187
188 if (_debugLevel > 9) printf("TRGGDLModule::event() starts.\n");
189
190 newDir->cd();
191
192 //...GDL simulation...
193 _gdl->update(true);
194 _gdl->simulate();
195 _gdl->accumulateInp(h_inp);
196 _gdl->accumulateFtd(h_ftd);
197 _gdl->accumulatePsn(h_psn);
198
199 //StoreObjPtr<TRGSummary> m_TRGSummary; /**< output for TRGSummary */
200 bool result_summary = false;
201 if (m_TRGSummary) {
202 result_summary = m_TRGSummary->test();
203 } else {
204 B2WARNING("TRGGDLModule.cc: TRGSummary not found. Check it!!!!");
205 }
206 setReturnValue(result_summary);
207
208 oldDir->cd();
209 }
210
211 void
213 {
214 B2DEBUG(200, "TRGGDLModule ... endRun called ");
215 }
216
217 void
219 {
220
221 _gdl->terminate();
222
223 B2DEBUG(100, "TRGGDLModule ... terminate called ");
224 }
225
227} // namespace Belle2
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
void setReturnValue(int value)
Sets the return value for this module as integer.
Definition: Module.cc:220
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
StoreObjPtr< TRGGRLInfo > m_TRGGRLInfo
< required input for TRGGRLInfo
Definition: TRGGDLModule.h:71
std::string _configFilename
Config. file name.
Definition: TRGGDLModule.h:80
bool _algFromDB
Switch for algorithm source. False when using local .alg file.
Definition: TRGGDLModule.h:94
int _debugLevel
Debug level.
Definition: TRGGDLModule.h:77
double _timquality_threshold_sfin
Threshold to determine timing quality flag with MC truth: super fine.
Definition: TRGGDLModule.h:103
int _simulationMode
Mode for TRGGDL simulation.
Definition: TRGGDLModule.h:84
bool m_simulateT0Jitter
if True, L1 jitter is simulated by EventT0Generator
Definition: TRGGDLModule.h:108
int _firmwareSimulationMode
Switch for the firmware simulation. 0:do nothing, 1:do everything.
Definition: TRGGDLModule.h:91
double _timquality_threshold_fine
Threshold to determine timing quality flag with MC truth: fine.
Definition: TRGGDLModule.h:106
int _fastSimulationMode
Switch for the fast simulation.
Definition: TRGGDLModule.h:88
StoreObjPtr< SimClockState > m_simClockState
generated hardware clock state
Definition: TRGGDLModule.h:115
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
virtual void initialize() override
Initilizes TRGGDLModule.
virtual void event() override
Called event by event.
virtual void endRun() override
Called when run ended.
virtual ~TRGGDLModule()
Destructor.
virtual void terminate() override
Called when processing ended.
static TRGGDL * _gdl
A pointer to a TRGGDL;.
Definition: TRGGDLModule.h:113
virtual void beginRun() override
Called when new run started.
TRGGDLModule()
Constructor.
Definition: TRGGDLModule.cc:37
std::string version(void) const
returns version of TRGGDLModule.
Definition: TRGGDLModule.cc:32
virtual void defineHisto() override
Define Histogram.
void checkDatabase() const
Check the content of the DBObjects used by this class.
Definition: TRGGDL.cc:1001
void accumulatePsn(TH1I *)
Accumulate bit info in histogram.
Definition: TRGGDL.cc:994
void terminate(void)
terminates when run is finished
Definition: TRGGDL.cc:179
static TRGGDL * getTRGGDL(void)
returns TRGGDL object.
Definition: TRGGDL.cc:103
void accumulateFtd(TH1I *)
Accumulate bit info in histogram.
Definition: TRGGDL.cc:986
static int level(void)
returns the debug level.
Definition: Debug.cc:67
void update(bool mcAnalysis=true)
updates TRGGDL information.
Definition: TRGGDL.cc:209
void accumulateInp(TH1I *)
Accumulate bit info in histogram.
Definition: TRGGDL.cc:978
std::string configFile(void) const
returns configuration file name.
Definition: TRGGDL.h:334
void simulate(void)
fast trigger simulation.
Definition: TRGGDL.cc:227
Abstract base class for different kinds of events.
STL namespace.