11#include <framework/core/Module.h>
12#include <vxd/dataobjects/VxdID.h>
13#include <framework/datastore/StoreArray.h>
14#include <framework/datastore/StoreObjPtr.h>
15#include <rawdata/dataobjects/RawPXD.h>
16#include <pxd/dataobjects/PXDDAQStatus.h>
17#include <pxd/dataobjects/PXDErrorFlags.h>
35 enum {PACKER_NUM_ROWS = 768};
36 enum {PACKER_NUM_COLS = 250};
40 c_NO_ERROR = __uint128_t(0),
41 c_ALL_ERROR = ~ c_NO_ERROR,
43 c_EVENT_STRUCT = __uint128_t(1) << Belle2::PXD::PXDError::c_nrEVENT_STRUCT,
44 c_FRAME_TNR_MM = __uint128_t(1) << Belle2::PXD::PXDError::c_nrFRAME_TNR_MM,
45 c_META_MM = __uint128_t(1) << Belle2::PXD::PXDError::c_nrMETA_MM,
46 c_ONSEN_TRG_FIRST = __uint128_t(1) << Belle2::PXD::PXDError::c_nrONSEN_TRG_FIRST,
48 c_DHC_END_MISS = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHC_END_MISS,
49 c_NR_FRAMES_TO_SMALL = __uint128_t(1) << Belle2::PXD::PXDError::c_nrNR_FRAMES_TO_SMALL,
50 c_ROI_PACKET_INV_SIZE = __uint128_t(1) << Belle2::PXD::PXDError::c_nrROI_PACKET_INV_SIZE,
51 c_DATA_OUTSIDE = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDATA_OUTSIDE,
53 c_DHC_START_SECOND = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHC_START_SECOND,
54 c_DHE_WRONG_ID_SEQ = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHE_WRONG_ID_SEQ,
55 c_FIX_SIZE = __uint128_t(1) << Belle2::PXD::PXDError::c_nrFIX_SIZE,
56 c_DHE_CRC = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHE_CRC,
58 c_DHC_UNKNOWN = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHC_UNKNOWN,
59 c_HEADERTYPE_INV = __uint128_t(1) << Belle2::PXD::PXDError::c_nrHEADERTYPE_INV,
60 c_PACKET_SIZE = __uint128_t(1) << Belle2::PXD::PXDError::c_nrPACKET_SIZE,
61 c_MAGIC = __uint128_t(1) << Belle2::PXD::PXDError::c_nrMAGIC,
63 c_FRAME_NR = __uint128_t(1) << Belle2::PXD::PXDError::c_nrFRAME_NR,
64 c_FRAME_SIZE = __uint128_t(1) << Belle2::PXD::PXDError::c_nrFRAME_SIZE,
65 c_HLTROI_MAGIC = __uint128_t(1) << Belle2::PXD::PXDError::c_nrHLTROI_MAGIC,
66 c_MERGER_TRIGNR = __uint128_t(1) << Belle2::PXD::PXDError::c_nrMERGER_TRIGNR,
68 c_DHP_SIZE = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHP_SIZE,
69 c_DHE_DHP_DHEID = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHE_DHP_DHEID,
70 c_DHE_DHP_PORT = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHE_DHP_PORT,
71 c_DHP_PIX_WO_ROW = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHP_PIX_WO_ROW,
73 c_DHE_START_END_ID = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHE_START_END_ID,
74 c_DHE_START_ID = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHE_START_ID,
75 c_DHE_START_WO_END = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHE_START_WO_END,
76 c_NO_PXD = __uint128_t(1) << Belle2::PXD::PXDError::c_nrNO_PXD,
78 c_NO_DATCON = __uint128_t(1) << Belle2::PXD::PXDError::c_nrNO_DATCON,
79 c_FAKE_NO_DATA_TRIG = __uint128_t(1) << Belle2::PXD::PXDError::c_nrFAKE_NO_DATA_TRIG,
80 c_DHE_ACTIVE = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHE_ACTIVE,
81 c_DHP_ACTIVE = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHP_ACTIVE,
83 c_SENDALL_TYPE = __uint128_t(1) << Belle2::PXD::PXDError::c_nrSENDALL_TYPE,
84 c_NOTSENDALL_TYPE = __uint128_t(1) << Belle2::PXD::PXDError::c_nrNOTSENDALL_TYPE,
85 c_DHP_DBL_HEADER = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHP_DBL_HEADER,
86 c_HEADER_ERR = __uint128_t(1) << Belle2::PXD::PXDError::c_nrHEADER_ERR,
88 c_HEADER_ERR_GHOST = __uint128_t(1) << Belle2::PXD::PXDError::c_nrHEADER_ERR_GHOST,
89 c_SUSP_PADDING = __uint128_t(1) << Belle2::PXD::PXDError::c_nrSUSP_PADDING,
90 c_DHC_WIE = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHC_WIE,
91 c_DHE_WIE = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHE_WIE,
93 c_ROW_OVERFLOW = __uint128_t(1) << Belle2::PXD::PXDError::c_nrROW_OVERFLOW,
94 c_DHP_NOT_CONT = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHP_NOT_CONT,
95 c_DHP_DHP_FRAME_DIFFER = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHP_DHP_FRAME_DIFFER,
96 c_DHP_DHE_FRAME_DIFFER = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHP_DHE_FRAME_DIFFER,
98 c_DHE_ID_INVALID = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHE_ID_INVALID,
99 c_DHC_DHCID_START_END_MM = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHC_DHCID_START_END_MM,
100 c_DHE_END_WO_START = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHE_END_WO_START,
101 c_DHC_END_DBL = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHC_END_DBL,
103 c_META_MM_DHC = __uint128_t(1) << Belle2::PXD::PXDError::c_nrMETA_MM_DHC,
104 c_META_MM_DHE = __uint128_t(1) << Belle2::PXD::PXDError::c_nrMETA_MM_DHE,
105 c_COL_OVERFLOW = __uint128_t(1) << Belle2::PXD::PXDError::c_nrCOL_OVERFLOW,
106 c_UNEXPECTED_FRAME_TYPE = __uint128_t(1) << Belle2::PXD::PXDError::c_nrUNEXPECTED_FRAME_TYPE,
108 c_META_MM_DHC_ERS = __uint128_t(1) << Belle2::PXD::PXDError::c_nrMETA_MM_DHC_ERS,
109 c_META_MM_DHC_TT = __uint128_t(1) << Belle2::PXD::PXDError::c_nrMETA_MM_DHC_TT,
110 c_META_MM_ONS_HLT = __uint128_t(1) << Belle2::PXD::PXDError::c_nrMETA_MM_ONS_HLT,
111 c_META_MM_ONS_DC = __uint128_t(1) << Belle2::PXD::PXDError::c_nrMETA_MM_ONS_DC,
113 c_EVT_TRG_GATE_DIFFER = __uint128_t(1) << Belle2::PXD::PXDError::c_nrEVT_TRG_GATE_DIFFER,
114 c_EVT_TRG_FRM_NR_DIFFER = __uint128_t(1) << Belle2::PXD::PXDError::c_nrEVT_TRG_FRM_NR_DIFFER,
115 c_DHP_ROW_WO_PIX = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHP_ROW_WO_PIX,
116 c_DHE_START_THIRD = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHE_START_THIRD,
118 c_FAKE_NO_FAKE_DATA = __uint128_t(1) << Belle2::PXD::PXDError::c_nrFAKE_NO_FAKE_DATA,
119 c_UNUSABLE_DATA = __uint128_t(1) << Belle2::PXD::PXDError::c_nrUNUSABLE_DATA,
120 c_DHH_END_ERRORBITS = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHH_END_ERRORBITS,
121 c_DHH_MISC_ERROR = __uint128_t(1) << Belle2::PXD::PXDError::c_nrDHH_MISC_ERROR,
133 void event() override final;
192 void pack_dhc(
int dhc_id,
int dhe_mask,
int* dhe_ids,
bool send_all =
true,
bool send_roi =
false);
196 void pack_dhe(
int dhe_id,
int dhp_mask);
200 void pack_dhp(
int dhp_id,
int dhe_id,
int dhe_reformat);
214 void do_the_reverse_mapping(
unsigned int& row,
unsigned int& col,
unsigned short layer,
unsigned short sensor);
void do_the_reverse_mapping(unsigned int &row, unsigned int &col, unsigned short layer, unsigned short sensor)
function still to be implemented
std::vector< std::vector< unsigned char > > m_onsen_payload
For one DHC event, we utilize one payload for all DHE/DHP frames.
void initialize() override final
Initialize the module.
bool m_Check
false=Pack Raw Data, true=Check unpacked result
void add_frame_to_payload(void)
Add Frame to Event payload.
unsigned short m_run_nr_word2
Exp+Run Nr.
std::string m_PXDDAQEvtStatsName
The name of the StoreObjPtr of PXDDAQStatus to be read.
std::map< VxdID, int > startOfVxdID
Store start of Vxd Detector related digits.
void append_int16(unsigned short w)
cat 16bit value to frame
StoreObjPtr< PXDDAQStatus > m_daqStatus
Output array for RawPxds.
void pack_dhe(int dhe_id, int dhp_mask)
Pack one DHE (several DHP) to buffer.
bool m_found_fatal
flag if we found one test failing
myerrormasks
enumeration of the error masks
void pack_dhp_raw(int dhp_id, int dhe_id)
Pack one DHP RAW to buffer.
std::string m_RawPXDsName
The name of the StoreArray of generated RawPXDs.
bool CheckErrorMaskInEvent(unsigned int eventnr, PXDError::PXDErrorFlags mask)
void pack_event(void)
Pack one event (several DHC) stored in seperate RawPXD object.
void terminate() override final
Terminate the module.
void event() override final
do the packing
PXDPackerErrModule()
Constructor defining the parameters.
unsigned int dhc_byte_count
Byte count in current DHC package.
std::vector< std::vector< int > > m_dhe_to_dhc
Parameter dhc<->dhe list, mapping from steering file.
bool m_Clusterize
Use clusterizer (FCE format)
unsigned short m_run_nr_word1
Run+Subrun Nr.
bool isErrorIn(uint32_t enr)
Check if we want this type of error in this event.
std::vector< unsigned int > m_onsen_header
For one DHC event, we utilize one header (writing out, beware of endianess!)
unsigned int m_real_trigger_nr
Real Trigger Nr.
void append_int32(unsigned int w)
cat 32value value to frame
StoreArray< RawPXD > m_storeRaws
Output array for RawPxds.
unsigned int m_trigger_dhp_framenr
DHP Readout Frame Nr for DHP and DHE headers.
unsigned int dhe_byte_count
Byte count in current DHE package.
static std::vector< PXDErrorFlags > m_errors
The pxd error flags.
void pack_dhp(int dhp_id, int dhe_id, int dhe_reformat)
Pack one DHP to buffer.
std::map< int, std::vector< int > > m_dhc_mapto_dhe
mapping calculated from m_dhe_to_dhc for easier handling
void start_frame(void)
Start with a new Frame.
void append_int8(unsigned char w)
cat 8bit value to frame
unsigned int m_trigger_dhe_gate
DHE Trigger Gate for DHE headers.
unsigned int m_packed_events
Event counter.
bool m_InvertMapping
Flag if we invert mapping to DHP row/col or use premapped coordinates.
unsigned long long int m_meta_time
Time(Tag) from MetaInfo.
std::vector< unsigned char > m_current_frame
For current processed frames.
unsigned char halfladder_pixmap[PACKER_NUM_ROWS][PACKER_NUM_COLS]
temporary hitmap buffer for pixel to raw data conversion
unsigned int m_trigger_nr
Trigger Nr.
void pack_dhc(int dhc_id, int dhe_mask, int *dhe_ids, bool send_all=true, bool send_roi=false)
Pack one DHC (several DHE) stored in one RawPXD object.
Accessor to arrays stored in the data store.
Type-safe access to single objects in the data store.
Abstract base class for different kinds of events.