diff --git a/reco/eventbuilder/digis/CbmBuildEventsQA.cxx b/reco/eventbuilder/digis/CbmBuildEventsQA.cxx index fe1ebea8f1ed7761411a264496705c92cc8c628c..a7a3ddbd097df8e4e37d3bfb5f013193ce6d1ecb 100644 --- a/reco/eventbuilder/digis/CbmBuildEventsQA.cxx +++ b/reco/eventbuilder/digis/CbmBuildEventsQA.cxx @@ -16,6 +16,7 @@ #include "FairRootManager.h" #include "TClonesArray.h" +#include "TH1.h" #include "TStopwatch.h" #include <cassert> @@ -27,18 +28,40 @@ using namespace std; // ===== Constructor ===================================================== -CbmBuildEventsQA::CbmBuildEventsQA() : FairTask("BuildEventsQA"), fEvents(NULL), fNofEntries(0) {} +CbmBuildEventsQA::CbmBuildEventsQA() + : FairTask("BuildEventsQA") + , fEvents(NULL) + , fNofEntries(0) + , fOutFolder("BuildEventsQA", "Build Events QA") +{ +} // =========================================================================== // ===== Destructor ====================================================== -CbmBuildEventsQA::~CbmBuildEventsQA() {} +CbmBuildEventsQA::~CbmBuildEventsQA() { DeInit(); } // =========================================================================== +// ===== De-initialisation ============================================= +void CbmBuildEventsQA::DeInit() +{ + fOutFolder.Clear(); + histFolder = nullptr; + SafeDelete(fhCorrectDigiRatioAll); + SafeDelete(fhFoundDigiRatioAll); +} // ===== Task initialisation ============================================= InitStatus CbmBuildEventsQA::Init() { + DeInit(); + + // --- Init histograms + histFolder = fOutFolder.AddFolder("hist", "Histogramms"); + fhCorrectDigiRatioAll = new TH1F("fhCorrectDigiRatioAll", "\% correct digis per event", 1001, 0., 100.1); + fhFoundDigiRatioAll = new TH1F("fhFoundDigiRatioAll", "\% found digis per event", 1001, 0., 100.1); + histFolder->Add(fhCorrectDigiRatioAll); + histFolder->Add(fhFoundDigiRatioAll); // --- Get FairRootManager instance FairRootManager* ioman = FairRootManager::Instance(); @@ -75,7 +98,6 @@ InitStatus CbmBuildEventsQA::Init() // ===== Task execution ================================================== void CbmBuildEventsQA::Exec(Option_t*) { - // --- Time and counters TStopwatch timer; timer.Start(); @@ -155,6 +177,9 @@ void CbmBuildEventsQA::Exec(Option_t*) << 100. * Double_t(nLinksCorrect) / Double_t(nLinks) << " % "; LOG(info) << "Digi percentage found " << nDigiCorrect << " / " << totEventDigis << " = " << 100. * Double_t(nDigiCorrect) / Double_t(totEventDigis) << " % "; + + fhCorrectDigiRatioAll->Fill(100. * Double_t(nLinksCorrect) / Double_t(nLinks)); + fhFoundDigiRatioAll->Fill(100. * Double_t(nDigiCorrect) / Double_t(totEventDigis)); } else { LOG(info) << GetName() << ": Detector " << CbmModuleList::GetModuleNameCaps(system) @@ -227,6 +252,22 @@ void CbmBuildEventsQA::MatchEvent(CbmEvent* event) // =========================================================================== +// ===== Finish task ======================================================= +void CbmBuildEventsQA::Finish() +{ + fhCorrectDigiRatioAll->DrawCopy("colz", ""); + fhFoundDigiRatioAll->DrawCopy("colz", ""); + + if (!FairRootManager::Instance() || !FairRootManager::Instance()->GetSink()) { + LOG(error) << "No sink found"; + return; + } + FairSink* sink = FairRootManager::Instance()->GetSink(); + sink->WriteObject(&fOutFolder, nullptr); +} +// =========================================================================== + + // ===== Get digi type ===================================================== ECbmDataType CbmBuildEventsQA::GetDigiType(ECbmModuleId system) { diff --git a/reco/eventbuilder/digis/CbmBuildEventsQA.h b/reco/eventbuilder/digis/CbmBuildEventsQA.h index 33c20d02b12ddf64c70205b65574c949731674b9..d7e3013b151aa55a323fa6af28cba2f3e9796ac0 100644 --- a/reco/eventbuilder/digis/CbmBuildEventsQA.h +++ b/reco/eventbuilder/digis/CbmBuildEventsQA.h @@ -10,6 +10,7 @@ #include <FairTask.h> class TClonesArray; +class TH1F; class CbmDigiManager; class CbmEvent; @@ -34,6 +35,7 @@ public: /** Task execution **/ virtual void Exec(Option_t* opt); + void Finish(); /** Add a reference detector **/ void AddRefDetector(ECbmModuleId RefDetector) { fRefDetectors.push_back(RefDetector); } @@ -44,9 +46,16 @@ private: TClonesArray* fEvents; ///< Input array (class CbmEvent) Int_t fNofEntries = 0; ///< Number of processed entries + TFolder* histFolder = nullptr; /// subfolder for histograms + TFolder fOutFolder; /// output folder with histos and canvases + /** Task initialisation **/ virtual InitStatus Init(); + void DeInit(); + /** Histograms **/ + TH1F* fhCorrectDigiRatioAll = nullptr; /// correct digis per event for all detectors + TH1F* fhFoundDigiRatioAll = nullptr; /// digis found per event for all detectors /** Match a reconstructed event to MC events+ ** @param event Pointer to reconstructed event