14#include <TGeoManager.h>
23#include <fmt/format.h>
31 std::stringstream msg;
32 msg <<
"Errors in the detector interface initialization for " << this->
GetDetectorName() <<
":\n";
42 std::string prefix = std::string(
"\t- Station ") + std::to_string(iSt) +
" has ";
48 if (!std::isfinite(z0) || !std::isfinite(z1) || !std::isfinite(z2) || !(z0 < z1 && z1 < z2)) {
49 msg << prefix <<
" wrong Z position (" << z0 <<
" < " << z1 <<
" < " << z2 <<
" cm)\n";
57 if (!(xMax > xMin) || std::isnan(xMax) || std::isnan(xMin)) {
58 msg << prefix <<
" zero, negative or NaN X-size (xMin = " << xMin <<
", xMax = " << xMax <<
" cm)\n";
66 if (!(yMax > yMin) || std::isnan(yMax) || std::isnan(yMin)) {
67 msg << prefix <<
" zero, negative or NaN Y-size (yMin = " << yMin <<
", yMax = " << yMax <<
" cm)\n";
76 zPositions[iSt] = this->
GetZref(iSt);
78 std::set<double> zPositionSet(zPositions.begin(), zPositions.end());
79 if (zPositions.size() != zPositionSet.size()) {
80 msg <<
"\t- Some of stations have the same z position component:\n";
81 for (
size_t iSt = 0; iSt < zPositions.size(); ++iSt) {
82 msg <<
"\t\tstation " << iSt <<
", z = " << zPositions[iSt] <<
" cm\n";
90 LOG(error) << msg.str()
91 <<
"\033[4mErrors above mean that the CA tracking cannot be used with the current version of "
93 <<
" setup parameters and the corresponding tracking detector interface are initialized properly\033[0m";
105 std::stringstream table;
107 "\n|{:>5}|{:>9}|{:>17}|{:>17}|{:>17}|{:>17}|{:>17}|{:>17}|{:>9}|{:>9}|{:>9}|{:>9}|{:>9}|{:>9}|{:>9}|\n",
"st.No",
108 "z_ref[cm]",
"x_min(active)[cm]",
"x_max(active)[cm]",
"y_min(active)[cm]",
"y_max(active)[cm]",
109 "z_min(active)[cm]",
"z_max(active)[cm]",
"x_min[cm]",
"x_max[cm]",
"y_min[cm]",
"y_max[cm]",
"z_min[cm]",
110 "z_max[cm]",
"time info");
111 table << format(
"|{0:->5}|{0:->9}|{0:->17}|{0:->17}|{0:->17}|{0:->17}|{0:->17}|{0:->17}|{0:->9}|{0:->9}"
112 "|{0:->9}|{0:->9}|{0:->9}|{0:->9}|{0:->9}|\n",
115 table << format(
"|{:>5d}|{:>9.2f}|{:>17.2f}|{:>17.2f}|{:>17.2f}|{:>17.2f}|{:>17.2f}|{:>17.2f}|{:>9.2f}|{:>9.2f}|{:>"
116 "9.2f}|{:>9.2f}|{:>9.2f}|"
128 const TString& path, TGeoNode* pNode)
130 std::vector<TString> vPaths;
136 TString nodePath = path + (path.IsNull() ?
"" :
"/") + pNode->GetName();
138 if (TString(pNode->GetName()).Contains(component, TString::kIgnoreCase)) {
139 if (nodePath.Contains(detector, TString::kIgnoreCase)) {
140 vPaths.push_back(nodePath);
144 for (
int iNode = 0; iNode < pNode->GetNdaughters(); ++iNode) {
145 TGeoNode* pDaughter = pNode->GetDaughter(iNode);
146 auto daughterPaths =
CollectNodes(detector, component, nodePath, pDaughter);
147 vPaths.insert(vPaths.end(), daughterPaths.begin(), daughterPaths.end());
157 if (!gGeoManager->cd(path)) {
158 std::stringstream msg;
159 msg <<
"Node with path " << path <<
" is not found in the geo manager";
160 throw std::runtime_error(msg.str());
163 auto* matrix{gGeoManager->GetCurrentMatrix()};
164 const double* translation{matrix->GetTranslation()};
165 auto* volume{gGeoManager->GetCurrentVolume()};
166 auto*
shape{volume->GetShape()};
167 auto GetDimension = [&](
int iD) {
170 shape->GetAxisRange(iD + 1, min, max);
171 return std::make_pair<double, double>(min + translation[iD], max + translation[iD]);
173 std::tie(res.
fXmin, res.
fXmax) = GetDimension(0);
174 std::tie(res.
fYmin, res.
fYmax) = GetDimension(1);
175 std::tie(res.
fZmin, res.
fZmax) = GetDimension(2);
184 std::stringstream msg;
186 <<
", xMax = " <<
fXmax <<
", yMin = " <<
fYmin <<
", yMax = " <<
fYmax;
Base abstract class for tracking detector interface to L1 (implementation of Checker)
friend fscal max(fscal x, fscal y)
friend fscal min(fscal x, fscal y)
double GetYmin(int stationId) const
Gets lower bound of a station passive volume along the Y-axis.
int GetNtrackingStations() const
Gets actual number of stations, provided by the current geometry setup.
double GetZref(int stationId) const
Gets reference z of the station passive volume.
virtual std::string GetDetectorName() const =0
Returns the name of the detector subsystem.
double GetActiveXmin(int stationId) const
Gets lower bound of the station active volume along x-axis.
double GetActiveZmax(int stationId) const
Gets upper bound of the station active volume along z-axis.
std::string ToString() const
Prints all the parameters into table and saves the table as a string.
double GetActiveYmax(int stationId) const
Gets upper bound of the station active volume along y-axis.
double GetZmax(int stationId) const
Gets max z of the station passive volume.
virtual bool IsTimeInfoProvided(int stationId) const =0
Check if station provides time measurements.
VolumeInfo ReadVolume(const TString &path)
Creates volume info from a geo node provided by path.
std::vector< TString > CollectNodes(const TString &detector, const TString &component, const TString &path, TGeoNode *pNode)
Collects paths of the components.
double GetActiveYmin(int stationId) const
Gets lower bound of the station active volume along y-axis.
double GetXmin(int stationId) const
Gets lower bound of a station passive volume along the X-axis.
double GetYmax(int stationId) const
Gets upper bound of a station passive volume along the Y-axis.
double GetXmax(int stationId) const
Gets upper bound of a station passive volume along the X-axis.
double GetActiveZmin(int stationId) const
Gets lower bound of the station active volume along z-axis.
bool Check() const
Checks detector interface: boundary conditions of the parameters.
double GetActiveXmax(int stationId) const
Gets upper bound of the station active volume along x-axis.
double GetZmin(int stationId) const
Gets min z of the station passive volume.
Structure to store geometry information of each station.
double fYmax
Upper bound in y-direction [cm].
double fZmin
Lower bound in z-direction [cm].
double fXmax
Upper bound in x-direction [cm].
std::string ToString() const
String representation of the structure.
double fYmin
Lower bound in y-direction [cm].
double fXmin
Lower bound in x-direction [cm].
double fZmax
Upper bound in z-direction [cm].