LDMX Software
LDMXRoRHeader.cxx
1#include "Packing/LDMXRoRHeader.h"
2
3#include <cassert>
4
5namespace packing {
6
7const std::unordered_map<std::string, int> LDMXRoRHeader::SUBSYSTEM_ID = {
8 {"tdaq", 1}, {"ts", 2}, {"tracker", 4}, {"ecal", 5}, {"hcal", 5}};
9
10const std::unordered_map<std::string, int> LDMXRoRHeader::CONTRIBUTOR_ID = {
11 {"tdaq", -1}, {"ts", 1}, {"tracker", -1}, {"ecal", 40}, {"hcal", 20}};
12
13std::tuple<int, int> LDMXRoRHeader::subsystem(const std::string& name) {
14 auto subsys_it{SUBSYSTEM_ID.find(name)};
15 if (subsys_it == SUBSYSTEM_ID.end()) {
16 return std::make_tuple(-1, -1);
17 }
18
19 int subsys{subsys_it->second}, contrib{-1};
20 auto contrib_it{CONTRIBUTOR_ID.find(name)};
21 if (contrib_it != CONTRIBUTOR_ID.end()) {
22 contrib = contrib_it->second;
23 }
24 return std::make_tuple(subsys, contrib);
25}
26
28 uint8_t sentinel;
29 uint32_t zero;
30 if (!(r >> version_ >> subsystem_ >> contributor_ >> sentinel)) {
31 return r;
32 }
33
34 // sentinel should be 0xa5
35 assert(sentinel == 0xa5);
36
37 if (!(r >> zero)) {
38 return r;
39 }
40
41 // next 32b should be zero since they are unused
42 assert(zero == 0);
43
44 return (r >> timestamp_);
45}
46
47} // namespace packing
uint64_t timestamp_
timestamp of this Readout-Request (RoR)
uint8_t subsystem() const
ID number for subsystem originating data (compiled into firmware)
uint8_t contributor_
ID number for contributor within subsystem (configured into firmware)
static const std::unordered_map< std::string, int > SUBSYSTEM_ID
The subsystem ID numbers organized by subsystem name.
uint8_t version_
version of LDMX data (should be zero)
utility::Reader & read(utility::Reader &r)
read the next LDMX RoR header into memory
uint8_t subsystem_
ID number for subsystem originating data (compiled into firmware)
static const std::unordered_map< std::string, int > CONTRIBUTOR_ID
The contributor ID is a configurable parameter of the DAQ firmware.
Reading a raw data file.
Definition Reader.h:20