diff --git a/algo/ca/core/CMakeLists.txt b/algo/ca/core/CMakeLists.txt
index 92b404c128f5e14cafd3c4b3617c4fce6d27d176..c43f891688d8c54d921e79cef8e0ca61093b17d4 100644
--- a/algo/ca/core/CMakeLists.txt
+++ b/algo/ca/core/CMakeLists.txt
@@ -75,6 +75,7 @@ install(
     utils/CaSimdPseudo.h
     utils/CaVector.h
     utils/CaUtils.h
+    utils/CaDefines.h
   DESTINATION
     include/
 )
diff --git a/algo/ca/core/data/CaGridArea.h b/algo/ca/core/data/CaGridArea.h
index 39632d9e4cb2980c16966802d41694c48d202293..5ec34be08fa490ed9ee533e3c68392b9d678d260 100644
--- a/algo/ca/core/data/CaGridArea.h
+++ b/algo/ca/core/data/CaGridArea.h
@@ -10,6 +10,7 @@
 #include "CaGrid.h"
 #include "CaHit.h"
 #include "CaSimd.h"
+#include "CaUtils.h"
 
 namespace cbm::algo::ca
 {
@@ -81,20 +82,14 @@ namespace cbm::algo::ca
     bool xIndexOutOfRange = (fCurentEntry >= fEntriesXend);  // current entry is not in the area
 
     // jump to the next y row if fCurentEntry is outside of the X area
-    // TODO use ISUNLIKELY() macro here
-    while (xIndexOutOfRange) {
-      if (fAreaCurrentBinY >= fAreaLastBinY) { return false; }
+    while (utils::IsUnlikely(xIndexOutOfRange)) {
+      if (utils::IsUnlikely(fAreaCurrentBinY >= fAreaLastBinY)) { return false; }
       fAreaCurrentBinY++;            // get new y-line
       fAreaFirstBin += fGridNbinsX;  // move the left-down corner of the area to the next y-line
       fCurentEntry     = fGrid.GetFirstBinEntryIndex(fAreaFirstBin);  // get first hit in cell, if y-line is new
       fEntriesXend     = fGrid.GetFirstBinEntryIndex(fAreaFirstBin + fAreaNbinsX);
       xIndexOutOfRange = (fCurentEntry >= fEntriesXend);
     }
-
-    // TODO:: include L1_ASSERT and uncomment
-    //L1_ASSERT(fCurentEntry < fGrid.FirstHitInBin(fGrid.N()) || xIndexOutOfRange,
-    //          fCurentEntry << " < " << fGrid.FirstHitInBin(fGrid.N()) << " || " << xIndexOutOfRange);
-
     ind = fCurentEntry;  // return value
     fCurentEntry++;      // go to next
     return true;
diff --git a/algo/ca/core/utils/CaDefines.h b/algo/ca/core/utils/CaDefines.h
new file mode 100644
index 0000000000000000000000000000000000000000..d98b0fc592e5d1fc6a01676287b61c7197d4c423
--- /dev/null
+++ b/algo/ca/core/utils/CaDefines.h
@@ -0,0 +1,32 @@
+/* Copyright (C) 2010-2021 Frankfurt Institute for Advanced Studies, Goethe-Universität Frankfurt, Frankfurt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Maksym Zyzak, Igor Kulakov [committer], Sergey Gorbunov */
+
+/// \file CaDefines.h
+/// \brief Macros for the CA tracking algorithm
+/// \details Try to minimize the amount of macros. Try to call this header only from cxx files.
+
+#ifndef CaDefines_h
+#define CaDefines_h
+
+#include <iostream>
+
+#include <assert.h>
+
+// #define CBMCA_DEBUG_MODE
+
+#if defined(CBMCA_DEBUG_MODE)
+
+#define CBMCA_DEBUG_ASSERT(v)                                                                                          \
+  if (!(v)) {                                                                                                          \
+    std::cerr << __FILE__ << ":" << __LINE__ << " assertion failed: " << #v << " = " << (v) << std::endl;              \
+    assert(v);                                                                                                         \
+  }
+#else  // not CBMCA_DEBUG_MODE
+
+#define CBMCA_DEBUG_ASSERT(v)
+
+#endif  // CBMCA_DEBUG_MODE
+
+
+#endif  // CaDefines_h
diff --git a/algo/ca/core/utils/CaUtils.h b/algo/ca/core/utils/CaUtils.h
index 45fa539e23a49dc9ab7636f0bc32d1f45b9d3096..a3e7cc079436344151428929fafdb01a4ab5544f 100644
--- a/algo/ca/core/utils/CaUtils.h
+++ b/algo/ca/core/utils/CaUtils.h
@@ -30,13 +30,32 @@ namespace cbm::algo::ca::utils
     return b ? t : f;
   }
 
-
   template<typename T>
   inline T fabs(const T& v)
   {
     return std::fabs(v);
   }
 
+  /// tell the CPU that the bool condition is likely to be true
+  __always_inline bool IsLikely(bool b)
+  {
+#if defined(__GNUC__) && __GNUC__ - 0 >= 3
+    return __builtin_expect(!!(b), 1);
+#else
+    return b;
+#endif
+  }
+
+  /// tell the CPU that the bool condition is unlikely to be true
+  __always_inline bool IsUnlikely(bool b)
+  {
+#if defined(__GNUC__) && __GNUC__ - 0 >= 3
+    return __builtin_expect(!!(b), 0);
+#else
+    return b;
+#endif
+  }
+
   /// \brief Checks whether a variable of a particular type defined
   /// \param val Value to be checked
   template<typename T>
diff --git a/reco/KF/obsolete/CbmL1TofMerger.cxx b/reco/KF/obsolete/CbmL1TofMerger.cxx
index 1c56302daf3cf3116fead98084196529f3514bc7..791cc190211ef8364ba75e9e7e83cac6377f77fe 100644
--- a/reco/KF/obsolete/CbmL1TofMerger.cxx
+++ b/reco/KF/obsolete/CbmL1TofMerger.cxx
@@ -74,7 +74,7 @@ void CbmL1TofMerger::Init()
          << "ROOT manager is not instantiated!" << endl;
     return;
   }
