Skip to content
Snippets Groups Projects
Commit 89c72128 authored by Dominik Smith's avatar Dominik Smith Committed by Dominik Smith
Browse files

CbmBuildEventsQA: Added histograms to display percentage of correct digis per...

CbmBuildEventsQA: Added histograms to display percentage of correct digis per event and percentage of found digis per event.
parent 00116898
No related branches found
No related tags found
No related merge requests found
......@@ -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)
{
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment