diff --git a/core/base/CbmTrackingDetectorInterfaceBase.cxx b/core/base/CbmTrackingDetectorInterfaceBase.cxx index 7e394603ab419959ed989c9aa3081d5380757a9e..9fad5ba1241c38f45e9c2784d4ecec64b2714b4a 100644 --- a/core/base/CbmTrackingDetectorInterfaceBase.cxx +++ b/core/base/CbmTrackingDetectorInterfaceBase.cxx @@ -17,75 +17,110 @@ bool CbmTrackingDetectorInterfaceBase::Check() const { - bool res = true; - std::string prefix = std::string("Detector interface for ") + this->GetDetectorName() + ": "; + bool res = true; + std::stringstream msg; + msg << "Errors in the detector interface initialization for " << this->GetDetectorName() << ":\n"; // Number of stations if (this->GetNtrackingStations() < 1) { - LOG(error) << prefix << "Number of stations is less then 1(" << this->GetNtrackingStations() << ")"; + msg << "\t- Number of stations is less then 1(" << this->GetNtrackingStations() << ")"; res = false && res; } else { - // Position along beam axis - std::vector<double> zPositions(this->GetNtrackingStations()); + + // Station individual parameters check for (int iSt = 0; iSt < this->GetNtrackingStations(); ++iSt) { - zPositions[iSt] = this->GetZ(iSt); - } - std::set<double> zPositionSet(zPositions.begin(), zPositions.end()); - if (zPositions.size() != zPositionSet.size()) { - LOG(error) << prefix << "Some of stations have the same z position component:"; - for (size_t iSt = 0; iSt < zPositions.size(); ++iSt) { - LOG(error) << "\tstation " << iSt << ", z = " << zPositions[iSt] << " cm"; + std::string prefix = std::string("\t- Station ") + std::to_string(iSt) + " has "; + // Position along Z-axis + if (std::isnan(this->GetZ(iSt))) { + msg << prefix << " NaN component along Z-axis (" << this->GetZ(iSt) << " cm)\n"; + res = false && res; } - res = false && res; - } - // Station sizes check - for (int iSt = 0; iSt < this->GetNtrackingStations(); ++iSt) { // Size along X-axis - if (this->GetXmax(iSt) < std::numeric_limits<double>::epsilon()) { - LOG(error) << prefix << "Station " << iSt << " has zero or negative X-size (" << this->GetXmax(iSt) << " cm)"; + auto xMax = this->GetXmax(iSt); + if (xMax < std::numeric_limits<double>::epsilon() || std::isnan(xMax)) { + msg << prefix << " zero, negative or NaN X-size (" << xMax << " cm)\n"; res = false && res; } // Size along Y-axis - if (this->GetYmax(iSt) < std::numeric_limits<double>::epsilon()) { - LOG(error) << prefix << "Station " << iSt << " has zero or negative Y-size (" << this->GetYmax(iSt) << " cm)"; + auto yMax = this->GetYmax(iSt); + if (yMax < std::numeric_limits<double>::epsilon() || std::isnan(yMax)) { + msg << prefix << " zero, negative or NaN Y-size (" << yMax << " cm)\n"; res = false && res; } // Max station radius - if (this->GetRmax(iSt) < std::numeric_limits<double>::epsilon()) { - LOG(error) << prefix << "Station " << iSt << " has zero or negative outer radius (" << this->GetRmax(iSt) - << " cm)"; + auto rMax = this->GetRmax(iSt); + if (rMax < std::numeric_limits<double>::epsilon() || std::isnan(rMax)) { + msg << prefix << " zero, negative or NaN outer radius (" << rMax << " cm)\n"; res = false && res; } // Min station radius - if (this->GetRmin(iSt) < 0) { - LOG(error) << prefix << "Station " << iSt << " has negative inner radius (" << this->GetRmin(iSt) << " cm)"; + auto rMin = this->GetRmin(iSt); + if (rMin < 0 || std::isnan(rMin)) { + msg << prefix << " negative or NaN inner radius (" << rMin << " cm)\n"; + res = false && res; + } + + // Front strips stereo angle + auto angleF = this->GetStripsStereoAngleFront(iSt); + if (std::isnan(angleF)) { + msg << prefix << " NaN front strips stereo angle (" << angleF << " rad)\n"; + res = false && res; + } + + // Back strips stereo angle + auto angleB = this->GetStripsStereoAngleBack(iSt); + if (std::isnan(angleF)) { + msg << prefix << " NaN back strips stereo angle (" << angleB << " rad)\n"; res = false && res; } // Front strips spatial resolution - if (this->GetStripsSpatialRmsFront(iSt) < std::numeric_limits<double>::epsilon()) { - LOG(error) << prefix << "Station " << iSt << " has zero or negative front strips spatial resolution (" - << this->GetStripsSpatialRmsFront(iSt) << " cm)"; + auto rmsF = this->GetStripsSpatialRmsFront(iSt); + if (rmsF < std::numeric_limits<double>::epsilon() || std::isnan(rmsF)) { + msg << prefix << " zero, negative or NaN front strips spatial resolution (" << rmsF << " cm)\n"; res = false && res; } // Back strips spatial resolution - if (this->GetStripsSpatialRmsBack(iSt) < std::numeric_limits<double>::epsilon()) { - LOG(error) << prefix << "Station " << iSt << " has zero or negative back strips spatial resolution (" - << this->GetStripsSpatialRmsBack(iSt) << " cm)"; + auto rmsB = this->GetStripsSpatialRmsBack(iSt); + if (rmsB < std::numeric_limits<double>::epsilon() || std::isnan(rmsB)) { + msg << prefix << " zero, negative or NaN back strips spatial resolution (" << rmsB << " cm)\n"; res = false && res; } + + // Time resolution + auto timeRes = this->GetTimeResolution(iSt); + if (timeRes < std::numeric_limits<double>::epsilon() || std::isnan(timeRes)) { + msg << prefix << " zero, negative or NaN time resolution (" << timeRes << " cm)\n"; + res = false && res; + } + } + + // Position along beam axis + std::vector<double> zPositions(this->GetNtrackingStations()); + for (int iSt = 0; iSt < this->GetNtrackingStations(); ++iSt) { + zPositions[iSt] = this->GetZ(iSt); + } + std::set<double> zPositionSet(zPositions.begin(), zPositions.end()); + if (zPositions.size() != zPositionSet.size()) { + msg << "\t- Some of stations have the same z position component:\n"; + for (size_t iSt = 0; iSt < zPositions.size(); ++iSt) { + msg << "\t\tstation " << iSt << ", z = " << zPositions[iSt] << " cm\n"; + } + res = false && res; } } + if (!res) { - LOG(error) << "\033[4mErrors above mean that CA tracking cannot be used for the current version of " + LOG(error) << msg.str() << "\033[4mErrors above mean that CA tracking cannot be used for the current version of " << this->GetDetectorName() << " setup. Please, check if the " << this->GetDetectorName() << " setup parameters and the corresponding tracking detector interface are initialized properly\033[0m"; } + return res; } diff --git a/core/base/CbmTrackingDetectorInterfaceBase.h b/core/base/CbmTrackingDetectorInterfaceBase.h index 349df6208683a635797a00ec31a7acc1462304c8..c5a5827beef8e149d269232ad143a33b357b5bdf 100644 --- a/core/base/CbmTrackingDetectorInterfaceBase.h +++ b/core/base/CbmTrackingDetectorInterfaceBase.h @@ -29,6 +29,10 @@ public: /// Gets actual number of stations, provided by the current geometry setup virtual int GetNtrackingStations() const = 0; + // TODO: SZh 17.10.2022: At the moment the radiation length and the station thickness are not used for the tracking + // initialization as soon as the material budget maps are in use. Should we keep these + // accessors here, or just remove them from the interfaces? + /// Gets station radiation length /// \param stationId Tracking station ID in the setup (NOTE: must be in range [0..GetNstations()-1]) /// \return Radiation length [cm]