Belle II Software development
PXDPackerModule.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 <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/PXDDigit.h>
17#include <pxd/dataobjects/PXDInjectionBGTiming.h>
18
19#include <pxd/dbobjects/PXDDHHFirmwareVersionPar.h>
20#include <framework/database/DBObjPtr.h>
21
22namespace Belle2 {
28 namespace PXD {
29
37 class PXDPackerModule : public Module {
38 enum {PACKER_NUM_ROWS = 768};
39 enum {PACKER_NUM_COLS = 250};
40
41 public:
44
45 private:
47 void initialize() override final;
49 void beginRun() override final;
51 void event() override final;
53 void terminate() override final;
54
55 std::string m_PXDDigitsName;
56 std::string m_RawPXDsName;
63 std::vector< std::vector<int >> m_dhe_to_dhc;
64
65// /** mapping calculated from m_dhe_to_dhc for easier handling */
66// std::map <int, int> dhe_mapto_dhc;
67
69 std::map <int, std::vector <int>> m_dhc_mapto_dhe;
70
72 unsigned int m_packed_events{0};
74 unsigned int m_trigger_nr{0};
76 unsigned short m_run_nr_word1{0};
78 unsigned short m_run_nr_word2{0};
80 unsigned long long int m_meta_time{0};
81
83 unsigned int m_trigger_dhp_framenr{0};
85 unsigned int m_trigger_dhe_gate{0};
86
88 std::vector <unsigned int> m_onsen_header;
89
91 std::vector <std::vector <unsigned char>> m_onsen_payload;
92
94 std::vector <unsigned char> m_current_frame;
95
102
105
110
113 void pack_event(void);
114
117 void pack_dhc(int dhc_id, int dhe_mask, int* dhe_ids);
118
121 void pack_dhe(int dhe_id, int dhp_mask);
122
125 void pack_dhp(int dhp_id, int dhe_id, int dhe_reformat, int startrow = 0);
126
129 /* cppcheck-suppress unusedPrivateFunction */
130 void pack_dhp_raw(int dhp_id, int dhe_id);
131
132 void start_frame(void);
133 /* cppcheck-suppress unusedPrivateFunction */
134 void append_int8(unsigned char w);
135 void append_int16(unsigned short w);
136 void append_int32(unsigned int w);
137 void add_frame_to_payload(void);
138
140 void do_the_reverse_mapping(unsigned int& row, unsigned int& col, unsigned short layer, unsigned short sensor);
141
143 std::map <VxdID, int> startOfVxdID;
144
146 unsigned char halfladder_pixmap[PACKER_NUM_ROWS][PACKER_NUM_COLS] {{0}};
147
148 unsigned int dhe_byte_count{0};
149 unsigned int dhc_byte_count{0};
151 };//end class declaration
152
153
154 } //end PXD namespace;
156} // 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 PXDPacker module.
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.
int m_overrideFirmwareVersion
override firmware version from DB.
void initialize() override final
Initialize the module.
StoreObjPtr< PXDInjectionBGTiming > m_storeInjectionBGTiming
Input Obj InjectionBGTiming.
void add_frame_to_payload(void)
Add Frame to Event payload.
unsigned short m_run_nr_word2
Exp+Run Nr.
std::map< VxdID, int > startOfVxdID
Store start of Vxd Detector related digits.
void append_int16(unsigned short w)
cat 16bit value to frame
void pack_dhe(int dhe_id, int dhp_mask)
Pack one DHE (several DHP) to buffer.
void pack_dhp(int dhp_id, int dhe_id, int dhe_reformat, int startrow=0)
Pack one DHP to buffer.
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.
void pack_dhc(int dhc_id, int dhe_mask, int *dhe_ids)
Pack one DHC (several DHE) stored in one RawPXD object.
PXDPackerModule()
Constructor defining the parameters.
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
std::string m_InjectionBGTimingName
The name of the StoreObj InjectionBGTiming.
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.
OptionalDBObjPtr< PXDDHHFirmwareVersionPar > m_firmwareFromDB
firmware version from DB.
std::vector< unsigned int > m_onsen_header
For one DHC event, we utilize one header (writing out, beware of endianess!)
int m_firmware
Firmware version, must be read from database on run change.
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.
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.
void beginRun() override final
begin run
unsigned int m_packed_events
Event counter.
bool m_InvertMapping
Flag if we invert mapping to DHP row/col or use premapped coordinates.
std::string m_PXDDigitsName
The name of the StoreArray of PXDDigits to be processed.
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.
StoreArray< PXDDigit > m_storeDigits
Input array for Digits.
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.