42 #include "TGraphAsymmErrors.h" 44 #include "TLegendEntry.h" 59 return to_string(count_++);
73 void DrawAll(
const vector<unique_ptr<Hist1D::SingleHist1D> > &hists,
74 string &draw_opt,
bool reversed =
false){
76 for(
auto &hist: hists){
77 hist->scaled_hist_.Draw(draw_opt.c_str());
79 draw_opt = draw_opt +
" same";
83 for(
auto h = hists.crbegin(); h != hists.crend(); ++h){
85 hist->scaled_hist_.Draw(draw_opt.c_str());
87 draw_opt = draw_opt +
" same";
98 h.GetXaxis()->SetTitle(
"");
99 h.SetLabelSize(0.,
"x");
100 h.SetTitleSize(0.,
"x");
115 size_t entries_per_column = n_entries / n_columns;
116 size_t cols_with_extra_entry = n_entries % n_columns;
117 size_t this_col = -1;
118 size_t this_col_end = 0;
119 while(this_col_end <= entry){
121 this_col_end += entries_per_column;
122 if(this_col < cols_with_extra_entry){
139 const std::shared_ptr<Process> &process,
144 proc_and_hist_cut_(figure.cut_ && process->cut_),
155 bool have_vec =
false;
173 if(!have_vec ||
wgt_vector_.size() < min_vec_size){
185 if(!have_vec ||
val_vector_.size() < min_vec_size){
194 for(
size_t i = 0; i < min_vec_size; ++i){
216 bool include_error_bar,
217 bool include_overflow)
const{
218 int start_bin = include_overflow ? 0 : 1;
220 double the_max = -numeric_limits<double>::infinity();
221 for(
int bin = start_bin; bin <= end_bin; ++bin){
223 if(include_error_bar){
226 if(content > the_max && content < max_bound){
247 bool include_error_bar,
248 bool include_overflow)
const{
249 int start_bin = include_overflow ? 0 : 1;
251 double the_min = numeric_limits<double>::infinity();
252 for(
int bin = start_bin; bin <= end_bin; ++bin){
254 if(include_error_bar){
257 if(content < the_min && content > min_bound){
274 const std::vector<std::shared_ptr<Process> > &processes,
275 const std::vector<PlotOpt> &plot_options):
297 empty.SetStats(
false);
299 for(
const auto &process: processes){
300 unique_ptr<SingleHist1D> hist(
new SingleHist1D(*
this, process, empty));
301 hist->
raw_hist_.SetFillColor(process->GetFillColor());
302 hist->
raw_hist_.SetFillStyle(process->GetFillStyle());
303 hist->
raw_hist_.SetLineColor(process->GetLineColor());
304 hist->
raw_hist_.SetLineStyle(process->GetLineStyle());
305 hist->
raw_hist_.SetLineWidth(process->GetLineWidth());
306 hist->
raw_hist_.SetMarkerColor(process->GetMarkerColor());
307 hist->
raw_hist_.SetMarkerStyle(process->GetMarkerStyle());
308 hist->
raw_hist_.SetMarkerSize(process->GetMarkerSize());
310 switch(process->type_){
312 datas_.push_back(move(hist));
326 blank_.SetFillColor(kWhite);
328 blank_.SetLineColor(kWhite);
330 blank_.SetMarkerColor(kWhite);
338 const string &subdir){
350 double bot_min, bot_max;
353 TGraphAsymmErrors bottom_background;
355 bottom_background = TGraphAsymmErrors(&bot_plots.back());
358 bot_plots.pop_back();
366 vector<TLine> bot_cuts =
GetCutLines(bot_min, bot_max,
false);
368 unique_ptr<TCanvas> full;
369 unique_ptr<TPad> top, bottom;
377 string draw_opt =
"e0";
378 for(
auto &h: bot_plots){
379 h.Draw(draw_opt.c_str());
380 draw_opt =
"e0 same";
382 bottom_background.Draw(
"2 same");
384 horizontal.Draw(
"same");
386 bottom->RedrawAxis();
387 bottom->RedrawAxis(
"g");
388 for(
auto &cut: bot_cuts) cut.Draw();
393 else top->SetLogy(
false);
395 string draw_opt =
"hist";
401 for(
auto &cut: cut_vals) cut.Draw();
403 vector<shared_ptr<TLegend> > legends =
GetLegends();
404 for(
auto &legend: legends){
409 top->RedrawAxis(
"g");
412 for(
auto &x: title_text){
418 TH1D *hdata = (
datas_.size() ? &(
datas_[0]->scaled_hist_) : 0);
420 TH1D *hbot = (bot_plots.size() ? &(bot_plots[0]) : 0);
421 if(hdata==0 || hmc==0 || hbot==0) cout<<
"Printing values not supported yet without Data, MC, or ratio"<<endl;
423 int digits = floor(log10(max(hdata->GetBinContent(hdata->GetMaximumBin()),
424 hmc->GetBinContent(hmc->GetMaximumBin())))+1.);
426 int edigits = floor(log10(sqrt(max(hdata->GetMaximum(), hmc->GetMaximum())))+1.)+2;
427 cout<<endl<<
"Printing values for "<<
Name()<<
". Data/MC = " 428 <<
RoundNumber(hdata->Integral(), 2,hmc->Integral()) <<endl;
429 for(
int bin=1; bin<=hdata->GetNbinsX(); bin++){
430 cout<<
"Bin "<<setw(5)<<hdata->GetBinLowEdge(bin)<<
","<<setw(5)<<hdata->GetBinLowEdge(bin+1)<<
": Data = ";
431 cout<<setw(digits)<<hdata->GetBinContent(bin)<<
" +- "<<setw(edigits)<<
RoundNumber(hdata->GetBinError(bin),1);
432 cout<<
", MC = "<<setw(digits+2)<<
RoundNumber(hmc->GetBinContent(bin),1)<<
" +- " 433 <<setw(edigits)<<
RoundNumber(hmc->GetBinError(bin),1);
435 cout<<
" -> Ratio = "<<setw(6)<<
RoundNumber(hbot->GetBinContent(bin),3)
436 <<
" +- "<<setw(5)<<
RoundNumber(hbot->GetBinError(bin),3);
442 if(subdir !=
"") mkdir((
"plots/"+subdir).c_str(), 0777);
443 string base_name = subdir !=
"" 444 ?
"plots/"+subdir+
"/"+
Name()
448 full->Print(full_name.c_str());
449 cout <<
"open " << full_name << endl;
455 set<const Process*> processes;
457 processes.insert(proc->process_.get());
460 processes.insert(proc->process_.get());
462 for(
const auto &proc:
datas_){
463 processes.insert(proc->process_.get());
470 for(
const auto &component: component_list){
471 if(component->process_.get() == process){
472 return component.get();
475 DBG(
"Could not find histogram for process "+process->
name_+
".");
518 const string &denominator){
544 hist->scaled_hist_ = hist->raw_hist_;
545 hist->scaled_hist_.SetName((
"bkg_"+hist->process_->name_+
"_"+
counter()).c_str());
548 hist->scaled_hist_ = hist->raw_hist_;
549 hist->scaled_hist_.SetName((
"sig_"+hist->process_->name_+
"_"+
counter()).c_str());
552 hist->scaled_hist_ = hist->raw_hist_;
553 hist->scaled_hist_.SetName((
"dat_"+hist->process_->name_+
"_"+
counter()).c_str());
563 case OverflowType::none:
567 case OverflowType::underflow:
571 case OverflowType::overflow:
575 case OverflowType::both:
619 hist->scaled_hist_ = hist->scaled_hist_ +
backgrounds_.front()->scaled_hist_;
634 double data_error, mc_error;
635 double data_norm =
datas_.front()->scaled_hist_.IntegralAndError(0, nbins+1, data_error,
"width");
636 double mc_norm =
backgrounds_.front()->scaled_hist_.IntegralAndError(0, nbins+1, mc_error,
"width");
638 mc_scale_error_ = hypot(data_norm*mc_error, mc_norm*data_error)/(mc_norm*mc_norm);
645 double this_integral = hist->scaled_hist_.IntegralAndError(0, nbins+1, dumb,
"width");
646 hist->scaled_hist_.Scale(this_integral == 0. ? 1. : data_norm/this_integral);
650 Normalize(hist->scaled_hist_, 100.,
true);
653 Normalize(hist->scaled_hist_, 100.,
true);
656 Normalize(hist->scaled_hist_, 100.,
true);
672 case YAxisType::linear:
673 bottom = the_min >= 0. ? 0. : the_min;
674 top = bottom+ratio*(the_max-bottom);
678 top = exp(
log(bottom)+ratio*(
log(the_max)-
log(bottom)));
683 hist->scaled_hist_.SetMinimum(bottom);
684 hist->scaled_hist_.SetMaximum(top);
687 hist->scaled_hist_.SetMinimum(bottom);
688 hist->scaled_hist_.SetMaximum(top);
691 hist->scaled_hist_.SetMinimum(bottom);
692 hist->scaled_hist_.SetMaximum(top);
729 case StackType::signal_overlay:
730 case StackType::signal_on_top:
731 case StackType::data_norm:
732 case StackType::lumi_shapes:
738 title <<
"Entries/(" << bin_width;
743 case StackType::shapes:
745 title <<
"% entries";
749 title <<
"% entries/(" << bin_width;
756 h.GetYaxis()->SetTitle(title.str().c_str());
765 TH1D &h =
bkg->scaled_hist_;
767 h.SetLineColor(h.GetFillColor());
785 unique_ptr<TPad> &top,
786 unique_ptr<TPad> &bottom)
const{
790 top.reset(
new TPad((
"top_pad_"+
counter()).c_str(),
"top_pad", 0., 0., 1., 1.));
791 bottom.reset(
new TPad((
"bottom_pad_"+
counter()).c_str(),
"bottom_pad", 0., 0., 1., 1.));
792 c->SetMargin(0., 0., 0., 0.);
794 c->SetFillStyle(4000);
796 top->SetFillStyle(4000);
797 bottom->SetTicks(1,1);
798 bottom->SetFillStyle(4000);
829 int digits = fabs(floor(log10(the_max))-1)+2;
830 digits = max(2, min(6, digits));
833 offset = 0.6+0.25*digits;
837 hist->scaled_hist_.SetTitleOffset(offset,
"y");
840 hist->scaled_hist_.SetTitleOffset(offset,
"y");
843 hist->scaled_hist_.SetTitleOffset(offset,
"y");
845 for(
auto &hist: bottom_plots){
846 if(
this_opt_.
Bottom() != BottomType::ratio) hist.SetTitleOffset(offset,
"y");
858 vector<shared_ptr<TLatex> > out;
865 out.push_back(make_shared<TLatex>(0.5*(left+right), 0.5*(bottom+top),
867 out.back()->SetNDC();
868 out.back()->SetTextAlign(22);
872 double max_width, max_height;
874 UInt_t width, height;
875 out.back()->GetBoundingBox(width, height);
876 while(width > max_width || height > max_height){
877 out.back()->SetTextSize(0.8*out.back()->GetTextSize());
878 out.back()->GetBoundingBox(width, height);
880 while(width < 0.5*max_width && height < 0.5*max_height){
881 out.back()->SetTextSize(1.25*out.back()->GetTextSize());
882 out.back()->GetBoundingBox(width, height);
888 case TitleType::preliminary: extra =
"Preliminary";
break;
889 case TitleType::simulation: extra =
"Simulation";
break;
890 case TitleType::supplementary: extra =
"Supplementary";
break;
891 case TitleType::data: extra =
"";
break;
892 case TitleType::info:
896 out.push_back(make_shared<TLatex>(left, 0.5*(bottom+top),
897 (
"#font[62]{CMS}#scale[0.76]{#font[52]{ "+extra+
"}}").c_str()));
898 out.back()->SetNDC();
899 out.back()->SetTextAlign(12);
903 oss <<
luminosity_ <<
" fb^{-1} (13 TeV)" << flush;
904 out.push_back(make_shared<TLatex>(right, 0.5*(bottom+top),
906 out.back()->SetNDC();
907 out.back()->SetTextAlign(32);
921 g = TGraphAsymmErrors(&h);
923 g = TGraphAsymmErrors(&(
backgrounds_.front()->scaled_hist_));
925 g.SetFillStyle(3002);
927 g.SetFillColor(
backgrounds_.front()->scaled_hist_.GetLineColor());
943 double bottom = y_min;
948 case YAxisType::linear: bottom = y_min >= 0. ? 0. : y_min;
break;
954 out.emplace_back(cut, bottom, cut, y_max);
955 out.back().SetNDC(
false);
956 out.back().SetLineStyle(2);
957 out.back().SetLineColor(kBlack);
958 out.back().SetLineWidth(3);
980 }
else if(
datas_.size() != 0){
981 denom =
datas_.front()->scaled_hist_;
983 denom =
signals_.front()->scaled_hist_;
985 ERROR(
"No histograms available to make bottom plot");
989 case StackType::signal_overlay:
990 case StackType::signal_on_top:
991 case StackType::data_norm:
992 stacked =
true;
break;
993 case StackType::lumi_shapes:
994 case StackType::shapes:
995 stacked =
false;
break;
1002 out.back().SetName((
"bot_plot_bkg_"+
backgrounds_.front()->process_->name_+
"_"+
counter()).c_str());
1005 out.push_back(h->scaled_hist_);
1006 out.back().SetName((
"bot_plot_bkg_"+h->process_->name_+
"_"+
counter()).c_str());
1009 for(
const auto &h:
datas_){
1010 out.push_back(h->scaled_hist_);
1011 out.back().SetName((
"bot_plot_data_"+h->process_->name_+
"_"+
counter()).c_str());
1015 out.push_back(h->scaled_hist_);
1016 out.back().SetName((
"bot_plot_sig_"+h->process_->name_+
"_"+
counter()).c_str());
1019 if(!out.size())
return vector<TH1D>();
1020 TH1D band = out.front();
1021 for(
size_t i = 0; (i+1) < out.size(); ++i){
1022 out.at(i) = out.at(i+1);
1025 out.back().SetFillStyle(3002);
1027 if (
backgrounds_.front()->scaled_hist_.GetLineColor()!=kBlack)
1028 out.back().SetFillColor(
backgrounds_.front()->scaled_hist_.GetLineColor());
1029 out.back().SetLineWidth(0);
1030 out.back().SetMarkerStyle(0);
1031 out.back().SetMarkerSize(0);
1032 out.back().SetName((
"bot_plot_band_"+
counter()).c_str());
1034 for(
int bin = 0; bin <= denom.GetNbinsX()+1; ++bin){
1035 denom.SetBinError(bin, 0.);
1039 case BottomType::ratio:
1044 case BottomType::diff:
1049 case BottomType::off:
1055 the_min = numeric_limits<double>::infinity();
1056 the_max = -numeric_limits<double>::infinity();
1059 for(
int bin = 1; bin <= h.GetNbinsX(); ++bin){
1060 double hi = h.GetBinContent(bin)+h.GetBinErrorUp(bin);
1061 double lo = h.GetBinContent(bin)-fabs(h.GetBinErrorLow(bin));
1062 if(hi>the_max) the_max = hi;
1063 if(lo<the_min) the_min = lo;
1073 if(datas_.size() != 0){
1074 if(num ==
"") num =
"Data";
1075 if(den ==
"") den =
"MC";
1077 if(num ==
"") num =
"MC";
1078 if(den ==
"") den =
backgrounds_.front()->process_->name_;
1080 h.GetYaxis()->CenterTitle();
1081 h.GetYaxis()->SetTitle((
"#frac{"+num+
"}{"+den+
"}").c_str());
1082 h.SetTitleSize(h.GetTitleSize(
"y")/1.25,
"y");
1083 h.SetTitleOffset(h.GetTitleOffset(
"y")/1.25,
"y");
1084 h.SetMinimum(the_min);
1085 h.SetMaximum(the_max);
1089 if(datas_.size() != 0) h.GetYaxis()->SetTitle(
"Data-MC");
1091 h.SetMinimum(the_min);
1092 h.SetMaximum(the_max);
1093 h.GetYaxis()->CenterTitle();
1110 case BottomType::ratio: y = 1.;
break;
1111 case BottomType::diff: y = 0.;
break;
1112 case BottomType::off: y = 0.;
break;
1118 TLine line(left, y, right, y);
1120 line.SetLineStyle(2);
1121 line.SetLineColor(kBlack);
1122 line.SetLineWidth(2);
1151 double the_max = -numeric_limits<double>::infinity();
1154 if(this_max > the_max && this_max < max_bound){
1159 double this_max = hist->GetMax(max_bound,
false);
1160 if(this_max > the_max && this_max < max_bound){
1164 for(
const auto &hist:
datas_){
1165 double this_max = hist->GetMax(max_bound,
true);
1166 if(this_max > the_max && this_max < max_bound){
1182 double the_min = numeric_limits<double>::infinity();
1185 if(this_min < the_min && this_min > min_bound){
1190 double this_min = hist->GetMin(min_bound,
false);
1191 if(this_min < the_min && this_min > min_bound){
1195 for(
const auto &hist:
datas_){
1196 double this_min = hist->GetMin(min_bound,
true);
1197 if(this_min < the_min && this_min > min_bound){
1223 vector<shared_ptr<TLegend> > legends(n_columns);
1224 for(
size_t i = 0; i < n_columns; ++i){
1225 double x = left+i*delta_x;
1227 legends.at(i)->SetFillStyle(0);
1228 legends.at(i)->SetBorderSize(0);
1233 size_t entries_added = 0;
1240 auto &leg = legends.at(
GetLegendIndex(entries_added, n_entries, legends.size()));
1241 ostringstream label;
1242 label << fixed << setprecision(1) <<
"L=" <<
luminosity_ <<
" fb^{-1}";
1246 auto entry = leg->AddEntry(&
blank_, label.str().c_str(),
"f");
1247 entry->SetFillStyle(0);
1248 entry->SetFillColor(kWhite);
1249 entry->SetLineWidth(0);
1250 entry->SetLineColor(kWhite);
1251 entry->SetMarkerStyle(0);
1252 entry->SetMarkerStyle(kWhite);
1271 const vector<unique_ptr<SingleHist1D> > &hists,
1272 const string &style,
1274 size_t &entries_added)
const{
1275 for(
auto h = hists.cbegin(); h != hists.cend(); ++h){
1276 size_t legend_index =
GetLegendIndex(entries_added, n_entries, legends.size());
1277 TLegend &legend = *legends.at(legend_index);
1278 string label = (*h)->process_->name_.c_str();
1284 case StackType::signal_overlay:
1285 case StackType::signal_on_top:
1286 case StackType::data_norm:
1294 case StackType::lumi_shapes:
1295 case StackType::shapes:
1302 double fudge_factor = 0.25;
1305 TLatex latex(0.5, 0.5, label.c_str());
1306 latex.SetTextSize(legend.GetTextSize());
1307 latex.SetTextFont(legend.GetTextFont());
1308 UInt_t width, height;
1309 latex.GetBoundingBox(width, height);
1310 while(width > max_width || height > max_height){
1311 latex.SetTextSize(0.95*latex.GetTextSize());
1312 for(
auto &leg: legends){
1313 leg->SetTextSize(0.95*leg->GetTextSize());
1315 latex.GetBoundingBox(width, height);
1318 legend.AddEntry(&((*h)->scaled_hist_), label.c_str(), style.c_str());
1332 double top_plot_height;
1350 TH1D hist = (*h)->scaled_hist_;
1356 hist = hist - (*(++h))->scaled_hist_;
1361 double raw_integral = hist.Integral(
"width");
1362 int nbins = hist.GetNbinsX();
1363 double left = hist.GetBinLowEdge(1);
1364 double right = hist.GetBinLowEdge(nbins+1);
1365 double width = (right-left)/nbins;
1366 return raw_integral/width;
1376 double Hist1D::GetMean(std::vector<std::unique_ptr<SingleHist1D> >::const_iterator h)
const{
1377 TH1D hist = (*h)->scaled_hist_;
1383 hist = hist - (*(++h))->scaled_hist_;
1386 return hist.GetMean();
1408 switch(process->
type_){
1416 ERROR(
"Did not understand process type "+to_string(static_cast<long>(process->
type_))+
".");
PlotOpt & TopMargin(double top)
double GetMean(std::vector< std::unique_ptr< SingleHist1D > >::const_iterator h) const
Get mean of histogram.
PlotOpt & Stack(PlotOptTypes::StackType stack_type)
PlotOpt & FileExtensions(const std::set< std::string > &file_extensions)
PlotOpt & LeftMargin(double left)
PlotOpt & YAxis(PlotOptTypes::YAxisType y_axis_type)
size_t GetLegendIndex(size_t entry, size_t n_entries, size_t n_columns)
Determines which legend column to put an entry in.
PlotOpt & LegendColumns(int columns)
TLine GetBottomHorizontal() const
Get horizontal line drawn at "agreement" value for bottom plots.
FigureComponent * GetComponent(const Process *process) final
void SetRanges() const
Set y-axis plotting range.
NamedFunc::VectorType cut_vector_
std::string units_
Units of Axis::var_.
void StripXLabels(TH1D &h)
Erases x-axis title and labels from plot.
bool DisplayLumiEntry() const
void Normalize(TH1D &h, double normalization, bool norm_per_avg_x)
void ScaleHistos() const
Scales histograms to required luminosity.
NamedFunc cut_
Event selection.
PlotOpt & LabelSize(double label_size)
PlotOpt & CanvasWidth(int width)
Axis xaxis_
Specification of content: plotted variable, binning, etc.
PlotOpt & AutoYAxis(bool auto_y_axis)
std::string CodeToPlainText(std::string code)
const std::string & Name() const
Get the string representation of this function.
double AvgBinWidth() const
Abstract base class for access to ntuple variables.
PlotOpt & CanvasHeight(int height)
std::string tag_
Filename tag to identify plot.
void ReplaceAll(std::string &str, const std::string &orig, const std::string &rep)
double GetYield(std::vector< std::unique_ptr< SingleHist1D > >::const_iterator h) const
Get integrated number of weighted entries in histogram.
Hist1D & Weight(const NamedFunc &weight)
ScalarType GetScalar(const Baby &b) const
Evaluate scalar function with b as argument.
const std::vector< std::unique_ptr< SingleHist1D > > & GetComponentList(const Process *process)
Combines a callable function taking a Baby and returning a scalar or vector with its string represent...
bool Contains(const std::string &str, const std::string &pat)
void RecordEvent(const Baby &baby) final
PlotOpt & NDivisionsBottom(int n_divisions)
std::vector< std::unique_ptr< SingleHist1D > > backgrounds_
Background components of the figure.
NamedFunc proc_and_hist_cut_
PlotOpt this_opt_
Plot style currently being drawn.
void DrawAll(const vector< unique_ptr< Hist1D::SingleHist1D > > &hists, string &draw_opt, bool reversed=false)
Draws all histograms to current canvas, updating draw_opt to contain "same" as needed.
void NormalizeHistos() const
Normalize histograms to data or 100%*(bin width) if needed for current style.
void Print(double luminosity, const std::string &subdir) final
Produce and save formatted plots at given luminosity.
std::string ratio_numerator_
Label for numerator in ratio plot.
double GetMin(double max_bound=0., bool include_error_bar=false, bool include_overflow=false) const
std::string title_
Axis title without units.
double mc_scale_
data/MC normalization
double GetMaxDraw(double max_bound=std::numeric_limits< double >::infinity()) const
Get highest drawn point below max_bound across all component histograms.
bool IsScalar() const
Check if scalar function is valid.
std::vector< PlotOpt > plot_options_
Styles with which to draw plot.
std::vector< std::unique_ptr< SingleHist1D > > datas_
Data components of the figure.
PlotOpt & Overflow(PlotOptTypes::OverflowType overflow_type)
Hist1D & RatioTitle(const std::string &numerator, const std::string &denominator)
double TrueLegendWidth(std::size_t num_entries) const
NamedFunc::VectorType val_vector_
void RefreshScaledHistos()
Generates stacked and scaled histograms from unstacked and unscaled ones.
std::string CodeToRootTex(std::string code)
std::vector< std::unique_ptr< SingleHist1D > > signals_
Signal components of the figure.
void StyleHisto(TH1D &h) const
Set label styles and title for a histogram.
std::vector< TH1D > GetBottomPlots(double &the_min, double &the_max) const
Get ratio or other plots drawn on the lower pad.
bool BackgroundsStacked() const
std::string TypeString() const
Container for a TH1D associated with a single Process.
NamedFunc::VectorType wgt_vector_
void ApplyStyles() const
Set label styles and title for all histograms.
void AddEntries(std::vector< std::shared_ptr< TLegend > > &legends, const std::vector< std::unique_ptr< SingleHist1D > > &hists, const std::string &style, std::size_t n_entries, std::size_t &entries_added) const
Distribute processes from list of histograms across legends.
double TrueLegendEntryHeight(std::size_t num_entries) const
std::vector< TLine > GetCutLines(double y_min, double y_max, bool adjust_bottom) const
Get vertical lines at cut values.
PlotOpt & XTitleOffset(double x_title_offset)
void GetTitleSize(double &width, double &height, bool in_pixels) const
Get width and height of title region.
std::set< const Process * > GetProcesses() const final
double mc_scale_error_
data/MC normalization uncertainty
void StackHistos() const
Stacks histograms if necessary for current plot style.
VectorType GetVector(const Baby &b) const
Evaluate vector function with b as argument.
PlotOpt & NDivisions(int n_divisions)
NamedFunc var_
Variable to be plotted.
TString RoundNumber(double num, int decimals, double denom=1.)
void FixYAxis(std::vector< TH1D > &bottom_plots) const
Adjust y-axis title offset based on y-axis range.
PlotOpt & Bottom(PlotOptTypes::BottomType bottom_type)
Axis & Bins(const std::vector< double > &bins)
void AdjustFillStyles() const
Make histograms a hollow line for unstacked styles.
PlotOpt & TitleSize(double title_size)
std::vector< std::shared_ptr< TLegend > > GetLegends()
Get list of legends emulating single legend with multiple columns.
void MergeOverflow() const
Moves overflow (underflow) contents into last (first) visible bin.
PlotOpt & RatioMaximum(double ratio_maximum)
std::vector< std::shared_ptr< TLatex > > GetTitleTexts() const
Get text to print at top of plot.
PlotOpt & LegendMarkerWidth(double width)
PlotOpt & UseCMYK(bool use_cmyk)
double GetMax(double max_bound=std::numeric_limits< double >::infinity(), bool include_error_bar=false, bool include_overflow=false) const
PlotOpt & ShowBackgroundError(bool show_background_error)
void AdjustDensityForBinWidth(TH1D &h)
TH1D scaled_hist_
Kludge. Mutable storage of scaled and stacked histogram.
PlotOpt & BottomMargin(double bottom)
bool IsVector() const
Check if vectorr function is valid.
A full 1D plot with stacked/overlayed histograms.
void GetPads(std::unique_ptr< TCanvas > &c, std::unique_ptr< TPad > &top, std::unique_ptr< TPad > &bottom) const
Generated canvas and pads for top and bottom plots.
double luminosity_
Luminosity currently being drawn.
class anonymous_namespace{hist1d.cpp}::Counter counter
PlotOpt & LegendDensity(double density)
std::string ratio_denominator_
Label for denominator in ratio plot.
TH1D raw_hist_
Histogram storing distribution before stacking and luminosity weighting.
std::string Title() const
PlotOpt & LegendPad(double pad)
PlotOpt & LogMinimum(double log_minimum)
PlotOpt & PrintVals(bool print_vals)
std::size_t Nbins() const
double TrueLegendHeight(std::size_t num_entries) const
std::set< double > cut_vals_
Values of HistoDef::var_ for which to plot a line.
std::string FixedDigits(double x, int n_digits)
Hist1D & Tag(const std::string &tag)
void StripTopPlotLabels() const
PlotOpt & Title(PlotOptTypes::TitleType title_type)
PlotOpt & RatioMinimum(double ratio_minimum)
NamedFunc weight_
Event weight.
void InitializeHistos() const
Sets all Hist1D::SingleHist1D::scaled_hist_ to corresponding Hist1D::SingleHist1D::raw_hist_.
bool HavePass(const NamedFunc::VectorType &v)
PlotOpt & RightMargin(double right)
TGraphAsymmErrors GetBackgroundError() const
Get uncertainty on total background.
double GetMinDraw(double min_bound=0.) const
Get lowest drawn point above min_bound across all component histograms.
PlotOpt & BottomHeight(double bottom_height)
double GetLegendRatio() const
Get factor by which to expand y-axis range to fit legend.
PlotOpt & YTitleOffset(double y_title_offset)