CbmRoot
Loading...
Searching...
No Matches
CaParametersBuilder.h
Go to the documentation of this file.
1/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
10#ifndef CaParametersBuilder_h
11#define CaParametersBuilder_h 1
12
13#include "CaConfigReader.h"
14#include "CaDefs.h"
15#include "CaParameters.h"
17#include "KfISetupFactory.h"
18#include "KfSetup.h"
19
20#include <algorithm>
21#include <array>
22#include <functional>
23#include <memory>
24#include <string>
25#include <vector>
26
27namespace cbm::algo::ca
28{
32
33 public:
34 using DetNamesArray_t = std::array<std::string, constants::size::MaxNdetectors>;
35 using GeoFactoryPtr_t = std::unique_ptr<const kf::ISetupFactory>;
36
40 template<typename Float>
42
47 void DisableStation(EDetectorID detId, int locId) { fvInactiveIds.push_back(std::pair{detId, locId}); }
48
56 void SetGeoSetupFactoryConstructor(std::function<GeoFactoryPtr_t()> lazyConstructor)
57 {
58 fpGeoSetupFactoryConstructor = lazyConstructor;
59 }
60
62 void SetMainConfig(const std::string& mainConfig) { fsMainConfig = mainConfig; }
63
65 void SetUserConfig(const std::string& userConfig) { fsUserConfig = userConfig; }
66
68 void SetDetNames(const DetNamesArray_t& detNames) { fDetNames = detNames; }
69
70
71 private:
73 void Init();
74
75 std::string fsMainConfig{};
76 std::string fsUserConfig{};
77 std::vector<std::pair<EDetectorID, int>> fvInactiveIds;
80
83 // NOTE: Set of the lazy constructor ensures, that the geo-setup factory will be constructed in the
84 // initialization of the parameters builder. This method is to be called in a constructor of
85 // a concrete parameter builder class.
86 };
87
88 //* Template method implementation
89 template<typename Float>
91 {
92 if (fsMainConfig.empty()) {
93 throw std::runtime_error("ca::ParametersBuilder: attempt to build a parameters object with an "
94 "uninitialized main config.");
95 }
96
97 if (fpGeoSetupFactory == nullptr) {
98 Init();
99 }
100
101 auto configReader = ConfigReader{};
102 configReader.SetDetectorNames(fDetNames);
103 configReader.SetMainConfigPath(fsMainConfig);
104 configReader.SetUserConfigPath(fsUserConfig);
105 auto config = configReader.CreateConfig();
106
107 // Append inactive indices from the config
108 auto inactiveIdsFromCfg = configReader.ReadInactiveStationMap();
109 std::vector<std::pair<ca::EDetectorID, int>> inactiveIdsFull;
110 inactiveIdsFull.reserve(inactiveIdsFromCfg.size() + fvInactiveIds.size());
111 std::copy(fvInactiveIds.begin(), fvInactiveIds.end(), std::back_inserter(inactiveIdsFull));
112 std::copy(inactiveIdsFromCfg.begin(), inactiveIdsFromCfg.end(), std::back_inserter(inactiveIdsFull));
113
114 auto geoSetup = fpGeoSetupFactory->Create(kf::FloatTag<Float>{}, fldMode);
115 auto caSetup = ca::Setup{std::move(geoSetup), inactiveIdsFull};
116 auto swMaps =
117 SearchWindowMapContainerFactory{}.Create(caSetup.GetActiveSetup(), fpGeoSetupFactory->GetFieldFunction(), config);
118
119 return Parameters<Float>{std::move(caSetup), std::move(config), std::move(swMaps)};
120 }
121
122} // namespace cbm::algo::ca
123
124#endif // CaParametersBuilder_h
Configuration parameter file reader for the CA tracking algorithm (header)
Compile-time constants definition for the CA tracking algorithm.
A factory class for a search window map container.
An abstract factory for different setups.
Setup representation for the Kalman-filter framework (header)
A reader for the CA parameters from the YAML configuration files.
void SetDetectorNames(const std::array< std::string, constants::size::MaxNdetectors > &input)
Sets detector names.
A builder class for ca::Parameters.
void SetMainConfig(const std::string &mainConfig)
Sets main config path.
std::string fsUserConfig
Path to user config (optional)
Parameters< Float > Build(kf::FloatTag< Float > floatTag, kf::EFieldMode fldMode)
Builds the parameters object.
std::unique_ptr< const kf::ISetupFactory > GeoFactoryPtr_t
GeoFactoryPtr_t fpGeoSetupFactory
Shared geo-setup factory.
std::vector< std::pair< EDetectorID, int > > fvInactiveIds
Indices of inactive stations.
void DisableStation(EDetectorID detId, int locId)
Disables tracking station.
std::array< std::string, constants::size::MaxNdetectors > DetNamesArray_t
void SetGeoSetupFactoryConstructor(std::function< GeoFactoryPtr_t()> lazyConstructor)
Sets a constructor callable for the geo-setup factory.
std::function< GeoFactoryPtr_t()> fpGeoSetupFactoryConstructor
void Init()
Initializes the instance.
DetNamesArray_t fDetNames
Detector subsystem names.
void SetUserConfig(const std::string &userConfig)
Sets user config path.
std::string fsMainConfig
Path to main config.
void SetDetNames(const DetNamesArray_t &detNames)
Sets tracking detector names.
A container for all external parameters of the CA tracking algorithm.
A factory class for seach window map container.
static SearchWindowMapContainer Create(const kf::Setup< F > &actSetup, const kf::FieldFn_t &fieldFn, const ca::Config &config)
Creates the map.
Setup representation for tracking.
Definition CaSetup.h:54
TODO: SZh 8.11.2022: add selection of parameterisation.
Definition CaBranch.h:14
EDetectorID
Enumeration for the tracking detector subsystems in CBM-CA.
Definition CbmDefs.h:216
EFieldMode
Enumiration for the magnetic field representation variants in the track fitting algorithm.
Definition KfDefs.h:108
A floating-point tag for tag dispatching.
Definition KfDefs.h:117