22 const std::shared_ptr<Process> &process,
23 const TH2D &hist_template):
25 clusterizer_(hist_template, 10000),
26 proc_and_hist_cut_(figure.cut_ && process->cut_),
36 bool have_vec =
false;
87 for(
size_t i = 0; i < min_vec_size; ++i){
97 const std::vector<std::shared_ptr<Process> > &processes,
98 const std::vector<PlotOpt> &plot_options):
116 TH2D empty(
"", (
";"+xtitle+
";"+ytitle).c_str(),
119 empty.SetStats(
false);
121 for(
const auto &process: processes){
122 TH2D hist_template = empty;
123 hist_template.SetFillColor(process->GetFillColor());
124 hist_template.SetFillStyle(process->GetFillStyle());
125 hist_template.SetLineColor(process->GetLineColor());
126 hist_template.SetLineStyle(process->GetLineStyle());
127 hist_template.SetLineWidth(process->GetLineWidth());
128 hist_template.SetMarkerColor(process->GetMarkerColor());
129 hist_template.SetMarkerStyle(process->GetMarkerStyle());
130 hist_template.SetMarkerSize(process->GetMarkerSize());
131 unique_ptr<SingleHist2D> hist(
new SingleHist2D(*
this, process, hist_template));
133 switch(process->type_){
135 datas_.push_back(move(hist));
150 const string &subdir){
166 case StackType::signal_overlay:
167 case StackType::signal_on_top:
168 case StackType::data_norm:
171 case StackType::lumi_shapes:
172 case StackType::shapes:
177 const Int_t NRGBs = 5;
178 const Int_t NCont = 999;
180 Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
181 Double_t red[NRGBs] = { 0.71, 0.50, 1.00, 1.00, 1.00 };
182 Double_t green[NRGBs] = { 0.80, 1.00, 1.00, 0.60, 0.50 };
183 Double_t blue[NRGBs] = { 0.95, 1.00, 0.50, 0.40, 0.50 };
184 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
185 gStyle->SetNumberContours(NCont);
190 c.SetFillStyle(4000);
198 vector<shared_ptr<TLatex> > labels =
GetLabels(bkg_is_hist);
202 legend.SetBorderSize(0);
203 legend.SetFillStyle(4000);
206 vector<TGraph> bkg_graphs;
207 if(bkg_is_hist) bkg_graphs.clear();
213 for(
size_t i = 0; i <
datas_.size(); ++i){
216 for(
size_t i = 0; i <
signals_.size(); ++i){
225 bkg_hist.Draw(
"axis");
227 bkg_hist.Draw(
"colz same");
229 for(
auto &g: bkg_graphs){
236 for(
auto &g: data_graphs){
239 for(
auto &g: sig_graphs){
242 for(
auto &l: labels){
246 bkg_hist.Draw(
"axis same");
247 if(subdir !=
"") mkdir((
"plots/"+subdir).c_str(), 0777);
248 string base_name = subdir !=
"" 249 ?
"plots/"+subdir+
"/"+
Name()
253 c.Print(full_name.c_str());
254 cout <<
"open " << full_name << endl;
260 string z_title = bkg_is_hist
272 h = TH2D(
"", title.c_str(),
276 h.SetTitle(title.c_str());
277 h.GetZaxis()->SetTitle(z_title.c_str());
280 h.SetLabelOffset(0.011);
290 bool lumi_weighted)
const{
291 vector<TGraph> graphs(components.size());
292 for(
size_t i = 0; i < components.size(); ++i){
293 graphs.at(i) = components.at(i)->clusterizer_.GetGraph(lumi_weighted ?
luminosity_ : 1.);
294 graphs.at(i).SetName(components.at(i)->process_->name_.c_str());
310 l.SetLineColor(kBlack);
319 vector<shared_ptr<TLatex> > labels;
322 case TitleType::preliminary: extra =
"Preliminary";
break;
323 case TitleType::simulation: extra =
"Simulation";
break;
324 case TitleType::supplementary: extra =
"Supplementary";
break;
325 case TitleType::data: extra =
"";
break;
326 case TitleType::info: extra =
"";
break;
330 labels.push_back(make_shared<TLatex>(left, top,
331 (
"#font[62]{CMS}#scale[0.76]{#font[52]{ "+extra+
"}}").c_str()));
332 labels.back()->SetNDC();
333 labels.back()->SetTextAlign(13);
337 oss <<
luminosity_ <<
" fb^{-1} (13 TeV)" << flush;
338 labels.push_back(make_shared<TLatex>(right, top,
340 labels.back()->SetNDC();
341 labels.back()->SetTextAlign(33);
376 case TitleType::info:
379 case TitleType::preliminary:
380 case TitleType::simulation:
381 case TitleType::supplementary:
382 case TitleType::data:
390 oss <<
" [#rho=" << rho <<
"]" << flush;
393 l.AddEntry(&g, oss.str().c_str(),
"p");
397 set<const Process*> processes;
399 processes.insert(proc->process_.get());
402 processes.insert(proc->process_.get());
404 for(
const auto &proc:
datas_){
405 processes.insert(proc->process_.get());
412 for(
const auto &component: component_list){
413 if(component->process_.get() == process){
414 return component.get();
417 DBG(
"Could not find histogram for process "+process->
name_+
".");
422 switch(process->
type_){
430 ERROR(
"Did not understand process type "+to_string(static_cast<long>(process->
type_))+
".");
PlotOpt & TopMargin(double top)
std::vector< PlotOpt > plot_options_
NamedFunc::VectorType cut_vector_
PlotOpt & Stack(PlotOptTypes::StackType stack_type)
PlotOpt & FileExtensions(const std::set< std::string > &file_extensions)
PlotOpt & LeftMargin(double left)
NamedFunc::VectorType xval_vector_
void Print(double luminosity, const std::string &subdir) override
std::string Title() const
std::string units_
Units of Axis::var_.
NamedFunc::VectorType wgt_vector_
std::vector< TGraph > GetGraphs(const std::vector< std::unique_ptr< SingleHist2D > > &components, bool lumi_weighted) const
PlotOpt & LabelSize(double label_size)
PlotOpt & CanvasWidth(int width)
std::vector< std::unique_ptr< SingleHist2D > > backgrounds_
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)
void AddEntry(TLegend &l, const SingleHist2D &h, const TGraph &g) const
ScalarType GetScalar(const Baby &b) const
Evaluate scalar function with b as argument.
NamedFunc::VectorType yval_vector_
Combines a callable function taking a Baby and returning a scalar or vector with its string represent...
const std::vector< std::unique_ptr< SingleHist2D > > & GetComponentList(const Process *process)
NamedFunc proc_and_hist_cut_
std::string title_
Axis title without units.
bool IsScalar() const
Check if scalar function is valid.
std::set< const Process * > GetProcesses() const override
TH2D GetHistogram(double luminosity) const
std::string TypeString() const
FigureComponent * GetComponent(const Process *process) override
PlotOpt & XTitleOffset(double x_title_offset)
PlotOpt & ZTitleOffset(double z_title_offset)
VectorType GetVector(const Baby &b) const
Evaluate vector function with b as argument.
NamedFunc var_
Variable to be plotted.
TH2D GetBkgHist(bool bkg_is_hist) const
std::vector< std::unique_ptr< SingleHist2D > > signals_
Axis & Bins(const std::vector< double > &bins)
PlotOpt & TitleSize(double title_size)
void AddPoint(float x, float y, float w)
std::vector< TLine > GetLines() const
Hist2D & Weight(const NamedFunc &weight)
void RecordEvent(const Baby &baby)
PlotOpt & UseCMYK(bool use_cmyk)
PlotOpt & BottomMargin(double bottom)
bool IsVector() const
Check if vectorr function is valid.
Clustering::Clusterizer clusterizer_
PlotOpt & LogMinimum(double log_minimum)
std::size_t Nbins() const
std::vector< std::shared_ptr< TLatex > > GetLabels(bool bkg_is_hist) const
std::set< double > cut_vals_
Values of HistoDef::var_ for which to plot a line.
void MakeOnePlot(const std::string &subdir)
PlotOpt & Title(PlotOptTypes::TitleType title_type)
std::vector< std::unique_ptr< SingleHist2D > > datas_
bool HavePass(const NamedFunc::VectorType &v)
PlotOpt & RightMargin(double right)
std::string ToString(const T &x)
Hist2D & Tag(const std::string &tag)
PlotOpt & YTitleOffset(double y_title_offset)