1 |
#ifndef PLOTUTILITIES_H
|
2 |
#define PLOTUTILITIES_H
|
3 |
#include <TString.h>
|
4 |
#include <string>
|
5 |
#include <TPaveText.h>
|
6 |
#include <TLegend.h>
|
7 |
#include <TGraph.h>
|
8 |
#include <TGraphErrors.h>
|
9 |
#include <TGraphAsymmErrors.h>
|
10 |
#include <TH1F.h>
|
11 |
#include <TF1.h>
|
12 |
#include <TFile.h>
|
13 |
#include <TSystem.h>
|
14 |
#include <TObject.h>
|
15 |
#include <TROOT.h>
|
16 |
#include <TCanvas.h>
|
17 |
#include <TArrow.h>
|
18 |
#include <TTree.h>
|
19 |
|
20 |
using namespace std;
|
21 |
|
22 |
void DrawCMS(string cms="CMS Preliminary", double x1=0.7, double y1=0.9, double x2=0.8, double y2=1.0, double txtsize=0.05); //FIXME: don't do this inside class
|
23 |
TPaveText* SetTPaveText (Double_t x1,
|
24 |
Double_t y1,
|
25 |
Double_t x2,
|
26 |
Double_t y2);
|
27 |
TLegend* DrawLegend (Float_t x1,
|
28 |
Float_t y1,
|
29 |
TH1F* hist,
|
30 |
TString label,
|
31 |
TString option,
|
32 |
Float_t tsize = 0.04,
|
33 |
Float_t xoffset = 0.25,
|
34 |
Float_t yoffset = 0.15);
|
35 |
TLegend* DrawLegend (Float_t x1,
|
36 |
Float_t y1,
|
37 |
TGraph* hist,
|
38 |
TString label,
|
39 |
TString option,
|
40 |
Float_t tsize = 0.04,
|
41 |
Float_t xoffset = 0.25,
|
42 |
Float_t yoffset = 0.15);
|
43 |
void MoveLegend(TLegend *leg, Float_t x1,
|
44 |
Float_t y1, Float_t xoffset=0.25, Float_t yoffset=0.15);
|
45 |
void Save(TCanvas *cCanvas, string _ssave);
|
46 |
void DrawText(double x1, double y1, double x2, double y2, TString text, double size = 0.045);
|
47 |
class PlotWithBelts{
|
48 |
public:
|
49 |
PlotWithBelts()
|
50 |
:cCanvas(NULL),legend(NULL),pt(NULL),gGreen(NULL),
|
51 |
gYellow(NULL),lineOne(NULL),gr(NULL),
|
52 |
grobs(NULL),ptCMSPreli(NULL)
|
53 |
{};
|
54 |
~PlotWithBelts();
|
55 |
PlotWithBelts(
|
56 |
double *r1sigLt, double *r1sigHt,
|
57 |
double *r2sigLt, double *r2sigHt,
|
58 |
double *rmeant, int npointst,
|
59 |
double *xpointst, string ssavetmp, TPaveText *pttmp,
|
60 |
double xmintmp =100, double xmaxtmp =260, double ymintmp=0.5, double ymaxtmp=100, bool logYtmp=true,
|
61 |
string stitlet ="; Higgs mass, m_{H} (GeV/c^{2}); Exclusion Limit, r = #sigma_{95%}/#sigma_{SM}");
|
62 |
PlotWithBelts(
|
63 |
double *r1sigLt, double *r1sigHt,
|
64 |
double *r2sigLt, double *r2sigHt,
|
65 |
double *rmeant, double *robst, int npointst,
|
66 |
double *xpointst, string ssavetmp, TPaveText *pttmp,
|
67 |
double xmintmp =100, double xmaxtmp =260, double ymintmp=0.5, double ymaxtmp=100, bool logYtmp=true,
|
68 |
string stitlet ="; Higgs mass, m_{H} (GeV/c^{2}); Exclusion Limit, r = #sigma_{95%}/#sigma_{SM}");
|
69 |
TGraph *getGreenGraph(){return gGreen;};
|
70 |
TGraph *getYellowGraph(){return gYellow;};
|
71 |
TGraph *getMeanGraph(){return gr;};
|
72 |
TGraph *getObsGraph(){return grobs;};
|
73 |
TLine *getLine(){return lineOne;};
|
74 |
TPaveText *getTitlePT(){return pt;};
|
75 |
TPaveText *getCMSPT(){return ptCMSPreli;};
|
76 |
|
77 |
TCanvas *getCanvas(){return cCanvas;};
|
78 |
TLegend *getLegend(){return legend;};
|
79 |
void setSavePath(string tmp){ssave=tmp;};
|
80 |
void drawLegend(string s_gr, string s_gGreen, string s_gYellow, string s_grobs="");
|
81 |
void plot();
|
82 |
void save();
|
83 |
void clear();
|
84 |
|
85 |
TH1F * getFrame(){return hframe;};
|
86 |
|
87 |
private:
|
88 |
TCanvas *cCanvas;
|
89 |
TLegend *legend;
|
90 |
bool logY;
|
91 |
string stitle;
|
92 |
string ssave;
|
93 |
|
94 |
double xmin, xmax, ymin, ymax;
|
95 |
TPaveText *pt;
|
96 |
TGraph *gGreen;
|
97 |
TGraph *gYellow;
|
98 |
TLine *lineOne;
|
99 |
TGraph *gr;
|
100 |
TGraph *grobs;
|
101 |
TPaveText *ptCMSPreli;
|
102 |
|
103 |
int bDrawGrobs;
|
104 |
double *r1sigL, *r1sigH, *r2sigL, *r2sigH, *rmean, *robs, *xpoints;
|
105 |
int npoints;
|
106 |
|
107 |
|
108 |
TH1F* hframe;
|
109 |
|
110 |
};
|
111 |
class DrawSigBkgPdfs{
|
112 |
public:
|
113 |
DrawSigBkgPdfs(double (*pdfs)(double *, double *), double *pars, int npars,
|
114 |
double (*pdfb)(double *, double *), double *parb, int nparb, double Ns, double Nb,
|
115 |
double xstart, double xstop, bool logY, string ssave, string stitle, bool debug=0);
|
116 |
~DrawSigBkgPdfs();
|
117 |
void draw();
|
118 |
void save();
|
119 |
TCanvas *getCanvas(){return cCanvas;};
|
120 |
TLegend *getLegend(){return legend;};
|
121 |
void setSavePath(string tmp){_ssave=tmp;};
|
122 |
void drawLegend(string s_tot, string s_s, string s_b);
|
123 |
void setLogY(bool b){_logY=b;};
|
124 |
void setDebug(bool b){_debug=b;};
|
125 |
|
126 |
TH1F *getHistS(){return hs;};
|
127 |
TH1F *getHistB(){return hb;};
|
128 |
TH1F *getHistTot(){return htot;};
|
129 |
TF1 *getTf1S(){return fs;};
|
130 |
TF1 *getTf1B(){return fb;};
|
131 |
private:
|
132 |
TCanvas *cCanvas;
|
133 |
string _ssave;
|
134 |
string _stitle;
|
135 |
bool _logY;
|
136 |
TLegend *legend;
|
137 |
bool _debug;
|
138 |
|
139 |
TF1 *fs;
|
140 |
TF1 *fb;
|
141 |
double (*_pdfs)(double *x, double *par); // normalized to unity
|
142 |
double (*_pdfb)(double *x, double *par); // normalized to unity
|
143 |
double *_pars;
|
144 |
double *_parb;
|
145 |
int _npars, _nparb;
|
146 |
double _Ns, _Nb;
|
147 |
double _xstart, _xstop;
|
148 |
TH1F *hs, *hb, *htot;
|
149 |
};
|
150 |
class DrawEvolution2D{
|
151 |
public:
|
152 |
DrawEvolution2D(vector<double> vx, vector<double> vy, string stitle, string ssave, TPaveText *pt, bool debug=0);
|
153 |
~DrawEvolution2D();
|
154 |
|
155 |
void draw();
|
156 |
void save();
|
157 |
TCanvas *getCanvas(){return cCanvas;};
|
158 |
TLegend *getLegend(){return legend;};
|
159 |
void setSavePath(string tmp){_ssave=tmp;};
|
160 |
//void drawLegend(string s_tot, string s_s, string s_b){};
|
161 |
void setLogY(bool b){_logY=b;};
|
162 |
void setDebug(bool b){_debug=b;};
|
163 |
TPaveText *getTitlePT(){return _pt;};
|
164 |
TGraph *getGraph(){return graph;};
|
165 |
TLine *getLine(){return lineOne;};
|
166 |
private:
|
167 |
TCanvas *cCanvas;
|
168 |
string _ssave;
|
169 |
string _stitle;
|
170 |
bool _logY;
|
171 |
TLegend *legend;
|
172 |
bool _debug;
|
173 |
TPaveText *_pt;
|
174 |
|
175 |
vector<double> _vx, _vy;
|
176 |
|
177 |
TLine *lineOne;
|
178 |
TGraph *graph;
|
179 |
};
|
180 |
class PlotXvsCummulativeProb{
|
181 |
public:
|
182 |
PlotXvsCummulativeProb(
|
183 |
double* vx_not_sorted, int nexps,
|
184 |
string ssave, string stitle,TPaveText *pt);
|
185 |
PlotXvsCummulativeProb(
|
186 |
vector<double> vx_not_sorted,
|
187 |
string ssave, string stitle,TPaveText *pt);
|
188 |
PlotXvsCummulativeProb(
|
189 |
vector<double> vx_sorted,
|
190 |
vector<double> vcumulaP_sorted,
|
191 |
double m1s, double p1s, double m2s, double p2s,
|
192 |
string ssave, string stitle,TPaveText *pt);
|
193 |
~PlotXvsCummulativeProb();
|
194 |
void draw();
|
195 |
void save();
|
196 |
TCanvas *getCanvas(){return cCanvas;};
|
197 |
TLegend *getLegend(){return legend;};
|
198 |
void setSavePath(string tmp){_ssave=tmp;};
|
199 |
//void drawLegend(string s_tot, string s_s, string s_b){};
|
200 |
void setLogY(bool b){_logY=b;};
|
201 |
void setDebug(bool b){_debug=b;};
|
202 |
TPaveText *getTitlePT(){return _pt;};
|
203 |
TGraphErrors *getGraph(){return graph;};
|
204 |
TLine *getLine(){return lineOne;};
|
205 |
TH1F *getDifferencialHist(){return diffHist;};
|
206 |
void setGraphDrawOption(string so){_graphOption=so;};
|
207 |
|
208 |
// --- to show the error bar of bins
|
209 |
void setTotalExps(int nexps){_nexps=nexps;};
|
210 |
void setShowErrorBar(bool b){bShowErrorBar=b;}
|
211 |
|
212 |
void drawDifferencial(string stitle, string ssave);
|
213 |
|
214 |
private:
|
215 |
TCanvas *cCanvas;
|
216 |
string _ssave;
|
217 |
string _stitle;
|
218 |
bool _logY;
|
219 |
TLegend *legend;
|
220 |
bool _debug;
|
221 |
TPaveText *_pt;
|
222 |
|
223 |
vector<double> _vx, _vy;
|
224 |
|
225 |
TLine *lineOne;
|
226 |
TGraphErrors *graph;
|
227 |
TH1F *diffHist;
|
228 |
|
229 |
double _1SigmaLow, _1SigmaHigh, _2SigmaLow, _2SigmaHigh;
|
230 |
|
231 |
bool bShowErrorBar;
|
232 |
int _nexps;
|
233 |
|
234 |
string _graphOption;
|
235 |
};
|
236 |
class DrawPdfM2logQ{
|
237 |
public:
|
238 |
DrawPdfM2logQ(vector<double> vPdfM2logQ_sb, vector<double> vPdfM2logQ_b,
|
239 |
double m2lnQ_d, string sdata, string stitle, string ssave, TPaveText *pt); // show the famous -2lnQ with s, b, d
|
240 |
DrawPdfM2logQ(vector< pair<double,double> > vPdfM2logQ_sb, vector< pair<double,double> > vPdfM2logQ_b,
|
241 |
double m2lnQ_d, string sdata, string stitle, string ssave, TPaveText *pt); // show the famous -2lnQ with s, b, d
|
242 |
~DrawPdfM2logQ();
|
243 |
void draw(); void draw2Hist(); void draw2Graph();
|
244 |
TCanvas *getCanvas(){return cCanvas;};
|
245 |
TLegend *getLegend(){return legend;};
|
246 |
void setSavePath(string tmp){_ssave=tmp;};
|
247 |
void drawLegend(string s_sb, string s_b, string s_d);
|
248 |
void setLogY(bool b){_logY=b;};
|
249 |
void setDebug(bool b){_debug=b;};
|
250 |
TPaveText *getTitlePT(){return _pt;};
|
251 |
TLine *getLine(){return lineOne;};
|
252 |
TGraph *getSignalGraph(){return gSB;};
|
253 |
TGraph *getBackgroundGraph(){return gB;};
|
254 |
TH1F *getSignalHist(){return hSB;};
|
255 |
TH1F *getBackgroundHist(){return hB;};
|
256 |
private:
|
257 |
TCanvas *cCanvas;
|
258 |
string _ssave;
|
259 |
string _stitle;
|
260 |
bool _logY;
|
261 |
TLegend *legend;
|
262 |
bool _debug;
|
263 |
TPaveText *_pt;
|
264 |
TLine *lineOne;
|
265 |
|
266 |
TGraph *gSB, *gB;
|
267 |
TH1F *hSB, *hB;
|
268 |
|
269 |
string _lineTitle;
|
270 |
double _m2lnQ_d;
|
271 |
vector<double> _vsb, _vb; //inputs from pseudo experiments
|
272 |
vector< pair<double,double> > _vpsb, _vpb; // inputs from analytic formula
|
273 |
// tag the inputs are _vsb or _vpsb
|
274 |
bool bFromPseudoExps;
|
275 |
};
|
276 |
|
277 |
const int maxNumGraphs=10;
|
278 |
const int _glineStyle[maxNumGraphs]={2,2,8,8,1,1, 1,1,1,1};
|
279 |
const int _glineColor[maxNumGraphs]={4,2,6,1,5,3, 3, 3, 3, 3};
|
280 |
const int _gmarkerStyle[maxNumGraphs]={20,24,3,26,22,23, 23,23,23,23};
|
281 |
class DrawMultiGraph{
|
282 |
public:
|
283 |
DrawMultiGraph(double *x1, double *y1, int n1, string title1,
|
284 |
string stitle, string ssave, TPaveText *pt,
|
285 |
double xmin, double xmax, double ymin, double ymax, bool logY);
|
286 |
DrawMultiGraph(double *x1, double *y1, int n1, string title1,
|
287 |
double *x2, double *y2, int n2, string title2, string stitle, string ssave, TPaveText *pt,
|
288 |
double xmin, double xmax, double ymin, double ymax, bool logY);
|
289 |
~DrawMultiGraph();
|
290 |
void add(double *x, double *y, int n, string title);
|
291 |
void draw();
|
292 |
TGraph* getGraph(int i){if(i<maxNumGraphs && i>=0) return _gr[i];else return 0;};
|
293 |
|
294 |
TLegend *getLegend(){
|
295 |
//cout<<"delete me2 legendY2="<<legend->GetY2()<<endl;
|
296 |
return legend;};
|
297 |
void setSavePath(string tmp){_ssave=tmp;};
|
298 |
//void drawLegend(string s_sb, string s_b, string s_d);
|
299 |
void setLogY(bool b){_logY=b;};
|
300 |
void setDebug(bool b){_debug=b;};
|
301 |
TPaveText *getTitlePT(){return _pt;};
|
302 |
TLine *getLine(){return lineOne;};
|
303 |
TCanvas *getCanvas(){return cCanvas;};
|
304 |
void drawOption(int i, string op){if(i<maxNumGraphs && i>=0)_drawOptions[i]=op;};
|
305 |
void setLegendXY(double x, double y){legendX=x; legendY=y;};
|
306 |
//void save();
|
307 |
private:
|
308 |
TCanvas *cCanvas;
|
309 |
string _ssave;
|
310 |
string _stitle;
|
311 |
bool _logY;
|
312 |
TLegend *legend;
|
313 |
bool _debug;
|
314 |
TPaveText *_pt;
|
315 |
TLine *lineOne;
|
316 |
|
317 |
TGraph *_gr[maxNumGraphs];//currenly limit to maxNumGraphs graphs..
|
318 |
int _numGraphAdded;
|
319 |
double *_x[maxNumGraphs], *_y[maxNumGraphs];
|
320 |
int _n[maxNumGraphs];
|
321 |
string _title[maxNumGraphs];
|
322 |
double _xmin,_xmax,_ymin,_ymax;
|
323 |
string _drawOptions[maxNumGraphs];
|
324 |
double legendX, legendY;
|
325 |
};
|
326 |
class DrawPdfRLikelihood{
|
327 |
public:
|
328 |
DrawPdfRLikelihood(double r95, double *par, int npar, string stitle, string ssave, TPaveText *pt);
|
329 |
~DrawPdfRLikelihood();
|
330 |
void draw();
|
331 |
TH1F* getHist(){return hist;};
|
332 |
|
333 |
TLegend *getLegend(){return legend;};
|
334 |
void setSavePath(string tmp){_ssave=tmp;};
|
335 |
//void drawLegend(string s_hist, string s_arrow){};
|
336 |
void setLogY(bool b){_logY=b;};
|
337 |
void setDebug(bool b){_debug=b;};
|
338 |
TPaveText *getTitlePT(){return _pt;};
|
339 |
TArrow *getArrow(){return arrow;};
|
340 |
|
341 |
private:
|
342 |
TCanvas *cCanvas;
|
343 |
string _ssave;
|
344 |
string _stitle;
|
345 |
bool _logY;
|
346 |
TLegend *legend;
|
347 |
bool _debug;
|
348 |
TPaveText *_pt;
|
349 |
TArrow *arrow;
|
350 |
TH1F *hist;
|
351 |
bool _bUnbinned;
|
352 |
double _r95;
|
353 |
double *_par;
|
354 |
int _npar;
|
355 |
};
|
356 |
void GetMuHat(TTree *tree, vector<double>& inputMH, vector<double>& inputLimits );
|
357 |
void GetMuHat(TTree *tree, vector<double>& inputMH, vector<double>& inputLimits , vector<double> & inputLimitErrsUp, vector<double>& inputLimitErrsDn );
|
358 |
void GetLimits(TTree *tree, vector<double>& inputMH, vector<double>& inputLimits, vector<double> & inputLimitErrs );
|
359 |
void GetPValues(TTree *tree, vector<double>& inputMH, vector<double>& inputLimits, vector<double> & inputLimitErrs_m2s, vector<double> & inputLimitErrs_m1s, vector<double>&inputLimitErrs_p1s, vector<double>&inputLimitErrs_p2s );
|
360 |
void GetLimitBands(TTree *tree, vector<double>& inputMH, vector<double>& inputLimits, vector<double> & inputLimitsM2S, vector<double>& inputLimitsM1S,
|
361 |
vector<double>& inputLimitsMEDIAN, vector<double>& inputLimitsP1S, vector<double>& inputLimitsP2S);
|
362 |
TGraph* GetBeltGraph(const vector<double>& xpoints, const vector<double>& vup, const vector<double> & vdn);
|
363 |
|
364 |
TGraph* GetMuHatGraph(TTree *tree );
|
365 |
TGraphAsymmErrors* GetMuHatGraphAsymm(TTree *tree );
|
366 |
TGraph* GetLimitsGraph(TTree *tree );
|
367 |
TGraph* GetPValuesGraph(TTree *tree );
|
368 |
TObject* GetTObject(string filename, string objname);
|
369 |
#endif /* ----- #ifndef PLOTUTILITIES_H ----- */
|