Commit 735edb73 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Merge branch 'fixedm26' into 'master'

Fixedm26

See merge request corryvreckan/corryvreckan!418
parents 2d046e09 63089878
Pipeline #2528144 passed with stages
in 24 minutes and 26 seconds
......@@ -53,6 +53,12 @@ EventDefinitionM26::EventDefinitionM26(Configuration& config, std::vector<std::s
// Unfortunately, EUDAQ does not provide appropriate member functions for their configuration class to avoid this dance
const eudaq::Configuration eu_cfg = cfg;
eudaq_config_ = std::make_shared<const eudaq::Configuration>(eu_cfg);
// Shift trigger ID of this device with respect to the IDs stored in the Corryrveckan Event
// Note: Require shift_triggers >= 0
if(shift_triggers_ < 0) {
throw InvalidValueError(config_, "shift_triggers", "Trigger shift needs to be positive (or zero).");
}
}
void EventDefinitionM26::initialize() {
......@@ -150,12 +156,13 @@ StatusCode EventDefinitionM26::run(const std::shared_ptr<Clipboard>& clipboard)
}
// read events until we have a common tag:
try {
triggerTLU_ = static_cast<unsigned>(
static_cast<int>(get_next_event_with_det(readerTime_, detector_time_, time_trig_start_, time_trig_stop_)) +
shift_triggers_);
triggerTLU_ = get_next_event_with_det(readerTime_, detector_time_, time_trig_start_, time_trig_stop_);
;
timebetweenTLUEvents_->Fill(static_cast<double>(Units::convert(time_trig_start_ - trig_prev_, "us")));
trig_prev_ = time_trig_start_;
triggerM26_ = get_next_event_with_det(readerDuration_, "mimosa26", time_before_, time_after_);
triggerM26_ = static_cast<unsigned>(
static_cast<int>(get_next_event_with_det(readerDuration_, "mimosa26", time_before_, time_after_)) +
shift_triggers_);
} catch(EndOfFile&) {
return StatusCode::EndRun;
}
......@@ -164,14 +171,14 @@ StatusCode EventDefinitionM26::run(const std::shared_ptr<Clipboard>& clipboard)
try {
if(triggerTLU_ < triggerM26_) {
LOG(DEBUG) << "TLU trigger smaller than Mimosa26 trigger, get next TLU trigger";
triggerTLU_ = static_cast<unsigned>(static_cast<int>(get_next_event_with_det(
readerTime_, detector_time_, time_trig_start_, time_trig_stop_)) +
shift_triggers_);
triggerTLU_ = get_next_event_with_det(readerTime_, detector_time_, time_trig_start_, time_trig_stop_);
timebetweenTLUEvents_->Fill(static_cast<double>(Units::convert(time_trig_start_ - trig_prev_, "us")));
trig_prev_ = time_trig_start_;
} else if(triggerTLU_ > triggerM26_) {
LOG(DEBUG) << "Mimosa26 trigger smaller than TLU trigger, get next Mimosa26 trigger";
triggerM26_ = get_next_event_with_det(readerDuration_, "mimosa26", time_before_, time_after_);
triggerM26_ = static_cast<unsigned>(
static_cast<int>(get_next_event_with_det(readerDuration_, "mimosa26", time_before_, time_after_)) +
shift_triggers_);
}
} catch(EndOfFile&) {
......@@ -183,7 +190,16 @@ StatusCode EventDefinitionM26::run(const std::shared_ptr<Clipboard>& clipboard)
if(triggerTLU_ == triggerM26_) {
auto time_trig = time_trig_start_;
if(time_trig - time_prev_ > 0) {
// M26 frames need to have a distance of at least one frame length!
if(time_trig - time_prev_ < 115000) {
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.";
}
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")));
......
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