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

EventLoaderEUDAQ2: changed implementation of queueing sub-events and sorting...

EventLoaderEUDAQ2: changed implementation of queueing sub-events and sorting in reverse alphabetic order from std::vector + std::sort to std::priority_queue
parent abe7da4b
......@@ -162,22 +162,18 @@ std::shared_ptr<eudaq::StandardEvent> EventLoaderEUDAQ2::get_next_std_event() {
LOG(TRACE) << "Buffer gets filled with " << new_event->GetNumSubEvent() << " (sub-) events:";
for(uint32_t i = 0; i < new_event->GetNumSubEvent(); i++) {
LOG(TRACE) << " (sub-) event " << i << " is a " << new_event->GetSubEvent(i)->GetDescription();
events_.push(new_event->GetSubEvent(i));
}
// Build buffer from all sub-events:
events_ = new_event->GetSubEvents();
// The main event might also contain data, so add it to the buffer:
if(events_.empty()) {
LOG(TRACE) << " event is a " << new_event->GetDescription();
events_.push_back(new_event);
events_.push(new_event);
}
// FIXME get TLU events with trigger IDs before Ni - sort by name, reversed
sort(events_.begin(), events_.end(), [](const eudaq::EventSPC& a, const eudaq::EventSPC& b) -> bool {
return a->GetDescription() > b->GetDescription();
});
}
auto event = events_.front();
events_.erase(events_.begin());
// get first element and erease it:
LOG(TRACE) << "Buffer still contains " << events_.size() << " events.";
auto event = events_.top();
events_.pop();
decoding_failed = !eudaq::StdEventConverter::Convert(event, stdevt, eudaq_config_);
LOG(DEBUG) << event->GetDescription() << ": EventConverter returned " << (decoding_failed ? "false" : "true");
} while(decoding_failed);
......
......@@ -92,17 +92,27 @@ namespace corryvreckan {
// EUDAQ file reader instance to retrieve data from
eudaq::FileReaderUP reader_;
// Buffer of undecoded EUDAQ events
std::vector<eudaq::EventSPC> events_;
// Currently processed decoded EUDAQ StandardEvent:
std::shared_ptr<eudaq::StandardEvent> event_;
// custom comparator to sort priority_queue by event Description
// FIXME get TLU events with trigger IDs before Ni - sort by name, reversed
struct CompareDescription {
bool operator()(const eudaq::EventSPC a, const eudaq::EventSPC b) {
return a->GetDescription() > b->GetDescription();
}
};
// custom comparator for time-sorted priority_queue
struct CompareTimeGreater {
bool operator()(const std::shared_ptr<eudaq::StandardEvent> a, const std::shared_ptr<eudaq::StandardEvent> b) {
return a->GetTimeBegin() > b->GetTimeBegin();
}
};
// Buffer of undecoded EUDAQ events
std::priority_queue<eudaq::EventSPC, std::vector<eudaq::EventSPC>, CompareDescription> events_;
// Buffer of timesorted decoded EUDAQ StandardEvents: (need to use greater here!)
std::priority_queue<std::shared_ptr<eudaq::StandardEvent>,
std::vector<std::shared_ptr<eudaq::StandardEvent>>,
......
Supports Markdown
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