PandaRoot
PndTrackingQAAna.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
20 #pragma once
21 
22 #include "PndTrackingQASummary.h"
23 
24 #include <TH1D.h>
25 #include <TFile.h>
26 #include <TTree.h>
27 #include <TString.h>
28 #include <TCut.h>
29 
30 #include <map>
31 #include <string>
32 
33 
34 class PndTrackingQAAna : public TObject {
35  public:
37  PndTrackingQAAna(std::string fileName) : fQAFileName(fileName){};
38  PndTrackingQAAna(TFile *file) : fFile(file){};
39 
40  void SetQAFileName(TString fileName) { fQAFileName = fileName; }
41 
42  void SetSaveHistosAsPictures(bool val) { fSaveHistosAsPictures = val; }
43  void SetPicturePrefix(TString prefix) { fPicturePrefix = prefix; };
44  void SetPictureFormat(TString format) { fPictureFormat = format; }
45  void SetWorkdir(TString workdir) { fWorkdir = workdir; }
46 
47  PndTrackingQASummary *GetTrackingQASummary() const { return fSummary; }
48  std::map<std::string, double> GetResults() const { return fResults; }
49  std::vector<std::string> GetPngFilenames() const { return fPngFiles; }
50  void FillResults();
51 
52  virtual ~PndTrackingQAAna();
53 
54  void Init();
55  void AnalyseQAData();
56 
57  protected:
58  void InitHistograms();
59  void LabelQualityHistogram(TH1 *h);
60  void FillQualityHisto();
61  void FillIdealHistos();
62  void FillMomHistos();
63  void FillEfficiencyHistos();
64  virtual void SetQualityHisto(TH1 *histo, Bool_t relative, Int_t base = 1);
65  void SaveHistoVectorAsPicture(std::vector<TH1 *>, TString identifier, int col, int row, TString options = "");
66  void SaveHistosAsPicture();
67  void SetEfficiencyVsHisto(TH1D *h1, TString selector, TCut cut = "", Double_t hitEfficiency = 0.7);
68  std::array<Double_t, 6> DoubleGaussFit(TH1 *hisDiff);
69  double FitMomHistos(std::string histoName);
70 
71  private:
72  std::map<std::string, TH1 *> fHistos;
73  std::map<std::string, double> fResults;
74  std::vector<std::string> fPngFiles;
75  std::string fQAFileName;
76  TFile *fFile = nullptr;
77  TFile *fOutputFile = nullptr;
78  TTree *fTree = nullptr;
79  PndTrackingQASummary *fSummary = nullptr;
80 
81  TString fPicturePrefix = "test";
82  TString fPictureFormat = "gif";
83 // bool fCDashOutput = true;
84  bool fSaveHistosAsPictures = true;
85  TString fWorkdir = "."; // directory to tell cdash where to find png output files
86  bool fPngOutputSuccessful = true;
87 
88  ClassDef(PndTrackingQAAna, 1);
89 };
double FitMomHistos(std::string histoName)
void SetSaveHistosAsPictures(bool val)
void SetPictureFormat(TString format)
PndTrackingQASummary * GetTrackingQASummary() const
void SetPicturePrefix(TString prefix)
void SetWorkdir(TString workdir)
std::vector< std::string > GetPngFilenames() const
void FillIdealHistos()
void SaveHistosAsPicture()
void SetEfficiencyVsHisto(TH1D *h1, TString selector, TCut cut="", Double_t hitEfficiency=0.7)
Generates track efficiency histo vs. a selected parameter.
void FillEfficiencyHistos()
virtual ~PndTrackingQAAna()
std::array< Double_t, 6 > DoubleGaussFit(TH1 *hisDiff)
std::map< std::string, double > GetResults() const
virtual void SetQualityHisto(TH1 *histo, Bool_t relative, Int_t base=1)
void LabelQualityHistogram(TH1 *h)
PndTrackingQAAna(std::string fileName)
void SaveHistoVectorAsPicture(std::vector< TH1 *>, TString identifier, int col, int row, TString options="")
PndTrackingQAAna(TFile *file)
void SetQAFileName(TString fileName)
void FillQualityHisto()