epic-drich-beam-test-analysis
ePIC dRICH beam test analysis framework
Loading...
Searching...
No Matches
triggers.h File Reference

Header-only trigger definitions, registry, and TOML-based configuration reader. More...

#include <string>
#include <vector>
#include <cstdint>
#include <iostream>
#include <toml++/toml.h>
#include "TH2.h"

Go to the source code of this file.

Classes

struct  trigger_event
 Per-event trigger data attached to a decoded data frame. More...
 
struct  trigger_config
 Static configuration for a single trigger channel, loaded from TOML. More...
 
struct  trigger_registry
 Runtime lookup table that maps trigger values to names and positions. More...
 

Enumerations

enum  trigger_number : uint8_t {
  _TRIGGER_FIRST_FRAMES_ = 100 , _TRIGGER_TIMING_ = 101 , _TRIGGER_TRACKING_ = 102 , _TRIGGER_RING_FOUND_ = 103 ,
  _TRIGGER_STREAMING_RING_FOUND_ = 104 , _TRIGGER_HOUGH_RING_FOUND_ = 105 , _TRIGGER_START_OF_SPILL_ = 200 , _TRIGGER_UNKNOWN_ = 255
}
 Enumeration of known hardware trigger types. More...
 

Functions

constexpr int default_trigger_index (trigger_number t)
 Returns the index of a trigger in the default table at compile time.
 
std::vector< trigger_configtrigger_conf_reader (const std::string &config_file="Data/triggers.toml")
 Reads trigger configuration from a TOML file.
 

Detailed Description

Header-only trigger definitions, registry, and TOML-based configuration reader.

Provides:

TOML config format

[[trigger]]
name = "luca_and_finger"
index = 0
device = 196
delay = 117
[[trigger]]
name = "broad_scintillator"
index = 1
device = 197
delay = 117

Dependencies

Enumeration Type Documentation

◆ trigger_number

enum trigger_number : uint8_t

Enumeration of known hardware trigger types.

Values in the 100–199 range are physics/DAQ triggers; 200+ are spill-level signals; 255 is the catch-all unknown.

Config-defined triggers must use indices in [0, 99] — this range is intentionally left out of the enum and managed at runtime.

Enumerator
_TRIGGER_FIRST_FRAMES_ 

First frames of a run.

_TRIGGER_TIMING_ 

Timing trigger.

_TRIGGER_TRACKING_ 

Tracking trigger.

_TRIGGER_RING_FOUND_ 

Ring-finding trigger.

_TRIGGER_STREAMING_RING_FOUND_ 

Streaming ring-finding trigger.

_TRIGGER_HOUGH_RING_FOUND_ 

Hough-transform ring-finding trigger.

_TRIGGER_START_OF_SPILL_ 

Start-of-spill signal.

_TRIGGER_UNKNOWN_ 

Unknown / unmapped trigger.

Function Documentation

◆ default_trigger_index()

constexpr int default_trigger_index ( trigger_number  t)
constexpr

Returns the index of a trigger in the default table at compile time.

Parameters
tTrigger enum value to look up.
Returns
Index in all_default_triggers, or -1 if not found.

◆ trigger_conf_reader()

std::vector< trigger_config > trigger_conf_reader ( const std::string &  config_file = "Data/triggers.toml")
inline

Reads trigger configuration from a TOML file.

Parses an array of [[trigger]] tables. Each table must contain:

Key Type Description
name string Human-readable trigger label
index integer Trigger index in data stream
device integer Source hardware device ID
delay integer Trigger delay (DAQ units)

Entries missing any required key are skipped with a warning. If the file cannot be opened or parsed, an empty vector is returned.

Index range and uniqueness rules

Config-defined triggers must use indices in [0, 99] — the range [100, 255] is reserved for the built-in trigger_number defaults.

  • An entry with an out-of-range index is reassigned to the earliest unused slot in [0, 99] and a warning is emitted.
  • A duplicate in-range index (two entries claiming the same slot) causes the second entry to be reassigned the same way.
  • If no free slot remains in [0, 99], the offending entry is dropped with an error.
Parameters
config_filePath to the TOML configuration file.
Returns
List of successfully parsed trigger configurations, with out-of-range and duplicate indices corrected.