14#include <boost/serialization/access.hpp>
15#include <boost/serialization/utility.hpp>
22#include <fmt/format.h>
51 friend class boost::serialization::access;
61 template<
class EDetID =
int>
62 std::pair<EDetID, int> GlobalToLocal(
int globId)
const;
70 template<
class EDetID>
73 return fvLocToGlb[fvDetLocOffset[fvDetExtToInt[
static_cast<int>(detId)]] + locId];
80 template<
class EDetID>
81 void Disable(EDetID detId,
int locId);
87 std::string
ToString(
int indentLevel = 0)
const;
90 template<
class Archive>
100 std::vector<int> fvLocToGlb{};
101 std::vector<std::pair<int, int>> fvGlbToLoc{};
102 std::vector<int> fvDetLocOffset{};
103 std::vector<int> fvDetIntToExt{};
104 std::vector<int> fvDetExtToInt{};
113 Component(
int detId,
int locId,
double z) : fZ(z), fLocId(locId), fDetId(detId) {}
125 template<
class EDetID>
126 void AddComponent(EDetID detId,
int locId,
double z);
140 template<
class EDetID>
141 void ModuleIndexMap::Disable(EDetID detIdDisable,
int locIdDisable)
144 auto iDetIntDsbl{fvDetExtToInt[
static_cast<int>(detIdDisable)]};
145 if (iDetIntDsbl >=
static_cast<int>(fvDetIntToExt.size())) {
149 auto& iGlbDsbl = fvLocToGlb[fvDetLocOffset[iDetIntDsbl] + locIdDisable];
154 fvGlbToLoc.erase(fvGlbToLoc.begin() + iGlbDsbl);
155 for (
auto& val : fvLocToGlb) {
156 if (val > iGlbDsbl) {
165 template<
class EDetID>
166 inline std::pair<EDetID, int> ModuleIndexMap::GlobalToLocal(
int globId)
const
168 const auto& [iDetExt, iLoc] = fvGlbToLoc[globId];
169 return std::pair(
static_cast<EDetID
>(iDetExt), iLoc);
174 template<
class EDetID>
175 void ModuleIndexMapFactory::AddComponent(EDetID detId,
int locId,
double z)
177 if (!fvComponentLayers.emplace(
static_cast<int>(detId), locId, z).second) {
178 std::stringstream msg;
179 msg <<
"ModuleIndexMapFactory: attempt of adding a duplicating component with z = " << z
180 <<
", detID = " <<
static_cast<int>(detId) <<
" and locId = " << locId
181 <<
".\n The next components were already added:";
182 for (
const auto& c : fvComponentLayers) {
183 msg <<
"\n\t- {z, detId, locId} = {" << c.fZ <<
", " << c.fDetId <<
", " << c.fLocId <<
"}";
185 throw std::logic_error(msg.str());
std::string ToString(ECbmModuleId modId)
Common constant definitions for the Kalman Filter library.
Creates a valid module mapper.
std::set< Component > fvComponentLayers
Maps local detector and station indices to the material maps and field slices.
void serialize(Archive &ar, const unsigned int)
int GetNofLayers() const
Gets total number of components.
int LocalToGlobal(EDetID detId, int locId) const
Converts external pair (detID, locID) to internal layer index.
Structure to keep information on layers.
bool operator<(const Component &rhs) const
int fDetId
External index of detector subsystem.
double fZ
Reference z-coordinate of the component.
int fLocId
Local index of component.
Component(int detId, int locId, double z)