From d8071d9f34d12055b9dfa12a57bf754a84c6acce Mon Sep 17 00:00:00 2001
From: sgorbuno <se.gorbunov@gsi.de>
Date: Thu, 22 Apr 2021 09:57:46 +0000
Subject: [PATCH] give names to L1Vectors for debugging purposes

---
 reco/L1/CbmL1Def.h        | 22 ++++++++++++++++------
 reco/L1/L1Algo/L1Algo.h   | 30 +++++++++++++++---------------
 reco/L1/L1Algo/L1Branch.h |  3 ++-
 3 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/reco/L1/CbmL1Def.h b/reco/L1/CbmL1Def.h
index ca650b6d65..b1d9803844 100644
--- a/reco/L1/CbmL1Def.h
+++ b/reco/L1/CbmL1Def.h
@@ -65,10 +65,12 @@ typedef int index_type;
 template<typename T>
 class L1Vector : public std::vector<T> {
 public:
-  L1Vector() : std::vector<T>(), fSize(0) {};
-  L1Vector(const unsigned int n) : std::vector<T>(n), fSize(0) {};
-  L1Vector(const unsigned int n, const unsigned int value)
-    : std::vector<T>(n, value), fSize(0) {};
+  L1Vector(const char* name = "no name") : std::vector<T>(), fSize(0), fName(name) {};
+  L1Vector(const char* name, const unsigned int n) : std::vector<T>(n), fSize(0), fName(name) {};
+  L1Vector(const char* name, const unsigned int n, const unsigned int value)
+    : std::vector<T>(n, value)
+    , fSize(0)
+    , fName(name) {};
 
 
   unsigned int Size() const { return fSize; }  // Size() return number
@@ -106,8 +108,8 @@ public:
 #ifdef _OPENMP
 #pragma omp critical
 #endif
-      std::vector<T>::resize(index + 1);
-      std::cout << "Warning: L1Vector autoresize to " << index + 1 << std::endl;
+      std::vector<T>::resize((index + 1) * 2);
+      std::cout << "Warning: L1Vector " << fName << " autoresize to " << (index + 1) * 2 << std::endl;
     }
     if (index >= fSize) fSize = index + 1;
 
@@ -119,8 +121,16 @@ public:
     return std::vector<T>::operator[](index);
   }
 
+  const char* getName()
+  {
+    std::string s = " L1Vector<";
+    s += fName + "> ";
+    return s.data();
+  }
+
 private:
   unsigned int fSize;
+  std::string fName;
 };
 
 #endif  // CbmL1Def_h
diff --git a/reco/L1/L1Algo/L1Algo.h b/reco/L1/L1Algo/L1Algo.h
index 215fa11a5e..703c5fb2d7 100644
--- a/reco/L1/L1Algo/L1Algo.h
+++ b/reco/L1/L1Algo/L1Algo.h
@@ -77,15 +77,15 @@ class L1Algo {
 public:
   //  L1Algo(int nThreads=7):
   L1Algo(int nThreads = 1, int TypicalSize = 200000)
-    : n_g1()
-    , FirstHit()
-    , LastHit()
-    , FirstHitIndex()
-    , LastHitIndex()
-    , Neighbour()
-    , TrackChi2()
-    , vRecoHitsNew()
-    , vTracksNew()
+    : n_g1("L1Algo::n_g1")
+    , FirstHit("L1Algo::FirstHit")
+    , LastHit("L1Algo::LastHit")
+    , FirstHitIndex("L1Algo::FirstHitIndex")
+    , LastHitIndex("L1Algo::LastHitIndex")
+    , Neighbour("L1Algo::Neighbour")
+    , TrackChi2("L1Algo::TrackChi2")
+    , vRecoHitsNew("L1Algo::vRecoHitsNew")
+    , vTracksNew("L1Algo::vTracksNew")
     , NStations(0)
     ,  // number of all detector stations
     NMvdStations(0)
@@ -100,9 +100,9 @@ public:
     , vSFlag(0)  // information of hits station & using hits in tracks(),
     , CATime(0)
     ,  // time of trackfinding
-    vTracks(40000)
+    vTracks("L1Algo::vTracks", 40000)
     ,  // reconstructed tracks
-    vRecoHits(400000)
+    vRecoHits("L1Algo::vRecoHits", 400000)
     ,  // packed hits of reconstructed tracks
     StsHitsStartIndex(nullptr)
     , StsHitsStopIndex(nullptr)
@@ -120,12 +120,12 @@ public:
     ,
 
 #ifdef _OPENMP
-    hitToBestTrackF(TypicalSize * 2)
-    , hitToBestTrackB(TypicalSize * 2)
+    hitToBestTrackF("L1Algo::hitToBestTrackF", TypicalSize * 2)
+    , hitToBestTrackB("L1Algo::hitToBestTrackB", TypicalSize * 2)
     ,
 #endif
-    vStripToTrack(TypicalSize * 2)
-    , vStripToTrackB(TypicalSize * 2)
+    vStripToTrack("L1Algo::vStripToTrack", TypicalSize * 4)
+    , vStripToTrackB("L1Algo::vStripToTrackB", TypicalSize * 4)
     ,
     //sh (),
     fNThreads(nThreads)
diff --git a/reco/L1/L1Algo/L1Branch.h b/reco/L1/L1Algo/L1Branch.h
index 00d6a40b4d..55df14e9a6 100644
--- a/reco/L1/L1Algo/L1Branch.h
+++ b/reco/L1/L1Algo/L1Branch.h
@@ -32,7 +32,8 @@ struct L1Branch {
     , NHits(0)
     , chi2(0)
     , CandIndex(0)
-    , StsHits() {
+    , StsHits("L1Branch::StsHits")
+  {
     //  L1Branch():Momentum(0),chi2(0),NHits(0),Lengtha(0),ista(0) , StsHits(){
     StsHits.resize(12);
   }
-- 
GitLab