Commit 283449ca authored by Jens Kroeger's avatar Jens Kroeger
Browse files

Merge branch 'metronome_triggers' into 'master'

Metronome Module: generate fake triggers

See merge request !173
parents b1a01049 62c19285
Pipeline #1111096 passed with stages
in 31 minutes and 30 seconds
......@@ -5,9 +5,10 @@ using namespace corryvreckan;
using namespace std;
Metronome::Metronome(Configuration config, std::vector<std::shared_ptr<Detector>> detectors)
: Module(std::move(config), std::move(detectors)) {
: Module(std::move(config), std::move(detectors)), m_triggers(0) {
m_eventLength = m_config.get<double>("event_length", Units::get<double>(10, "us"));
m_triggersPerEvent = m_config.get<uint32_t>("triggers", 0);
}
void Metronome::initialise() {
......@@ -20,9 +21,21 @@ void Metronome::initialise() {
StatusCode Metronome::run(std::shared_ptr<Clipboard> clipboard) {
// Set up the current event:
auto event = std::make_shared<Event>(m_eventStart, m_eventEnd);
LOG(DEBUG) << "Defining event, time frame " << Units::display(m_eventStart, {"us", "ms", "s"}) << " to "
<< Units::display(m_eventEnd, {"us", "ms", "s"});
clipboard->putEvent(std::make_shared<Event>(m_eventStart, m_eventEnd));
if(m_triggersPerEvent > 1) {
LOG(DEBUG) << "Adding " << m_triggersPerEvent << " triggers to event, IDs " << m_triggers << "-"
<< (m_triggers + m_triggersPerEvent - 1);
} else if(m_triggersPerEvent > 0) {
LOG(DEBUG) << "Adding " << m_triggersPerEvent << " trigger to event, ID " << m_triggers;
}
for(uint32_t i = 0; i < m_triggersPerEvent; i++) {
event->addTrigger(m_triggers++, (m_eventStart + m_eventEnd) / 2);
}
clipboard->putEvent(event);
// Increment the current event's start and end times by the configured event length
m_eventStart = m_eventEnd;
......
......@@ -26,6 +26,7 @@ namespace corryvreckan {
private:
double m_eventStart, m_eventEnd, m_eventLength;
uint32_t m_triggersPerEvent, m_triggers;
};
} // namespace corryvreckan
#endif // Metronome_H
# Metronome
**Maintainer**: Simon Spannagel (<simon.spannagel@cern.ch>)
**Module Type**: *GLOBAL*
**Status**: Functional
**Status**: Functional
### Description
The `Metronome` module is can be used to slice data without strict event structure in arbitrarily long time slots, which serve as events for subsequent modules. This is done by configuring an event length and by setting the variables `eventStart` and `eventStop` on the clipboard.
The `Metronome` module can be used to slice data without strict event structure in arbitrarily long time frames, which serve as event definition for subsequent modules.
A new Event object is created and stored on the clipboard, with the begin and end of the frame calculated from the `event_length` parameter.
Subsequent modules should read these values and adhere to them.
The module also provides the option to add trigger IDs to the generated event by specifying the number of triggers to be set per event via the `trigger`.
Trigger IDs are consecutive numbers, starting at zero.
With a setting of `triggers = 2`, the first event would receive trigger IDs 0 and 1, the subsequent event 2 and 3 and so forth.
### Parameters
* `event_length`: Length of the event to be defined in physical units (not clock cycles of a specific device). Default value is `10us`.
* `skip_time`: Time to skip at the begin of the run before processing the first event. Defaults to `0us`.
* `triggers`: Number of triggers to generate and add to each event. All trigger timestamps are set to the center of the configured metronome time frame. Defaults to zero, i.e. no triggers are added.
### Usage
```toml
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment