CbmRoot
Loading...
Searching...
No Matches
CaStation.cxx
Go to the documentation of this file.
1/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergey Gorbunov, Sergei Zharko [committer] */
4
5#include "CaStation.h"
6
8
9#include <iomanip>
10#include <sstream>
11
12namespace cbm::algo::ca
13{
14 // --------------------------------------------------------------------------------------------------------------------
15 //
16 template<typename DataT>
18 {
20
21 if (type < 0) {
22 std::stringstream msg;
23 msg << "CaStation: station type was not initialized (type = " << type << ", type > 0)";
24 throw std::logic_error(msg.str());
25 }
26
27 if (timeInfo != 0 && timeInfo != 1) {
28 std::stringstream msg;
29 msg << "CaStation: illegal time information flag (timeInfo = " << timeInfo << ", "
30 << "0 [time information is not used] or 1 [time information is used] expected)";
31 throw std::logic_error(msg.str());
32 }
33
34 if (fieldStatus != 0 && fieldStatus != 1) {
35 std::stringstream msg;
36 msg << "CaStation: illegal field status flag (fieldStatus = " << fieldStatus << ", "
37 << "0 [station is outside the field] or 1 [station is inside the field] expected";
38 throw std::logic_error(msg.str());
39 }
40
42 // TODO: SZh 06.06.2024: Do we still need these checks?
43 kfutils::CheckSimdVectorEquality<DataT>(fZ, "CaStation::fZ");
44 kfutils::CheckSimdVectorEquality<DataT>(Xmax, "CaStation::Xmax");
45 kfutils::CheckSimdVectorEquality<DataT>(Ymax, "CaStation::Ymax");
46
47
50
51 if (this->GetXmax<float>() < 0. || this->GetYmax<float>() < 0.) {
52 std::stringstream msg;
53 msg << "CaStation: " << this->ToString() << " has incorrect sizes: "
54 << "Xmax = " << this->GetXmax<float>() << " [cm], Ymax = " << this->GetYmax<float>()
55 << " [cm] (0 < Xmax && 0 < Ymax expected)";
56 throw std::logic_error(msg.str());
57 }
58
60
61 //materialInfo.CheckConsistency();
62 // TODO: Temporarily switched off, because Much has RL = 0, which is actually incorrect, but really is not used.
63 // One should provide average radiation length values for each Much layer (S.Zharko)
64 fieldSlice.CheckConsistency();
65 }
66
67 // --------------------------------------------------------------------------------------------------------------------
68 //
69 template<typename DataT>
70 std::string Station<DataT>::ToString(int verbosityLevel, int indentLevel, bool isHeader) const
71 {
72 std::stringstream msg{};
73 constexpr char indentChar = '\t';
74 constexpr char columnSize = 15;
75 std::string indent(indentLevel, indentChar);
76 if (verbosityLevel == 0) {
77 msg << "station type = " << type << ", z = " << this->GetZ<float>() << " cm";
78 }
79 else {
80 if (isHeader) {
81 verbosityLevel = 0;
82 msg << indent;
83 msg << std::setw(columnSize) << std::setfill(' ') << "type" << ' ';
84 msg << std::setw(columnSize) << std::setfill(' ') << "time status" << ' ';
85 msg << std::setw(columnSize) << std::setfill(' ') << "field status" << ' ';
86 msg << std::setw(columnSize) << std::setfill(' ') << "geo layer ID" << ' ';
87 msg << std::setw(columnSize) << std::setfill(' ') << "z [cm]" << ' ';
88 msg << std::setw(columnSize) << std::setfill(' ') << "Xmax [cm]" << ' ';
89 msg << std::setw(columnSize) << std::setfill(' ') << "Ymax [cm]";
90 }
91 else {
92 msg << indent;
93 msg << std::setw(columnSize) << std::setfill(' ') << this->GetType() << ' ';
94 msg << std::setw(columnSize) << std::setfill(' ') << this->GetTimeStatus() << ' ';
95 msg << std::setw(columnSize) << std::setfill(' ') << this->GetFieldStatus() << ' ';
96 msg << std::setw(columnSize) << std::setfill(' ') << this->GetGeoLayerID() << ' ';
97 msg << std::setw(columnSize) << std::setfill(' ') << this->GetZ<float>() << ' ';
98 msg << std::setw(columnSize) << std::setfill(' ') << this->GetXmax<float>() << ' ';
99 msg << std::setw(columnSize) << std::setfill(' ') << this->GetYmax<float>();
100 }
101 if (verbosityLevel > 3) {
102 msg << indent << "\nField slices:\n";
103 msg << fieldSlice.ToString(indentLevel + 1, verbosityLevel) << '\n';
104 }
105 }
106 return msg.str();
107 }
108
109 template class Station<fvec>;
110 template class Station<float>;
111 template class Station<double>;
112} // namespace cbm::algo::ca
void CheckConsistency() const
Verifies class invariant consistency.
Definition CaStation.cxx:17
std::string ToString(int verbosityLevel=0, int indentLevel=0, bool isHeader=false) const
String representation of class contents.
Definition CaStation.cxx:70
TODO: SZh 8.11.2022: add selection of parameterisation.
Definition CaBranch.h:14
void CheckSimdVectorEquality(fvec v, const char *name)
Checks, if a SIMD vector horizontally equal TODO: Find this method in the VC!
Definition KfUtils.cxx:29
std::string_view ToString(T t)
Definition EnumDict.h:64