Commit e7f1b3ea authored by Jens Kroeger's avatar Jens Kroeger
Browse files

Merge branch 'shift_all_times' into 'master'

EventLoaderEUDAQ2: correctly place adjustment of event times (now actually...

Closes #73

See merge request !167
parents 9d4d7dbc 4b6f5b5c
Pipeline #1092492 passed with stages
in 14 minutes and 33 seconds
......@@ -246,6 +246,8 @@ Event::Position EventLoaderEUDAQ2::is_within_event(std::shared_ptr<Clipboard> cl
// Read time from EUDAQ2 event and convert from picoseconds to nanoseconds:
double event_start = static_cast<double>(evt->GetTimeBegin()) / 1000 + m_detector->timingOffset();
double event_end = static_cast<double>(evt->GetTimeEnd()) / 1000 + m_detector->timingOffset();
// Store the original position of the event before adjusting its length:
double event_timestamp = event_start;
LOG(DEBUG) << "event_start = " << Units::display(event_start, "us")
<< ", event_end = " << Units::display(event_end, "us");
......@@ -254,6 +256,17 @@ Event::Position EventLoaderEUDAQ2::is_within_event(std::shared_ptr<Clipboard> cl
m_adjust_event_times.end(),
[evt](const std::vector<std::string>& x) { return x.front() == evt->GetDescription(); });
if(it != m_adjust_event_times.end()) {
event_start += corryvreckan::from_string<double>(it->at(1));
event_end += corryvreckan::from_string<double>(it->at(2));
LOG(DEBUG) << "Adjusting " << it->at(0) << " event_start by "
<< Units::display(corryvreckan::from_string<double>(it->at(1)), {"us", "ns"}) << ", event_end by "
<< Units::display(corryvreckan::from_string<double>(it->at(2)), {"us", "ns"});
LOG(DEBUG) << "Adjusted event: " << Units::display(event_start, {"us", "ns"}) << " - "
<< Units::display(event_end, {"us", "ns"}) << ", length "
<< Units::display(event_end - event_start, {"us", "ns"});
}
// Skip if later start is requested:
if(event_start < m_skip_time) {
LOG(DEBUG) << "Event start before requested skip time: " << Units::display(event_start, {"us", "ns"}) << " < "
......@@ -261,24 +274,11 @@ Event::Position EventLoaderEUDAQ2::is_within_event(std::shared_ptr<Clipboard> cl
return Event::Position::BEFORE;
}
double shift_start = 0;
double shift_end = 0;
// Check if an event is defined or if we need to create it:
if(!clipboard->isEventDefined()) {
LOG(DEBUG) << "Defining Corryvreckan event: " << Units::display(event_start, {"us", "ns"}) << " - "
<< Units::display(event_end, {"us", "ns"}) << ", length "
<< Units::display(event_end - event_start, {"us", "ns"});
if(it != m_adjust_event_times.end()) {
shift_start = corryvreckan::from_string<double>(it->at(1));
shift_end = corryvreckan::from_string<double>(it->at(2));
event_start += shift_start;
event_end += shift_end;
LOG(DEBUG) << "Adjusting " << it->at(0) << ": event_start by " << Units::display(shift_start, {"us", "ns"})
<< ", event_end by " << Units::display(shift_end, {"us", "ns"});
}
LOG(DEBUG) << "Shifted Corryvreckan event: " << Units::display(event_start, {"us", "ns"}) << " - "
<< Units::display(event_end, {"us", "ns"}) << ", length "
<< Units::display(event_end - event_start, {"us", "ns"});
clipboard->putEvent(std::make_shared<Event>(event_start, event_end));
} else {
LOG(DEBUG) << "Corryvreckan event found on clipboard.";
......@@ -296,9 +296,9 @@ Event::Position EventLoaderEUDAQ2::is_within_event(std::shared_ptr<Clipboard> cl
// check if event has valid trigger ID (flag = 0x10):
if(evt->IsFlagTrigger()) {
// Store potential trigger numbers, assign to center of event:
clipboard->getEvent()->addTrigger(evt->GetTriggerN(), event_start - shift_start);
clipboard->getEvent()->addTrigger(evt->GetTriggerN(), event_timestamp);
LOG(DEBUG) << "Stored trigger ID " << evt->GetTriggerN() << " at "
<< Units::display(event_start - shift_start, {"us", "ns"});
<< Units::display(event_timestamp, {"us", "ns"});
}
}
......
......@@ -74,7 +74,7 @@ Also, more complex constructs such as arrays or matrices read by the Corryvrecka
* `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.
* `adjust_event_times`: Matrix that allows the user to shift the event start/end of all different types of EUDAQ events before comparison to any other Corryvreckan data. 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.
* `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`.
### Plots produced
......@@ -105,6 +105,6 @@ file_name = /path/to/data/examplerun_clicpix2.raw
[EventLoaderEUDAQ2]
type = "MIMOSA26"
file_name = /path/to/data/examplerun_telescope.raw
adjust_event_times = ["TluRawDataEvent", -115us, +230us], ["other", 0ns, 0ns]
adjust_event_times = ["TluRawDataEvent", -115us, +230us]
buffer_depth = 1000
```
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