Skip to content
Snippets Groups Projects
Commit b3979466 authored by Sergei Zharko's avatar Sergei Zharko
Browse files

online: moving TrackingSetup (former SetupInterface) initialization to the...

online: moving TrackingSetup (former SetupInterface) initialization to the Reco.cxx, since it should be used by the CbmEventSelector as well
to determine the TOF layer index.
parent b04f1afa
No related branches found
No related tags found
1 merge request!1766online: tracking station ID in tof/HitfindSetup; TrackingSetup class
......@@ -146,7 +146,7 @@ set(SRCS
qa/PadConfig.cxx
qa/QaData.cxx
qa/unpack/StsDigiQa.cxx
ca/SetupInterface.cxx
ca/TrackingSetup.cxx
ca/TrackingChain.cxx
ca/qa/CaInputQa.cxx
ca/qa/CaOutputQa.cxx
......
......@@ -49,9 +49,10 @@ TrackingChain::TrackingChain(std::shared_ptr<HistogramSender> histoSender)
//
void TrackingChain::Init()
{
// ------ Initialize setup interface
fSetup.SetContext(this->GetContext());
fSetup.Init();
if (fpSetup.get() == nullptr) {
throw std::runtime_error("Tracking Chain: TrackingSetup object was not registered");
}
// ------ Read tracking chain parameters from the config
fConfig = yaml::ReadFromFile<TrackingChainConfig>(Opts().ParamsDir() / "TrackingChainConfig.yaml");
......@@ -75,6 +76,11 @@ void TrackingChain::Init()
auto parameters = manager.TakeParameters();
L_(info) << "Tracking Chain: parameters object: \n" << parameters.ToString(1) << '\n';
// ------ Used detector subsystem flags
fbDetUsed.fill(false);
fbDetUsed[EDetectorID::Sts] = Opts().Has(fles::Subsystem::STS) && parameters.IsActive(EDetectorID::Sts);
fbDetUsed[EDetectorID::Tof] = Opts().Has(fles::Subsystem::TOF) && parameters.IsActive(EDetectorID::Tof);
// ------ Initialize CA framework
fCaMonitor.Reset();
fCaFramework.SetNofThreads(Opts().NumOMPThreads() == std::nullopt ? 1 : *(Opts().NumOMPThreads()));
......@@ -138,8 +144,12 @@ void TrackingChain::PrepareInput(Input_t recoResults)
fCaDataManager.ResetInputData(nHitsTot);
faHitExternalIndices.clear();
faHitExternalIndices.reserve(nHitsTot);
if (fbDetUsed[EDetectorID::Sts]) {
ReadHits<EDetectorID::Sts>(recoResults.stsHits);
}
if (fbDetUsed[EDetectorID::Tof]) {
ReadHits<EDetectorID::Tof>(recoResults.tofHits);
}
faHitExternalIndices.shrink_to_fit();
fCaDataManager.SetNhitKeys(fNofHitKeys);
L_(info) << "Tracking chain:" << fCaDataManager.GetNofHits() << " hits will be passed to the ca::Framework";
......@@ -255,10 +265,7 @@ void TrackingChain::ReadHits(PartitionedSpan<const ca::HitTypes_t::at<DetID>> hi
iStLocal = (extHitAddress >> 4) & 0xF;
}
if constexpr (IsTof) {
iStLocal = fSetup.GetTrackingStation<DetID>(extHitAddress);
if (tof::Config::IsBmon(extHitAddress)) {
continue;
} // skip hits from Bmon
iStLocal = fpSetup->GetTrackingStation<DetID>(extHitAddress);
}
int iStActive = (iStLocal != -1) ? fCaFramework.GetParameters().GetStationIndexActive(iStLocal, DetID) : -1;
......
......@@ -19,10 +19,10 @@
#include "HistogramSender.h"
#include "PartitionedSpan.h"
#include "RecoResults.h"
#include "SetupInterface.h"
#include "SubChain.h"
#include "TrackingChainConfig.h"
#include "TrackingDefs.h"
#include "TrackingSetup.h"
#include "sts/Hit.h"
#include "tof/Hit.h"
......@@ -72,6 +72,9 @@ namespace cbm::algo
/// \brief Provides action in the initialization of the run
void Init();
/// \brief Registers tracking setup
void RegisterSetup(std::shared_ptr<TrackingSetup> pSetup) { fpSetup = pSetup; }
/// \brief Provides action for a given time-slice
/// \param recoResults Structure of reconstruction results
/// \return A pair (vector of tracks, tracking monitor)
......@@ -108,7 +111,9 @@ namespace cbm::algo
ca::InputQa fInputQa; ///< CA input QA builder
ca::OutputQa fOutputQa; ///< CA output QA builder
SetupInterface fSetup; ///< setup interface
std::shared_ptr<TrackingSetup> fpSetup = nullptr; ///< setup interface
ca::DetIdArray_t<bool> fbDetUsed; ///< Flags of detector subsystems used in tracking
// ************************
// ** Auxilary variables
......
......@@ -2,20 +2,24 @@
SPDX-License-Identifier: GPL-3.0-only
Authors: Sergei Zharko [committer] */
/// \file SetupInterface.h
/// \file TrackingSetup.h
/// \date 19.04.2024
/// \brief A detector setup interface used for tracking input data initialization (source)
/// \author Sergei Zharko <s.zharko@gsi.de>
#include "SetupInterface.h"
#include "TrackingSetup.h"
using cbm::algo::SetupInterface;
#include "Definitions.h"
using cbm::algo::TrackingSetup;
using fles::Subsystem;
// ---------------------------------------------------------------------------------------------------------------------
//
void SetupInterface::Init()
void TrackingSetup::Init()
{
if (Opts().Has(Subsystem::TOF)) {
fTof.SetContext(this->GetContext());
fTof.Init();
}
}
......@@ -2,7 +2,7 @@
SPDX-License-Identifier: GPL-3.0-only
Authors: Sergei Zharko [committer] */
/// \file SetupInterface.h
/// \file TrackingSetup.h
/// \date 19.04.2024
/// \brief A detector setup interface used for tracking input data initialization (header)
/// \author Sergei Zharko <s.zharko@gsi.de>
......@@ -19,9 +19,9 @@
namespace cbm::algo
{
/// \class SetupInterface
/// \class TrackingSetup
/// \brief A detector setup interface class for tracking input data initialization
class SetupInterface : public SubChain {
class TrackingSetup : public SubChain {
private:
/// \brief A helper temporary function to enable a method for a given detector subsystem
template<ca::EDetectorID DetID>
......@@ -32,16 +32,16 @@ namespace cbm::algo
public:
/// \brief Default constructor
SetupInterface() = default;
TrackingSetup() = default;
/// \brief Copy constructor
SetupInterface(const SetupInterface&) = delete;
TrackingSetup(const TrackingSetup&) = delete;
/// \brief Move constructor
SetupInterface(SetupInterface&&) = delete;
TrackingSetup(TrackingSetup&&) = delete;
/// \brief Destructor
~SetupInterface() = default;
~TrackingSetup() = default;
/// \brief Initializer function
void Init();
......
......@@ -305,6 +305,10 @@ namespace cbm::algo::ca
/// \brief Provides access to the misalignment of the detector systems in Time
const std::array<float, constants::size::MaxNdetectors> GetMisalignmentT() const { return fMisalignmentT; }
/// \brief Checks, if the detector subsystem active
/// \param detId Detector ID
bool IsActive(EDetectorID detId) const { return GetNstationsActive(detId) != 0; }
/// \brief Class invariant checker
void CheckConsistency() const;
......
......@@ -47,7 +47,7 @@ namespace cbm::algo::tof
double sigVel;
double timeRes;
Cell cell;
int trackingStationId;
i32 trackingStationId;
double CPTOffYBinWidth;
double CPTOffYRange;
std::vector<double> CPTOffY;
......
......@@ -48,6 +48,10 @@ void TrackingInterface::Init()
int TrackingInterface::GetTrackingStation(uint32_t address) const
{
int iSmType = CbmTofAddress::GetSmType(address);
if (5 == iSmType) {
return -1; // Bmon hit
}
int iSm = CbmTofAddress::GetSmId(address);
int iRpc = CbmTofAddress::GetRpcId(address);
if (iSmType < fvNofSm.size()) {
......
......@@ -57,6 +57,9 @@ namespace cbm::algo::evbuild
/** @brief Status info to logger **/
void Status() const;
/** @brief Registers tracking setup **/
void RegisterTrackingSetup(std::shared_ptr<TrackingSetup> pSetup) { fSelector.RegisterTrackingSetup(pSetup); }
private: // members
ECbmModuleId fTriggerDet = ECbmModuleId::kNotExist; ///< Trigger detector
TimeClusterTrigger fTrigger; ///< Trigger algorithm
......
......@@ -6,7 +6,6 @@
#include "AlgoFairloggerCompat.h"
#include "CbmStsDigi.h"
#include "tof/Config.h"
#include <gsl/span>
#include <iterator>
......@@ -109,10 +108,10 @@ namespace cbm::algo::evbuild
if (digi.GetSide() != strip->second) { // Found other end => full strip, insert into counter set
const int32_t rpcAddr = CbmTofAddress::GetRpcFullId(digiAddr);
if (rpcs.count(rpcAddr) == 0) { // new RPC activated
const int32_t smId = CbmTofAddress::GetSmId(digiAddr); // Super-module ID
const int32_t smType = CbmTofAddress::GetSmType(digiAddr); // Super-module type
const int32_t rpcId = CbmTofAddress::GetRpcId(digiAddr); // RPC ID
const int32_t TofStationId = tof::Config::GetTofTrackingStation(smType, smId, rpcId);
const int32_t TofStationId = fpTrackingSetup->GetTrackingStation<ca::EDetectorID::Tof>(digiAddr);
if (TofStationId < 0) {
continue;
} // unused tracking station (BMON)
stations.insert(TofStationId);
if (stations.size() == minNum) break;
}
......
......@@ -7,6 +7,7 @@
#include "DigiData.h"
#include "DigiEventSelectorConfig.h"
#include "TrackingSetup.h"
#include <cstdint>
#include <gsl/span>
......@@ -48,6 +49,10 @@ namespace cbm::algo::evbuild
**/
bool operator()(const DigiEvent& event) const;
/** @brief Registers tracking setup
** @param pSetup The tracking setup instance
**/
void RegisterTrackingSetup(std::shared_ptr<TrackingSetup> pSetup) { fpTrackingSetup = pSetup; }
/** @brief Info to string **/
std::string ToString() const;
......@@ -71,6 +76,7 @@ namespace cbm::algo::evbuild
private: // members
DigiEventSelectorConfig fConfig; ///< Configuration / parameters
std::shared_ptr<TrackingSetup> fpTrackingSetup = nullptr; ///< Tracking setup (access to stations info)
};
} // namespace cbm::algo::evbuild
......
......@@ -9,6 +9,7 @@
#include "Exceptions.h"
#include "HistogramSender.h"
#include "StsDigiQa.h"
#include "TrackingSetup.h"
#include "bmon/Unpack.h"
#include "ca/TrackingChain.h"
#include "compat/OpenMP.h"
......@@ -151,11 +152,17 @@ void Reco::Init(const Options& opts)
fTrd2dUnpack = std::make_unique<trd2d::Unpack>(cfg);
}
// --- Tracking setup
auto pTrackingSetup = std::make_shared<TrackingSetup>();
pTrackingSetup->SetContext(&fContext);
pTrackingSetup->Init();
// --- Event building
if (Opts().Has(Step::DigiTrigger)) {
fs::path configFile = opts.ParamsDir() / "EventbuildConfig.yaml";
evbuild::Config config(YAML::LoadFile(configFile.string()));
fEventBuild = std::make_unique<evbuild::EventbuildChain>(config, fSender);
fEventBuild->RegisterTrackingSetup(pTrackingSetup);
}
// STS Hitfinder
......@@ -185,6 +192,7 @@ void Reco::Init(const Options& opts)
// Tracking
if (Opts().Has(Step::Tracking)) {
fTracking = std::make_unique<TrackingChain>(fSender);
fTracking->RegisterSetup(pTrackingSetup);
fTracking->SetContext(&fContext);
fTracking->Init();
}
......
......@@ -6,7 +6,6 @@
#include "DigiEventSelectorConfig.h"
#include "gtest/gtest-spi.h"
#include "gtest/gtest.h"
#include "tof/Config.h"
#include <unordered_set>
......@@ -197,6 +196,17 @@ TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple)
const uint8_t numSmTypes = 10;
const uint8_t numRpc[numSmTypes] = {5, 3, 5, 1, 1, 1, 2, 2, 1, 2};
const uint8_t numSm[numSmTypes] = {5, 0, 1, 0, 0, 1, 1, 1, 2, 1};
std::vector<std::vector<uint8_t>> trkStationId = {
{0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3},
{0, 0, 0, 0, 0},
{2, 2, 2, 2, 2},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{1, 1, 0, 0, 0},
{1, 1, 0, 0, 0},
{0, 0, 0, 0, 0},
{2, 2, 2, 2, 0}};
std::unordered_set<int32_t> setTofStation;
for (uint smType = 0; smType < numSmTypes; smType++) {
......@@ -208,7 +218,12 @@ TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple)
eventIn.fTof.push_back(CbmTofDigi(addrFront, 0.0, 0.0));
eventIn.fTof.push_back(CbmTofDigi(addrBack, 0.0, 0.0));
const int32_t TofStationId = cbm::algo::tof::Config::GetTofTrackingStation(smType, sm, rpc);
int32_t TofStationId = -1;
if (smType < numSmTypes) {
if (sm < numSm[smType] && rpc < numRpc[smType]) {
TofStationId = trkStationId[smType][sm * numRpc[smType] + rpc];
}
}
setTofStation.insert(TofStationId);
YAML::Node node2;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment