Belle II Software development
eclUnpackerModule.h
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#pragma once
10
11/* ECL headers. */
12#include <ecl/dataobjects/ECLTrig.h>
13#include <ecl/mapper/ECLChannelMapper.h>
14
15/* Basf2 headers. */
16#include <framework/core/FrameworkExceptions.h>
17#include <framework/core/Module.h>
18#include <framework/database/DBObjPtr.h>
19#include <framework/datastore/RelationArray.h>
20#include <framework/datastore/StoreArray.h>
21#include <framework/datastore/StoreObjPtr.h>
22
23namespace Belle2 {
29 class EventMetaData;
30 class RawECL;
31 class ECLDigit;
32 class ECLDsp;
33
35 class ECLUnpackerModule : public Module {
36 public:
40 virtual ~ECLUnpackerModule() {}
41
43 virtual void initialize() override;
45 virtual void beginRun() override;
47 virtual void event() override;
49 virtual void endRun() override;
51 virtual void terminate() override;
52
54 BELLE2_DEFINE_EXCEPTION(Unexpected_end_of_FINESSE_buffer,
55 "Unexpected end of the FINESSE buffer is reached while reading ShpaerDSP data");
58 BELLE2_DEFINE_EXCEPTION(Bad_ShaperDSP_header, "Corrupted Shaper DSP header");
59
61 enum ECLUnpack {
67 ECL_OFFLINE_ADC_FIT = 0x00000004,
68 };
69
70 protected:
71
72
73 private:
78
80 unsigned int* m_bufPtr;
87
94
103
108 void doEvtNumReport(unsigned int iCrate, int tag, int evt_number);
113 void doTagsReport(unsigned int iCrate, int tag0, int tag1);
118 void doPhasesReport(unsigned int iCrate, int phase0, int phase1);
123 void doBadHeaderReport(unsigned int iCrate);
124
129 bool evtNumReported(unsigned int iCrate) { return m_evtNumReportedMask & (1L << (iCrate - 1)); }
134 bool tagsReported(unsigned int iCrate) { return m_tagsReportedMask & (1L << (iCrate - 1)); }
139 bool phasesReported(unsigned int iCrate) { return m_phasesReportedMask & (1L << (iCrate - 1)); }
144 bool badHeaderReported(unsigned int iCrate) { return m_badHeaderReportedMask & (1L << (iCrate - 1)); }
145
147 std::string m_eclDigitsName;
149 std::string m_eclTrigsName;
151 std::string m_eclDspsName;
154
157
160
161 /* Input data */
162
167
168 /* Output data */
169
176
181
183 ECLTrig m_eclTrigsBuffer[ECL::ECL_CRATES];
184
187
189 unsigned int readNextCollectorWord();
191 unsigned int readNBits(int bitsToRead);
193 void readRawECLData(RawECL* rawCOPPERData, int n);
195 bool isDSPValid(int cellID, int crate, int shaper, int channel, int amp, int time, int quality);
196
197 };
199}//namespace Belle2
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
Class to store ECLTrig, still need to be study relation to ECLHit filled in ecl/modules/eclDigitizer/...
Definition: ECLTrig.h:25
the ECL unpacker module
StoreArray< RawECL > m_rawEcl
store array for RawECL
StoreArray< ECLDsp > m_eclDsps
store array for waveforms
int m_debugLevel
Cached debug level from LogSystem.
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.
unsigned int readNBits(int bitsToRead)
read N bits from COPPER buffer (needed for reading the compressed ADC data)
bool badHeaderReported(unsigned int iCrate)
Check if the problem with bad shaper header was already reported for crate iCrate.
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.
ECL::ECLChannelMapper m_eclMapper
ECL channel mapper.
bool phasesReported(unsigned int iCrate)
Check if the problem with different trigger phases was already reported for crate iCrate.
virtual void initialize() override
initialize
int m_bufPos
position in the COPPER data array
bool evtNumReported(unsigned int iCrate)
Check if the problem with trg tag <-> evt number inconsistency was already reported for crate iCrate.
virtual ~ECLUnpackerModule()
destructor
std::string m_eclTrigsName
name of output collection for ECLTrig
virtual void event() override
event
void doEvtNumReport(unsigned int iCrate, int tag, int evt_number)
Report the problem with inconsistency between trg tag and evt number.
long m_badHeaderReportedMask
report only once per crate about problem with shaper header
bool m_storeUnmapped
flag for whether or not to store ECLDsp data for unmapped channels
StoreArray< ECLTrig > m_eclTrigs
store array for eclTrigs data (trigger time and tag)
void readRawECLData(RawECL *rawCOPPERData, int n)
read raw data from COPPER and fill output m_eclDigits container
virtual void endRun() override
endRun
int m_bitPos
bit position for bit-by-bit data read
virtual void terminate() override
terminate
DBObjPtr< ECLChannelMap > m_unpackingParams
Run-dependent unpacking parameters for each channel.
StoreArray< ECLDigit > m_eclDigits
store array for digitized gits
RelationArray m_relDigitToTrig
ECLDigit->ECLTrig relation array.
StoreObjPtr< EventMetaData > m_eventMetaData
store objptr for EventMetaData
std::string m_eclMapperInitFileName
name of the file with correspondence between cellID and crate/shaper/channel numbers
int m_globalEvtNum
event number from EventMetaData
long m_evtNumReportedMask
report only once per crate about inconsistency between trg tag and evt number
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.
BELLE2_DEFINE_EXCEPTION(Bad_ShaperDSP_header, "Corrupted Shaper DSP header")
exeption should be thrown when the Shaepr DSP header is corrupted
std::string m_eclDspsName
name of output collection for ECLDsp
virtual void beginRun() override
beginRun
bool m_storeTrigTime
flag for whether or not to store collection with trigger times
unsigned int readNextCollectorWord()
read nex word from COPPER data, check if the end of data is reached
RelationArray m_relDigitToDsp
ECLDigit->ECLTrig relation array.
int m_bufLength
length of COPPER data
int m_localEvtNum
Internally counted event number.
bool tagsReported(unsigned int iCrate)
Check if the problem with different trigger tags was already reported for crate iCrate.
ECLUnpack
ECL unpacker run-dependent parameters (per channel)
@ ECL_OFFLINE_ADC_FIT
Get ECLDigits from offline waveform fit.
@ ECL_DISCARD_DSP_DATA
Skip ECLDigit unpacking.
@ ECL_KEEP_GOOD_DSP_DATA
Keep ECLDigits for quality flag 0 even if ECL_DISCARD_DSP_DATA is set.
bool m_useUnpackingParameters
Use ECLUnpackingParameters payload for run-dependent unpacking.
void doBadHeaderReport(unsigned int iCrate)
Report the problem with bad shaper header and exclude the crate from further reports of this type.
std::string m_eclDigitsName
name of output collection for ECLDigits
ECLTrig m_eclTrigsBuffer[ECL::ECL_CRATES]
ECLTrigs objects before they are added to m_eclTrigs array.
long m_phasesReportedMask
report only once per crate about problem with different trg phases
unsigned int * m_bufPtr
pointer to data from COPPER
BELLE2_DEFINE_EXCEPTION(Unexpected_end_of_FINESSE_buffer, "Unexpected end of the FINESSE buffer is reached while reading ShpaerDSP data")
exeption should be thrown when the unexpected
long m_tagsReportedMask
report only once per crate about problem with different trg tags
This class provides access to ECL channel map that is either a) Loaded from the database (see ecl/dbo...
Base class for Modules.
Definition: Module.h:72
The Raw ECL class Class for RawCOPPER class data taken by ECL Currently, this class is almost same as...
Definition: RawECL.h:26
Low-level class to create/modify relations between StoreArrays.
Definition: RelationArray.h:62
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
Abstract base class for different kinds of events.