From f34c3be972daed72a07dd21f1898cbe5beffe140 Mon Sep 17 00:00:00 2001
From: sgorbuno <se.gorbunov@gsi.de>
Date: Tue, 15 Jun 2021 23:35:58 +0000
Subject: [PATCH] L1Tracker: prevent potential problems in assigning strip and
 hit id's

---
 reco/L1/CbmL1ReadEvent.cxx | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/reco/L1/CbmL1ReadEvent.cxx b/reco/L1/CbmL1ReadEvent.cxx
index 2f728adcbb..6c3bbe4c69 100644
--- a/reco/L1/CbmL1ReadEvent.cxx
+++ b/reco/L1/CbmL1ReadEvent.cxx
@@ -387,13 +387,11 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength,
       {
         CbmMvdHit* mh = L1_DYNAMIC_CAST<CbmMvdHit*>(listMvdHits->At(j));
         th.ExtIndex   = -(1 + j);
-        th.id         = j;
+        th.id         = tmpHits.size();
         th.iStation   = mh->GetStationNr();
-        //   th.iSector  = 0;
-        int iStripF = j;
-        th.iStripF  = firstDetStrip + iStripF;
+        th.iStripF    = firstDetStrip + j;
         th.iStripB  = th.iStripF;
-        if (NStrips <= iStripF) { NStrips = iStripF + 1; }
+        if (NStrips <= th.iStripF) { NStrips = th.iStripF + 1; }
 
         TVector3 pos, err;
         mh->Position(pos);
@@ -519,7 +517,7 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength,
 
         if (fTimesliceMode) th.id = hitIndex;
         else
-          th.id = j + nMvdHits;
+          th.id = tmpHits.size();
 
         if ((th.time > (TsStart + TsLength)) && ((nEntSts - hitIndex) > 300))
           break;                                   /// stop if reco TS ends or few hits left
@@ -615,7 +613,7 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength,
 
         th.ExtIndex = j;
         th.Det      = 2;
-        th.id       = j + nMvdHits + nStsHits;
+        th.id       = tmpHits.size();
 
 
         Int_t stationNumber = CbmMuchGeoScheme::GetStationIndex(mh->GetAddress());
@@ -720,7 +718,7 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength,
       th.ExtIndex   = j;
       th.Det        = 3;
 
-      th.id = j + nMvdHits + nStsHits + nMuchHits;
+      th.id = tmpHits.size();
 
       th.iStation = NMvdStations + mh->GetPlaneId() + NStsStations + NMuchStations;
 
@@ -815,7 +813,7 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength,
       th.ExtIndex = j;
       th.Det      = 4;
 
-      th.id = j + nMvdHits + nStsHits + nMuchHits + nTrdHits;
+      th.id = tmpHits.size();
 
       if (0x00202806 == mh->GetAddress() || 0x00002806 == mh->GetAddress()) continue;
 
-- 
GitLab