From 8983cc58646c74f6df5c34cf221c6be648487b93 Mon Sep 17 00:00:00 2001
From: "s.zharko@gsi.de" <s.zharko@gsi.de>
Date: Fri, 1 Dec 2023 02:08:10 +0100
Subject: [PATCH] CA: adding MC event selection and CbmEvent formalism; QA:
 added event-based QAexecutionor CbmQaTask

---
 core/qa/CbmQaTask.cxx          | 1 +
 reco/L1/CbmCaMCModule.cxx      | 3 +++
 reco/L1/CbmCaTimeSliceReader.h | 3 +++
 3 files changed, 7 insertions(+)

diff --git a/core/qa/CbmQaTask.cxx b/core/qa/CbmQaTask.cxx
index 58a6ffc7fc..4dbd7da02c 100644
--- a/core/qa/CbmQaTask.cxx
+++ b/core/qa/CbmQaTask.cxx
@@ -44,6 +44,7 @@ void CbmQaTask::Exec(Option_t* /*option*/)
     int nEvents = fpBrEvents->GetEntriesFast();
     for (int iEvt = 0; iEvt < nEvents; ++iEvt) {
       fpCurrentEvent = static_cast<CbmEvent*>(fpBrEvents->At(iEvt));
+      assert(fpCurrentEvent);
       this->InitTimeSlice();
       this->FillHistograms();
       fNofEvents.SetVal(fNofEvents.GetVal() + 1);
diff --git a/reco/L1/CbmCaMCModule.cxx b/reco/L1/CbmCaMCModule.cxx
index cf6408539b..6195dbc621 100644
--- a/reco/L1/CbmCaMCModule.cxx
+++ b/reco/L1/CbmCaMCModule.cxx
@@ -261,8 +261,11 @@ void MCModule::MatchRecoAndMC()
   this->MatchPointsAndHits<ca::EDetectorID::kMuch>();
   this->MatchPointsAndHits<ca::EDetectorID::kTrd>();
   this->MatchPointsAndHits<ca::EDetectorID::kTof>();
+  LOG(info) << "DBG 1";
   this->MatchRecoAndMCTracks();
+  LOG(info) << "DBG 2";
   this->InitTrackInfo();
+  LOG(info) << "DBG 3";
   for (const auto& trkMC : fpMCData->GetTrackContainer()) {
     if (trkMC.IsReconstructable()) {
       fMonitor.IncrementCounter(EMonitorKey::kMcTrackReconstructable);
diff --git a/reco/L1/CbmCaTimeSliceReader.h b/reco/L1/CbmCaTimeSliceReader.h
index 5845553173..2b8df810e2 100644
--- a/reco/L1/CbmCaTimeSliceReader.h
+++ b/reco/L1/CbmCaTimeSliceReader.h
@@ -224,6 +224,9 @@ int cbm::ca::TimeSliceReader::ReadHitsForDetector()
 
   for (int iH = 0; iH < nHitsTot; ++iH) {
     int iHext = fpEvent ? fpEvent->GetIndex(kCbmHitType[DetID], iH) : iH;
+    if (iHext < 0) {
+      continue;
+    }
     tools::HitRecord hitRecord;
 
     auto* pHit  = static_cast<Hit_t*>(fvpBrHits[DetID]->At(iHext));
-- 
GitLab