1 #include "DrawingToolsBase.hxx" 2 #include "WeightTools.hxx" 3 #include "HEPConstants.hxx" 4 #include <TVirtualHistPainter.h> 5 #include <THistPainter.h> 6 #include "SetT2KStyle.H" 16 int auto_colors[NAUTOCOLORS] = { 1, 2 ,3 ,4 , 6 ,7, 8, 9, 31, 32};
17 int auto_markers[NAUTOCOLORS] = { 20, 21, 22, 23, 33, 34, 29, 24, 25, 26};
18 int auto_styles[NAUTOCOLORS] = {3004, 3005, 3006, 3007, 3013, 3001, 3352, 3325, 3357, 3375};
19 const int NMAXTOYS=1000;
22 DrawingToolsBase::DrawingToolsBase(
const std::string& file, Int_t T2KstyleIndex){
33 gStyle->SetStatFormat(
"6.6g");
35 if (T2KstyleIndex==1) {
39 gStyle->SetFrameBorderMode(0);
40 gStyle->SetCanvasBorderMode(0);
41 gStyle->SetPadBorderMode(0);
42 gStyle->SetPadColor(0);
43 gStyle->SetCanvasColor(0);
44 gStyle->SetStatColor(0);
45 gStyle->SetLegendBorderSize(1);
48 gStyle->SetPaperSize(20,26);
49 gStyle->SetPadTopMargin(0.05);
50 gStyle->SetPadRightMargin(0.05);
51 gStyle->SetPadBottomMargin(0.16);
52 gStyle->SetPadLeftMargin(0.13);
55 gStyle->SetTextFont(132);
56 gStyle->SetTextSize(0.08);
57 gStyle->SetLabelFont(132,
"x");
58 gStyle->SetLabelFont(132,
"y");
59 gStyle->SetLabelFont(132,
"z");
60 gStyle->SetLabelSize(0.05,
"x");
61 gStyle->SetTitleSize(0.06,
"x");
62 gStyle->SetLabelSize(0.05,
"y");
63 gStyle->SetTitleSize(0.06,
"y");
64 gStyle->SetLabelSize(0.05,
"z");
65 gStyle->SetTitleSize(0.06,
"z");
66 gStyle->SetLabelFont(132,
"t");
67 gStyle->SetTitleFont(132,
"x");
68 gStyle->SetTitleFont(132,
"y");
69 gStyle->SetTitleFont(132,
"z");
70 gStyle->SetTitleFont(132,
"t");
71 gStyle->SetStatFont(132);
72 gStyle->SetTitleFillColor(0);
73 gStyle->SetTitleX(0.25);
74 gStyle->SetTitleFontSize(0.08);
75 gStyle->SetTitleFont(132,
"pad");
82 gStyle->SetPadTickX(1);
83 gStyle->SetPadTickY(1);
88 gStyle->SetPalette(1,0);
89 const Int_t NRGBs = 5;
90 const Int_t NCont = 255;
92 Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
93 Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
94 Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
95 Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
96 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
97 gStyle->SetNumberContours(NCont);
99 else if (T2KstyleIndex>1) {
100 if (T2KstyleIndex>4){std::cout <<
"DrawingTools. Not existing style !!!!" << std::endl;}
102 TString localStyleName =
"T2K";
107 Int_t localWhichStyle = T2KstyleIndex-1;
109 TStyle* t2kstyle = SetT2KStyle(localWhichStyle, localStyleName);
110 gROOT->SetStyle(t2kstyle->GetName());
120 SetSmallLegendSize(0.15,0.1);
126 _statPos[0] = 1 - gStyle->GetPadRightMargin();
127 _statPos[1] = 1.04 - gStyle->GetPadTopMargin();
128 SetStatPos(_statPos[0],_statPos[1]);
131 _stat_option = 1000000;
134 _stack_fill_style = 3001;
135 _different_fill_styles =
false;
146 _data_color = kBlack;
147 _allmc_color = kBlack;
148 _data_label =
"Data";
149 _allmc_label =
"MC all";
150 _allmcstat_label =
"MC all (stat)";
151 _allmcsyst_label =
"MC all (syst)";
167 _mcstaterror_color = 6;
189 for (
int i=0;i<NMAXAUTOCOLORS;i++) {
191 _auto_colors[i] = auto_colors[i];
192 _auto_markers[i] = auto_markers[i];
195 _auto_colors[i] = _line_color;
196 _auto_markers[i] = _marker_style;
211 for (
unsigned int i=0;i<_saved_histos.size();i++)
212 delete _saved_histos[i];
214 _saved_histos.clear();
217 for (
unsigned int i=0;i<_saved_histos2D.size();i++)
218 delete _saved_histos2D[i];
220 _saved_histos2D.clear();
223 for (
unsigned int i=0;i<_saved_graphs.size();i++)
224 delete _saved_graphs[i];
226 _saved_graphs.clear();
229 for (
unsigned int i=0;i<_saved_histoStacks.size();i++)
230 delete _saved_histoStacks[i];
232 _saved_histoStacks.clear();
234 for (
unsigned int i=0;i<_cut_lines.size();i++)
235 delete _cut_lines[i];
240 for (
unsigned int i=0;i<_legends.size();i++)
257 ReadSystematics(file);
262 _configTree_tools.Initialize(file);
286 if (posX != -999) _legendPos[0] = posX;
287 if (posY != -999) _legendPos[1] = posY;
288 SetLegendParam(_legendPos[0],_legendPos[1],_legendPos[0]+_legendSize[0], _legendPos[1]+_legendSize[1]);
295 if (pos.find(
"r") != std::string::npos)
296 SetLegendPos(1-gStyle->GetPadRightMargin()-_legendSize[0],_legendPos[1]);
297 else if (pos.find(
"l") != std::string::npos)
298 SetLegendPos(gStyle->GetPadLeftMargin() + 0.02,_legendPos[1]);
299 else if (pos.find(
"c") != std::string::npos)
300 SetLegendPos((1-gStyle->GetPadRightMargin()+gStyle->GetPadLeftMargin()-_legendSize[0])/2.,_legendPos[1]);
302 if (pos.find(
"t") != std::string::npos)
303 SetLegendPos(_legendPos[0],(1-gStyle->GetPadTopMargin()-_legendSize[1]));
304 else if (pos.find(
"b") != std::string::npos)
305 SetLegendPos(_legendPos[0],gStyle->GetPadBottomMargin()+0.02);
315 if (w != -999) _legendSize[0] = w;
316 if (h != -999) _legendSize[1] = h;
321 SetLegendParam(_legendPos[0],_legendPos[1],_legendPos[0]+_legendSize[0], _legendPos[1]+_legendSize[1]);
325 void DrawingToolsBase::SetStatPos(
double x,
double y){
327 if (x != -999) _statPos[0]=x;
328 if (y != -999) _statPos[1]=y;
329 gStyle->SetStatX(_statPos[0]);
330 gStyle->SetStatY(_statPos[1]);
334 void DrawingToolsBase::SetEffDivideParams(
const std::string& params) {
336 if(params.find_first_not_of(
" ") == std::string::npos){
337 std::cout <<
" DrawingToolsBase::SetEffDivideParams() no options provided --> setting default " << std::endl;
355 TH1*
DrawingToolsBase::Draw(TTree* tree,
const std::string& var,
int nx,
double xmin,
double xmax,
const std::string& categ,
356 const std::string& cut,
const std::string& root_opt,
const std::string& opt,
double norm,
bool scale_errors){
360 double xbins[NMAXBINS];
361 return Draw(tree, var, nx,
GetVariableBins(nx,xmin,xmax,xbins), categ, cut, root_opt, opt, norm, scale_errors);
366 const std::string& cut,
const std::string& root_opt,
const std::string& opt,
double norm,
bool scale_errors){
372 return Draw(tree,var,nx,xbins,ny,ybins,categ,cut, root_opt, opt,norm,scale_errors);
376 TH1*
DrawingToolsBase::Draw(TTree* tree,
const std::string& var,
int nx,
double xmin,
double xmax,
int ny,
double ymin,
double ymax,
377 const std::string& categ,
const std::string& cut,
const std::string& root_opt,
const std::string& opt,
double norm,
bool scale_errors){
381 double xbins[NMAXBINS];
382 double ybins[NMAXBINS];
383 return Draw(tree, var, nx,
GetVariableBins(nx,xmin,xmax,xbins), ny,
GetVariableBins(ny,ymin,ymax,ybins), categ, cut, root_opt, opt, norm, scale_errors);
387 void DrawingToolsBase::Draw(TTree* tree,
const std::string& var,
int nx,
double xmin,
double xmax,
int ny,
double ymin,
double ymax,
388 const std::string& idVar, std::vector<int> idSel, std::vector<std::string> idName, std::vector<int> idColor,
389 const std::string& cut,
const std::string& root_opt,
const std::string& opt,
double norm,
bool scale_errors){
391 double xbins[NMAXBINS];
392 double ybins[NMAXBINS];
393 Draw(tree, var, nx,
GetVariableBins(nx,xmin,xmax,xbins), ny,
GetVariableBins(ny,ymin,ymax,ybins), idVar,idSel,idName,idColor,cut,root_opt,opt,norm,scale_errors);
397 void DrawingToolsBase::Project(
HistoStack* hs1,
HistoStack* hs2, TTree* tree1, TTree* tree2,
const std::string& var,
int nx,
double* xbins,
int ny,
double* ybins,
const std::string& categ,
398 const std::string& cut,
const std::string& root_opt,
const std::string& opt,
double norm2,
bool scale_errors){
401 ProjectNew(hs1,hs2,tree1,tree2,var,nx,xbins,ny,ybins,categ,cut,cut,root_opt,opt,norm2,scale_errors);
405 void DrawingToolsBase::ProjectNew(
HistoStack* hs1,
HistoStack* hs2, TTree* tree1, TTree* tree2,
const std::string& var,
int nx,
double* xbins,
int ny,
double* ybins,
const std::string& categ,
406 const std::string& cut1,
const std::string& cut2,
const std::string& root_opt,
const std::string& opt,
double norm2,
bool scale_errors){
415 Project(hs1,
"sample1", tree1,var,nx,xbins,ny,ybins,
"all",cut1,root_opt,opt+
" NOAREA",norm1,scale_errors);
416 Project(hs2,
"sample2", tree2,var,nx,xbins,ny,ybins,categ,cut2,root_opt,opt+
" NOAREA",norm2,scale_errors);
425 void DrawingToolsBase::Project(
HistoStack* hs,
const std::string& sample_name, TTree* tree,
const std::string& var,
int nx,
double* xbins,
int ny,
double* ybins,
const std::string& categ,
426 const std::string& cut,
const std::string& root_opt,
const std::string& opt,
double norm,
bool scale_errors){
445 TH1_h* hall = GetHisto(hs, tree,
GetUniqueName(sample_name+
"_all"),var,nx,xbins,cut,root_opt,uopt,hsyst,norm,scale_errors);
447 _saved_histos.pop_back();
451 TH2_h* hall = GetHisto(tree,
GetUniqueName(sample_name+
"_all"),var,nx,xbins,ny,ybins,cut, root_opt, uopt,norm,scale_errors);
454 _saved_histos.pop_back();
462 std::string categ2 = categ;
463 std::string categ_withoutPur = categ;
470 size_t pos = categ.find(
"_withPurities");
471 if (pos != std::string::npos) categ_withoutPur = categ.substr(0,pos);
472 else categ_withoutPur = categ;
476 std::string cut_range =
AddRangeCut(var,nx,xbins,ny,ybins,cut,uopt);
478 categ2 +=
"_withPurities";
483 std::vector<TrackTypeDefinition>::iterator it;
485 for (it=cat().GetCategoryTypes(categ2).begin();it!=cat().
GetCategoryTypes(categ2).end();it++, i++){
486 std::string type = it->_name;
488 int color = it->_color;
490 if(!_draw_2p2h && type==
"2p2h")
continue;
492 std::string cut2 = categ_withoutPur +
"==" + code;
494 if (cut!=
"") cut2 = cut +
" && " + cut2;
497 TH1_h* ht1 = GetHisto(hs, tree,
GetUniqueName(sample_name+
"_"+type),var,nx,xbins,cut2, root_opt,uopt+
" CAT",norm,scale_errors);
499 if(!
drawUtils::CheckOption(uopt,
"SHOWSAND") && ht1->Integral() == 0. && type.find(NAMESAND) !=std::string::npos)
continue;
500 if(!
drawUtils::CheckOption(uopt,
"SHOWNOTRUTH") && ht1->Integral() == 0. && type.find(NAMENOTRUTH)!=std::string::npos)
continue;
503 if (hs->GetCurrentSystGroup()==
"default")
505 _saved_histos.pop_back();
509 TH2_h* ht2 = GetHisto(tree,
GetUniqueName(sample_name+
"_"+type),var,nx,xbins,ny,ybins,cut2,root_opt,uopt+
" CAT",norm,scale_errors);
511 if (uroot_opt.find(
"BOX") != std::string::npos)
512 hs->
Add(ht2,0,color,type.c_str());
514 hs->
Add(ht2,color,color,type.c_str());
515 _saved_histos.pop_back();
526 TH1*
DrawingToolsBase::Draw(TTree* tree,
const std::string& var,
int nx,
double* xbins,
int ny,
double* ybins,
const std::string& categ,
527 const std::string& cut,
const std::string& root_opt,
const std::string& opt,
double norm2,
bool scale_errors){
538 _saved_histoStacks.push_back(hs);
543 Project(hs,
"", tree,var,nx,xbins,ny,ybins,categ,cut,root_opt,opt,norm2,scale_errors);
546 DrawHistoStack(hs,categ,root_opt, uopt);
556 void DrawingToolsBase::Project(
HistoStack* hs, TTree* tree,
const std::string& var,
int nx,
double* xbins,
int ny,
double* ybins,
557 const std::string& idVar, std::vector<int> idSel, std::vector<std::string> idName, std::vector<int> idColor,
558 const std::string& cut,
const std::string& root_opt,
const std::string& opt,
double norm,
bool scale_errors) {
566 TH1_h* hall = GetHisto(tree,
"all", var, nx, xbins, cut, root_opt, uopt, norm, scale_errors);
570 TH2_h* hall = GetHisto(tree,
"all", var, nx, xbins, ny, ybins, cut, root_opt, uopt, norm, scale_errors);
575 for (
unsigned int i = 0; i < idSel.size(); i++) {
576 std::string type = idName[i];
577 std::stringstream ss;
579 int color = idColor[i];
581 if(!_draw_2p2h && type==
"2p2h")
continue;
583 std::string cut2 = idVar +
"==" + ss.str();
585 cut2 = cut +
" && " + cut2;
588 TH1_h* ht1 = GetHisto(tree, type, var, nx, xbins, cut2, root_opt, uopt +
" CAT", norm, scale_errors);
599 TH2_h* ht2 = GetHisto(tree, type, var, nx, xbins, ny, ybins, cut2, root_opt, uopt +
" CAT", norm, scale_errors);
601 if (uroot_opt.find(
"BOX") != std::string::npos)
602 hs->
Add(ht2, 0, color);
604 hs->
Add(ht2, color, color);
612 void DrawingToolsBase::Draw(TTree* tree,
const std::string& var,
int nx,
double* xbins,
int ny,
double* ybins,
613 const std::string& idVar, std::vector<int> idSel, std::vector<std::string> idName, std::vector<int> idColor,
614 const std::string& cut,
const std::string& root_opt,
const std::string& opt,
double norm2,
bool scale_errors){
633 _saved_histoStacks.push_back(hs);
635 Project(hs, tree, var, nx, xbins, ny, ybins, idVar, idSel, idName, idColor, cut, root_opt, opt, norm2, scale_errors);
638 DrawHistoStack(hs,
"",root_opt, uopt,
"",2);
642 _legends.back()->Draw();
650 void DrawingToolsBase::Draw(TTree* tree_mc, TTree* tree_data,
const std::string& var,
int nx,
double* xbins,
int ny,
double* ybins,
651 const std::string& idVar, std::vector<int> idSel, std::vector<std::string> idName, std::vector<int> idColor,
652 const std::string& cut,
const std::string& root_opt,
const std::string& opt,
double norm,
bool scale_errors){
661 TVirtualPad* curPad = gPad;
669 gPad->SetBottomMargin(0);
670 if(!_MainPad) _MainPad =
new TPad(
"MainPad",
"MainPad",
671 curPad->GetAbsXlowNDC(),
672 curPad->GetAbsYlowNDC()+(curPad->GetAbsHNDC()*0.3),
673 curPad->GetAbsXlowNDC()+curPad->GetAbsWNDC(),
674 curPad->GetAbsYlowNDC()+curPad->GetAbsHNDC());
675 _MainPad->SetLogy(_logY);
676 _MainPad->SetBottomMargin(0);
677 gStyle->SetOptStat(_stat_option);
685 double norm_data = 1.;
687 double entries_mc =
GetEntries(tree_mc,cut,var,opt);
688 double entries_data =
GetEntries(tree_data,cut,var,opt);
690 double area = entries_data;
694 if(entries_mc > 0.) norm = area/entries_mc;
695 if(entries_data > 0.) norm_data = area/entries_data;
707 TH1_h* hdata = GetHisto(tree_data,
"data",var,nx,xbins,cut, root_opt, uopt,norm_data,scale_errors);
710 std::string leg =
"data";
721 _saved_histoStacks.push_back(hs);
729 TH1_h* hall = GetHisto(tree_mc,
"mcall",var,nx,xbins,cut, root_opt, uopt,norm,scale_errors);
735 TH2_h* hall = GetHisto(tree_mc,
"mcall",var,nx,xbins,ny,ybins,cut, root_opt, uopt,norm,scale_errors);
740 for (
unsigned int i = 0; i < idSel.size();i++ ) {
741 std::string type = idName[i];
742 std::stringstream ss;
744 int color = idColor[i];
746 if(!_draw_2p2h && type==
"2p2h")
continue;
748 std::string cut2 = idVar+
"=="+ss.str();
749 if (cut!=
"") cut2 = cut+
" && "+cut2;
753 TH1_h* ht1 = GetHisto(tree_mc,type,var,nx,xbins,cut2, root_opt,uopt+
" CAT",norm,scale_errors);
769 TH2_h* ht2 = GetHisto(tree_mc,type,var,nx,xbins,ny,ybins,cut2,root_opt,uopt+
" CAT",norm,scale_errors);
772 if (uroot_opt.find(
"BOX") != std::string::npos)
773 hs->Add(ht2,0,color);
775 hs->Add(ht2,color,color);
783 if(ny==0 && ( hdata->GetMaximum() + sqrt(hdata->GetBinError(hdata->GetMaximumBin()))) > hs->GetTotal1D()->GetMaximum()) {
784 DrawHisto(hdata, 1, 1, 0, 0, root_opt+
"error",
"ST NOSTAT ISDATA",
"", 2);
785 DrawHistoStack(hs,
"",root_opt+
" same", uopt,
"",2);
786 DrawHisto(hdata, 1, 1, 0, 0, root_opt+
" same error",
"ST NOSTAT ISDATA",
"", 2);
789 DrawHistoStack(hs,
"",root_opt, uopt,
"",2);
790 DrawHisto(hdata, 1, 1, 0, 0, root_opt+
" same error",
"ST NOSTAT ISDATA",
"", 2);
795 _legends.back()->Draw();
802 if(!_RatioPad) _RatioPad =
new TPad(
"RatioPad",
"RatioPad",
803 curPad->GetAbsXlowNDC(),
804 curPad->GetAbsYlowNDC(),
805 curPad->GetAbsXlowNDC()+curPad->GetAbsWNDC(),
806 curPad->GetAbsYlowNDC()+(curPad->GetAbsHNDC()*0.3));
809 TH1F* ratio = (TH1F*)hdata->Clone();
810 ratio->Divide(hs->GetTotal1D());
813 ratio->GetYaxis()->SetNdivisions(010,
true);
814 ratio->GetXaxis()->SetLabelSize(ratio->GetXaxis()->GetLabelSize()/0.3);
815 ratio->GetYaxis()->SetLabelSize(ratio->GetYaxis()->GetLabelSize()/0.3);
816 ratio->GetYaxis()->SetTitle(
"Ratio");
817 ratio->GetXaxis()->SetTitleSize(ratio->GetXaxis()->GetTitleSize()/0.3);
818 ratio->GetYaxis()->SetTitleSize(ratio->GetYaxis()->GetTitleSize()/0.3);
819 DrawHisto(ratio, _line_color, _line_width, 0, 0, root_opt+
" same error",
"ST NOSTAT ISDATA DONTADDLEGENTRY",
"", 2);
820 ratio->SetMaximum(_relativeMaxY*ratio->GetBinContent(ratio->GetMaximumBin()));
821 ratio->SetMinimum( ratio->GetBinContent(ratio->GetMinimumBin())/_relativeMaxY);
822 _RatioPad->SetLogy(0);
823 _RatioPad->SetTopMargin(0);
824 _RatioPad->SetBottomMargin(0.3);
825 _RatioPad->SetGridx();
826 _RatioPad->SetGridy();
832 gStyle->SetOptStat(_stat_option);
834 if(_RatioPad){_RatioPad->Update();_RatioPad->Draw();}
835 if(_MainPad) {_MainPad ->Update();_MainPad ->Draw();}
843 void DrawingToolsBase::Draw(TTree* tree_mc, TTree* tree_data,
const std::string& var,
int nx,
double xmin,
double xmax,
int ny,
double ymin,
double ymax,
844 const std::string& idVar, std::vector<int> idSel, std::vector<std::string> idName, std::vector<int> idColor,
845 const std::string& cut,
const std::string& root_opt,
const std::string& opt,
double norm,
bool scale_errors){
848 double xbins[NMAXBINS];
849 double ybins[NMAXBINS];
851 Draw(tree_mc, tree_data, var, nx,
GetVariableBins(nx,xmin,xmax,xbins), ny,
GetVariableBins(ny,ymin,ymax,ybins), idVar,idSel,idName,idColor,cut,root_opt,opt,norm,scale_errors);
856 const std::string& cut1,
const std::string& cut2,
const std::string& root_opt,
const std::string& opt) {
860 return GetEff(tree, var, xmin, xmax, errlow, errhigh, cut1, cut2, root_opt, opt);
865 const std::string& cut1,
const std::string& cut2,
const std::string& root_opt,
const std::string& opt) {
872 double xbins[2] = {xmin, xmax};
875 TH1_h* h1 = GetHisto(tree,
"eff1",var,nbins,xbins,(cut1+
" && "+cut2), root_opt, opt,1);
878 TH1_h* h2 = GetHisto(tree,
"eff2",var,nbins,xbins,cut2, root_opt, opt,1);
882 TGraphAsymmErrors* eff =
new TGraphAsymmErrors(h1);
883 _saved_graphs.push_back(eff);
886 if (eff->GetN() != 1) {
887 std::cout <<
"Error computing efficiency" << std::endl;
891 errlow = eff->GetEYlow()[0];
892 errhigh = eff->GetEYhigh()[0];
894 return eff->GetY()[0];
899 void DrawingToolsBase::DrawEff(TTree* tree,
const std::string& var,
int nx,
double xmin,
double xmax,
900 const std::string& cut1,
const std::string& cut2,
const std::string& root_opt,
const std::string& opt,
const std::string& leg){
904 double xbins[NMAXBINS];
905 DrawEff(tree, var, nx,
GetVariableBins(nx,xmin,xmax,xbins), cut1, cut2, root_opt, opt, leg);
909 void DrawingToolsBase::DrawEff(TTree* tree,
const std::string& var,
int nx,
double* xbins,
910 const std::string& cut1,
const std::string& cut2,
const std::string& root_opt,
const std::string& opt,
const std::string& leg){
923 _saved_histoStacks.push_back(hs1);
924 _saved_histoStacks.push_back(hs2);
930 double *ybins = NULL;
931 ProjectNew(hs1, hs2, tree,tree,var,nx,xbins,ny,ybins,
"all",(cut1+
" && "+cut2),cut2,root_opt,opt,1.,
true);
943 TGraphAsymmErrors* eff =
new TGraphAsymmErrors(h1);
944 _saved_graphs.push_back(eff);
948 FillGraphErrors(hs1, hs2, eff, uopt);
951 DrawGraph(eff,nx,xbins,uroot_opt,uopt,leg);
957 const std::string& cut1,
const std::string& cut2,
const std::string& root_opt,
const std::string& opt,
const std::string& leg){
960 double xbins[NMAXBINS];
961 DrawDoubleEff(tree1, tree2, var, nx,
GetVariableBins(nx,xmin,xmax,xbins), cut1, cut2, root_opt, opt, leg);
966 const std::string& cut1,
const std::string& cut2,
const std::string& root_opt,
const std::string& opt,
const std::string& leg){
981 _saved_histoStacks.push_back(hs1_num);
982 _saved_histoStacks.push_back(hs1_den);
983 _saved_histoStacks.push_back(hs2_num);
984 _saved_histoStacks.push_back(hs2_den);
990 double *ybins = NULL;
991 ProjectNew(hs1_num, hs1_den, tree1,tree1,var,nx,xbins,ny,ybins,
"all",(cut1+
" && "+cut2),cut2,root_opt,opt,1.,
true);
992 ProjectNew(hs2_num, hs2_den, tree2,tree2,var,nx,xbins,ny,ybins,
"all",(cut1+
" && "+cut2),cut2,root_opt,opt,1.,
true);
1014 TGraphAsymmErrors* eff1 =
new TGraphAsymmErrors(h1d);
1015 _saved_graphs.push_back(eff1);
1019 TGraphAsymmErrors* eff2 =
new TGraphAsymmErrors(h2d);
1020 _saved_graphs.push_back(eff2);
1024 FillGraphErrors(hs1_num, hs1_den, eff1, uopt);
1027 FillGraphErrors(hs2_num, hs2_den, eff2, uopt);
1030 TGraphAsymmErrors* ratio =
new TGraphAsymmErrors(h2d);
1031 _saved_graphs.push_back(ratio);
1033 for (
int i=0;i<nx;i++){
1035 eff1->GetPoint(i,x1,y1);
1036 eff2->GetPoint(i,x2,y2);
1037 double e1 = eff1->GetErrorY(i);
1038 double e2l = eff2->GetErrorYlow(i);
1039 double e2h = eff2->GetErrorYhigh(i);
1040 double exl = eff2->GetErrorXlow(i);
1041 double exh = eff2->GetErrorXhigh(i);
1044 double erl = sqrt(e1*e1/(y2*y2)+pow(y1/(y2*y2)*e2l,2));
1045 double erh = sqrt(e1*e1/(y2*y2)+pow(y1/(y2*y2)*e2h,2));
1047 ratio->SetPoint(i,x1,r);
1048 ratio->SetPointError(i,exl,exh,erl,erh);
1052 DrawGraph(ratio,nx,xbins,uroot_opt,uopt,leg,1.3);
1057 const std::string& uroot_opt,
const std::string& uopt,
const std::string& leg,
double ymax){
1061 if (slevel==
"0" && leg!=
"")
1066 DumpGraph(graph,nbins,uopt);
1072 graph->GetXaxis()->SetRangeUser(xbins[0],xbins[nbins]);
1073 graph->GetYaxis()->SetRangeUser(0,ymax);
1074 graph->GetYaxis()->SetNdivisions(520);
1076 graph->SetTitle(_title.c_str());
1077 graph->SetLineColor(_auto_colors[_same_level]);
1078 graph->SetMarkerColor(_auto_colors[_same_level]);
1079 graph->SetMarkerStyle(_auto_markers[_same_level]);
1082 gStyle->SetOptStat(0);
1085 if (uroot_opt.find(
"SAME")!=std::string::npos)
1086 graph->Draw((
"P"+uroot_opt).c_str());
1088 graph->Draw((
"AP"+uroot_opt).c_str());
1091 graph->GetXaxis()->SetTitle(_titleX.c_str());
1092 graph->GetYaxis()->SetTitle(_titleY.c_str());
1097 _legends.back()->Draw();
1104 void DrawingToolsBase::DumpGraph(TGraphAsymmErrors* graph,
int nbins,
const std::string& uopt){
1109 std::cout <<
"---------- Dumping graph -----------" << std::endl;
1111 for (
int i=0;i<nbins;i++){
1113 graph->GetPoint(i,x,y);
1114 double el = graph->GetErrorYlow(i);
1115 double eh = graph->GetErrorYhigh(i);
1117 std::cout << i <<
": x = " << x <<
", y = " << y <<
" +- " << eh <<
" " << el << std::endl;
1127 std::cout <<
"---------- Dumping histo -----------" << std::endl;
1129 for (
int i=0;i<histo->GetNbinsX();i++){
1130 double x = histo->GetBinCenter(i+1);
1131 double y = histo->GetBinContent(i+1);
1132 double e = histo->GetBinError(i+1);
1134 std::cout << i <<
": x = " << x <<
", y = " << y <<
" +- " << e << std::endl;
1145 std::cout <<
" --------------------------------------------------------" << std::endl;
1146 std::cout <<
" Statistics" << std::endl;
1147 std::cout <<
" entries = " << histo->GetEntries() <<
" (not weighted; under/overflow included) " << std::endl;
1148 std::cout <<
" integral = " << histo->Integral() << std::endl;
1149 std::cout <<
" underflow = " << histo->GetBinContent(0) << std::endl;
1150 std::cout <<
" overflow = " << histo->GetBinContent(histo->GetNbinsX()+1) << std::endl;
1151 std::cout <<
" --------------------------------------------------------" << std::endl;
1152 std::cout << std::endl;
1157 double norm,
double rel_syst,
const std::string& root_opt,
const std::string& opt,
const std::string& leg){
1162 double xbins[NMAXBINS];
1163 DrawSignificance(tree,var, nx,
GetVariableBins(nx,xmin,xmax,xbins), cut1, cut2, norm, rel_syst, root_opt, opt, leg);
1168 double norm,
double rel_syst,
const std::string& root_opt,
const std::string& opt,
const std::string& leg){
1180 if (slevel==
"0" && leg!=
"")
1184 TH1_h* h1 = GetHisto(tree,
"sig1",var,nbins,xbins,(cut1+
" && "+cut2), root_opt, uopt,norm);
1186 TH1_h* h2 = GetHisto(tree,
"sig2",var,nbins,xbins,cut2, root_opt, uopt,norm);
1189 TH1_h* sig =
new TH1_h(*h1);
1191 _saved_histos.push_back(sig);
1194 for (
int ibin=0;ibin<sig->GetXaxis()->GetNbins();ibin++){
1195 double total = h2->GetBinContent(ibin+1);
1198 double pur = h1->GetBinContent(ibin+1)/total;
1199 s = pur/(sqrt(1/(total*norm) + pow(rel_syst*(1-pur),2)));
1201 sig->SetBinContent(ibin+1,s);
1202 sig->SetBinError(ibin+1,0);
1206 sig->GetXaxis()->SetTitle(_titleX.c_str());
1207 sig->GetYaxis()->SetTitle(
"significance");
1208 sig->SetTitle(leg.c_str());
1211 DrawHisto(sig, _auto_colors[_same_level], _line_width, 1, _fill_style, root_opt, uopt+
" NOSTAT",
"LE1P");
1215 _legends.back()->Draw();
1223 const std::string& cut1,
const std::string& cut2,
const std::string& root_opt,
const std::string& opt,
const std::string& leg){
1227 double xbins[NMAXBINS];
1228 DrawRatio(tree, var, nx,
GetVariableBins(nx,xmin,xmax,xbins), cut1, cut2, root_opt, opt, leg);
1233 const std::string& cut1,
const std::string& cut2,
const std::string& root_opt,
const std::string& opt,
const std::string& leg){
1237 DrawRatioTwoCuts(tree, tree, var, nx, xbins, cut1, cut2, root_opt, opt, leg, 1.);
1242 const std::string& categ,
const std::string& cut,
const std::string& root_opt,
const std::string& opt,
double norm,
bool scale_errors){
1246 double xbins[NMAXBINS];
1247 Draw(tree1,tree2,var,nx,
GetVariableBins(nx,xmin,xmax,xbins),categ,cut,root_opt,opt,norm,scale_errors);
1252 const std::string& categ,
const std::string& cut,
const std::string& root_opt,
const std::string& opt,
double norm,
bool scale_errors){
1258 Draw(tree1,tree2,var,nx,xbins,ny,ybins,categ,cut,root_opt,opt,norm,scale_errors);
1262 void DrawingToolsBase::Draw(TTree* tree1, TTree* tree2,
const std::string& var,
int nx,
double xmin,
double xmax,
int ny,
double ymin,
double ymax,
1263 const std::string& categ,
const std::string& cut,
const std::string& root_opt,
const std::string& opt,
double norm,
bool scale_errors){
1267 double xbins[NMAXBINS];
1268 double ybins[NMAXBINS];
1269 Draw(tree1,tree2,var,nx,
GetVariableBins(nx,xmin,xmax,xbins),ny,
GetVariableBins(ny,ymin,ymax,ybins),categ,cut,root_opt,opt,norm,scale_errors);
1273 void DrawingToolsBase::Draw(TTree* tree1, TTree* tree2,
const std::string& var,
int nx,
double* xbins,
int ny,
double* ybins,
1274 const std::string& categ,
const std::string& cut,
const std::string& root_opt,
const std::string& opt,
double norm2,
bool scale_errors){
1289 _saved_histoStacks.push_back(hs1);
1290 _saved_histoStacks.push_back(hs2);
1295 Project(hs1, hs2, tree1,tree2,var,nx,xbins,ny,ybins,categ,cut,root_opt,opt,norm2,scale_errors);
1298 DrawHistoStacks(hs1,hs2,categ,root_opt,opt,norm2);
1302 void DrawingToolsBase::DrawRatioTwoCuts(TTree* tree1, TTree* tree2,
const std::string& var,
int nx,
double* xbins,
int ny,
double* ybins,
1303 const std::string& cut1,
const std::string& cut2,
const std::string& root_opt,
const std::string& opt,
const std::string& leg,
double norm,
bool scale_errors){
1315 _saved_histoStacks.push_back(hs1);
1316 _saved_histoStacks.push_back(hs2);
1319 ProjectNew(hs1, hs2, tree1,tree2,var,nx,xbins,ny,ybins,
"all",cut1,cut2,root_opt,opt,norm,scale_errors);
1322 DrawRatioHistoStacks(hs1,hs2,root_opt,opt,norm,leg);
1328 const std::string& root_opt,
const std::string& opt,
double norm,
const std::string& leg){
1338 if (hs1->
Is2D()) is2D=
true;
1341 if (hs2->
Is2D()) is2D=
true;
1344 std::string box =
"";
1345 std::string error =
"e";
1351 if (!hs2) uopt=uopt+
" NOLEG";
1355 if (slevel==
"0" && leg!=
"")
1359 uopt = uopt+
" NOCREATELEG";
1361 TH1_h* ratio = GetRatioHisto(hs1,hs2,uopt);
1364 DrawRatio(ratio,root_opt+box+error,uopt,leg);
1370 const std::string& cut,
const std::string& root_opt,
const std::string& opt,
const std::string& leg,
double norm){
1374 double xbins[NMAXBINS];
1375 DrawRatioTwoCuts(tree1,tree2,var,nx,
GetVariableBins(nx,xmin,xmax,xbins),cut,cut,root_opt,opt,leg,norm);
1380 const std::string& cut,
const std::string& root_opt,
const std::string& opt,
const std::string& leg,
double norm){
1384 DrawRatioTwoCuts(tree1,tree2,var,nx,xbins,cut,cut,root_opt,opt,leg,norm);
1388 void DrawingToolsBase::DrawRatioTwoCuts(TTree* tree1, TTree* tree2,
const std::string& var,
int nx,
double xmin,
double xmax,
1389 const std::string& cut1,
const std::string& cut2,
const std::string& root_opt,
const std::string& opt,
const std::string& leg,
double norm){
1393 double xbins[NMAXBINS];
1394 DrawRatioTwoCuts(tree1,tree2,var,nx,
GetVariableBins(nx,xmin,xmax,xbins),cut1,cut2,root_opt,opt,leg,norm);
1398 void DrawingToolsBase::DrawRatioTwoCuts(TTree* tree1, TTree* tree2,
const std::string& var,
int nx,
double* xbins,
1399 const std::string& cut1,
const std::string& cut2,
const std::string& root_opt,
const std::string& opt,
const std::string& leg,
double norm){
1404 DrawRatioTwoCuts(tree1,tree2,var,nx,xbins,ny,ybins,cut1,cut2,root_opt,opt,leg,norm);
1412 if (slevel==
"0" && leg!=
"")
1416 DrawHisto(ratio, _auto_colors[_same_level], _line_width, 1, _fill_style, root_opt, uopt+
" NOSTAT NOVARBIN",
"LE1P",0);
1420 _legends.back()->Draw();
1428 const std::string& root_opt,
const std::string& opt,
const std::string& leg){
1436 const std::string& root_opt,
const std::string& opt,
const std::string& leg){
1440 if (sel().GetSelection(ibranch,
true)) {
1442 std::cout <<
"Drawing for selection " << isel <<
", branch 0" << std::endl;
1443 return DrawEventsVSCut(tree,isel,0,cut_norm,first_cut,last_cut,root_opt,opt,leg);
1446 DrawEventsVSCut(tree,0,ibranch,cut_norm,first_cut,last_cut,root_opt,opt,leg);
1452 const std::string& root_opt,
const std::string& opt,
const std::string& leg){
1459 if (!sel().GetSelection(isel,
true))
return;
1467 if (slevel==
"0" && leg!=
"")
1470 if (strcmp(tree->GetName(),
"truth") && !
drawUtils::CheckOption(uopt,
"DRAWALLCUTS")) first_cut = _minAccumLevelToSave-1;
1471 TH1_h* hall =
GetEventsVSCut(tree,
"events",cut_norm, isel, ibranch,first_cut, last_cut,root_opt,uopt);
1473 Int_t cut_offset = 0;
1475 if (first_cut ==-1){
1476 hall->GetXaxis()->SetBinLabel(1,
"NO CUT");
1482 for (
int i=cut_offset;i<hall->GetNbinsX();i++ ){
1483 int icut = first_cut+i;
1484 hall->GetXaxis()->SetBinLabel(i+1, cuts[icut]->Title().c_str());
1488 gStyle->SetErrorX(0.0001);
1490 hall->SetTitle(_title.c_str());
1491 hall->SetMarkerStyle(21);
1493 DrawHisto(hall, _auto_colors[_same_level], _line_width, _auto_colors[_same_level], _fill_style,
"pl e"+root_opt, uopt+
" NOSTAT NOLEG");
1495 hall->GetXaxis()->SetTitle(
"");
1496 hall->GetYaxis()->SetTitle(
"# events");
1501 _legends.back()->Draw();
1508 gStyle->SetErrorX();
1513 const std::string& root_opt,
const std::string& opt,
const std::string& leg,
double norm){
1516 DrawRatioVSCut(tree1,tree2,0, precut,first_cut,last_cut,root_opt,opt,leg,norm);
1521 const std::string& root_opt,
const std::string& opt,
const std::string& leg,
double norm){
1525 if (sel().GetSelection(ibranch,
true)) {
1527 std::cout <<
"Drawing for selection " << isel <<
", branch 0" << std::endl;
1528 return DrawRatioVSCut(tree1,tree2,isel,0,precut,first_cut,last_cut,root_opt,opt,leg,norm);
1531 DrawRatioVSCut(tree1,tree2,0,ibranch,precut,first_cut,last_cut,root_opt,opt,leg,norm);
1536 const std::string& root_opt,
const std::string& opt,
const std::string& leg,
double norm){
1540 if (!sel().GetSelection(isel,
true))
return;
1548 if (slevel==
"0" && leg!=
"")
1551 Int_t first_cut2=-1;
1553 TH1_h* h1 =
GetEventsVSCut(tree1,
"num",precut,isel,branch,first_cut2, last_cut,root_opt,uopt);
1557 TH1_h* h2 =
GetEventsVSCut(tree2,
"den",precut,isel,branch,first_cut2, last_cut,root_opt,uopt);
1568 const std::string& root_opt,
const std::string& opt,
const std::string& leg){
1571 DrawPurVSCut(tree,0,signal,precut,first_cut,last_cut,root_opt,opt,leg);
1576 const std::string& root_opt,
const std::string& opt,
const std::string& leg){
1580 if (sel().GetSelection(ibranch,
true)) {
1582 std::cout <<
"Drawing for selection " << isel <<
", branch 0" << std::endl;
1583 return DrawPurVSCut(tree,isel,0,signal,precut,first_cut,last_cut,root_opt,opt,leg);
1586 DrawPurVSCut(tree,0,ibranch,signal,precut,first_cut,last_cut,root_opt,opt,leg);
1592 const std::string& root_opt,
const std::string& opt,
const std::string& leg){
1596 if (!sel().GetSelection(isel,
true))
return;
1604 if (slevel==
"0" && leg!=
"")
1607 std::string numer =
"";
1610 }
else if (precut ==
"") {
1613 numer = signal+
"&&"+precut;
1616 Int_t first_cut2 =-1;
1618 TH1_h* h1 =
GetEventsVSCut(tree,
"pur1",numer,isel,branch,first_cut2, last_cut,root_opt,uopt);
1622 TH1_h* h2 =
GetEventsVSCut(tree,
"pur2",precut,isel,branch,first_cut2, last_cut,root_opt,uopt);
1624 std::cout <<
"----- Purity values -----------" << std::endl;
1627 DrawRatioVSCut(h1,h2,isel,branch,first_cut,root_opt,uopt+
" EFF",leg);
1632 const std::string& root_opt,
const std::string& opt,
const std::string& leg){
1635 DrawEffVSCut(tree,0,signal,precut,first_cut,last_cut,root_opt,opt,leg);
1640 const std::string& root_opt,
const std::string& opt,
const std::string& leg){
1644 if (sel().GetSelection(ibranch,
true)) {
1646 std::cout <<
"Drawing for selection " << isel <<
", branch 0" << std::endl;
1647 return DrawEffVSCut(tree,isel,0,signal,precut,first_cut,last_cut,root_opt,opt,leg);
1650 DrawEffVSCut(tree,0,ibranch,signal,precut,first_cut,last_cut,root_opt,opt,leg);
1656 const std::string& root_opt,
const std::string& opt,
const std::string& leg){
1660 if (!sel().GetSelection(isel,
true))
return;
1668 if (slevel==
"0" && leg!=
"")
1671 std::string numer =
"";
1674 }
else if (precut ==
"") {
1677 numer = signal+
"&&"+precut;
1680 Int_t first_cut2 = -1;
1682 TH1_h* h1 =
GetEventsVSCut(tree,
"eff1",numer,isel,branch,first_cut2, last_cut,root_opt,uopt);
1685 int nx = h1->GetNbinsX();
1686 double xmin = h1->GetXaxis()->GetXmin();
1687 double xmax = h1->GetXaxis()->GetXmax();
1688 double xbins[NMAXBINS];
1690 _saved_histos.push_back(h2);
1692 for (
int i=0; i<h2->GetNbinsX();i++){
1693 h2->SetBinContent(i+1,h1->GetBinContent(1));
1694 h2->SetBinError( i+1,h1->GetBinError(1));
1697 std::cout <<
"----- Efficiency values -----------" << std::endl;
1698 DrawRatioVSCut(h1,h2,isel,branch,first_cut,root_opt,uopt+
" EFF",leg);
1703 const std::string& root_opt,
const std::string& opt,
const std::string& leg){
1712 if (!sel().GetSelection(isel,
true))
return;
1720 TH1_h* hratio =
new TH1_h(
GetUniqueName(
"ratio").c_str(),
"",h1->GetNbinsX(),h1->GetXaxis()->GetXmin(),h1->GetXaxis()->GetXmax());
1721 _saved_histos.push_back(hratio);
1723 hratio->Divide(h1,h2);
1725 Int_t cut_offset = 1;
1727 hratio->GetXaxis()->SetBinLabel(1,
"NO CUT");
1731 for (
int i=cut_offset;i<hratio->GetNbinsX();i++ ){
1732 int icut = i-cut_offset;
1733 hratio->GetXaxis()->SetBinLabel(i+1, cuts[icut]->Title().c_str());
1737 gStyle->SetOptStat(0);
1740 hratio->SetTitle(_title.c_str());
1741 hratio->GetXaxis()->SetTitle(
"");
1742 hratio->GetYaxis()->SetTitle(_titleY.c_str());
1743 hratio->GetYaxis()->SetNdivisions(520);
1748 hratio->GetYaxis()->SetRangeUser(0,1.1);
1751 hratio->GetXaxis()->SetRange(first_cut+cut_offset+1,hratio->GetNbinsX());
1753 if (uroot_opt.find(
"SAME")!=std::string::npos)
1754 hratio->Draw(
"PHIST same");
1756 hratio->Draw(
"PHIST");
1760 TGraphAsymmErrors* eff =
new TGraphAsymmErrors(h1->GetNbinsX());
1762 _saved_graphs.push_back(eff);
1763 eff->Divide(h1, h2, (
_eff_params +
" v").c_str());
1765 eff->SetLineColor(_auto_colors[_same_level]);
1766 eff->SetMarkerColor(_auto_colors[_same_level]);
1767 eff->SetMarkerStyle(21);
1770 eff->GetXaxis()->SetLimits(first_cut+cut_offset+1,hratio->GetNbinsX());
1772 for (
int i=0; i<h1->GetNbinsX();i++){
1773 eff->SetPointEXhigh(i,0);
1774 eff->SetPointEXlow(i,0);
1778 eff->Draw((
"PL "+root_opt).c_str());
1787 hratio->SetLineColor(_auto_colors[_same_level]);
1788 hratio->SetMarkerColor(_auto_colors[_same_level]);
1789 hratio->SetMarkerStyle(21);
1792 hratio->GetXaxis()->SetRange(first_cut+cut_offset+1,hratio->GetNbinsX());
1795 hratio->Draw((
"PL "+uroot_opt).c_str());
1805 for (
int i=0;i<hratio->GetNbinsX();i++ ){
1807 std::string cut_name=
"";
1809 cut_name =
"NO CUT";
1811 cut_name = cuts[icut]->Title();
1812 sprintf(out1,
"%3s: %-25s %-10s",
"#",
"cut",
"ratio");
1813 sprintf(out2,
"%3d: %-25s %-10.2f", icut, cut_name.c_str(), hratio->GetBinContent(i+1));
1814 if (i==0) std::cout << out1 << std::endl;
1815 std::cout << out2 << std::endl;
1821 _legends.back()->Draw();
1828 void DrawingToolsBase::DrawToys(TTree* tree,
const std::string& cut,
const std::string& root_opt,
const std::string& opt,
const std::string& leg){
1842 TH1_h h1(
"h1",
"h1",ntoys,0,ntoys);
1843 TH1_h hw(
"hw",
"hw",ntoys,0,ntoys);
1846 std::string cutp = weightTools::ApplyWeights(tree,
FormatCut(cut),(uopt+
" NOTOYW").c_str());
1849 tree->Project(
"h1",
"toy_index",cutp.c_str());
1851 std::string cut2=cut;
1852 if (cut2==
"") cut2=
"1==1";
1856 tree->Project(
"hw",
"toy_index",(
"("+cutp+
")*toy_weight").c_str());
1862 hwa.Divide(&hw,&h1);
1870 const std::string& root_opt,
const std::string& opt,
const std::string& leg,
double norm){
1882 const std::string& root_opt,
const std::string& opt,
const std::string& leg,
double norm){
1893 if (NTOYS1!=NTOYS2)
return;
1902 std::string cut1p = weightTools::ApplyWeights(tree1,
FormatCut(cut1),(uopt+
" NOTOYW").c_str());
1903 std::string cut2p = weightTools::ApplyWeights(tree2,
FormatCut(cut2),(uopt+
" NOTOYW").c_str());
1906 TH1_h h1(
"en1",
"en2",NTOYS1,0,NTOYS1);
1907 tree1->Project(
"en1",
"toy_index",cut1p.c_str());
1910 TH1_h h2(
"en2",
"en2",NTOYS1,0,NTOYS1);
1911 tree2->Project(
"en2",
"toy_index",cut2p.c_str());
1915 ratio.SetName(
"ratio");
1917 ratio.Divide(&h1,&h2);
1920 TH1_h hw1(
"hw1",
"hw1",NTOYS1,0,NTOYS1);
1922 tree1->Project(
"hw1",
"toy_index",(
"("+cut1p+
")*toy_weight").c_str());
1927 TH1_h hw2(
"hw2",
"hw2",NTOYS1,0,NTOYS1);
1929 tree2->Project(
"hw2",
"toy_index",(
"("+cut2p+
")*toy_weight").c_str());
1936 hwa1.Divide(&hw1,&h1);
1940 hwa2.Divide(&hw2,&h2);
1954 if (slevel==
"0" && leg!=
"")
1958 int statTemp = _stat_option;
1960 gStyle->SetOptStat(1001110);
1962 const int NTOYS = result.GetNbinsX();
1964 double nentries[NMAXTOYS];
1965 double avg_weight[NMAXTOYS];
1966 double sum_weights=0;
1967 double avg_nentries=0;
1972 for (
int itoy=0;itoy<NTOYS;itoy++){
1973 nentries[itoy]=result.GetBinContent(itoy+1);
1975 if (nentries[itoy]>0)
1976 avg_weight[itoy] = weights.GetBinContent(itoy+1);
1978 avg_weight[itoy] = 0;
1979 std::cout <<
"toy_index = "<< itoy <<
"\t --> #entries = " << nentries[itoy] <<
"\t w=" << avg_weight[itoy] << std::endl;
1981 if (nentries[itoy]>hmax) hmax = nentries[itoy];
1982 if (nentries[itoy]<hmin) hmin = nentries[itoy];
1985 sum_weights += avg_weight[itoy];
1986 avg_nentries += nentries[itoy]*avg_weight[itoy];
1989 std::cout <<
"avg[#entries] = sum[entries*avg_weight]/sum[avg_weight] = "<< avg_nentries/sum_weights
1990 <<
", sum[avg_weights] = " << sum_weights
1991 <<
", sum[entries*avg_weight] = " << avg_nentries << std::endl;
1994 TH1_h* hentries =
new TH1_h(
GetUniqueName(
"hentries").c_str(),leg.c_str(),1000,hmin-(hmax-hmin)/10.,hmax+(hmax-hmin)/10.);
1995 _saved_histos.push_back(hentries);
1999 for (
int itoy=0;itoy<NTOYS;itoy++){
2001 hentries->Fill(nentries[itoy],1./NTOYS);
2004 rms += pow(nentries[itoy]-avg_nentries/sum_weights,2)*avg_weight[itoy]/sum_weights;
2007 rms2 += pow(nentries[itoy]-avg_nentries,2)*avg_weight[itoy];
2010 std::cout <<
"rms = "<< sqrt(rms) <<
", rms' = " << sqrt(rms2) << std::endl;
2013 DrawHisto(hentries, _line_width, _line_color, _fill_style, root_opt, uopt,
"LE1P");
2017 _legends.back()->Draw();
2027 void DrawingToolsBase::DrawHisto(TH1* h,
int lw,
int fc,
int fs,
const std::string& root_opt,
const std::string& opt,
const std::string& leg_opt,
int mode){
2035 DrawHisto(h,fc,lw,fc,fs, root_opt, opt,leg_opt,mode);
2039 DrawHisto(h,_auto_colors[_same_level],lw,fc,fs, root_opt, opt,leg_opt,mode);
2044 void DrawingToolsBase::DrawHisto(TH1* h,
int lc,
int lw,
int fc,
int fs,
const std::string& root_opt,
const std::string& opt,
const std::string& leg_opt,
int mode){
2062 gStyle->SetOptStat(0);
2064 gStyle->SetOptStat(_stat_option);
2066 h->SetLineColor(lc);
2067 h->SetMarkerColor(lc);
2071 h->SetMarkerStyle(_marker_style);
2073 h->SetMarkerSize(_marker_size);
2075 h->SetLineWidth(lw);
2076 h->SetFillColor(fc);
2077 h->SetFillStyle(fs);
2080 std::string title = h->GetTitle();
2081 std::string leg_opt_copy = leg_opt;
2083 title = _data_label;
2084 leg_opt_copy =
"lpe";
2087 title = _allmcstat_label;
2091 title = _allmcsyst_label;
2095 title = _allmc_label;
2100 h->GetXaxis()->SetTitle(_titleX.c_str());
2101 h->GetYaxis()->SetTitle(_titleY.c_str());
2102 h->SetTitle(_title.c_str());
2105 TH1_h* hp =
new TH1_h(*((TH1_h*)h));
2106 std::string name = hp->GetName();
2107 hp->SetName((name+
"_new").c_str());
2108 _saved_histos.push_back(hp);
2112 std::string root_opt_novarbin =
"Z";
2118 if (uroot_opt.find(
"HIST")!=std::string::npos)
2119 root_opt_novarbin = root_opt_novarbin +
" HIST";
2121 h->Draw(root_opt_novarbin.c_str());
2131 hp->Draw((uroot_opt2+
" same").c_str());
2138 double ymax = hp->GetBinContent(hp->GetMaximumBin())+hp->GetBinError(hp->GetMaximumBin());
2140 if (fabs(_maxY) > 1e-6 && _maxY > _minY)
2141 h->SetMaximum(_maxY);
2143 h->SetMaximum(ymax*_relativeMaxY);
2148 h->SetMinimum(_minY);
2151 gPad->SetLogy(_logY);
2160 void DrawingToolsBase::DrawHistoStack(
HistoStack* hs,
const std::string& categ,
const std::string& root_opt,
const std::string& opt,
const std::string& leg_opt,
int mode){
2163 DrawHistoStack(hs,categ,root_opt,opt,_line_color, _line_width, _fill_color, _fill_style, leg_opt, mode);
2167 void DrawingToolsBase::DrawHistoStack(
HistoStack* hs,
const std::string& categ,
const std::string& root_opt,
const std::string& opt,
int lc,
int lw,
int fc,
int fs,
const std::string& leg_opt,
int mode){
2192 gStyle->SetOptStat(0);
2194 gStyle->SetOptStat(_stat_option);
2204 std::string same=
"";
2207 std::string uopt2 = uopt;
2208 std::string error_opt =
"";
2212 lc = fc = _mcerror_color;
2215 uopt2 = uopt+
" NOAUTOCOLORS";
2216 error_opt=
" "+ error_opt;
2219 uopt2 = uopt+
" NOERROR";
2225 DrawHisto(hs->
GetTotal1D(), lc, lw, fc, fs, root_opt+
" HIST", uopt2,
"f");
2227 DrawHisto(hs->
GetTotal1D(), lc, lw, fc, fs, root_opt+error_opt, uopt2,
"f");
2234 DrawHisto(hs->
GetTotalStat1D(), _mcstaterror_color, lw, _mcstaterror_color, fs, root_opt+same+error_opt, uopt2+
" ALLMCSTATLEG",
"f");
2236 DrawHisto(hs->
GetTotalSyst1D(), _mcstaterror_color, lw, _mcstaterror_color, fs, root_opt+same+error_opt, uopt2+
" ALLMCSYSTLEG",
"f");
2239 else if (hs->
Is2D())
2240 DrawHisto(hs->
GetTotal2D(), lc, lw, fc, fs, root_opt, uopt);
2245 hs->
Draw(root_opt+
" HIST",uopt);
2247 DrawHisto(hs->
GetTotal1D(), lc, lw, fc, fs, root_opt+
" same", uopt,
"f");
2254 _legends.back()->Draw();
2258 int optstat = gStyle->GetOptStat();
2259 if (optstat % 2 != 0) {
2261 TPaveStats *pavestat = (TPaveStats*)gPad->GetPrimitive(
"stats");
2262 pavestat->SetName(
"mystats");
2263 TList *list = pavestat->GetListOfLines();
2264 list->RemoveFirst();
2266 TLatex *name =
new TLatex(0,0,_allmc_label.c_str());
2268 name =
new TLatex(0,0,_data_label.c_str());
2269 name->SetTextColor(_data_color);
2271 name =
new TLatex(0,0,_allmc_label.c_str());
2272 name->SetTextColor(_allmc_color);
2274 list->AddFirst(name);
2286 if (fabs(_maxY) < 1e-6 || _maxY < _minY) {
2288 relmax=_relativeMaxY;
2293 if (categ!=
"all") relmax/=1.05;
2301 gPad->SetLogy(_logY);
2309 const std::string& categ,
const std::string& root_opt,
const std::string& opt,
double norm){
2329 if (hs1->
Is2D()) is2D=
true;
2332 if (hs2->
Is2D()) is2D=
true;
2335 std::string box =
"";
2336 std::string error1 =
"";
2337 TVirtualPad* curPad = gPad;
2340 if (uroot_opt.find(
"HIST") == std::string::npos)
2343 uopt= uopt+
" NOERROR";
2350 std::string smallleg=
"";
2351 if (categ==
"all") smallleg=
" SMALLLEG";
2352 if (!hs2) uopt=uopt+
" NOLEG";
2357 uopt = uopt+
" NOCREATELEG";
2362 gPad->SetBottomMargin(0);
2363 if(!_MainPad) _MainPad =
new TPad(
"MainPad",
"MainPad",
2364 curPad->GetAbsXlowNDC(),
2365 curPad->GetAbsYlowNDC()+(curPad->GetAbsHNDC()*0.3),
2366 curPad->GetAbsXlowNDC()+curPad->GetAbsWNDC(),
2367 curPad->GetAbsYlowNDC()+curPad->GetAbsHNDC());
2368 _MainPad->SetLogy(_logY);
2369 _MainPad->SetBottomMargin(0);
2370 gStyle->SetOptStat(_stat_option);
2383 gStyle->SetOptStat(_stat_option);
2388 double w = gStyle->GetStatW();
2389 SetStatPos(_statPos[0]-w);
2391 _statPos[0] = _statPos[0] + w;
2393 std::string uopt2 = uopt+
" ALLMCLEG";
2398 DrawHistoStack(hs2,categ,
GetSameRootOption(root_opt), uopt2+
" ISSECONDSAMPLE");
2402 SetStatPos(_statPos[0], _statPos[1]);
2403 DrawHistoStack(hs2,categ,root_opt+box,uopt+
" ISSECONDSAMPLE");
2408 SetStatPos(_statPos[0], _statPos[1]);
2409 std::string same=
"";
2411 DrawHistoStack(hs1,
"all", root_opt+same+error1, uopt+
" ISDATA DONTADDLEGENTRY",_line_color, _line_width, _fill_color, 0,
"LE1P", 2);
2425 if (fabs(_maxY) < 1e-6 || _maxY < _minY) {
2426 relmax=_relativeMaxY;
2436 else if (draw2) max = max2;
2438 if (categ!=
"all") relmax/=1.05;
2451 if(!_RatioPad) _RatioPad =
new TPad(
"RatioPad",
"RatioPad",
2452 curPad->GetAbsXlowNDC(),
2453 curPad->GetAbsYlowNDC(),
2454 curPad->GetAbsXlowNDC()+curPad->GetAbsWNDC(),
2455 curPad->GetAbsYlowNDC()+(curPad->GetAbsHNDC()*0.3));
2458 TH1F* ratio = (TH1F*)hs1->
GetTotal1D()->Clone();
2462 ratio->GetYaxis()->SetNdivisions(010,
true);
2463 ratio->GetXaxis()->SetLabelSize(ratio->GetXaxis()->GetLabelSize()/0.3);
2464 ratio->GetYaxis()->SetLabelSize(ratio->GetYaxis()->GetLabelSize()/0.3);
2465 ratio->GetYaxis()->SetTitle(
"Ratio");
2466 ratio->GetXaxis()->SetTitleSize(ratio->GetXaxis()->GetTitleSize()/0.3);
2467 ratio->GetYaxis()->SetTitleSize(ratio->GetYaxis()->GetTitleSize()/0.3);
2468 DrawHisto(ratio, _line_color, _line_width, 0, 0, root_opt+
" same error",
"ST NOSTAT ISDATA DONTADDLEGENTRY",
"", 2);
2469 ratio->SetMaximum(_relativeMaxY*ratio->GetBinContent(ratio->GetMaximumBin()));
2470 ratio->SetMinimum( ratio->GetBinContent(ratio->GetMinimumBin())/_relativeMaxY);
2471 _RatioPad->SetLogy(0);
2472 _RatioPad->SetTopMargin(0);
2473 _RatioPad->SetBottomMargin(0.3);
2474 _RatioPad->SetGridx();
2475 _RatioPad->SetGridy();
2476 _RatioPad->Update();
2480 gStyle->SetOptStat(_stat_option);
2482 if(_RatioPad){_RatioPad->Update();_RatioPad->Draw();}
2483 if(_MainPad) {_MainPad ->Update();_MainPad ->Draw();}
2491 void DrawingToolsBase::DrawHisto(TH2* h,
int lc,
int lw,
int fc,
int fs,
const std::string& root_opt,
const std::string& opt,
const std::string& leg_opt,
int mode){
2501 gStyle->SetOptStat(0);
2503 gStyle->SetOptStat(_stat_option);
2505 h->SetLineColor(lc);
2506 h->SetMarkerColor(lc);
2510 h->SetMarkerStyle(_marker_style);
2512 h->SetMarkerSize(_marker_size);
2514 h->SetLineWidth(lw);
2515 h->SetFillColor(fc);
2516 h->SetFillStyle(fs);
2519 h->SetMinimum(_minY);
2525 std::string title = h->GetTitle();
2527 h->GetXaxis()->SetTitle(_titleX.c_str());
2528 h->GetYaxis()->SetTitle(_titleY.c_str());
2530 h->SetTitle(_title.c_str());
2536 prof = h->ProfileX();
2539 prof = h->ProfileY();
2542 std::cout <<
"wrong profile type !!!!" << std::endl;
2545 _saved_histos.push_back(prof);
2546 DrawHisto(prof,lc,lw,fc,fs, root_opt, uopt+
" NOMIN",leg_opt);
2549 h->Draw(root_opt.c_str());
2551 gPad->SetLogz(_logZ);
2560 void DrawingToolsBase::DrawHisto(TH3F* h,
int lc,
int lw,
int fc,
int fs,
const std::string& root_opt){
2565 gStyle->SetOptStat(_stat_option);
2569 h->SetLineColor(lc);
2570 h->SetLineWidth(lw);
2571 h->SetFillColor(fc);
2572 h->SetFillStyle(fs);
2574 h->SetMarkerColor(lc);
2576 h->Draw(root_opt.c_str());
2588 if (scale==0 || scale ==1)
return;
2599 for (
int i=0;i<nx+1;i++)
2600 xbins[i]= xmin+i*(xmax-xmin)/nx;
2610 if (uroot_opt.find(
"SAME") == std::string::npos){
2620 std::stringstream slevel;
2621 slevel << _same_level;
2623 return slevel.str();
2630 if (_different_fill_styles && i < NAUTOCOLORS) {
2631 return auto_styles[i];
2633 return _stack_fill_style;
2645 double sizex = _legendSize[0];
2646 double sizey = _legendSize[1];
2654 _legends.push_back(
new TLegend(_legendParam[0],_legendParam[1],_legendParam[2],_legendParam[3]));
2655 _legends.back()->SetShadowColor(0);
2656 _legends.back()->SetFillColor(0);
2660 _legends.back()->SetTextAlign(32);
2662 _legends.back()->SetTextAlign(12);
2670 std::stringstream unique;
2672 TString name2 = name;
2673 name2 = name2.ReplaceAll(
"(",
"_");
2674 name2 = name2.ReplaceAll(
")",
"_");
2675 return std::string(name2.Data()) +
"_" + unique.str();
2679 TH1_h* DrawingToolsBase::GetHisto(TTree* tree,
const std::string& name,
const std::string& var,
int nx,
double* xbins,
2680 const std::string& cut,
const std::string& root_opt,
const std::string& opt,
double scale,
bool scale_errors,
int toy_ref){
2684 return GetHisto(hs,tree,name,var,nx,xbins,cut,root_opt,opt,scale,scale_errors,toy_ref);
2688 TH1_h* DrawingToolsBase::GetHisto(
HistoStack* hs, TTree* tree,
const std::string& name,
const std::string& var,
int nx,
double* xbins,
2689 const std::string& cut,
const std::string& root_opt,
const std::string& opt,
double scale,
bool scale_errors,
int toy_ref){
2692 TH1_h* hsyst = NULL;
2693 return GetHisto(hs,tree,name,var,nx,xbins,cut,root_opt,opt,hsyst,scale,scale_errors,toy_ref);
2697 TH1_h* DrawingToolsBase::GetHisto(
HistoStack* hs, TTree* tree,
const std::string& name,
const std::string& var,
int nx,
double* xbins,
2698 const std::string& cut,
const std::string& root_opt,
const std::string& opt, TH1_h*& hsyst,
double scale,
bool scale_errors,
int toy_ref){
2722 cut2 = cut2 +
" && (" + var +
"!=-999)";
2726 std::stringstream stoy_ref;
2727 stoy_ref << toy_ref;
2728 cut2 = cut2 +
" && toy_index=="+stoy_ref.str();
2732 std::string cutp = weightTools::ApplyWeights(tree,cut,(uopt+
" NOTOYW").c_str());
2733 std::string cut2p = weightTools::ApplyWeights(tree,cut2,uopt);
2736 TH1_h* hstat =
new TH1_h(name2.c_str(),
"all",nx,xbins);
2737 _saved_histos.push_back(hstat);
2740 std::string newvar = var;
2742 std::stringstream s;
2743 s <<
"((" << newvar <<
"<" << xbins[nx] <<
")*(" << newvar <<
"))+((" << newvar <<
">=" << xbins[nx] <<
")*(" << (xbins[nx]+xbins[nx-1])/2. <<
"))";
2747 std::stringstream s;
2748 s <<
"((" << newvar <<
">" << xbins[0] <<
")*(" << newvar <<
"))+((" << newvar <<
"<=" << xbins[0] <<
")*(" << (xbins[0]+xbins[1])/2. <<
"))";
2752 tree->Project(name2.c_str(),newvar.c_str(),cut2p.c_str());
2756 FillHistoErrors(NULL, hs, NULL, tree,name2,var,nx,xbins,cutp,cutp,uopt,1,hstat,hsyst);
2759 UpdateSystInfo(NULL, hs, NULL, tree, var, nx, xbins, cutp, cutp, uopt,1);
2768 TH2_h* DrawingToolsBase::GetHisto(TTree* tree,
const std::string& name,
const std::string& var,
int nx,
double* xbins,
int ny,
double* ybins,
2769 const std::string& cut,
const std::string& root_opt,
const std::string& opt,
double scale,
bool scale_errors,
int toy_ref){
2793 std::stringstream stoy_ref;
2794 stoy_ref << toy_ref;
2795 cut2 = (cut+
" && toy_index=="+stoy_ref.str()).c_str();
2799 std::string cut2p = weightTools::ApplyWeights(tree,cut2,uopt);
2802 TH2_h* hall =
new TH2_h(name2.c_str(),
"all",nx,xbins,ny,ybins);
2803 _saved_histos2D.push_back(hall);
2804 tree->Project(name2.c_str(),var.c_str(),cut2p.c_str());
2817 TH1_h* DrawingToolsBase::GetRatioHisto(
HistoStack* hs1,
HistoStack* hs2,
const std::string& opt){
2823 std::cout <<
"ERROR. numerator does not exist !!!" << std::endl;
2828 std::cout <<
"ERROR. denominator does not exist !!!" << std::endl;
2841 TH1_h* ratio =
new TH1_h(*h1);
2843 ratio->SetName(name2.c_str());
2844 _saved_histos.push_back(ratio);
2845 ratio->Divide(h1,h2);
2848 FillHistoErrors(hs1, hs2, ratio, uopt);
2854 TH1_h* DrawingToolsBase::GetRatioHisto(TTree* tree1, TTree* tree2,
const std::string& name,
const std::string& var,
int nx,
double* xbins,
2855 const std::string& cut1,
const std::string& cut2,
2856 const std::string& root_opt,
const std::string& opt,
double norm,
double scale,
bool scale_errors,
int toy_ref){
2885 cut1p = cut1p +
" && (" + var +
"!=-999)";
2886 cut2p = cut2p +
" && (" + var +
"!=-999)";
2893 std::stringstream stoy_ref;
2894 stoy_ref << toy_ref;
2895 cut1p = (cut1p+
" && toy_index=="+stoy_ref.str()).c_str();
2896 cut2p = (cut2p+
" && toy_index=="+stoy_ref.str()).c_str();
2900 std::string cut1pp = weightTools::ApplyWeights(tree1,cut1p,uopt);
2901 std::string cut2pp = weightTools::ApplyWeights(tree2,cut2p,uopt);
2904 std::string newvar = var;
2906 std::stringstream s;
2907 s <<
"((" << newvar <<
"<" << xbins[nx] <<
")*(" << newvar <<
"))+((" << newvar <<
">=" << xbins[nx] <<
")*(" << (xbins[nx]+xbins[nx-1])/2. <<
"))";
2911 std::stringstream s;
2912 s <<
"((" << newvar <<
">" << xbins[0] <<
")*(" << newvar <<
"))+((" << newvar <<
"<=" << xbins[0] <<
")*(" << (xbins[0]+xbins[1])/2. <<
"))";
2918 TH1_h ratio1(
"ratio1",
"ratio1",nx,xbins);
2919 tree1->Project(
"ratio1",var.c_str(),cut1pp.c_str());
2922 TH1_h ratio2(
"ratio2",
"ratio2",nx,xbins);
2923 tree2->Project(
"ratio2",var.c_str(),cut2pp.c_str());
2932 TH1_h* ratio =
new TH1_h(ratio1);
2933 ratio->SetName(name2.c_str());
2934 _saved_histos.push_back(ratio);
2936 ratio->Divide(&ratio1,&ratio2);
2940 FillHistoErrors(NULL,NULL,tree1,tree2,name2,var,nx,xbins,cut1,cut2,uopt,norm,ratio,hsyst);
2947 void DrawingToolsBase::FillHistoErrors(
HistoStack* hs1,
HistoStack* hs2, TH1_h* histo,
const std::string uopt){
2958 void DrawingToolsBase::FillGraphErrors(
HistoStack* hs1,
HistoStack* hs2, TGraphAsymmErrors* graph,
const std::string uopt){
2968 void DrawingToolsBase::FillHistoErrors(
HistoStack* hs1,
HistoStack* hs2, TTree* tree1,TTree* tree2,
const std::string& name,
const std::string& var,
int nx,
double* xbins,
2969 const std::string& cut1,
const std::string& cut2,
const std::string& opt,
double norm, TH1_h* hstat, TH1_h*& hsyst) {
2990 const std::string& cut1,
const std::string& cut2,
const std::string& opt,
double norm) {
3011 const std::string& root_opt,
const std::string& opt){
3015 if (!sel().GetSelection(isel,
true))
return NULL;
3023 if (last_cut>(
int)(sel().GetSelection(isel)->GetNCuts(ibranch)-1) || last_cut == -1) last_cut=sel().
GetSelection(isel)->
GetNCuts(ibranch)-1;
3024 if (first_cut<-1 || first_cut>last_cut ) first_cut=-1;
3026 double xmin=first_cut-0.5;
3027 double xmax=last_cut+0.5;
3028 int nx = (int)(xmax-xmin);
3029 double xbins[NMAXBINS];
3033 _saved_histos.push_back(hall);
3039 std::cout << std::endl <<
"-------- List of selected cuts for branch " << ibranch;
3040 std::cout <<
": #cuts = " << cuts.size() <<
" -------" << std::endl;
3042 for (
int i=0;i<nx;i++ ){
3043 int icut = first_cut+i;
3045 std::stringstream sbranch;
3047 std::stringstream ssel;
3049 std::stringstream scut;
3052 Int_t accumLevelCut = std::max(icut,_minAccumLevelToSave-1);
3053 std::stringstream sAccumLevelCut;
3054 sAccumLevelCut << accumLevelCut;
3057 if (!strcmp(tree->GetName(),
"truth")){
3059 cut= cut0 +
" && accum_level["+ssel.str()+
"]["+sbranch.str()+
"]>"+scut.str();
3061 cut= cut0 +
" && accum_level["+sbranch.str()+
"]>"+scut.str();
3064 if (sel().GetNEnabledSelections()>1)
3065 cut= cut0 +
" && accum_level[]["+ssel.str()+
"]["+sbranch.str()+
"]>"+sAccumLevelCut.str();
3067 cut= cut0 +
" && accum_level[]["+sbranch.str()+
"]>"+sAccumLevelCut.str();
3071 std::string cutp = weightTools::ApplyWeights(tree,cut,uopt);
3073 TH1_h htemp(
"temp",
"temp",1,0,1);
3074 tree->Project(
"temp",
"0.5",cutp.c_str());
3076 double ball = (double)htemp.Integral();
3077 hall->SetBinContent(i+1,ball);
3080 std::cout << ball <<
" events before any cut " << std::endl;
3082 std::cout << ball <<
" events after cut " << icut <<
": " << cuts[icut]->Title() << std::endl;
3085 std::cout <<
"---------------------------------------------------------------" << std::endl << std::endl;
3093 TH1_h* DrawingToolsBase::AddErrorsInQuadrature(TH1_h* h1,TH1_h* h2,
const std::string& slevel){
3099 TH1_h *h3 =
new TH1_h(*h1);
3100 std::string name =
"errors_quad_sum"+slevel;
3101 h3->SetName(name.c_str());
3102 _saved_histos.push_back(h3);
3105 for (
int i=0;i<h1->GetNbinsX();i++){
3108 if (h1->GetNbinsX() != h2->GetNbinsX())
return NULL;
3110 double err = sqrt(pow(h1->GetBinError(i+1),2)+pow(h2->GetBinError(i+1),2));
3111 h3->SetBinError(i+1,err);
3112 h3->SetBinContent(i+1,h1->GetBinContent(i+1));
3115 h3->SetBinError(i+1,h1->GetBinError(i+1));
3116 h3->SetBinContent(i+1,h1->GetBinContent(i+1));
3119 h3->SetBinError(i+1,h2->GetBinError(i+1));
3120 h3->SetBinContent(i+1,h2->GetBinContent(i+1));
3132 std::string cut2=cut;
3133 if (cut2==
"") cut2=
"1==1";
3143 TH1_h *ht =
new TH1_h(
"temp",
" ",10,0.,10.);
3147 if (tree->FindLeaf(
"toy_ref"))
3148 cut1 = cut1 +
"&& toy_index == toy_ref";
3153 cut1 = weightTools::ApplyWeights(tree,cut1,
"");
3155 tree->Project(
"temp",
"1.",cut1.c_str());
3157 double TotalEntries = ht->GetSumOfWeights();
3160 return TotalEntries;
3182 cut2 +=
"&&(" + var +
"!=-999)";
3186 std::stringstream stoy_ref;
3187 stoy_ref << toy_ref;
3188 cut2 = (cut+
" && toy_index=="+stoy_ref.str()).c_str();
3192 std::string cut2p = weightTools::ApplyWeights(tree,cut2,uopt);
3195 double xbins[NMAXBINS];
3196 TH1_h* hall =
new TH1_h(
"temp",
"all",10,
GetVariableBins(10,-5.,5.,xbins));
3197 _saved_histos.push_back(hall);
3200 std::string newvar = var;
3201 std::stringstream s;
3202 s <<
"((" << newvar <<
")*(" << newvar <<
")/((" << newvar <<
")*(" << newvar <<
")+10.))";
3205 tree->Project(
"temp",newvar.c_str(),cut2p.c_str());
3208 double TotalEntries = hall->GetSumOfWeights();
3211 return TotalEntries;
3221 if (!cat().
HasCategory(categ) || categ ==
"all" ) {
3222 std::cout <<
" ------------------------------------------ " << std::endl;
3223 std::cout <<
" Invalid category " << categ << std::endl;
3224 std::cout <<
" ------------------------------------------ " << std::endl;
3230 TH1_h *ht =
new TH1_h(
"temp",
" ",10,0.,10.);
3233 if (tree->FindLeaf(
"toy_ref"))
3234 cut1 = cut1 +
" && toy_index == toy_ref";
3237 std::string cut1w = weightTools::ApplyWeights(tree,cut,
"");
3239 tree->Project(
"temp",
"1.",cut1w.c_str());
3241 double TotalEntries = ht->GetSumOfWeights();
3245 std::cout <<
" --------------------------------------------------------" << std::endl;
3246 std::cout <<
" Purities: " << std::endl;
3247 std::cout <<
" Category: " << categ << std::endl;
3248 std::cout <<
" Cut: " << cut << std::endl;
3249 std::cout <<
" Events: " << std::setprecision(8) << TotalEntries << std::endl;
3250 std::cout <<
" --------------------------------------------------------" << std::endl;
3253 std::ostringstream percstr, str_tmp;
3255 std::string* cattypes =
new std::string[ntypes];
3256 int* catcodes =
new int[ntypes];
3257 int* catcolors =
new int[ntypes];
3260 std::vector<TrackTypeDefinition>::iterator it;
3261 for (it=cat().GetCategoryTypes(categ).begin();it!=cat().
GetCategoryTypes(categ).end();it++, i++){
3262 std::string type = it->_name;
3265 std::string cut2 = cut1+
"&&"+categ+
"=="+code;
3267 cut2 = weightTools::ApplyWeights(tree,cut2,
"");
3270 TH1_h *ht1 =
new TH1_h(
"temp1",
" ",10,0.,10.);
3272 tree->Project(
"temp1",
"1.",cut2.c_str());
3274 double caseEntries = ht1->GetSumOfWeights();
3275 double frac = caseEntries/TotalEntries;
3276 double nev1 = caseEntries * events_ratio;
3279 std::cout << std::setprecision(8) << std::setw(25) << type << std::setw(12) << frac*100. <<
" % (" << nev1 <<
" events)" << std::endl;
3282 percstr.str(std::string());
3283 percstr << std::setprecision(2) << std::fixed << frac*100.;
3284 str_tmp.str(std::string());
3285 str_tmp << it->_name << std::setw(8) << percstr.str() <<
" %";
3286 cattypes[itype] = str_tmp.str();
3287 catcodes[itype] = it->_code;
3288 catcolors[itype] = it->_color;
3294 bool noWarning =
true, addNOTRUTH =
false, addSAND =
false;
3295 cat().
AddCategory(categ+
"_withPurities",itype,cattypes,catcodes,catcolors,multi,noWarning,addNOTRUTH,addSAND);
3297 std::cout <<
" --------------------------------------------------------" << std::endl;
3298 std::cout << std::endl;
3311 bool noWarning =
false;
3314 bool addNOTRUTH=
false;
3318 cat().
AddCategory(categ_name, ntypes, names, codes, colors, multi, noWarning, addNOTRUTH, addSAND);
3330 std::cout <<
"Category '" << categ <<
"' does not exist" << std::endl;
3349 std::cout <<
" Invalid tree. It is missing one or all of the following branches: evt, run, subrun " << std::endl;
3356 std::stringstream stoy_ref;
3357 stoy_ref << toy_ref;
3358 cut2 = (cut+
" && toy_index=="+stoy_ref.str()).c_str();
3362 std::string cutp = weightTools::ApplyWeights(tree,cut2,
"");
3364 std::ofstream output;
3366 output.open (file.c_str());
3369 char* tmpFilename=
new char;
3370 strcpy(tmpFilename,
"/tmp/XXXXXX");
3371 mktemp (tmpFilename);
3372 TFile *tmpFile =
new TFile(tmpFilename,
"RECREATE");
3373 TTree *tmpTree = tree->CopyTree(cutp.c_str());
3374 int run, subrun, evt;
3375 tmpTree->SetBranchAddress(
"run", &run);
3376 tmpTree->SetBranchAddress(
"subrun", &subrun);
3377 tmpTree->SetBranchAddress(
"evt", &evt);
3379 Long64_t nentries = tmpTree->GetEntries();
3381 std::cout<<
"# run,subrun,evt"<<std::endl;
3382 for (Long64_t i=0;i<nentries; i++) {
3383 tmpTree->GetEntry(i);
3385 output<<run<<
","<<subrun<<
","<<evt<<std::endl;
3387 std::cout<<run<<
","<<subrun<<
","<<evt<<std::endl;
3392 remove(tmpFilename);
3400 double ymin = gPad->PadtoY(gPad->GetUymin());
3401 double ymax = gPad->PadtoY(gPad->GetUymax());
3406 double deltax = xval-gPad->PadtoX( gPad->XtoPad(xval)-(gPad->GetUxmax()-gPad->GetUxmin())/20.);
3408 if (uarrowdir.find(
"L") != std::string::npos) {
3413 double yarr = gPad->PadtoY((gPad->GetUymax()-gPad->GetUymin())*arrowpos+gPad->GetUymin());
3414 double xarrmax = xval + deltax;
3422 double xmin = gPad->PadtoX(gPad->GetUxmin());
3423 double xmax = gPad->PadtoX(gPad->GetUxmax());
3428 double deltay = yval-gPad->PadtoY( gPad->YtoPad(yval)-(gPad->GetUymax()-gPad->GetUymin())/20.);
3430 if (uarrowdir.find(
"D") != std::string::npos) {
3435 double xarr = gPad->PadtoX((gPad->GetUxmax()-gPad->GetUxmin())*arrowpos+gPad->GetUxmin());
3436 double yarrmax = yval + deltay;
3444 TLine* l =
new TLine(xmin, ymin, xmax, ymax);
3446 l->SetLineColor(_cut_line_col);
3447 l->SetLineWidth(_cut_line_width);
3448 _cut_lines.push_back(l);
3451 if (_drawleg && _legends.size() > 0 && gPad->FindObject(_legends.back())) {
3452 _legends.back()->Draw();
3459 TArrow* arr =
new TArrow(xmin, ymin, xmax, ymax, 0.02,
"|>");
3460 arr->SetLineColor(_cut_line_col);
3461 arr->SetFillColor(_cut_line_col);
3462 arr->SetLineWidth(_cut_line_width);
3463 _cut_lines.push_back(arr);
3466 if (_drawleg && _legends.size() > 0 && gPad->FindObject(_legends.back())) {
3467 _legends.back()->Draw();
3477 xmin = std::max(xmin, gPad->PadtoX(gPad->GetUxmin()));
3478 xmax = std::min(xmax, gPad->PadtoY(gPad->GetUxmax()));
3479 ymin = std::max(ymin, gPad->PadtoX(gPad->GetUymin()));
3480 ymax = std::min(ymax, gPad->PadtoY(gPad->GetUymax()));
3483 if (uopt.find(
"T")!=std::string::npos) {
3486 if (uopt.find(
"B")!=std::string::npos) {
3489 if (uopt.find(
"L")!=std::string::npos) {
3492 if (uopt.find(
"R")!=std::string::npos) {
3501 if (minY<=0 && _logY) {
3502 std::cout <<
"Cannot set minimum <= 0 in logY scale! Call SetLogY(false) before calling SetMinY()!" << std::endl;
3515 std::cout <<
"Cannot set a log-scale if minimum is <= 0! Call SetMinY() before calling SetLogY()!" << std::endl;
3532 for (Int_t i=0;i<NMAXAUTOCOLORS;i++){
3533 if (i<ncolors) _auto_colors[i]= colors[i];
3534 else _auto_colors[i]= _line_color;
3541 for (Int_t i=0;i<NMAXAUTOCOLORS;i++){
3542 if (i<nmarkers) _auto_markers[i]= markers[i];
3543 else _auto_markers[i]= _marker_style;
3561 _webheader +=
"<html><head><title>" + title +
"</title></head><body>\n";
3562 _webheader +=
"<h2>" + title +
"</h2>\n<ol>\n";
3563 _webbody +=
"</ol>\n";
3572 _pdfcanvas =
new TCanvas(
"pdfcanvas",
"pdfcanvas", 800, 630);
3573 _headpad =
new TPad(
"header",
"header", 0, 0.95, 1, 1, 0);
3574 _headpad->SetNumber(1);
3576 _bodypad =
new TPad(
"body",
"body", 0, 0, 1, 0.95, 0);
3577 _bodypad->SetNumber(2);
3583 std::cout << _pdfpath << std::endl;
3585 gPad->Print((_pdfpath+
"[").c_str());
3592 if (_webpath !=
"") {
3593 TString safename = name;
3594 safename = safename.ReplaceAll(
" ",
"_");
3595 gPad->SaveAs((_webpath +
"/" + safename.Data() +
".png").c_str());
3596 _webheader += std::string(
"<li><a href=\"#") + safename.Data() +
"\">" + name +
"</a></li>\n";
3597 _webbody += std::string(
"<p><a name=\"") + safename.Data() +
"\"></a>" + name +
"</p>\n";
3598 _webbody += std::string(
"<p><img src=\"") + safename.Data() +
".png\" alt=\"" + name +
"\"/></p>\n";
3601 if (_pdfpath !=
"") {
3602 TVirtualPad* currpad = gPad;
3604 if (currpad && currpad == _bodypad) {
3610 l.DrawLatex(0.5, 0.5, name.c_str());
3614 _pdfcanvas->Print(_pdfpath.c_str());
3618 currpad->Print(_pdfpath.c_str());
3626 if (_webpath !=
"") {
3627 _webbody +=
"</body></html>\n";
3628 std::ofstream outfile;
3629 outfile.open((_webpath+
"/index.html").c_str());
3630 outfile << _webheader << _webbody;
3633 if (_pdfpath !=
"") {
3634 gPad->Print((_pdfpath+
"]").c_str());
3641 size_t pre = 0, pos;
3643 std::string s = path;
3646 if (s[s.size() - 1] !=
'/') {
3651 while ((pos = s.find_first_of(
"/", pre))) {
3652 dir = s.substr(0, pos++);
3654 if (dir.size() == 0)
3656 if ((mdret = mkdir(dir.c_str(), mode)) && errno != EEXIST) {
3671 if (opt.Contains(
"n")) mode+=1;
3672 if (opt.Contains(
"e")) mode+=10;
3673 if (opt.Contains(
"m")) mode+=100;
3674 if (opt.Contains(
"M")) mode+=200;
3675 if (opt.Contains(
"r")) mode+=1000;
3676 if (opt.Contains(
"R")) mode+=2000;
3677 if (opt.Contains(
"u")) mode+=10000;
3678 if (opt.Contains(
"o")) mode+=100000;
3679 if (opt.Contains(
"i")) mode+=1000000;
3680 if (opt.Contains(
"I")) mode+=2000000;
3681 if (opt.Contains(
"s")) mode+=10000000;
3682 if (opt.Contains(
"S")) mode+=20000000;
3683 if (opt.Contains(
"k")) mode+=100000000;
3684 if (opt.Contains(
"K")) mode+=200000000;
3685 if (mode == 1) mode = 1000000001;
3716 void DrawingToolsBase::DrawVariations(
const std::string& name, Int_t ipar,
int nx,
double xmin,
double xmax,
const std::string& root_opt,
const std::string& opt,
const std::string& leg){
3728 if (slevel==
"0" && leg!=
"")
3732 int statTemp = _stat_option;
3734 gStyle->SetOptStat(1110);
3736 TH1_h* hvar =
new TH1_h(
GetUniqueName(
"hvar").c_str(),leg.c_str(),nx,xmin,xmax);
3737 _saved_histos.push_back(hvar);
3741 for (Int_t itoy=0;itoy<con->
GetNToys();itoy++){
3743 for (UInt_t ipar2=0;ipar2<con->
_toys[itoy].npar;ipar2++)
3744 hvar->Fill(con->
_toys[itoy].variations[ipar2]);
3747 hvar->Fill(con->
_toys[itoy].variations[ipar]);
3750 hvar->SetTitle(_title.c_str());
3754 DrawHisto(hvar, _line_width, _line_color, _fill_style, root_opt, uopt,
"LE1P");
3756 hvar->GetXaxis()->SetTitle(
"variation");
3757 hvar->GetYaxis()->SetTitle(
"# toys");
3761 _legends.back()->Draw();
3775 std::string file2 = file;
3776 if (file==
"") file2 = _config_file;
3779 TChain* chain =
new TChain(
"header");
3780 chain->AddFile(file2.c_str());
3784 chain =
new TChain(
"config");
3785 chain->AddFile(file2.c_str());
3790 chain->SetBranchAddress(
"SoftwareVersion", version);
3792 Long64_t centry = chain->LoadTree(0);
3794 std::cout <<
"failed in reading SoftwareVersion !!!" << std::endl;
3797 Int_t nb = chain->GetEntry(0);
3799 std::cout <<
"failed in reading SoftwareVersion !!!" << std::endl;
3804 std::cout <<
"------ Software Version for original input files -------------------------------------" << std::endl;
3805 std::cout <<
"file: " << file << std::endl;
3806 std::cout <<
"version: " << version << std::endl;
3809 std::cout <<
"software version used to produce original input files: " << version << std::endl;
3818 std::string file2 = file;
3819 if (file==
"") file2 = _config_file;
3831 TChain* chain =
new TChain(
"config");
3832 chain->AddFile(file.c_str());
3834 char cmtpath[200]=
"unknown";
3835 char hostname[50]=
"unknown";
3836 char inputFile[200]=
"unknown";
3837 char OriginalFile[200]=
"unknown";
3839 chain->SetBranchAddress(
"CMTPATH", cmtpath);
3840 chain->SetBranchAddress(
"HOSTNAME", hostname);
3841 chain->SetBranchAddress(
"InputFile", inputFile);
3843 chain->SetBranchAddress(
"OriginalFile", OriginalFile);
3846 Long64_t centry = chain->LoadTree(0);
3848 std::cout <<
"failed in reading config tree !!!" << std::endl;
3851 Int_t nb = chain->GetEntry(0);
3853 std::cout <<
"failed in reading config tree !!!" << std::endl;
3858 std::cout <<
"====================== FILE INFORMATION ===================================" << std::endl;
3859 std::cout << std::endl;
3860 std::cout <<
"CMTPATH: " << cmtpath << std::endl;
3861 std::cout <<
"HOSTNAME: " << hostname << std::endl;
3862 std::cout <<
"Input file: " << inputFile << std::endl;
3863 std::cout <<
"original file: " << OriginalFile << std::endl;
3873 std::cout <<
"===========================================================================" << std::endl;
3883 TChain chain(
"config");
3884 chain.AddFile(file.c_str());
3892 _minAccumLevelToSave = 0;
3894 config->SetBranchAddress(
"MinAccumLevelToSave", &_minAccumLevelToSave);
3896 Long64_t centry = config->LoadTree(0);
3898 std::cout <<
"failed in reading config tree !!!" << std::endl;
3901 Int_t nb = config->GetEntry(0);
3903 std::cout <<
"failed in reading config tree !!!" << std::endl;
3910 std::string
DrawingToolsBase::AddRangeCut(
const std::string& var,
int nx,
double* xbins,
int ny,
double* ybins,
const std::string& cut,
const std::string& uopt) {
3917 std::stringstream scut;
3920 scut <<
"(" << cut2;
3923 scut <<
" && " << var <<
">=" << xbins[0];
3926 scut <<
" && " << var <<
"<" << xbins[nx];
3942 if (uroot_opt.find(
"SAMES")!=std::string::npos)
3944 else if (uroot_opt.find(
"SAME")!=std::string::npos)
3957 if (uroot_opt.find(
"SAMES")!=std::string::npos){
3958 uroot_opt = uroot_opt.replace(uroot_opt.find(
"SAMES"), 5, std::string(
""));
3961 else if (uroot_opt.find(
"SAME")!=std::string::npos){
3962 uroot_opt = uroot_opt.replace(uroot_opt.find(
"SAME"), 4, std::string(
""));
3977 std::vector<TLegendEntry*> entries;
3980 while (leg0->GetNRows()>0){
3981 entries.push_back(
new TLegendEntry(leg0->GetEntry()->GetObject(), leg0->GetEntry()->GetLabel(), leg0->GetEntry()->GetOption()));
3982 leg0->DeleteEntry();
3986 if (drawUtils::legendEntryHeight>0)
3987 leg0->SetY1NDC(leg0->GetY2NDC());
3990 for (UInt_t i=0;i<entries.size();i++){
3991 const char* label = entries[i]->GetLabel();
3992 const char* opt = entries[i]->GetOption();
3993 if ((Int_t)i==index && new_label!=
"") label = new_label.c_str();
3994 if ((Int_t)i==index && new_opt!=
"" ) opt = new_opt.c_str();
4009 std::vector<TLegendEntry*> entries;
4012 while (leg0->GetNRows()>0){
4013 entries.push_back(
new TLegendEntry(leg0->GetEntry()->GetObject(), leg0->GetEntry()->GetLabel(), leg0->GetEntry()->GetOption()));
4014 leg0->DeleteEntry();
4018 if (drawUtils::legendEntryHeight>0)
4019 leg0->SetY1NDC(leg0->GetY2NDC());
4023 for (UInt_t i=0;i<entries.size();i++){
4024 if ((Int_t)i!=index)
4035 std::string DrawingToolsBase::ConvertCutForTruthTree(
const std::string cut,
bool replace_selmu) {
4038 std::string cut2 = cut;
4042 size_t pos = cut2.find(
"accum_level[]");
4043 if (pos == std::string::npos)
break;
4044 std::string pre = cut2.substr(0,pos);
4045 std::string post = cut2.substr(pos+strlen(
"accum_level[]"));
4046 cut2 = pre +
"accum_level" + post;
4049 if ( ! replace_selmu)
return cut2;
4053 size_t pos = cut2.find(
"selmu_");
4054 if (pos == std::string::npos)
break;
4055 std::string pre = cut2.substr(0,pos);
4056 std::string post = cut2.substr(pos+strlen(
"selmu_"));
4057 cut2 = pre +
"truelepton_" + post;
4064 int DrawingToolsBase::GetNDOF(
const TH1* h1,
const TH1* h2) {
4067 for (
int i=1; i<=h1->GetXaxis()->GetNbins(); i++) {
4068 if (h1->GetBinContent(i)==0 && h2->GetBinContent(i)==0)
continue;
4079 if (h1->GetXaxis()->GetNbins() != h2->GetXaxis()->GetNbins())
4080 std::cout <<
"WARNING: the two histograms have different number of bins!" << std::endl;
4082 TH1* h1temp = (TH1*)h1->Clone();
4083 TH1* h2temp = (TH1*)h2->Clone();
4088 for (
int i=1; i<=h1temp->GetXaxis()->GetNbins(); i++) {
4089 h1temp->SetBinContent(i,h1->GetBinContent(i));
4090 h2temp->SetBinContent(i,h2->GetBinContent(i));
4091 h1temp->SetBinError(i,h1->GetBinError(i));
4092 h2temp->SetBinError(i,h2->GetBinError(i));
4097 for (
int i=1; i<=h1temp->GetXaxis()->GetNbins(); i++) {
4098 if (h1temp->GetBinContent(i)==0 && h2temp->GetBinContent(i)==0)
continue;
4100 double diff = h1temp->GetBinContent(i) - h2temp->GetBinContent(i);
4101 double err1 = h1temp->GetBinError(i);
4102 double err2 = h2temp->GetBinError(i);
4103 double errsq = pow(err1,2) + pow(err2,2);
4104 if (errsq == 0 || errsq != errsq) {
4106 std::cout <<
"ERROR errsq = 0! \n";
4108 std::cout <<
"WARNING diff=0 and errsq= 0 (set to 1) \n";
4113 chi2 += pow(diff,2) / errsq;
4156 if (sel().GetNEnabledSelections()>1){
4166 if (sel().GetNEnabledSelections()>1){
void Draw(int lc, int lw, int fc, int fs, const std::string &root_opt="", const std::string &opt="", const std::string &leg_opt="", int mode=0)
void DumpBranches() const
Dumps the list of branches.
void DumpCuts(Int_t branch=-1) const
Print out the index, name and title of each cut for a given branch (no argument for all branches) ...
void AddTotal(TH1_h *h1, TH1_h *hsyst=NULL)
Sets the total 1D histo if it does not exists or adds to the previous one when it exists...
void DumpSelections()
Print out the index, name and title of each selection for a given branch (no argument for all branche...
bool IsMultiType()
Is this a multi-type category ? (Can several types coexist?)
void AddCategory(const std::string &name, int ntypes, std::string *names, int *codes, int *colors, bool multi=false, bool noWarning=false, bool addNOTRUTH=true, bool addSAND=true)
void AddLegendEntry(TLegend *leg, TObject *ht, const std::string &type, const std::string &opt)
Add an entry to the Legend and resize it.
void DumpSteps(const std::string &branch="", bool onlycuts=false) const
Print out the index, name and title of each step for a given branch (no argument for all branches) ...
void BuildOptions()
Build the map of valid options with AddOption.
void ReadVersions(const std::string &file)
Read package names and versions use to produce this file.
void NormalizeVariableBinning(TH1 *h, int mode, const std::string &opt, Double_t &minwidth)
Normalize bin contents by bin width. return the with of the bin with minimum width.
Int_t GetNToys() const
Get and sets the number of toys.
void FillLegend(TLegend *leg)
Fill the legend with info in the HistoStack.
UInt_t GetNEnabledSelections()
Returns the number of enabled selections.
TH1_h * GetTotalStat1D()
Return the total 1D histo with only stat errors.
double GetMaximum(const std::string &opt="")
Get the maximum for the HistoStack.
TH1_h * GetTotalSyst1D()
Return the total 1D histo with only systematic errors.
void SetMinimum(double min)
Set the minimum for the HistoStack.
void NormalizeByArea(const std::string &uopt, double area=1)
normalize all histos in the stack by area
TrackCategoryDefinition & GetCategory(const std::string &categ)
Get a specific category.
void SetMaximum(double max)
Set the maximum for the HistoStack.
bool TreeHasVar(TTree *tree, const std::string &var)
Check wether the tree has a given variable.
void ReadSelections(const std::string &file)
std::vector< ToyVariationWrite > _toys
The variations for each of the toys.
void Add(TH1_h *h1, int lc, int lw, int fc, int fs, const std::string &leg)
Add a new 1D histogram to the stack, with fill colour "fc", line colour "lc".
bool Is1D()
Tells whether this is a 1D histo.
std::string GetString(int code)
convert integer to string
std::vector< StepBase * > GetCutsInBranch(const std::string &branch) const
Get all cuts in a given branch provided the branch alias.
std::vector< TrackTypeDefinition > & GetCategoryTypes(const std::string &categ)
Get the vector of track types in a given category.
bool ContainValidOptions(const std::string &uopt)
Check if the input string contails only valid options.
UInt_t GetNCuts(Int_t branch) const
Return the number of cuts in a given branch.
double GetMaximumWithError(const std::string &opt="")
Get the maximum for the HistoStack taking into account the upper error.
TH2_h * GetTotal2D()
Return the total 2D histo.
void DumpVersions()
dump package names and versions
std::string ToUpper(const std::string &str)
bool CheckInternalOption(const std::string &uopt, const std::string &this_opt)
Check if specific option appears in option field (don't check if it exists: Added with AddOption) ...
int GetNToys(TTree *tree)
get the number of weights in the tree
ConfigurationBase * GetConfiguration(Int_t index) const
return the configuration with a given index
SelectionBase * GetSelection(const std::string &name, bool print_error=true)
Return the selection that was registered with the given name. NULL if it does not exist...
TH1_h * GetTotal1D()
Return the total 1D histo.
bool Is2D()
Tells whether this is a 2D histo.
bool CheckOption(const std::string &uopt, const std::string &this_opt)
Check if specific option exists, and if so if it appears in option field.