Belle II Software  release-05-01-25
eclUnpackerModule.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2020 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Vasily Shebalin, Mikhail Remnev *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 // Framework
13 #include <framework/datastore/StoreArray.h>
14 #include <framework/datastore/StoreObjPtr.h>
15 #include <framework/database/DBObjPtr.h>
16 #include <framework/core/FrameworkExceptions.h>
17 #include <framework/core/Module.h>
18 
19 // ECL
20 #include <ecl/utility/ECLChannelMapper.h>
21 
22 namespace Belle2 {
28  class EventMetaData;
29  class RawECL;
30  class ECLDigit;
31  class ECLTrig;
32  class ECLDsp;
33 
38  class ECLUnpackerModule : public Module {
39  public:
43  virtual ~ECLUnpackerModule();
44 
46  virtual void initialize() override;
48  virtual void beginRun() override;
50  virtual void event() override;
52  virtual void endRun() override;
54  virtual void terminate() override;
55 
57  BELLE2_DEFINE_EXCEPTION(Unexpected_end_of_FINESSE_buffer,
58  "Unexpected end of the FINESS buffer is reached while reading ShpaerDSP data");
61  BELLE2_DEFINE_EXCEPTION(Bad_ShaperDSP_header, "Corrupted Shaper DSP header");
62 
64  enum ECLUnpack {
66  ECL_DISCARD_DSP_DATA = 0x00000001,
68  ECL_KEEP_GOOD_DSP_DATA = 0x00000002,
70  ECL_OFFLINE_ADC_FIT = 0x00000004,
71  };
72 
73  protected:
74 
75 
76  private:
80  int m_localEvtNum;
81 
83  unsigned int* m_bufPtr;
85  int m_bufPos;
87  int m_bufLength;
89  int m_bitPos;
90 
92  bool m_storeTrigTime;
94  bool m_storeUnmapped;
97 
99  long m_evtNumReportedMask = 0;
101  long m_tagsReportedMask = 0;
103  long m_phasesReportedMask = 0;
105  long m_badHeaderReportedMask = 0;
106 
111  void doEvtNumReport(unsigned int iCrate, int tag, int evt_number);
116  void doTagsReport(unsigned int iCrate, int tag0, int tag1);
121  void doPhasesReport(unsigned int iCrate, int phase0, int phase1);
126  void doBadHeaderReport(unsigned int iCrate);
127 
132  bool evtNumReported(unsigned int iCrate) { return m_evtNumReportedMask & (1L << (iCrate - 1)); }
137  bool tagsReported(unsigned int iCrate) { return m_tagsReportedMask & (1L << (iCrate - 1)); }
142  bool phasesReported(unsigned int iCrate) { return m_phasesReportedMask & (1L << (iCrate - 1)); }
147  bool badHeaderReported(unsigned int iCrate) { return m_badHeaderReportedMask & (1L << (iCrate - 1)); }
148 
150  std::string m_eclDigitsName;
152  std::string m_eclTrigsName;
154  std::string m_eclDspsName;
156  std::string m_eclMapperInitFileName;
157 
160 
163 
164  /* Input data */
165 
170 
171  /* Output data */
172 
179 
181  int m_debugLevel;
182 
184  unsigned int readNextCollectorWord();
186  unsigned int readNBits(int bitsToRead);
188  void readRawECLData(RawECL* rawCOPPERData, int n);
190  bool isDSPValid(int cellID, int crate, int shaper, int channel, int amp, int time, int quality);
191 
192  };
194 }//namespace Belle2
Belle2::ECLUnpackerModule::m_badHeaderReportedMask
long m_badHeaderReportedMask
report only once per crate about problem with shaper header
Definition: eclUnpackerModule.h:113
Belle2::ECLUnpackerModule::ECLUnpack
ECLUnpack
ECL unpacker run-dependent parameters (per channel)
Definition: eclUnpackerModule.h:72
Belle2::ECLUnpackerModule::m_useUnpackingParameters
bool m_useUnpackingParameters
Use ECLUnpackingParameters payload for run-dependent unpacking.
Definition: eclUnpackerModule.h:104
Belle2::ECLUnpackerModule::m_bufPos
int m_bufPos
position in the COPPER data array
Definition: eclUnpackerModule.h:93
Belle2::ECLUnpackerModule::m_bitPos
int m_bitPos
bit position for bit-by-bit data read
Definition: eclUnpackerModule.h:97
Belle2::ECLUnpackerModule::tagsReported
bool tagsReported(unsigned int iCrate)
Check if the problem with different trigger tags was already reported for crate iCrate.
Definition: eclUnpackerModule.h:145
Belle2::ECLUnpackerModule::m_eclDigitsName
std::string m_eclDigitsName
name of output collection for ECLDigits
Definition: eclUnpackerModule.h:158
Belle2::ECLUnpackerModule::m_debugLevel
int m_debugLevel
Cached debug level from LogSystem.
Definition: eclUnpackerModule.h:189
Belle2::ECLUnpackerModule::ECL_OFFLINE_ADC_FIT
@ ECL_OFFLINE_ADC_FIT
Get ECLDigits from offline waveform fit.
Definition: eclUnpackerModule.h:78
Belle2::ECLUnpackerModule::m_eclDsps
StoreArray< ECLDsp > m_eclDsps
store array for waveforms
Definition: eclUnpackerModule.h:186
Belle2::ECLUnpackerModule::m_evtNumReportedMask
long m_evtNumReportedMask
report only once per crate about inconsistency between trg tag and evt number
Definition: eclUnpackerModule.h:107
Belle2::RawECL
The Raw ECL class Class for RawCOPPER class data taken by ECL Currently, this class is almost same as...
Definition: RawECL.h:26
Belle2::ECLUnpackerModule::ECL_KEEP_GOOD_DSP_DATA
@ ECL_KEEP_GOOD_DSP_DATA
Keep ECLDigits for quality flag 0 even if ECL_DISCARD_DSP_DATA is set.
Definition: eclUnpackerModule.h:76
Belle2::ECLUnpackerModule::terminate
virtual void terminate() override
terminate
Definition: eclUnpackerModule.cc:186
Belle2::ECLUnpackerModule::readNBits
unsigned int readNBits(int bitsToRead)
rean N bits from COPPER buffer (needed for reading the compressed ADC data)
Definition: eclUnpackerModule.cc:203
Belle2::ECLUnpackerModule::endRun
virtual void endRun() override
endRun
Definition: eclUnpackerModule.cc:182
Belle2::ECLUnpackerModule::m_eclDigits
StoreArray< ECLDigit > m_eclDigits
store array for digitized gits
Definition: eclUnpackerModule.h:182
Belle2::DBObjPtr
Class for accessing objects in the database.
Definition: DBObjPtr.h:31
Belle2::ECLUnpackerModule::doTagsReport
void doTagsReport(unsigned int iCrate, int tag0, int tag1)
Report the problem with trigger tags and exclude the crate from further reports of this type.
Definition: eclUnpackerModule.cc:572
Belle2::ECLUnpackerModule::m_bufPtr
unsigned int * m_bufPtr
pointer to data from COPPER
Definition: eclUnpackerModule.h:91
Belle2::ECLUnpackerModule::evtNumReported
bool evtNumReported(unsigned int iCrate)
Check if the problem with trg tag <-> evt number inconsistency was already reported for crate iCrate.
Definition: eclUnpackerModule.h:140
Belle2::ECL::ECLChannelMapper
This class provides access to ECL channel map that is either a) Loaded from the database (see ecl/dbo...
Definition: ECLChannelMapper.h:36
Belle2::ECLUnpackerModule::m_rawEcl
StoreArray< RawECL > m_rawEcl
store array for RawECL
Definition: eclUnpackerModule.h:175
Belle2::ECLUnpackerModule::readNextCollectorWord
unsigned int readNextCollectorWord()
read nex word from COPPER data, check if the end of data is reached
Definition: eclUnpackerModule.cc:191
Belle2::ECLUnpackerModule::m_storeUnmapped
bool m_storeUnmapped
flag for whether or not to store ECLDsp data for unmapped channels
Definition: eclUnpackerModule.h:102
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ECLUnpackerModule::m_eventMetaData
StoreObjPtr< EventMetaData > m_eventMetaData
store objptr for EventMetaData
Definition: eclUnpackerModule.h:177
Belle2::ECLUnpackerModule::initialize
virtual void initialize() override
initialize
Definition: eclUnpackerModule.cc:118
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::ECLUnpackerModule::badHeaderReported
bool badHeaderReported(unsigned int iCrate)
Check if the problem with bad shaper header was already reported for crate iCrate.
Definition: eclUnpackerModule.h:155
Belle2::ECLUnpackerModule::m_unpackingParams
DBObjPtr< ECLChannelMap > m_unpackingParams
Run-dependent unpacking parameters for each channel.
Definition: eclUnpackerModule.h:170
Belle2::ECLUnpackerModule::ECL_DISCARD_DSP_DATA
@ ECL_DISCARD_DSP_DATA
Skip ECLDigit unpacking.
Definition: eclUnpackerModule.h:74
Belle2::ECLUnpackerModule::m_localEvtNum
int m_localEvtNum
Internally counted event number.
Definition: eclUnpackerModule.h:88
Belle2::ECLUnpackerModule::m_eclMapper
ECL::ECLChannelMapper m_eclMapper
ECL channel mapper.
Definition: eclUnpackerModule.h:167
Belle2::ECLUnpackerModule::doPhasesReport
void doPhasesReport(unsigned int iCrate, int phase0, int phase1)
Report the problem with trigger phases and exclude the crate from further reports of this type.
Definition: eclUnpackerModule.cc:581
Belle2::ECLUnpackerModule::m_phasesReportedMask
long m_phasesReportedMask
report only once per crate about problem with different trg phases
Definition: eclUnpackerModule.h:111
Belle2::ECLUnpackerModule::m_eclMapperInitFileName
std::string m_eclMapperInitFileName
name of the file with correspondence between cellID and crate/shaper/channel numbers
Definition: eclUnpackerModule.h:164
Belle2::ECLUnpackerModule::m_globalEvtNum
int m_globalEvtNum
event number from EventMetaData
Definition: eclUnpackerModule.h:86
Belle2::ECLUnpackerModule::event
virtual void event() override
event
Definition: eclUnpackerModule.cc:155
Belle2::ECLUnpackerModule::m_eclDspsName
std::string m_eclDspsName
name of output collection for ECLDsp
Definition: eclUnpackerModule.h:162
Belle2::ECLUnpackerModule::doBadHeaderReport
void doBadHeaderReport(unsigned int iCrate)
Report the problem with bad shaper header and exclude the crate from further reports of this type.
Definition: eclUnpackerModule.cc:590
Belle2::ECLUnpackerModule::~ECLUnpackerModule
virtual ~ECLUnpackerModule()
destructor
Definition: eclUnpackerModule.cc:113
Belle2::ECLUnpackerModule::m_bufLength
int m_bufLength
length of COPPER data
Definition: eclUnpackerModule.h:95
Belle2::ECLUnpackerModule::m_eclTrigs
StoreArray< ECLTrig > m_eclTrigs
store array for eclTrigs data (trigger time and tag)
Definition: eclUnpackerModule.h:184
Belle2::ECLUnpackerModule::readRawECLData
void readRawECLData(RawECL *rawCOPPERData, int n)
read raw data from COPPER and fill output m_eclDigits container
Definition: eclUnpackerModule.cc:232
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::ECLUnpackerModule::beginRun
virtual void beginRun() override
beginRun
Definition: eclUnpackerModule.cc:139
Belle2::ECLUnpackerModule::ECLUnpackerModule
ECLUnpackerModule()
constructor
Definition: eclUnpackerModule.cc:84
Belle2::ECLUnpackerModule::doEvtNumReport
void doEvtNumReport(unsigned int iCrate, int tag, int evt_number)
Report the problem with inconsistency between trg tag and evt number.
Definition: eclUnpackerModule.cc:562
Belle2::ECLUnpackerModule::m_storeTrigTime
bool m_storeTrigTime
flag for whether or not to store collection with trigger times
Definition: eclUnpackerModule.h:100
Belle2::ECLUnpackerModule::BELLE2_DEFINE_EXCEPTION
BELLE2_DEFINE_EXCEPTION(Unexpected_end_of_FINESSE_buffer, "Unexpected end of the FINESS buffer is reached while reading ShpaerDSP data")
exeption should be thrown when the unexpected
Belle2::ECLUnpackerModule::phasesReported
bool phasesReported(unsigned int iCrate)
Check if the problem with different trigger phases was already reported for crate iCrate.
Definition: eclUnpackerModule.h:150
Belle2::ECLUnpackerModule::m_tagsReportedMask
long m_tagsReportedMask
report only once per crate about problem with different trg tags
Definition: eclUnpackerModule.h:109
Belle2::ECLUnpackerModule::isDSPValid
bool isDSPValid(int cellID, int crate, int shaper, int channel, int amp, int time, int quality)
Check if DSP data should be saved to datastore.
Definition: eclUnpackerModule.cc:543
Belle2::ECLUnpackerModule::m_eclTrigsName
std::string m_eclTrigsName
name of output collection for ECLTrig
Definition: eclUnpackerModule.h:160