CbmRoot
Loading...
Searching...
No Matches
KfSetup.h
Go to the documentation of this file.
1/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
10#pragma once // include this header only once per compilation unit
11
12#include "KfDefs.h"
13#include "KfField.h"
14#include "KfMaterialMap.h"
15#include "KfModuleIndexMap.h"
16#include "KfTarget.h"
17#include "KfVector.h"
18
19#include <boost/serialization/access.hpp>
20
21#include <fstream>
22#include <optional>
23#include <sstream>
24#include <string>
25#include <vector>
26
27namespace cbm::algo::kf
28{
32 template<typename T>
33 class alignas(VcMemAlign) Setup {
34 friend class boost::serialization::access; // Boost serializer methods
35 friend class SetupBuilder;
36 template<typename>
37 friend class Setup;
38
39 public:
43 : fvMaterialLayers({})
44 , fField(Field<T>(fldMode, EFieldType::Normal))
45 , fTarget(Target<T>())
46 {
47 }
48
50 ~Setup() = default;
51
54 template<typename I>
55 Setup(const Setup<I>& other)
56 : fModuleIndexMap(other.fModuleIndexMap)
57 , fvMaterialLayers(other.fvMaterialLayers)
58 , fField(other.fField)
59 , fTarget(other.fTarget)
60 {
61 }
62
64 //Setup(Setup&&) noexcept;
65
67 Setup& operator=(const Setup& other) = default;
68
70 //Setup& operator=(Setup&&) noexcept;
71
76 template<class EDetID>
77 void DisableLayer(EDetID iDet, int iLoc);
78
81 const Field<T>& GetField() const { return fField; }
82
85 const MaterialMap& GetMaterial(int iLayer) const { return fvMaterialLayers[iLayer]; }
86
91 template<class EDetID>
92 const MaterialMap& GetMaterial(EDetID iDet, int iLoc) const
93 {
94 return fvMaterialLayers[fModuleIndexMap.LocalToGlobal(iDet, iLoc)];
95 }
96
98 const ModuleIndexMap& GetIndexMap() const { return fModuleIndexMap; }
99
101 int GetNofLayers() const { return static_cast<int>(fvMaterialLayers.size()); }
102
104 const Target<T>& GetTarget() const { return fTarget; }
105
109 std::string ToString(int verbosity = 1, int indentLevel = 0) const;
110
111 private:
112 template<class Archive>
113 void serialize(Archive& ar, const unsigned int /*version*/)
114 {
115 ar& fModuleIndexMap;
116 ar& fvMaterialLayers;
117 ar& fTarget;
118 ar& fField;
119 }
120
121 ModuleIndexMap fModuleIndexMap{};
122 std::vector<MaterialMap> fvMaterialLayers{};
125 };
126
127
128 // -------------------------------------------------------------------------------------------------------------------
129 //
130 template<typename T>
131 template<class EDetID>
132 void Setup<T>::DisableLayer(EDetID iDet, int iLoc)
133 {
134 int iLayer{fModuleIndexMap.LocalToGlobal(iDet, iLoc)};
135 if (iLayer == -1) {
136 return;
137 }
138
139 // Remove material layer and add it to the next one
140 if (iLayer < static_cast<int>(fvMaterialLayers.size() - 1)) {
141 fvMaterialLayers[iLayer + 1].Add(fvMaterialLayers[iLayer], utils::simd::Cast<T, float>(fTarget.GetZ()));
142 }
143 fvMaterialLayers.erase(fvMaterialLayers.begin() + iLayer);
144
145 // Remove field slice
146 fField.RemoveSlice(iLayer);
147
148 // Disable layer in the index map
149 fModuleIndexMap.Disable(iDet, iLoc);
150 //std::cout << "LAYERS: \n" << fModuleIndexMap.ToString() << '\n';
151 }
152
153
154} // namespace cbm::algo::kf
std::string ToString(ECbmModuleId modId)
Definition CbmDefs.cxx:70
Common constant definitions for the Kalman Filter library.
Magnetic field representation in KF (header)
A helper class to map external indices with the ones of KF-setup.
A target layer in the KF-setup (header)
std::vector with an additional utility set
Magnetic field manager class.
Definition KfField.h:188
A map of station thickness in units of radiation length (X0) to the specific point in XY plane.
Maps local detector and station indices to the material maps and field slices.
Creates a valid initialized Setup instance.
KF-framework representation of the detector setup.
Definition KfSetup.h:33
int GetNofLayers() const
Gets number of geometry layers.
Definition KfSetup.h:101
const Target< T > & GetTarget() const
Gets target.
Definition KfSetup.h:104
const ModuleIndexMap & GetIndexMap() const
Gets module index map.
Definition KfSetup.h:98
~Setup()=default
Destructor.
Field< T > fField
Interpolated field (NOTE: maybe make optional)
Definition KfSetup.h:123
Setup(const Setup< I > &other)
Copy constructor.
Definition KfSetup.h:55
Setup & operator=(const Setup &other)=default
Move constructor.
const MaterialMap & GetMaterial(int iLayer) const
Gets material layer.
Definition KfSetup.h:85
Setup(EFieldMode fldMode)
Constructor.
Definition KfSetup.h:42
void serialize(Archive &ar, const unsigned int)
Definition KfSetup.h:113
void DisableLayer(EDetID iDet, int iLoc)
Move assignment operator.
Definition KfSetup.h:132
const Field< T > & GetField() const
Makes an instance of the field depending on the template parameter.
Definition KfSetup.h:81
const MaterialMap & GetMaterial(EDetID iDet, int iLoc) const
Gets material layer from external indices.
Definition KfSetup.h:92
Target< T > fTarget
Target layer.
Definition KfSetup.h:124
A geometry layer in the target region.
Definition KfTarget.h:25
EFieldMode
Enumiration for the magnetic field representation variants in the track fitting algorithm.
Definition KfDefs.h:27