Belle II Software  release-08-01-10
PXDUnpackerModule.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 #include <framework/core/Module.h>
12 #include <pxd/dataobjects/PXDRawHit.h>
13 #include <pxd/dataobjects/PXDRawAdc.h>
14 #include <pxd/dataobjects/PXDRawROIs.h>
15 #include <vxd/dataobjects/VxdID.h>
16 #include <rawdata/dataobjects/RawPXD.h>
17 #include <framework/datastore/StoreArray.h>
18 #include <framework/datastore/StoreObjPtr.h>
19 #include <framework/dataobjects/EventMetaData.h>
20 
21 #include <pxd/dataobjects/PXDErrorFlags.h>
22 #include <pxd/dataobjects/PXDDAQStatus.h>
23 
24 #include <pxd/dbobjects/PXDDHHFirmwareVersionPar.h>
25 #include <framework/database/DBObjPtr.h>
26 
27 namespace Belle2 {
33  namespace PXD {
34 
44  class PXDUnpackerModule : public Module {
45 
46  public:
49 
50  private:
51 
53  void initialize() override final;
55  void beginRun() override final;
57  void event() override final;
59  void terminate() override final;
60 
61  std::string m_RawPXDsName;
62  std::string m_PXDDAQEvtStatsName;
63  std::string m_PXDRawHitsName;
64  std::string m_PXDRawAdcsName;
65  std::string m_PXDRawROIsName;
68  bool m_doNotStore{false};
70  bool m_checkPaddingCRC{false};
72  bool m_forceMapping{false};
74  bool m_forceNoMapping{false};
76  unsigned int m_maxDHPFrameDiff{0};
77 
79  int m_firmware{0};
80 
82  PXDError::PXDErrorFlags m_criticalErrorMask{};
84  PXDError::PXDErrorFlags m_suppressErrorMask{};
86  PXDError::PXDErrorFlags m_errorSkipPacketMask{};
87 
89  unsigned long m_meta_event_nr{0};
91  unsigned long m_meta_run_nr{0};
93  unsigned long m_meta_subrun_nr{0};
95  unsigned long m_meta_experiment{0};
97  unsigned long long int m_meta_time{0};
99  unsigned int m_meta_sec{0};
101  unsigned int m_meta_ticks{0};
102 
104  unsigned int m_unpackedEventsCount{0};
106  unsigned int m_errorCounter[PXDError::ONSEN_MAX_TYPE_ERR] {};
108  bool m_verbose{false};
110  bool m_continueOnError{false};
111 
124 
126  PXDError::PXDErrorFlags m_errorMask{0};
128  PXDError::PXDErrorFlags m_errorMaskDHE{0};
130  PXDError::PXDErrorFlags m_errorMaskDHC{0};
132  PXDError::PXDErrorFlags m_errorMaskPacket{0};
134  PXDError::PXDErrorFlags m_errorMaskEvent{0};
135 
137  unsigned int m_notaccepted{0};
139  unsigned int m_sendrois{0};
141  unsigned int m_sendunfiltered{0};
143  bool m_formatBonnDAQ{false};
144 
146  int m_last_dhp_readout_frame_lo[4] { -1}; // signed because -1 means undefined
147 
152 
157  void unpack_rawpxd(RawPXD& px, int inx);
158 
160 
168  void unpack_dhc_frame_v01(void* data, const int length, const int Frame_Number, const int Frames_in_event,
169  PXDDAQPacketStatus& daqpktstat);
170 
181  void unpack_dhp_v01(void* data, unsigned int length, unsigned int dhe_first_readout_frame_lo, unsigned int dhe_ID,
182  unsigned dhe_DHPport,
183  unsigned dhe_reformat, VxdID vxd_id, PXDDAQPacketStatus& daqpktstat);
184 
186 
194  void unpack_dhc_frame_v10(void* data, const int length, const int Frame_Number, const int Frames_in_event,
195  PXDDAQPacketStatus& daqpktstat);
196 
207  void unpack_dhp_v10(void* data, unsigned int length, unsigned int dhe_first_readout_frame_lo, unsigned int dhe_ID,
208  unsigned dhe_DHPport,
209  unsigned dhe_reformat, VxdID vxd_id, PXDDAQPacketStatus& daqpktstat);
210 
212 
220  void unpack_dhp_raw(void* data, unsigned int length, unsigned int dhe_ID, unsigned dhe_DHPport, VxdID vxd_id);
221 
228  void unpack_fce(unsigned short* data, unsigned int length, VxdID vxd_id);
229 
230  public:
234  static int nr5bits(int i);
235 
238  static void dump_dhp(void* data, unsigned int frame_len);
239 
242  static void dump_roi(void* data, unsigned int frame_len);
243 
244  };//end class declaration
245 
246 
247  } //end PXD namespace;
249 } // end namespace Belle2
Base class for Modules.
Definition: Module.h:72
Optional DBObjPtr: This class behaves the same as the DBObjPtr except that it will not raise errors w...
Definition: DBObjPtr.h:48
The PXD DAQ Packet Status class.
The PXDUnpacker module.
int m_overrideFirmwareVersion
override firmware version from DB.
std::string m_PXDRawHitsName
The name of the StoreArray of PXDRawHits to be generated.
void unpack_dhc_frame_v01(void *data, const int length, const int Frame_Number, const int Frames_in_event, PXDDAQPacketStatus &daqpktstat)
==== the functions for the "old" firmware ====
void initialize() override final
Initialize the module.
unsigned long m_meta_experiment
Experiment from MetaInfo.
PXDError::PXDErrorFlags m_errorMaskEvent
Error Mask set per packet / event.
StoreObjPtr< PXDDAQStatus > m_storeDAQEvtStats
Output array for DAQ Status.
bool m_doNotStore
Only unpack, but Do Not Store anything to file.
StoreArray< RawPXD > m_storeRawPXD
Input array for PXD Raw.
bool m_forceNoMapping
Force No Mapping even if DHH bit is requesting it.
std::string m_PXDDAQEvtStatsName
The name of the StoreObjPtr of PXDDAQStatus to be generated.
static void dump_roi(void *data, unsigned int frame_len)
dump to a file, helper function for debugging.
PXDError::PXDErrorFlags m_suppressErrorMask
Mask for suppressing selected error messages.
bool m_formatBonnDAQ
flag ONSEN or BonnDAQ format
unsigned int m_errorCounter[PXDError::ONSEN_MAX_TYPE_ERR]
Error counters.
StoreArray< PXDRawROIs > m_storeROIs
Output array for Raw ROIs.
unsigned int m_sendunfiltered
counter for send unfiltered
PXDError::PXDErrorFlags m_errorMaskDHC
Error Mask set per packet / DHC.
bool m_checkPaddingCRC
Check for susp.
PXDError::PXDErrorFlags m_errorMaskPacket
Error Mask set per packet / packet.
std::string m_RawPXDsName
The name of the StoreArray of processed RawPXDs.
void unpack_dhc_frame_v10(void *data, const int length, const int Frame_Number, const int Frames_in_event, PXDDAQPacketStatus &daqpktstat)
==== the functions for the "new" firmware ====
void unpack_dhp_v01(void *data, unsigned int length, unsigned int dhe_first_readout_frame_lo, unsigned int dhe_ID, unsigned dhe_DHPport, unsigned dhe_reformat, VxdID vxd_id, PXDDAQPacketStatus &daqpktstat)
Unpack DHP data within one DHE frame.
void terminate() override final
Terminate the module.
StoreObjPtr< EventMetaData > m_eventMetaData
Input ptr for EventMetaData.
int m_last_dhp_readout_frame_lo[4]
some workaround check for continouous frame ids
unsigned long m_meta_subrun_nr
Subrun Number from MetaInfo.
void event() override final
do the unpacking
StoreArray< PXDRawAdc > m_storeRawAdc
Output array for Raw Adcs.
PXDUnpackerModule()
Constructor defining the parameters.
unsigned long m_meta_event_nr
Event Number from MetaInfo.
OptionalDBObjPtr< PXDDHHFirmwareVersionPar > m_firmwareFromDB
firmware version from DB.
PXDError::PXDErrorFlags m_errorSkipPacketMask
Mask for error which stop package unpacking directly.
static int nr5bits(int i)
helper function to "count" nr of set bits within lower 5 bits.
int m_firmware
Firmware version, must be read from database on run change.
void unpack_fce(unsigned short *data, unsigned int length, VxdID vxd_id)
Unpack DHP/FCE data within one DHE frame Not fully implemented as cluster format not 100% fixed.
std::string m_PXDRawAdcsName
The name of the StoreArray of PXDRawAdcs to be generated.
unsigned long m_meta_run_nr
Run Number from MetaInfo.
bool m_continueOnError
flag continue unpacking of frames even after error (for debugging)
unsigned int m_notaccepted
counter for not accepted events...
unsigned int m_meta_sec
Time(Tag) from MetaInfo, seconds (masked to lower bits)
PXDError::PXDErrorFlags m_criticalErrorMask
Critical error mask which defines return value of task.
void beginRun() override final
Begin Run.
unsigned int m_sendrois
counter for send debug rois
static void dump_dhp(void *data, unsigned int frame_len)
dump to a file, helper function for debugging.
void unpack_rawpxd(RawPXD &px, int inx)
Unpack one event (several frames) stored in RawPXD object.
unsigned long long int m_meta_time
Time(Tag) from MetaInfo.
void unpack_dhp_raw(void *data, unsigned int length, unsigned int dhe_ID, unsigned dhe_DHPport, VxdID vxd_id)
==== more firmware version independent functions ====
unsigned int m_maxDHPFrameDiff
Maximum DHP frame difference until error is reported.
PXDError::PXDErrorFlags m_errorMask
Error Mask set per packet / frame.
unsigned int m_unpackedEventsCount
Event counter.
StoreArray< PXDRawHit > m_storeRawHits
Output array for Raw Hits.
bool m_forceMapping
Force Mapping even if DHH bit is not requesting it.
unsigned int m_meta_ticks
Time(Tag) from MetaInfo, Ticks of 127MHz.
bool m_verbose
give verbose unpacking information
PXDError::PXDErrorFlags m_errorMaskDHE
Error Mask set per packet / DHE.
void unpack_dhp_v10(void *data, unsigned int length, unsigned int dhe_first_readout_frame_lo, unsigned int dhe_ID, unsigned dhe_DHPport, unsigned dhe_reformat, VxdID vxd_id, PXDDAQPacketStatus &daqpktstat)
Unpack DHP data within one DHE frame.
std::string m_PXDRawROIsName
The name of the StoreArray of PXDRawROIs to be generated.
The Raw PXD class.
Definition: RawPXD.h:27
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
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
Abstract base class for different kinds of events.