本文整理汇总了C++中TH1F::DrawNormalized方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1F::DrawNormalized方法的具体用法?C++ TH1F::DrawNormalized怎么用?C++ TH1F::DrawNormalized使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1F
的用法示例。
在下文中一共展示了TH1F::DrawNormalized方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: plots_for_config
void plots_for_config(string toyfile, string smsfile, string massGlu, string massLSP) {
gROOT->SetStyle("Plain");
bool do_fat_line=false; // if you want to have HistLineWidth=1 and FuncWidth=1 as it was before instead of 2
setTDRStyle(do_fat_line);
gStyle->SetTextFont(42);
string massCut_ = "MassGlu==" + massGlu + "&&MassLSP==" + massLSP;
string massCut2_ = "massGlu==" + massGlu + "&&massLSP==" + massLSP;
TCut massCut(massCut_.c_str());
TCut massCut2(massCut2_.c_str());
string comp = "comparison_" + massGlu + "_" + massLSP;
TFile *_file = TFile::Open(smsfile.c_str());
TTree *point = (TTree*)_file->Get("events");
TH1F *jzb = new TH1F("jzb", "", 50, -600, 800);
point->Project("jzb", "jzb[1]", "id1==id2&&pfJetGoodNum>2&&abs(mll-91.2)<20" + massCut, "gof");
TFile *_filepa = TFile::Open(toyfile.c_str());
TTree *pointpa = (TTree*)_filepa->Get("events");
TH1F *jzbpa = new TH1F("jzbpa", "", 50, -600, 800);
pointpa->Project("jzbpa", "jzb", "njets>2 && nleptons==2" + massCut2);
jzbpa->SetLineColor(kRed);
jzbpa->GetXaxis()->SetTitle("JZB [GeV]");
jzb->GetXaxis()->SetTitle("JZB [GeV]");
TLegend *l1 = new TLegend(0.7, 0.75, 0.9, 0.85);
l1->SetFillColor(kWhite);
l1->SetTextFont(42);
l1->SetLineWidth(0);
l1->SetBorderSize(0);
l1->AddEntry(jzb, "SMS", "L");
l1->AddEntry(jzbpa, "SMS TOY", "L");
TCanvas *m1 = new TCanvas("m1");
m1->GetPad(0)->SetLogy(1);
m1->cd();
jzb->DrawNormalized();
jzbpa->DrawNormalized("SAME");
l1->Draw();
CompleteSave(m1,"Plots/" + comp);
delete m1;
return;
}
示例2: plotDistribution
//.........这里部分代码省略.........
<< delim << setw(left) << Form("%.3f %s %.4f",effdata4,pm,effdata4err) << setw(4)
<< delim << setw(left) << Form("%.3f %s %.4f",effdata5,pm,effdata5err) << setw(4)
<< delimend << endl;
cout << delimstart << setw(10) << "mc" << setw(4)
<< delim << setw(left) << Form("%.3f %s %.4f",effmc1,pm,effmc1err) << setw(4)
<< delim << setw(left) << Form("%.3f %s %.4f",effmc2,pm,effmc2err) << setw(4)
<< delim << setw(left) << Form("%.3f %s %.4f",effmc3,pm,effmc3err) << setw(4)
<< delim << setw(left) << Form("%.3f %s %.4f",effmc4,pm,effmc4err) << setw(4)
<< delim << setw(left) << Form("%.3f %s %.4f",effmc5,pm,effmc5err) << setw(4)
<< delimend << endl;
cout << delimstart << setw(10) << "data/mc" << setw(4)
<< delim << setw(left) << Form("%.2f %s %.2f",ratio1,pm,ratio1err) << setw(4)
<< delim << setw(left) << Form("%.2f %s %.2f",ratio2,pm,ratio2err) << setw(4)
<< delim << setw(left) << Form("%.2f %s %.2f",ratio3,pm,ratio3err) << setw(4)
<< delim << setw(left) << Form("%.2f %s %.2f",ratio4,pm,ratio4err) << setw(4)
<< delim << setw(left) << Form("%.2f %s %.2f",ratio5,pm,ratio5err) << setw(4)
<< delimend << endl;
//--------------------------------------
// draw stuff
//--------------------------------------
hdata->Scale(1.0/hdata->Integral());
hmc->Scale(1.0/hmc->Integral());
if( log ) hmc->GetYaxis()->SetRangeUser(0.0001,5);
else hmc->GetYaxis()->SetRangeUser(0.0,1);
hmc->GetXaxis()->SetTitle(xtitle);
hmc->SetLineColor(2);
hmc->SetMarkerColor(2);
hmc->DrawNormalized("hist");
hmc->DrawNormalized("sameE1");
hdata->SetLineColor(4);
hdata->SetMarkerColor(4);
hdata->Draw("sameE1");
grdata->SetLineColor(6);
grmc->SetLineColor(7);
//grdata->Draw("sameP");
//grmc->Draw("sameP");
TLegend *leg = new TLegend(0.6,0.7,0.8,0.9);
leg->AddEntry(hdata , "data" , "lp");
leg->AddEntry(hmc , "MC" , "lp");
leg->SetBorderSize(0);
leg->SetFillColor(0);
leg->Draw();
TLatex *t = new TLatex();
t->SetNDC();
if( TString(plottitle).Contains("el") ) t->DrawLatex(0.6,0.6,"electrons");
if( TString(plottitle).Contains("mu") ) t->DrawLatex(0.6,0.6,"muons");
if( TString(plottitle).Contains("0j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 0");
if( TString(plottitle).Contains("1j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 1");
if( TString(plottitle).Contains("2j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 2");
if( TString(plottitle).Contains("3j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 3");
if( TString(plottitle).Contains("4j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 4");
//--------------------------------------
// draw residual plots
//--------------------------------------
示例3: plotDist
void plotDist(char* drawVar="sumJetMass_pt50",char* binning="(20,0,2000)"){
gROOT->ProcessLine(".L ~/tdrstyle.C");
setTDRStyle();
// fill signal tree and draw
///////////////////////////////////////
TChain* sigTree = new TChain("TreeFiller/AnalysisTree");
cout << sampleNames[ kT1tttt ] << " " << sigTree->Add( fileNames[ kT1tttt ] ) << endl;
char drawString[150];
sprintf(drawString,"%s>>sig%s",drawVar,binning);
sigTree->Draw(drawString,"nJets_pt50>3");
TH1F* sig = (TH1F*) gDirectory->Get("sig");
sig->SetLineWidth(2);
sig->SetLineColor(colorCodes[kT1tttt]);
TLegend* leg = new TLegend(.9,.9,.7,.7);
leg->SetFillColor(0);
leg->AddEntry(sig,sampleNames[ kT1tttt ],"l");
// Fill background tree and draw
//////////////////////////////////////
const int numBkg = 4;
TChain* bkgTree[numBkg];
TH1F* bkg[numBkg];
for( unsigned int iBkg = 0 ; iBkg < numBkg ; iBkg++){
//if( iBkg == 1 || iBkg==2 || iBkg==3 ) continue;
bkgTree[iBkg] = new TChain("TreeFiller/AnalysisTree");
cout << sampleNames[ iBkg ] << " " << bkgTree[iBkg]->Add( fileNames[ iBkg ] ) << endl;
sprintf(drawString,"%s>>bkg%i%s",drawVar,iBkg,binning);
bkgTree[iBkg]->Draw(drawString,"nJets_pt50>3");
char histoName[150];
sprintf(histoName,"bkg%i",iBkg);
bkg[iBkg] = (TH1F*) gDirectory->Get(histoName);
bkg[iBkg]->SetLineWidth(2);
bkg[iBkg]->SetLineColor(colorCodes[iBkg]);
leg->AddEntry(bkg[iBkg],sampleNames[ iBkg ],"l");
}
// hacking normalizations...
//sig->Scale(1000*4.e-2/50000.);
//bkg[kQCD]->Scale(1000*2.99e10/100000.);
sig->DrawNormalized("");
for( unsigned int iBkg = 0 ; iBkg < numBkg ; iBkg++){
//if( iBkg == 1 || iBkg==2 || iBkg==3 ) continue;
bkg[iBkg]->DrawNormalized("SAME");
}
leg->Draw();
}
示例4: toyMC
void toyMC(int nsteps = 1e6) {
Float_t LA = 9.2;
Float_t LB = 10.3;
Float_t SF = 492./LB;
Float_t eSF = TMath::Sqrt(23.*23.+19.7*19.7)/LB;
// Float_t OF = 358./LA;
// Float_t eOF = 27./LA;
Float_t OF = 358./LB;
Float_t eOF = 31./LB;
Float_t SigB = 188.+238-414;
TH1F* hSig = new TH1F("hSig ; SF-R_{SF/OF}#timesOF ; ","Signal component",600,-100.,500.);
hSig->SetLineColor(kRed+2);
TRandom3* ran = new TRandom3();
for ( int i=0; i<nsteps; ++i ) {
Float_t nBSF = ran->Gaus(SF*LB,eSF*LB);
Float_t nBOF = ran->Gaus(OF*LB,eOF*LB);
Float_t rsfof = ran->Gaus(1.0,0.05);
hSig->Fill(nBSF-nBOF*rsfof);
}
TCanvas* mycan = new TCanvas("mycan","",100,10,900,600);
mycan->SetLogy();
TH1F* hSigNorm = hSig->DrawNormalized("");
hSigNorm->SetMinimum(1e-5);
hSigNorm->Draw();
// Find 95% CL range
float integral = 0;
int binStart = -1;
while ( integral <= 0.025 ) {
++binStart;
integral += hSigNorm->GetBinContent(binStart);
}
std::cout << integral << " up to " << hSigNorm->GetBinCenter(binStart) << std::endl;
integral = 0;
int binEnd = hSigNorm->GetNbinsX()+2;
while ( integral <= 0.025 ) {
--binEnd;
integral += hSigNorm->GetBinContent(binEnd);
}
std::cout << integral << " up to " << hSigNorm->GetBinCenter(binEnd) << std::endl;
// Draw 95% CL
TBox* range95 = new TBox(hSigNorm->GetBinCenter(binStart),hSigNorm->GetMinimum(),hSigNorm->GetBinCenter(binEnd),1.2*hSigNorm->GetMaximum());
range95->SetFillColor(kBlue-9);
range95->SetFillStyle(1000);
range95->SetLineColor(range95->GetFillColor());
range95->Draw();
hSigNorm->SetTitle("hSigNorm; \"S\" #equiv SF - R_{SF/OF}#timesOF ; pdf");
hSigNorm->Draw("same");
std::cout << "Integrating from 0 to " << SigB << ": " << std::endl;
std::cout << hSigNorm->Integral(0,hSigNorm->FindBin(SigB)) <<std::endl;
TLegend* legend = new TLegend(0.6,0.7,0.95,0.9,"","brNDC");
legend->SetBorderSize(0);
legend->AddEntry(hSigNorm,"Expected \"S\" for block B","l");
legend->AddEntry(range95,"95% region","f");
legend->Draw();
mycan->RedrawAxis();
mycan->SaveAs("toyMCexp.pdf");
TArrow* a = new TArrow(SigB,hSigNorm->GetMaximum(),SigB,hSigNorm->GetMinimum()*1.1,0.02);
a->SetLineColor(kBlue+2);
a->Draw();
TLegend* legend2 = new TLegend(0.6,0.6,0.95,0.7,"","brNDC");
legend2->SetBorderSize(0);
legend2->AddEntry(a,"Observed (p-value 0.6%)","l");
legend2->Draw();
mycan->SaveAs("toyMC.pdf");
}
示例5: if
//.........这里部分代码省略.........
float max = 0;
max=1.2*d->GetMaximum();
std::cout << "max = " << max << std::endl;
d->GetYaxis()->SetTitle(yLabel);
d->GetXaxis()->SetTitle(xLabel);
if(logy){
max*=10;
d->GetYaxis()->SetRangeUser(0.1,max);
c->SetLogy();
} else {
d->GetYaxis()->SetRangeUser(0,max);
}
for(int i=0; i < nHist; i++){
//TString mcHistName; mcHistName+=i; mcHistName+="_hist";
TString mcHistName; mcHistName+="hist_";mcHistName+=i;
TH1F *s = (TH1F *) gROOT->FindObject(mcHistName);
s->SetStats(0);
s->SetTitle("");
if(s==NULL) continue;
std::cout << "nEvents signal: " << s->Integral() << "\t" << s->GetEntries() << std::endl;
if(d->Integral()==0 && s->Integral()==0){
delete c;
return NULL;
}
if(logy){
s->GetYaxis()->SetRangeUser(0.1,max);
} else {
s->GetYaxis()->SetRangeUser(0,max);
}
s->GetYaxis()->SetTitle(yLabel);
s->GetXaxis()->SetTitle(xLabel);
s->SetMarkerStyle(20);
s->SetMarkerSize(1);
s->SetMarkerColor(colors[i]);
s->SetFillStyle(fillstyle[i]);
s->SetFillColor(colors[i]);
s->SetLineColor(colors[i]);
s->SetLineWidth(2);
TH1F* s_norm = NULL;
if(i==0) s_norm = (TH1F *) (s->DrawNormalized("hist", d->Integral()));
else s_norm = (TH1F *) (s->DrawNormalized("hist same", d->Integral()));
if(logy){
//d_norm->GetYaxis()->SetRangeUser(0.1,max);
s_norm->GetYaxis()->SetRangeUser(0.1,max);
} else {
//d_norm->GetYaxis()->SetRangeUser(0,max);
s_norm->GetYaxis()->SetRangeUser(0,max);
}
if(mcLabel_vec[i] !="") leg->AddEntry(s,mcLabel_vec[i], "lf");
// TH1F *sRatio = (TH1F *) s->Clone(mcHistName+"_ratio");
// sRatio->Divide(d);
// if(ratio){
// pad2->cd();
// if(i==0) sRatio->Draw();
// else sRatio->Draw("same");
// }
// pad1->cd();
}
//TH1F* d_norm = s_norm;
//if(d!=s) d_norm = (TH1F *) (d->DrawNormalized("p same", d->Integral()));
std::cout<<"After normalization "<<std::endl;
//std::cout<<"s_norm" <<s_norm->Integral()<<std::endl;
std::cout<<"data Integral " <<d->Integral()<<std::endl;
if(nHist>0) d->Draw("p same");
else d->Draw("p");
// std::cout << "Variable & Data & Simulation \\" << std::endl;
// std::cout << "Mean & " << d->GetMean() << " " << d->GetMeanError()
// << " & " << s_norm->GetMean() << " " << s_norm->GetMeanError() << " \\" << std::endl;
// std::cout << "Std. dev. & " << d->GetRMS() << " " << d->GetRMSError()
// << " & " << s_norm->GetRMS() << " " << s_norm->GetRMSError() << " \\" << std::endl;
// std::cout << "\\hline" << std::endl;
// std::cout << "$\\Chi^2$ " << d->Chi2Test(s_norm, "UW CHI2/NDF NORM") << std::endl;
if(mcLabel_vec.size()!=0) leg->Draw();
TPaveText *pv = new TPaveText(0.25,0.95,0.65,1,"NDC");
pv->AddText("CMS Preliminary 2016");
pv->SetFillColor(0);
pv->SetBorderSize(0);
pv->Draw();
watch.Stop();
watch.Print();
c->SaveAs(outputPath+label4Print+".png","png");
c->SaveAs(outputPath+label4Print+".pdf","pdf");
c->SaveAs(outputPath+label4Print+".eps","eps");
c->SaveAs(outputPath+label4Print+".C","C");
return c;
}
示例6: TCanvas
//.........这里部分代码省略.........
//d->SaveAs("tmp/d_hist.root");
s->SaveAs("tmp/s_hist.root");
s2->SaveAs("tmp/s2_hist.root");
yLabel.Form("Events /(%.2f %s)", s->GetBinWidth(2), yLabelUnit.Data());
float max = 1.1 * std::max(
d->GetMaximum(),///d->Integral(),
s->GetMaximum() ///s->Integral()
);
max=1.1*d->GetMaximum();
std::cout << "max = " << max << std::endl;
std::cout << "nEvents data: " << d->Integral() << "\t" << d->GetEntries() << std::endl;
std::cout << "nEvents signal: " << s->Integral() << "\t" << s->GetEntries() << std::endl;
std::cout << "nEvents signal2: " << s2->Integral() << "\t" << s2->GetEntries() << std::endl;
if(logy){
max*=10;
d->GetYaxis()->SetRangeUser(0.1,max);
s->GetYaxis()->SetRangeUser(0.1,max);
s2->GetYaxis()->SetRangeUser(0.1,max);
c->SetLogy();
} else {
d->GetYaxis()->SetRangeUser(0,max);
s->GetYaxis()->SetRangeUser(0,max);
s2->GetYaxis()->SetRangeUser(0,max);
}
s->GetYaxis()->SetTitle(yLabel);
s->GetXaxis()->SetTitle(xLabel);
s2->GetYaxis()->SetTitle(yLabel);
s2->GetXaxis()->SetTitle(xLabel);
d->GetYaxis()->SetTitle(yLabel);
d->GetXaxis()->SetTitle(xLabel);
d->SetMarkerStyle(20);
d->SetMarkerSize(1);
if(d != s){
s->SetMarkerStyle(20);
s->SetMarkerSize(1);
s->SetFillStyle(3001);
s->SetFillColor(kRed);
}
if(s2 != s){
//s2->SetMarkerStyle(1);
//s2->SetMarkerSize(0);
//s->SetFillStyle(0);
//s->SetFillColor(kB);
s2->SetLineWidth(3);
s2->SetLineColor(kBlack);
}
TH1F* s_norm = (TH1F *) (s->DrawNormalized("hist", d->Integral()));
TH1F* s2_norm = (TH1F *) (s2->DrawNormalized("hist same", d->Integral()));
//TH1F* d_norm = s_norm;
//if(d!=s) d_norm = (TH1F *) (d->DrawNormalized("p same", d->Integral()));
if(d!=s) d->Draw("p same");
if(logy){
//d_norm->GetYaxis()->SetRangeUser(0.1,max);
s_norm->GetYaxis()->SetRangeUser(0.1,max);
c->SetLogy();
} else {
//d_norm->GetYaxis()->SetRangeUser(0,max);
s_norm->GetYaxis()->SetRangeUser(0,max);
}
std::cout << "Variable & Data & Simulation & Simulation2 \\" << std::endl;
std::cout << "Mean & " << d->GetMean() << " " << d->GetMeanError()
<< " & " << s_norm->GetMean() << " " << s_norm->GetMeanError()
<< " & " << s2_norm->GetMean() << " " << s2_norm->GetMeanError()
<< " \\" << std::endl;
std::cout << "Std. dev. & " << d->GetRMS() << " " << d->GetRMSError()
<< " & " << s_norm->GetRMS() << " " << s_norm->GetRMSError()
<< " & " << s2_norm->GetRMS() << " " << s2_norm->GetRMSError()
<< " \\" << std::endl;
std::cout << "\\hline" << std::endl;
std::cout << "$\\Chi^2$ " << d->Chi2Test(s_norm, "UW CHI2/NDF NORM") << std::endl;
TLegend *leg = new TLegend(0.6,0.8,1,1);
if(dataLabel !="") leg->AddEntry(d,dataLabel,"p");
if(mcLabel !="") leg->AddEntry(s,mcLabel, "lf");
if(mc2Label !="") leg->AddEntry(s2,mc2Label, "l");
leg->SetBorderSize(1);
leg->SetFillColor(0);
leg->SetTextSize(0.04);
if(dataLabel !="" && mcLabel !="") leg->Draw();
//c->GetListOfPrimitives()->Add(leg,"");
TPaveText *pv = new TPaveText(0.23,0.95,0.6,1,"NDC");
pv->AddText("CMS Preliminary 2016");
pv->SetFillColor(0);
pv->SetBorderSize(0);
pv->Draw();
return c;
}
示例7: probabilityDirection
//.........这里部分代码省略.........
for (int j = 0; j < _vertex; j++)
{
if (_pdg[j] == 5)
{
bs.push_back(j);
}
else//if (_pdg[j] == -5)
{
bbars.push_back(j);
}
}
for (int k = 0; k < bbars.size(); k++)
{
/*if (
_bbarIPdistance < 0.50
|| _bbartotalnumber > 5
|| _bbartotalnumber < 3
|| _bbarnumber < 2
|| _bbartotalnumber - _bbarnumber < 2
)
{
continue;
}*/
if (bbars.size() > 1)
{
std::cout << "Nb: " << i << '\n';
probhist->Fill(_probability[bbars[k]]);
chihist->Fill(_chi2[bbars[k]]);
}
else
{
probhist_non->Fill(_probability[bbars[0]]);
chihist_non->Fill(_chi2[bbars[0]]);
}
}
for (int m = 0; m < bs.size(); m++)
{
/*if (
_bIPdistance < 0.50
|| _btotalnumber > 5
//|| _btotalnumber < 3
|| _bnumber < 2
|| _btotalnumber - _bnumber < 2
)
{
continue;
}*/
if (bs.size() > 1)
{
probhist->Fill(_probability[bs[m]]);
chihist->Fill(_chi2[bs[m]]);
}
else
{
probhist_non->Fill(_probability[bs[0]]);
chihist_non->Fill(_chi2[bs[0]]);
}
}
if ( bbars.size() > 0)
{
totalcounter++;
}
if ( bs.size() > 0)
{
totalcounter++;
}
}
boxPad->cd();
probhist_non->SetMarkerStyle(20);
chihist_non->SetMarkerStyle(20);
chihist_non->SetMarkerColor(kBlack);
chihist_non->SetMarkerSize(0.7);
chihist_non->GetXaxis()->SetTitle("#chi^2");
chihist->SetFillColor(kYellow);
chihist->GetXaxis()->SetTitle("#chi^{2}");
probhist_non->SetMarkerColor(kBlack);
probhist_non->SetMarkerSize(0.7);
probhist_non->GetXaxis()->SetTitle("P(V)");
//probhist->GetYaxis()->SetRange(0,0.1);
//probhist_non->GetYaxis()->SetRange(0,0.1);
probhist->SetMaximum(2000);
probhist_non->SetMaximum(2000);
probhist_non->SetMinimum(0);
probhist->SetMinimum(0);
probhist->SetFillColor(kYellow);
probhist->GetXaxis()->SetTitle("P(V)");
probhist->DrawNormalized("same");
probhist_non->DrawNormalized("ex0psame");
boxPad->SetGrid();
box1Pad->cd();
box1Pad->SetLogy();
chihist->DrawNormalized("");
chihist_non->DrawNormalized("ex0psame",1);
box1Pad->SetGrid();
box1Pad->Modified();
boxPad->Modified();
std::cout << "Statistics: " << probhist->GetEntries() << " with ternary; " << probhist_non->GetEntries() << " without ternary; " << totalcounter << " total; " << counter << " discarded\n";
std::cout << "Mean: " << probhist->GetMean() << " with ternary; " << probhist_non->GetMean() << " without ternary;\n";
}
示例8: plotShape
//.........这里部分代码省略.........
c1->SetLogy(1);
*/
TH1F *ttbarH = (TH1F *) ttbar7H->Clone("ttbarH");
ttbarH->Add(ttbar10H);
totalH->SetLineColor(kBlue);
totalH->SetLineWidth(2);
//totalH->DrawNormalized("hist");
//totalPredH->Draw("hist same");
qcd1predH->SetLineColor(kBlue);
qcd2predH->SetLineColor(kRed);
qcd3predH->SetLineColor(kGreen);
qcd4predH->SetLineColor(kOrange);
qcd5predH->SetLineColor(kViolet);
qcd6predH->SetLineColor(kCyan);
//qcd1predH->Draw("hist same");
//qcd2predH->Draw("hist same");
//qcd3predH->Draw("hist same");
//qcd4predH->Draw("hist same");
//qcd5predH->Draw("hist same");
//qcd6predH->Draw("hist same");
totalH->SetMarkerSize(0);
totalH->SetLineWidth(3);
totalH->SetLineColor(kBlack);
totalH->GetXaxis()->SetTitle(title.c_str());
totalH->GetYaxis()->SetTitle("Fraction of Events");
totalH->GetYaxis()->SetTitleOffset(1.25);
totalH->DrawNormalized("hist");
ttbarH->SetLineColor(kRed - 1);
ttbarH->SetLineWidth(3);
ttbarH->DrawNormalized("hist same");
signal1H->SetLineColor(kGreen + 1);
signal1H->SetLineWidth(2);
signal1H->DrawNormalized("hist same");
signalH->SetLineColor(kViolet);
signalH->SetLineWidth(2);
signalH->DrawNormalized("hist same");
signal3H->SetLineColor(kCyan + 2);
signal3H->SetLineWidth(2);
signal3H->DrawNormalized("hist same");
TLegend *leg = new TLegend(0.1,0.9,0.9,0.99);
leg->SetNColumns(3);
leg->AddEntry(totalH, btag_string, "");
leg->AddEntry(totalH, "QCD", "l");
leg->AddEntry(ttbarH, "t#bar{t}", "l");
leg->AddEntry(signal1H, "Narrow Z' (1 TeV)", "l");
leg->AddEntry(signalH, "Narrow Z' (2 TeV)", "l");
leg->AddEntry(signal3H, "Narrow Z' (3 TeV)", "l");
leg->SetFillColor(0);
leg->Draw("same");
TLatex *cmsLabel = new TLatex();
cmsLabel->SetNDC();
//cmsLabel.DrawLatex(0.1,0.9, "CMS Preliminary, #sqrt{s} = 8 TeV, 19.7 fb^{-1}");
//cmsLabel->DrawLatex(0.8, 0.9, label.c_str());
//qcd1H->Draw("same");