Library usage

Output data structure

The output data structure of this program is a C++ struct:

struct StructData

Public Members

ReceiveDataHeader header = {}

Header data.

std::vector<MarkerData> marker_data

Marker data.

std::vector<HitData> hit_data

Hit data.

with its sub structure:

struct HitData

Public Members

bool is_over_threshold = false

whether the hit data is over the threshould

uint8_t channel_num = {}

Channel number.

uint8_t tdc = {}

TDC value.

uint8_t offset = {}

Offset value.

uint8_t vmm_id = {}

VMM ID.

uint16_t adc = {}

ADC value.

uint16_t bc_id = {}

BC ID.

struct MarkerData

Public Members

uint8_t vmm_id = {}

VMM ID for the marker data.

uint64_t srs_timestamp = {}

Timestamp value.

struct ReceiveDataHeader

Public Members

uint32_t frame_counter = {}

The counting value for current UDP data frame.

std::array<char, VMM_TAG_BIT_LENGTH> vmm_tag = {}

Hard-coded text “VMM3”.

uint8_t fec_id = {}

FEC ID.

uint32_t udp_timestamp = {}

UDP timestamp.

uint32_t overflow = {}

Overflow value.

An example of ROOT macro to extract data structure from the tree

To extract the data structure value, it’s highly recommended to use ROOT TTreeReader instead of direct ROOT TTree. The tree name from the srs_control save a tree named “srs_data_tree” with a single branch named “srs_frame_data”.

Attention

To let ROOT use the dictionary of srs::StructData, the libaray path srs-download/lib has to be added to LD_LIBRARY_PATH before running the Macro file: export LD_LIBRARY_PATH="[.../srs-download]/lib:$LD_LIBRARY_PATH"

The following example extracts the whole data structure srs::StructData and print out every offset value:

int check_srs()
{
    auto file = std::make_unique<TFile>("output.root", "read");
    auto tree_reader = TTreeReader{ "srs_data_tree", file.get() };

    auto srs_struct_data = TTreeReaderValue<srs::StructData>{ tree_reader, "srs_frame_data" };

    while (tree_reader.Next())
    {
        const auto& hit_data = srs_struct_data->hit_data;
        for (const auto& hit : hit_data)
        {
            std::cout << "offset: " << static_cast<int>(hit.offset) << "\n";
        }
    }
    return 0;
}

Available APIs