Belle II Software  release-05-02-19
TRGGDLModule.cc
1 //-----------------------------------------------------------------------------
2 // $Id$
3 //-----------------------------------------------------------------------------
4 // Filename : TRGGDLModule.cc
5 // Section : TRG GDL
6 // Owner : Yoshihito Iwasaki
7 // Email : yoshihito.iwasaki@kek.jp
8 //-----------------------------------------------------------------------------
9 // Description : A trigger module for GDL
10 //-----------------------------------------------------------------------------
11 // 0.00 : 2013/12/13 : First version
12 //-----------------------------------------------------------------------------
13 
14 #define TRGGDL_SHORT_NAMES
15 
16 #include <iostream>
17 
18 #include "trg/trg/Debug.h"
19 #include "trg/gdl/modules/trggdl/TRGGDLModule.h"
20 //framework
21 #include <framework/logging/Logger.h>
22 
23 using namespace std;
24 
25 namespace Belle2 {
31  REG_MODULE(TRGGDL);
32 
33  TRGGDL*
34  TRGGDLModule::_gdl = 0;
35 
36  string
37  TRGGDLModule::version() const
38  {
39  return string("TRGGDLModule 0.00");
40  }
41 
42  TRGGDLModule::TRGGDLModule() : HistoModule(),
43 //TRGGDLModule::TRGGDLModule()
44 // : Module::Module(),
45  _debugLevel(0),
46  _configFilename("TRGGDLConfig.dat"),
47  _simulationMode(1),
48  _fastSimulationMode(0),
49  _firmwareSimulationMode(0),
50  _Phase("Phase2"),
51  _algFilePath("ftd.alg")
52  {
53 
54  string desc = "TRGGDLModule(" + version() + ")";
55  setDescription(desc);
57 
58  addParam("debugLevel", _debugLevel, "Debug Level", _debugLevel);
59  addParam("Belle2Phase", _Phase, "Phase2 or Phase3", _Phase);
60  addParam("ConfigFile",
62  "The filename of CDC trigger config file",
64  addParam("SimulationMode",
66  "TRGGDL simulation switch",
68  addParam("FastSimulationMode",
70  "TRGGDL fast simulation mode",
72  addParam("FirmwareSimulationMode",
74  "TRGGDL firmware simulation mode",
76 
77  addParam("algFromDB",
78  _algFromDB,
79  "Set false when alg is taken from local file.",
80  true);
81 
82  addParam("algFilePath",
83  _algFilePath,
84  ".alg file path",
85  _algFilePath);
86 
87  B2DEBUG(100, "TRGGDLModule ... created");
88  }
89 
91  {
92 
93  if (_gdl)
94  B2DEBUG(100, "good-bye");
95 
96  B2DEBUG(100, "TRGGDLModule ... destructed ");
97  }
98 
100  {
101 
102  oldDir = gDirectory;
103  newDir = gDirectory;
104  oldDir->mkdir("TRGGDLModule");
105  newDir->cd("TRGGDLModule");
106 
107  h_inp = new TH1I("hTRGGDL_inp", "input bits from TRGGDLModule", 200, 0, 200);
108  h_ftd = new TH1I("hTRGGDL_ftd", "ftdl bits from TRGGDLModule", 200, 0, 200);
109  h_psn = new TH1I("hTRGGDL_psn", "psnm bits from TRGGDLModule", 200, 0, 200);
110 
111  oldDir->cd();
112 
113  }
114 
115  void
117  {
118 
119  REG_HISTOGRAM
120  defineHisto();
121 
122 // m_TRGSummary.isRequired();
124 
125  B2INFO("TRGGDLModule::initialize. simulationMode=" << _simulationMode);
126  if (_simulationMode != 3) {
127  m_TRGGRLInfo.isRequired("TRGGRLObjects");
128  }
129  m_TRGSummary.registerInDataStore();
130  }
131 
132  void
134  {
135 
136  //...GDL config. name...
137  string cfn = _configFilename;
138 
139  //...GDL...
140  if (_gdl == 0) {
141  _gdl = TRGGDL::getTRGGDL(cfn,
145  _Phase,
146  _algFromDB,
147  _algFilePath,
148  _debugLevel);
149  } else if (cfn != _gdl->configFile()) {
150  _gdl = TRGGDL::getTRGGDL(cfn,
154  _Phase,
155  _algFromDB,
156  _algFilePath,
157  _debugLevel);
158  }
159  if (_debugLevel > 9) printf("TRGGDLModule::beginRun() ends.\n");
160 
161  B2DEBUG(100, "TRGGDLModule ... beginRun called configFile = " << cfn);
162  }
163 
164  void
166  {
167 
168  if (_debugLevel > 9) printf("TRGGDLModule::event() starts.\n");
169 
170  newDir->cd();
171 
172  //...GDL simulation...
173  _gdl->update(true);
174  _gdl->simulate();
175  _gdl->accumulateInp(h_inp);
176  _gdl->accumulateFtd(h_ftd);
177  _gdl->accumulatePsn(h_psn);
178 
179  //StoreObjPtr<TRGSummary> m_TRGSummary; /**< output for TRGSummary */
180  int result_summary = 0;
181  if (m_TRGSummary) {
182  result_summary = m_TRGSummary->getTRGSummary(0);
183  } else {
184  B2WARNING("TRGGDLModule.cc: TRGSummary not found. Check it!!!!");
185  }
186  setReturnValue(result_summary);
187 
188  oldDir->cd();
189  }
190 
191  void
193  {
194  B2DEBUG(200, "TRGGDLModule ... endRun called ");
195  }
196 
197  void
199  {
200 
201  _gdl->terminate();
202 
203  B2DEBUG(100, "TRGGDLModule ... terminate called ");
204  }
205 
207 } // namespace Belle2
Belle2::TRGGDL::configFile
std::string configFile(void) const
returns configuration file name.
Definition: TRGGDL.h:318
Belle2::TRGGDLModule::_simulationMode
int _simulationMode
Mode for TRGGDL simulation.
Definition: TRGGDLModule.h:88
Belle2::TRGGDLModule::m_TRGGRLInfo
StoreObjPtr< TRGGRLInfo > m_TRGGRLInfo
< required input for TRGGRLInfo
Definition: TRGGDLModule.h:75
Belle2::Module::setDescription
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:216
Belle2::TRGDebug::level
static int level(void)
returns the debug level.
Definition: Debug.cc:72
Belle2::TRGGDL::accumulatePsn
void accumulatePsn(TH1I *)
Accumulate bit info in histogram.
Definition: TRGGDL.cc:970
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module::c_ParallelProcessingCertified
@ 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:82
Belle2::TRGGDL::accumulateInp
void accumulateInp(TH1I *)
Accumulate bit info in histogram.
Definition: TRGGDL.cc:954
Belle2::TRGGDLModule::_firmwareSimulationMode
int _firmwareSimulationMode
Switch for the firmware simulation. 0:do nothing, 1:do everything.
Definition: TRGGDLModule.h:95
Belle2::TRGGDL::simulate
void simulate(void)
fast trigger simulation.
Definition: TRGGDL.cc:222
Belle2::TRGGDLModule::_algFromDB
bool _algFromDB
Switch for algorithm source. False when using local .alg file.
Definition: TRGGDLModule.h:98
Belle2::TRGGDLModule::~TRGGDLModule
virtual ~TRGGDLModule()
Destructor.
Definition: TRGGDLModule.cc:90
Belle2::TRGGDLModule::version
std::string version(void) const
returns version of TRGGDLModule.
Definition: TRGGDLModule.cc:37
Belle2::Module::setPropertyFlags
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:210
Belle2::TRGGDL::update
void update(bool mcAnalysis=true)
updates TRGGDL information.
Definition: TRGGDL.cc:204
Belle2::TRGGDLModule::initialize
virtual void initialize() override
Initilizes TRGGDLModule.
Definition: TRGGDLModule.cc:116
Belle2::TRGGDLModule::defineHisto
virtual void defineHisto() override
Define Histogram.
Definition: TRGGDLModule.cc:99
Belle2::TRGGDLModule::terminate
virtual void terminate() override
Called when processing ended.
Definition: TRGGDLModule.cc:198
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TRGGDLModule::_gdl
static TRGGDL * _gdl
A pointer to a TRGGDL;.
Definition: TRGGDLModule.h:109
Belle2::Module::setReturnValue
void setReturnValue(int value)
Sets the return value for this module as integer.
Definition: Module.cc:222
Belle2::TRGGDLModule::endRun
virtual void endRun() override
Called when run ended.
Definition: TRGGDLModule.cc:192
Belle2::Module::addParam
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:562
Belle2::TRGGDL::getTRGGDL
static TRGGDL * getTRGGDL(void)
returns TRGGDL object.
Definition: TRGGDL.cc:102
Belle2::TRGGDLModule::_fastSimulationMode
int _fastSimulationMode
Switch for the fast simulation.
Definition: TRGGDLModule.h:92
Belle2::TRGGDL::accumulateFtd
void accumulateFtd(TH1I *)
Accumulate bit info in histogram.
Definition: TRGGDL.cc:962
Belle2::TRGGDL::terminate
void terminate(void)
terminates when run is finished
Definition: TRGGDL.cc:174
Belle2::TRGGDLModule::beginRun
virtual void beginRun() override
Called when new run started.
Definition: TRGGDLModule.cc:133
Belle2::TRGGDLModule::_configFilename
std::string _configFilename
Config. file name.
Definition: TRGGDLModule.h:84
Belle2::TRGGDLModule::event
virtual void event() override
Called event by event.
Definition: TRGGDLModule.cc:165
Belle2::HistoModule
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
Belle2::TRGGDLModule::_debugLevel
int _debugLevel
Debug level.
Definition: TRGGDLModule.h:81