diff --git a/reco/L1/L1Algo/L1Algo.h b/reco/L1/L1Algo/L1Algo.h index 5f4077e342e1f8a6252d3de4ebf6875691d4957b..670211ee1c5006a2adc8cc010d2a8f6457492aeb 100644 --- a/reco/L1/L1Algo/L1Algo.h +++ b/reco/L1/L1Algo/L1Algo.h @@ -37,7 +37,16 @@ class L1AlgoDraw; //#define MERGE_CLONES +/********************************************************************************* + ************ TEMPORARY MACROS, SHOULD BE REMOVED (TODO!!, S. Zharko) *********** + * */ + #define FEATURING_L1ALGO_INIT 1 // If defined, new initialization will be used, if not - the old one +// Macro: 1 - new track finder loop, other - old track finder loop +#define FEATURING_L1ALGO_CATRACKFINDER_ITERATIONLOOP 1 + +/* * + *********************************************************************************/ #include <array> #include <iomanip> diff --git a/reco/L1/L1Algo/L1Assert.h b/reco/L1/L1Algo/L1Assert.h new file mode 100644 index 0000000000000000000000000000000000000000..aface5465aa8083666b58fda699a5709847c2426 --- /dev/null +++ b/reco/L1/L1Algo/L1Assert.h @@ -0,0 +1,53 @@ +/* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergey Gorbunov, Sergei Zharko [committer] */ + +/// @file L1Assert.h +/// @author Sergei Zharko +/// @date 22.02.2022 +/// @brief Level-defined assertion functionality +/// +/// This file provides level-dependent assertion mechanism. Two defined macros L1ASSERT(LEVEL, COND) +/// and L1MASSERT(LEVEL, COND, MSG), which will do the assertion for LEVEL >= L1Assert::kAssertionLevel +/// and skip it otherwise. When L1ASSERT(LEVEL, COND) is called the COND expression is printed on the screen. +/// When L + + + +#ifndef L1Assert_h +#define L1Assert_h 1 + +#include "FairLogger.h" + +#if defined(NDEBUG) || defined(L1_NO_ASSERT) +#define L1ASSERT(LEVEL, COND) +#define L1MASSERT(LEVEL, COND, MSG) +#else +#define L1ASSERT(LEVEL, COND) L1Assert::DoAssertion<(LEVEL) >= L1Assert::kAssertionLevel>((LEVEL), (COND), (#COND), __FILE__, __LINE__) +#define L1MASSERT(LEVEL, COND, MSG) L1Assert::DoAssertion<(LEVEL) >= L1Assert::kAssertionLevel>((LEVEL), (COND), (MSG), __FILE__, __LINE__) +#endif // defined(NDEBUG) || defined(L1_NO_ASSERT) + +namespace L1Assert { + constexpr int kAssertionLevel {1}; + + /// Basic template function. Usage: place "level >= L1Assert::kAssertionLevel" + template <bool IsAsserted> + int DoAssertion (int level, bool condition, const char* msg, const char* fileName, int lineNo); + + /// Specialization in case of IsAsserted = true, i.e. the assertion is made + template <> + int DoAssertion<true>(int level, bool condition, const char* msg, const char* fileName, int lineNo) + { + if (!condition) { + LOG(fatal) << "Level " << level << " assertion failed: " << msg << " (" << fileName << " : " << lineNo << ")\n"; + //std::abort(); // Do we need it with LOG(fatal)? + } + return 1; + } + + /// Specialization in case of IsAsserted = false, i.e. the assertion is not made + template <> + int DoAssertion<false>(int level, bool condition, const char* msg, const char* fileName, int lineNo) { return 0 }; +}; + +#endif // L1Assert_h