Commit 590a810a authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Metronome: allow to add (fake) triggers

parent a2b4061d
......@@ -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
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