LDMX Software
packing::LDMXRoRHeader Class Reference

the header that the LDMX DAQ Firmware block includes in the output data stream at the beginning of each data frame More...

#include <LDMXRoRHeader.h>

Public Member Functions

utility::Readerread (utility::Reader &r)
 read the next LDMX RoR header into memory
 
bool valid () const
 true if the header was parsed successfully (sentinel and reserved word matched)
 
uint8_t version () const
 version of LDMX data (should be zero)
 
uint8_t subsystem () const
 ID number for subsystem originating data (compiled into firmware)
 
uint8_t contributor () const
 ID number for contributor within subsystem (configured into firmware)
 
uint64_t timestamp () const
 get timestamp of this RoR
 

Static Public Member Functions

static std::tuple< int, int > subsystem (const std::string &name)
 Get the (subsystem, contributor) pair for the input subsystem name.
 
static std::string getSubsystemName (uint8_t subsystem_id, uint8_t contributor_id)
 Get the subsystem name from subsystem and contributor IDs.
 

Static Public Attributes

static const unsigned int SIZE = 16
 size of this header in bytes
 
static const std::unordered_map< std::string, int > SUBSYSTEM_ID
 The subsystem ID numbers organized by subsystem name.
 
static const std::unordered_map< std::string, int > CONTRIBUTOR_ID
 The contributor ID is a configurable parameter of the DAQ firmware.
 

Private Attributes

bool valid_ {false}
 set to true only when all validity checks pass during read()
 
uint8_t version_
 version of LDMX data (should be zero)
 
uint8_t subsystem_
 ID number for subsystem originating data (compiled into firmware)
 
uint8_t contributor_
 ID number for contributor within subsystem (configured into firmware)
 
uint64_t timestamp_
 timestamp of this Readout-Request (RoR)
 

Detailed Description

the header that the LDMX DAQ Firmware block includes in the output data stream at the beginning of each data frame

This header is immediately preceeded by a RogueFrameHeader for data frames. It is separate only becuase some frames written to the file (mainly, the configuration stream) do not include this header as well as the RogueFrameHeader.

Definition at line 22 of file LDMXRoRHeader.h.

Member Function Documentation

◆ contributor()

uint8_t packing::LDMXRoRHeader::contributor ( ) const
inline

ID number for contributor within subsystem (configured into firmware)

Definition at line 91 of file LDMXRoRHeader.h.

91{ return contributor_; }
uint8_t contributor_
ID number for contributor within subsystem (configured into firmware)

References contributor_.

Referenced by eventbuilder::EventBuilder::produce().

◆ getSubsystemName()

std::string packing::LDMXRoRHeader::getSubsystemName ( uint8_t subsystem_id,
uint8_t contributor_id )
static

Get the subsystem name from subsystem and contributor IDs.

Uses both the subsystem ID (compiled into firmware) and contributor ID (configured into firmware) to uniquely identify the subsystem. This is necessary because some subsystems share the same subsystem ID but have different contributor IDs (e.g., ecal and hcal both use subsystem ID 5 but have different contributor IDs).

Parameters
[in]subsystem_idthe subsystem ID from the RoR header
[in]contributor_idthe contributor ID from the RoR header
Returns
subsystem name string (lowercase: 'tdaq', 'ts', 'tracker', 'ecal', 'hcal') or a generic name if the combination is not recognized

Definition at line 27 of file LDMXRoRHeader.cxx.

28 {
29 // Check each subsystem's IDs to find a match
30 for (const auto& name_id_pair : SUBSYSTEM_ID) {
31 const auto& name = name_id_pair.first;
32 int subsys_id = name_id_pair.second;
33
34 if (subsys_id != subsystem_id) {
35 continue; // Not a match on subsystem ID
36 }
37
38 // Check if contributor ID matches (if it's set)
39 auto contrib_it = CONTRIBUTOR_ID.find(name);
40 if (contrib_it != CONTRIBUTOR_ID.end()) {
41 int expected_contrib = contrib_it->second;
42 if (expected_contrib != -1 && expected_contrib != contributor_id) {
43 continue; // Contributor ID doesn't match, try next
44 }
45 }
46
47 // Found a match
48 return name;
49 }
50
51 // No match found, return generic name
52 return "subsystem" + std::to_string(subsystem_id) + "c" +
53 std::to_string(contributor_id);
54}
static const std::unordered_map< std::string, int > SUBSYSTEM_ID
The subsystem ID numbers organized by subsystem name.
static const std::unordered_map< std::string, int > CONTRIBUTOR_ID
The contributor ID is a configurable parameter of the DAQ firmware.

References CONTRIBUTOR_ID, and SUBSYSTEM_ID.

Referenced by eventbuilder::EventBuilder::produce().

◆ read()

utility::Reader & packing::LDMXRoRHeader::read ( utility::Reader & r)

read the next LDMX RoR header into memory

Definition at line 56 of file LDMXRoRHeader.cxx.

56 {
57 valid_ = false;
58
59 uint8_t sentinel;
60 uint32_t zero;
61
62 if (!(r >> version_ >> subsystem_ >> contributor_ >> sentinel)) {
63 return r;
64 }
65
66 // sentinel should be 0xa5; if not, this is not a valid LDMX data frame
67 if (sentinel != 0xa5) return r;
68
69 if (!(r >> zero)) return r;
70
71 // next 32b should be zero since they are unused
72 if (zero != 0) return r;
73
74 if (!(r >> timestamp_)) return r;
75
76 valid_ = true;
77 return r;
78}
uint64_t timestamp_
timestamp of this Readout-Request (RoR)
bool valid_
set to true only when all validity checks pass during read()
uint8_t version_
version of LDMX data (should be zero)
uint8_t subsystem_
ID number for subsystem originating data (compiled into firmware)

References contributor_, subsystem_, timestamp_, valid_, and version_.

Referenced by eventbuilder::EventBuilder::produce().

◆ subsystem() [1/2]

uint8_t packing::LDMXRoRHeader::subsystem ( ) const
inline

ID number for subsystem originating data (compiled into firmware)

Definition at line 89 of file LDMXRoRHeader.h.

89{ return subsystem_; }

References subsystem_.

Referenced by packing::SingleSubsystemUnpacker::configure().

◆ subsystem() [2/2]

std::tuple< int, int > packing::LDMXRoRHeader::subsystem ( const std::string & name)
static

Get the (subsystem, contributor) pair for the input subsystem name.

Note
For the 2025 slice test at SLAC, there was only ever one contributor per subsystem (-1 means that it was not set and can be ignored). In the future, there will be more than one contributor for some subsystems and so this function will need to be rewritten.
Parameters
[in]namesubsystem name ('tdaq','ts','tracker','hcal','ecal')
Returns
2-tuple of subsystem, contributor ID numbers. Returns the pair (-1, -1) if the name is not found in our maps above.

Definition at line 13 of file LDMXRoRHeader.cxx.

13 {
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}

References CONTRIBUTOR_ID, and SUBSYSTEM_ID.

Referenced by eventbuilder::EventBuilder::produce().

◆ timestamp()

uint64_t packing::LDMXRoRHeader::timestamp ( ) const
inline

get timestamp of this RoR

Definition at line 93 of file LDMXRoRHeader.h.

93{ return timestamp_; }

References timestamp_.

Referenced by eventbuilder::EventBuilder::produce(), and packing::SingleSubsystemUnpacker::produce().

◆ valid()

bool packing::LDMXRoRHeader::valid ( ) const
inline

true if the header was parsed successfully (sentinel and reserved word matched)

Definition at line 85 of file LDMXRoRHeader.h.

85{ return valid_; }

References valid_.

◆ version()

uint8_t packing::LDMXRoRHeader::version ( ) const
inline

version of LDMX data (should be zero)

Definition at line 87 of file LDMXRoRHeader.h.

87{ return version_; }

References version_.

Member Data Documentation

◆ contributor_

uint8_t packing::LDMXRoRHeader::contributor_
private

ID number for contributor within subsystem (configured into firmware)

Definition at line 103 of file LDMXRoRHeader.h.

Referenced by contributor(), and read().

◆ CONTRIBUTOR_ID

const std::unordered_map< std::string, int > packing::LDMXRoRHeader::CONTRIBUTOR_ID
static
Initial value:
= {
{"tdaq", -1}, {"ts", 1}, {"tracker", -1}, {"ecal", 40}, {"hcal", 20}}

The contributor ID is a configurable parameter of the DAQ firmware.

For the 2025 slice test at SLAC, there was only ever one contributor per subsystem and so there is just one integer per subsystem here. (-1 means that it was not set and can be ignored).

In the future, there will be more than one contributor for some subsystems.

The subsystem names are all lower case.

Definition at line 49 of file LDMXRoRHeader.h.

Referenced by getSubsystemName(), and subsystem().

◆ SIZE

const unsigned int packing::LDMXRoRHeader::SIZE = 16
static

size of this header in bytes

Definition at line 25 of file LDMXRoRHeader.h.

Referenced by packing::SingleSubsystemUnpacker::produce().

◆ subsystem_

uint8_t packing::LDMXRoRHeader::subsystem_
private

ID number for subsystem originating data (compiled into firmware)

Definition at line 101 of file LDMXRoRHeader.h.

Referenced by read(), and subsystem().

◆ SUBSYSTEM_ID

const std::unordered_map< std::string, int > packing::LDMXRoRHeader::SUBSYSTEM_ID
static
Initial value:
= {
{"tdaq", 1}, {"ts", 2}, {"tracker", 4}, {"ecal", 5}, {"hcal", 5}}

The subsystem ID numbers organized by subsystem name.

These ID numbers are compiled into the DAQ firmware. Since the same firmware was used for both the ECal and HCal, they both ended up having the same subsystem ID (5).

The subsystem names are all lower case.

Definition at line 35 of file LDMXRoRHeader.h.

Referenced by getSubsystemName(), and subsystem().

◆ timestamp_

uint64_t packing::LDMXRoRHeader::timestamp_
private

timestamp of this Readout-Request (RoR)

It is some combination of pulseID and bunchCount, but I'm unsure on how to decompose those at this time.

Definition at line 111 of file LDMXRoRHeader.h.

Referenced by read(), and timestamp().

◆ valid_

bool packing::LDMXRoRHeader::valid_ {false}
private

set to true only when all validity checks pass during read()

Definition at line 97 of file LDMXRoRHeader.h.

97{false};

Referenced by read(), and valid().

◆ version_

uint8_t packing::LDMXRoRHeader::version_
private

version of LDMX data (should be zero)

Definition at line 99 of file LDMXRoRHeader.h.

Referenced by read(), and version().


The documentation for this class was generated from the following files: