Commit 0dd6689f authored by Lennart Huth's avatar Lennart Huth
Browse files

merged master

parents 75e77fb9 f0d183e1
......@@ -19,13 +19,14 @@ EventDefinitionM26::EventDefinitionM26(Configuration& config, std::vector<std::s
config_.setDefault<int>("time_shift", 0);
config_.setDefault<int>("shift_triggers", 0);
config_.setDefault<std::string>("eudaq_loglevel", "ERROR");
config_.setDefault<double>("skip_time", 0.);
config_.setDefault<double>("add_begin", 0.);
config_.setDefault<double>("add_end", 0.);
config_.setDefault<int>("plane_pivot", 0.);
config_.setDefault<int>("pivot_min", 0.);
config_.setDefault<int>("pivot_max", 576.);
config_.setDefault<bool>("add_trigger", false);
config_.setDefault<std::string>("eudaq_loglevel", "ERROR");
detector_time_ = config_.get<std::string>("detector_event_time");
// Convert to lower case before string comparison to avoid errors by the user:
......@@ -42,9 +43,9 @@ EventDefinitionM26::EventDefinitionM26(Configuration& config, std::vector<std::s
pivot_min_ = config_.get<int>("pivot_min");
pivot_max_ = config_.get<int>("pivot_max");
config_.setDefault<std::string>("eudaq_loglevel", "ERROR");
LOG(WARNING) << " seting shift to " << Units::get(timeshift_, "us") << ": accepting pivots from " << pivot_min_
<< " to " << pivot_max_;
add_trigger_ = config_.get<bool>("add_trigger");
// Set EUDAQ log level to desired value:
EUDAQ_LOG_LEVEL(config_.get<std::string>("eudaq_loglevel"));
LOG(INFO) << "Setting EUDAQ2 log level to \"" << config_.get<std::string>("eudaq_loglevel") << "\"";
......@@ -241,13 +242,23 @@ StatusCode EventDefinitionM26::run(const std::shared_ptr<Clipboard>& clipboard)
if(time_trig - time_prev_ > 0) {
// M26 frames need to have a distance of at least one frame length!
if(time_trig - time_prev_ < 115200) {
if(time_trig - time_prev_ < 115200 && (!add_trigger_)) {
LOG(ERROR) << "M26 triggers too close together to fit M26 frame, dt = " +
Units::display(time_trig - time_prev_, "us")
<< std::endl
<< "Check if a shift of trigger IDs is required.";
}
// If we stretch the event over three frames and add a trigger, we need a larger distance
if((time_trig - time_prev_ < 345600) && add_trigger_) {
triggerTLU_--;
LOG(DEBUG)
<< "Skipping event that would overlap previous event, since bool add_triggers_ is set to true";
continue;
}
if(add_trigger_) {
time_before_ = Units::get(115.2, "us");
time_after_ = Units::get(230.4, "us");
}
timebetweenMimosaEvents_->Fill(static_cast<double>(Units::convert(time_trig - time_prev_, "us")));
timeBeforeTrigger_->Fill(static_cast<double>(Units::convert(-1.0 * time_before_, "us")));
timeAfterTrigger_->Fill(static_cast<double>(Units::convert(time_after_, "us")));
......@@ -274,24 +285,17 @@ StatusCode EventDefinitionM26::run(const std::shared_ptr<Clipboard>& clipboard)
_ends.push_back(evtEnd);
_pivots.push_back(_pivotCurrent);
_triggers.push_back(time_trig);
// make the event longer if possible - requires a buffering of 1 event
if(_oldEvent.first != 0) {
//_oldEvent.second = (Units::convert(evtStart-_oldEvent.second,"us")>=115.2) ?
//_oldEvent.second+115.2*1000 : _oldEvent.second;
auto event = std::make_shared<Event>(_oldEvent.first, _oldEvent.second);
clipboard->putEvent(event);
LOG(DEBUG) << "Defining Corryvreckan event: " << Units::display(evtStart, {"us", "ns"}) << " - "
<< Units::display(evtEnd, {"us", "ns"}) << ", length "
<< Units::display(_oldEvent.second - _oldEvent.first, {"us", "ns"});
eventDuration_->Fill(static_cast<double>(Units::convert(event->duration(), "us")));
hClipboardEventStart->Fill(static_cast<double>(Units::convert(evtStart, "ms")));
hClipboardEventStart_long->Fill(static_cast<double>(Units::convert(evtStart, "s")));
} else {
triggerTLU_--;
auto event = std::make_shared<Event>(evtStart, evtEnd);
clipboard->putEvent(event);
if(add_trigger_) {
clipboard->getEvent()->addTrigger(triggerTLU_, static_cast<double>(time_trig));
}
_oldEvent = std::make_pair(evtStart, evtEnd);
LOG(DEBUG) << "Defining Corryvreckan event: " << Units::display(evtStart, {"us", "ns"}) << " - "
<< Units::display(evtEnd, {"us", "ns"}) << ", length "
<< Units::display(evtEnd - evtStart, {"us", "ns"});
eventDuration_->Fill(static_cast<double>(Units::convert(event->duration(), "us")));
hClipboardEventStart->Fill(static_cast<double>(Units::convert(evtStart, "ms")));
hClipboardEventStart_long->Fill(static_cast<double>(Units::convert(evtStart, "s")));
} else {
LOG(ERROR) << "Current trigger time smaller than previous: " << time_trig << " vs " << time_prev_;
}
......
......@@ -56,6 +56,8 @@ namespace corryvreckan {
std::vector<long double> _triggers{};
long double _pivotCurrent;
std::vector<uint32_t> triggerIDs_{};
bool add_trigger_{};
long double timeshift_{};
int shift_triggers_{};
double skip_time_{};
......
# EventDefinitionM26
**Maintainer**: Lennart Huth (lennart.huth@desy.de), Jens Kroeger (jens.kroeger@cern.ch)
**Module Type**: *GLOBAL*
**Status**: Functional
**Maintainer**: Lennart Huth (lennart.huth@desy.de), Jens Kroeger (jens.kroeger@cern.ch)
**Module Type**: *GLOBAL*
**Status**: Advanced
### Description
This global module allows to fully utilize the PIVOT pixel behaviour of the
EUDET type telescopes based on the NI MIMOSA26 readout. The event begin and
EUDET type telescopes based on the NI MIMOSA26 readout. The MIMOSA DAQ stores two full rolling shutter frames.
The first frame corresponds to the frame where the trigger has been received. To store also particle hits at a position in front of the shutter, also the next frame is stored.
Note that the default NI-converter only returns pixels after the pivot in the first frame and in front of the pivot in the second frame.
The event begin and
end are defined based on the pivot pixel provided in the MIMOSA data
stream. Currently, the module assumes that the full two data frames are read
out, which is not the case in the standard converter.
However, the converter only returns all pixels after the pivot pixel of the
first frame and those before the pivot pixel of the second frame.
stream.
For a triggerID that has a TLU event from 425.000us to 425.025us (default
25 ns events), the trigger timestamp is defined as the middle of the event:
t_trig = (425us+425.025us)/2
and the pivot pixel-row is p the event will be defined as:
```math
begin = t_{trig} - (p * (115.2 / 576)) \mu s \\
end = begin + 230 \mu s
Event definition example:
If a triggerID has a TLU event from 425.000us to 425.025us (default
25 ns events) and the pivot pixel-row is 512 the event will be defined as:
```
It should be noted that in about 1 permille of the cases, zero triggers per event are
observed, which should in principle not be possible.
......@@ -24,10 +32,6 @@ This causes that in about 1 permille of the cases, the "time before" and
"time after" a trigger spanning the event is not set correctly when the
pivot pixel is close to its roll-over.
```math
begin = 125.012.5us - (512 * (115.2 / 576)) us
end = begin + 230us
```
### Parameters
* `detector_event_time`: Specify the detector type used to define the event timestamp.
......@@ -37,7 +41,7 @@ end = begin + 230us
* `shift_triggers`: Shift the trigger ID of the `detector_event_time`. This allows to correct trigger ID offsets between different devices such as the TLU and MIMOSA26. Note that if using the module `EventLoaderEUDAQ2` the same value for `shift_triggers` needs to be passed in both cases. Defaults to `0`.
* `skip_time`: Time that can be skipped at the start of a run. All events with earlier timestamps are discarded. Default is `0ms`.
* `eudaq_loglevel`: Verbosity level of the EUDAQ logger instance of the converter module. Possible options are, in decreasing severity, `USER`, `ERROR`, `WARN`, `INFO`, `EXTRA` and `DEBUG`. The default level is `ERROR`. Please note that the EUDAQ verbosity can only be changed globally, i.e. when using instances of `EventLoaderEUDAQ2` below this module, the last occurrence will determine the (global) value of this parameter.
* `add_trigger`: Option to directly add the trigger of the TLU to the event. If this option is selected, the event length is defined to be 3*115.2us - with 115.2us before the trigger timestamp and 230.4us after it. Note that no `EventLoaderEUDAQ2` for the TLU is required if this option is activated. Defaults to `false`
In addition, parameters can be forwarded to the EUDAQ2 event converters.
Please refer to the README of the `EventLoaderEUDAQ2` for more details.
......@@ -53,5 +57,6 @@ detector_event_time = TLU
file_timestamp = tlu_data.raw
file_duration = mimosa_data.raw
time_shift = 0
shift_triggers = -1
shift_triggers = 1
add_trigger = false
```
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