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

Merge branch 'catch_events_negative_duration' into 'master'

Catch events with negative duration in EventLoaderEUDAQ2

See merge request !400
parents cb3b8091 eb3ea81f
Pipeline #2371232 passed with stages
in 21 minutes and 51 seconds
......@@ -382,7 +382,7 @@ Event::Position EventLoaderEUDAQ2::is_within_event(const std::shared_ptr<Clipboa
} else if(position == Event::Position::AFTER) {
LOG(DEBUG) << "Event end after Corryvreckan event: " << Units::display(event_end, {"us", "ns"}) << " > "
<< Units::display(clipboard->getEvent()->end(), {"us", "ns"});
} else {
} else if(position == Event::Position::DURING) {
// check if event has valid trigger ID (flag = 0x10):
if(evt->IsFlagTrigger()) {
// Store potential trigger numbers, assign to center of event:
......@@ -558,7 +558,10 @@ StatusCode EventLoaderEUDAQ2::run(const std::shared_ptr<Clipboard>& clipboard) {
}
// If this event was after the current event or if we have not enough information, stop reading:
if(current_position == Event::Position::AFTER || current_position == Event::Position::UNKNOWN) {
if(current_position == Event::Position::AFTER) {
break;
} else if(current_position == Event::Position::UNKNOWN) {
event_.reset();
break;
}
......
......@@ -12,6 +12,7 @@
#define CORRYVRECKAN_EVENT_H 1
#include "Object.hpp"
#include "exceptions.h"
namespace corryvreckan {
......@@ -37,7 +38,11 @@ namespace corryvreckan {
* @param trigger_list Optional list of triggers assigned to this event, containing their ID and timestamps
*/
Event(double start, double end, std::map<uint32_t, double> trigger_list = std::map<uint32_t, double>())
: Object(start), end_(end), trigger_list_(std::move(trigger_list)){};
: Object(start), end_(end), trigger_list_(std::move(trigger_list)) {
if(end < start) {
throw InvalidEventError(typeid(*this), "Negative Event duration");
}
};
/**
* @brief Static member function to obtain base class for storage on the clipboard.
......
......@@ -110,6 +110,20 @@ namespace corryvreckan {
}
};
class InvalidEventError : public ObjectError {
public:
/**
* @brief InvalidEventError
* @param source
*/
explicit InvalidEventError(const std::type_info& source, const std::string msg = "") {
error_message_ += " Event Object ";
error_message_ += corryvreckan::demangle((source.name()));
error_message_ += " invalid: ";
error_message_ += msg;
}
};
} // namespace corryvreckan
#endif /* CORRYVRECKAN_OBJECT_EXCEPTIONS_H */
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