diff --git a/algo/detectors/tof/Hitfind.cxx b/algo/detectors/tof/Hitfind.cxx index 6445a02f85cd8586c860355409d05e67f10248f6..251c38b006d44b7cae6fbf63724d24a49df560ef 100644 --- a/algo/detectors/tof/Hitfind.cxx +++ b/algo/detectors/tof/Hitfind.cxx @@ -14,6 +14,67 @@ using fles::Subsystem; namespace cbm::algo::tof { + // ----- Constructor ------------------------------------------------------ + Hitfind::Hitfind(tof::HitfindSetup setup) + { + //Number of SMs per super module type + fNbSm = setup.NbSm; + + //Number of RPCs per super module type + fNbRpc = setup.NbRpc; + + //Prepare digi storage + fStorDigi.resize(fNbSm.size()); + + // Create one algorithm per RPC for TOF and configure it with parametersa + for (uint32_t SmType = 0; SmType < fNbSm.size(); SmType++) { + + int32_t NbSm = fNbSm[SmType]; + int32_t NbRpc = fNbRpc[SmType]; + fStorDigi[SmType].resize(NbSm * NbRpc); + + for (int32_t Sm = 0; Sm < NbSm; Sm++) { + for (int32_t Rpc = 0; Rpc < NbRpc; Rpc++) { + + std::unique_ptr<cbm::algo::tof::ClusterizerRpcPar> par(new cbm::algo::tof::ClusterizerRpcPar()); + + HitfindSetup::Rpc rpcPar = setup.rpcs[SmType][Sm * NbRpc + Rpc]; + par->fDeadStrips = rpcPar.deadStrips; + par->fPosYMaxScal = rpcPar.posYMaxScal; + par->fdMaxTimeDist = rpcPar.maxTimeDist; + par->fdMaxSpaceDist = rpcPar.maxSpaceDist; + par->fSigVel = rpcPar.sigVel; + par->fCPTOffYBinWidth = rpcPar.CPTOffYBinWidth; + par->fCPTOffY = rpcPar.CPTOffY; + par->fCPTOffYRange = rpcPar.CPTOffYRange; + par->fTimeRes = rpcPar.timeRes; + + //geometry information, can in principle be done channel-wise but not needed for now + const double* tra_ptr = rpcPar.cell.translation.data(); + const double* rot_ptr = rpcPar.cell.rotation.data(); + + //channel parameters + int32_t NbChan = rpcPar.chanPar.size(); + par->fChanPar.resize(NbChan); + + for (int32_t Ch = 0; Ch < NbChan; Ch++) { + HitfindSetup::Channel chanPar = rpcPar.chanPar[Ch]; + par->fChanPar[Ch].address = chanPar.address; + par->fChanPar[Ch].cell.pos = ROOT::Math::XYZVector(tra_ptr[0], tra_ptr[1], tra_ptr[2]); + par->fChanPar[Ch].cell.rotation = ROOT::Math::Rotation3D(&rot_ptr[0], &rot_ptr[9]); + par->fChanPar[Ch].cell.sizeX = rpcPar.cell.sizeX; + par->fChanPar[Ch].cell.sizeY = rpcPar.cell.sizeY; + } + fAlgo[SmType][Sm * NbRpc + Rpc].SetParams(std::move(par)); + } + } + } + L_(info) << "--- Configured hitfinder algorithms for TOF."; + L_(info) << "=================================================="; + } + // ---------------------------------------------------------------------------- + + // ----- Execution ------------------------------------------------------- Hitfind::resultType Hitfind::operator()(gsl::span<CbmTofDigi> digiIn) { @@ -101,65 +162,4 @@ namespace cbm::algo::tof } // ---------------------------------------------------------------------------- - - // ----- Initialisation --------------------------------------------------- - void Hitfind::Init() - { - //Number of SMs per super module type - fNbSm = fTofConfig.NbSm; - - //Number of RPCs per super module type - fNbRpc = fTofConfig.NbRpc; - - //Prepare digi storage - fStorDigi.resize(fNbSm.size()); - - // Create one algorithm per RPC for TOF and configure it with parametersa - for (uint32_t SmType = 0; SmType < fNbSm.size(); SmType++) { - - int32_t NbSm = fNbSm[SmType]; - int32_t NbRpc = fNbRpc[SmType]; - fStorDigi[SmType].resize(NbSm * NbRpc); - - for (int32_t Sm = 0; Sm < NbSm; Sm++) { - for (int32_t Rpc = 0; Rpc < NbRpc; Rpc++) { - - std::unique_ptr<cbm::algo::tof::ClusterizerRpcPar> par(new cbm::algo::tof::ClusterizerRpcPar()); - - HitfindSetup::Rpc rpcPar = fTofConfig.rpcs[SmType][Sm * NbRpc + Rpc]; - par->fDeadStrips = rpcPar.deadStrips; - par->fPosYMaxScal = rpcPar.posYMaxScal; - par->fdMaxTimeDist = rpcPar.maxTimeDist; - par->fdMaxSpaceDist = rpcPar.maxSpaceDist; - par->fSigVel = rpcPar.sigVel; - par->fCPTOffYBinWidth = rpcPar.CPTOffYBinWidth; - par->fCPTOffY = rpcPar.CPTOffY; - par->fCPTOffYRange = rpcPar.CPTOffYRange; - par->fTimeRes = rpcPar.timeRes; - - //geometry information, can in principle be done channel-wise but not needed for now - const double* tra_ptr = rpcPar.cell.translation.data(); - const double* rot_ptr = rpcPar.cell.rotation.data(); - - //channel parameters - int32_t NbChan = rpcPar.chanPar.size(); - par->fChanPar.resize(NbChan); - - for (int32_t Ch = 0; Ch < NbChan; Ch++) { - HitfindSetup::Channel chanPar = rpcPar.chanPar[Ch]; - par->fChanPar[Ch].address = chanPar.address; - par->fChanPar[Ch].cell.pos = ROOT::Math::XYZVector(tra_ptr[0], tra_ptr[1], tra_ptr[2]); - par->fChanPar[Ch].cell.rotation = ROOT::Math::Rotation3D(&rot_ptr[0], &rot_ptr[9]); - par->fChanPar[Ch].cell.sizeX = rpcPar.cell.sizeX; - par->fChanPar[Ch].cell.sizeY = rpcPar.cell.sizeY; - } - fAlgo[SmType][Sm * NbRpc + Rpc].SetParams(std::move(par)); - } - } - } - L_(info) << "--- Configured hitfinder algorithms for TOF."; - L_(info) << "=================================================="; - } - // ---------------------------------------------------------------------------- - } // namespace cbm::algo::tof diff --git a/algo/detectors/tof/Hitfind.h b/algo/detectors/tof/Hitfind.h index 995b9bdb105a1b10d46dd2a2a4931ff0a28ba95d..fcab40e3964e2ca3715050dd93fa0c1fe047028f 100644 --- a/algo/detectors/tof/Hitfind.h +++ b/algo/detectors/tof/Hitfind.h @@ -61,19 +61,12 @@ namespace cbm::algo::tof **/ resultType operator()(gsl::span<CbmTofDigi> digiIn); - /** @brief Default constructor **/ - Hitfind() {}; + /** @brief Constructor **/ + Hitfind(tof::HitfindSetup); /** @brief Destructor **/ ~Hitfind() {}; - /** @brief Parameters for TOF hitfinders **/ - tof::HitfindSetup fTofConfig {}; - - /** @brief Initialize hitfinder and fill parameters from config object - **/ - void Init(); - private: // members /** @brief TOF hitfinders **/ std::map<uint32_t, std::map<uint32_t, tof::Clusterizer>> fAlgo = {}; //[nbType][nbSm*nbRpc] diff --git a/algo/detectors/tof/HitfinderChain.cxx b/algo/detectors/tof/HitfinderChain.cxx index 9faaa9e6009b23b0c165a0fa12e5208e968f6547..22fc90eab404fe171bf67a474d789c179643c7b5 100644 --- a/algo/detectors/tof/HitfinderChain.cxx +++ b/algo/detectors/tof/HitfinderChain.cxx @@ -10,10 +10,8 @@ using namespace cbm::algo::tof; void HitfinderChain::Init() { - auto setup = config::ReadFromFile<HitfindSetup>(Opts().ParamsDir() / "TofHitfinderPar.yaml"); - fHitfind = std::make_unique<Hitfind>(); - fHitfind->fTofConfig = setup; - fHitfind->Init(); + auto setup = config::ReadFromFile<HitfindSetup>(Opts().ParamsDir() / "TofHitfinderPar.yaml"); + fHitfind = std::make_unique<Hitfind>(setup); } HitfinderChain::ReturnType HitfinderChain::Run(gsl::span<CbmTofDigi> digis) diff --git a/reco/tasks/CbmTaskTofClusterizer.cxx b/reco/tasks/CbmTaskTofClusterizer.cxx index 2a58a0ac076c55d7fd9f68c7af72027843c0dc79..2e979e2be8972921f233cec5f7f77c3247ccccb4 100644 --- a/reco/tasks/CbmTaskTofClusterizer.cxx +++ b/reco/tasks/CbmTaskTofClusterizer.cxx @@ -310,8 +310,8 @@ bool CbmTaskTofClusterizer::RegisterOutputs() bool CbmTaskTofClusterizer::InitAlgos() { // Read hitfinder parameters and initialize algo - fAlgo.fTofConfig = cbm::algo::config::ReadFromFile<cbm::algo::tof::HitfindSetup>("TofHitfinderPar.yaml"); - fAlgo.Init(); + fAlgo = std::make_unique<cbm::algo::tof::Hitfind>( + cbm::algo::config::ReadFromFile<cbm::algo::tof::HitfindSetup>("TofHitfinderPar.yaml")); // Read calibration parameters pass to algo fCalibrate.fTofConfig = cbm::algo::config::ReadFromFile<cbm::algo::tof::CalibrateSetup>("TofCalibratePar.yaml"); @@ -353,7 +353,7 @@ bool CbmTaskTofClusterizer::BuildClusters() *fTofCalDigiVec = fCalibrate(fTofDigiVec).first; //Call cluster finder - auto clusterOut = fAlgo(*fTofCalDigiVec); + auto clusterOut = (*fAlgo)(*fTofCalDigiVec); auto& clusters = std::get<0>(clusterOut); auto& indices = std::get<2>(clusterOut); size_t indexOffset = 0; diff --git a/reco/tasks/CbmTaskTofClusterizer.h b/reco/tasks/CbmTaskTofClusterizer.h index b4996cc2c33e7b74a971282c4b65778c968a45ec..78fb5059bcc49f1848946e1a5d6ad8da7c1750fb 100644 --- a/reco/tasks/CbmTaskTofClusterizer.h +++ b/reco/tasks/CbmTaskTofClusterizer.h @@ -128,7 +128,7 @@ private: bool InitAlgos(); // Hit finder algo - cbm::algo::tof::Hitfind fAlgo; + std::unique_ptr<cbm::algo::tof::Hitfind> fAlgo; // Calibrator algo cbm::algo::tof::Calibrate fCalibrate;