CbmRoot
Loading...
Searching...
No Matches
CaStationInitializer.cxx
Go to the documentation of this file.
1/* Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergey Gorbunov, Sergei Zharko [committer] */
4
10
12
14#include "CaDefs.h"
15
16#include <iomanip>
17#include <sstream>
18#include <utility>
19
24
25// ---------------------------------------------------------------------------------------------------------------------
26//
27StationInitializer::StationInitializer(EDetectorID detectorID, int stationID) noexcept
28 : fDetectorID(detectorID)
29 , fStationID(stationID)
30{
31 fInitController.SetFlag(EInitKey::kDetectorID);
32 fInitController.SetFlag(EInitKey::kStationID);
33}
34
35// ---------------------------------------------------------------------------------------------------------------------
36//
38{
40 this->Swap(other);
41}
42
43// ---------------------------------------------------------------------------------------------------------------------
44//
46{
48 std::stringstream msg;
49 msg << "StationInitializer::GetStation: attempt to get a Station object from uninitialized L1BaseStation with "
50 << "stationID = " << fStationID << " and detectorID = " << static_cast<int>(fDetectorID);
51 LOG(fatal) << msg.str();
52 }
53 return fStation;
54}
55
56// ---------------------------------------------------------------------------------------------------------------------
57//
59{
61 fDetectorID = inID;
63 }
64 else {
65 LOG(warn) << "StationInitializer::SetDetectorID: Attempt of detector ID redifinition";
66 }
67}
68
69
70// ---------------------------------------------------------------------------------------------------------------------
71//
73 const std::function<void(const double (&xyz)[3], double (&B)[3])>& getFieldValue)
74{
76 LOG(warn) << "StationInitializer::SetFieldSlice: Attempt to redifine field slice for station with detectorID = "
77 << static_cast<int>(fDetectorID) << " and stationID = " << fStationID << ". Redifinition ignored";
78 return;
79 }
80
82 LOG(fatal) << "Attempt to set magnetic field slice before setting z position of the station";
83 }
85 LOG(fatal) << "Attempt to set magnetic field slice before Xmax size of the station";
86 }
88 LOG(fatal) << "Attempt to set magnetic field slice before Ymax size of the station";
89 }
90
93 auto glambda = [&](double x, double y, double z) -> std::tuple<double, double, double> {
94 double xyz[3] = {x, y, z};
95 double B[3] = {};
96 getFieldValue(xyz, B);
97 return std::tuple<double, double, double>(B[0], B[1], B[2]);
98 };
99
101
103}
104
105// ---------------------------------------------------------------------------------------------------------------------
106//
108{
109 fStation.fieldStatus = fieldStatus;
111}
112
113// ---------------------------------------------------------------------------------------------------------------------
114//
116{
117 fStation.geoLayerID = geoLayerID;
119}
120
121// ---------------------------------------------------------------------------------------------------------------------
122//
124{
126 fStationID = inID;
128 }
129 else {
130 LOG(warn) << "StationInitializer::SetStationID: Attempt of station ID redifinition";
131 }
132}
133
134// ---------------------------------------------------------------------------------------------------------------------
135//
137{
139 fStation.type = inType;
141 }
142 else {
143 LOG(warn) << "StationInitializer::SetStationType: Attempt of station type redifinition";
144 }
145}
146
147// ---------------------------------------------------------------------------------------------------------------------
148//
150{
151 fXmax = aSize;
152 fStation.Xmax = aSize;
154}
155
156// ---------------------------------------------------------------------------------------------------------------------
157//
159{
160 fYmax = aSize;
161 fStation.Ymax = aSize;
163}
164
165// ---------------------------------------------------------------------------------------------------------------------
166//
168{
169 fStation.timeInfo = inTimeInfo;
171}
172
173// ---------------------------------------------------------------------------------------------------------------------
174//
180
181// ---------------------------------------------------------------------------------------------------------------------
182//
184{
185 fStation.fZ = inZ; // setting simd vector of single-precision floats, which is passed to high performanced L1Algo
186 fZref = inZ; // setting precised value to use in field approximation etc
188}
189
190// ---------------------------------------------------------------------------------------------------------------------
191//
193{
194 fZmin = inZ; // setting precised value to use in field approximation etc
196}
197
198// ---------------------------------------------------------------------------------------------------------------------
199//
201{
202 fZmax = inZ; // setting precised value to use in field approximation etc
204}
205
206// ---------------------------------------------------------------------------------------------------------------------
207//
209{
210 std::swap(fDetectorID, other.fDetectorID);
211 std::swap(fStationID, other.fStationID);
212 std::swap(fTrackingStatus, other.fTrackingStatus);
213 std::swap(fXmax, other.fXmax);
214 std::swap(fYmax, other.fYmax);
215 std::swap(fZref, other.fZref);
216 std::swap(fZmin, other.fZmin);
217 std::swap(fZmax, other.fZmax);
218 std::swap(fStation, other.fStation);
219 std::swap(fInitController, other.fInitController);
220}
221
222// ---------------------------------------------------------------------------------------------------------------------
223//
224std::string StationInitializer::ToString(int verbosityLevel, int indentLevel) const
225{
226 std::stringstream aStream{};
227 constexpr char indentChar = '\t';
228 std::string indent(indentLevel, indentChar);
229
230 if (verbosityLevel == 0) {
231 aStream << indent << "StationInitializer object: {stationID, detectorID, z, address} = {" << fStationID << ", "
232 << static_cast<int>(fDetectorID) << ", " << fZref << ", " << this << '}';
233 }
234 else if (verbosityLevel > 0) {
235 aStream << indent << "StationInitializer object: at " << this << '\n';
236 aStream << indent << indentChar << "Station ID: " << fStationID << '\n';
237 aStream << indent << indentChar << "Detector ID: " << static_cast<int>(fDetectorID) << '\n';
238 aStream << indent << indentChar << "ca::Station object:" << '\n';
239 aStream << fStation.ToString(verbosityLevel - 1, indentLevel + 1) << '\n';
240 aStream << indent << indentChar << "Additional fields:\n";
241 aStream << indent << indentChar << indentChar << "Zmin: " << fZmin << '\n';
242 aStream << indent << indentChar << indentChar << "Zmax: " << fZmax << '\n';
243 aStream << indent << indentChar << indentChar << "Xmax: " << fXmax << '\n';
244 aStream << indent << indentChar << indentChar << "Ymax: " << fYmax << '\n';
245 }
246 return aStream.str();
247}
Compile-time constants definition for the CA tracking algorithm.
An interface for the CA Station object initialization.
bool GetFlag(InitKeyEnum bitKey) const
void SetFlag(InitKeyEnum bitKey, bool newStatus=true)
bool IsFinalized() const
Checks, if the object is finalized, i.e. all its fields were set up.
A base class which provides interface to L1Algo station geometry.
double fYmax
Maximum distance between station center and its edge in y direction.
bool fTrackingStatus
Tracking status: true - station is used for tracking.
void SetYmax(double aSize)
Sets maximum distance between station center and its edge in y direction.
void SetStationID(int inID)
Sets station ID.
double fXmax
Maximum distance between station center and its edge in x direction.
@ kTimeInfo
if time info is used (flag)
@ kTrackingStatus
flag, if station is used in tracking or not
@ kFieldSlice
ca::Station.ca::FieldSlice object initialization
@ kGeoLayerID
index of geo layer in geometrical setup (including possibly inactive stations)
@ kFieldStatus
if station is placed in field (flag)
void SetZmax(double inZ)
Sets max z of the station.
void SetZmin(double inZ)
Sets min z of the station.
void SetStationType(int inType)
Sets type of station.
void SetZref(double inZ)
Sets reference z position of the station.
void SetGeoLayerID(int geoLayerID)
Sets geometry ID (index of the layer in the geometrical setup)
std::string ToString(int verbosityLevel=0, int indentLevel=0) const
String representation of class contents.
StationInitializer()=default
Default constructor.
void SetTimeInfo(int inTimeInfo)
Sets flag: 0 - time information is not provided by this detector type 1 - time information is provide...
void Swap(StationInitializer &other) noexcept
Swap method for easy implementation of move constructor and copy and move assignment operator.
Station< fvec > fStation
ca::Station structure, describes a station in L1Algo
InitController_t fInitController
Class fileds initialization flags.
void SetFieldStatus(int fieldStatus)
Sets flag: true - station is placed in field, false - station is placed outside the field.
void SetDetectorID(EDetectorID inID)
Sets detector ID.
const Station< fvec > & GetStation() const
Gets a reference to ca::Station info field of the L1BaseStation info.
void SetTrackingStatus(bool flag)
Sets tracking status: true - station is active for tracking, false - station exists,...
void Reset()
Resets fields to the default values.
void SetXmax(double aSize)
Sets maximum distance between station center and its edge in x direction.
void SetFieldFunction(const std::function< void(const double(&xyz)[3], double(&B)[3])> &getFieldValue)
Sets arrays of the approcimation.
kf::FieldSlice< DataT > fieldSlice
Magnetic field near the station.
Definition CaStation.h:33
A magnetic field approximation on the two-dimensional plane.
EDetectorID
Enumeration for the tracking detector subsystems in CBM-CA.
Definition CbmDefs.h:176