PandaRoot
PndHistoCombiner.h
Go to the documentation of this file.
1 
16 #ifndef TOOLS_PNDHISTOCOMBINER_H_
17 #define TOOLS_PNDHISTOCOMBINER_H_
18 
19 #include <TObject.h>
20 #include <TString.h>
21 
22 #include <vector>
23 #include <map>
24 
25 #include "PndMultiCanvasCreator.h"
26 
27 class TFile;
28 class TH1;
29 
30 class PndHistoCombiner : public TObject {
31  public:
32  struct fileData {
33  fileData(){};
34  fileData(TString fileName, TString shortName) : fFileName(fileName), fShortName(shortName){};
35  TString fFileName;
36  TString fShortName;
37  TFile *fFile = nullptr;
38  Double_t fP = -1.;
39  };
40 
42  virtual ~PndHistoCombiner();
43 
50  void AddFileNamesAndShortName(TString fileName, TString shortName)
51  {
52  fileData myData(fileName, shortName);
53  fFileData.push_back(myData);
54  }
55 
59  int GenerateHistos();
60 
64  int GenerateBranches();
65 
70  void AddHistoSelector(TString histoName) { fHistoSelector.push_back(histoName); }
71 
76  void AddBranchSelector(TString branchName) { fBranchSelector.push_back(branchName); }
77 
83  void SetPicPerCan(int val) { fCanCreator.SetPicPerCan(val); }
84 
85  void SetCanvasPrefix(TString val) { fCanCreator.SetPrefix(val); }
86 
87  void SetCanvasOutputDir(TString val) { fCanCreator.SetOutputDir(val); }
88 
89  void SetCanvasOutputFormat(TString val) { fCanCreator.SetOutputFormat(val); }
90 
91  void SetPulls(bool dopulls = true)
92  {
93  fDoPulls = dopulls;
94  SetDimensions(400, 400);
95  }
96 
97  void SetDimensions(int x = 400, int y = 300) { fCanCreator.SetDimensions(x, y); }
98 
104  void DoTest(int val = 0, double threshold = 0.03)
105  {
106  fTestType = val;
107  fThreshold = threshold;
108  }
109 
113  void SetCDashOutput(bool val = true) { fCreateCDashOutput = val; }
118  void CreateCDashOutput();
119 
120  protected:
121  void InitFiles();
122  bool CheckHistoName(TString histoName);
123  bool CheckBranchName(TString branchName);
124  bool CheckBranchType(TString branchType);
125  void DrawAndTestHistoStack(std::vector<TH1 *> &histos);
126  std::pair<TPad *, TPad *> SplitPadForPulls();
127  void DrawPulls(std::vector<TH1 *> &histos);
128  void CreateLegend(std::vector<TH1 *> &histos);
129  double PerformTest(TH1 *h1, TH1 *h2);
130  bool TestPassed(double result, double threshold)
131  {
132  if (result > threshold)
133  return true;
134  return false;
135  }
136 
140  void AddCDashOutput(TString prefix, TString histoName, double value);
141 
142  TString RemoveSpecialCharacters(TString input);
143 
144  private:
145  std::vector<fileData> fFileData;
146  std::vector<TString> fHistoSelector;
147  std::vector<TString> fBranchSelector;
148  std::vector<TString> fCDashOutput;
149  std::vector<TH1 *> fTmpHistos;
150  PndMultiCanvasCreator fCanCreator;
151  int fTestType = 0;
152  bool fCreateCDashOutput = false;
153  double fThreshold = 0;
154  int fFailCount = 0;
155  int fPadNumber = 0;
156  bool fDoPulls = false;
157 
158  ClassDef(PndHistoCombiner, 1);
159 };
160 
161 #endif /* TOOLS_PNDHISTOCOMBINER_H_ */
std::pair< TPad *, TPad * > SplitPadForPulls()
int GenerateHistos()
Main method to generate histograms.
TString RemoveSpecialCharacters(TString input)
bool TestPassed(double result, double threshold)
void SetPicPerCan(int val)
pictures per canvas. They will be organized in a quadratic way
void SetCanvasPrefix(TString val)
fileData(TString fileName, TString shortName)
Combines histograms with the same name from different files in one overlay histogram.
double PerformTest(TH1 *h1, TH1 *h2)
void SetCDashOutput(bool val=true)
Select to generate output string automatically to upload data to CDASH server.
void CreateCDashOutput()
Generate output string to upload data to CDASH server This can be called automatically or by hand...
void AddCDashOutput(TString prefix, TString histoName, double value)
Add to output string to upload data to CDASH server.
bool CheckBranchName(TString branchName)
void AddFileNamesAndShortName(TString fileName, TString shortName)
Adds the file which contain the histos to be plotted together. First file is the one comparisons are ...
void SetCanvasOutputFormat(TString val)
Creates new canvasses once the number of histograms per canvas exceeds a setable threshold Automatic...
void AddHistoSelector(TString histoName)
Only those histograms are combined with part of their matching the histoName.
bool CheckHistoName(TString histoName)
void CreateLegend(std::vector< TH1 *> &histos)
void DoTest(int val=0, double threshold=0.03)
perform Kolmogorov or chi2 test between histograms of first file and all others.
void AddBranchSelector(TString branchName)
Only those branches are combined with part of their matching the branchName.
void SetDimensions(int x=400, int y=300)
int GenerateBranches()
Main method to generate histograms from branches.
void SetCanvasOutputDir(TString val)
void SetPulls(bool dopulls=true)
bool CheckBranchType(TString branchType)
void DrawPulls(std::vector< TH1 *> &histos)
virtual ~PndHistoCombiner()
void DrawAndTestHistoStack(std::vector< TH1 *> &histos)