Belle II Software  release-08-01-10
TRGGRLModule.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 TRGGRL_SHORT_NAMES
10 
11 #include <iostream>
12 
13 #include "trg/grl/modules/trggrl/TRGGRLModule.h"
14 #include <framework/logging/Logger.h>
15 
16 using namespace std;
17 
18 namespace Belle2 {
26 
27  TRGGRL*
28  TRGGRLModule::_grl = 0;
29 
30  string
31  TRGGRLModule::version() const
32  {
33  return string("TRGGRLModule 0.00");
34  }
35 
36  TRGGRLModule::TRGGRLModule()
37  : Module::Module(),
38  _debugLevel(0),
39  _configFilename("TRGGDLConfig.dat"),
40  _simulationMode(2),
41  _fastSimulationMode(0),
42  _firmwareSimulationMode(0)
43  {
44 
45  string desc = "TRGGRLModule(" + version() + ")";
46  setDescription(desc);
48 
49  addParam("DebugLevel", _debugLevel, "TRGGRL debug level", _debugLevel);
50  addParam("ConfigFile",
52  "The filename of CDC trigger config file",
54  addParam("SimulationMode",
56  "TRGGRL simulation switch",
58  addParam("FastSimulationMode",
60  "TRGGRL fast simulation mode",
62  addParam("FirmwareSimulationMode",
64  "TRGGRL firmware simulation mode",
66  }
67 
69  {
70 
71  if (_grl)
72  TRGGRL::getTRGGRL("good-bye");
73 
74  }
75 
76  void
78  {
79 
80 // TRGDebug::level(_debugLevel);
81 
82  B2DEBUG(100, "TRGGRLModule::initialize ... options");
83  }
84 
85  void
87  {
88 
89  //...GDL config. name...
90  string cfn = _configFilename;
91 
92  //...GRL...
93  if (_grl == 0) {
94  _grl = TRGGRL::getTRGGRL(cfn,
98  } else if (cfn != _grl->configFile()) {
99  _grl = TRGGRL::getTRGGRL(cfn,
103  }
104 
105  B2DEBUG(300, "TRGGDLModule ... beginRun called configFile = " << cfn);
106 
107  }
108 
109  void
111  {
112 
113  //...GRL simulation...
114  _grl->update(true);
115  _grl->simulate();
116 
117  }
118 
119  void
121  {
122  B2DEBUG(300, "TRGGRLModule ... endRun called ");
123  }
124 
125 
126  void
128  {
129  _grl->terminate();
130  B2DEBUG(200, "TRGGRLModule ... terminate called ");
131  }
132 
134 } // namespace Belle2
Base class for Modules.
Definition: Module.h:72
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
@ 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
std::string _configFilename
Config. file name.
Definition: TRGGRLModule.h:66
int _debugLevel
Debug level.
Definition: TRGGRLModule.h:63
int _simulationMode
Mode for TRGGRL simulation.
Definition: TRGGRLModule.h:70
int _firmwareSimulationMode
Switch for the firmware simulation. 0:do nothing, 1:do everything.
Definition: TRGGRLModule.h:77
int _fastSimulationMode
Switch for the fast simulation.
Definition: TRGGRLModule.h:74
a class for TRGGRL
Definition: TRGGRL.h:43
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 TRGGRLModule.
Definition: TRGGRLModule.cc:77
virtual void event() override
Called event by event.
virtual void endRun() override
Called when run ended.
virtual void terminate() override
Called when processing ended.
virtual void beginRun() override
Called when new run started.
Definition: TRGGRLModule.cc:86
std::string version(void) const
returns version of TRGGRLModule.
Definition: TRGGRLModule.cc:31
static TRGGRL * _grl
A pointer to a TRGGRL;.
Definition: TRGGRLModule.h:82
virtual ~TRGGRLModule()
Destructor.
Definition: TRGGRLModule.cc:68
void terminate(void)
terminates when run is finished
Definition: TRGGRL.cc:120
static TRGGRL * getTRGGRL(void)
returns TRGGRL object.
Definition: TRGGRL.cc:73
void update(bool mcAnalysis=true)
updates TRGGRL information.
Definition: TRGGRL.cc:143
std::string configFile(void) const
returns configuration file name.
Definition: TRGGRL.h:227
void simulate(void)
fast trigger simulation.
Definition: TRGGRL.cc:162
Abstract base class for different kinds of events.