diff --git a/README.md b/README.md index e43c363f754dca0cfcbf1aa25da1d637969d0366..992403e840062b51e8fb49d4735c0be32f9d02fc 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ The following authors, in alphabetical order, have contributed to Corryvreckan: * Carsten Daniel Burgard, DESY, @cburgard * Manuel Colocci, CERN, @mcolocci * Jens Dopke, STFC RAL, @jdopke +* Jordi Duarte-Campderros, IFCA, @duarte * Nicolò Jacazio, CERN, @njacazio * Chun Cheng, DESY, @chengc * Dominik Dannheim, CERN, @dannheim diff --git a/src/modules/EventLoaderEUDAQ/CMakeLists.txt b/src/modules/EventLoaderEUDAQ/CMakeLists.txt index 001a1cd52d8937c534198b782ecb31e316bef132..a19ca83a631e7f1933e61f2d6ee31caed45242dd 100644 --- a/src/modules/EventLoaderEUDAQ/CMakeLists.txt +++ b/src/modules/EventLoaderEUDAQ/CMakeLists.txt @@ -14,6 +14,7 @@ INCLUDE_DIRECTORIES(SYSTEM ${EUDAQ_INCLUDE_DIR}) # Add source files to library CORRYVRECKAN_MODULE_SOURCES(${MODULE_NAME} EventLoaderEUDAQ.cpp + SequentialReader.cpp ) # Add EUDAQ libraries diff --git a/src/modules/EventLoaderEUDAQ/EventLoaderEUDAQ.cpp b/src/modules/EventLoaderEUDAQ/EventLoaderEUDAQ.cpp index 7d3a6a2927bd94b784067b4945175d3025bb9099..99d742159ff4d50e7394b7c612c9f8b3dc26bd8e 100644 --- a/src/modules/EventLoaderEUDAQ/EventLoaderEUDAQ.cpp +++ b/src/modules/EventLoaderEUDAQ/EventLoaderEUDAQ.cpp @@ -8,10 +8,14 @@ * Intergovernmental Organization or submit itself to any jurisdiction. */ +#include + +#include "TDirectory.h" +#include "TH2F.h" + #include "EventLoaderEUDAQ.h" -#include "eudaq/PluginManager.hh" -#include +#include "eudaq/PluginManager.hh" using namespace corryvreckan; using namespace std; @@ -21,17 +25,20 @@ EventLoaderEUDAQ::EventLoaderEUDAQ(Configuration& config, std::vector("long_detector_id", true); - m_filename = config_.getPath("file_name", true); + m_filenames = config_.getPathArray("file_name", true); m_longID = config_.get("long_detector_id"); } void EventLoaderEUDAQ::initialize() { - // Create new file reader: - try { - reader = new eudaq::FileReader(m_filename, ""); - } catch(...) { - throw ModuleError("Unable to read input file \"" + m_filename + "\""); + // Create files reader: + reader = std::make_unique(); + for(const auto& file : m_filenames) { + try { + reader->addFile(file); + } catch(...) { + throw ModuleError("Unable to read input file \"" + file + "\""); + } } // Loop over all planes @@ -65,7 +72,7 @@ void EventLoaderEUDAQ::initialize() { StatusCode EventLoaderEUDAQ::run(const std::shared_ptr& clipboard) { // Read next event from EUDAQ reader: - const eudaq::DetectorEvent& evt = reader->Event(); + const eudaq::DetectorEvent& evt = reader->GetDetectorEvent(); LOG(TRACE) << evt; // Convert timestamp to nanoseconds, using diff --git a/src/modules/EventLoaderEUDAQ/EventLoaderEUDAQ.h b/src/modules/EventLoaderEUDAQ/EventLoaderEUDAQ.h index 806ee471f233f8fcf7415e2e80549360e7e50ece..60af3cf1c2752bfab4f43e1343ee5b8849fb1243 100644 --- a/src/modules/EventLoaderEUDAQ/EventLoaderEUDAQ.h +++ b/src/modules/EventLoaderEUDAQ/EventLoaderEUDAQ.h @@ -11,15 +11,16 @@ #ifndef EventLoaderEUDAQ_H #define EventLoaderEUDAQ_H 1 -#include -#include -#include -#include +#include +#include +#include +#include + #include "core/module/Module.hpp" -#include "eudaq/FileReader.hh" -#include "objects/Cluster.hpp" -#include "objects/Pixel.hpp" -#include "objects/Track.hpp" + +#include "SequentialReader.h" + +class TH2F; namespace corryvreckan { /** @ingroup Modules @@ -35,11 +36,11 @@ namespace corryvreckan { void initialize() override; StatusCode run(const std::shared_ptr& clipboard) override; - // EUDAQ file reader instance: - eudaq::FileReader* reader; + // EUDAQ-based file reader instance: + std::unique_ptr reader; // Member variables - std::string m_filename{}; + std::vector m_filenames{}; bool m_longID; std::map hitmap; diff --git a/src/modules/EventLoaderEUDAQ/README.md b/src/modules/EventLoaderEUDAQ/README.md index 382ddc0e95bf1532c077ecdc5596d3e7915aee1d..24d8ab2c8e9016d8118892e1cf5c7119c6c67847 100644 --- a/src/modules/EventLoaderEUDAQ/README.md +++ b/src/modules/EventLoaderEUDAQ/README.md @@ -8,6 +8,8 @@ This module allows data recorded by EUDAQ and stored in the EUDAQ-native raw for The detector IDs are taken from the plane name and IDs, two possible naming options for Corryvreckan are available: When setting `long_detector_id = true`, the name of the sensor plane and the ID are used in the form `_`, while only the ID is used otherwise as `plane`. Only detectors listed in the Corryvreckan geometry are decoded and stored, data from other detectors available in the same EUDAQ event are ignored. +This module is able to process multiple runs sequentially if all the devices were integrated with EUDAQ in the data-taking. This is an important limitation preventing to add data from other devices via different event loaders, as the event building algorithm of Corryvreckan will add the data into the Event if it matches either the timestamps or trigger IDs. However, EUDAQv1.x support stopped some years ago, and this module is a bit outdated: right now is defining the Corryvreckan Event using hardcoded timestamps in the [code](https://gitlab.cern.ch/corryvreckan/corryvreckan/-/blob/master/src/modules/EventLoaderEUDAQ/EventLoaderEUDAQ.cpp#L140-143) and therefore, it is impossible to include any device from a different event loader. + ### Requirements This module requires an installation of [EUDAQ 1.x](https://github.com/eudaq/eudaq). The installation path should be set as environment variable via ```bash @@ -16,13 +18,19 @@ export EUDAQPATH=/path/to/eudaq for CMake to find the library link against and headers to include. ### Parameters -* `file_name`: File name of the EUDAQ raw data file. This parameter is mandatory. +* `file_name`: File name(s) of the EUDAQ raw data file(s). At least one file is mandatory. * `long_detector_id`: Boolean switch to configure using the long or short detector ID in Corryvreckan, defaults to `true`. ### Usage ```toml [EUDAQEventLoader] -file_name = "rawdata/eudaq/run020808.raw" +file_names = "rawdata/eudaq/run020808.raw" +long_detector_id = true +``` +If all the devices were integrated in EUDAQ: you can process multiple files at once: +```toml +[EUDAQEventLoader] +file_names = "rawdata/eudaq/run020808.raw","rawdata/eudaq/run020810.raw" long_detector_id = true ``` diff --git a/src/modules/EventLoaderEUDAQ/SequentialReader.cpp b/src/modules/EventLoaderEUDAQ/SequentialReader.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2f4950fddcd97d95d411b12f9c6cafbca25c2dcf --- /dev/null +++ b/src/modules/EventLoaderEUDAQ/SequentialReader.cpp @@ -0,0 +1,37 @@ +/** + * @file + * @brief EUDAQ event-based reader to allow sequential reading of multiple runs + * + * @copyright Copyright (c) 2017-2020 CERN and the Corryvreckan authors. + * This software is distributed under the terms of the MIT License, copied verbatim in the file "LICENSE.md". + * In applying this license, CERN does not waive the privileges and immunities granted to it by virtue of its status as an + * Intergovernmental Organization or submit itself to any jurisdiction. + */ + +#include "SequentialReader.h" + +using namespace corryvreckan; + +void SequentialReader::addFile(const std::string& filename) { + // Files are read sequentially, and FIFO + file_readers_.emplace(std::make_unique(filename, "")); +} + +bool SequentialReader::NextEvent() { + if(!file_readers_.front()->NextEvent()) { + // Remove the all one, assign the event, and ask again + // if still are readers + file_readers_.pop(); + if(file_readers_.size() == 0) { + return false; + }; + // and call it again + NextEvent(); + } + + return true; +} + +const eudaq::DetectorEvent& SequentialReader::GetDetectorEvent() const { + return file_readers_.front()->GetDetectorEvent(); +} diff --git a/src/modules/EventLoaderEUDAQ/SequentialReader.h b/src/modules/EventLoaderEUDAQ/SequentialReader.h new file mode 100644 index 0000000000000000000000000000000000000000..f70bb6eb39a7cec7e2fce1182a8ca156190adef9 --- /dev/null +++ b/src/modules/EventLoaderEUDAQ/SequentialReader.h @@ -0,0 +1,53 @@ +/** + * @file + * @brief EUDAQ event-based reader to allow sequential reading of multiple runs + * + * @copyright Copyright (c) 2017-2020 CERN and the Corryvreckan authors. + * This software is distributed under the terms of the MIT License, copied verbatim in the file "LICENSE.md". + * In applying this license, CERN does not waive the privileges and immunities granted to it by virtue of its status as an + * Intergovernmental Organization or submit itself to any jurisdiction. + */ + +#ifndef SequentialREADER_H__ +#define SequentialREADER_H__ + +#include "eudaq/DetectorEvent.hh" +#include "eudaq/Event.hh" +#include "eudaq/FileReader.hh" + +#include +#include +#include + +namespace corryvreckan { + + class SequentialReader { + + public: + /* + * @brief Constructor and destructor + */ + SequentialReader() = default; + ~SequentialReader() = default; + + /* + * @brief Add a file to read + * @param filename: the name of the raw file + */ + void addFile(const std::string& filename); + + /* + * @brief Process the next event + */ + bool NextEvent(); + /* + * @brief Get the current detector event + */ + const eudaq::DetectorEvent& GetDetectorEvent() const; + + private: + // the container of all file readers + std::queue> file_readers_; + }; +} // namespace corryvreckan +#endif // SequentialREADER_H__