32 SquarePlot(TObjArray* array, TString xTitle, TString yTitle);
35 void Draw(TString outname);
56 options = std::vector<std::string> (array->GetEntries(),
"SAME");
66 std::cout <<
"-----------------------------" << std::endl;
67 std::cout <<
" Plot Square Canvas:" << std::endl;
68 std::cout <<
"-----------------------------" << std::endl;
71 std::cout <<
"Due to one or more \033[1;33mFATAL ERRORS\033[0m your Plot will not be drawn" << std::endl;
72 std::cout <<
"-----------------------------" << std::endl << std::endl;
79 mainPad =
new TPad(
"mainPad",
"Distribution", 0, 0, 1, 1);
88 canvas->SaveAs(outname.Data());
91 std::cout <<
"-----------------------------" << std::endl << std::endl;
106 RatioPlot(TObjArray* rArray, TString xTitle, TString yTitle);
109 void Draw(TString outname);
110 void DrawRatioArray(TObjArray* array, Int_t off, Int_t offOpt = 0);
138 options = std::vector<std::string>(rArray->GetEntries(),
"SAME");
148 std::cout <<
"-----------------------------" << std::endl;
149 std::cout <<
" Plot Ratio Canvas:" << std::endl;
150 std::cout <<
"-----------------------------" << std::endl;
153 std::cout <<
"Due to one or more \033[1;33mFATAL ERRORS\033[0m your Plot will not be drawn" << std::endl;
154 std::cout <<
"-----------------------------" << std::endl << std::endl;
161 mainPad =
new TPad(
"mainPad",
"Ratio", 0, 0, 1, 1);
170 canvas->SaveAs(outname.Data());
173 std::cout <<
"-----------------------------" << std::endl << std::endl;
212 SingleRatioPlot(TObjArray* mainArray, TObjArray* ratioArray, TString xTitle, TString yTitle, TString ratioTitle);
215 void Draw(TString outname);
218 void SetCanvasOffsets(Float_t xOffset, Float_t yOffset, Float_t rOffset = 0);
220 virtual void SetRanges(Float_t xLow, Float_t xUp, Float_t yLow, Float_t yUp, Float_t rLow, Float_t rUp);
221 virtual void SetOptions(std::string optns, std::string postns);
225 static Float_t padFrac;
227 TPad* ratioPad {
nullptr};
230 TObjArray* ratioArray;
232 Float_t offsetR {0.};
233 Float_t rRangeUp {1.2};
234 Float_t rRangeLow {0.8};
236 static Int_t rOffset;
242 Float_t SingleRatioPlot::padFrac {.3};
243 Int_t SingleRatioPlot::rOffset {1};
260 options = std::vector<std::string>(mainArray->GetEntries()+rArray->GetEntries(),
"SAME");
270 std::cout <<
"-----------------------------" << std::endl;
271 std::cout <<
" Plot Single Ratio Canvas: " << std::endl;
272 std::cout <<
"-----------------------------" << std::endl;
275 std::cout <<
"Due to one or more \033[1;33mFATAL ERRORS\033[0m your Plot will not be drawn" << std::endl;
276 std::cout <<
"-----------------------------" << std::endl << std::endl;
283 mainPad =
new TPad(
"mainPad",
"Distribution", 0, padFrac, 1, 1);
290 ratioPad =
new TPad(
"ratioPad",
"Ratio", 0, 0, 1, padFrac);
292 ratioPad->SetTopMargin(0.);
302 canvas->SaveAs(outname.Data());
305 std::cout <<
"-----------------------------" << std::endl << std::endl;
315 offsetR = rOffset ? rOffset : yOffset;
358 std::istringstream
options(optns);
359 std::istringstream positions(postns);
361 TString* opt =
new TString();
362 TString* pos =
new TString();
364 opt->ReadToDelim(options,
';');
365 pos->ReadToDelim(positions,
';');
368 opt->ReadLine(options);
369 pos->ReadLine(positions);
385 HeatMapPlot(TObjArray* plotArray, TString xTitle, TString yTitle, TString zTitle =
"count");
386 HeatMapPlot(TH2* map, TLegend* l, TString xTitle, TString yTitle, TString zTitle =
"count");
389 void Draw(TString outname);
393 void SetLog(Bool_t xLog = kFALSE, Bool_t yLog = kTRUE, Bool_t zLog = kFALSE);
394 virtual void SetRanges(Float_t xLow, Float_t xUp, Float_t yLow, Float_t yUp, Float_t zLow, Float_t zUp);
399 void EnsureTH2(TObject* first, std::string arrayName);
401 void SetCanvasStyle(TH2* first);
402 void SetPadStyle(TH2* first, TString xTitle, TString yTitle, TString zTitle, Float_t xUp, Float_t xLow, Float_t yUp, Float_t yLow, Float_t zUp, Float_t zLow);
403 void SetUpPad(TPad* pad, Bool_t xLog, Bool_t yLog, Bool_t zLog = kFALSE);
406 TString titleZ {
"count"};
409 Bool_t logZ {kFALSE};
410 Float_t zRangeUp {0};
411 Float_t zRangeLow {0};
413 TObjArray *plotArray {
nullptr};
425 EnsureTH2(array->At(0),
"Heatmap Array");
431 options = std::vector<std::string>(array->GetEntries(),
"SAME");
442 plotArray =
new TObjArray();
450 options = {
"SAME COLZ",
"SAME"};
460 std::cout <<
"-----------------------------" << std::endl;
461 std::cout <<
" Plot Heat Map:" << std::endl;
462 std::cout <<
"-----------------------------" << std::endl;
465 std::cout <<
"Due to one or more \033[1;33mFATAL ERRORS\033[0m your Plot will not be drawn" << std::endl;
466 std::cout <<
"-----------------------------" << std::endl << std::endl;
473 mainPad =
new TPad(
"mainPad",
"Distribution", 0, 0, 1, 1);
475 SetCanvasStyle((TH2*)plotArray->At(0));
483 canvas->SaveAs(outname.Data());
486 std::cout <<
"-----------------------------" << std::endl << std::endl;
490 void HeatMapPlot::EnsureTH2(TObject* first, std::string arrayName){
494 std::cout <<
"\033[1;33mFATAL ERROR:\033[0m First entry in array doesn't exist!!" << std::endl;
500 if (!first->InheritsFrom(
"TH2")){
502 std::cout <<
"\033[1;33mFATAL ERROR:\033[0m First entry in array must be a TH2 "
503 <<
"\033[1;36m(" << arrayName <<
")\033[0m" << std::endl;
504 std::cout <<
" In case you don't want to draw a TH2, please use SquarePlot." << std::endl;
516 map->SetContour(100);
517 map->SetStats(kFALSE);
518 map->SetTitle(title.data());
522 void HeatMapPlot::SetCanvasStyle(TH2* first){
528 first->GetZaxis()->SetTitleOffset(offsetZ);
529 first->GetZaxis()->SetTickSize(0.03);
530 first->GetZaxis()->SetTitleSize(
label);
531 first->GetZaxis()->SetTitleFont(
font);
532 first->GetZaxis()->SetLabelFont(
font);
533 first->GetZaxis()->SetLabelSize(
label);
537 void HeatMapPlot::SetPadStyle(TH2* first, TString xTitle, TString yTitle, TString zTitle, Float_t xUp, Float_t xLow, Float_t yUp, Float_t yLow, Float_t zUp, Float_t zLow){
543 first->GetZaxis()->SetRangeUser(zLow, zUp);
544 first->GetZaxis()->SetTitle(zTitle);
548 void HeatMapPlot::SetUpPad(TPad* pad, Bool_t xLog, Bool_t yLog, Bool_t zLog){
555 if (zRangeLow > 0) pad->SetLogz(1);
556 else std::cout <<
"\033[1;31mERROR in SetLog:\033[0m Z-Ranges must be above zero! Logarithm not set!!" << std::endl;
SquarePlot(TObjArray *array, TString xTitle, TString yTitle)
Constructor.
Definition: PlotDerived.h:46
TLine * one
Horizontal TLine which will be included to every ratio at height 1.
Definition: PlotDerived.h:118
void SetLog(Bool_t xLog=kFALSE, Bool_t yLog=kTRUE, Bool_t zLog=kFALSE)
Definition: PlotDerived.h:571
Class for plotting a single TH2 (heatmap) and one corresponding legend.
Definition: PlotDerived.h:381
HeatMapPlot(TObjArray *plotArray, TString xTitle, TString yTitle, TString zTitle="count")
Constructor.
Definition: PlotDerived.h:420
void SetCanvasOffsets(Float_t xOffset, Float_t yOffset)
Definition: PlotBase.h:314
Float_t yRangeLow
Lower Y-axis range.
Definition: PlotBase.h:101
static void SetLineProperties(PO *pobj, Color_t color, Style_t lstyle, Size_t lwid=2.)
Definition: PlotBase.h:209
virtual void SetOptions(std::string optns, std::string postns)
Definition: PlotDerived.h:352
TPad * mainPad
Main pad.
Definition: PlotBase.h:73
Float_t offsetY
Offset of Y title.
Definition: PlotBase.h:93
Base class for all plotting functionality.
Definition: PlotBase.h:21
void SetOptions(TString opt)
Definition: PlotBase.h:478
virtual void SetRanges(Float_t xLow, Float_t xUp, Float_t yLow, Float_t yUp, Float_t rLow, Float_t rUp)
Definition: PlotDerived.h:337
void SetCanvasOffsets(Float_t xOffset, Float_t yOffset, Float_t zOffset)
Definition: PlotDerived.h:561
SingleRatioPlot(TObjArray *mainArray, TObjArray *ratioArray, TString xTitle, TString yTitle, TString ratioTitle)
Constructor.
Definition: PlotDerived.h:248
Bool_t logX
Should X-axis be logarithmic?
Definition: PlotBase.h:98
Class for a simple square-format plot.
Definition: PlotDerived.h:27
static Int_t mOffset
Offset for style array index.
Definition: PlotBase.h:114
Double_t oneUp
Upper bound on x-Range for TLine one.
Definition: PlotDerived.h:119
void Draw()
Abstract template for function.
Definition: PlotBase.h:37
void SetUpStyle(TObject *first, TString xTitle, TString yTitle, Float_t xUp, Float_t xLow, Float_t yUp, Float_t yLow, Float_t xOff, Float_t yOff)
Definition: PlotBase.h:187
void SetCanvasOffsets(Float_t xOffset, Float_t yOffset, Float_t rOffset=0)
Definition: PlotDerived.h:309
static Style_t label
Label size.
Definition: PlotBase.h:112
TObjArray * plotArray
Array containing all objects to be plotted.
Definition: PlotDerived.h:116
Float_t height
Height of canvas.
Definition: PlotBase.h:91
Bool_t drawone
Variable indicating wether TLine one will be drawn.
Definition: PlotDerived.h:121
Class for a rectangle plot displaying ratios.
Definition: PlotDerived.h:101
void DrawArray(TObjArray *array, Int_t off=0, Int_t offOpt=0)
Definition: PlotBase.h:587
Bool_t logY
Should Y-axis be logarithmic?
Definition: PlotBase.h:99
void SetCanvasMargins(Float_t rMargin, Float_t lMargin, Float_t tMargin, Float_t bMargin)
Definition: PlotBase.h:303
void EnsureAxes(TObject *first, std::string arrayName="")
Definition: PlotBase.h:564
virtual void SetRanges(Float_t xLow, Float_t xUp, Float_t yLow, Float_t yUp, Float_t zLow, Float_t zUp)
Definition: PlotDerived.h:581
void SetCanvasStyle(AO *first, Float_t xOff, Float_t yOff)
Definition: PlotBase.h:155
void SetPadStyle(AO *first, TString xTitle, TString yTitle, Float_t xUp, Float_t xLow, Float_t yUp, Float_t yLow)
Definition: PlotBase.h:175
std::vector< std::string > options
Drawing options.
Definition: PlotBase.h:85
TString titleY
Title of Y-axis.
Definition: PlotBase.h:88
void SetOffset(Int_t off, Int_t roff)
Definition: PlotDerived.h:327
Float_t xRangeUp
Upper X-axis range.
Definition: PlotBase.h:104
Float_t xRangeLow
Lower X-axis range.
Definition: PlotBase.h:103
void SetOption(std::string opt, Int_t pos)
Definition: PlotBase.h:524
void DrawRatioArray(TObjArray *array, Int_t off, Int_t offOpt=0)
Definition: PlotDerived.h:177
static Style_t font
Font style.
Definition: PlotBase.h:111
TString titleX
Title of X-axis.
Definition: PlotBase.h:87
void SuppressXaxis(AO *first)
Definition: PlotBase.h:373
Bool_t ranges
Were ranges set manually?
Definition: PlotBase.h:106
Float_t offsetX
Offset of X title.
Definition: PlotBase.h:92
RatioPlot(TObjArray *rArray, TString xTitle, TString yTitle)
Constructor.
Definition: PlotDerived.h:128
Float_t yRangeUp
Upper Y-axis range.
Definition: PlotBase.h:102
TCanvas * canvas
Main canvas.
Definition: PlotBase.h:74
Float_t width
Width of canvas.
Definition: PlotBase.h:90
Bool_t broken
Did any fatal error occur?
Definition: PlotBase.h:107
void SetProperties(TH2 *map, std::string title="")
Definition: PlotDerived.h:512
void SetUpPad(TPad *pad, Bool_t xLog, Bool_t yLog)
Definition: PlotBase.h:534
void ToggleOne()
Toggle wether TLine indicating ratio = 1, will be drawn.
Definition: PlotDerived.h:112
void SetPadFraction(Double_t frac)
Definition: PlotDerived.h:319
void SetCanvasDimensions(Float_t cWidth, Float_t cHeight)
Definition: PlotBase.h:294
Class for a rectangle plot with the distributions in the upper pad and the ratios in the lower pad...
Definition: PlotDerived.h:207
void SetUpperOneLimit(Double_t up)
Definition: PlotDerived.h:193