diff --git a/algo/ca/core/data/CaDataManager.cxx b/algo/ca/core/data/CaDataManager.cxx index 0e9174594c38c84a462b0ac1471716505401b26d..72ba8a626c64ccae0e2d80bc9798a3efabee93f0 100644 --- a/algo/ca/core/data/CaDataManager.cxx +++ b/algo/ca/core/data/CaDataManager.cxx @@ -1,10 +1,10 @@ -/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only Authors: Sergey Gorbunov, Sergei Zharko [committer] */ -/// \file L1IODataManager.h -/// \brief Input-output data manager for L1 tracking algorithm -/// \since 08.08.2022 +/// \file CaDataManager.h +/// \brief Input-output data manager for L1 tracking algorithm +/// \since 08.08.2022 /// \author S.Zharko <s.zharko@gsi.de> #include "CaDataManager.h" @@ -14,9 +14,12 @@ #include <fstream> +using cbm::algo::ca::DataManager; +using cbm::algo::ca::InputData; + // --------------------------------------------------------------------------------------------------------------------- // -bool L1IODataManager::SendInputData(L1InputData& destination) +bool DataManager::SendInputData(InputData& destination) { // Set boundary hit indexes InitData(); @@ -33,7 +36,7 @@ bool L1IODataManager::SendInputData(L1InputData& destination) // --------------------------------------------------------------------------------------------------------------------- // -L1InputData&& L1IODataManager::TakeInputData() +InputData&& DataManager::TakeInputData() { // Init the input data InitData(); @@ -50,7 +53,7 @@ L1InputData&& L1IODataManager::TakeInputData() // --------------------------------------------------------------------------------------------------------------------- // -void L1IODataManager::ReadInputData(const std::string& fileName) +void DataManager::ReadInputData(const std::string& fileName) { // Reset input data object ResetInputData(); @@ -60,7 +63,7 @@ void L1IODataManager::ReadInputData(const std::string& fileName) std::ifstream ifs(fileName, std::ios::binary); if (!ifs) { LOG(fatal) << "L1: input data reader: data file \"" << fileName << "\" was not found"; } - // Get L1InputData object + // Get InputData object try { boost::archive::binary_iarchive ia(ifs); ia >> fInputData; @@ -72,9 +75,9 @@ void L1IODataManager::ReadInputData(const std::string& fileName) // --------------------------------------------------------------------------------------------------------------------- // -void L1IODataManager::ResetInputData(ca::HitIndex_t nHits) noexcept +void DataManager::ResetInputData(ca::HitIndex_t nHits) noexcept { - L1InputData tmp; + InputData tmp; fInputData.Swap(tmp); fLastStreamId = -1; fInputData.fStreamStartIndices.reserve(2000); // TODO: What are these numbers? Please, put them into constants.h @@ -84,7 +87,7 @@ void L1IODataManager::ResetInputData(ca::HitIndex_t nHits) noexcept // --------------------------------------------------------------------------------------------------------------------- // -void L1IODataManager::InitData() +void DataManager::InitData() { // set the end pointers to data streams @@ -105,7 +108,7 @@ void L1IODataManager::InitData() // --------------------------------------------------------------------------------------------------------------------- // -void L1IODataManager::WriteInputData(const std::string& fileName) const +void DataManager::WriteInputData(const std::string& fileName) const { // Check current data object for consistency if (!CheckInputData<constants::control::InputDataQaLevel>()) { @@ -120,7 +123,7 @@ void L1IODataManager::WriteInputData(const std::string& fileName) const return; } - // Serialize L1InputData object and write + // Serialize InputData object and write boost::archive::binary_oarchive oa(ofs); oa << fInputData; } diff --git a/algo/ca/core/data/CaDataManager.h b/algo/ca/core/data/CaDataManager.h index 3cba54fde4e9a028dfd7456f7bcf9d983c287e63..be27b5414cecc087fe9e4ca60fed53aa6c509c95 100644 --- a/algo/ca/core/data/CaDataManager.h +++ b/algo/ca/core/data/CaDataManager.h @@ -1,175 +1,168 @@ -/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only Authors: Sergey Gorbunov, Sergei Zharko [committer] */ -/// \file L1IODataManager.h -/// \brief Input-output data manager for L1 tracking algorithm -/// \since 05.08.2022 +/// \file CaDataManager.h +/// \brief Input-output data manager for L1 tracking algorithm +/// \since 05.08.2022 /// \author S.Zharko <s.zharko@gsi.de> -#ifndef L1IODataManager_h -#define L1IODataManager_h 1 +#ifndef CaDataManager_h +#define CaDataManager_h 1 #include "CaConstants.h" #include "CaInputData.h" -using namespace cbm::algo::ca; //TODO: remove - -class L1Algo; -//class L1OutputData; - -/// Class L1IODataManager defines the interface for input and output data flow in the L1 tracking algorithm -/// -class alignas(constants::misc::Alignment) L1IODataManager { -public: - // *************************** - // ** Member functions list ** - // *************************** - - // ** Constructors and destructor ** - - /// Default constructor - L1IODataManager() = default; - - /// Destructor - ~L1IODataManager() = default; - - /// Copy constructor - L1IODataManager(const L1IODataManager& other) = delete; - - /// Move constructor - L1IODataManager(L1IODataManager&& other) = delete; - - /// Copy assignment operator - L1IODataManager& operator=(const L1IODataManager& other) = delete; - - /// Move assignment operator - L1IODataManager& operator=(L1IODataManager&& other) = delete; - - /// @brief Gets number of hits stored - /// @return Number of hits - int GetNofHits() { return fInputData.fHits.size(); } - - /// Reads input data object from boost-serialized binary file - /// \param fileName Name of input file - void ReadInputData(const std::string& fileName); - - /// Reserve number of hits - /// \param nHits Number of hits to be stored - /// \note If one does not call this method, the underlying vector of hits will be filled with the time penalty - void ReserveNhits(ca::HitIndex_t nHits) { fInputData.fHits.reserve(nHits); } - - /// @brief Resets the input data block - /// @param nHits Number of hits to reserve - void ResetInputData(ca::HitIndex_t nHits = 0) noexcept; - - /// Pushes back a hit - /// \param hit An ca::Hit object - void PushBackHit(const ca::Hit& hit, int64_t streamId) - { - if (fInputData.fStreamStartIndices.size() == 0 || fLastStreamId != streamId) { // new data stream - fLastStreamId = streamId; - fInputData.fStreamStartIndices.push_back(fInputData.fHits.size()); - // for a case.. it is fixed later in InitData() - fInputData.fStreamStopIndices.push_back(fInputData.fHits.size()); +namespace cbm::algo::ca +{ + /// \class cbm::algo::ca::DataManager + /// \brief A manager for the input-output data of the CA tracking algorithm + /// + class alignas(constants::misc::Alignment) DataManager { + public: + // *************************** + // ** Member functions list ** + // *************************** + + // ** Constructors and destructor ** + + /// Default constructor + DataManager() = default; + + /// Destructor + ~DataManager() = default; + + /// Copy constructor + DataManager(const DataManager& other) = delete; + + /// Move constructor + DataManager(DataManager&& other) = delete; + + /// Copy assignment operator + DataManager& operator=(const DataManager& other) = delete; + + /// Move assignment operator + DataManager& operator=(DataManager&& other) = delete; + + /// @brief Gets number of hits stored + /// @return Number of hits + int GetNofHits() { return fInputData.fHits.size(); } + + /// Reads input data object from boost-serialized binary file + /// \param fileName Name of input file + void ReadInputData(const std::string& fileName); + + /// Reserve number of hits + /// \param nHits Number of hits to be stored + /// \note If one does not call this method, the underlying vector of hits will be filled with the time penalty + void ReserveNhits(ca::HitIndex_t nHits) { fInputData.fHits.reserve(nHits); } + + /// @brief Resets the input data block + /// @param nHits Number of hits to reserve + void ResetInputData(ca::HitIndex_t nHits = 0) noexcept; + + /// Pushes back a hit + /// \param hit An ca::Hit object + void PushBackHit(const ca::Hit& hit, int64_t streamId) + { + if (fInputData.fStreamStartIndices.size() == 0 || fLastStreamId != streamId) { // new data stream + fLastStreamId = streamId; + fInputData.fStreamStartIndices.push_back(fInputData.fHits.size()); + // for a case.. it is fixed later in InitData() + fInputData.fStreamStopIndices.push_back(fInputData.fHits.size()); + } + fInputData.fHits.push_back(hit); } - fInputData.fHits.push_back(hit); - } - /// Sets the number of hit keys - /// \param nKeys Number of hit keys - void SetNhitKeys(int nKeys) { fInputData.fNhitKeys = nKeys; } + /// Sets the number of hit keys + /// \param nKeys Number of hit keys + void SetNhitKeys(int nKeys) { fInputData.fNhitKeys = nKeys; } - /// @brief Sets number of active stations - /// @param nStations Number of stations - void SetNofActiveStations(int nStations) { fNofActiveStations = nStations; } + /// @brief Sets number of active stations + /// @param nStations Number of stations + void SetNofActiveStations(int nStations) { fNofActiveStations = nStations; } - /// Sends (moves) input data to the destination reference - /// \param pAlgo Pointer to the L1 tracking algorithm main class - /// \return Success flag - bool SendInputData(L1Algo* pAlgo); + /// @brief Sends (moves) input data to an object (alternative method of data sending) + /// @param destination Destination object of input data + bool SendInputData(InputData& destination); - /// @brief Sends (moves) input data to an object (alternative method of data sending) - /// @param destination Destination object of input data - bool SendInputData(L1InputData& destination); + /// \brief Takes (moves) the instance of the input data object + InputData&& TakeInputData(); - /// \brief Takes (moves) the instance of the input data object - L1InputData&& TakeInputData(); + /// Writes input data object to boost-serialized binary file + /// \param fileName Name of input file + void WriteInputData(const std::string& fileName) const; - /// Writes input data object to boost-serialized binary file - /// \param fileName Name of input file - void WriteInputData(const std::string& fileName) const; + private: + /// @brief Initializes data object + /// + /// Sorts hits by stations (complexity O(n)) and defines bordering hit index for station + void InitData(); -private: - /// @brief Initializes data object - /// - /// Sorts hits by stations (complexity O(n)) and defines bordering hit index for station - void InitData(); - - /// Provides quick QA for input data - /// \tparam Level The level of the checks. The values of the parameter: - /// - 0: no checks will be done - /// - 1: only number of hits and strips as well as validity of hits first and last indexes will be checked - /// - 2: hits sorting is checked - /// - 3: every hit is checked for consistency - /// \note The larger Level corresponds to more precise checks, but is followed by larger time penalty - template<int Level> - bool CheckInputData() const; + /// Provides quick QA for input data + /// \tparam Level The level of the checks. The values of the parameter: + /// - 0: no checks will be done + /// - 1: only number of hits and strips as well as validity of hits first and last indexes will be checked + /// - 2: hits sorting is checked + /// - 3: every hit is checked for consistency + /// \note The larger Level corresponds to more precise checks, but is followed by larger time penalty + template<int Level> + bool CheckInputData() const; - // *************************** - // ** Member variables list ** - // *************************** + // *************************** + // ** Member variables list ** + // *************************** - L1InputData fInputData {}; ///< Object of input data + InputData fInputData {}; ///< Object of input data - int64_t fLastStreamId {-1}; ///< data stream Id of the last hit added - int fNofActiveStations = -1; ///< Number of active stations -}; + int64_t fLastStreamId {-1}; ///< data stream Id of the last hit added + int fNofActiveStations = -1; ///< Number of active stations + }; -// ************************************* -// ** Inline functions implementation ** -// ************************************* + // ************************************* + // ** Inline functions implementation ** + // ************************************* -// --------------------------------------------------------------------------------------------------------------------- -// + // ------------------------------------------------------------------------------------------------------------------- + // -// TODO: Complete this function -template<int Level> -inline bool L1IODataManager::CheckInputData() const -{ - if constexpr (Level == 0) { return true; } // Level = 0 -> do nothing - else if constexpr (Level > 0) { // Level = 1 and higher - // ----- Check if the hits container is not empty ------------------------------------------------------------------ - if (fInputData.fHits.size() == 0) { - LOG(warn) << "L1IODataManager [check input]: Sample contains empty hits, tracking will not be executed"; - return false; - } + // TODO: Complete this function + template<int Level> + inline bool DataManager::CheckInputData() const + { + if constexpr (Level == 0) { return true; } // Level = 0 -> do nothing + else if constexpr (Level > 0) { // Level = 1 and higher + // ----- Check if the hits container is not empty ---------------------------------------------------------------- + if (fInputData.fHits.size() == 0) { + LOG(warn) << "DataManager [check input]: Sample contains empty hits, tracking will not be executed"; + return false; + } - // ----- Checks if the number of hit keys is valid ----------------------------------------------------------------- - if (fInputData.fNhitKeys < 1) { - LOG(error) << "L1IODataManager [check input]: Incorrect number of keys passed (" << fInputData.fNhitKeys - << "), tracking will not be executed"; - return false; - } + // ----- Checks if the number of hit keys is valid --------------------------------------------------------------- + if (fInputData.fNhitKeys < 1) { + LOG(error) << "DataManager [check input]: Incorrect number of keys passed (" << fInputData.fNhitKeys + << "), tracking will not be executed"; + return false; + } - // ----- Checks the indexes of first and last hits in stations - // TODO: Add one of the two following checks for fvStartHitIn + // ----- Checks the indexes of first and last hits in stations + // TODO: Add one of the two following checks for fvStartHitIn - if constexpr (Level > 1) { // Level = 2 and higher - // ----- Checks for hits sorting --------------------------------------------------------------------------------- - // TODO... - if constexpr (Level > 2) { // Level = 3 and higher - // ----- Checks for consistency of the particular hit ---------------------------------------------------------- + if constexpr (Level > 1) { // Level = 2 and higher + // ----- Checks for hits sorting ------------------------------------------------------------------------------- // TODO... + if constexpr (Level > 2) { // Level = 3 and higher + // ----- Checks for consistency of the particular hit -------------------------------------------------------- + // TODO... + } } + return true; } return true; } - return true; -} - +} // namespace cbm::algo::ca -#endif // L1IODataManager_h +#endif // CaDataManager_h diff --git a/algo/ca/core/data/CaInputData.cxx b/algo/ca/core/data/CaInputData.cxx index bafa1c1ba24ad940c6eacb895940de9dfec38309..d0906f06624a6caade2cb68fb989c4214501f375 100644 --- a/algo/ca/core/data/CaInputData.cxx +++ b/algo/ca/core/data/CaInputData.cxx @@ -1,22 +1,23 @@ -/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only Authors: Sergey Gorbunov, Sergei Zharko [committer] */ -/// \file L1InputData.cxx +/// \file CaInputData.cxx /// \brief Structure for input data to the L1 tracking algorithm (implementation) /// \since 08.08.2022 /// \author Sergei Zharko <s.zharko@gsi.de> #include "CaInputData.h" +using cbm::algo::ca::InputData; // --------------------------------------------------------------------------------------------------------------------- // -L1InputData::L1InputData() {} +InputData::InputData() {} // --------------------------------------------------------------------------------------------------------------------- // -L1InputData::L1InputData(const L1InputData& other) +InputData::InputData(const InputData& other) : fHits(other.fHits) , fStreamStartIndices(other.fStreamStartIndices) , fStreamStopIndices(other.fStreamStopIndices) @@ -26,22 +27,22 @@ L1InputData::L1InputData(const L1InputData& other) // --------------------------------------------------------------------------------------------------------------------- // -L1InputData::L1InputData(L1InputData&& other) noexcept { this->Swap(other); } +InputData::InputData(InputData&& other) noexcept { this->Swap(other); } // --------------------------------------------------------------------------------------------------------------------- // -L1InputData& L1InputData::operator=(const L1InputData& other) +InputData& InputData::operator=(const InputData& other) { - if (this != &other) { L1InputData(other).Swap(*this); } + if (this != &other) { InputData(other).Swap(*this); } return *this; } // --------------------------------------------------------------------------------------------------------------------- // -L1InputData& L1InputData::operator=(L1InputData&& other) noexcept +InputData& InputData::operator=(InputData&& other) noexcept { if (this != &other) { - L1InputData tmp(std::move(other)); + InputData tmp(std::move(other)); this->Swap(tmp); } return *this; diff --git a/algo/ca/core/data/CaInputData.h b/algo/ca/core/data/CaInputData.h index 093e07816e400061d99251ecda9a2d8f56123bb0..aeeb08094b8459b32e9db21e629df0377dbc84f6 100644 --- a/algo/ca/core/data/CaInputData.h +++ b/algo/ca/core/data/CaInputData.h @@ -1,14 +1,14 @@ -/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only Authors: Sergey Gorbunov, Sergei Zharko [committer] */ -/// \file L1InputData.h +/// \file CaInputData.h /// \brief Structure for input data to the L1 tracking algorithm (declaration) /// \since 08.08.2022 /// \author Sergei Zharko <s.zharko@gsi.de> -#ifndef L1InputData_h -#define L1InputData_h 1 +#ifndef CaInputData_h +#define CaInputData_h 1 #include <boost/serialization/access.hpp> #include <boost/serialization/array.hpp> @@ -17,129 +17,126 @@ #include "CaHit.h" #include "CaVector.h" -namespace +namespace cbm::algo::ca { - using cbm::algo::ca::Vector; - using namespace cbm::algo; - using namespace cbm::algo::ca; -} // namespace + /// Class InputData represents a block of the input data to the L1 tracking algorithm per event or time slice. + /// Filling of the InputData is carried out with L1IODataManager class + /// + class alignas(constants::misc::Alignment) InputData { + public: + // ************************** + // ** Friend classes list ** + // ************************** -/// Class L1InputData represents a block of the input data to the L1 tracking algorithm per event or time slice. -/// Filling of the L1InputData is carried out with L1IODataManager class -/// -class alignas(constants::misc::Alignment) L1InputData { -public: - // ************************** - // ** Friend classes list ** - // ************************** + friend class DataManager; ///< Class which fills the InputData object for each event or time slice + friend class boost::serialization::access; - friend class L1IODataManager; ///< Class which fills the L1InputData object for each event or time slice - friend class boost::serialization::access; + // *************************** + // ** Member functions list ** + // *************************** - // *************************** - // ** Member functions list ** - // *************************** + // ** Constructors and destructor ** - // ** Constructors and destructor ** + /// Default constructor + InputData(); - /// Default constructor - L1InputData(); + /// Destructor + ~InputData() = default; - /// Destructor - ~L1InputData() = default; + /// Copy constructor + InputData(const InputData& other); - /// Copy constructor - L1InputData(const L1InputData& other); + /// Move constructor + InputData(InputData&&) noexcept; - /// Move constructor - L1InputData(L1InputData&&) noexcept; + /// Copy assignment operator + InputData& operator=(const InputData& other); - /// Copy assignment operator - L1InputData& operator=(const L1InputData& other); + /// Move assignment operator + InputData& operator=(InputData&& other) noexcept; - /// Move assignment operator - L1InputData& operator=(L1InputData&& other) noexcept; + /// Gets hits sample size + ca::HitIndex_t GetSampleSize() const { return fHits.size(); } - /// Gets hits sample size - ca::HitIndex_t GetSampleSize() const { return fHits.size(); } + // ** Accessors ** - // ** Accessors ** + /// Gets number of data streams + int GetNdataStreams() const { return fStreamStartIndices.size(); } - /// Gets number of data streams - int GetNdataStreams() const { return fStreamStartIndices.size(); } + /// Gets reference to hit by its index + /// \param index Index of hit in the hits sample + const ca::Hit& GetHit(ca::HitIndex_t index) const { return fHits[index]; } - /// Gets reference to hit by its index - /// \param index Index of hit in the hits sample - const ca::Hit& GetHit(ca::HitIndex_t index) const { return fHits[index]; } + /// Gets reference to hits vector + const Vector<ca::Hit>& GetHits() const { return fHits; } - /// Gets reference to hits vector - const Vector<ca::Hit>& GetHits() const { return fHits; } + /// Gets number of hits in the hits vector + ca::HitIndex_t GetNhits() const { return fHits.size(); } - /// Gets number of hits in the hits vector - ca::HitIndex_t GetNhits() const { return fHits.size(); } + /// Gets total number of stored keys + int GetNhitKeys() const { return fNhitKeys; } - /// Gets total number of stored keys - int GetNhitKeys() const { return fNhitKeys; } + /// Gets index of the first hit in the sorted hits vector + /// \param iStream Index of the data stream + ca::HitIndex_t GetStreamStartIndex(int iStream) const { return fStreamStartIndices[iStream]; } - /// Gets index of the first hit in the sorted hits vector - /// \param iStream Index of the data stream - ca::HitIndex_t GetStreamStartIndex(int iStream) const { return fStreamStartIndices[iStream]; } + /// Gets index of (the last + 1) hit in the sorted hits vector + /// \param iStream Index of the data stream + ca::HitIndex_t GetStreamStopIndex(int iStream) const { return fStreamStopIndices[iStream]; } - /// Gets index of (the last + 1) hit in the sorted hits vector - /// \param iStream Index of the data stream - ca::HitIndex_t GetStreamStopIndex(int iStream) const { return fStreamStopIndices[iStream]; } + /// Gets n hits for the data stream + /// \param iStream Index of the data stream + ca::HitIndex_t GetStreamNhits(int iStream) const + { + return fStreamStopIndices[iStream] - fStreamStartIndices[iStream]; + } - /// Gets n hits for the data stream - /// \param iStream Index of the data stream - ca::HitIndex_t GetStreamNhits(int iStream) const - { - return fStreamStopIndices[iStream] - fStreamStartIndices[iStream]; - } + private: + /// Swap method + void Swap(InputData& other) noexcept; -private: - /// Swap method - void Swap(L1InputData& other) noexcept; + /// Data serialization method + template<class Archive> + void serialize(Archive& ar, const unsigned int /*versino*/) + { + ar& fHits; + ar& fStreamStartIndices; + ar& fStreamStopIndices; + ar& fNhitKeys; + } - /// Data serialization method - template<class Archive> - void serialize(Archive& ar, const unsigned int /*versino*/) - { - ar& fHits; - ar& fStreamStartIndices; - ar& fStreamStopIndices; - ar& fNhitKeys; - } + // *************************** + // ** Member variables list ** + // *************************** - // *************************** - // ** Member variables list ** - // *************************** + /// @brief Sample of input hits + Vector<ca::Hit> fHits {"InputData::fHits"}; - /// @brief Sample of input hits - Vector<ca::Hit> fHits {"L1InputData::fHits"}; + /// @brief Index of the first hit in the sorted hits vector for a given data stream + Vector<ca::HitIndex_t> fStreamStartIndices {"InputData::fStreamStartIndices"}; + Vector<ca::HitIndex_t> fStreamStopIndices {"InputData::fStreamStopIndices"}; - /// @brief Index of the first hit in the sorted hits vector for a given data stream - Vector<ca::HitIndex_t> fStreamStartIndices {"L1InputData::fStreamStartIndices"}; - Vector<ca::HitIndex_t> fStreamStopIndices {"L1InputData::fStreamStopIndices"}; + /// @brief Number of hit keys used for rejecting fake STS hits + int fNhitKeys = -1; + }; - /// @brief Number of hit keys used for rejecting fake STS hits - int fNhitKeys = -1; -}; + // ******************************************** + // ** Inline member functions initialization ** + // ********************************************* -// ******************************************** -// ** Inline member functions initialization ** -// ********************************************* + // ------------------------------------------------------------------------------------------------------------------- + // + [[gnu::always_inline]] inline void InputData::Swap(InputData& other) noexcept + { + std::swap(fHits, other.fHits); + std::swap(fStreamStartIndices, other.fStreamStartIndices); + std::swap(fStreamStopIndices, other.fStreamStopIndices); + std::swap(fNhitKeys, other.fNhitKeys); + } -// --------------------------------------------------------------------------------------------------------------------- -// -[[gnu::always_inline]] inline void L1InputData::Swap(L1InputData& other) noexcept -{ - std::swap(fHits, other.fHits); - std::swap(fStreamStartIndices, other.fStreamStartIndices); - std::swap(fStreamStopIndices, other.fStreamStopIndices); - std::swap(fNhitKeys, other.fNhitKeys); -} +} // namespace cbm::algo::ca -#endif // L1InputData_h +#endif // InputData_h diff --git a/reco/L1/CbmCaTimeSliceReader.cxx b/reco/L1/CbmCaTimeSliceReader.cxx index ecdaf8af27017525b863acac6f3732009d2fc8df..cc76e90f96b05292d9cda63d01fee9b15be187dd 100644 --- a/reco/L1/CbmCaTimeSliceReader.cxx +++ b/reco/L1/CbmCaTimeSliceReader.cxx @@ -304,9 +304,9 @@ void TimeSliceReader::ReadRecoTracks() // --------------------------------------------------------------------------------------------------------------------- // -void TimeSliceReader::RegisterIODataManager(std::shared_ptr<L1IODataManager>& pIODataManager) +void TimeSliceReader::RegisterIODataManager(std::shared_ptr<ca::DataManager>& pIODataManager) { - LOG_IF(fatal, !pIODataManager.get()) << "TimeSliceReader: passed null pointer as a L1IODataManager instance"; + LOG_IF(fatal, !pIODataManager.get()) << "TimeSliceReader: passed null pointer as a ca::DataManager instance"; fpIODataManager = pIODataManager; } diff --git a/reco/L1/CbmCaTimeSliceReader.h b/reco/L1/CbmCaTimeSliceReader.h index beccd07282ea940d129c95fbc5e1aae8fe36958f..98db0a8cb2dd8e35c2cee26bf25e23c2cf1eee49 100644 --- a/reco/L1/CbmCaTimeSliceReader.h +++ b/reco/L1/CbmCaTimeSliceReader.h @@ -35,9 +35,9 @@ class CbmTimeSlice; -class L1IODataManager; namespace cbm::algo::ca { + class DataManager; class Parameters; } @@ -116,7 +116,7 @@ namespace cbm::ca /// @brief Registers the CA IO data manager instance /// @param pIODataManager Shared pointer to the IO data manager instance /// @note If no container is registered, all related routines are omitted - void RegisterIODataManager(std::shared_ptr<L1IODataManager>& ioDataManager); + void RegisterIODataManager(std::shared_ptr<ca::DataManager>& ioDataManager); /// @brief Register the reconstructed tracks container /// @param vTracks Reference to reconstructed tracks container @@ -182,7 +182,7 @@ namespace cbm::ca ca::Vector<CbmL1HitId>* fpvHitIds = nullptr; ///< Pointer to array of hit index objects ca::Vector<CbmL1HitDebugInfo>* fpvQaHits = nullptr; ///< Pointer to array of debug hits ca::Vector<CbmL1Track>* fpvTracks = nullptr; ///< Pointer to array of reconstructed tracks - std::shared_ptr<L1IODataManager> fpIODataManager = nullptr; ///< Pointer to input data manager + std::shared_ptr<ca::DataManager> fpIODataManager = nullptr; ///< Pointer to input data manager std::shared_ptr<ca::Parameters> fpParameters = nullptr; ///< Pointer to tracking parameters object // Maps of hit indexes: ext -> int diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index 4853609d442a1bb65c0e6c8dd7541f1d8e5f08c6..880fa8405ecb31f7344aa1b92b7659979f8e3ef6 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -103,7 +103,7 @@ CbmL1::CbmL1(const char* name, Int_t verbose, Int_t performance) : FairTask(name default: LOG(info) << "CbmL1: tracking will be run without external data R/W"; break; } - fpIODataManager = std::make_shared<L1IODataManager>(); + fpIODataManager = std::make_shared<ca::DataManager>(); this->DefineSTAPNames(""); diff --git a/reco/L1/CbmL1.h b/reco/L1/CbmL1.h index e4f861c73d941c2c8df3008a6fdef40d49e957eb..2d5bf5321dabe150925899f20b64ec6b9c9ce2c8 100644 --- a/reco/L1/CbmL1.h +++ b/reco/L1/CbmL1.h @@ -430,7 +430,7 @@ private: /// Defines the name of input/output directory [dir] and prefix of the files [pref], which is used to define /// input and output data trees in the reconstruction macro. If the output TTree file has name /// /path/to/[pref].reco.root, the data files will be: - /// [dir]/input_hits/[pref].job[No].L1InputData.dat - hits input files, containing serialized L1InputData objects, + /// [dir]/input_hits/[pref].job[No].ca.input.dat - hits input files, containing serialized ca::InputData objects, /// stored for each job (each call of CbmL1::ReadEvent function) /// [dir]/[pref].L1Parameters.dat - parameters input files, containing serialized L1Parameters object void DefineSTAPNames(const char* dirName); @@ -438,14 +438,14 @@ private: /// Writes initialized L1Parameters object to file "" void WriteSTAPParamObject(); - /// Writes a sample of an L1InputData object to defined directory fSTAPDataDir + /// Writes a sample of an ca::InputData object to defined directory fSTAPDataDir /// \param iJob Number of job, usually is defined by the nCalls of executing function /// \note Creates a file fSTAPDataDir + "/" + fSTAPDataPrefix + "." + TString::Format(kSTAPAlgoIDataSuffix, iJob) void WriteSTAPAlgoInputData(int iJob = 0); void WriteSTAPPerfInputData(); - /// Reads a sample of an L1InputData object from defined directory fSTAPDataDir + /// Reads a sample of an ca::InputData object from defined directory fSTAPDataDir /// \param iJob Number of job, usually is defined by the nCalls of executing function /// \note Reads from a file fSTAPDataDir + "/" + fSTAPDataPrefix + "." + TString::Format(kSTAPAlgoIDataSuffix, iJob) void ReadSTAPParamObject(); @@ -484,7 +484,7 @@ private: ca::InitManager fInitManager; ///< Tracking parameters data manager - std::shared_ptr<L1IODataManager> fpIODataManager = nullptr; ///< Input-output data manager + std::shared_ptr<ca::DataManager> fpIODataManager = nullptr; ///< Input-output data manager //std::unique_ptr<CbmCaMCModule> fpMCModule = nullptr; ///< MC-module for tracking @@ -559,15 +559,15 @@ private: /// Extension for IO of the L1Parameters object static constexpr std::string_view kSTAPParamSuffix = "L1Parameters.dat"; - /// Extension for IO of the L1InputData object - /// \note IO of the L1InputData object is called inside every launch of CbmL1::ReadEvent function. Inside the function + /// Extension for IO of the ca::InputData object + /// \note IO of the ca::InputData object is called inside every launch of CbmL1::ReadEvent function. Inside the function /// there is a static counter, which calculates the job (function call) number. One have to define the name of /// the kSTAPAlgoIDataSuffix containing '%d' control symbol, which is replaced with the current job number. - /// \example The file name with [pref] = auau.mbias.eb.100ev and [suff] = "job%d.L1InputData.dat" for the job - /// number 10 is auau.mbias.eb.100ev.job10.L1InputData.dat - static constexpr std::string_view kSTAPAlgoIDataSuffix = "job%d.L1InputData.dat"; + /// \example The file name with [pref] = auau.mbias.eb.100ev and [suff] = "job%d.ca.input.dat" for the job + /// number 10 is auau.mbias.eb.100ev.job10.ca.input.dat + static constexpr std::string_view kSTAPAlgoIDataSuffix = "job%d.ca.input.dat"; - /// Name of subdirectory for handling L1InputData objects + /// Name of subdirectory for handling ca::InputData objects static constexpr std::string_view kSTAPAlgoIDataDir = "input_hits"; diff --git a/reco/L1/L1Algo/L1Algo.cxx b/reco/L1/L1Algo/L1Algo.cxx index 8f897fe70713dcd9eae7d04d7d7caa47350fa798..12d4b53fb315f3597b54f09ed3c930fd184aec81 100644 --- a/reco/L1/L1Algo/L1Algo.cxx +++ b/reco/L1/L1Algo/L1Algo.cxx @@ -27,7 +27,7 @@ void L1Algo::Finish() { Debugger::Instance().Write(); } // --------------------------------------------------------------------------------------------------------------------- // -void L1Algo::ReceiveInputData(L1InputData&& inputData) +void L1Algo::ReceiveInputData(InputData&& inputData) { // ----- Get input data ---------------------------------------------------------------------------------------------- fInputData = std::move(inputData); diff --git a/reco/L1/L1Algo/L1Algo.h b/reco/L1/L1Algo/L1Algo.h index 8718507e869b01913ab8ac78e1ab0fc2e5891478..d4dc73a350666eb435d27a1c697909e3dd86c5af 100644 --- a/reco/L1/L1Algo/L1Algo.h +++ b/reco/L1/L1Algo/L1Algo.h @@ -149,13 +149,13 @@ public: const Parameters* GetParameters() const { return &fParameters; } /// Receives input data - void ReceiveInputData(L1InputData&& inputData); + void ReceiveInputData(InputData&& inputData); /// Receives tracking parameters void ReceiveParameters(Parameters&& parameters); /// Gets pointer to input data object for external access - const L1InputData& GetInputData() const { return fInputData; } + const InputData& GetInputData() const { return fInputData; } inline int PackIndex(const int& a, const int& b, const int& c); @@ -279,8 +279,8 @@ private: // ** Member variables list ** // *************************** - Parameters fParameters; ///< Object of L1Algo parameters class - L1InputData fInputData; ///< Tracking input data + Parameters fParameters; ///< Object of L1Algo parameters class + InputData fInputData; ///< Tracking input data Vector<unsigned char> fvHitKeyFlags { "L1Algo::fvHitKeyFlags"}; ///< List of key flags: has been this hit or cluster already used diff --git a/reco/L1/qa/CbmCaOutputQa.cxx b/reco/L1/qa/CbmCaOutputQa.cxx index 75152fdbe47a60925c51f7d5220696f5a2fed190..66a1dbab496c21be917e3a2894d125c3c11aba1a 100644 --- a/reco/L1/qa/CbmCaOutputQa.cxx +++ b/reco/L1/qa/CbmCaOutputQa.cxx @@ -431,7 +431,7 @@ InitStatus OutputQa::InitDataBranches() << "via OutputQa::ReadParameters(filename) from the qa macro"; // Initialize IO data manager - if (!fpDataManager.get()) { fpDataManager = std::make_shared<L1IODataManager>(); } + if (!fpDataManager.get()) { fpDataManager = std::make_shared<ca::DataManager>(); } // Initialize time slice reader instance fpTSReader->SetTrackingMode(fTrackingMode); diff --git a/reco/L1/qa/CbmCaOutputQa.h b/reco/L1/qa/CbmCaOutputQa.h index c8bf506a131a8c0ebae1a96cb0e20d01538f4b3f..8908894b4af82783bd0e318b3fd01ab4c0462057 100644 --- a/reco/L1/qa/CbmCaOutputQa.h +++ b/reco/L1/qa/CbmCaOutputQa.h @@ -265,7 +265,7 @@ namespace cbm::ca std::unique_ptr<TimeSliceReader> fpTSReader = nullptr; ///< Reader of the time slice std::shared_ptr<MCModule> fpMCModule = nullptr; ///< MC module - std::shared_ptr<L1IODataManager> fpDataManager = nullptr; ///< Data manager + std::shared_ptr<ca::DataManager> fpDataManager = nullptr; ///< Data manager std::shared_ptr<tools::Debugger> fpDebugger = nullptr; ///< Debugger std::shared_ptr<ca::Parameters> fpParameters = nullptr; ///< Tracking parameters object