diff --git a/algo/CMakeLists.txt b/algo/CMakeLists.txt index b59f7c99b9c55177be8928503fbbb8c0e8cfb7db..ca5a15094d71830914dfdf0d1733d61537767a2a 100644 --- a/algo/CMakeLists.txt +++ b/algo/CMakeLists.txt @@ -116,8 +116,6 @@ set(SRCS detectors/bmon/ReadoutConfig.cxx detectors/bmon/Unpack.cxx detectors/bmon/UnpackMS.cxx - detectors/bmon/config/ReadoutPars_mCBM2022.cxx - detectors/bmon/config/ReadoutPars_mCBM2024.cxx detectors/trd/Cluster.cxx detectors/trd/Clusterizer.cxx detectors/trd/Cluster2D.cxx diff --git a/algo/detectors/bmon/ReadoutConfig.cxx b/algo/detectors/bmon/ReadoutConfig.cxx index 2412dc88ce506553096e1104e7693b5a44d3f9ec..4d5b79bf0190abc5d54870fbfac573bedf73d656 100644 --- a/algo/detectors/bmon/ReadoutConfig.cxx +++ b/algo/detectors/bmon/ReadoutConfig.cxx @@ -6,7 +6,6 @@ #include "CbmTofAddress.h" #include "Exceptions.h" -#include "config/ReadoutPars.h" #include "gDpbMessv100.h" #include <bitset> @@ -20,7 +19,7 @@ using namespace std; namespace cbm::algo::bmon { // --- Constructor ------------------------------------------------------------------ - ReadoutConfig::ReadoutConfig(const config::ReadoutPars& pars) { Init(pars); } + ReadoutConfig::ReadoutConfig(const ReadoutSetup& pars) { Init(pars); } // ------------------------------------------------------------------------------------ // --- Destructor ----------------------------------------------------------------- @@ -62,7 +61,7 @@ namespace cbm::algo::bmon } // ------------------------------------------------------------------------------------ - void ReadoutConfig::Init(const config::ReadoutPars& pars) + void ReadoutConfig::Init(const ReadoutSetup& pars) { // Constructing the map (equipmentId, eLink, channel) -> (TOF address) const uint32_t numChanPerComp = pars.NChansPerComponent(); @@ -98,7 +97,7 @@ namespace cbm::algo::bmon } // ------------------------------------------------------------------------- - void ReadoutConfig::BuildChannelsUidMap(const config::ReadoutPars& pars) + void ReadoutConfig::BuildChannelsUidMap(const ReadoutSetup& pars) { const uint32_t numAsics = pars.NComponents() * pars.nFebsPerComponent * pars.nAsicsPerFeb; const uint32_t numChan = numAsics * pars.nChannelsPerAsic; @@ -197,7 +196,7 @@ namespace cbm::algo::bmon } // ------------------------------------------------------------------------- - void ReadoutConfig::BuildChannelsUidMapBmon(uint32_t& uCh, uint32_t uGbtx, const config::ReadoutPars& pars) + void ReadoutConfig::BuildChannelsUidMapBmon(uint32_t& uCh, uint32_t uGbtx, const ReadoutSetup& pars) { const auto& crob = pars.crobs.at(uGbtx); L_(debug) << " Map diamond " << crob.moduleId << " at GBTX " << uGbtx << " - uCh = " << uCh; @@ -220,7 +219,7 @@ namespace cbm::algo::bmon } // ------------------------------------------------------------------------- - void ReadoutConfig::BuildChannelsUidMapBmon_2022(uint32_t& uCh, uint32_t uGbtx, const config::ReadoutPars& pars) + void ReadoutConfig::BuildChannelsUidMapBmon_2022(uint32_t& uCh, uint32_t uGbtx, const ReadoutSetup& pars) { const auto& crob = pars.crobs.at(uGbtx); L_(debug) << " Map 2022 diamond " << crob.moduleId << " at GBTX " << uGbtx << " - uCh = " << uCh; diff --git a/algo/detectors/bmon/ReadoutConfig.h b/algo/detectors/bmon/ReadoutConfig.h index 2d4b8a5894e53ef1a37f79e0de4b6c01e5ecbd5f..64496ead00851655daedcd66e6b480a1dab0f786 100644 --- a/algo/detectors/bmon/ReadoutConfig.h +++ b/algo/detectors/bmon/ReadoutConfig.h @@ -2,27 +2,67 @@ SPDX-License-Identifier: GPL-3.0-only Authors: Dominik Smith [committer] */ -#ifndef ALGO_DETECTORS_BMON_READOUTCONFIG_H -#define ALGO_DETECTORS_BMON_READOUTCONFIG_H +#pragma once + +#include "Definitions.h" +#include "yaml/Property.h" +#include "yaml/Yaml.h" #include <cstddef> #include <cstdint> #include <map> #include <vector> -namespace cbm::algo::bmon::config -{ - struct CROB; - struct ReadoutPars; -} // namespace cbm::algo::bmon::config - namespace cbm::algo::bmon { + + struct ReadoutSetup { + + struct CROB { + i32 moduleId; + i32 rpcType; + i32 rpcSide; + i32 nRPC; + + CBM_YAML_PROPERTIES( + yaml::Property(&CROB::moduleId, "moduleId", "Unique ID of module the CROB resides in"), + yaml::Property(&CROB::rpcType, "rpcType", "add explanation."), + yaml::Property(&CROB::rpcSide, "rpcSide", "add explanation."), + yaml::Property(&CROB::nRPC, "nRPC", "number of RPCs.")); + }; + + i32 nFebsPerComponent; + i32 nAsicsPerFeb; + i32 nChannelsPerAsic; + i32 nCrobPerComponent; + std::vector<CROB> crobs; + std::vector<u16> eqIds; + + CBM_YAML_PROPERTIES(yaml::Property(&ReadoutSetup::nFebsPerComponent, "nFebsPerComponent", "Number of FEBs per component"), + yaml::Property(&ReadoutSetup::nAsicsPerFeb, "nAsicsPerFeb", "Number of ASICs per FEB"), + yaml::Property(&ReadoutSetup::nChannelsPerAsic, "nChannelsPerAsic", "Number of channels per ASIC"), + yaml::Property(&ReadoutSetup::nCrobPerComponent, "nCrobPerComponent", "Number of CROBs per component"), + yaml::Property(&ReadoutSetup::crobs, "crobs", "Crobs", {}, YAML::Flow), + yaml::Property(&ReadoutSetup::eqIds, "eqIds", "Array to hold the unique IDs (equipment ID) for all BMON DPBs" , YAML::Flow, YAML::Hex)); + + size_t NComponents() const { return eqIds.size(); } + size_t NCROBs() const { return crobs.size(); } + i32 NFebsPerCrob() const { return nFebsPerComponent / nCrobPerComponent; } + i32 NChansPerFeb() const { return nAsicsPerFeb * nChannelsPerAsic; } + i32 NChansPerComponent() const { return nChannelsPerAsic * NElinksPerComponent(); } + i32 NElinksPerCrob() const { return nAsicsPerFeb * NFebsPerCrob(); } + i32 NElinksPerComponent() const { return NElinksPerCrob() * nCrobPerComponent; } + + bool CheckBmonComp(uint32_t uCompId) const { return ((uCompId & 0xFFF0) == 0xABF0); } + bool CheckInnerComp(uint32_t uCompId) const { return ((uCompId & 0xFFF0) == 0xBBC0); } + }; + + class ReadoutConfig { public: /** @brief Constructor **/ - ReadoutConfig(const config::ReadoutPars& pars); + ReadoutConfig(const ReadoutSetup& pars); /** @brief Destructor **/ virtual ~ReadoutConfig(); @@ -51,15 +91,13 @@ namespace cbm::algo::bmon std::map<uint16_t, std::vector<std::vector<uint32_t>>> fReadoutMap = {}; /** @brief Initialisation of readout map **/ - void Init(const config::ReadoutPars& pars); + void Init(const ReadoutSetup& pars); std::vector<int32_t> fviRpcChUId = {}; ///< UID/address for each channel, build from type, side and module - void BuildChannelsUidMap(const config::ReadoutPars& pars); - void BuildChannelsUidMapBmon(uint32_t& uCh, uint32_t uGbtx, const config::ReadoutPars& pars); - void BuildChannelsUidMapBmon_2022(uint32_t& uCh, uint32_t uGbtx, const config::ReadoutPars& pars); + void BuildChannelsUidMap(const ReadoutSetup& pars); + void BuildChannelsUidMapBmon(uint32_t& uCh, uint32_t uGbtx, const ReadoutSetup& pars); + void BuildChannelsUidMapBmon_2022(uint32_t& uCh, uint32_t uGbtx, const ReadoutSetup& pars); }; } // namespace cbm::algo::bmon - -#endif //ALGO_DETECTORS_BMON_READOUTCONFIG_H diff --git a/algo/detectors/bmon/config/ReadoutPars.h b/algo/detectors/bmon/config/ReadoutPars.h deleted file mode 100644 index 81832fab2c699097153620d8762d7b14e8d99688..0000000000000000000000000000000000000000 --- a/algo/detectors/bmon/config/ReadoutPars.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Pierre-Alain Loizeau [committer], Felix Weiglhofer, Dominik Smith */ -#pragma once - -#include "Definitions.h" - -#include <vector> - -namespace cbm::algo::bmon::config -{ - - struct CROB { - i32 moduleId; - i32 rpcType; - i32 rpcSide; - i32 nRPC; - }; - - struct ReadoutPars { - - static ReadoutPars MakeMCBM2022(); - static ReadoutPars MakeMCBM2024(); - - i32 nFebsPerComponent; - i32 nAsicsPerFeb; - i32 nChannelsPerAsic; - i32 nCrobPerComponent; - - std::vector<CROB> crobs; - size_t NCROBs() const { return crobs.size(); } - - // Array to hold the unique IDs (equipment ID) for all TOF DPBs - std::vector<u16> eqIds; - size_t NComponents() const { return eqIds.size(); } - - i32 NFebsPerCrob() const { return nFebsPerComponent / nCrobPerComponent; } - i32 NChansPerFeb() const { return nAsicsPerFeb * nChannelsPerAsic; } - i32 NChansPerComponent() const { return nChannelsPerAsic * NElinksPerComponent(); } - i32 NElinksPerCrob() const { return nAsicsPerFeb * NFebsPerCrob(); } - i32 NElinksPerComponent() const { return NElinksPerCrob() * nCrobPerComponent; } - - bool CheckBmonComp(uint32_t uCompId) const { return ((uCompId & 0xFFF0) == 0xABF0); } - bool CheckInnerComp(uint32_t uCompId) const { return ((uCompId & 0xFFF0) == 0xBBC0); } - }; - -} // namespace cbm::algo::bmon::config diff --git a/algo/detectors/bmon/config/ReadoutPars_mCBM2022.cxx b/algo/detectors/bmon/config/ReadoutPars_mCBM2022.cxx deleted file mode 100644 index e0e1647f946984160738d314a0bc1d03b979b905..0000000000000000000000000000000000000000 --- a/algo/detectors/bmon/config/ReadoutPars_mCBM2022.cxx +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Pierre-Alain Loizeau [committer], Felix Weiglhofer, Dominik Smith */ -#include "Exceptions.h" -#include "ReadoutPars.h" - -using namespace cbm::algo::bmon::config; - -ReadoutPars ReadoutPars::MakeMCBM2022() -{ - // This here refers to the mCBM 2022 and mCBM 2024 Au setups. - // Taken from CbmMcbm2018TofPar in combination with macro/beamtime/mcbm2022/mBmonCriPar.par - - ReadoutPars pars; - - pars.nFebsPerComponent = 10; - pars.nAsicsPerFeb = 8; - pars.nChannelsPerAsic = 4; - pars.nCrobPerComponent = 2; - - constexpr int NumCrob = 8; - - // Module Identifier connected to Gbtx link, has to match geometry - const int32_t moduleId[NumCrob] = {0, -1, 0, -1, 0, -1, 0, -1}; - - // type of Rpcs connected to Gbtx link - const int32_t rpcType[NumCrob] = {99, -1, 99, -1, 99, -1, 99, -1}; - - // side of Rpcs connected to Gbtx link, i.e. 0 or 1 - const int32_t rpcSide[NumCrob] = {0, 0, 0, 0, 0, 0, 0, 0}; - - // number of Rpcs connected to Gbtx link, i.e. 3 or 5 - const int32_t numRpc[NumCrob] = {1, 0, 1, 0, 1, 0, 1, 0}; - - for (int i = 0; i < NumCrob; ++i) { - pars.crobs.push_back({moduleId[i], rpcType[i], rpcSide[i], numRpc[i]}); - } - - pars.eqIds = {0xabf3, 0xabf2, 0xabf1, 0xabf0}; - - return pars; -} diff --git a/algo/detectors/bmon/config/ReadoutPars_mCBM2024.cxx b/algo/detectors/bmon/config/ReadoutPars_mCBM2024.cxx deleted file mode 100644 index 0e24dc068177b2371b51e52e7c2119cd3f80096e..0000000000000000000000000000000000000000 --- a/algo/detectors/bmon/config/ReadoutPars_mCBM2024.cxx +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Pierre-Alain Loizeau [committer], Felix Weiglhofer, Dominik Smith */ -#include "Exceptions.h" -#include "ReadoutPars.h" - -using namespace cbm::algo::bmon::config; - -ReadoutPars ReadoutPars::MakeMCBM2024() -{ - // This here refers to the mCBM 2024 setups. - // Taken from CbmMcbm2018TofPar in combination with macro/beamtime/mcbm2024/mBmonCriPar - - ReadoutPars pars; - - pars.nFebsPerComponent = 10; - pars.nAsicsPerFeb = 8; - pars.nChannelsPerAsic = 4; - pars.nCrobPerComponent = 2; - - constexpr int NumCrob = 10; - - // Module Identifier connected to Gbtx link, has to match geometry - const int32_t moduleId[NumCrob] = {0, -1, 0, -1, 0, -1, 0, -1, 0, -1}; - - // type of Rpcs connected to Gbtx link - const int32_t rpcType[NumCrob] = {99, -1, 99, -1, 99, -1, 99, -1, 99, -1}; - - // side of Rpcs connected to Gbtx link, i.e. 0 or 1 - const int32_t rpcSide[NumCrob] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 0}; - - // number of Rpcs connected to Gbtx link, i.e. 3 or 5 - const int32_t numRpc[NumCrob] = {1, 0, 1, 0, 1, 0, 1, 0, 1, 0}; - - for (int i = 0; i < NumCrob; ++i) { - pars.crobs.push_back({moduleId[i], rpcType[i], rpcSide[i], numRpc[i]}); - } - - pars.eqIds = {0xabf0, 0xabf1, 0xabf2, 0xabf3, 0xabf4}; - - return pars; -} diff --git a/algo/global/ParFiles.cxx b/algo/global/ParFiles.cxx index a0809d7d70c8e71822fea5205178b64ad1cd3af1..20c753273116d030635263312d3598de33ac249a 100644 --- a/algo/global/ParFiles.cxx +++ b/algo/global/ParFiles.cxx @@ -22,6 +22,8 @@ ParFiles::ParFiles(uint32_t runId) switch (setup) { case Setup::mCBM2022: + bmon.readout = "BmonReadout_mcbm2022.yaml"; + sts.readout = "StsReadout_mcbm2022.yaml"; sts.chanMask = "StsChannelMaskSet_mcbm2022.yaml"; sts.walkMap = "StsWalkMap_mcbm2022.yaml"; @@ -40,6 +42,8 @@ ParFiles::ParFiles(uint32_t runId) break; case Setup::mCBM2024_03: + bmon.readout = "BmonReadout_mcbm2024.yaml"; + sts.readout = "StsReadout_mcbm2024.yaml"; sts.chanMask = "StsChannelMaskSet_mcbm2024.yaml"; sts.walkMap = "StsWalkMap_mcbm2024.yaml"; @@ -58,6 +62,8 @@ ParFiles::ParFiles(uint32_t runId) break; case Setup::mCBM2024_05: + bmon.readout = "BmonReadout_mcbm2024.yaml"; + sts.readout = "StsReadout_mcbm2024.yaml"; sts.chanMask = "StsChannelMaskSet_mcbm2024.yaml"; sts.walkMap = "StsWalkMap_mcbm2024.yaml"; diff --git a/algo/global/ParFiles.h b/algo/global/ParFiles.h index 92bbd4717abcc13ee813b98ee033b8373efecabc..9411227464caa93dbf8a2945837aef35b521e6de 100644 --- a/algo/global/ParFiles.h +++ b/algo/global/ParFiles.h @@ -24,6 +24,10 @@ namespace cbm::algo Setup setup; + struct { + fs::path readout; + } bmon; + struct { fs::path readout; fs::path chanMask; diff --git a/algo/global/Reco.cxx b/algo/global/Reco.cxx index 5f67d0986a85a30cfc69349c9264596d041ecd05..9a09c0f93b4f7a88e8e7964a9fe007971a776425 100644 --- a/algo/global/Reco.cxx +++ b/algo/global/Reco.cxx @@ -11,8 +11,8 @@ #include "ParFiles.h" #include "StsDigiQa.h" #include "TrackingSetup.h" +#include "bmon/ReadoutConfig.h" #include "bmon/Unpack.h" -#include "bmon/config/ReadoutPars.h" #include "ca/TrackingChain.h" #include "ca/core/data/CaTrack.h" #include "compat/OpenMP.h" @@ -103,8 +103,9 @@ void Reco::Init(const Options& opts) // Unpackers if (Opts().Has(Subsystem::BMON) && Opts().Has(Step::Unpack)) { - bmon::ReadoutConfig cfg{2941 <= Opts().RunId() ? bmon::config::ReadoutPars::MakeMCBM2024() - : bmon::config::ReadoutPars::MakeMCBM2022()}; + bmon::ReadoutSetup readoutSetup = + yaml::ReadFromFile<bmon::ReadoutSetup>(Opts().ParamsDir() / parFiles.bmon.readout); + bmon::ReadoutConfig cfg{readoutSetup}; fBmonUnpack = std::make_unique<bmon::Unpack>(cfg); } diff --git a/reco/tasks/CbmTaskUnpack.cxx b/reco/tasks/CbmTaskUnpack.cxx index 6a9a347a265f453b7231a08755740f4e886f90b9..e6a26d5e5a4402e4ef79347239d34ed10fb55cca 100644 --- a/reco/tasks/CbmTaskUnpack.cxx +++ b/reco/tasks/CbmTaskUnpack.cxx @@ -19,7 +19,7 @@ #include "CbmTrdParSpadic.h" #include "MicrosliceDescriptor.hpp" #include "System.hpp" -#include "bmon/config/ReadoutPars.h" +#include "bmon/ReadoutConfig.h" #include "sts/ChannelMaskSet.h" #include "tof/ReadoutConfig.h" #include "yaml/Yaml.h" @@ -167,8 +167,9 @@ InitStatus CbmTaskUnpack::Init() // ---- Initialize unpacker - auto bmonReadoutPars = bmon::config::ReadoutPars::MakeMCBM2022(); - fBmonUnpack = std::make_unique<bmon::Unpack>(bmon::ReadoutConfig{bmonReadoutPars}); + std::string bmonReadoutFile = Form("%s/parameters/online/BmonReadout_mcbm2022.yaml", std::getenv("VMCWORKDIR")); + auto bmonReadoutPars = yaml::ReadFromFile<bmon::ReadoutSetup>(bmonReadoutFile); + fBmonUnpack = std::make_unique<bmon::Unpack>(bmon::ReadoutConfig{bmonReadoutPars}); fMuchUnpack = std::make_unique<much::Unpack>(much::ReadoutConfig{}); fRichUnpack = std::make_unique<rich::Unpack>(rich::ReadoutConfig{});