From fcec79d42824324a2e4f070d25adb353fe34ccd2 Mon Sep 17 00:00:00 2001
From: Valentina <v.akishina@gsi.de>
Date: Mon, 14 Jun 2021 18:51:20 +0200
Subject: [PATCH] L1 fix bug for mCBM ToF hit indexes

---
 reco/L1/CbmL1ReadEvent.cxx | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/reco/L1/CbmL1ReadEvent.cxx b/reco/L1/CbmL1ReadEvent.cxx
index ffe86377ff..d8ff079c19 100644
--- a/reco/L1/CbmL1ReadEvent.cxx
+++ b/reco/L1/CbmL1ReadEvent.cxx
@@ -928,8 +928,14 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength,
   if (fVerbose >= 10) { cout << "ReadEvent: strips are read." << endl; }
 
   // -- save hits --
-  int nEffHits = 0;
-  SortedIndex.resize(max(nEntSts, nHits));
+  int nEffHits    = 0;
+  int maxHitIndex = 0;
+  if (fTofHits) maxHitIndex = fTofHits->GetEntriesFast() + nMvdHits + nStsHits + nMuchHits + nTrdHits;
+  else
+    maxHitIndex = nMvdHits + nStsHits + nMuchHits + nTrdHits;
+
+  SortedIndex.resize(max(nEntSts, maxHitIndex));
+
 
   vector<float> vStsZPos_temp;  // temp array for unsorted z positions of detectors segments
   for (int i = 0; i < nHits; i++) {
-- 
GitLab