Skip to content
Snippets Groups Projects
Commit 616f957a authored by Sergei Zharko's avatar Sergei Zharko
Browse files

L1: added limits check for tracking iteration parameters

parent 6e35fa2b
No related branches found
No related tags found
1 merge request!972L1: Finalized track finder iterations + envelope classes for tracking QA
Pipeline #19292 passed
...@@ -11,15 +11,18 @@ ...@@ -11,15 +11,18 @@
#include "L1CAIteration.h" #include "L1CAIteration.h"
#include <FairLogger.h>
#include <sstream> #include <sstream>
//
//---------------------------------------------------------------------------------------------------------------------- #include "L1Constants.h"
using namespace L1Constants::size;
// ---------------------------------------------------------------------------------------------------------------------
// //
L1CAIteration::L1CAIteration() noexcept { LOG(debug) << "L1CAIteration: Default constructor called for " << this; } L1CAIteration::L1CAIteration() noexcept { LOG(debug) << "L1CAIteration: Default constructor called for " << this; }
//
//---------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------
// //
L1CAIteration::L1CAIteration(const L1CAIteration& other) noexcept L1CAIteration::L1CAIteration(const L1CAIteration& other) noexcept
// Basic fields // Basic fields
...@@ -46,31 +49,31 @@ L1CAIteration::L1CAIteration(const L1CAIteration& other) noexcept ...@@ -46,31 +49,31 @@ L1CAIteration::L1CAIteration(const L1CAIteration& other) noexcept
, fIfSuppressGhost(other.fIfSuppressGhost) , fIfSuppressGhost(other.fIfSuppressGhost)
{ {
} }
//
//---------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------
// //
L1CAIteration::L1CAIteration(L1CAIteration&& other) noexcept L1CAIteration::L1CAIteration(L1CAIteration&& other) noexcept
{ {
this->Swap(other); this->Swap(other);
} }
//
//---------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------
// //
L1CAIteration::L1CAIteration(const std::string& name) noexcept : fName(name) {} L1CAIteration::L1CAIteration(const std::string& name) noexcept : fName(name) {}
//
//---------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------
// //
L1CAIteration::~L1CAIteration() noexcept {} L1CAIteration::~L1CAIteration() noexcept {}
//
//---------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------
// //
L1CAIteration& L1CAIteration::operator=(const L1CAIteration& other) noexcept L1CAIteration& L1CAIteration::operator=(const L1CAIteration& other) noexcept
{ {
if (this != &other) { L1CAIteration(other).Swap(*this); } if (this != &other) { L1CAIteration(other).Swap(*this); }
return *this; return *this;
} }
//
//---------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------
// //
L1CAIteration& L1CAIteration::operator=(L1CAIteration&& other) noexcept L1CAIteration& L1CAIteration::operator=(L1CAIteration&& other) noexcept
{ {
...@@ -80,24 +83,46 @@ L1CAIteration& L1CAIteration::operator=(L1CAIteration&& other) noexcept ...@@ -80,24 +83,46 @@ L1CAIteration& L1CAIteration::operator=(L1CAIteration&& other) noexcept
} }
return *this; return *this;
} }
// ---------------------------------------------------------------------------------------------------------------------
// //
//---------------------------------------------------------------------------------------------------------------------- bool L1CAIteration::Check() const
{
bool res = true;
// TODO: SZh 06.10.2022: These values should be tuned
res = this->CheckValueLimits<float>("track_chi2_cut", fTrackChi2Cut, 0.f, 12.f) && res;
res = this->CheckValueLimits<float>("triplet_chi2_cut", fTripletChi2Cut, 0.f, 30.f) && res;
res = this->CheckValueLimits<float>("doublet_chi2_cut", fDoubletChi2Cut, 0.f, 15.f) && res;
res = this->CheckValueLimits<float>("pick_gather", fPickGather, 2.f, 5.f) && res;
res = this->CheckValueLimits<float>("pick_neighbour", fPickNeighbour, 2.f, 6.f) && res;
res = this->CheckValueLimits<float>("min_momentum", fMaxInvMom, 1.f / 1.f, 1.f / 0.05f) && res;
res = this->CheckValueLimits<float>("max_slope_pv", fMaxSlopePV, 0.1f, 2.f) && res;
res = this->CheckValueLimits<float>("max_slope", fMaxSlope, 1.f, 3.f) && res;
res = this->CheckValueLimits<float>("max_dz", fMaxDZ, 0.f, 1.0f) && res;
res = this->CheckValueLimits<int>("min_start_triplet_lvl", fMinLevelTripletStart, 0, 5) && res;
res = this->CheckValueLimits<int>("first_station_index", fFirstStationIndex, 0, kMaxNstations) && res;
res = this->CheckValueLimits<float>("target_pos_sigma_x", fTargetPosSigmaX, 0.01f, 15.f) && res;
res = this->CheckValueLimits<float>("target_pos_sigma_y", fTargetPosSigmaY, 0.01f, 15.f) && res;
return res;
}
// ---------------------------------------------------------------------------------------------------------------------
// //
void L1CAIteration::Print(int verbosityLevel) const void L1CAIteration::Print(int verbosityLevel) const
{ {
if (verbosityLevel == 0) { LOG(info) << " - " << fName; } if (verbosityLevel == 0) { LOG(info) << " - " << fName; }
if (verbosityLevel > 0) { LOG(info) << ToString(0); } if (verbosityLevel > 0) { LOG(info) << ToString(0); }
} }
//
//---------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------
// //
void L1CAIteration::SetTargetPosSigmaXY(float sigmaX, float sigmaY) void L1CAIteration::SetTargetPosSigmaXY(float sigmaX, float sigmaY)
{ {
fTargetPosSigmaX = sigmaX; fTargetPosSigmaX = sigmaX;
fTargetPosSigmaY = sigmaY; fTargetPosSigmaY = sigmaY;
} }
//
//---------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------
// //
void L1CAIteration::Swap(L1CAIteration& other) noexcept void L1CAIteration::Swap(L1CAIteration& other) noexcept
{ {
...@@ -124,8 +149,8 @@ void L1CAIteration::Swap(L1CAIteration& other) noexcept ...@@ -124,8 +149,8 @@ void L1CAIteration::Swap(L1CAIteration& other) noexcept
std::swap(fIfJumped, other.fIfJumped); std::swap(fIfJumped, other.fIfJumped);
std::swap(fIfSuppressGhost, other.fIfSuppressGhost); std::swap(fIfSuppressGhost, other.fIfSuppressGhost);
} }
//
//---------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------
// //
std::string L1CAIteration::ToString(int indentLevel) const std::string L1CAIteration::ToString(int indentLevel) const
{ {
... ...
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#ifndef L1CAIteration_h #ifndef L1CAIteration_h
#define L1CAIteration_h 1 #define L1CAIteration_h 1
#include <FairLogger.h>
#include <boost/serialization/access.hpp> #include <boost/serialization/access.hpp>
#include <boost/serialization/string.hpp> #include <boost/serialization/string.hpp>
...@@ -48,6 +50,9 @@ public: ...@@ -48,6 +50,9 @@ public:
/// Move assignment operator /// Move assignment operator
L1CAIteration& operator=(L1CAIteration&& other) noexcept; L1CAIteration& operator=(L1CAIteration&& other) noexcept;
/// Checks parameters consistency
bool Check() const;
/// Gets doublet chi2 upper cut /// Gets doublet chi2 upper cut
float GetDoubletChi2Cut() const { return fDoubletChi2Cut; } float GetDoubletChi2Cut() const { return fDoubletChi2Cut; }
...@@ -270,8 +275,29 @@ private: ...@@ -270,8 +275,29 @@ private:
ar& fIfSuppressGhost; ar& fIfSuppressGhost;
} }
/// Checks, if a particular value lies within selected limits. In case of fail throws std::logic_error
/// \param name Name of parameters
/// \param value Value of parameter
/// \param lLimit Lower limit of parameter
/// \param uLimit Upper limit of parameter
template<typename T>
static bool CheckValueLimits(const std::string& name, T value, T lLimit, T uLimit);
// ^ TODO: invent more proper name // ^ TODO: invent more proper name
}; };
// ---------------------------------------------------------------------------------------------------------------------
// TODO: SZh. 06.10.2022: Probably, this method should be replaced to L1Utils
template<typename T>
bool L1CAIteration::CheckValueLimits(const std::string& name, T value, T lLimit, T uLimit)
{
if (value < lLimit || value > uLimit) {
LOG(error) << "parameter\033[1;32m" << name << "\033[0m (" << value << ") runs out of range: [" << lLimit << ','
<< uLimit << ']';
return false;
}
return true;
}
#endif // L1CAIteration_h #endif // L1CAIteration_h
...@@ -235,8 +235,10 @@ void L1Parameters::CheckConsistency() const ...@@ -235,8 +235,10 @@ void L1Parameters::CheckConsistency() const
/* /*
* Check iterations sequence * Check iterations sequence
* 1. Number of iterations with TrackFromTriplets flag turned on no more then 1 * 1. Number of iterations should be larger then zero
* 2. If this iteration exists, it should be the last one in the sequence * 2. Each iteration should contain values within predefined limits
* 3. Number of iterations with TrackFromTriplets flag turned on no more then 1
* 4. If the TrackFromTriplets iteration exists, it should be the last one in the sequence
*/ */
{ {
int nIterations = fCAIterations.size(); int nIterations = fCAIterations.size();
...@@ -246,6 +248,16 @@ void L1Parameters::CheckConsistency() const ...@@ -246,6 +248,16 @@ void L1Parameters::CheckConsistency() const
throw std::logic_error(msg.str()); throw std::logic_error(msg.str());
} }
std::string names = "";
for (const auto iter : fCAIterations) {
if (!iter.Check()) { names += iter.GetName() + " "; }
}
if (names.size()) {
std::stringstream msg;
msg << "L1Parameters: some parameters are out of range for the following iterations: " << names;
throw std::logic_error(msg.str());
}
nIterations = std::count_if(fCAIterations.begin(), fCAIterations.end(), nIterations = std::count_if(fCAIterations.begin(), fCAIterations.end(),
[=](const L1CAIteration& it) { return it.GetTrackFromTripletsFlag(); }); [=](const L1CAIteration& it) { return it.GetTrackFromTripletsFlag(); });
if (nIterations > 1) { if (nIterations > 1) {
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment