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
valid_
=
false
;
29
uint8_t sentinel;
30
uint32_t zero;
31
if
(!(r >>
version_
>>
subsystem_
>>
contributor_
>> sentinel)) {
32
return
r;
33
}
34
35
// sentinel should be 0xa5; if not, this is not a valid LDMX data frame
36
if
(sentinel != 0xa5)
return
r;
37
38
if
(!(r >> zero))
return
r;
39
40
// next 32b should be zero since they are unused
41
if
(zero != 0)
return
r;
42
43
if
(!(r >>
timestamp_
))
return
r;
44
45
valid_
=
true
;
46
return
r;
47
}
48
49
}
// namespace packing
packing::LDMXRoRHeader::timestamp_
uint64_t timestamp_
timestamp of this Readout-Request (RoR)
Definition
LDMXRoRHeader.h:95
packing::LDMXRoRHeader::subsystem
uint8_t subsystem() const
ID number for subsystem originating data (compiled into firmware)
Definition
LDMXRoRHeader.h:73
packing::LDMXRoRHeader::valid_
bool valid_
set to true only when all validity checks pass during read()
Definition
LDMXRoRHeader.h:81
packing::LDMXRoRHeader::contributor_
uint8_t contributor_
ID number for contributor within subsystem (configured into firmware)
Definition
LDMXRoRHeader.h:87
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:83
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:85
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