LDMX Software
Packing
src
Packing
LDMXRoRHeader.cxx
1
#include "Packing/LDMXRoRHeader.h"
2
3
#include <cassert>
4
5
namespace
packing {
6
7
const
std::unordered_map<std::string, int>
LDMXRoRHeader::SUBSYSTEM_ID
= {
8
{
"tdaq"
, 1}, {
"ts"
, 2}, {
"tracker"
, 4}, {
"ecal"
, 5}, {
"hcal"
, 5}};
9
10
const
std::unordered_map<std::string, int>
LDMXRoRHeader::CONTRIBUTOR_ID
= {
11
{
"tdaq"
, -1}, {
"ts"
, 1}, {
"tracker"
, -1}, {
"ecal"
, 40}, {
"hcal"
, 20}};
12
13
std::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
27
utility::Reader
&
LDMXRoRHeader::read
(
utility::Reader
& r) {
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
packing::LDMXRoRHeader::timestamp_
uint64_t timestamp_
timestamp of this Readout-Request (RoR)
Definition
LDMXRoRHeader.h:90
packing::LDMXRoRHeader::subsystem
uint8_t subsystem() const
ID number for subsystem originating data (compiled into firmware)
Definition
LDMXRoRHeader.h:70
packing::LDMXRoRHeader::contributor_
uint8_t contributor_
ID number for contributor within subsystem (configured into firmware)
Definition
LDMXRoRHeader.h:82
packing::LDMXRoRHeader::SUBSYSTEM_ID
static const std::unordered_map< std::string, int > SUBSYSTEM_ID
The subsystem ID numbers organized by subsystem name.
Definition
LDMXRoRHeader.h:35
packing::LDMXRoRHeader::version_
uint8_t version_
version of LDMX data (should be zero)
Definition
LDMXRoRHeader.h:78
packing::LDMXRoRHeader::read
utility::Reader & read(utility::Reader &r)
read the next LDMX RoR header into memory
Definition
LDMXRoRHeader.cxx:27
packing::LDMXRoRHeader::subsystem_
uint8_t subsystem_
ID number for subsystem originating data (compiled into firmware)
Definition
LDMXRoRHeader.h:80
packing::LDMXRoRHeader::CONTRIBUTOR_ID
static const std::unordered_map< std::string, int > CONTRIBUTOR_ID
The contributor ID is a configurable parameter of the DAQ firmware.
Definition
LDMXRoRHeader.h:49
packing::utility::Reader
Reading a raw data file.
Definition
Reader.h:20
Generated by
1.12.0