File indexing completed on 2024-09-27 07:03:27
0001
0002
0003
0004 #pragma once
0005
0006 #include <map>
0007 #include <iomanip>
0008
0009
0010 #include <TFile.h>
0011 #include <TCanvas.h>
0012 #include <TRegexp.h>
0013 #include <TSystem.h>
0014 #include <TROOT.h>
0015 #include <TStyle.h>
0016 #include <TGaxis.h>
0017 #include <TLegend.h>
0018 #include <TProfile.h>
0019 #include <TProfile2D.h>
0020
0021
0022 #include <adage/CutDef.h>
0023 #include <adage/BinSet.h>
0024
0025
0026 #include "Histos.h"
0027 #include "Kinematics.h"
0028 #include "HistosDAG.h"
0029
0030 class PostProcessor
0031 {
0032 public:
0033 PostProcessor(
0034 TString infileN_,
0035 TString outfileN_=""
0036 );
0037 ~PostProcessor();
0038
0039
0040
0041 const Int_t dimx=800;
0042 const Int_t dimy=700;
0043 static const int nsumMax=3;
0044
0045
0046
0047 HistosDAG *GetHistosDAG() { return HD; };
0048 HistosDAG *Op() { return GetHistosDAG(); };
0049
0050 void Execute(Bool_t clear=true) {
0051 if(clear) HD->ExecuteAndClearOps();
0052 else HD->ExecuteOps();
0053 };
0054
0055
0056
0057
0058
0059 void Finish();
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070 void DumpHist(TString datFile, TString histSet, TString varName);
0071 void DumpAve(TString datFile, Histos *H, TString cutName);
0072 void DrawSingle(Histos *H, TString histName, TString drawFormat="", Int_t profileAxis=0, Bool_t profileOnly=false);
0073 void DrawSingle(TString histSet, TString histName);
0074 void DrawRatios(
0075 TString outName, Histos *numerSet, Histos *denomSet, Bool_t plotRatioOnly=false
0076 );
0077 void DrawInBins(
0078 TString outName,
0079 std::vector<std::vector<Histos*>>& histArr, TString histName,
0080 TString var1name, int nvar1, double var1low, double var1high, bool var1log,
0081 TString var2name, int nvar2, double var2low, double var2high, bool var2log,
0082 bool intgrid1=false, bool intgrid2=false,
0083 bool renormalize=false
0084 );
0085 void DrawInBins(
0086 TString outName,
0087 std::vector<std::vector<std::vector<Histos*>>>& histArrList, TString histName,
0088 TString var1name, int nvar1, double var1low, double var1high, bool var1log,
0089 TString var2name, int nvar2, double var2low, double var2high, bool var2log,
0090 bool intgrid1=false, bool intgrid2=false,
0091 bool renormalize=false
0092 );
0093 void DrawRatioInBins(
0094 TString outName,
0095 std::vector<std::vector<Histos*>>& histArr, TString histName,
0096 TString var1name, int nvar1, double var1low, double var1high, bool var1log,
0097 TString var2name, int nvar2, double var2low, double var2high, bool var2log,
0098 bool intgrid1=false, bool intgrid2=false,
0099 bool renormalize=false
0100 );
0101 void DrawRatioInBins(
0102 TString outName,
0103 std::vector<std::vector<std::vector<Histos*>>>& histArrList, TString histName,
0104 TString var1name, int nvar1, double var1low, double var1high, bool var1log,
0105 TString var2name, int nvar2, double var2low, double var2high, bool var2log,
0106 bool intgrid1=false, bool intgrid2=false,
0107 bool renormalize=false
0108 );
0109
0110
0111 void FinishDumpAve(TString datFile);
0112 void FinishDrawRatios(TString summaryDir);
0113
0114
0115 std::vector<TString> legendLabels;
0116
0117
0118 TString GetPngDir() { return pngDir; };
0119 TString GetOutfileName() { return outfileN; };
0120 TFile *GetOutfile() { return outfile; };
0121 BinSet *GetBinSet(TString varName);
0122 CutDef *GetBinCut(TString varName, Int_t binNum);
0123 std::vector<int> GetBinNums(TString varName);
0124
0125
0126 void StartTextFile(TString datFile, TString firstLine="");
0127 void AppendToTextFile(TString datFile, TString appendText);
0128 void Columnify(TString inputFile, TString outputFile);
0129 void PrintTextFile(TString datFile);
0130
0131
0132 Bool_t SkipFull(TString varName, Int_t binNum);
0133
0134
0135 void ResetVars();
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145 static void UnzoomVertical(TVirtualPad *pad, TString title="", Bool_t min0=false, Bool_t logy=false) {
0146 Double_t max=-1e6;
0147 Double_t min=1e6;
0148 Double_t maxTmp,minTmp;
0149 for(auto obj : *pad->GetListOfPrimitives()) {
0150 if(obj->InheritsFrom(TH1::Class())) {
0151 maxTmp = ((TH1*)obj)->GetMaximum();
0152 minTmp = ((TH1*)obj)->GetMinimum();
0153 max = maxTmp > max ? maxTmp : max;
0154 min = minTmp < min ? minTmp : min;
0155 };
0156 };
0157 max += 0.05*(max-min);
0158
0159 for(auto obj : *pad->GetListOfPrimitives()) {
0160 if(obj->InheritsFrom(TH1::Class())) {
0161 Double_t drawMin;
0162 if(logy) drawMin = 0.001*max;
0163 else drawMin = min0 ? 0:min;
0164 ((TH1*)obj)->GetYaxis()->SetRangeUser(drawMin,max);
0165 if(title!="") ((TH1*)obj)->SetTitle(title);
0166 };
0167 };
0168 };
0169
0170
0171
0172
0173 private:
0174
0175
0176 TString infileN, outfileN, pngDir;
0177 TFile *infile, *outfile;
0178
0179
0180 HistosDAG *HD;
0181
0182
0183 std::map<TString,TCanvas*> summaryCanvMap;
0184 std::vector<TString> varList;
0185 int nsum,ndump;
0186 CutDef *dumpCut;
0187 TCanvas *summaryCanv;
0188 Color_t summaryColor[nsumMax];
0189 Style_t summaryStyle[nsumMax];
0190
0191 ClassDef(PostProcessor,1);
0192 };