Belle II Software development
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
27namespace Belle2 {
33 namespace PXD {
34
41 class PXDUnpackerModule : public Module {
42
43 public:
46
47 private:
48
50 void initialize() override final;
52 void beginRun() override final;
54 void event() override final;
56 void terminate() override final;
57
58 std::string m_RawPXDsName;
60 std::string m_PXDRawHitsName;
61 std::string m_PXDRawAdcsName;
62 std::string m_PXDRawROIsName;
65 bool m_doNotStore{false};
67 bool m_checkPaddingCRC{false};
69 bool m_forceMapping{false};
71 bool m_forceNoMapping{false};
73 unsigned int m_maxDHPFrameDiff{0};
74
76 int m_firmware{0};
77
79 PXDError::PXDErrorFlags m_criticalErrorMask{};
81 PXDError::PXDErrorFlags m_suppressErrorMask{};
83 PXDError::PXDErrorFlags m_errorSkipPacketMask{};
84
86 unsigned long m_meta_event_nr{0};
88 unsigned long m_meta_run_nr{0};
90 unsigned long m_meta_subrun_nr{0};
92 unsigned long m_meta_experiment{0};
94 unsigned long long int m_meta_time{0};
96 unsigned int m_meta_sec{0};
98 unsigned int m_meta_ticks{0};
99
101 unsigned int m_unpackedEventsCount{0};
103 unsigned int m_errorCounter[PXDError::ONSEN_MAX_TYPE_ERR] {};
105 bool m_verbose{false};
107 bool m_continueOnError{false};
108
121
123 PXDError::PXDErrorFlags m_errorMask{0};
125 PXDError::PXDErrorFlags m_errorMaskDHE{0};
127 PXDError::PXDErrorFlags m_errorMaskDHC{0};
129 PXDError::PXDErrorFlags m_errorMaskPacket{0};
131 PXDError::PXDErrorFlags m_errorMaskEvent{0};
132
134 unsigned int m_notaccepted{0};
136 unsigned int m_sendrois{0};
138 unsigned int m_sendunfiltered{0};
140 bool m_formatBonnDAQ{false};
141
143 int m_last_dhp_readout_frame_lo[4] { -1}; // signed because -1 means undefined
144
149
154 void unpack_rawpxd(RawPXD& px, int inx);
155
157
165 void unpack_dhc_frame_v01(void* data, const int length, const int Frame_Number, const int Frames_in_event,
166 PXDDAQPacketStatus& daqpktstat);
167
178 void unpack_dhp_v01(void* data, unsigned int length, unsigned int dhe_first_readout_frame_lo, unsigned int dhe_ID,
179 unsigned dhe_DHPport,
180 unsigned dhe_reformat, VxdID vxd_id, PXDDAQPacketStatus& daqpktstat);
181
183
191 void unpack_dhc_frame_v10(void* data, const int length, const int Frame_Number, const int Frames_in_event,
192 PXDDAQPacketStatus& daqpktstat);
193
204 void unpack_dhp_v10(void* data, unsigned int length, unsigned int dhe_first_readout_frame_lo, unsigned int dhe_ID,
205 unsigned dhe_DHPport,
206 unsigned dhe_reformat, VxdID vxd_id, PXDDAQPacketStatus& daqpktstat);
207
209
217 void unpack_dhp_raw(void* data, unsigned int length, unsigned int dhe_ID, unsigned dhe_DHPport, VxdID vxd_id);
218
225 void unpack_fce(unsigned short* data, unsigned int length, VxdID vxd_id);
226
227 public:
231 static int nr5bits(int i);
232
235 static void dump_dhp(void* data, unsigned int frame_len);
236
239 static void dump_roi(void* data, unsigned int frame_len);
240
241 };//end class declaration
242
243
244 } //end PXD namespace;
246} // 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... should not happen TODO discussion ongoing with DAQ group
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.