From bdcb8504eac5593091dfa890a7a506732925e625 Mon Sep 17 00:00:00 2001
From: P-A Loizeau <p.-a.loizeau@gsi.de>
Date: Thu, 23 Feb 2023 16:19:23 +0100
Subject: [PATCH] Add safety check for empty match in TrdHitProducerQa, fix
 #2736

---
 reco/detectors/trd/qa/CbmTrdHitProducerQa.cxx | 1 +
 1 file changed, 1 insertion(+)

diff --git a/reco/detectors/trd/qa/CbmTrdHitProducerQa.cxx b/reco/detectors/trd/qa/CbmTrdHitProducerQa.cxx
index 19c1f315ff..09f172d665 100644
--- a/reco/detectors/trd/qa/CbmTrdHitProducerQa.cxx
+++ b/reco/detectors/trd/qa/CbmTrdHitProducerQa.cxx
@@ -166,6 +166,7 @@ void CbmTrdHitProducerQa::Exec(Option_t*)
     const CbmMatch* trdDigiMatch = fDigiMan->GetMatch(ECbmModuleId::kTrd, trdHit->GetRefId());
     if (nullptr == trdDigiMatch) continue;
 
+    if (0 == trdDigiMatch->GetNofLinks()) continue;  // catch case w/o links as then MatchedLink is invalid
     const CbmTrdPoint* trdPoint =
       dynamic_cast<CbmTrdPoint*>(fTrdPoints->Get(trdDigiMatch->GetMatchedLink()));  // file, event, object
     if (nullptr == trdPoint) continue;
-- 
GitLab