Belle II Software  release-08-01-10
PXDUnpackerOTModule.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 namespace Belle2 {
30  namespace PXD {
31 
41  class PXDUnpackerOTModule : public Module {
42 
43  public:
46 
47  private:
48 
50  void initialize() override final;
52  void event() override final;
54  void terminate() override final;
55 
56  std::string m_RawPXDsName;
57  std::string m_PXDDAQEvtStatsName;
58  std::string m_PXDRawHitsName;
59  std::string m_PXDRawAdcsName;
60  std::string m_PXDRawROIsName;
63  bool m_doNotStore{false};
65  bool m_checkPaddingCRC{false};
67  bool m_forceMapping{false};
69  bool m_forceNoMapping{false};
71  unsigned int m_maxDHPFrameDiff{0};
72 
74  PXDError::PXDErrorFlags m_criticalErrorMask{};
76  PXDError::PXDErrorFlags m_suppressErrorMask{};
78  PXDError::PXDErrorFlags m_errorSkipPacketMask{};
79 
81  unsigned long m_meta_event_nr{0};
83  unsigned long m_meta_run_nr{0};
85  unsigned long m_meta_subrun_nr{0};
87  unsigned long m_meta_experiment{0};
89  unsigned long long int m_meta_time{0};
91  unsigned int m_meta_sec{0};
93  unsigned int m_meta_ticks{0};
94 
96  unsigned int m_unpackedEventsCount{0};
98  unsigned int m_errorCounter[PXDError::ONSEN_MAX_TYPE_ERR] {};
100  bool m_verbose{false};
102  bool m_continueOnError{false};
103 
116 
121  void unpack_rawpxd(RawPXD& px, int inx);
122 
130  void unpack_dhc_frame(void* data, const int len, const int Frame_Number, const int Frames_in_event, PXDDAQPacketStatus& daqpktstat);
131 
142  void unpack_dhp(void* data, unsigned int len, unsigned int dhe_first_readout_frame_lo, unsigned int dhe_ID, unsigned dhe_DHPport,
143  unsigned dhe_reformat, VxdID vxd_id, PXDDAQPacketStatus& daqpktstat);
144 
152  void unpack_dhp_raw(void* data, unsigned int len, unsigned int dhe_ID, unsigned dhe_DHPport, VxdID vxd_id);
153 
160  void unpack_fce(unsigned short* data, unsigned int length, VxdID vxd_id);
161 
163  PXDError::PXDErrorFlags m_errorMask{0};
165  PXDError::PXDErrorFlags m_errorMaskDHE{0};
167  PXDError::PXDErrorFlags m_errorMaskDHC{0};
169  PXDError::PXDErrorFlags m_errorMaskPacket{0};
171  PXDError::PXDErrorFlags m_errorMaskEvent{0};
172 
174  unsigned int m_notaccepted{0};
176  unsigned int m_sendrois{0};
178  unsigned int m_sendunfiltered{0};
180  bool m_formatBonnDAQ{false};
181 
183  int m_last_dhp_readout_frame_lo[4] { -1}; // signed because -1 means undefined
184 
185  public:
189  static int nr5bits(int i);
190 
193  static void dump_dhp(void* data, unsigned int frame_len);
194 
197  static void dump_roi(void* data, unsigned int frame_len);
198 
199  };//end class declaration
200 
201 
202  } //end PXD namespace;
204 } // end namespace Belle2
Base class for Modules.
Definition: Module.h:72
The PXD DAQ Packet Status class.
std::string m_PXDRawHitsName
The name of the StoreArray of PXDRawHits to be generated.
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.
PXDUnpackerOTModule()
Constructor defining the parameters.
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.
PXDError::PXDErrorFlags m_errorMaskPacket
Error Mask set per packet / packet.
std::string m_RawPXDsName
The name of the StoreArray of processed RawPXDs.
void unpack_dhp(void *data, unsigned int len, 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.
unsigned long m_meta_event_nr
Event Number from MetaInfo.
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.
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)
void unpack_dhp_raw(void *data, unsigned int len, unsigned int dhe_ID, unsigned dhe_DHPport, VxdID vxd_id)
Unpack DHP RAW data within one DHE frame (pedestals, etc)
PXDError::PXDErrorFlags m_criticalErrorMask
Critical error mask which defines return value of task.
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.
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.
void unpack_dhc_frame(void *data, const int len, const int Frame_Number, const int Frames_in_event, PXDDAQPacketStatus &daqpktstat)
Unpack one frame (within an event).
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.
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.