Belle II Software development
PXDPackerModule.cc
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#include <pxd/unpacking/PXDRawDataDefinitions.h>
10#include <pxd/modules/pxdUnpacking/PXDPackerModule.h>
11#include <framework/datastore/DataStore.h>
12#include <framework/logging/Logger.h>
13#include <framework/dataobjects/EventMetaData.h>
14#include <framework/datastore/StoreObjPtr.h>
15#include <framework/core/ModuleParam.templateDetails.h>
16
17#include <boost/crc.hpp>
18#include <boost/algorithm/clamp.hpp>
19
20#include <pxd/unpacking/PXDMappingLookup.h>
21
22
23#include <TRandom.h>
24
25using namespace std;
26using namespace Belle2;
27using namespace Belle2::PXD;
28
29//-----------------------------------------------------------------
30// Register the Module
31//-----------------------------------------------------------------
32REG_MODULE(PXDPacker);
33
34//-----------------------------------------------------------------
35// Implementation
36//-----------------------------------------------------------------
37
38using boost::crc_optimal;
39typedef crc_optimal<32, 0x04C11DB7, 0, 0, false, false> dhe_crc_32_type;
40
44
46 Module(),
47 m_storeRaws()
48{
49 m_trigger_nr = 0;
53 //Set module properties
54 setDescription("Pack PXD Hits to raw data object");
56
57 addParam("PXDDigitsName", m_PXDDigitsName, "The name of the StoreArray of PXDDigits to be processed", std::string(""));
58 addParam("RawPXDsName", m_RawPXDsName, "The name of the StoreArray of generated RawPXDs", std::string(""));
59 addParam("InjectionBGTimingName", m_InjectionBGTimingName, "The name of the StoreObj for Injection Timing", std::string(""));
60 addParam("dhe_to_dhc", m_dhe_to_dhc, "DHE to DHC mapping (DHC_ID, DHE1, DHE2, ..., DHE5) ; -1 disable port");
61 addParam("InvertMapping", m_InvertMapping, "Use invers mapping to DHP row/col instead of \"remapped\" coordinates", false);
62 addParam("Clusterize", m_Clusterize, "Use clusterizer (FCE format)", false);
63 addParam("overrideFirmwareVersion", m_overrideFirmwareVersion, "Overwrite Firmware Version from DB with this value", 0);
64
65}
66
68{
69 // Register output collections
73
75
76 B2DEBUG(27, "Clusterizer is " << m_Clusterize);
77 B2DEBUG(27, "InvertMapping is " << m_InvertMapping);
78
82 for (auto& it : m_dhe_to_dhc) {
83 bool flag;
84 int dhc_id;
85 B2DEBUG(27, "PXD Packer --> DHC/DHE");
86 flag = false;
87 if (it.size() != 6) {
89 B2WARNING("PXD Packer --> DHC/DHE maps 1 dhc to 5 dhe (1+5 values), but I found " << it.size());
90 }
91 for (auto& it2 : it) {
92 if (flag) {
93 int v;
94 v = it2;
95 B2DEBUG(27, "PXD Packer --> ... DHE " << it2);
96 if (it2 < -1 || it2 >= 64) {
97 if (it2 != -1) B2ERROR("PXD Packer --> DHC id " << it2 << " is out of range (0-64 or -1)! disable channel.");
98 v = -1;
99 }
100// if (v > 0) dhe_mapto_dhc[v] = dhc_id;
101 m_dhc_mapto_dhe[dhc_id].push_back(v);
102 } else {
103 dhc_id = it2;
104 B2DEBUG(27, "PXD Packer --> DHC .. " << it2);
105 if (dhc_id < 0 || dhc_id >= 16) {
106 B2ERROR("PXD Packer --> DHC id " << it2 << " is out of range (0-15)! skip");
107 break;
108 }
109 }
110 flag = true;
111 }
112 }
113 B2DEBUG(27, "PXD Packer --> DHC/DHE done");
114
115// for (auto & it : m_dhe_mapto_dhc) {
116// B2DEBUG(27, "PXD Packer --> DHE " << it.first << " connects to DHC " << it.second);
117// }
118
119 for (auto& it : m_dhc_mapto_dhe) {
120 int port = 0;
121 B2DEBUG(27, "PXD Packer --> DHC " << it.first);
122 for (auto& it2 : it.second) {
123 B2DEBUG(27, "PXD Packer --> .. connects to DHE " << it2 << " port " << port);
124 port++;
125 }
126 }
127
128}
129
131{
132 if (m_overrideFirmwareVersion == 0) {
133 if (m_firmwareFromDB.isValid()) m_firmware = (*m_firmwareFromDB).getDHHFirmwareVersion();
134 else {
135 B2WARNING("Could not read PXD Firmware version from db, assume default (new) firmware");
136 m_firmware = 10;
137 }
138 } else {
140 }
141}
142
144{
145}
146
148{
150
151 // First, throw the dices for a few event-wise properties
152 // optional, use simulated trigger information to calculate it
153
154 m_trigger_dhp_framenr = gRandom->Integer(0x10000);
155 // we use the very same m_trigger_dhp_framenr in DHE and DHP header, no second DHP frame is generated anyway
156 // (-> like in the new firmware)
157
158 if (m_storeInjectionBGTiming.isValid()) {
160 } else {
161 m_trigger_dhe_gate = gRandom->Integer(192);
162 }
163
164 int nDigis = m_storeDigits.getEntries();
165
166 B2DEBUG(27, "PXD Packer --> Nr of Digis: " << nDigis);
167
168 startOfVxdID.clear();
169
170 VxdID lastVxdId = -1;
173 for (auto it = m_storeDigits.begin() ; it != m_storeDigits.end(); ++it) {
174 VxdID currentVxdId;
175 currentVxdId = it->getSensorID();
176 currentVxdId.setSegmentNumber(0);
177 if (currentVxdId != lastVxdId) {
178 // do something...
179 lastVxdId = currentVxdId;
180 B2DEBUG(27, "VxdId: " << currentVxdId << " " << (int)currentVxdId);
181 {
182 unsigned int layer, ladder, sensor, segment, dhe_id;
183 layer = currentVxdId.getLayerNumber();
184 ladder = currentVxdId.getLadderNumber();
185 sensor = currentVxdId.getSensorNumber();
186 segment = currentVxdId.getSegmentNumber();// Frame nr?
187 dhe_id = ((layer - 1) << 5) | ((ladder) << 1) | (sensor - 1);
188 B2DEBUG(27, "Layer: " << layer << " Ladder " << ladder << " Sensor " << sensor << " Segment(Frame) " << segment << " =>DHEID: " <<
189 dhe_id);
190 }
191
192 if (startOfVxdID.count(currentVxdId) > 0) B2FATAL("PXD Digits are not sorted by VxdID!");
193 startOfVxdID[currentVxdId] = std::distance(m_storeDigits.begin(), it);
194 B2DEBUG(27, "Offset : " << startOfVxdID[currentVxdId]);
195 }
196 }
197
198 m_trigger_nr = evtPtr->getEvent();
199 m_run_nr_word1 = ((evtPtr->getRun() & 0xFF) << 8) | (evtPtr->getSubrun() & 0xFF);
200 m_run_nr_word2 = ((evtPtr->getExperiment() & 0x3FF) << 6) | ((evtPtr->getRun() >> 8) & 0x3F);
201 m_meta_time = evtPtr->getTime();
202
203 pack_event();
205}
206
207
209{
210 int dhe_ids[5] = {0, 0, 0, 0, 0};
211 B2DEBUG(27, "PXD Packer --> pack_event");
212
213 // loop for each DHC in system
214 // get active DHCs from a database?
215 for (auto& it : m_dhc_mapto_dhe) {
216 int port = 1, port_inx = 0;
217 int act_port = 0;
218
219 for (auto& it2 : it.second) {
220 if (it2 >= 0) act_port += port;
221 port += port;
222 dhe_ids[port_inx] = it2;
223 port_inx++;
224 if (port_inx == 5) break; // not more than five.. checked above
225 }
226
227 // if(act_port&0x1F) B2ERROR();... checked above
228 // act_port&=0x1F;... checked above
229
230 // get active DHE mask from a database?
231
232 m_onsen_header.clear();// Reset
233 m_onsen_payload.clear();// Reset
234 pack_dhc(it.first, act_port, dhe_ids);
235 // and write to PxdRaw object
236 // header will be finished and endian swapped by constructor; payload already has be on filling the vector
238 }
239
240}
241
243{
244 if (m_current_frame.size() & 0x3) {
245 B2ERROR("Frame is not 32bit aligned!!! Unsupported by Unpacker!");
246 }
247 // checksum frame
248 dhe_crc_32_type current_crc;
249 current_crc.process_bytes(m_current_frame.data(), m_current_frame.size());
250 append_int32(current_crc.checksum());
251
252 // and add it
253 m_onsen_header.push_back(m_current_frame.size());
255}
256
257void PXDPackerModule::append_int8(unsigned char w)
258{
259 m_current_frame.push_back(w);
262}
263
264void PXDPackerModule::append_int16(unsigned short w)
265{
266 m_current_frame.push_back((unsigned char)(w >> 8));
267 m_current_frame.push_back((unsigned char)(w));
268 dhe_byte_count += 2;
269 dhc_byte_count += 2;
270}
271
273{
274 m_current_frame.push_back((unsigned char)(w >> 24));
275 m_current_frame.push_back((unsigned char)(w >> 16));
276 m_current_frame.push_back((unsigned char)(w >> 8));
277 m_current_frame.push_back((unsigned char)(w));
278 dhe_byte_count += 4;
279 dhc_byte_count += 4;
280}
281
283{
284 m_current_frame.clear();
285}
286
287void PXDPackerModule::pack_dhc(int dhc_id, int dhe_active, int* dhe_ids)
288{
289 B2DEBUG(27, "PXD Packer --> pack_dhc ID " << dhc_id << " DHE act: " << dhe_active);
290
292 start_frame();
293 append_int32((EDHCFrameHeaderDataType::c_ONSEN_TRG << 27) | (m_trigger_nr & 0xFFFF));
294 append_int32(0xCAFE8000);// HLT HEADER, accepted flag set
295 append_int32(m_trigger_nr); // HLT Trigger Nr
296 append_int16(m_run_nr_word2); // Exp NR 9-0 | Run Nr 13-8
297 append_int16(m_run_nr_word1); // Run Nr 7-0 | Subrunnr 7-0
298 append_int32(0xCAFE0000);// DATCON HEADER ...
299 append_int32(m_trigger_nr); // DATCON Trigger Nr
300 append_int16(m_run_nr_word2); // Exp NR 9-0 | Run Nr 13-8
301 append_int16(m_run_nr_word1); // Run Nr 7-0 | Subrunnr 7-0
303
305
306 dhc_byte_count = 0;
307 start_frame();
308 append_int32((EDHCFrameHeaderDataType::c_DHC_START << 27) | ((dhc_id & 0xF) << 21) | ((dhe_active & 0x1F) << 16) |
309 (m_trigger_nr & 0xFFFF));
311
312 uint32_t mm = (unsigned int)std::round((m_meta_time % 1000000000ull) * 0.127216); // in 127MHz Ticks
313 uint32_t ss = (unsigned int)(m_meta_time / 1000000000ull) ; // in seconds
314 append_int16(((mm << 4) & 0xFFF0) | 0x1); // TT 11-0 | Type --- fill with something usefull TODO
315 append_int16(((mm >> 12) & 0x7FFF) | ((ss & 1) ? 0x8000 : 0x0)); // TT 27-12 ... not clear if completely filled by DHC
316 append_int16((ss >> 1) & 0xFFFF); // TT 43-28 ... not clear if completely filled by DHC
317 append_int16(m_run_nr_word1); // Run Nr 7-0 | Subrunnr 7-0
318 append_int16(m_run_nr_word2); // Exp NR 9-0 | Run Nr 13-8
320
321 // loop for each DHE in system
322 // Run & TTT etc are zero until better idea
323
324 for (int i = 0; i < 5; i++) {
325 if (dhe_active & 0x1) pack_dhe(dhe_ids[i], 0xF);
326 dhe_active >>= 1;
327 }
328
330
331 // start_frame();
332 // append_int32((EDHCFrameHeaderDataType::c_ONSEN_ROI<<27) | (m_trigger_nr & 0xFFFF));
334 // add_frame_to_payload();
335
337 unsigned int dlen = (dhc_byte_count / 4); // 32 bit words
338 start_frame();
339 append_int32((EDHCFrameHeaderDataType::c_DHC_END << 27) | ((dhc_id & 0xF) << 21) | (m_trigger_nr & 0xFFFF));
340 append_int32(dlen); // 32 bit word count
341 append_int32(0x00000000); // Error Flags
343
344}
345
346void PXDPackerModule::pack_dhe(int dhe_id, int dhp_active)
347{
348 B2DEBUG(27, "PXD Packer --> pack_dhe ID " << dhe_id << " DHP act: " << dhp_active);
349 // dhe_id is not dhe_id ...
350 bool dhe_has_remapped = !m_InvertMapping;
351
352 if (m_InvertMapping) {
353 // problem, we do not have an exact definition of if this bit is set in the new firmware and under which circumstances
354 // and its not clear if we have to translate the coordinates back to "DHP" layout! (look up tabel etc!)
355 // this code has never been completed as pxd cluster format will anyway need mapping in firmware
356 B2FATAL("Inverse Mapping not implemented in Packer");
357 }
358
360 dhe_byte_count = 0;
361 start_frame();
362 append_int32((EDHCFrameHeaderDataType::c_DHE_START << 27) | ((dhe_id & 0x3F) << 20) | ((dhp_active & 0xF) << 16) |
363 (m_trigger_nr & 0xFFFF));
364 append_int16(m_trigger_nr >> 16); // Trigger Nr Hi
365 append_int16(0x00000000); // DHE Timer Lo
366 append_int16(0x00000000); // DHE Time Hi
367 append_int16(((m_trigger_dhp_framenr & 0x3F) << 10) |
368 (m_trigger_dhe_gate & 0xFF)); // Last DHP Frame Nr 15-10, Reserved 9-8, Trigger Offset 7-0
370
371// now prepare the data from one halfladder
372// do the ROI selection??? optional...
373// then loop for each DHP in system
374// get active DHPs from a database?
375// and pack data per halfladder.
376// we fake the framenr and startframenr until we find some better solution
377
378 if (dhp_active != 0) {
379 // const int ladder_min_row = 0; Hardware counts from 0, only include if it does not.
380 const int ladder_max_row = PACKER_NUM_ROWS - 1;
381 // const int ladder_min_col = 0;
382 const int ladder_max_col = PACKER_NUM_COLS - 1;
383
385 bzero(halfladder_pixmap, sizeof(halfladder_pixmap));
386
387 VxdID currentVxdId = 0;
394 unsigned short sensor, ladder, layer;
395 sensor = (dhe_id & 0x1) + 1;
396 ladder = (dhe_id & 0x1E) >> 1; // no +1
397 layer = ((dhe_id & 0x20) >> 5) + 1;
398 currentVxdId = VxdID(layer, ladder, sensor);
399
400 B2DEBUG(27, "pack_dhe: VxdId: " << currentVxdId << " " << (int)currentVxdId);
401
402 {
403 auto it = m_storeDigits.begin();
404 B2DEBUG(27, "Advance: " << startOfVxdID[currentVxdId]);
405 advance(it, startOfVxdID[currentVxdId]);
406 for (; it != m_storeDigits.end(); ++it) {
407 auto id = it->getSensorID();
408 id.setSegmentNumber(0);
409 if (currentVxdId != id) break;
411 {
412 unsigned int row, col;
413 row = it->getVCellID();// hardware starts counting at 0!
414 col = it->getUCellID();// U/V cell ID DO NOT follow Belle2 Note, thus no -1
415 if (row > ladder_max_row || col > ladder_max_col) {
416 B2ERROR("U/V out of range U: " << col << " V: " << row);
417 } else {
418 // fill ADC ... convert float to unsigned char, clamp to 0 - 255 , no scaling ... and how about common mode?
419 B2DEBUG(26, "Pixel: V: " << row << ", U: " << col << ", Ch " << it->getCharge());
420 if (!dhe_has_remapped) {
421 do_the_reverse_mapping(row, col, layer, sensor);
422 }
423 halfladder_pixmap[row][col] = (unsigned char) boost::algorithm::clamp(lrint(it->getCharge()), 0, 255);
424 }
425 }
426 }
427 }
428
429 if (m_Clusterize) {
430 B2FATAL("Clusterizer not supported in Packer");
431 } else {
432 for (int i = 0; i < 4; i++) {
433 if (dhp_active & 0x1) {
434 pack_dhp(i, dhe_id, dhe_has_remapped ? 1 : 0);
437// if (m_trigger_nr == 0x11) {
438// pack_dhp_raw(i, dhe_id, false);
439// pack_dhp_raw(i, dhe_id, true);
440// }
441 }
442 dhp_active >>= 1;
443 }
444 }
445 }
446
448 unsigned int dlen = (dhe_byte_count / 2); // 16 bit words
449 start_frame();
450 append_int32((EDHCFrameHeaderDataType::c_DHE_END << 27) | ((dhe_id & 0x3F) << 20) | (m_trigger_nr & 0xFFFF));
451 append_int16(dlen & 0xFFFF); // 16 bit word count
452 append_int16((dlen >> 16) & 0xFFFF); // 16 bit word count
453 append_int32(0x00000000); // Error Flags
455}
456
457void PXDPackerModule::do_the_reverse_mapping(unsigned int& /*row*/, unsigned int& /*col*/, unsigned short /*layer*/,
458 unsigned short /*sensor*/)
459{
460 B2FATAL("code needs to be written");
461 // work to be done
462 // I suspect this code will never be written.
463 //
464 // PXDMappingLookup::map_uv_to_rc_IF_OB(unsigned int& v_cellID, unsigned int& u_cellID, unsigned int& dhp_id, unsigned int dhe_ID)
465 // PXDMappingLookup::map_uv_to_rc_IB_OF(unsigned int& v_cellID, unsigned int& u_cellID, unsigned int& dhp_id, unsigned int dhe_ID)
466}
467
468void PXDPackerModule::pack_dhp_raw(int chip_id, int dhe_id)
469{
470 B2FATAL("This code needs to be checked agains new firmware");
471 B2DEBUG(27, "PXD Packer --> pack_dhp Raw Chip " << chip_id << " of DHE id: " << dhe_id);
472 start_frame();
474 append_int32((EDHCFrameHeaderDataType::c_DHP_RAW << 27) | ((dhe_id & 0x3F) << 20) | ((chip_id & 0x03) << 16) |
475 (m_trigger_nr & 0xFFFF));
476 append_int32((EDHPFrameHeaderDataType::c_RAW << 29) | ((dhe_id & 0x3F) << 18) | ((chip_id & 0x03) << 16) |
477 (m_trigger_dhp_framenr & 0xFFFF));
478
479 int c1, c2;
480 c1 = 64 * chip_id;
481 c2 = c1 + 64;
482 if (c2 >= PACKER_NUM_COLS) c2 = PACKER_NUM_COLS;
483
484 // ADC data / memdump for pedestal calculation
485 for (int row = 0; row < PACKER_NUM_ROWS; row++) {
486 for (int col = c1; col < c2; col++) {
488 }
489 // unconnected drain lines -> 0
490 for (int col = c2; col < c1 + 64; col++) {
491 append_int8(0);
492 }
493 }
494
496}
497
498void PXDPackerModule::pack_dhp(int chip_id, int dhe_id, int dhe_has_remapped, int startrow)
499{
500 B2DEBUG(27, "PXD Packer --> pack_dhp Chip " << chip_id << " of DHE id: " << dhe_id);
501 // remark: chip_id != port most of the time ...
502 bool empty = true;
503 unsigned short last_rowstart = 0;
504
505 if (dhe_has_remapped == 0) {
506 // problem, we do not have an exact definition of if this bit is set in the new firmware and under which circumstances
507 // and its not clear if we have to translate the coordinates back to "DHP" layout! (look up tabel etc!)
508 B2FATAL("dhe_has_remapped == 0");
509 }
510
511 start_frame();
513 append_int32((EDHCFrameHeaderDataType::c_DHP_ZSD << 27) | ((dhe_id & 0x3F) << 20) | ((dhe_has_remapped & 0x1) << 19) | ((
514 chip_id & 0x03) << 16) | (m_trigger_nr & 0xFFFF));
515 append_int32((EDHPFrameHeaderDataType::c_ZSD << 29) | ((dhe_id & 0x3F) << 18) | ((chip_id & 0x03) << 16) |
516 (m_trigger_dhp_framenr & 0xFFFF));
517
518 int c1, c2;
519 c1 = 64 * chip_id;
520 c2 = c1 + 64;
521 if (c2 >= PACKER_NUM_COLS) c2 = PACKER_NUM_COLS;
522 for (int rr = startrow; rr < startrow + PACKER_NUM_ROWS; rr++) {
523 int row = (rr % PACKER_NUM_ROWS); // warp around
527 bool rowstart = true;
528 for (int col = c1; col < c2; col++) {
529 if (halfladder_pixmap[row][col] != 0) {
530 // Attention, we decided to (mis)use ADC=0 values as truncation marker in future firmware! (discussion 15.1.2021)
531 // ADC cut for sim should have been done already
532 B2DEBUG(26, "Pixel: ROW: " << row << ", COL: " << col << ", Ch " << (int)halfladder_pixmap[row][col]);
533 if (rowstart) {
534 last_rowstart = ((row & 0x3FE) << (6 - 1)) | 0; // plus common mode 6 bits ... set to 0
535 append_int16(last_rowstart);
536 rowstart = false;
537 }
538 int colout = col;
539 append_int16(0x8000 | ((row & 0x1) << 14) | ((colout & 0x3F) << 8) | (halfladder_pixmap[row][col] & 0xFF));
540 empty = false;
541 }
542 }
543 }
544 if (!empty && (m_current_frame.size() & 0x3)) {
545 B2DEBUG(27, "Repeat last rowstart to align to 32bit.");
546 append_int16(last_rowstart);
547 }
548
549 if (empty) {
550 B2DEBUG(27, "Found no data for halfladder! DHEID: " << dhe_id << " Chip: " << chip_id);
554 if (m_firmware < 10) {
555 // behaviour of old firmware is not upward comaptible, but for simulation (=Packing) the new behaviour
556 // would work even for the old unpacking, even so not according to firmware documentation
557 // -> maybe we remove this code?
558 // we DROP the frame, thus we have to correct DHE and DHC counters
559 dhc_byte_count -= 8; // fixed size of Header
560 dhe_byte_count -= 8; // fixed size of Header
561 start_frame();
563 append_int32((EDHCFrameHeaderDataType::c_GHOST << 27) | ((dhe_id & 0x3F) << 20) | ((chip_id & 0x03) << 16) |
564 (m_trigger_nr & 0xFFFF));
565 }
566 }
568
569}
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
Definition: DataStore.h:72
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
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.
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
void setSegmentNumber(baseType segment)
Set the sensor segment.
Definition: VxdID.h:113
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Namespace to encapsulate code needed for simulation and reconstrucion of the PXD.
Abstract base class for different kinds of events.
STL namespace.