Metronome.cpp 1.07 KB
Newer Older
Simon Spannagel's avatar
Simon Spannagel committed
1
#include "Metronome.h"
2
#include "objects/Event.hpp"
Simon Spannagel's avatar
Simon Spannagel committed
3
4
5
6

using namespace corryvreckan;
using namespace std;

7
Metronome::Metronome(Configuration config, std::vector<std::shared_ptr<Detector>> detectors)
Simon Spannagel's avatar
Simon Spannagel committed
8
9
    : Module(std::move(config), std::move(detectors)) {

10
    m_eventLength = m_config.get<double>("event_length", Units::get(10.0, "us"));
Simon Spannagel's avatar
Simon Spannagel committed
11
12
13
14
15
16
17
18
19
}

void Metronome::initialise() {

    // Set initial values for the start and stop time of the first event:
    m_eventStart = 0.0;
    m_eventEnd = m_eventLength;
}

20
StatusCode Metronome::run(std::shared_ptr<Clipboard> clipboard) {
Simon Spannagel's avatar
Simon Spannagel committed
21

Simon Spannagel's avatar
Simon Spannagel committed
22
23
24
    // Set up the current event:
    LOG(DEBUG) << "Defining event, time frame " << Units::display(m_eventStart, {"us", "ms", "s"}) << " to "
               << Units::display(m_eventEnd, {"us", "ms", "s"});
25
26
    clipboard->put_event(std::make_shared<Event>(m_eventStart, m_eventEnd));

Simon Spannagel's avatar
Simon Spannagel committed
27
28
29
30
31
    // Increment the current event's start and end times by the configured event length
    m_eventStart = m_eventEnd;
    m_eventEnd += m_eventLength;

    // Return value telling analysis to keep running
32
    return StatusCode::Success;
Simon Spannagel's avatar
Simon Spannagel committed
33
}