Belle II Software  release-05-02-19
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 #include <framework/datastore/RelationArray.h>
19 
20 // ECL
21 #include <ecl/utility/ECLChannelMapper.h>
22 #include <ecl/dataobjects/ECLTrig.h>
23 
24 namespace Belle2 {
30  class EventMetaData;
31  class RawECL;
32  class ECLDigit;
33  class ECLDsp;
34 
39  class ECLUnpackerModule : public Module {
40  public:
44  virtual ~ECLUnpackerModule();
45 
47  virtual void initialize() override;
49  virtual void beginRun() override;
51  virtual void event() override;
53  virtual void endRun() override;
55  virtual void terminate() override;
56 
58  BELLE2_DEFINE_EXCEPTION(Unexpected_end_of_FINESSE_buffer,
59  "Unexpected end of the FINESS buffer is reached while reading ShpaerDSP data");
62  BELLE2_DEFINE_EXCEPTION(Bad_ShaperDSP_header, "Corrupted Shaper DSP header");
63 
65  enum ECLUnpack {
67  ECL_DISCARD_DSP_DATA = 0x00000001,
69  ECL_KEEP_GOOD_DSP_DATA = 0x00000002,
71  ECL_OFFLINE_ADC_FIT = 0x00000004,
72  };
73 
74  protected:
75 
76 
77  private:
81  int m_localEvtNum;
82 
84  unsigned int* m_bufPtr;
86  int m_bufPos;
88  int m_bufLength;
90  int m_bitPos;
91 
93  bool m_storeTrigTime;
95  bool m_storeUnmapped;
98 
100  long m_evtNumReportedMask = 0;
102  long m_tagsReportedMask = 0;
104  long m_phasesReportedMask = 0;
106  long m_badHeaderReportedMask = 0;
107 
112  void doEvtNumReport(unsigned int iCrate, int tag, int evt_number);
117  void doTagsReport(unsigned int iCrate, int tag0, int tag1);
122  void doPhasesReport(unsigned int iCrate, int phase0, int phase1);
127  void doBadHeaderReport(unsigned int iCrate);
128 
133  bool evtNumReported(unsigned int iCrate) { return m_evtNumReportedMask & (1L << (iCrate - 1)); }
138  bool tagsReported(unsigned int iCrate) { return m_tagsReportedMask & (1L << (iCrate - 1)); }
143  bool phasesReported(unsigned int iCrate) { return m_phasesReportedMask & (1L << (iCrate - 1)); }
148  bool badHeaderReported(unsigned int iCrate) { return m_badHeaderReportedMask & (1L << (iCrate - 1)); }
149 
151  std::string m_eclDigitsName;
153  std::string m_eclTrigsName;
155  std::string m_eclDspsName;
157  std::string m_eclMapperInitFileName;
158 
161 
164 
165  /* Input data */
166 
171 
172  /* Output data */
173 
180 
185 
187  ECLTrig m_eclTrigsBuffer[ECL::ECL_CRATES];
188 
191 
193  unsigned int readNextCollectorWord();
195  unsigned int readNBits(int bitsToRead);
197  void readRawECLData(RawECL* rawCOPPERData, int n);
199  bool isDSPValid(int cellID, int crate, int shaper, int channel, int amp, int time, int quality);
200 
201  };
203 }//namespace Belle2
Belle2::RelationArray
Low-level class to create/modify relations between StoreArrays.
Definition: RelationArray.h:72
Belle2::ECLUnpackerModule::m_badHeaderReportedMask
long m_badHeaderReportedMask
report only once per crate about problem with shaper header
Definition: eclUnpackerModule.h:114
Belle2::ECLUnpackerModule::ECLUnpack
ECLUnpack
ECL unpacker run-dependent parameters (per channel)
Definition: eclUnpackerModule.h:73
Belle2::ECLUnpackerModule::m_useUnpackingParameters
bool m_useUnpackingParameters
Use ECLUnpackingParameters payload for run-dependent unpacking.
Definition: eclUnpackerModule.h:105
Belle2::ECLUnpackerModule::m_bufPos
int m_bufPos
position in the COPPER data array
Definition: eclUnpackerModule.h:94
Belle2::ECLUnpackerModule::m_bitPos
int m_bitPos
bit position for bit-by-bit data read
Definition: eclUnpackerModule.h:98
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:146
Belle2::ECLUnpackerModule::m_eclDigitsName
std::string m_eclDigitsName
name of output collection for ECLDigits
Definition: eclUnpackerModule.h:159
Belle2::ECLUnpackerModule::m_debugLevel
int m_debugLevel
Cached debug level from LogSystem.
Definition: eclUnpackerModule.h:198
Belle2::ECLUnpackerModule::ECL_OFFLINE_ADC_FIT
@ ECL_OFFLINE_ADC_FIT
Get ECLDigits from offline waveform fit.
Definition: eclUnpackerModule.h:79
Belle2::ECLUnpackerModule::m_eclDsps
StoreArray< ECLDsp > m_eclDsps
store array for waveforms
Definition: eclUnpackerModule.h:187
Belle2::ECLUnpackerModule::m_relDigitToTrig
RelationArray m_relDigitToTrig
ECLDigit->ECLTrig relation array.
Definition: eclUnpackerModule.h:190
Belle2::ECLUnpackerModule::m_evtNumReportedMask
long m_evtNumReportedMask
report only once per crate about inconsistency between trg tag and evt number
Definition: eclUnpackerModule.h:108
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:77
Belle2::ECLUnpackerModule::terminate
virtual void terminate() override
terminate
Definition: eclUnpackerModule.cc:211
Belle2::ECLUnpackerModule::readNBits
unsigned int readNBits(int bitsToRead)
rean N bits from COPPER buffer (needed for reading the compressed ADC data)
Definition: eclUnpackerModule.cc:228
Belle2::ECLUnpackerModule::endRun
virtual void endRun() override
endRun
Definition: eclUnpackerModule.cc:207
Belle2::ECLUnpackerModule::m_eclDigits
StoreArray< ECLDigit > m_eclDigits
store array for digitized gits
Definition: eclUnpackerModule.h:183
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:578
Belle2::ECLUnpackerModule::m_bufPtr
unsigned int * m_bufPtr
pointer to data from COPPER
Definition: eclUnpackerModule.h:92
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:141
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:176
Belle2::ECLUnpackerModule::readNextCollectorWord
unsigned int readNextCollectorWord()
read nex word from COPPER data, check if the end of data is reached
Definition: eclUnpackerModule.cc:216
Belle2::ECLUnpackerModule::m_storeUnmapped
bool m_storeUnmapped
flag for whether or not to store ECLDsp data for unmapped channels
Definition: eclUnpackerModule.h:103
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:178
Belle2::ECLUnpackerModule::initialize
virtual void initialize() override
initialize
Definition: eclUnpackerModule.cc:117
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::ECLUnpackerModule::m_relDigitToDsp
RelationArray m_relDigitToDsp
ECLDigit->ECLTrig relation array.
Definition: eclUnpackerModule.h:192
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:156
Belle2::ECLUnpackerModule::m_unpackingParams
DBObjPtr< ECLChannelMap > m_unpackingParams
Run-dependent unpacking parameters for each channel.
Definition: eclUnpackerModule.h:171
Belle2::ECLUnpackerModule::ECL_DISCARD_DSP_DATA
@ ECL_DISCARD_DSP_DATA
Skip ECLDigit unpacking.
Definition: eclUnpackerModule.h:75
Belle2::ECLUnpackerModule::m_localEvtNum
int m_localEvtNum
Internally counted event number.
Definition: eclUnpackerModule.h:89
Belle2::ECLUnpackerModule::m_eclMapper
ECL::ECLChannelMapper m_eclMapper
ECL channel mapper.
Definition: eclUnpackerModule.h:168
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:587
Belle2::ECLUnpackerModule::m_phasesReportedMask
long m_phasesReportedMask
report only once per crate about problem with different trg phases
Definition: eclUnpackerModule.h:112
Belle2::ECLUnpackerModule::m_eclMapperInitFileName
std::string m_eclMapperInitFileName
name of the file with correspondence between cellID and crate/shaper/channel numbers
Definition: eclUnpackerModule.h:165
Belle2::ECLUnpackerModule::m_globalEvtNum
int m_globalEvtNum
event number from EventMetaData
Definition: eclUnpackerModule.h:87
Belle2::ECLUnpackerModule::event
virtual void event() override
event
Definition: eclUnpackerModule.cc:154
Belle2::ECLUnpackerModule::m_eclDspsName
std::string m_eclDspsName
name of output collection for ECLDsp
Definition: eclUnpackerModule.h:163
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:596
Belle2::ECLUnpackerModule::~ECLUnpackerModule
virtual ~ECLUnpackerModule()
destructor
Definition: eclUnpackerModule.cc:112
Belle2::ECLUnpackerModule::m_bufLength
int m_bufLength
length of COPPER data
Definition: eclUnpackerModule.h:96
Belle2::ECLUnpackerModule::m_eclTrigs
StoreArray< ECLTrig > m_eclTrigs
store array for eclTrigs data (trigger time and tag)
Definition: eclUnpackerModule.h:185
Belle2::ECLUnpackerModule::readRawECLData
void readRawECLData(RawECL *rawCOPPERData, int n)
read raw data from COPPER and fill output m_eclDigits container
Definition: eclUnpackerModule.cc:257
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::ECLTrig
Class to store ECLTrig, still need to be study relation to ECLHit filled in ecl/modules/eclDigitizer/...
Definition: ECLTrig.h:38
Belle2::ECLUnpackerModule::beginRun
virtual void beginRun() override
beginRun
Definition: eclUnpackerModule.cc:138
Belle2::ECLUnpackerModule::ECLUnpackerModule
ECLUnpackerModule()
constructor
Definition: eclUnpackerModule.cc:83
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:568
Belle2::ECLUnpackerModule::m_storeTrigTime
bool m_storeTrigTime
flag for whether or not to store collection with trigger times
Definition: eclUnpackerModule.h:101
Belle2::ECLUnpackerModule::m_eclTrigsBuffer
ECLTrig m_eclTrigsBuffer[ECL::ECL_CRATES]
ECLTrigs objects before they are added to m_eclTrigs array.
Definition: eclUnpackerModule.h:195
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:151
Belle2::ECLUnpackerModule::m_tagsReportedMask
long m_tagsReportedMask
report only once per crate about problem with different trg tags
Definition: eclUnpackerModule.h:110
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:549
Belle2::ECLUnpackerModule::m_eclTrigsName
std::string m_eclTrigsName
name of output collection for ECLTrig
Definition: eclUnpackerModule.h:161