-  fArrayTrdTrack = L1_DYNAMIC_CAST<TClonesArray*>(rootMgr->GetObject("TrdTrack"));
+  fArrayTrdTrack = dynamic_cast<TClonesArray*>(rootMgr->GetObject("TrdTrack"));
   if (NULL == fArrayTrdTrack) {
     cout << "-W- CbmL1TofMerger::Init: "
          << "no TRD track array" << endl;
@@ -131,7 +131,7 @@ Int_t CbmL1TofMerger::DoMerge(TClonesArray* glbTracks, TClonesArray* tofHits)
       if (mapTrack.find(iTrack) == mapTrack.end()) continue;
 
       // Get pointer to the global track
-      track = L1_DYNAMIC_CAST<CbmGlobalTrack*>(glbTracks->At(iTrack));
+      track = dynamic_cast<CbmGlobalTrack*>(glbTracks->At(iTrack));
       if (NULL == track) {
         mapTrack.erase(iTrack);
         continue;
@@ -145,7 +145,7 @@ Int_t CbmL1TofMerger::DoMerge(TClonesArray* glbTracks, TClonesArray* tofHits)
 
       // Get TRD track
       trdTrackIndex = track->GetTrdTrackIndex();
-      trdTrack      = L1_DYNAMIC_CAST<CbmTrdTrack*>(fArrayTrdTrack->At(trdTrackIndex));
+      trdTrack      = dynamic_cast<CbmTrdTrack*>(fArrayTrdTrack->At(trdTrackIndex));
       if (NULL == trdTrack) {
         mapTrack.erase(iTrack);
         continue;
@@ -161,7 +161,7 @@ Int_t CbmL1TofMerger::DoMerge(TClonesArray* glbTracks, TClonesArray* tofHits)
         // Check if pair is not forbidden
         if (mapForbidden[make_pair(iTrack, iTof)]) continue;
         // Get TOF hit
-        tofHit = L1_DYNAMIC_CAST<CbmTofHit*>(tofHits->At(iTof));
+        tofHit = dynamic_cast<CbmTofHit*>(tofHits->At(iTof));
         if (NULL == tofHit) continue;
         // Get z position of hit
         zposTof = tofHit->GetZ();
@@ -186,7 +186,7 @@ Int_t CbmL1TofMerger::DoMerge(TClonesArray* glbTracks, TClonesArray* tofHits)
           if (chi2min < mapTofHitChi2[indexOfClosest]) {
             // Force previous track to be reprocessed
             oldTrackIndex = mapTofHitTrack[indexOfClosest];
-            track2        = L1_DYNAMIC_CAST<CbmGlobalTrack*>(glbTracks->At(oldTrackIndex));
+            track2        = dynamic_cast<CbmGlobalTrack*>(glbTracks->At(oldTrackIndex));
             track2->SetTofHitIndex(-1);
             mapTrack[oldTrackIndex] = kTRUE;
             nMerged -= 1;
diff --git a/reco/KF/obsolete/CbmL1TrackMerger.cxx b/reco/KF/obsolete/CbmL1TrackMerger.cxx
index 23d1c818c58acf595fc7164ed3e288a3e5f5ac81..2acf4de2e1736e0b5335e5b814127ca8b6d7090d 100644
--- a/reco/KF/obsolete/CbmL1TrackMerger.cxx
+++ b/reco/KF/obsolete/CbmL1TrackMerger.cxx
@@ -123,12 +123,12 @@ void CbmL1TrackMerger::Init()
          << "FairRootManager is not instantiated!" << endl;
     return;
   }
-  fArrayStsTrackM = L1_DYNAMIC_CAST<TClonesArray*>(rootMgr->GetObject("StsTrackMatch"));
+  fArrayStsTrackM = dynamic_cast<TClonesArray*>(rootMgr->GetObject("StsTrackMatch"));
   if (NULL == fArrayStsTrackM) {
     cout << "-W- CbmL1TrackMerger::Init : "
          << "no STS track match array" << endl;
   }
-  fArrayTrdTrackM = L1_DYNAMIC_CAST<TClonesArray*>(rootMgr->GetObject("TrdTrackMatch"));
+  fArrayTrdTrackM = dynamic_cast<TClonesArray*>(rootMgr->GetObject("TrdTrackMatch"));
   if (NULL == fArrayTrdTrackM) {
     cout << "-W- CbmL1TrackMerger::Init : "
          << "no TRD track match array" << endl;
@@ -170,7 +170,7 @@ Int_t CbmL1TrackMerger::MergeSimple(TClonesArray* stsTracks, TClonesArray* trdTr
   // and attach STS track
   for (Int_t iTrdTrack = 0; iTrdTrack < trdTracks->GetEntriesFast(); iTrdTrack++) {
     // Get pointer to the TRD track
-    trdTrack = L1_DYNAMIC_CAST<CbmTrdTrack*>(trdTracks->At(iTrdTrack));
+    trdTrack = dynamic_cast<CbmTrdTrack*>(trdTracks->At(iTrdTrack));
     if (NULL == trdTrack) continue;
     // Create global track
     glbTrack = new ((*glbTracks)[nGlb]) CbmGlobalTrack();
@@ -240,14 +240,14 @@ Int_t CbmL1TrackMerger::MergeImPlane(TClonesArray* stsTracks, TClonesArray* trdT
   // Loop over STS tracks
   for (Int_t iStsTrack = 0; iStsTrack < stsTracks->GetEntriesFast(); iStsTrack++) {
     // Get pointer to the STS track and track match
-    stsTrack = L1_DYNAMIC_CAST<CbmStsTrack*>(stsTracks->At(iStsTrack));
+    stsTrack = dynamic_cast<CbmStsTrack*>(stsTracks->At(iStsTrack));
     if (NULL == stsTrack) continue;
-    stsTrackM = L1_DYNAMIC_CAST<CbmTrackMatch*>(fArrayStsTrackM->At(iStsTrack));
+    stsTrackM = dynamic_cast<CbmTrackMatch*>(fArrayStsTrackM->At(iStsTrack));
     if (NULL == stsTrackM) continue;
 
     // Create global track
     new ((*glbTracks)[nGlb]) CbmGlobalTrack();
-    glbTrack = L1_DYNAMIC_CAST<CbmGlobalTrack*>(glbTracks->At(nGlb));
+    glbTrack = dynamic_cast<CbmGlobalTrack*>(glbTracks->At(nGlb));
     if (NULL == glbTrack) continue;
     nGlb += 1;
     // Set STS track index
@@ -261,9 +261,9 @@ Int_t CbmL1TrackMerger::MergeImPlane(TClonesArray* stsTracks, TClonesArray* trdT
       // Skip if already merged
       if (mapTrdTrackUsed[iTrdTrack]) continue;
       // Get pointer to the TRD track and track match
-      trdTrack = L1_DYNAMIC_CAST<CbmTrdTrack*>(trdTracks->At(iTrdTrack));
+      trdTrack = dynamic_cast<CbmTrdTrack*>(trdTracks->At(iTrdTrack));
       if (NULL == trdTrack) continue;
-      trdTrackM = L1_DYNAMIC_CAST<CbmTrackMatch*>(fArrayTrdTrackM->At(iTrdTrack));
+      trdTrackM = dynamic_cast<CbmTrackMatch*>(fArrayTrdTrackM->At(iTrdTrack));
       if (NULL == trdTrackM) continue;
       // Extrapolate STS track to the first plane of TRD track
       kfTrack.Extrapolate(trdTrack->GetParamFirst()->GetZ());
@@ -395,7 +395,7 @@ Int_t CbmL1TrackMerger::MergeImPlane(TClonesArray* stsTracks, TClonesArray* trdT
     if (mapTrdTrackUsed[iTrdTrack]) continue;
     // Create global track
     new ((*glbTracks)[nGlb]) CbmGlobalTrack();
-    glbTrack = L1_DYNAMIC_CAST<CbmGlobalTrack*>(glbTracks->At(nGlb));
+    glbTrack = dynamic_cast<CbmGlobalTrack*>(glbTracks->At(nGlb));
     if (NULL == glbTrack) continue;
     nGlb += 1;
     // Set TRD track index
diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx
index 62bb54989ae31113e105f5b9bdb5ebe6bd90e833..d72aafdb59c901594560aa7714e17c920a8ae987 100644
--- a/reco/L1/CbmL1.cxx
+++ b/reco/L1/CbmL1.cxx
@@ -204,7 +204,7 @@ InitStatus CbmL1::Init()
     fUseTRD  = 0;
     fUseTOF  = 0;
     // check if MVD is switched off in the Sts task
-    CbmStsFindTracks* findTask = L1_DYNAMIC_CAST<CbmStsFindTracks*>(FairRunAna::Instance()->GetTask("STSFindTracks"));
+    CbmStsFindTracks* findTask = dynamic_cast<CbmStsFindTracks*>(FairRunAna::Instance()->GetTask("STSFindTracks"));
     if (findTask) fUseMVD = findTask->MvdUsage();
   }
 
@@ -258,11 +258,11 @@ InitStatus CbmL1::Init()
   fTimeSlice = (CbmTimeSlice*) fairManager->GetObject("TimeSlice.");
   if (!fTimeSlice) { LOG(fatal) << GetName() << ": No time slice branch in the tree!"; }
 
-  fpStsClusters       = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("StsCluster"));
-  fpStsHitMatches     = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("StsHitMatch"));
-  fpStsClusterMatches = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("StsClusterMatch"));
+  fpStsClusters       = dynamic_cast<TClonesArray*>(fairManager->GetObject("StsCluster"));
+  fpStsHitMatches     = dynamic_cast<TClonesArray*>(fairManager->GetObject("StsHitMatch"));
+  fpStsClusterMatches = dynamic_cast<TClonesArray*>(fairManager->GetObject("StsClusterMatch"));
 
-  fpStsHits = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("StsHit"));
+  fpStsHits = dynamic_cast<TClonesArray*>(fairManager->GetObject("StsHit"));
 
   if (!fUseMUCH) {
     fpMuchPixelHits   = nullptr;
@@ -282,7 +282,7 @@ InitStatus CbmL1::Init()
     fpTrdHits       = nullptr;
   }
   else {
-    fpTrdHits = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("TrdHit"));
+    fpTrdHits = dynamic_cast<TClonesArray*>(fairManager->GetObject("TrdHit"));
   }
 
   if (!fUseTOF) {
@@ -310,8 +310,8 @@ InitStatus CbmL1::Init()
 
     if (fUseMVD) {
       fpMvdPoints      = mcManager->InitBranch("MvdPoint");
-      fpMvdDigiMatches = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("MvdDigiMatch"));
-      fpMvdHitMatches  = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("MvdHitMatch"));
+      fpMvdDigiMatches = dynamic_cast<TClonesArray*>(fairManager->GetObject("MvdDigiMatch"));
+      fpMvdHitMatches  = dynamic_cast<TClonesArray*>(fairManager->GetObject("MvdHitMatch"));
       if (!fpMvdHitMatches) { LOG(error) << "No fpMvdHitMatches provided, performance is not done correctly"; }
     }
 
@@ -336,7 +336,7 @@ InitStatus CbmL1::Init()
       fpMuchDigiMatches = (TClonesArray*) fairManager->GetObject("MuchDigiMatch");
       fpMuchClusters    = (TClonesArray*) fairManager->GetObject("MuchCluster");
       fpMuchPoints      = mcManager->InitBranch("MuchPoint");
-      fpMuchHitMatches  = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("MuchPixelHitMatch"));
+      fpMuchHitMatches  = dynamic_cast<TClonesArray*>(fairManager->GetObject("MuchPixelHitMatch"));
     }
 
     fpTofPoints = mcManager->InitBranch("TofPoint");
@@ -349,7 +349,7 @@ InitStatus CbmL1::Init()
 
   if (!fUseMVD) { fpMvdHits = 0; }
   else {
-    fpMvdHits = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("MvdHit"));
+    fpMvdHits = dynamic_cast<TClonesArray*>(fairManager->GetObject("MvdHit"));
   }
 
   // *****************************
@@ -956,7 +956,7 @@ void CbmL1::writedir2current(TObject* obj)
     TDirectory* cur = gDirectory;
     TDirectory* sub = cur->mkdir(obj->GetName());
     sub->cd();
-    TList* listSub = (L1_DYNAMIC_CAST<TDirectory*>(obj))->GetList();
+    TList* listSub = (dynamic_cast<TDirectory*>(obj))->GetList();
     TIter it(listSub);
     while (TObject* obj1 = it())
       writedir2current(obj1);
diff --git a/reco/L1/CbmL1Performance.cxx b/reco/L1/CbmL1Performance.cxx
index 3d396d0feb7d2afee94814112417f36a0858995b..52618e80610c9ac004e0b5e88d72d90694da828c 100644
--- a/reco/L1/CbmL1Performance.cxx
+++ b/reco/L1/CbmL1Performance.cxx
@@ -250,7 +250,7 @@ struct TL1PerfEfficiencies : public TL1Efficiencies {
   void PrintEff(bool ifPrintTableToLog = false, bool ifDeleteTable = false,
                 const std::string& nameOfTable = "efficiency_table")
   {
-    L1_assert(nEvents != 0);
+    assert(nEvents != 0);
     int NCounters = mc.GetNcounters();
     std::vector<std::string> rowNames(NCounters + 2);
     for (int iC = 0; iC < NCounters; ++iC) {
@@ -1974,7 +1974,7 @@ void CbmL1::InputPerformance()
   if (fpStsHits && fpStsHitMatches && fpStsPoints) {
     for (int iH = 0; iH < fpStsHits->GetEntriesFast(); iH++) {
 
-      const CbmStsHit* sh = L1_DYNAMIC_CAST<CbmStsHit*>(fpStsHits->At(iH));
+      const CbmStsHit* sh = dynamic_cast<CbmStsHit*>(fpStsHits->At(iH));
 
       //    int iMCPoint = -1;
       CbmLink link;
@@ -2048,8 +2048,8 @@ void CbmL1::InputPerformance()
     Int_t nEnt = fpMvdHits->GetEntriesFast();
     for (int j = 0; j < nEnt; j++) {
 
-      CbmMvdHit* sh = L1_DYNAMIC_CAST<CbmMvdHit*>(fpMvdHits->At(j));
-      CbmMatch* hm  = L1_DYNAMIC_CAST<CbmMatch*>(fpMvdHitMatches->At(j));
+      CbmMvdHit* sh = dynamic_cast<CbmMvdHit*>(fpMvdHits->At(j));
+      CbmMatch* hm  = dynamic_cast<CbmMatch*>(fpMvdHitMatches->At(j));
 
       CbmMvdPoint* pt = nullptr;
       {
@@ -2086,8 +2086,8 @@ void CbmL1::InputPerformance()
   if (fpMuchPixelHits && fpMuchHitMatches && fpMuchPoints) {
     for (int iH = 0; iH < fpMuchPixelHits->GetEntriesFast(); iH++) {
 
-      const CbmMuchPixelHit* sh = L1_DYNAMIC_CAST<CbmMuchPixelHit*>(fpMuchPixelHits->At(iH));
-      const CbmMatch* hm        = L1_DYNAMIC_CAST<CbmMatch*>(fpMuchHitMatches->At(iH));
+      const CbmMuchPixelHit* sh = dynamic_cast<CbmMuchPixelHit*>(fpMuchPixelHits->At(iH));
+      const CbmMatch* hm        = dynamic_cast<CbmMatch*>(fpMuchHitMatches->At(iH));
 
       if (hm->GetNofLinks() == 0) continue;
       Float_t bestWeight  = 0.f;
@@ -2143,8 +2143,8 @@ void CbmL1::InputPerformance()
   if (fpTrdHits && fpTrdHitMatches && fpTrdPoints) {
     for (int iH = 0; iH < fpTrdHits->GetEntriesFast(); iH++) {
 
-      const CbmTrdHit* sh = L1_DYNAMIC_CAST<CbmTrdHit*>(fpTrdHits->At(iH));
-      const CbmMatch* hm  = L1_DYNAMIC_CAST<CbmMatch*>(fpTrdHitMatches->At(iH));
+      const CbmTrdHit* sh = dynamic_cast<CbmTrdHit*>(fpTrdHits->At(iH));
+      const CbmMatch* hm  = dynamic_cast<CbmMatch*>(fpTrdHitMatches->At(iH));
 
       if (hm->GetNofLinks() == 0) continue;
       if (hm->GetNofLinks() != 1) continue;  // only check single-linked hits
@@ -2204,8 +2204,8 @@ void CbmL1::InputPerformance()
   if (fpTofHits && fpTofHitMatches && fpTofPoints) {
     for (int iH = 0; iH < fpTofHits->GetEntriesFast(); iH++) {
 
-      const CbmTofHit* sh = L1_DYNAMIC_CAST<CbmTofHit*>(fpTofHits->At(iH));
-      const CbmMatch* hm  = L1_DYNAMIC_CAST<CbmMatch*>(fpTofHitMatches->At(iH));
+      const CbmTofHit* sh = dynamic_cast<CbmTofHit*>(fpTofHits->At(iH));
+      const CbmMatch* hm  = dynamic_cast<CbmMatch*>(fpTofHitMatches->At(iH));
 
       if (hm->GetNofLinks() == 0) continue;
       Float_t bestWeight = 0.f;
diff --git a/reco/L1/CbmL1ReadEvent.cxx b/reco/L1/CbmL1ReadEvent.cxx
index 57d90763f40607fdb0590801902756622889d5c7..92f0eff196fd3dc054d495c3ff85c9c4810c3daa 100644
--- a/reco/L1/CbmL1ReadEvent.cxx
+++ b/reco/L1/CbmL1ReadEvent.cxx
@@ -380,7 +380,7 @@ void CbmL1::ReadEvent(CbmEvent* event)
       Int_t hitIndex = (event ? event->GetIndex(ECbmDataType::kMvdHit, j) : j);
 
       TmpHit th;
-      CbmMvdHit* h = L1_DYNAMIC_CAST<CbmMvdHit*>(fpMvdHits->At(hitIndex));
+      CbmMvdHit* h = dynamic_cast<CbmMvdHit*>(fpMvdHits->At(hitIndex));
       {
         th.ExtIndex = hitIndex;
         th.iStation = fpAlgo->GetParameters()->GetStationIndexActive(
@@ -442,7 +442,7 @@ void CbmL1::ReadEvent(CbmEvent* event)
       // ***********************************
 
       TmpHit th;
-      CbmStsHit* h = L1_DYNAMIC_CAST<CbmStsHit*>(fpStsHits->At(hitIndex));
+      CbmStsHit* h = dynamic_cast<CbmStsHit*>(fpStsHits->At(hitIndex));
 
       // Fill reconstructed information
       {
@@ -565,7 +565,7 @@ void CbmL1::ReadEvent(CbmEvent* event)
       TmpHit th;
 
       Int_t hitIndex = (event ? event->GetIndex(ECbmDataType::kTrdHit, iHit) : iHit);
-      CbmTrdHit* h   = L1_DYNAMIC_CAST<CbmTrdHit*>(fpTrdHits->At(hitIndex));
+      CbmTrdHit* h   = dynamic_cast<CbmTrdHit*>(fpTrdHits->At(hitIndex));
 
       if ((L1Algo::TrackingMode::kGlobal == fTrackingMode) && (int) h->GetClassType() != 1) {
         // SGtrd2d!! skip TRD-1D hit
@@ -635,7 +635,7 @@ void CbmL1::ReadEvent(CbmEvent* event)
 
       TmpHit th;
 
-      CbmTofHit* h = L1_DYNAMIC_CAST<CbmTofHit*>(fpTofHits->At(hitIndex));
+      CbmTofHit* h = dynamic_cast<CbmTofHit*>(fpTofHits->At(hitIndex));
 
 
       th.ExtIndex = hitIndex;
@@ -826,7 +826,7 @@ void CbmL1::Fill_vMCTracks()
     Int_t nMCTrack = fpMcTracks->Size(iFile, iEvent);
     /* Loop over MC tracks */
     for (Int_t iMCTrack = 0; iMCTrack < nMCTrack; iMCTrack++) {
-      CbmMCTrack* MCTrack = L1_DYNAMIC_CAST<CbmMCTrack*>(fpMcTracks->Get(iFile, iEvent, iMCTrack));
+      CbmMCTrack* MCTrack = dynamic_cast<CbmMCTrack*>(fpMcTracks->Get(iFile, iEvent, iMCTrack));
       if (!MCTrack) { continue; }
 
       int mother_ID = MCTrack->GetMotherId();
@@ -835,7 +835,7 @@ void CbmL1::Fill_vMCTracks()
       int chainParent = mother_ID;
       while (chainParent >= 0) {
         chainID            = chainParent;
-        CbmMCTrack* parent = L1_DYNAMIC_CAST<CbmMCTrack*>(fpMcTracks->Get(iFile, iEvent, chainParent));
+        CbmMCTrack* parent = dynamic_cast<CbmMCTrack*>(fpMcTracks->Get(iFile, iEvent, chainParent));
         chainParent        = parent->GetMotherId();
       }
 
@@ -884,7 +884,7 @@ void CbmL1::ReadMCPoint(ca::EDetectorID iDet, int file, int event, int iPoint)
 
   int iStLoc = -1;
   if (ca::EDetectorID::kMvd == iDet) {
-    CbmMvdPoint* pt = L1_DYNAMIC_CAST<CbmMvdPoint*>(fpMvdPoints->Get(file, event, iPoint));
+    CbmMvdPoint* pt = dynamic_cast<CbmMvdPoint*>(fpMvdPoints->Get(file, event, iPoint));
     assert(pt);
     fairPoint = pt;
     pt->PositionOut(xyzO);
@@ -893,7 +893,7 @@ void CbmL1::ReadMCPoint(ca::EDetectorID iDet, int file, int event, int iPoint)
   }
 
   if (ca::EDetectorID::kSts == iDet) {
-    CbmStsPoint* pt = L1_DYNAMIC_CAST<CbmStsPoint*>(fpStsPoints->Get(file, event, iPoint));
+    CbmStsPoint* pt = dynamic_cast<CbmStsPoint*>(fpStsPoints->Get(file, event, iPoint));
     assert(pt);
     fairPoint = pt;
     pt->PositionOut(xyzO);
@@ -903,7 +903,7 @@ void CbmL1::ReadMCPoint(ca::EDetectorID iDet, int file, int event, int iPoint)
 
 
   if (ca::EDetectorID::kMuch == iDet) {
-    CbmMuchPoint* pt = L1_DYNAMIC_CAST<CbmMuchPoint*>(fpMuchPoints->Get(file, event, iPoint));
+    CbmMuchPoint* pt = dynamic_cast<CbmMuchPoint*>(fpMuchPoints->Get(file, event, iPoint));
     assert(pt);
     fairPoint = pt;
     pt->PositionOut(xyzO);
@@ -913,7 +913,7 @@ void CbmL1::ReadMCPoint(ca::EDetectorID iDet, int file, int event, int iPoint)
 
 
   if (ca::EDetectorID::kTrd == iDet) {
-    CbmTrdPoint* pt = L1_DYNAMIC_CAST<CbmTrdPoint*>(fpTrdPoints->Get(file, event, iPoint));
+    CbmTrdPoint* pt = dynamic_cast<CbmTrdPoint*>(fpTrdPoints->Get(file, event, iPoint));
     assert(pt);
     fairPoint = pt;
     pt->PositionOut(xyzO);
@@ -922,7 +922,7 @@ void CbmL1::ReadMCPoint(ca::EDetectorID iDet, int file, int event, int iPoint)
   }
 
   if (ca::EDetectorID::kTof == iDet) {
-    CbmTofPoint* pt = L1_DYNAMIC_CAST<CbmTofPoint*>(fpTofPoints->Get(file, event, iPoint));
+    CbmTofPoint* pt = dynamic_cast<CbmTofPoint*>(fpTofPoints->Get(file, event, iPoint));
     assert(pt);
     fairPoint = pt;
     pt->Position(xyzO);
@@ -961,7 +961,7 @@ void CbmL1::ReadMCPoint(ca::EDetectorID iDet, int file, int event, int iPoint)
   MC.pzOut = PO.Z();
   MC.p     = sqrt(fabs(MC.px * MC.px + MC.py * MC.py + MC.pz * MC.pz));
 
-  CbmMCTrack* MCTrack = L1_DYNAMIC_CAST<CbmMCTrack*>(fpMcTracks->Get(file, event, fairPoint->GetTrackID()));
+  CbmMCTrack* MCTrack = dynamic_cast<CbmMCTrack*>(fpMcTracks->Get(file, event, fairPoint->GetTrackID()));
 
   auto itTrack = fmMCTracksLinksMap.find(CbmL1LinkKey(fairPoint->GetTrackID(), event, file));
   assert(itTrack != fmMCTracksLinksMap.cend());
diff --git a/reco/L1/L1Algo/L1BranchExtender.cxx b/reco/L1/L1Algo/L1BranchExtender.cxx
index 6f524e3b53393ebb44e7cf282b6a6924cb212523..42d03fb98289756168f7138a026da123f34ba629 100644
--- a/reco/L1/L1Algo/L1BranchExtender.cxx
+++ b/reco/L1/L1Algo/L1BranchExtender.cxx
@@ -4,6 +4,7 @@
 
 #include <iostream>
 
+#include "CaDefines.h"
 #include "CaGridArea.h"
 #include "CaTrack.h"
 #include "CaTrackParam.h"
@@ -24,7 +25,7 @@ using std::endl;
 void L1Algo::BranchFitterFast(const L1Branch& t, TrackParamV& Tout, const bool upstream, const fvec qp0,
                               const bool initParams)
 {
-  L1_assert(t.NHits >= 3);
+  CBMCA_DEBUG_ASSERT(t.NHits >= 3);
 
   L1Fit fit;
   fit.SetParticleMass(GetDefaultParticleMass());
diff --git a/reco/L1/L1Algo/L1Def.h b/reco/L1/L1Algo/L1Def.h
index 0e7da09ac99f4d5d67c4d21f645a7202572ba59e..3db98677f681111f33a267252e1ee1acdfc25770 100644
--- a/reco/L1/L1Algo/L1Def.h
+++ b/reco/L1/L1Algo/L1Def.h
@@ -9,30 +9,17 @@
 
 #include <iostream>
 
-#include <assert.h>
-
 #ifdef FAST_CODE
 
 #define L1_NO_ASSERT  // use with asserts, etc.
-#define L1_DYNAMIC_CAST static_cast
 
 #else  // FAST_CODE
 
-#define L1_DYNAMIC_CAST dynamic_cast
 
 #endif  // FAST_CODE
 
-#if 1 && defined(__GNUC__) && __GNUC__ - 0 >= 3  // for speed up conditions
-#define ISLIKELY(x) __builtin_expect(!!(x), 1)
-#define ISUNLIKELY(x) __builtin_expect(!!(x), 0)
-#else
-#define ISLIKELY(x) (x)
-#define ISUNLIKELY(x) (x)
-#endif
 
 #if defined(NDEBUG) || defined(L1_NO_ASSERT)
-#define L1_ASSERT(v, msg)
-#define L1_assert(v)
 
 // Prints expression value to the std::cout
 #define L1_SHOW(expr)
@@ -40,16 +27,8 @@
 // Prints file and line information to the std::cout
 #define L1_SHOWF(msg)
 
-
 #else
-#define L1_ASSERT(v, msg)                                                                                              \
-  if (v) {}                                                                                                            \
-  else {                                                                                                               \
-    std::cerr << __FILE__ << ":" << __LINE__ << " assertion failed: " << #v << " = " << (v) << "\n"                    \
-              << msg << std::endl;                                                                                     \
-    abort();                                                                                                           \
-  }
-#define L1_assert(v) assert(v)
+
 #define L1_SHOW(expr)                                                                                                  \
   std::cout << __FILE__ << ":" << __LINE__ << ": \033[01;38;5;208m" << (#expr) << "\033[0m = " << (expr) << "\n"
 #define L1_SHOWF(msg)                                                                                                  \
@@ -61,14 +40,4 @@
 
 #endif
 
-
-// Prints function call
-#if defined(__GNUC__)
-#define L1_SHOWFN std::cout << "\033[1;32mCALL \033[1;33m" << __PRETTY_FUNCTION__ << "\033[0m\n"
-#else
-#define L1_SHOWFN std::cout << "\033[1;32mCALL \033[1;33m" << __func__ << "\033[0m\n"
-#endif
-
-typedef int index_type;
-
 #endif
diff --git a/reco/L1/L1Algo/L1Triplet.h b/reco/L1/L1Algo/L1Triplet.h
index 4bc10d1f0c94edaea098df2a39acdcea95196d28..c33f8a3a66ae6648ab8ece9ffa3ac4d71994a38b 100644
--- a/reco/L1/L1Algo/L1Triplet.h
+++ b/reco/L1/L1Algo/L1Triplet.h
@@ -10,7 +10,7 @@
 // @author Valentina Akishina
 // @date 2021-05-18
 
-#include "L1Def.h"
+#include "CaSimd.h"
 
 namespace
 {
diff --git a/reco/L1/L1Algo/L1TripletConstructor.cxx b/reco/L1/L1Algo/L1TripletConstructor.cxx
index c44e486717e80c83f679ce1b13bd539fe2c210c9..9e6042279c06ae1c75050f976a2a9bb95b532b79 100644
--- a/reco/L1/L1Algo/L1TripletConstructor.cxx
+++ b/reco/L1/L1Algo/L1TripletConstructor.cxx
@@ -10,11 +10,11 @@
 #include <algorithm>
 #include <iostream>
 
+#include "CaDefines.h"
 #include "CaGridArea.h"
 #include "CaToolsDebugger.h"
 #include "CaTrackParam.h"
 #include "L1Algo.h"
-#include "L1Assert.h"
 #include "L1Fit.h"
 
 using cbm::ca::tools::Debugger;
@@ -566,12 +566,9 @@ void L1TripletConstructor::StoreTriplets()
     const ca::HitIndex_t ihitm = fHitsM_3[i3];
     const ca::HitIndex_t ihitr = fHitsR_3[i3];
 
-    L1_ASSERT(ihitl < fAlgo->fStationHitsStartIndex[fIstaL + 1],
-              ihitl << " < " << fAlgo->fStationHitsStartIndex[fIstaL + 1]);
-    L1_ASSERT(ihitm < fAlgo->fStationHitsStartIndex[fIstaM + 1],
-              ihitm << " < " << fAlgo->fStationHitsStartIndex[fIstaM + 1]);
-    L1_ASSERT(ihitr < fAlgo->fStationHitsStartIndex[fIstaR + 1],
-              ihitr << " < " << fAlgo->fStationHitsStartIndex[fIstaR + 1]);
+    CBMCA_DEBUG_ASSERT(ihitl < fAlgo->fStationHitsStartIndex[fIstaL + 1]);
+    CBMCA_DEBUG_ASSERT(ihitm < fAlgo->fStationHitsStartIndex[fIstaM + 1]);
+    CBMCA_DEBUG_ASSERT(ihitr < fAlgo->fStationHitsStartIndex[fIstaR + 1]);
 
     if (!fAlgo->fpCurrentIteration->GetTrackFromTripletsFlag()) {
       if (chi2 > fAlgo->fTripletFinalChi2Cut) { continue; }
diff --git a/reco/L1/OffLineInterface/CbmL1GlobalTrackFinder.cxx b/reco/L1/OffLineInterface/CbmL1GlobalTrackFinder.cxx
index 4b8d843dc6dd7742a9d449ffd88da4f294881b57..efea0e6fcf354cb6ca233ff63147ecb0376d5938 100644
--- a/reco/L1/OffLineInterface/CbmL1GlobalTrackFinder.cxx
+++ b/reco/L1/OffLineInterface/CbmL1GlobalTrackFinder.cxx
@@ -89,7 +89,7 @@ Int_t CbmL1GlobalTrackFinder::CopyL1Tracks(CbmEvent* event)
     //BEGIN add global track
     new ((*fGlobalTracks)[globalTrackIndex]) CbmGlobalTrack();
     if (event) event->AddData(ECbmDataType::kGlobalTrack, globalTrackIndex);
-    CbmGlobalTrack* t = L1_DYNAMIC_CAST<CbmGlobalTrack*>(fGlobalTracks->At(globalTrackIndex++));
+    CbmGlobalTrack* t = dynamic_cast<CbmGlobalTrack*>(fGlobalTracks->At(globalTrackIndex++));
     t->SetFlag(0);
     t->SetParamFirst(cbm::L1Util::ConvertTrackParam(T));
     t->SetParamLast(cbm::L1Util::ConvertTrackParam(T.TLast));
diff --git a/reco/L1/OffLineInterface/CbmL1StsTrackFinder.cxx b/reco/L1/OffLineInterface/CbmL1StsTrackFinder.cxx
index 80a21a974931b56e7ec27683bedfcacc5c540f80..a0c074d7ae7e23767a0de99b8dbb71a3010c8928 100644
--- a/reco/L1/OffLineInterface/CbmL1StsTrackFinder.cxx
+++ b/reco/L1/OffLineInterface/CbmL1StsTrackFinder.cxx
@@ -74,7 +74,7 @@ Int_t CbmL1StsTrackFinder::CopyL1Tracks(CbmEvent* event)
     new ((*fTracks)[trackIndex]) CbmStsTrack();
     nTracks++;
     if (event) event->AddData(ECbmDataType::kStsTrack, trackIndex);
-    CbmStsTrack* t = L1_DYNAMIC_CAST<CbmStsTrack*>(fTracks->At(trackIndex++));
+    CbmStsTrack* t = dynamic_cast<CbmStsTrack*>(fTracks->At(trackIndex++));
     t->SetFlag(0);
     t->SetParamFirst(cbm::L1Util::ConvertTrackParam(T));
     t->SetParamLast(cbm::L1Util::ConvertTrackParam(T.TLast));
diff --git a/reco/detectors/rich/finder/CbmL1RichENNRingFinderParallel.cxx b/reco/detectors/rich/finder/CbmL1RichENNRingFinderParallel.cxx
index a94fc78b009e33868ee6caea04773cbcdee2cb86..9b18c59912a8c514056e76056792602972c1f522 100644
--- a/reco/detectors/rich/finder/CbmL1RichENNRingFinderParallel.cxx
+++ b/reco/detectors/rich/finder/CbmL1RichENNRingFinderParallel.cxx
@@ -36,6 +36,7 @@
 
 #include <cmath>
 
+#include "CaUtils.h"
 #include "assert.h"
 
 using std::cout;
@@ -45,6 +46,8 @@ using std::ios;
 using std::sqrt;
 using std::vector;
 
+namespace ca = cbm::algo::ca;
+
 CbmL1RichENNRingFinderParallel::CbmL1RichENNRingFinderParallel(Int_t /*verbose*/) : fRecoTime(0), fNEvents(0)
 {
 #ifdef PRINT_TIMING
@@ -96,7 +99,7 @@ Int_t CbmL1RichENNRingFinderParallel::DoFind(CbmEvent* event, TClonesArray* HitA
   const Int_t nhits = event ? event->GetNofData(ECbmDataType::kRichHit) : HitArray->GetEntriesFast();
   for (Int_t i0 = 0; i0 < nhits; ++i0) {
     Int_t i         = event ? event->GetIndex(ECbmDataType::kRichHit, i0) : i0;
-    CbmRichHit* hit = L1_DYNAMIC_CAST<CbmRichHit*>(HitArray->At(i));
+    CbmRichHit* hit = dynamic_cast<CbmRichHit*>(HitArray->At(i));
     if (!hit) continue;
     ENNRingHit tmp;
     tmp.x        = hit->GetX();
@@ -184,7 +187,7 @@ Int_t CbmL1RichENNRingFinderParallel::DoFind(CbmEvent* event, TClonesArray* HitA
     if (!i->on) continue;
     new ((*RingArray)[NRings]) CbmRichRing();
     if (event != nullptr) event->AddData(ECbmDataType::kRichRing, NRings);
-    CbmRichRing* ring = L1_DYNAMIC_CAST<CbmRichRing*>(RingArray->At(NRings));
+    CbmRichRing* ring = dynamic_cast<CbmRichRing*>(RingArray->At(NRings));
     NRings++;
     ring->SetCenterX(i->x);
     ring->SetCenterY(i->y);
@@ -342,7 +345,7 @@ void CbmL1RichENNRingFinderParallel::ENNRingFinder(const int NHits, cbm::algo::c
         sHit.lr2     = sHit.S0 + sHit.S1;
         // if(( sHit.lr2 > AreaSize2 ) || ( j == i )) continue; // no difference in speed
         if (sHit.lr2[i_4] > AreaSize2) continue;
-        if (ISUNLIKELY(j == i_main)) continue;
+        if (ca::utils::IsUnlikely(j == i_main)) continue;
 
         if (sHit.quality[i_4] >= SearchHitMaxQuality) {  // CHECKME do we really need PickUpArea
           PickUpArea[static_cast<int>(PickUpAreaSize[i_4]++)].CopyHit(HitsV[j_V], j_4, i_4);
@@ -505,10 +508,10 @@ void CbmL1RichENNRingFinderParallel::ENNRingFinder(const int NHits, cbm::algo::c
 #ifdef PRINT_TIMING
     GetTimer("Ring finding: Store ring").Start(0);
 #endif  // PRINT_TIMING
-    if (ISUNLIKELY(validRing.isEmpty())) continue;
+    if (ca::utils::IsUnlikely(validRing.isEmpty())) continue;
 
       ///////////
-#if 0  // TODO 1
+#if 0   // TODO 1
     {
       ENNRingV &ringV = rings_tmp[nRings_tmp++];
     
@@ -587,7 +590,7 @@ void CbmL1RichENNRingFinderParallel::ENNRingFinder(const int NHits, cbm::algo::c
     for (size_t i_4 = 0; (i_4 < fvec::size()); i_4++) {
       //      if( NRingHits < MinRingHits || R2 > R2Max || R2 < R2Min ) continue;
 
-      if (/*ISUNLIKELY*/ (!validRing[i_4])) continue;
+      if (/*ca::utils::IsUnlikely*/ (!validRing[i_4])) continue;
 
       ENNRing voidRing;
       Rings.push_back(voidRing);
@@ -607,7 +610,7 @@ void CbmL1RichENNRingFinderParallel::ENNRingFinder(const int NHits, cbm::algo::c
         const float dx      = sHit.x[i_4] - ring.x;
         const float dy      = sHit.y[i_4] - ring.y;
         const float d       = fabs(sqrt(dx * dx + dy * dy) - R[i_4]);
-        if (ISLIKELY(d <= HitSize)) {
+        if (ca::utils::IsUnlikely(d <= HitSize)) {
           ring.chi2 += d * d;
           ring.localIHits.push_back(int(sHit.localIndex[i_4]));
           ring.NHits++;
@@ -619,14 +622,14 @@ void CbmL1RichENNRingFinderParallel::ENNRingFinder(const int NHits, cbm::algo::c
         const float dx = puHit.x[i_4] - ring.x;
         const float dy = puHit.y[i_4] - ring.y;
         const float d  = fabs(sqrt(dx * dx + dy * dy) - ring.r);
-        if (ISLIKELY(d <= HitSize)) {
+        if (ca::utils::IsUnlikely(d <= HitSize)) {
           ring.chi2 += d * d;
           ring.localIHits.push_back(static_cast<THitIndex>(puHit.localIndex[i_4]));
           ring.NHits++;
           if (d <= ShadowSize) Shadow.push_back(static_cast<THitIndex>(puHit.localIndex[i_4]));
         }
       }
-      if (ISUNLIKELY(ring.NHits < MinRingHits)) {
+      if (ca::utils::IsUnlikely(ring.NHits < MinRingHits)) {
         Rings.pop_back();
         continue;
       }
@@ -653,7 +656,7 @@ void CbmL1RichENNRingFinderParallel::ENNRingFinder(const int NHits, cbm::algo::c
 #ifdef PRINT_TIMING
     GetTimer("Ring finding: Store ring").Stop();
 #endif  // PRINT_TIMING
-  }  // i_main
+  }     // i_main
 #ifdef PRINT_TIMING
   GetTimer("Ring finding").Stop();
 
diff --git a/reco/detectors/rich/finder/CbmL1RichENNRingFinderParallel.h b/reco/detectors/rich/finder/CbmL1RichENNRingFinderParallel.h
index 977c4b73979234e8b0f69716e15ddb66fae3c34d..321733b7740ff680a51e56c30a5e6834e16a1631 100644
--- a/reco/detectors/rich/finder/CbmL1RichENNRingFinderParallel.h
+++ b/reco/detectors/rich/finder/CbmL1RichENNRingFinderParallel.h
@@ -29,7 +29,6 @@
 
 #include "CaSimd.h"
 #include "CaVector.h"
-#include "L1Def.h"
 
 class ENNHit;
 class ENNRing;
diff --git a/reco/detectors/rich/qa/CbmL1RichRingQa.cxx b/reco/detectors/rich/qa/CbmL1RichRingQa.cxx
index d697f5aefbbaeb7d808e6f6019baff63bfe12de4..5502e7ef7e5b0e42d54eb59fce8d82a6d8b591dd 100644
--- a/reco/detectors/rich/qa/CbmL1RichRingQa.cxx
+++ b/reco/detectors/rich/qa/CbmL1RichRingQa.cxx
@@ -38,8 +38,6 @@
 #include <ctype.h>
 #include <stdio.h>
 
-#include "L1Def.h"
-
 using namespace std;
 
 using std::cout;
@@ -214,25 +212,25 @@ InitStatus CbmL1RichRingQa::Init()
   }
 
   // Get hit Array
-  fHitArray = L1_DYNAMIC_CAST<TClonesArray*>(ioman->GetObject("RichHit"));
+  fHitArray = dynamic_cast<TClonesArray*>(ioman->GetObject("RichHit"));
   if (!fHitArray) { cout << "-W- CbmL1RichRingQa::Init: No RichHit array!" << endl; }
 
   // Get RichRing Array
-  fRingArray = L1_DYNAMIC_CAST<TClonesArray*>(ioman->GetObject("RichRing"));
+  fRingArray = dynamic_cast<TClonesArray*>(ioman->GetObject("RichRing"));
   if (!fRingArray) {
     cout << "-E- CbmL1RichRingQa::Init: No RichRing array!" << endl;
     return kERROR;
   }
 
   // Get MC Point array
-  fMCPointArray = L1_DYNAMIC_CAST<TClonesArray*>(ioman->GetObject("RichPoint"));
+  fMCPointArray = dynamic_cast<TClonesArray*>(ioman->GetObject("RichPoint"));
   if (!fMCPointArray) {
     cout << "-E- CbmL1RichRingQa::Init: No RichPoint array!" << endl;
     return kERROR;
   }
 
   // Get MC Point array
-  fMCTrackArray = L1_DYNAMIC_CAST<TClonesArray*>(ioman->GetObject("MCTrack"));
+  fMCTrackArray = dynamic_cast<TClonesArray*>(ioman->GetObject("MCTrack"));
   if (!fMCTrackArray) {
     cout << "-E- CbmL1RichRingQa::Init: No MCTrack array!" << endl;
     return kERROR;
@@ -317,7 +315,7 @@ void CbmL1RichRingQa::Exec(Option_t* /*option*/)
   Int_t NfakeHits = 0;
   for (Int_t hit = 0; hit < fHitArray->GetEntriesFast(); hit++) {
 
-    CbmRichHit* phit = L1_DYNAMIC_CAST<CbmRichHit*>(fHitArray->At(hit));
+    CbmRichHit* phit = dynamic_cast<CbmRichHit*>(fHitArray->At(hit));
     HitArrX[hit]     = (phit->GetX());
     HitArrY[hit]     = -1 * (phit->GetY());
     if (phit->GetRefId() == -1) {
@@ -327,7 +325,7 @@ void CbmL1RichRingQa::Exec(Option_t* /*option*/)
     }
   }
   for (Int_t i = 0; i < fRingArray->GetEntriesFast(); i++) {
-    CbmRichRing* ring = L1_DYNAMIC_CAST<CbmRichRing*>(fRingArray->At(i));
+    CbmRichRing* ring = dynamic_cast<CbmRichRing*>(fRingArray->At(i));
     //CbmRichRingLight *my_ring = (CbmRichRingLight*) fRingArray->At( i );
     ArrRingX[i] = ring->GetCenterX();
     ArrRingY[i] = -1 * (ring->GetCenterY());
@@ -428,18 +426,18 @@ void CbmL1RichRingQa::Exec(Option_t* /*option*/)
     hit.y         = 0;
     hit.MCTrackID = -1;
 
-    CbmRichHit* phit = L1_DYNAMIC_CAST<CbmRichHit*>(fHitArray->At(i));
+    CbmRichHit* phit = dynamic_cast<CbmRichHit*>(fHitArray->At(i));
     if (!phit) continue;
     pHitIndex.insert(pair<void*, int>(phit, i));
     hit.x         = phit->GetX();
     hit.y         = phit->GetY();
     Int_t pointID = phit->GetRefId();
     if (pointID < 0) continue;
-    CbmRichPoint* point = L1_DYNAMIC_CAST<CbmRichPoint*>(fMCPointArray->At(pointID));
+    CbmRichPoint* point = dynamic_cast<CbmRichPoint*>(fMCPointArray->At(pointID));
     if (!point) continue;
     Int_t trackID = point->GetTrackID();
     if (trackID < 0) continue;
-    CbmMCTrack* track = L1_DYNAMIC_CAST<CbmMCTrack*>(fMCTrackArray->At(trackID));
+    CbmMCTrack* track = dynamic_cast<CbmMCTrack*>(fMCTrackArray->At(trackID));
     if (!track || track->GetPdgCode() != 50000050) continue;  // select only Cherenkov photons
     hit.MCTrackID = track->GetMotherId();
   }
@@ -491,7 +489,7 @@ void CbmL1RichRingQa::Exec(Option_t* /*option*/)
     // find momentum
     if (!fMCTrackArray || ring.MCTrackID < 0) continue;
 
-    CbmMCTrack* pm = L1_DYNAMIC_CAST<CbmMCTrack*>(fMCTrackArray->At(ring.MCTrackID));
+    CbmMCTrack* pm = dynamic_cast<CbmMCTrack*>(fMCTrackArray->At(ring.MCTrackID));
     if (pm) {
       ring.PDG = pm->GetPdgCode();  // get PDG code of mother
 
@@ -684,13 +682,13 @@ void CbmL1RichRingQa::Exec(Option_t* /*option*/)
   for (Int_t ir = 0; ir < NReco; ir++) {
     MCRecoCor[ir] = -1;
     map<Int_t, Int_t> hitmap;
-    CbmRichRing* r = L1_DYNAMIC_CAST<CbmRichRing*>(fRingArray->At(ir));
+    CbmRichRing* r = dynamic_cast<CbmRichRing*>(fRingArray->At(ir));
     //     local_x[ir] = r->GetCenterX();
     //     local_y[ir] = r->GetCenterY();
     //     local_r[ir] = r->GetRadius();
     Int_t nh = r->GetNofHits();
     for (int ih = 0; ih < nh; ih++) {
-      CbmRichHit* h = L1_DYNAMIC_CAST<CbmRichHit*>(fHitArray->At(r->GetHit(ih)));
+      CbmRichHit* h = dynamic_cast<CbmRichHit*>(fHitArray->At(r->GetHit(ih)));
       Int_t jh      = pHitIndex[h];
       int ID        = Hits[jh].MCTrackID;
       if (hitmap.find(ID) == hitmap.end()) hitmap.insert(pair<Int_t, Int_t>(ID, 0));
@@ -742,11 +740,11 @@ void CbmL1RichRingQa::Exec(Option_t* /*option*/)
 
   for (Int_t i1 = 0; i1 < NReco; i1++) {
     //     IfClone[i1] = 0;
-    CbmRichRing* r1 = L1_DYNAMIC_CAST<CbmRichRing*>(fRingArray->At(i1));
+    CbmRichRing* r1 = dynamic_cast<CbmRichRing*>(fRingArray->At(i1));
     Int_t nh1       = r1->GetNofHits();
     for (Int_t i2 = 0; i2 < NReco; i2++) {
       if (MCRecoCor[i1] != MCRecoCor[i2]) continue;
-      CbmRichRing* r2 = L1_DYNAMIC_CAST<CbmRichRing*>(fRingArray->At(i2));
+      CbmRichRing* r2 = dynamic_cast<CbmRichRing*>(fRingArray->At(i2));
       Int_t nh2       = r2->GetNofHits();
       Int_t NSame     = 0;
       for (Int_t j1 = 0; j1 < nh1; j1++) {
@@ -766,10 +764,10 @@ void CbmL1RichRingQa::Exec(Option_t* /*option*/)
     CloneFlag[i] = 0;
   }
   for (Int_t i = 0; i < NReco; i++) {
-    CbmRichRing* r1 = L1_DYNAMIC_CAST<CbmRichRing*>(fRingArray->At(i));
+    CbmRichRing* r1 = dynamic_cast<CbmRichRing*>(fRingArray->At(i));
     if (MCRecoCor[i] == -1) continue;
     for (Int_t j = i + 1; j < NReco; j++) {
-      CbmRichRing* r2 = L1_DYNAMIC_CAST<CbmRichRing*>(fRingArray->At(j));
+      CbmRichRing* r2 = dynamic_cast<CbmRichRing*>(fRingArray->At(j));
       if (MCRecoCor[j] == -1) continue;
       if (MCRecoCor[i] == MCRecoCor[j]) {
         CloneFlag[i] = MCRecoCor[i];
@@ -801,7 +799,7 @@ void CbmL1RichRingQa::Exec(Option_t* /*option*/)
   //Draw Clones
   for (Int_t i = 0; i < NReco; i++) {
     if (CloneFlag[i] == 0) continue;
-    CbmRichRing* r = L1_DYNAMIC_CAST<CbmRichRing*>(fRingArray->At(i));
+    CbmRichRing* r = dynamic_cast<CbmRichRing*>(fRingArray->At(i));
     for (map<Int_t, MCRing>::iterator MC = MCRingMap.begin(); MC != MCRingMap.end(); ++MC) {
       MCRing& ring = MC->second;
       if (CloneFlag[i] != 0) {