From ced977ffb86b94d4fa5f6f6c98de8d3383ff0f06 Mon Sep 17 00:00:00 2001
From: Dominik Smith <d.smith@gsi.de>
Date: Thu, 24 Feb 2022 16:19:25 +0100
Subject: [PATCH] Added number of linked MC events per trigger to
 CbmSeedFinderQa.

---
 reco/eventbuilder/digis/CbmSeedFinderQa.cxx | 14 +++++++++++++-
 reco/eventbuilder/digis/CbmSeedFinderQa.h   | 17 ++++++++++-------
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/reco/eventbuilder/digis/CbmSeedFinderQa.cxx b/reco/eventbuilder/digis/CbmSeedFinderQa.cxx
index d979136ff1..f90037f39f 100644
--- a/reco/eventbuilder/digis/CbmSeedFinderQa.cxx
+++ b/reco/eventbuilder/digis/CbmSeedFinderQa.cxx
@@ -19,6 +19,10 @@ CbmSeedFinderQa::CbmSeedFinderQa() : fOutFolder("SeedFinderQA", "Seed finder QA"
   histFolder = fOutFolder.AddFolder("hist", "Histogramms");
 
   // --- Init histograms
+  fhLinkedMCEventsPerTrigger =
+    new TH1F("fhLinkedMCEventsPerTrigger", "Linked MC events per trigger (=0 for pure noise)", 5, -1, 4);
+  fhLinkedMCEventsPerTrigger->SetCanExtend(TH1::kAllAxes);
+
   fhCorrectDigiRatio = new TH1F("fhCorrectDigiRatio", "Correct digis per seed [pct]", 416, -2, 102);
   fhCorrectDigiRatioNoNoise =
     new TH1F("fhCorrectDigiRatioNoNoise", "Correct digis per seed [pct], disregarding noise", 416, -2, 102);
@@ -39,9 +43,10 @@ CbmSeedFinderQa::CbmSeedFinderQa() : fOutFolder("SeedFinderQA", "Seed finder QA"
   histFolder->Add(fhCorrectVsFound);
   histFolder->Add(fhCorrectVsFoundNoNoise);
   histFolder->Add(fhTimeOffset);
+  histFolder->Add(fhLinkedMCEventsPerTrigger);
 
   fCanv = new CbmQaCanvas("cSummary", "", 4 * 400, 2 * 400);
-  fCanv->Divide2D(7);
+  fCanv->Divide2D(8);
   fOutFolder.Add(fCanv);
 }
 
@@ -54,6 +59,7 @@ CbmSeedFinderQa::~CbmSeedFinderQa()
   delete fhCorrectVsFound;
   delete fhCorrectVsFoundNoNoise;
   delete fhTimeOffset;
+  delete fhLinkedMCEventsPerTrigger;
   delete fCanv;
 }
 
@@ -105,6 +111,7 @@ void CbmSeedFinderQa::FillQaInfo(const int32_t WinStart, const int32_t WinEnd, c
   }
   fvFullDigiCount.push_back(digiCount);
   fvNoiseDigiCount.push_back(noiseDigiCount);
+  fvLinkedMCEventsCount.push_back(seedMatch.GetNofLinks());
 
   if (seedMatch.GetNofLinks() == 0)  //seed is only noise digis
   {
@@ -157,6 +164,8 @@ void CbmSeedFinderQa::FillHistos()
 {
   for (uint32_t iEvent = 0; iEvent < fvEventMatches.size(); iEvent++) {
 
+    fhLinkedMCEventsPerTrigger->Fill(fvLinkedMCEventsCount.at(iEvent));
+
     const CbmMatch* match = &(fvEventMatches.at(iEvent));
     const CbmLink& link   = match->GetMatchedLink();
     if (link.GetEntry() == -1) { continue; }
@@ -226,6 +235,9 @@ void CbmSeedFinderQa::WriteHistos()
   fCanv->cd(7);
   fhTimeOffset->DrawCopy("colz", "");
 
+  fCanv->cd(8);
+  fhLinkedMCEventsPerTrigger->DrawCopy("colz", "");
+
   FairSink* sink = FairRootManager::Instance()->GetSink();
   sink->WriteObject(&fOutFolder, nullptr);
 }
diff --git a/reco/eventbuilder/digis/CbmSeedFinderQa.h b/reco/eventbuilder/digis/CbmSeedFinderQa.h
index 02c5a223f0..2722d32b6a 100644
--- a/reco/eventbuilder/digis/CbmSeedFinderQa.h
+++ b/reco/eventbuilder/digis/CbmSeedFinderQa.h
@@ -44,6 +44,8 @@ public:
 
   /** @brief Matches that link constructed event seeds to MC events. */
   std::vector<CbmMatch> fvEventMatches;
+  /** @brief Counts how many MC events contributed to a seed. */
+  std::vector<uint32_t> fvLinkedMCEventsCount;
   /** @brief Full vector of all event seeds that is not cleared at the end of a timeslice. */
   std::vector<double> fvSeedTimesFull;
   /** @brief Counts how many digis contributed to a seed. */
@@ -82,13 +84,14 @@ private:
   TFolder fOutFolder;             /// output folder with histos and canvases
 
   /** Histograms **/
-  TH1F* fhCorrectDigiRatio        = nullptr;  /// correct digis per event
-  TH1F* fhCorrectDigiRatioNoNoise = nullptr;  /// correct digis per event, disregarding noise
-  TH1F* fhNoiseDigiRatio          = nullptr;  /// noise digis per event
-  TH1F* fhFoundDigiRatio          = nullptr;  /// digis found per event
-  TH2I* fhCorrectVsFound          = nullptr;  /// correct digis per event vs found digis per event
-  TH2I* fhCorrectVsFoundNoNoise   = nullptr;  /// correct digis per event vs found digis per event, disregarding noise
-  TH1F* fhTimeOffset              = nullptr;  /// difference between true event time and seed time
+  TH1F* fhLinkedMCEventsPerTrigger = nullptr;  /// linked MC events per trigger
+  TH1F* fhCorrectDigiRatio         = nullptr;  /// correct digis per event
+  TH1F* fhCorrectDigiRatioNoNoise  = nullptr;  /// correct digis per event, disregarding noise
+  TH1F* fhNoiseDigiRatio           = nullptr;  /// noise digis per event
+  TH1F* fhFoundDigiRatio           = nullptr;  /// digis found per event
+  TH2I* fhCorrectVsFound           = nullptr;  /// correct digis per event vs found digis per event
+  TH2I* fhCorrectVsFoundNoNoise    = nullptr;  /// correct digis per event vs found digis per event, disregarding noise
+  TH1F* fhTimeOffset               = nullptr;  /// difference between true event time and seed time
 
   CbmQaCanvas* fCanv;  ///summary canvas
 
-- 
GitLab