CbmRoot
Loading...
Searching...
No Matches
KfTarget.cxx
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#include "KfTarget.h"
11
12#include <sstream>
13
16
17// ---------------------------------------------------------------------------------------------------------------------
18//
19template<typename T>
20Target<T>::Target(double x, double y, double z, double dz, double r)
21 : fX(utils::simd::Cast<double, T>(x))
22 , fY(utils::simd::Cast<double, T>(y))
23 , fZ(utils::simd::Cast<double, T>(z))
24 , fDz(utils::simd::Cast<double, T>(dz))
25 , fR(utils::simd::Cast<double, T>(r))
26{
27}
28
29// ---------------------------------------------------------------------------------------------------------------------
30//
31template<typename T>
33{
34 if (material.IsUndefined()) {
35 throw std::logic_error("Target:ReceiveMaterial(): attempt to pass an undefined instance of the material map");
36 }
37 fMaterial = material;
38}
40// ---------------------------------------------------------------------------------------------------------------------
41//
42template<typename T>
44{
45 if (material.IsUndefined()) {
46 throw std::logic_error("Target:ReceiveMaterial(): attempt to pass an undefined instance of the material map");
47 }
48 fMaterial = std::move(material);
49}
50
51// ---------------------------------------------------------------------------------------------------------------------
52//
53template<typename T>
54std::string Target<T>::ToString(int indentLevel, int verbose) const
55{
56 constexpr char IndentChar = '\t';
57 std::stringstream msg;
58 std::string indent(indentLevel, IndentChar);
59 auto Cnv = [&](const auto& val) { return utils::simd::Cast<T, Literal_t<T>>(val); }; // alias for the conversion fn
60 msg << indent << "position: {" << Cnv(fX) << ", " << Cnv(fY) << ", " << Cnv(fZ) << "} [cm]\n";
61 msg << indent << "half-thickness: " << Cnv(fDz) << " [cm]\n";
62 msg << indent << "material:\n" << indent << IndentChar << " " << fMaterial.ToString(verbose);
63 return msg.str();
64}
65
66
67namespace cbm::algo::kf
68{
69 template class Target<float>;
70 template class Target<double>;
71 template class Target<fvec>;
72} // namespace cbm::algo::kf
A target layer in the KF-setup (header)
A map of station thickness in units of radiation length (X0) to the specific point in XY plane.
bool IsUndefined() const
Function to test the instance for NaN.
A geometry layer in the target region.
Definition KfTarget.h:25
friend class Target
Definition KfTarget.h:27
std::string ToString(int indentLevel=0, int vebose=1) const
String representation of the class.
Definition KfTarget.cxx:54
void SetMaterial(const MaterialMap &material)
Sets material map.
Definition KfTarget.cxx:32
DataOut Cast(const DataT &val)
Converts a value of type DataT to type DataOut.
Definition KfUtils.h:212