From 9ed5361a32ac1c9b918290241b167a405e556ada Mon Sep 17 00:00:00 2001
From: Dominik Smith <smith@th.physik.uni-frankfurt.de>
Date: Tue, 9 Feb 2021 13:58:49 +0100
Subject: [PATCH] Fixed an issue whereby CbmBuildEventsQA was unable to deal
 with digi matches without links (noise). Added CbmBuildEventsQA to
 /macro/run/run_reco.C.

---
 macro/run/run_reco.C                         | 12 ++++++++----
 reco/eventbuilder/digis/CbmBuildEventsQA.cxx | 13 ++++---------
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/macro/run/run_reco.C b/macro/run/run_reco.C
index 61091edb..79de51cd 100644
--- a/macro/run/run_reco.C
+++ b/macro/run/run_reco.C
@@ -206,6 +206,8 @@ void run_reco(TString input        = "",
       evBuildRaw->SetFixedTimeWindow(5500.);
       evBuildRaw->SetTriggerMinNumberSts(50);
 
+      evBuildRaw->SetUseBaseMuchDigi(kTRUE);
+
       run->AddTask(evBuildRaw);
       std::cout << "-I- " << myName << ": Added task " << evBuildRaw->GetName()
                 << std::endl;
@@ -296,9 +298,12 @@ void run_reco(TString input        = "",
   }  //? event-based reco
   // ------------------------------------------------------------------------
 
-  //CbmBuildEventsQA* evBuildQA = new CbmBuildEventsQA();
-  //run->AddTask(evBuildQA);
-
+  // ----------- QA for raw event builder -----------------------------------
+  if (eventBased) {
+    CbmBuildEventsQA* evBuildQA = new CbmBuildEventsQA();
+    run->AddTask(evBuildQA);
+  }
+  // ------------------------------------------------------------------------
 
   // -----   Local reconstruction in MVD   ----------------------------------
   if (useMvd) {
@@ -491,7 +496,6 @@ void run_reco(TString input        = "",
 
   }  //? time-based reco
 
-
   // -----  Parameter database   --------------------------------------------
   std::cout << std::endl << std::endl;
   std::cout << "-I- " << myName << ": Set runtime DB" << std::endl;
diff --git a/reco/eventbuilder/digis/CbmBuildEventsQA.cxx b/reco/eventbuilder/digis/CbmBuildEventsQA.cxx
index 2f81f4be..2d6136f5 100644
--- a/reco/eventbuilder/digis/CbmBuildEventsQA.cxx
+++ b/reco/eventbuilder/digis/CbmBuildEventsQA.cxx
@@ -71,10 +71,6 @@ void CbmBuildEventsQA::Exec(Option_t*) {
       Int_t nLinks        = 0;
       Int_t nLinksCorrect = 0;
 
-      //LOG(info) << GetName() << ": Detector "
-      //          << CbmModuleList::GetModuleNameCaps(system)
-      //          << ", nDigis = " << nDigis;
-
       // --- Loop over digis
       for (Int_t iDigi = 0; iDigi < nDigis; iDigi++) {
         UInt_t index = event->GetIndex(GetDigiType(system), iDigi);
@@ -83,11 +79,10 @@ void CbmBuildEventsQA::Exec(Option_t*) {
         assert(digiMatch);
 
         // --- Check MC event of digi match
-        if (digiMatch->GetMatchedLink().GetEntry() == mcEventNr) nDigiCorrect++;
-
-        //if (system == ECbmModuleId::kTof){ dev
-        //     LOG(info) << "index = " <<index;
-        //}
+        if (digiMatch->GetNofLinks()) {
+          if (digiMatch->GetMatchedLink().GetEntry() == mcEventNr)
+            nDigiCorrect++;
+        }
 
         for (Int_t iLink = 0; iLink < digiMatch->GetNofLinks(); iLink++) {
           Int_t entry = digiMatch->GetLink(iLink).GetEntry();
-- 
GitLab