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 {
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"),
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",
79 ".alg file path",
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,
165 } else if (cfn != _gdl->configFile()) {
170 _Phase,
176 }
177 if (_debugLevel > 9) printf("TRGGDLModule::beginRun() ends.\n");
178
179 _gdl->checkDatabase();
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()
Constructor.
Definition HistoModule.h:32
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
std::string _configFilename
Config. file name.
bool _algFromDB
Switch for algorithm source. False when using local .alg file.
int _debugLevel
Debug level.
double _timquality_threshold_sfin
Threshold to determine timing quality flag with MC truth: super fine.
std::string _algFilePath
Path to algorithm file.
std::string _Phase
Phase.
int _simulationMode
Mode for TRGGDL simulation.
bool m_simulateT0Jitter
if True, L1 jitter is simulated by EventT0Generator
int _firmwareSimulationMode
Switch for the firmware simulation. 0:do nothing, 1:do everything.
double _timquality_threshold_fine
Threshold to determine timing quality flag with MC truth: fine.
int _fastSimulationMode
Switch for the fast simulation.
StoreObjPtr< TRGSummary > m_TRGSummary
output for TRGSummary
StoreObjPtr< SimClockState > m_simClockState
generated hardware clock state
The instance of TRGGDL is a singleton.
Definition TRGGDL.h:44
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
virtual void initialize() override
Initializes 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;.
virtual void beginRun() override
Called when new run started.
TRGGDLModule()
Constructor.
std::string version(void) const
returns version of TRGGDLModule.
virtual void defineHisto() override
Define Histogram.
static TRGGDL * getTRGGDL(void)
returns TRGGDL object.
Definition TRGGDL.cc:103
static int level(void)
returns the debug level.
Definition Debug.cc:67
Abstract base class for different kinds of events.
STL namespace.