Commit 23cf41a4 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Clipboard: rename event functions to be coherent

parent aa79a3e0
......@@ -20,11 +20,11 @@ bool Clipboard::hasPersistentData(std::string name) const {
return m_persistent_data.find(name) != m_persistent_data.end();
}
bool Clipboard::event_defined() const {
bool Clipboard::isEventDefined() const {
return (m_event != nullptr);
}
void Clipboard::put_event(std::shared_ptr<Event> event) {
void Clipboard::putEvent(std::shared_ptr<Event> event) {
// Already defined:
if(m_event) {
throw InvalidDataError("Event already defined. Only one module can place an event definition");
......@@ -33,7 +33,7 @@ void Clipboard::put_event(std::shared_ptr<Event> event) {
}
}
std::shared_ptr<Event> Clipboard::get_event() const {
std::shared_ptr<Event> Clipboard::getEvent() const {
if(!m_event) {
throw InvalidDataError("Event not defined. Add Metronome module or Event reader defining the event");
}
......
......@@ -63,21 +63,21 @@ namespace corryvreckan {
* @brief Check whether an event has been defined
* @return true if an event has been defined, false otherwise
*/
bool event_defined() const;
bool isEventDefined() const;
/**
* @brief Store the event object
* @param event The event object to be stored
* @thorws InvalidDataError in case an event exist already
*/
void put_event(std::shared_ptr<Event> event);
void putEvent(std::shared_ptr<Event> event);
/**
* @brief Retrieve the event object
* @returnShared pointer to the event
* @throws MissingDataError in case no event is available.
*/
std::shared_ptr<Event> get_event() const;
std::shared_ptr<Event> getEvent() const;
/**
* @brief Store or update variable on the persistent clipboard storage
......
......@@ -564,7 +564,7 @@ void ModuleManager::run() {
break;
}
if(m_clipboard->event_defined() && run_time > 0.0 && m_clipboard->get_event()->start() >= run_time) {
if(m_clipboard->isEventDefined() && run_time > 0.0 && m_clipboard->getEvent()->start() >= run_time) {
break;
}
......@@ -590,8 +590,8 @@ void ModuleManager::run() {
LOG_PROGRESS(STATUS, "event_loop")
<< "Ev: " << kilo_or_mega(m_events) << " Tr: " << kilo_or_mega(m_tracks) << " (" << std::setprecision(3)
<< (static_cast<double>(m_tracks) / m_events) << "/ev)"
<< (m_clipboard->event_defined()
? " t = " + Units::display(m_clipboard->get_event()->start(), {"ns", "us", "ms", "s"})
<< (m_clipboard->isEventDefined()
? " t = " + Units::display(m_clipboard->getEvent()->start(), {"ns", "us", "ms", "s"})
: "");
}
......
......@@ -385,7 +385,7 @@ StatusCode AnalysisDUT::run(std::shared_ptr<Clipboard> clipboard) {
}
// Get the event:
auto event = clipboard->get_event();
auto event = clipboard->getEvent();
// Discard tracks which are very close to the frame edges
if(fabs(track->timestamp() - event->end()) < m_timeCutFrameEdge) {
......
......@@ -213,7 +213,7 @@ StatusCode AnalysisEfficiency::run(std::shared_ptr<Clipboard> clipboard) {
}
// Get the event:
auto event = clipboard->get_event();
auto event = clipboard->getEvent();
// Discard tracks which are very close to the frame edges
if(fabs(track->timestamp() - event->end()) < m_timeCutFrameEdge) {
......
......@@ -403,7 +403,7 @@ StatusCode AnalysisTimingATLASpix::run(std::shared_ptr<Clipboard> clipboard) {
tracks_afterMasking++;
// Get the event:
auto event = clipboard->get_event();
auto event = clipboard->getEvent();
// Discard tracks which are very close to the frame edges
if(fabs(track->timestamp() - event->end()) < m_timeCutFrameEdge) {
......
......@@ -81,8 +81,8 @@ StatusCode ClusteringSpatial::run(std::shared_ptr<Clipboard> clipboard) {
cluster->addPixel(pixel);
if(useTriggerTimestamp) {
if(!clipboard->get_event()->triggerList().empty()) {
double trigger_ts = clipboard->get_event()->triggerList().begin()->second;
if(!clipboard->getEvent()->triggerList().empty()) {
double trigger_ts = clipboard->getEvent()->triggerList().begin()->second;
LOG(DEBUG) << "Using trigger timestamp " << Units::display(trigger_ts, "us") << " as cluster timestamp.";
cluster->setTimestamp(trigger_ts);
} else {
......
......@@ -224,7 +224,7 @@ void EventLoaderATLASpix::initialise() {
StatusCode EventLoaderATLASpix::run(std::shared_ptr<Clipboard> clipboard) {
// Check if event frame is defined:
auto event = clipboard->get_event();
auto event = clipboard->getEvent();
// If have reached the end of file, close it and exit program running
if(m_file.eof()) {
......
......@@ -121,7 +121,7 @@ StatusCode EventLoaderCLICpix::run(std::shared_ptr<Clipboard> clipboard) {
}
// Now set the event time so that the Timepix3 data is loaded correctly
clipboard->put_event(std::make_shared<Event>(shutterStartTime, shutterStopTime));
clipboard->putEvent(std::make_shared<Event>(shutterStartTime, shutterStopTime));
LOG(TRACE) << "Loaded " << npixels << " pixels";
// Put the data on the clipboard
......
......@@ -298,7 +298,7 @@ StatusCode EventLoaderCLICpix2::run(std::shared_ptr<Clipboard> clipboard) {
// Store current frame time and the length of the event:
LOG(DEBUG) << "Event time: " << Units::display(shutterStartTime, {"ns", "us", "s"})
<< ", length: " << Units::display((shutterStopTime - shutterStartTime), {"ns", "us", "s"});
clipboard->put_event(std::make_shared<Event>(shutterStartTime, shutterStopTime));
clipboard->putEvent(std::make_shared<Event>(shutterStartTime, shutterStopTime));
// Put the data on the clipboard
clipboard->put(pixels, m_detector->name());
......
......@@ -97,7 +97,7 @@ StatusCode EventLoaderEUDAQ::run(std::shared_ptr<Clipboard> clipboard) {
// Store event time on clipboard for subsequent modules
// FIXME assumes trigger in center of two Mimosa26 frames:
auto frame_length = Units::get(115.2, "us");
clipboard->put_event(std::make_shared<Event>(timestamp - frame_length, timestamp + frame_length));
clipboard->putEvent(std::make_shared<Event>(timestamp - frame_length, timestamp + frame_length));
// Advance to next event if possible, otherwise end this run:
if(!reader->NextEvent()) {
......
......@@ -225,13 +225,13 @@ EventLoaderEUDAQ2::EventPosition EventLoaderEUDAQ2::is_within_event(std::shared_
LOG(DEBUG) << evt->GetDescription() << ": Event has no timestamp, comparing trigger number";
// If there is no event defined yet or the trigger number is unkown, there is little we can do:
if(!clipboard->event_defined() || !clipboard->get_event()->hasTriggerID(evt->GetTriggerN())) {
if(!clipboard->isEventDefined() || !clipboard->getEvent()->hasTriggerID(evt->GetTriggerN())) {
LOG(DEBUG) << "Trigger ID " << evt->GetTriggerN() << " not found in current event.";
return EventPosition::UNKNOWN;
}
// Store trigger timestamp in event:
auto trigger_time = clipboard->get_event()->getTriggerTime(evt->GetTriggerN());
auto trigger_time = clipboard->getEvent()->getTriggerTime(evt->GetTriggerN());
LOG(DEBUG) << "Assigning trigger time " << Units::display(trigger_time, {"us", "ns"}) << " to event with trigger ID "
<< evt->GetTriggerN();
// Set EUDAQ StandardEvent timestamp in picoseconds:
......@@ -260,7 +260,7 @@ EventLoaderEUDAQ2::EventPosition EventLoaderEUDAQ2::is_within_event(std::shared_
double shift_start = 0;
double shift_end = 0;
if(!clipboard->event_defined()) {
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"});
......@@ -275,13 +275,13 @@ EventLoaderEUDAQ2::EventPosition EventLoaderEUDAQ2::is_within_event(std::shared_
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->put_event(std::make_shared<Event>(event_start, event_end));
clipboard->putEvent(std::make_shared<Event>(event_start, event_end));
} else {
LOG(DEBUG) << "Corryvreckan event found on clipboard.";
}
double clipboard_start = clipboard->get_event()->start();
double clipboard_end = clipboard->get_event()->end();
double clipboard_start = clipboard->getEvent()->start();
double clipboard_end = clipboard->getEvent()->end();
// if(event_start < clipboard_start) { // we still need to discuss about the logic here!
if(event_end < clipboard_start) {
......@@ -297,7 +297,7 @@ EventLoaderEUDAQ2::EventPosition EventLoaderEUDAQ2::is_within_event(std::shared_
// check if event has valid trigger ID (flag = 0x10):
if(evt->IsFlagTrigger()) {
// Store potential trigger numbers, assign to center of event:
clipboard->get_event()->addTrigger(evt->GetTriggerN(), event_start - shift_start);
clipboard->getEvent()->addTrigger(evt->GetTriggerN(), event_start - shift_start);
LOG(DEBUG) << "Stored trigger ID " << evt->GetTriggerN() << " at "
<< Units::display(event_start - shift_start, {"us", "ns"});
}
......@@ -402,19 +402,19 @@ StatusCode EventLoaderEUDAQ2::run(std::shared_ptr<Clipboard> clipboard) {
// Converting EUDAQ2 picoseconds into Corryvreckan nanoseconds:
hEudaqEventStart->Fill(static_cast<double>(event_->GetTimeBegin()) / 1e9); // here convert from ps to ms
hEudaqEventStart_long->Fill(static_cast<double>(event_->GetTimeBegin()) / 1e12); // here convert from ps to seconds
if(clipboard->event_defined()) {
hClipboardEventStart->Fill(static_cast<double>(Units::convert(clipboard->get_event()->start(), "ms")));
hClipboardEventStart_long->Fill(static_cast<double>(Units::convert(clipboard->get_event()->start(), "s")));
hClipboardEventEnd->Fill(static_cast<double>(Units::convert(clipboard->get_event()->end(), "ms")));
if(clipboard->isEventDefined()) {
hClipboardEventStart->Fill(static_cast<double>(Units::convert(clipboard->getEvent()->start(), "ms")));
hClipboardEventStart_long->Fill(static_cast<double>(Units::convert(clipboard->getEvent()->start(), "s")));
hClipboardEventEnd->Fill(static_cast<double>(Units::convert(clipboard->getEvent()->end(), "ms")));
hClipboardEventDuration->Fill(
static_cast<double>(Units::convert(clipboard->get_event()->end() - clipboard->get_event()->start(), "ms")));
static_cast<double>(Units::convert(clipboard->getEvent()->end() - clipboard->getEvent()->start(), "ms")));
}
// Reset this shared event pointer to get a new event from the stack:
event_.reset();
}
auto event = clipboard->get_event();
auto event = clipboard->getEvent();
hTriggersPerEvent->Fill(static_cast<double>(event->triggerList().size()));
LOG(DEBUG) << "Triggers on clipboard event: " << event->triggerList().size();
for(auto& trigger : event->triggerList()) {
......
......@@ -218,7 +218,7 @@ StatusCode EventLoaderTimepix3::run(std::shared_ptr<Clipboard> clipboard) {
// loading a fixed number of pixels (ie. 2000 at a time)
// Check if event frame is defined:
auto event = clipboard->get_event();
auto event = clipboard->getEvent();
LOG(TRACE) << "== New event";
......@@ -322,7 +322,7 @@ bool EventLoaderTimepix3::loadData(std::shared_ptr<Clipboard> clipboard,
std::shared_ptr<SpidrSignalVector>& spidrData) {
std::string detectorID = m_detector->name();
auto event = clipboard->get_event();
auto event = clipboard->getEvent();
bool extra = false; // temp
......
......@@ -212,13 +212,13 @@ void FileReader::initialise() {
StatusCode FileReader::run(std::shared_ptr<Clipboard> clipboard) {
if(clipboard->event_defined()) {
if(clipboard->isEventDefined()) {
ModuleError("Clipboard event already defined, cannot continue");
}
// Read event object from tree and store it on the clipboard:
event_tree_->GetEntry(event_num_);
clipboard->put_event(std::make_shared<Event>(*event_));
clipboard->putEvent(std::make_shared<Event>(*event_));
read_cnt_++;
for(auto& tree : trees_) {
......
......@@ -62,12 +62,12 @@ void FileWriter::initialise() {
StatusCode FileWriter::run(std::shared_ptr<Clipboard> clipboard) {
if(!clipboard->event_defined()) {
if(!clipboard->isEventDefined()) {
ModuleError("No Clipboard event defined, cannot continue");
}
// Read event from clipboard and write to tree:
event_ = clipboard->get_event().get();
event_ = clipboard->getEvent().get();
event_tree_->Fill();
write_cnt_++;
......
......@@ -22,7 +22,7 @@ StatusCode Metronome::run(std::shared_ptr<Clipboard> clipboard) {
// Set up the current event:
LOG(DEBUG) << "Defining event, time frame " << Units::display(m_eventStart, {"us", "ms", "s"}) << " to "
<< Units::display(m_eventEnd, {"us", "ms", "s"});
clipboard->put_event(std::make_shared<Event>(m_eventStart, m_eventEnd));
clipboard->putEvent(std::make_shared<Event>(m_eventStart, m_eventEnd));
// Increment the current event's start and end times by the configured event length
m_eventStart = m_eventEnd;
......
......@@ -45,13 +45,13 @@ void TextWriter::initialise() {
StatusCode TextWriter::run(std::shared_ptr<Clipboard> clipboard) {
if(!clipboard->event_defined()) {
if(!clipboard->isEventDefined()) {
ModuleError("No Clipboard event defined, cannot continue");
}
// Print the current event:
*output_file_ << "=== " << m_eventNumber << " ===" << std::endl;
*output_file_ << *clipboard->get_event() << std::endl;
*output_file_ << *clipboard->getEvent() << std::endl;
auto data = clipboard->get_all();
LOG(DEBUG) << "Clipboard has " << data.size() << " different object types.";
......
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