Belle II Software  release-08-01-10
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 
22 namespace Belle2 {
28  namespace PXD {
29 
40  class PXDPackerModule : public Module {
41  enum {PACKER_NUM_ROWS = 768};
42  enum {PACKER_NUM_COLS = 250};
43 
44  public:
47 
48  private:
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_PXDDigitsName;
59  std::string m_RawPXDsName;
63  bool m_Clusterize;
66  std::vector< std::vector<int >> m_dhe_to_dhc;
67 
68 // /** mapping calculated from m_dhe_to_dhc for easier handling */
69 // std::map <int, int> dhe_mapto_dhc;
70 
72  std::map <int, std::vector <int>> m_dhc_mapto_dhe;
73 
75  unsigned int m_packed_events{0};
77  unsigned int m_trigger_nr{0};
79  unsigned short m_run_nr_word1{0};
81  unsigned short m_run_nr_word2{0};
83  unsigned long long int m_meta_time{0};
84 
86  unsigned int m_trigger_dhp_framenr{0};
88  unsigned int m_trigger_dhe_gate{0};
89 
91  std::vector <unsigned int> m_onsen_header;
92 
94  std::vector <std::vector <unsigned char>> m_onsen_payload;
95 
97  std::vector <unsigned char> m_current_frame;
98 
105 
107  int m_firmware{0};
108 
113 
116  void pack_event(void);
117 
120  void pack_dhc(int dhc_id, int dhe_mask, int* dhe_ids);
121 
124  void pack_dhe(int dhe_id, int dhp_mask);
125 
128  void pack_dhp(int dhp_id, int dhe_id, int dhe_reformat, int startrow = 0);
129 
132  /* cppcheck-suppress unusedPrivateFunction */
133  void pack_dhp_raw(int dhp_id, int dhe_id);
134 
135  void start_frame(void);
136  /* cppcheck-suppress unusedPrivateFunction */
137  void append_int8(unsigned char w);
138  void append_int16(unsigned short w);
139  void append_int32(unsigned int w);
140  void add_frame_to_payload(void);
141 
143  void do_the_reverse_mapping(unsigned int& row, unsigned int& col, unsigned short layer, unsigned short sensor);
144 
146  std::map <VxdID, int> startOfVxdID;
147 
149  unsigned char halfladder_pixmap[PACKER_NUM_ROWS][PACKER_NUM_COLS] {{0}};
150 
151  unsigned int dhe_byte_count{0};
152  unsigned int dhc_byte_count{0};
154  };//end class declaration
155 
156 
157  } //end PXD namespace;
159 } // 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.