Commit f6d69b65 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Add new module: Metronome

parent 852a8340
# Define module and return the generated name as MODULE_NAME
CORRYVRECKAN_MODULE(MODULE_NAME)
# Add source files to library
CORRYVRECKAN_MODULE_SOURCES(${MODULE_NAME}
Metronome.cpp
# ADD SOURCE FILES HERE...
)
# Provide standard install target
CORRYVRECKAN_MODULE_INSTALL(${MODULE_NAME})
#include "Metronome.h"
using namespace corryvreckan;
using namespace std;
Metronome::Metronome(Configuration config, std::vector<Detector*> detectors)
: Module(std::move(config), std::move(detectors)) {
m_eventLength = m_config.get<double>("eventLength", Units::convert(10, "us"));
}
void Metronome::initialise() {
// Set initial values for the start and stop time of the first event:
m_eventStart = 0.0;
m_eventEnd = m_eventLength;
}
StatusCode Metronome::run(Clipboard* clipboard) {
// 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
return Success;
}
#ifndef Metronome_H
#define Metronome_H 1
#include <iostream>
#include "TCanvas.h"
#include "TH1F.h"
#include "TH2F.h"
#include "core/module/Module.hpp"
#include "objects/Cluster.h"
#include "objects/Pixel.h"
#include "objects/Track.h"
namespace corryvreckan {
/** @ingroup Modules
*/
class Metronome : public Module {
public:
// Constructors and destructors
Metronome(Configuration config, std::vector<Detector*> detectors);
~Metronome() {}
// Functions
void initialise();
StatusCode run(Clipboard* clipboard);
private:
double m_eventStart, m_eventEnd, m_eventLength;
};
} // namespace corryvreckan
#endif // Metronome_H
## Metronome
**Maintainer**: Simon Spannagel (<simon.spannagel@cern.ch>)
**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.
Subsequent modules should read these values and adhere to them.
#### Parameters
* `eventLength`: Length of the event to be defined in physical units (not clock cycles of a specific device). Default value is `10us`.
#### Usage
```toml
[Metronome]
eventLength = 500ns
```
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