10 _ratioMax(s_ratioMax),
18 WELCOME_LOG <<
"Hello from the Plotter() constructor!";
25 VERBOSE_LOG << histogram <<
" " << histogram->GetName();
27 histogram->SetTitle(
"");
32 if ( histogram->GetXaxis()->GetLabelSize() != 0.0 )
34 if ( histogram->GetYaxis()->GetLabelSize() != 0.0 )
41 if ( histogram->GetXaxis()->GetLabelOffset() != 999 )
43 if ( histogram->GetYaxis()->GetLabelOffset() != 999 )
53 double nBins = (double)histogram->GetNbinsX();
54 double markerSize = 15.0/nBins;
55 if (markerSize > 0.3) markerSize = 0.3;
56 histogram->SetMarkerSize(markerSize);
61 if (
_bMargin < 0.01) histogram->GetXaxis()->SetNoExponent();
74 VERBOSE_LOG <<
"Adding TLine from (" << xpos <<
", " << ymin <<
") to (" << xpos <<
", " << ymax <<
")";
75 TLine* line =
new TLine(xpos ,ymin ,xpos, ymax );
76 line->SetLineColor(colour);
77 line->SetLineStyle(style);
84 double xlow =
getHistogram(0)->GetXaxis()->GetBinLowEdge(1);
86 TLine* line =
new TLine(xlow ,ypos ,xhigh, ypos );
87 line->SetLineColor(colour);
88 line->SetLineStyle(style);
96 double xlow =
getHistogram(0)->GetXaxis()->GetBinLowEdge(1);
98 TBox* box =
new TBox(xlow ,ypos - (width*0.5) ,xhigh, ypos + (width*0.5) );
100 box->SetFillColor(fillColour);
110 TBox* box =
new TBox(xmin ,ymin ,xmax, ymax );
111 box->SetLineColor(0);
112 box->SetFillColor(fillColour);
113 box->SetFillStyle(fillstyle);
127 if (min < globalMin) globalMin = min;
130 if (globalMin > 0) globalMin = globalMin*0.95;
131 else globalMin = globalMin*1.05;
145 if (max > globalMax) globalMax = max;
148 if (globalMax > 0) globalMax = globalMax*1.05;
149 else globalMax = globalMax*0.95;
171 double splitHeight = 0.3;
172 double scaleFactor = (1.0 - splitHeight) / splitHeight;
176 TString upperPadName = (TString)
_canvas->GetName() +
"_upper";
177 TString lowerPadName = (TString)
_canvas->GetName() +
"_lower";
178 TPad* upperPad =
new TPad(upperPadName, upperPadName, 0.0, splitHeight, 1.0, 1.0);
179 TPad* lowerPad =
new TPad(lowerPadName, lowerPadName, 0.0, 0.0, 1.0, splitHeight);
182 plot (
"", plotOptions,upperPad );
187 if (plotDirectory !=
"") pad->Print(plotDirectory +
s_imageformat);
191 void RootPlotter1D::plotRatio(TString plotDirectory, TString plotOptions, TPad* pad,
double scaleFactor,
double* returnMin,
double* returnMax){
196 divHist0->GetXaxis()->SetTitle(
getHistogram(0)->GetXaxis()->GetTitle() );
197 divHist0->GetYaxis()->SetTitle(
getHistogram(0)->GetYaxis()->GetTitle() );
202 if (scaleFactor != 1.0){
203 divHist0->GetXaxis()->SetTickLength(divHist0->GetXaxis()->GetTickLength()*scaleFactor);
204 divHist0->GetYaxis()->SetNdivisions(502);
210 for (
unsigned int i = 2; i <
_histograms.size(); i++) {
212 divPlotter.
add(divHist);
219 if (scaleFactor != 1.0){
232 if ( fabs(min-1) > fabs(max-1) ) max = 1 + fabs(min-1);
234 divPlotter.
setMin(2.0-max);
237 if(returnMin != 0) *returnMin = 2.0-max;
238 if(returnMax != 0) *returnMax = max;
241 divPlotter.
plot(
"", plotOptions, pad);
244 if (plotDirectory !=
"") pad->Print(plotDirectory +
s_imageformat);
252 divHist0->GetXaxis()->SetTitle(
getHistogram(0)->GetXaxis()->GetTitle() );
253 divHist0->GetYaxis()->SetTitle(
getHistogram(0)->GetYaxis()->GetTitle() );
258 if (scaleFactor != 1.0){
259 divHist0->GetXaxis()->SetTickLength(divHist0->GetXaxis()->GetTickLength()*scaleFactor);
260 divHist0->GetYaxis()->SetNdivisions(502);
264 for (
unsigned int i = 2; i <
_histograms.size(); i++) {
266 divPlotter.
add(divHist);
273 if (scaleFactor != 1.0){
289 divPlotter.
plot(
"", plotOptions, pad);
292 if (plotDirectory !=
"") pad->Print(plotDirectory +
s_imageformat);
297 double splitHeight = 0.3;
298 double scaleFactor = (1.0 - splitHeight) / splitHeight;
302 TString upperPadName = (TString)
_canvas->GetName() +
"_upper";
303 TString lowerPadName = (TString)
_canvas->GetName() +
"_lower";
304 TPad* upperPad =
new TPad(upperPadName, upperPadName, 0.0, splitHeight, 1.0, 1.0);
305 TPad* lowerPad =
new TPad(lowerPadName, lowerPadName, 0.0, 0.0, 1.0, splitHeight);
307 plotPulls(
"", plotOptions,lowerPad, scaleFactor);
308 plot (
"", plotOptions,upperPad);
313 if (plotDirectory !=
"") pad->Print(plotDirectory +
s_imageformat);
321 ratioPlotter->
setMin(-999.999);
324 double absMin = fabs(min);
326 double base = pow(10, floor(log10(absMin)));
327 int unit = ceil(
double(absMin)/base);
328 double roundedMin = double(unit)*base;
330 if (min < 0.0) roundedMin = -roundedMin;
332 return 1.0 + roundedMin;
341 ratioPlotter->
setMax(-999.999);
344 double absMax = fabs(max);
346 double base = pow(10, floor(log10(absMax)));
347 int unit = ceil(
double(absMax)/base);
348 double roundedMax = double(unit)*base;
350 if (max < 0.0) roundedMax = -roundedMax;
352 return 1.0 + roundedMax;
static TString s_imageformat
virtual void setHistogramStyle(TH1 *histogram, bool setMinMax=1)
virtual double getGlobalMin()
std::vector< TObject * > _histograms
std::vector< TObject * > _objToPlot
double getRatioMin(RootPlotter1D *ratioPlotter)
void plotPulls(TString plotDirectory, TString plotOptions="", TPad *pad=0, double scaleFactor=1.0)
virtual double getGlobalMax()
void plotWithRatio(TString plotDirectory, TString plotOptions="", TPad *pad=0)
void plotWithPulls(TString plotDirectory, TString plotOptions="", TPad *pad=0)
void plotRatio(TString plotDirectory, TString plotOptions="", TPad *pad=0, double scaleFactor=1.0, double *returnMin=0, double *returnMax=0)
virtual void plot(TString plotDirectory, TString plotOptions="", TPad *pad=0, double scaleFactor=1.0)
void addVerticalLine(double xpos, int style=1, int colour=1)
void addHorizontalLine(double ypos, int style=1, int colour=1)
void setHistogramOwnership(bool i=1)
void addVerticalBox(double xmin, double xmax, int fillColour, int fillstyle)
double getRatioMax(RootPlotter1D *ratioPlotter)
void add(TObject *histogram)
TH1D gDivideTH1D(TH1D const *hist1, TH1D const *hist2, TString name)
TH1 * getHistogram(int i)
void addHorizontalBox(double ypos, double width, int fillColour)
RootPlotter1D(TH1 *histogram, double width=400, double height=300)
TH1D gPullTH1D(TH1D const *hist1, TH1D const *hist2, TString name)