Metronome.cpp 1.03 KB
Newer Older
Simon Spannagel's avatar
Simon Spannagel committed
1
2
3
4
5
#include "Metronome.h"

using namespace corryvreckan;
using namespace std;

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

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

void Metronome::initialise() {

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

19
StatusCode Metronome::run(std::shared_ptr<Clipboard> clipboard) {
Simon Spannagel's avatar
Simon Spannagel committed
20
21
22
23
24
25
26
27
28
29
30

    // Set up the clipboard persistent storage for the current event:
    clipboard->put_persistent("eventStart", m_eventStart);
    clipboard->put_persistent("eventEnd", m_eventEnd);
    clipboard->put_persistent("eventLength", m_eventLength);

    // 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
31
    return StatusCode::Success;
Simon Spannagel's avatar
Simon Spannagel committed
32
}