Belle II Software  release-05-02-19
TRGECLFAMModule.cc
1 //---------------------------------------------------------------
2 // $Id$
3 //---------------------------------------------------------------
4 // Filename : TRGECLFAMModule.cc
5 // Section : TRG ECL
6 // Owner : InSoo Lee/Yuuji Unno
7 // Email : islee@hep.hanyang.ac.kr / yunno@post.kek.jp
8 //---------------------------------------------------------------
9 // Description : A trigger module for TRG ECL
10 // The FAM module of ECL Trigger simulation
11 // This odule convert crystal Hits to TC Hit and shape the signal,
12 // then measure TC energy and timing.
13 // Raw TC Hit information is saved on TRGECHDigi0 table(before shaping).
14 // Measured TC Hit information is save on TRGECLHit table.
15 //---------------------------------------------------------------
16 // 1.00 : 2012/05/24 : First version
17 //---------------------------------------------------------------
18 
19 #define TRGECLFAM_SHORT_NAMES
20 
21 //framework headers
22 #include <framework/logging/Logger.h>
23 
24 //trg package headers
25 #include "trg/ecl/modules/trgecl/TRGECLFAMModule.h"
26 #include "trg/ecl/TrgEclDigitizer.h"
27 #include "trg/ecl/TrgEclFAMFit.h"
28 
29 #include "trg/ecl/dbobjects/TRGECLFAMPara.h"
30 
31 #include <iostream>
32 
33 using namespace std;
34 
35 namespace Belle2 {
40 //
41 //
43  REG_MODULE(TRGECLFAM);
44 //
45 //
46 //
47  string
48  TRGECLFAMModule::version() const
49  {
50  return string("TRGECLFAMModule 1.00");
51  }
52 //
53 //
54 //
55  TRGECLFAMModule::TRGECLFAMModule()
56  : Module::Module(),
57  _debugLevel(0),
58  _famMethod(1),
59  _binTimeInterval(125),
60  _waveform(0),
61  _beambkgtag(0),
62  _famana(0),
63  _threshold(100.0),
64  _FADC(1),
65  _ConditionDB(0)
66 
67  {
68 
69  string desc = "TRGECLFAMModule(" + version() + ")";
70  setDescription(desc);
72 
73  addParam("DebugLevel", _debugLevel, "TRGECL debug level", _debugLevel);
74  addParam("FAMFitMethod", _famMethod, "TRGECLFAM fit method", _famMethod);
75  addParam("FAMBinTimeInterval", _binTimeInterval, "TRGECLFAM binTimeInterval",
77  addParam("TCWaveform", _waveform, "Output the TC waveform ",
78  _waveform);
79  addParam("FAMAnaTable", _famana, "Save FAM ana table ",
80  _famana);
81  addParam("BeamBkgTag", _beambkgtag, "Save beambackground tag in TRGECLHit table ",
82  _beambkgtag);
83  addParam("TCThreshold", _threshold, "Set FAM TC threshold ",
84  _threshold);
85  addParam("ShapingFunction", _FADC, "Set function of shaper ", _FADC);
86  addParam("ConditionDB", _ConditionDB, "Use conditionDB ", _ConditionDB);
87 
88  if (_ConditionDB == 1) { //Use global tag
89  m_FAMPara.addCallback(this, &TRGECLFAMModule::beginRun);
90  }
91  B2DEBUG(100, "TRGECLFAMModule ... created");
92  Threshold.clear();
93  }
94 //
95 //
96 //
98  {
99 
100  B2DEBUG(100, "TRGECLFAMModule ... destructed ");
101 
102 
103  }
104 //
105 //
106 //
107  void
109  {
110 
111  B2DEBUG(100, "TRGECLFAMModule::initialize ... options");
112  B2DEBUG(100, "TRGECLFAMModule::initialize> FAM Fit Method = "
113  << _famMethod << " ; Bin of Time Interval = " << _binTimeInterval << " ;output TC waveforml = " << _waveform);
114 
115  m_nRun = 0;
116  m_nEvent = 1;
117 
118  m_TRGECLDigi0.registerInDataStore();
119  m_TRGECLWaveform.registerInDataStore();
120  m_TRGECLHit.registerInDataStore();
121  m_TRGECLFAMAna.registerInDataStore();
122  // m_FAMPara = new DBObjPtr<TRGECLFAMPara>;
123  }
124 //
125 //
126 //
127  void
129  {
130  if (_ConditionDB == 0) {
131  Threshold.resize(576, _threshold);
132  } else if (_ConditionDB == 1) { //Use global tag
133  Threshold.resize(576, 0);
134  for (const auto& para : m_FAMPara) {
135  Threshold[para.getTCId() - 1] = (int)((para.getThreshold()) * (para.getConversionFactor()));
136  }
137  }
138 
139  B2DEBUG(200, "TRGECLFAMModule ... beginRun called ");
140 
141  }
142 //
143 //
144 //
145  void
147  {
148 
149  B2DEBUG(200, "TRGECLFAMMoudle ... event called");
150  //
151  //
152  if (m_nEvent < 1e2) {if (m_nEvent % 10 == 0) {B2DEBUG(200, "TRGECLFAMModule::event> evtno= " << m_nEvent);}}
153  else if (m_nEvent < 1e3) {if (m_nEvent % 100 == 0) {B2DEBUG(200, "TRGECLFAMModule::event> evtno= " << m_nEvent);}}
154  else if (m_nEvent < 1e4) {if (m_nEvent % 1000 == 0) {B2DEBUG(200, "TRGECLFAMModule::event> evtno= " << m_nEvent);}}
155  else if (m_nEvent < 1e5) {if (m_nEvent % 10000 == 0) {B2DEBUG(200, "TRGECLFAMModule::event> evtno= " << m_nEvent);}}
156  else if (m_nEvent < 1e6) {if (m_nEvent % 100000 == 0) {B2DEBUG(200, "TRGECLFAMModule::event> evtno= " << m_nEvent);}}
157 
158 
159  //
160  //
161  //
162  // FAM Digitizer
163  TrgEclDigitizer* obj_trgeclDigi = new TrgEclDigitizer();
164  obj_trgeclDigi-> setWaveform(_waveform);
165  obj_trgeclDigi-> setFADC(_FADC);
166  obj_trgeclDigi-> setup();
167  if (_famMethod == 2 || _famMethod == 1) {obj_trgeclDigi-> digitization01(TCDigiE, TCDigiT); } // no-fit method = backup method 1
168  else if (_famMethod == 3) { obj_trgeclDigi-> digitization02(TCDigiE, TCDigiT); } // orignal method = backup method 2
169  obj_trgeclDigi-> save(m_nEvent);
170 
171 
172  // FAM Fitter
173  TrgEclFAMFit* obj_trgeclfit = new TrgEclFAMFit();
174  obj_trgeclfit-> SetBeamBkgTagFlag(_beambkgtag);
175  obj_trgeclfit-> SetAnaTagFlag(_famana);
176  obj_trgeclfit-> setup(m_nEvent);
177  obj_trgeclfit-> SetThreshold(Threshold);
178 
179  if (_famMethod == 1) {obj_trgeclfit-> FAMFit01(TCDigiE, TCDigiT); } // fitting method
180  else if (_famMethod == 2) {obj_trgeclfit-> FAMFit02(TCDigiE, TCDigiT); } // no-fit method = backup method 1
181  else if (_famMethod == 3) { obj_trgeclfit-> FAMFit03(TCDigiE, TCDigiT); } // orignal method = backup method 2
182  obj_trgeclfit-> save(m_nEvent);
183 
184 
185  //
186  //
187  //
188  m_nEvent++;
189  delete obj_trgeclDigi;
190  delete obj_trgeclfit;
191  //
192  //
193  //
194  }
195 //
196 //
197 //
198  void
200  {
201  B2DEBUG(200, "TRGECLFAMModule ... endRun called ");
202  }
203 //
204 //
205 //
206  void
208  {
209  B2DEBUG(100, "TRGECLFAMModule ... terminate called ");
210  }
211 //
212 //
213 //
215 } // namespace Belle2
Belle2::TRGECLFAMModule::m_nEvent
int m_nEvent
Event number.
Definition: TRGECLFAMModule.h:98
setup
Belle2::TrgEclFAMFit
FAM module
Definition: TrgEclFAMFit.h:27
Belle2::TRGECLFAMModule::TCDigiT
std::vector< std::vector< double > > TCDigiT
Digitized TC T [ns].
Definition: TRGECLFAMModule.h:102
Belle2::Module::setDescription
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:216
Belle2::TRGECLFAMModule::_ConditionDB
int _ConditionDB
Use Condition DB.
Definition: TRGECLFAMModule.h:81
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::TRGECLFAMModule::m_TRGECLHit
StoreArray< TRGECLHit > m_TRGECLHit
output for TRGECLHit
Definition: TRGECLFAMModule.h:112
Belle2::TRGECLFAMModule::m_TRGECLFAMAna
StoreArray< TRGECLFAMAna > m_TRGECLFAMAna
output for TRGECLFAMAna
Definition: TRGECLFAMModule.h:113
Belle2::TRGECLFAMModule::_FADC
int _FADC
Set Shaping Function.
Definition: TRGECLFAMModule.h:79
Belle2::TRGECLFAMModule::_famana
int _famana
save FAM ana table
Definition: TRGECLFAMModule.h:75
Belle2::TRGECLFAMModule::version
std::string version(void) const
returns version of TRGECLFAMModule.
Definition: TRGECLFAMModule.cc:48
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::TRGECLFAMModule::m_TRGECLWaveform
StoreArray< TRGECLWaveform > m_TRGECLWaveform
output for TRGECLWaveform
Definition: TRGECLFAMModule.h:111
Belle2::TRGECLFAMModule::_beambkgtag
int _beambkgtag
save Beam background tag in TRGECLHit table
Definition: TRGECLFAMModule.h:73
Belle2::Module::setPropertyFlags
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:210
Belle2::TRGECLFAMModule::_threshold
int _threshold
Threshold input.
Definition: TRGECLFAMModule.h:77
Belle2::TRGECLFAMModule::initialize
virtual void initialize() override
Initilizes TRGECLFAMModule.
Definition: TRGECLFAMModule.cc:108
Belle2::TRGECLFAMModule::~TRGECLFAMModule
virtual ~TRGECLFAMModule()
Destructor.
Definition: TRGECLFAMModule.cc:97
Belle2::TRGECLFAMModule::terminate
virtual void terminate() override
Called when processing ended.
Definition: TRGECLFAMModule.cc:207
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrgEclDigitizer
FAM module
Definition: TrgEclDigitizer.h:28
Belle2::TRGECLFAMModule::Threshold
std::vector< int > Threshold
Threshold.
Definition: TRGECLFAMModule.h:108
Belle2::TRGECLFAMModule::endRun
virtual void endRun() override
Called when run ended.
Definition: TRGECLFAMModule.cc:199
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::TRGECLFAMModule::_binTimeInterval
int _binTimeInterval
Time interval.
Definition: TRGECLFAMModule.h:69
Belle2::TRGECLFAMModule::_waveform
int _waveform
Waveform.
Definition: TRGECLFAMModule.h:71
Belle2::TRGECLFAMModule::beginRun
virtual void beginRun() override
Called when new run started.
Definition: TRGECLFAMModule.cc:128
Belle2::TRGECLFAMModule::m_FAMPara
DBArray< TRGECLFAMPara > m_FAMPara
FAM Parameters.
Definition: TRGECLFAMModule.h:114
Belle2::TRGECLFAMModule::_famMethod
int _famMethod
fam Method
Definition: TRGECLFAMModule.h:67
Belle2::TRGECLFAMModule::_debugLevel
int _debugLevel
Parameters.
Definition: TRGECLFAMModule.h:65
Belle2::TRGECLFAMModule::m_nRun
int m_nRun
Run number.
Definition: TRGECLFAMModule.h:96
Belle2::TRGECLFAMModule::event
virtual void event() override
Called event by event.
Definition: TRGECLFAMModule.cc:146
Belle2::TRGECLFAMModule::m_TRGECLDigi0
StoreArray< TRGECLDigi0 > m_TRGECLDigi0
output for TRGECLDigi0
Definition: TRGECLFAMModule.h:110
Belle2::TRGECLFAMModule::TCDigiE
std::vector< std::vector< double > > TCDigiE
Digitized TC E [GeV].
Definition: TRGECLFAMModule.h:100