Commit 5505198e authored by Morag Jean Williams's avatar Morag Jean Williams
Browse files

Merge branch 'eudaq_tags' into 'master'

Automatically create TProfiles from EUDAQ2 Event tags

See merge request !124
parents fd1e6945 c13b0f2e
Pipeline #1055464 passed with stages
in 22 minutes and 12 seconds
......@@ -17,6 +17,8 @@ EventLoaderEUDAQ2::EventLoaderEUDAQ2(Configuration config, std::shared_ptr<Detec
m_filename = m_config.getPath("file_name", true);
m_get_time_residuals = m_config.get<bool>("get_time_residuals", false);
m_get_tag_vectors = m_config.get<bool>("get_tag_vectors", false);
m_ignore_bore = m_config.get<bool>("ignore_bore", true);
m_skip_time = m_config.get("skip_time", 0.);
m_adjust_event_times = m_config.getMatrix<std::string>("adjust_event_times", {});
m_buffer_depth = m_config.get<int>("buffer_depth", 0);
......@@ -177,12 +179,44 @@ std::shared_ptr<eudaq::StandardEvent> EventLoaderEUDAQ2::get_next_std_event() {
auto event = events_.front();
// If this is a Begin-of-Run event and we should ignore it, please do so:
if(event->IsBORE() && m_ignore_bore) {
LOG(DEBUG) << "Found EUDAQ2 BORE event, ignoring it";
// Read and store tag information:
if(m_get_tag_vectors) {
decoding_failed = !eudaq::StdEventConverter::Convert(event, stdevt, eudaq_config_);
LOG(DEBUG) << event->GetDescription() << ": EventConverter returned " << (decoding_failed ? "false" : "true");
} while(decoding_failed);
return stdevt;
void EventLoaderEUDAQ2::retrieve_event_tags(const eudaq::EventSPC evt) {
auto tags = evt->GetTags();
for(auto tag_pair : tags) {
// Trying to convert tag value to double:
try {
double value = std::stod(tag_pair.second);
// Check if histogram exists already, if not: create it
if(hTagValues.find(tag_pair.first) == hTagValues.end()) {
std::string histName = "hTagValues_" + tag_pair.first;
std::string histTitle = "tag_" + tag_pair.first + ";event / 1000;tag value";
hTagValues[tag_pair.first] = new TProfile(histName.c_str(), histTitle.c_str(), 2e5, 0, 100);
hTagValues[tag_pair.first]->Fill(evt->GetEventN() / 1000, value, 1);
} catch(std::exception& e) {
EventLoaderEUDAQ2::EventPosition EventLoaderEUDAQ2::is_within_event(std::shared_ptr<Clipboard> clipboard,
std::shared_ptr<eudaq::StandardEvent> evt) {
......@@ -14,7 +14,10 @@
#include <TCanvas.h>
#include <TH1F.h>
#include <TH2F.h>
#include <TProfile.h>
#include <iostream>
#include "core/module/Module.hpp"
#include "eudaq/FileReader.hh"
#include "eudaq/StandardEvent.hh"
......@@ -76,6 +79,12 @@ namespace corryvreckan {
EventPosition is_within_event(std::shared_ptr<Clipboard> clipboard, std::shared_ptr<eudaq::StandardEvent> evt);
* @brief Helper function to retrieve event tags and creating plots from them
* @param evt Shared pointer to the current event
void retrieve_event_tags(const eudaq::EventSPC evt);
* @brief Store pixel data from relevant detectors on the clipboard
* @param evt StandardEvent to read the pixel data from
......@@ -85,7 +94,9 @@ namespace corryvreckan {
std::shared_ptr<Detector> m_detector;
std::string m_filename{};
bool m_get_time_residuals;
bool m_get_time_residuals{};
bool m_get_tag_vectors{};
bool m_ignore_bore{};
double m_skip_time{};
Matrix<std::string> m_adjust_event_times;
int m_buffer_depth;
......@@ -134,6 +145,8 @@ namespace corryvreckan {
std::map<size_t, TH1D*> hPixelTriggerTimeResidual;
TH2D* hPixelTriggerTimeResidualOverTime;
TH1D* hTriggersPerEvent;
std::map<std::string, TProfile*> hTagValues;
} // namespace corryvreckan
......@@ -27,6 +27,8 @@ If later, the pointer to this event is kept and it continues with the next detec
If no detector is capable of defining events, the `[Metronome]` model needs to be used.
Tags stores in the EUDAQ2 event header are read, a conversion to a double value is attempted and, if successful, a profile with the value over the number of events in the respective run is automatically allocated and filled. This feature can e.g. be used to log temperatures of the devices during data taking, simply storing the temperature as event tags.
### Requirements
This module requires an installation of [EUDAQ2]( The installation path needs to be set to
......@@ -68,7 +70,9 @@ Also, more complex constructs such as arrays or matrices read by the Corryvrecka
### Parameters
* `file_name`: File name of the EUDAQ2 raw data file. This parameter is mandatory.
* `skip_time`: Time that can be skipped at the start of a run. Default is `0ms`.
* `get_time_residuals`: Boolean to change if time residual plots should be outputted. Default value is `false`.
* `get_time_residuals`: Boolean to change if time residual plots should be created. Default value is `false`.
* `get_tag_vectors`: Boolean to enable creation of EUDAQ2 event tag histograms. Default value is `false`.
* `ignore_bore`: Boolean to completely ignore the Begin-of-Run event from EUDAQ2. Default value is `true`.
* `adjust_event_times`: Matrix that allows the user to shift the event start/end of all different types of EUDAQ events. The first entry of each row specifies the data type, the second is the offset which is added to the event start and the third entry is the offset added to the event end. A usage example is shown below. Default is `0ms, 0ms`, `"other"` is just a placeholder.
* `buffer_depth`: Depth of buffer in which EUDAQ2 `StandardEvents` are timesorted. This algorithm only works for `StandardEvents` with well-defined timestamps. Setting it to `0` disables timesorting. Default is `0`.
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