From e81bb3760e8293ddc26874098d43e9fced425696 Mon Sep 17 00:00:00 2001
From: "s.zharko@gsi.de" <s.zharko@gsi.de>
Date: Fri, 4 Mar 2022 21:17:46 +0100
Subject: [PATCH] L1Assert added

---
 reco/L1/CMakeLists.txt    |  1 +
 reco/L1/CbmL1.cxx         |  3 ++-
 reco/L1/L1Algo/L1Assert.h | 24 +++++++++++++-----------
 3 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/reco/L1/CMakeLists.txt b/reco/L1/CMakeLists.txt
index 7dffdb0df8..d2602fd95d 100644
--- a/reco/L1/CMakeLists.txt
+++ b/reco/L1/CMakeLists.txt
@@ -255,6 +255,7 @@ endif()
 
 GENERATE_LIBRARY()
 Install(FILES CbmL1Counters.h
+              L1Algo/L1Assert.h
               L1Algo/L1EventEfficiencies.h
               L1Algo/L1Grid.h
               L1Algo/L1Branch.h
diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx
index 1cc5edfcd1..d5e83ce1fa 100644
--- a/reco/L1/CbmL1.cxx
+++ b/reco/L1/CbmL1.cxx
@@ -71,6 +71,7 @@
 #include "L1Algo/L1Branch.h"
 #include "L1Algo/L1Field.h"
 #include "L1Algo/L1Hit.h"
+#include "L1Algo/L1Assert.h"
 #include "L1AlgoInputData.h"
 #include "L1Event.h"
 
@@ -842,7 +843,7 @@ InitStatus CbmL1::Init()
     // Step 4: initialize IDs of detectors active in tracking
     // TODO: temporary for tests, must be initialized somewhere in run_reco.C or similar (S.Zh.)
     fActiveTrackingDetectorIDs = {L1DetectorID::kMvd, L1DetectorID::kSts};
-    initMan->SetActiveDetectorIDs(fActiveTrackingDetectorIDs);
+    //initMan->SetActiveDetectorIDs(fActiveTrackingDetectorIDs);
 
     constexpr double PI = 3.14159265358;  // TODO: why cmath is not used? (S.Zh.)
 
diff --git a/reco/L1/L1Algo/L1Assert.h b/reco/L1/L1Algo/L1Assert.h
index aface5465a..a08eca9315 100644
--- a/reco/L1/L1Algo/L1Assert.h
+++ b/reco/L1/L1Algo/L1Assert.h
@@ -10,10 +10,8 @@
 /// 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
-
-
-
+/// When L1MASSERT(LEVEL, COND, MSG) is called, the MSG will be printed instead of expression
+///
 #ifndef L1Assert_h
 #define L1Assert_h 1
 
@@ -23,20 +21,24 @@
 #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__)
+#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 {
+  /// Assertion levels
+  /// 0 - 
+  /// 1 - 
+  /// 2 - 
   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);
+  //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)
+  template <bool IsAsserted>
+  int DoAssertion(int level, bool condition, const char* msg, const char* fileName, int lineNo)
   {
     if (!condition) {
       LOG(fatal) << "Level " << level << " assertion failed: " << msg << " (" << fileName << " : " << lineNo << ")\n";
@@ -47,7 +49,7 @@ namespace L1Assert {
 
   /// 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 };
+  constexpr int DoAssertion<false>(int /*level*/, bool /*condition*/, const char* /*msg*/, const char* /*fileName*/, int /*lineNo*/) { return 0; }
 };
 
 #endif // L1Assert_h
-- 
GitLab