本文整理汇总了C++中TH1F::SetNdivisions方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1F::SetNdivisions方法的具体用法?C++ TH1F::SetNdivisions怎么用?C++ TH1F::SetNdivisions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1F
的用法示例。
在下文中一共展示了TH1F::SetNdivisions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetStyle
void
HTT_TT_X(bool scaled=true, bool log=false, float min=0., float max=-1., const char* inputfile="root/$HISTFILE", const char* directory="$CATEGORY")
{
// define common canvas, axes pad styles
SetStyle(); gStyle->SetLineStyleString(11,"20 10");
// determine category tag
const char* category_extra = "";
if(std::string(directory) == std::string("emu_0jet_low" )){ category_extra = "0 jet, low p_{T}"; }
if(std::string(directory) == std::string("emu_0jet_high" )){ category_extra = "0 jet, high p_{T}"; }
if(std::string(directory) == std::string("emu_boost_low" )){ category_extra = "1 jet, low p_{T}"; }
if(std::string(directory) == std::string("emu_boost_high")){ category_extra = "1 jet, high p_{T}"; }
if(std::string(directory) == std::string("emu_vbf" )){ category_extra = "2 jet (VBF)"; }
if(std::string(directory) == std::string("emu_nobtag" )){ category_extra = "No B-Tag"; }
if(std::string(directory) == std::string("emu_btag" )){ category_extra = "B-Tag"; }
const char* dataset;
if(std::string(inputfile).find("7TeV")!=std::string::npos){dataset = "CMS Preliminary, ZH#rightarrow#lltau#tau, 4.9 fb^{-1} at 7 TeV";}
if(std::string(inputfile).find("8TeV")!=std::string::npos){dataset = "CMS Preliminary, ZH#rightarrowll#tau#tau, 19.4 fb^{-1} at 8 TeV";}
#ifdef MSSM
if(std::string(inputfile).find("8TeV")!=std::string::npos){dataset = "CMS Preliminary, H#rightarrow#tau#tau, 19.4 fb^{-1} at 8 TeV";}
#endif
TFile* input = new TFile(inputfile);
TH1F* ZZ = refill((TH1F*)input->Get(TString::Format("%s/ZZ" , directory)), "ZZ"); InitHist(ZZ, "", "", kMagenta-10, 1001);
TH1F* GGToZZ2L2L = refill((TH1F*)input->Get(TString::Format("%s/GGToZZ2L2L" , directory)), "GGToZZ2L2L"); InitHist(GGToZZ2L2L, "", "", kMagenta-10, 1001);
TH1F* Zjets = refill((TH1F*)input->Get(TString::Format("%s/Zjets" , directory)), "Zjets" ); InitHist(Zjets , "", "", kRed + 2, 1001);
#ifndef DROP_SIGNAL
TH1F* ZH_htt = refill((TH1F*)input->Get(TString::Format("%s/ZH_htt" , directory)+"125"), "ZH_htt" ); InitSignal(ZH_htt); ZH_htt->Scale(SIGNAL_SCALE);
TH1F* ZH_hww = refill((TH1F*)input->Get(TString::Format("%s/ZH_hww" , directory)+"125"), "ZH_hww" ); InitSignal(ZH_hww); ZH_hww->Scale(SIGNAL_SCALE);
#endif
TH1F* data = refill((TH1F*)input->Get(TString::Format("%s/data_obs", directory)), "data", true);
InitHist(data, "#bf{m_{#tau#tau} [GeV]}", "#bf{dN/dm_{#tau#tau} [1/GeV]}"); InitData(data);
TH1F* ref=(TH1F*)ZZ->Clone("ref");
ref->Add(GGToZZ2L2L);
ref->Add(Zjets );
double unscaled[5];
unscaled[0] = ZZ->Integral();
unscaled[1] = GGToZZ2L2L->Integral();
unscaled[2] = Zjets ->Integral();
#ifndef DROP_SIGNAL
unscaled[3] = ZH_htt ->Integral();
unscaled[4] = ZH_hww ->Integral();
#endif
if(scaled){
rescale(ZZ, 1);
rescale(GGToZZ2L2L, 2);
rescale(Zjets, 3);
#ifndef DROP_SIGNAL
rescale(ZH_htt, 4);
rescale(ZH_hww, 5);
#endif
}
TH1F* scales[5];
scales[0] = new TH1F("scales-ZZ", "", 5, 0, 5);
scales[0]->SetBinContent(1, unscaled[0]>0 ? (ZZ->Integral()/unscaled[0]-1.) : 0.);
scales[1] = new TH1F("scales-GGToZZ2L2L", "", 5, 0, 5);
scales[1]->SetBinContent(2, unscaled[1]>0 ? (GGToZZ2L2L->Integral()/unscaled[1]-1.) : 0.);
scales[2] = new TH1F("scales-Zjets" , "", 5, 0, 5);
scales[2]->SetBinContent(3, unscaled[2]>0 ? (Zjets ->Integral()/unscaled[2]-1.) : 0.);
#ifndef DROP_SIGNAL
scales[3] = new TH1F("scales-ZH_htt" , "", 5, 0, 5);
scales[3]->SetBinContent(4, unscaled[3]>0 ? (ZH_htt ->Integral()/unscaled[3]-1.) : 0.);
scales[4] = new TH1F("scales-ZH_hww" , "", 5, 0, 5);
scales[4]->SetBinContent(5, unscaled[4]>0 ? (ZH_hww ->Integral()/unscaled[4]-1.) : 0.);
#endif
GGToZZ2L2L->Add(Zjets);
ZZ ->Add(GGToZZ2L2L);
if(log){
#ifndef DROP_SIGNAL
ZH_htt ->Add(ZH_hww );
#endif
}
else{
#ifndef DROP_SIGNAL
ZH_htt ->Add(ZH_hww);
#endif
}
/*
mass plot before and after fit
*/
TCanvas* canv = MakeCanvas("canv", "histograms", 600, 600);
canv->cd();
if(log){ canv->SetLogy(1); }
#if defined MSSM
if(!log){ data->GetXaxis()->SetRange(0, data->FindBin(350)); } else{ data->GetXaxis()->SetRange(0, data->FindBin(1000)); };
#else
data->GetXaxis()->SetRange(0, data->FindBin(350));
#endif
data->SetNdivisions(505);
data->SetMinimum(min);
float maxZZ=ZZ->GetBinContent(ZZ->GetMaximumBin()); float maxdata=data->GetBinContent(data->GetMaximumBin());
if (maxdata>maxZZ)
//.........这里部分代码省略.........
示例2: Ifit
//___________________________________________________________________________
Double_t* Ifit(int shift, Double_t& dataResult, Double_t& dataErr, std::string dataFile,
TH1D* hsig, TH1D* hbkg, TH1D* hEGdata, Double_t* FitPar,
int ptbin=30, char EBEE[10]="EB", int fit_data=2)
{
printf(" *** calling Ifit for %s , ptbin %d *** \n\n", EBEE,ptbin);
cout << "The number of bins are: " << endl;
cout << "hdata nbins = " << hEGdata->GetNbinsX() << endl;
cout << "hsig nbins = " << hsig->GetNbinsX() << endl;
cout << "hbkg nbins = " << hbkg->GetNbinsX() << endl;
TCanvas *c1 = new TCanvas("HF1", "Histos1", 0, 0, 600, 600);
gStyle->SetOptFit(0);
if(fit_data != 3) dataColl.clear();
sigColl.clear();
bkgColl.clear();
totalColl.clear();
ctauColl.clear();
Para.clear();
Para_err.clear();
info.clear();
info_err.clear();
float ptmax=0.;
if(ptbin== 21) ptmax= 23;
if(ptbin== 23) ptmax= 26;
if(ptbin== 26) ptmax= 30;
if(ptbin== 30) ptmax= 35;
if(ptbin== 35) ptmax= 40;
if(ptbin== 40) ptmax= 45;
if(ptbin== 45) ptmax= 50;
if(ptbin== 50) ptmax= 60;
if(ptbin== 60) ptmax= 85;
if(ptbin== 85) ptmax= 120;
if(ptbin== 120) ptmax= 300;
if(ptbin== 300) ptmax= 500;
Double_t* fitted = new Double_t[6];
fitted[0] = 0.; fitted[1] = 0.; fitted[2] = 0.; fitted[3] = 0.;
fitted[4] = 0.; fitted[5] = 0.;
char hname[30];
hsig->SetLineColor(1);
hbkg->SetLineColor(1);
hsig->SetNdivisions(505,"XY");
hbkg->SetNdivisions(505,"XY");
hsig->SetTitle("");
hbkg->SetTitle("");
hsig->SetXTitle("combined ISO (GeV)");
hbkg->SetXTitle("combined ISO (GeV)");
TH1F *hsum = (TH1F*)hsig->Clone();
hsum->Add(hbkg,1);
float ntemplate = 1.;
if (hsum->Integral()>1.) ntemplate = hsum->Integral();
float sigfrac = hsig->Integral()/ntemplate*0.8;
TH1F *hsum_norm = (TH1F*)hsum->Clone();
hsum_norm->Scale(1./hsum->Integral());
TH1F *hdata = new TH1F();
int ndata=0;
if ( fit_data==1 ) {
hdata = (TH1F*)hEGdata->Clone();
ndata = (int)hdata->Integral();
for(int ibin=1; ibin<=hdata->GetNbinsX(); ibin++){
for(int ipoint=0; ipoint<hdata->GetBinContent(ibin); ipoint++) {
dataColl.push_back(hdata->GetBinCenter(ibin));
}
}
ndata = dataColl.size();
}else if (fit_data==2 ){
hdata = (TH1F*)hEGdata->Clone();
hdata -> Reset();
dataColl.clear();
FILE *infile = fopen(dataFile.data(),"r");
float xdata, xdata1, xdata2; // combined isolation, pt, eta
int flag = 1;
while (flag!=-1){
flag =fscanf(infile,"%f %f %f",&xdata, &xdata1, &xdata2);
if( xdata1 >= ptbin && xdata1 < ptmax && xdata<20.) {
if((strcmp(EBEE,"EB")==0 && TMath::Abs(xdata2)<1.45) ||
(strcmp(EBEE,"EE")==0 && TMath::Abs(xdata2)<2.5 && TMath::Abs(xdata2)>1.7) ) {
dataColl.push_back(xdata);
hdata->Fill(xdata);
}
}
}// keep reading files as long as text exists
ndata = dataColl.size();
//.........这里部分代码省略.........
示例3: SetStyle
//.........这里部分代码省略.........
scales[2] = new TH1F("scales-Cbb", "", 7, 0, 7);
scales[2]->SetBinContent(3, unscaled[2]>0 ? (Cbb ->Integral()/unscaled[2]-1.) : 0.);
scales[3] = new TH1F("scales-bbB" , "", 7, 0, 7);
scales[3]->SetBinContent(4, unscaled[3]>0 ? (bbB ->Integral()/unscaled[3]-1.) : 0.);
scales[4] = new TH1F("scales-Bbb" , "", 7, 0, 7);
scales[4]->SetBinContent(5, unscaled[4]>0 ? (Bbb ->Integral()/unscaled[4]-1.) : 0.);
#ifdef MSSM
scales[5] = new TH1F("scales-bbH" , "", 7, 0, 7);
scales[5]->SetBinContent(6, unscaled[5]>0 ? (bbH ->Integral()/unscaled[5]-1.) : 0.);
scales[6] = new TH1F("scales-NONE" , "", 7, 0, 7);
scales[6]->SetBinContent(7, 0.);
#endif
bbX ->Add(Qbb);
Cbb ->Add(bbX);
bbB ->Add(Cbb);
Bbb ->Add(bbB);
if(!log){
#ifdef MSSM
bbH ->Add(Bbb);
#endif
}
/*
mass plot before and after fit
*/
TCanvas* canv = MakeCanvas("canv", "histograms", 600, 600);
canv->cd();
if(log){ canv->SetLogy(1); }
#if defined MSSM
if(!log){ data->GetXaxis()->SetRange(0, data->FindBin(350)); } else{ data->GetXaxis()->SetRange(0, data->FindBin(1000)); };
#endif
data->SetNdivisions(505);
data->SetMinimum(min);
data->SetMaximum(max>0 ? max : std::max(maximum(data, log), maximum(Bbb, log)));
data->Draw("e");
TH1F* errorBand = (TH1F*)Bbb ->Clone();
errorBand ->SetMarkerSize(0);
errorBand ->SetFillColor(1);
errorBand ->SetFillStyle(3013);
errorBand ->SetLineWidth(1);
if(log){
Bbb ->Draw("histsame");
bbB ->Draw("histsame");
Cbb ->Draw("histsame");
bbX ->Draw("histsame");
Qbb ->Draw("histsame");
$DRAW_ERROR
#ifndef DROP_SIGNAL
bbH ->Draw("histsame");
#endif
}
else{
#ifndef DROP_SIGNAL
bbH ->Draw("histsame");
#endif
Bbb ->Draw("histsame");
bbB ->Draw("histsame");
Cbb ->Draw("histsame");
bbX ->Draw("histsame");
Qbb ->Draw("histsame");
$DRAW_ERROR
}
示例4: if
void
postfit_use(const char* inputfile, const char* analysis = "SM", const char* dataset = "2011+2012", const char* extra="", const char* extra2="", float min=0.1, float max=-1., bool log=true)
{
// defining the common canvas, axes pad styles
SetStyle(); gStyle->SetLineStyleString(11,"20 10");
// switch for MSSM/SM
bool MSSM = std::string(analysis) == std::string("MSSM");
// determine label
if (std::string(dataset) == std::string("2011" )){ dataset = "CMS Preliminary, H#rightarrow#tau#tau, 4.9 fb^{-1} at 7 TeV"; }
if (std::string(dataset) == std::string("2012" )){ dataset = "CMS Preliminary, H#rightarrow#tau#tau, 19.8 fb^{-1} at 8 TeV"; }
if (std::string(dataset) == std::string("2011+2012")){ dataset = "CMS Preliminary, H#rightarrow#tau#tau, 4.9 fb^{-1} at 7 TeV, 19.8 fb^{-1} at 8 TeV"; }
// determine category tag
const char* category_extra = "";
if(std::string(extra2) == std::string("0jet_low" )){ category_extra = "0 jet, low p_{T}"; }
if(std::string(extra2) == std::string("0jet_high" )){ category_extra = "0 jet, high p_{T}"; }
if(std::string(extra2) == std::string("0jet" )){ category_extra = "0 jet"; }
if(std::string(extra2) == std::string("1jet_low" )){ category_extra = "1 jet, low p_{T}"; }
if(std::string(extra2) == std::string("1jet_high" )){ category_extra = "1 jet, high p_{T}"; }
if(std::string(extra2) == std::string("1jet" )){ category_extra = "1 jet"; }
if(std::string(extra2) == std::string("vbf" )){ category_extra = "2 jet (VBF)"; }
if(std::string(extra2) == std::string("nobtag" )){ category_extra = "No B-Tag"; }
if(std::string(extra2) == std::string("btag" )){ category_extra = "B-Tag"; }
TFile* input = new TFile(inputfile);
TH1F* Fakes = refill((TH1F*)input->Get("Fakes" ), "Fakes/QCD");
TH1F* EWK = refill((TH1F*)input->Get("EWK" ), "EWK" );
TH1F* ttbar = refill((TH1F*)input->Get("ttbar" ), "ttbar" );
TH1F* Ztt = refill((TH1F*)input->Get("Ztt" ), "Ztt" );
TH1F* Zmm = refill((TH1F*)input->Get("Zmm" ), "Zmm" );
TH1F* Zee = refill((TH1F*)input->Get("Zee" ), "Zee" );
TH1F* ggH = refill((TH1F*)input->Get("ggH" ), "ggH" );
TH1F* data = (TH1F*)input->Get("data_obs");
// determine channel for etau Z->ee (EWK) will be shown separated from the rest (EWK1)
TH1F* EWK1 = 0;
if(std::string(extra) == std::string("e#tau_{h}")){
EWK1 = refill((TH1F*)input->Get("EWK1"), "EWK1");
}
TH1F* ggH_hww = 0;
if(std::string(extra) == std::string("e#mu") and HWWBG){
ggH_hww= refill((TH1F*)input->Get("ggH_hww" ), "ggH_hww" );
}
TH1F* errorBand = (TH1F*)input->Get("errorBand");
/*
mass plot before and after fit
*/
TCanvas *canv = MakeCanvas("canv", "histograms", 600, 600);
if(log) canv->SetLogy(1);
// reduce the axis range if necessary for linea plots and SM
if(MSSM && !log){ data->GetXaxis()->SetRange(0, data->FindBin(345)); } else{ data->GetXaxis()->SetRange(0, data->FindBin(UPPER_EDGE)); };
if(!MSSM){ data->GetXaxis()->SetRange(0, data->FindBin(345)); }
data->SetNdivisions(505);
data->SetMinimum(min);
if(std::string(extra) == std::string("#mu#mu")){
data->SetMaximum(max>0 ? max : std::max(maximum(data, log), maximum(Zmm, log)));
data->Draw("e");
if(log){
Zmm ->Draw("same");
Ztt ->Draw("same");
ttbar->Draw("same");
Fakes->Draw("same");
EWK ->Draw("same");
if(ggH) ggH ->Draw("histsame");
}
}
else if(std::string(extra) == std::string("ee")){
data->SetMaximum(max>0 ? max : std::max(maximum(data, log), maximum(Zee, log)));
data->Draw("e");
if(log){
Zee ->Draw("same");
Ztt ->Draw("same");
ttbar->Draw("same");
Fakes->Draw("same");
EWK ->Draw("same");
if(ggH) ggH ->Draw("histsame");
}
}
else if(std::string(extra) == std::string("e#tau_{h}")){
data->SetMaximum(max>0 ? max : std::max(maximum(data, log), maximum(Ztt, log)));
data->Draw("e");
if(log){
Ztt ->Draw("same");
ttbar->Draw("same");
EWK ->Draw("same");
EWK1 ->Draw("same");
Fakes->Draw("same");
if(ggH) ggH ->Draw("histsame");
}
else{
if(ggH) ggH ->Draw("histsame");
Ztt ->Draw("same");
ttbar->Draw("same");
EWK ->Draw("same");
EWK1 ->Draw("same");
Fakes->Draw("same");
}
}
else if(std::string(extra) == std::string("e#mu") && HWWBG){
data->SetMaximum(max>0 ? max : std::max(maximum(data, log), maximum(ggH_hww, log)));
data->Draw("e");
//.........这里部分代码省略.........
示例5: SetStyle
//.........这里部分代码省略.........
ggH ->Add(bbH);
#else
#ifndef DROP_SIGNAL
qqH ->Add(VH );
ggH ->Add(qqH);
#endif
#endif
}
else{
#ifdef MSSM
bbH ->Add(WJets);
ggH ->Add(bbH);
#else
#ifndef DROP_SIGNAL
VH ->Add(WJets);
qqH ->Add(VH );
ggH ->Add(qqH);
#endif
#endif
}
/*
mass plot before and after fit
*/
TCanvas* canv = MakeCanvas("canv", "histograms", 600, 600);
canv->cd();
if(log){ canv->SetLogy(1); }
#if defined MSSM
if(!log){ data->GetXaxis()->SetRange(0, data->FindBin(345)); } else{ data->GetXaxis()->SetRange(0, data->FindBin(UPPER_EDGE)); };
#else
data->GetXaxis()->SetRange(0, data->FindBin(345));
#endif
data->SetNdivisions(505);
data->SetMinimum(min);
#ifndef DROP_SIGNAL
data->SetMaximum(max>0 ? max : std::max(std::max(maximum(data, log), maximum(ZTT, log)), maximum(ggH, log)));
#else
data->SetMaximum(max>0 ? max : std::max(maximum(data, log), maximum(ZTT, log)));
#endif
data->Draw("e");
TH1F* errorBand = (TH1F*)ZEE ->Clone("errorBand");
errorBand ->SetMarkerSize(0);
errorBand ->SetFillColor(1);
errorBand ->SetFillStyle(3013);
errorBand ->SetLineWidth(1);
for(int idx=0; idx<errorBand->GetNbinsX(); ++idx){
if(errorBand->GetBinContent(idx)>0){
std::cout << "Uncertainties on summed background samples: " << errorBand->GetBinError(idx)/errorBand->GetBinContent(idx) << std::endl;
break;
}
}
if(log){
ZEE->Draw("histsame");
ZTT->Draw("histsame");
TTJ->Draw("histsame");
QCD->Draw("histsame");
WJets->Draw("histsame");
//Dibosons->Draw("histsame");
$DRAW_ERROR
#ifndef DROP_SIGNAL
ggH->Draw("histsame");
#endif
}
示例6: SetStyle
//.........这里部分代码省略.........
ggH ->Add(bbH);
#else
#ifndef DROP_SIGNAL
qqH ->Add(VH );
ggH ->Add(qqH);
#endif
#endif
}
else{
#ifdef MSSM
bbH ->Add(Ztt);
ggH ->Add(bbH);
#else
#ifndef DROP_SIGNAL
VH ->Add(Ztt);
qqH ->Add(VH );
ggH ->Add(qqH);
#endif
#endif
}
/*
Mass plot before and after fit
*/
TCanvas *canv = MakeCanvas("canv", "histograms", 600, 600);
canv->cd();
if(log){ canv->SetLogy(1); }
#if defined MSSM
if(!log){ data->GetXaxis()->SetRange(0, data->FindBin(345)); } else{ data->GetXaxis()->SetRange(0, data->FindBin(UPPER_EDGE)); };
#else
data->GetXaxis()->SetRange(0, data->FindBin(345));
#endif
data->SetNdivisions(505);
data->SetMinimum(min);
#ifndef DROP_SIGNAL
data->SetMaximum(max>0 ? max : std::max(std::max(maximum(data, log), maximum(Ztt, log)), maximum(ggH, log)));
#else
data->SetMaximum(max>0 ? max : std::max(maximum(data, log), maximum(Ztt, log)));
#endif
data->Draw("e");
TH1F* errorBand = (TH1F*)Ztt ->Clone("errorBand");
errorBand ->SetMarkerSize(0);
errorBand ->SetFillColor(13);
errorBand ->SetFillStyle(3013);
errorBand ->SetLineWidth(1);
for(int idx=0; idx<errorBand->GetNbinsX(); ++idx){
if(errorBand->GetBinContent(idx)>0){
std::cout << "Uncertainties on summed background samples: " << errorBand->GetBinError(idx)/errorBand->GetBinContent(idx) << std::endl;
break;
}
}
if(log){
Ztt ->Draw("histsame");
ttbar->Draw("histsame");
EWK ->Draw("histsame");
EWK1 ->Draw("histsame");
Fakes->Draw("histsame");
$DRAW_ERROR
#ifndef DROP_SIGNAL
ggH ->Draw("histsame");
#endif
}
else{
#ifndef DROP_SIGNAL
示例7: SetStyle
void
HBB_LEP_X(bool scaled=true, bool log=true, float min=0.1, float max=-1., const char* inputfile="root/$HISTFILE", const char* directory="bb_$CATEGORY")
{
// define common canvas, axes pad styles
SetStyle(); gStyle->SetLineStyleString(11,"20 10");
// determine category tag
const char* category_extra = "";
if(std::string(directory) == std::string("bb_had0" )){ category_extra = "all-had_{0}"; }
if(std::string(directory) == std::string("bb_had1" )){ category_extra = "all-had_{1}"; }
if(std::string(directory) == std::string("bb_had2" )){ category_extra = "all-had_{2}"; }
if(std::string(directory) == std::string("bb_had3" )){ category_extra = "all-had_{3}"; }
if(std::string(directory) == std::string("bb_had4" )){ category_extra = "all-had_{4}"; }
if(std::string(directory) == std::string("bb_had5" )){ category_extra = "all-had_{5}"; }
if(std::string(directory) == std::string("bb_lep" )){ category_extra = "semi-lep"; }
const char* dataset;
if(std::string(inputfile).find("7TeV")!=std::string::npos){dataset = "Preliminary, #sqrt{s} = 7 TeV, L = 4.8 fb^{-1}";}
if(std::string(inputfile).find("8TeV")!=std::string::npos){dataset = "Preliminary, #sqrt{s} = 8 TeV, L = 19.4 fb^{-1}";}
TFile* input = new TFile(inputfile);
TH1F* bkgBBB = refill((TH1F*)input->Get(TString::Format("%s/bkgBBB" , directory)), "bkgBBB"); InitHist(bkgBBB, "", "", kMagenta-10, 1001);;
#ifdef MSSM
float bbHScale = 1.; // scenario for MSSM, mhmax, mA=160, tanb=20, A+H for the time being
if(std::string(inputfile).find("7TeV")!=std::string::npos){ bbHScale = (23314.3*0.879 + 21999.3*0.877)/1000.; }
if(std::string(inputfile).find("8TeV")!=std::string::npos){ bbHScale = (31087.9*0.879 + 29317.8*0.877)/1000.; }
// float bbHScale = 1.; // scenario for MSSM, mhmax, mA=160, tanb=10, A+H for the time being
// if(std::string(inputfile).find("7TeV")!=std::string::npos){ bbHScale = (6211.6*0.89 + 5145.0*0.85)/1000.; }
// if(std::string(inputfile).find("8TeV")!=std::string::npos){ bbHScale = (8282.7*0.89 + 6867.8*0.85)/1000.; }
TH1F* bbH = refill((TH1F*)input->Get(TString::Format("%s/bbH160" , directory)), "bbH" ); InitSignal(bbH); bbH->Scale(bbHScale);
#endif
TH1F* data = refill((TH1F*)input->Get(TString::Format("%s/data_obs", directory)), "data", true);
InitHist(data, "#bf{m_{b#bar{b}} [GeV]}", "#bf{dN/dm_{b#bar{b}} [1/GeV]}"); InitData(data);
TH1F* ref=(TH1F*)bkgBBB->Clone("ref");
double unscaled[7];
unscaled[0] = bkgBBB ->Integral();
#ifdef MSSM
unscaled[1] = bbH ->Integral();
unscaled[2] = 0;
#endif
if(scaled){
rescale(bkgBBB, 1);
#ifdef MSSM
rescale(bbH, 2);
#endif
}
TH1F* scales[7];
scales[0] = new TH1F("scales-bkgBBB", "", 3, 0, 3);
scales[0]->SetBinContent(1, unscaled[0]>0 ? (bkgBBB ->Integral()/unscaled[0]-1.) : 0.);
#ifdef MSSM
scales[1] = new TH1F("scales-bbH" , "", 3, 0, 3);
scales[1]->SetBinContent(2, unscaled[1]>0 ? (bbH ->Integral()/unscaled[1]-1.) : 0.);
scales[2] = new TH1F("scales-NONE" , "", 3, 0, 3);
scales[2]->SetBinContent(3, 0.);
#endif
if(!log){
#ifdef MSSM
bbH ->Add(bkgBBB);
#endif
}
/*
mass plot before and after fit
*/
TCanvas* canv = MakeCanvas("canv", "histograms", 600, 600);
canv->cd();
if(log){ canv->SetLogy(1); }
#if defined MSSM
if(!log){ data->GetXaxis()->SetRange(0, data->FindBin(350)); } else{ data->GetXaxis()->SetRange(0, data->FindBin(1000)); };
#endif
data->SetNdivisions(505);
data->SetMinimum(min);
data->SetMaximum(max>0 ? max : std::max(maximum(data, log), maximum(bkgBBB, log)));
data->Draw("e");
TH1F* errorBand = (TH1F*)bkgBBB ->Clone();
errorBand ->SetMarkerSize(0);
errorBand ->SetFillColor(1);
errorBand ->SetFillStyle(3013);
errorBand ->SetLineWidth(1);
if(log){
bkgBBB ->Draw("histsame");
$DRAW_ERROR
#ifndef DROP_SIGNAL
bbH ->Draw("histsame");
#endif
}
else{
#ifndef DROP_SIGNAL
bbH ->Draw("histsame");
#endif
bkgBBB ->Draw("histsame");
$DRAW_ERROR
//.........这里部分代码省略.........
示例8: SetStyle
void
postfit(const char* inputfile, const char* analysis = "SM", const char* dataset = "2011+2012", const char* extra="", const char* extra2="", float min=0.1, float max=-1., bool log=true)
{
// defining the common canvas, axes pad styles
SetStyle(); gStyle->SetLineStyleString(11,"20 10");
// switch for MSSM/SM
bool MSSM = std::string(analysis) == std::string("MSSM");
// determine label
if (std::string(dataset) == std::string("2011" )){ dataset = "CMS Preliminary, H#rightarrow#tau#tau, 4.9 fb^{-1} at 7 TeV"; }
if (std::string(dataset) == std::string("2012" )){
if (std::string(extra) == std::string("#mu#mu") ) dataset = "MS Preliminary, H#rightarrow#tau#tau, 18.7 fb^{-1} at 8 TeV";
else dataset = "MS Preliminary, H#rightarrow#tau#tau, 19.4 fb^{-1} at 8 TeV";
}
if (std::string(dataset) == std::string("2011+2012")){
if (std::string(extra) == std::string("#mu#mu") ) dataset = "CMS Preliminary, H#rightarrow#tau#tau, 4.9 fb^{-1} at 7 TeV, 18.6 fb^{-1} at 8 TeV";
else dataset = "CMS Preliminary, H#rightarrow#tau#tau, 4.9 fb^{-1} at 7 TeV, 19.4 fb^{-1} at 8 TeV";
if (MSSM) dataset = "CMS Preliminary, H#rightarrow#tau#tau, 4.9 fb^{-1} at 7 TeV, 12.1 fb^{-1} at 8 TeV";
}
// determine category tag
const char* category_extra = "";
if(std::string(extra2) == std::string("0jet_low" )){ category_extra = "0 jet, low p_{T}"; }
if(std::string(extra2) == std::string("0jet_high" )){ category_extra = "0 jet, high p_{T}"; }
if(std::string(extra2) == std::string("0jet" )){ category_extra = "0 jet"; }
if(std::string(extra2) == std::string("boost_low" )){ category_extra = "1 jet, low p_{T}"; }
if(std::string(extra2) == std::string("boost_high")){ category_extra = "1 jet, high p_{T}"; }
if(std::string(extra2) == std::string("boost" )){ category_extra = "1 jet"; }
if(std::string(extra2) == std::string("vbf" )){ category_extra = "2 jet (VBF)"; }
if(std::string(extra2) == std::string("nobtag" )){ category_extra = "No B-Tag"; }
if(std::string(extra2) == std::string("btag" )){ category_extra = "B-Tag"; }
TFile* input = new TFile(inputfile);
TH1F* Fakes = refill((TH1F*)input->Get("Fakes" ), "Fakes/QCD");
TH1F* EWK = refill((TH1F*)input->Get("EWK" ), "EWK" );
TH1F* ttbar = refill((TH1F*)input->Get("ttbar" ), "ttbar" );
TH1F* Ztt = refill((TH1F*)input->Get("Ztt" ), "Ztt" );
TH1F* Zmm = refill((TH1F*)input->Get("Zmm" ), "Zmm" );
TH1F* ggH = refill((TH1F*)input->Get("ggH" ), "ggH" );
TH1F* data = (TH1F*)input->Get("data_obs");
// determine channel for etau Z->ee (EWK) will be shown separated from the rest (EWK1)
TH1F* EWK1 = 0;
if(std::string(extra) == std::string("e#tau_{h}")){
EWK1 = refill((TH1F*)input->Get("EWK1"), "EWK1");
}
TH1F* errorBand = (TH1F*)input->Get("errorBand");
/*
mass plot before and after fit
*/
TCanvas *canv = MakeCanvas("canv", "histograms", 600, 600);
if(log) canv->SetLogy(1);
// reduce the axis range if necessary for linea plots and SM
if(MSSM && !log){ data->GetXaxis()->SetRange(0, data->FindBin(350)); } else{ data->GetXaxis()->SetRange(0, data->FindBin(490)); };
if(!MSSM){ data->GetXaxis()->SetRange(0, data->FindBin(350)); }
data->SetNdivisions(505);
data->SetMinimum(min);
if(Zmm){
data->SetMaximum(max>0 ? max : std::max(maximum(data, log), maximum(EWK, log)));
}
else{
data->SetMaximum(max>0 ? max : std::max(maximum(data, log), maximum(Ztt, log)));
}
data->Draw("e");
if(log){
if(Zmm){
EWK ->Draw("same");
ttbar->Draw("same");
Fakes->Draw("same");
Zmm ->Draw("same");
Ztt ->Draw("same");
}
else{
Ztt ->Draw("same");
ttbar->Draw("same");
EWK ->Draw("same");
if(EWK1){
EWK1->Draw("same");
}
if(Fakes){ Fakes->Draw("same"); }
}
if(ggH) ggH ->Draw("histsame");
}
else{
if(ggH) ggH ->Draw("histsame");
if(Zmm){
EWK->Draw("same");
Fakes->Draw("same");
ttbar->Draw("same");
Zmm->Draw("same");
Ztt->Draw("same");
}
else{
Ztt ->Draw("same");
ttbar->Draw("same");
EWK ->Draw("same");
if(EWK1){
EWK1->Draw("same");
}
if(Fakes){ Fakes->Draw("same"); }
//.........这里部分代码省略.........
示例9: markerwarning
void markerwarning()
{
const int Nph = 14;
double np_ph[Nph] = {353.4,300.2,254.3,215.2,181.0,151.3,125.2,102.7, 83.3, 66.7, 52.5, 40.2, 30.2, 22.0};
double nc_ph[Nph] = {3.890,3.734,3.592,3.453,3.342,3.247,3.151,3.047,2.965,2.858,2.701,2.599,2.486,2.328};
double npe_ph[Nph] = {10.068,9.004,8.086,7.304,6.620,6.026,5.504,5.054,4.666,4.334,4.050,3.804,3.604,3.440};
double nce_ph[Nph] = {0.235,0.217,0.210,0.206,0.213,0.223,0.239,0.260,0.283,0.318,0.356,0.405,0.465,0.545};
const int Nbr = 6;
double np_br[Nbr] = {357.0,306.0,239.0,168.0,114.0, 73.0};
double nc_br[Nbr] = {3.501,3.275,3.155,3.060,3.053,3.014};
double npe_br[Nbr] = {8.000,11.000,10.000,9.000,9.000,8.000};
double nce_br[Nbr] = {0.318,0.311,0.306,0.319,0.370,0.429};
TGraphErrors *phUP = new TGraphErrors(Nph,np_ph,nc_ph,npe_ph,nce_ph);
TGraphErrors *phDN = new TGraphErrors(Nph,np_ph,nc_ph,npe_ph,nce_ph);
TGraphErrors *brUP = new TGraphErrors(Nbr,np_br,nc_br,npe_br,nce_br);
TGraphErrors *brDN = new TGraphErrors(Nbr,np_br,nc_br,npe_br,nce_br);
float Top_margin = 0.;
float Left_margin = 0.025;
float Right_margin = 0.005;
float maxPlotPart = 395;
float Marker_Size = 1.3;
int Marker_Style = 8;
float Et_200_Min = 0.71;
float Et_200_Max = 3.80;
float Et_130_Min = 1.21;
float Et_130_Max = 3.29;
float Nc_200_Min = 1.31;
float Nc_200_Max = 4.30;
float Nc_130_Min = 1.51;
float Nc_130_Max = 3.89;
TCanvas *canvasNc = new TCanvas("canvasNc", "Multiplicity",630,10,600,500);
gStyle->SetOptStat(0);
canvasNc->SetFillColor(10);
canvasNc->SetBorderSize(0);
// Primitives in Nc200 pad
TPad *padNcUP = new TPad("padNcUP","200 GeV",0.07,0.60,1.,1.00);
padNcUP->Draw();
padNcUP->cd();
padNcUP->SetFillColor(10);
padNcUP->SetFrameFillColor(10);
padNcUP->SetBorderSize(0);
padNcUP->SetLeftMargin(Left_margin);
padNcUP->SetRightMargin(Right_margin);
padNcUP->SetTopMargin(Top_margin+0.005);
padNcUP->SetBottomMargin(0.00);
TH1F* frameNcUP = new TH1F("frameNcUP","",100,0,maxPlotPart);
frameNcUP->GetYaxis()->SetLabelOffset(0.005);
frameNcUP->GetYaxis()->SetLabelSize(0.10);
frameNcUP->SetMinimum(Nc_200_Min);
frameNcUP->SetMaximum(Nc_200_Max);
frameNcUP->SetNdivisions(505,"Y");
frameNcUP->SetNdivisions(505,"X");
frameNcUP->Draw();
brUP->SetMarkerStyle(22);
brUP->SetMarkerSize (2.0);
brUP->Draw("P");
phDN->SetMarkerStyle(23);
phDN->SetMarkerSize (2);
phDN->Draw("P");
canvasNc->cd();
// Primitives in Nc130 pad
TPad *padNcDN = new TPad("padNcDN","130 GeV",0.07,0.02,1.,0.60);
padNcDN->Draw();
padNcDN->cd();
padNcDN->SetFillColor(10);
padNcDN->SetFrameFillColor(10);
padNcDN->SetBorderSize(0);
padNcDN->SetLeftMargin(Left_margin);
padNcDN->SetRightMargin(Right_margin);
padNcDN->SetTopMargin(Top_margin+0.005);
padNcDN->SetBottomMargin(0.30);
TH1F* frameNcDN = new TH1F("frameNcDN","",100,0,maxPlotPart);
frameNcDN->GetYaxis()->SetLabelOffset(0.005);
frameNcDN->GetYaxis()->SetLabelSize(0.07);
frameNcDN->GetXaxis()->SetLabelOffset(0.005);
frameNcDN->GetXaxis()->SetLabelSize(0.07);
frameNcDN->SetMinimum(Nc_200_Min);
frameNcDN->SetMaximum(Nc_200_Max);
frameNcDN->SetNdivisions(505,"Y");
frameNcDN->SetNdivisions(505,"X");
frameNcDN->Draw();
brDN->SetMarkerStyle(23);
brDN->SetMarkerSize (2.0);
brDN->Draw("P");
//.........这里部分代码省略.........
示例10: SetStyle
//.........这里部分代码省略.........
rescale(ttbar, 2);
rescale(Ztt , 1);
#ifdef MSSM
rescale(ggH , 8);
rescale(bbH , 9);
#else
rescale(ggH , 8);
rescale(qqH , 9);
rescale(VH ,10);
#endif
}
TH1F* scales[7];
scales[0] = new TH1F("scales-Fakes", "", 7, 0, 7);
scales[0]->SetBinContent(1, unscaled[0]>0 ? (Fakes->Integral()/unscaled[0]-1.) : 0.);
scales[1] = new TH1F("scales-EWK" , "", 7, 0, 7);
scales[1]->SetBinContent(2, unscaled[1]>0 ? ((EWK ->Integral()
+EWK1 ->Integral()
+EWK2 ->Integral()
#ifdef EXTRA_SAMPLES
+EWK3 ->Integral()
#endif
)/unscaled[1]-1.) : 0.);
scales[2] = new TH1F("scales-ttbar", "", 7, 0, 7);
scales[2]->SetBinContent(3, unscaled[2]>0 ? (ttbar->Integral()/unscaled[2]-1.) : 0.);
scales[3] = new TH1F("scales-Ztt" , "", 7, 0, 7);
scales[3]->SetBinContent(4, unscaled[3]>0 ? (Ztt ->Integral()/unscaled[3]-1.) : 0.);
#ifdef MSSM
scales[4] = new TH1F("scales-ggH" , "", 7, 0, 7);
scales[4]->SetBinContent(5, unscaled[4]>0 ? (ggH ->Integral()/unscaled[4]-1.) : 0.);
scales[5] = new TH1F("scales-bbH" , "", 7, 0, 7);
scales[5]->SetBinContent(6, unscaled[5]>0 ? (bbH ->Integral()/unscaled[5]-1.) : 0.);
scales[6] = new TH1F("scales-NONE" , "", 7, 0, 7);
scales[6]->SetBinContent(7, 0.);
#else
scales[4] = new TH1F("scales-ggH" , "", 7, 0, 7);
scales[4]->SetBinContent(5, unscaled[4]>0 ? (ggH ->Integral()/unscaled[4]-1.) : 0.);
scales[5] = new TH1F("scales-qqH" , "", 7, 0, 7);
scales[5]->SetBinContent(6, unscaled[5]>0 ? (qqH ->Integral()/unscaled[5]-1.) : 0.);
scales[6] = new TH1F("scales-VH" , "", 7, 0, 7);
scales[6]->SetBinContent(7, unscaled[6]>0 ? (VH ->Integral()/unscaled[6]-1.) : 0.);
#endif
EWK1 ->Add(Fakes);
EWK2 ->Add(EWK1 );
#ifdef EXTRA_SAMPLES
EWK3 ->Add(EWK2 );
EWK ->Add(EWK3 );
#else
EWK ->Add(EWK2 );
#endif
ttbar->Add(EWK );
Ztt ->Add(ttbar);
if(log){
#ifdef MSSM
ggH ->Add(bbH);
#else
qqH ->Add(VH );
ggH ->Add(qqH);
#endif
}
else{
#ifdef MSSM
bbH ->Add(Ztt);
ggH ->Add(bbH);
#else
VH ->Add(Ztt);
qqH ->Add(VH );
ggH ->Add(qqH);
#endif
}
/*
Mass plot before and after fit
*/
TCanvas *canv = MakeCanvas("canv", "histograms", 600, 600);
canv->cd();
if(log){ canv->SetLogy(1); }
// reduce the axis range if necessary
//data->GetXaxis()->SetRange(0, 28);
data->SetNdivisions(505);
data->SetMinimum(min);
data->SetMaximum(max);
data->Draw("e");
TH1F* errorBand = (TH1F*)Ztt ->Clone();
errorBand ->SetMarkerSize(0);
errorBand ->SetFillColor(1);
errorBand ->SetFillStyle(3013);
if(log){
Ztt ->Draw("histsame");
ttbar->Draw("histsame");
EWK ->Draw("histsame");
Fakes->Draw("histsame");
ggH ->Draw("histsame");
$DRAW_ERROR
}
else{
示例11: draw_centEff_fitResults
void draw_centEff_fitResults(string cutname = "hiHF_hfCoinc3_pVtx") {
ifstream in;
//in.open("temp.txt");
in.open(Form("centEff_fitResults_%s.txt",cutname.data()));
string run;
int runtemp;
Float_t eff, chi2;
Int_t nlines = 0;
//TFile *f = new TFile("hist_effcon_runDep.root","RECREATE");
TCanvas *c1 = new TCanvas("c1","",10,10,900,500);
c1->SetGrid();
TH1F *h = new TH1F("h1","Eff+Contamination vs. run",1,0,1);
h->SetStats(0);
h->SetTitle("Eff+Contamination vs. run; Run number;Efficiency+Contamination (%)");
h->SetAxisRange(95,105,"Y");
h->SetCanExtend(TH1::kAllAxes);
h->SetLineColor(2);
TH1F *hgaus = new TH1F("hgaus","Eff+Contamination",20,99,101);
while (1) {
in >> run>> eff >> chi2;
//run = itoa(runtemp);
if (!in.good()) break;
if (nlines < 5) printf("run=%s, eff+contamination=%3f, reduced chi2=%3f\n",run.data(),eff,chi2);
h->Fill(run.data(),eff);
hgaus->Fill(eff);
nlines++;
}
in.close();
printf(" found %d points\n",nlines);
c1->cd();
h->LabelsDeflate();
h->Draw("hist");
c1->SaveAs(Form("figures/centEff_runDep_%s.png",cutname.data()));
TCanvas *c2 = new TCanvas("c2","",500,500);
double gausMean, gausResol;
double histMean, histResol;
TF1* fgaus = cleverGaus(hgaus);
gausMean = fgaus->GetParameter(1);
gausResol = fgaus->GetParameter(2);
hgaus->SetTitle(";Efficiency+Contamination (%);");
hgaus->SetNdivisions(504);
hgaus->Draw("hist");
fgaus->Draw("same");
histMean = hgaus->GetMean();
histResol= hgaus->GetRMS();// GetRMS()=GetStdDev() only in ROOT!
float xpos(0.62), ypos(0.76);
float dy=0.05;
drawText(Form("from historgam"),xpos,ypos,kBlack,18);
drawText(Form("mean = %.3f",histMean),xpos,ypos-dy,kBlack,18);
drawText(Form("sigma = %.3f",histResol),xpos,ypos-2*dy,kBlack,18);
ypos=0.55;
drawText(Form("from gaus fit"),xpos,ypos,kBlack,18);
drawText(Form("mean = %.3f",gausMean),xpos,ypos-dy,kBlack,18);
drawText(Form("sigma = %.3f",gausResol),xpos,ypos-2*dy,kBlack,18);
xpos=0.62-0.21;
drawText("Dataset : HIMinimumBias2", xpos, 0.18+2*dy);
drawText("Trig : HLT_HIL1MinimumBiasHF1AND_v1", xpos, 0.18+dy);
drawText("Evt. sel. filter : hfCoinc3 && pVtx", xpos, 0.18);
c2->SaveAs(Form("figures/centEff_runDep_gaus_%s.png",cutname.data()));
}
示例12: quickPhotonPurity_yj_multiTreeUtil
//.........这里部分代码省略.........
// err->Reset();
// for(int s = 0; s < 4; s++)
// {
// if(s == 0)
// tempErr[s] = (TH1D*)TFile::Open("photonPurity_sys_loose.root")->Get(name);
// else if(s ==1)
// tempErr[s] = (TH1D*)TFile::Open("photonPurity_sys_tight.root")->Get(name);
// else if(s ==2)
// tempErr[s] = (TH1D*)TFile::Open("photonPurity_sys_sigshift.root")->Get(name);
// else if(s ==3)
// tempErr[s] = (TH1D*)TFile::Open("photonPurity_sys_bkgshift.root")->Get(name);
// tempErr[s]->Divide(hSigPdf);
// for (Int_t l=1; l<=tempErr[s]->GetNbinsX();l++)
// {
// tempErr[s]->SetBinContent(l, TMath::Abs(tempErr[s]->GetBinContent(l))-1);
// }
// }
// for (Int_t l=1; l<=err->GetNbinsX();l++)
// {
// Double_t errVal = TMath::Sqrt(tempErr[0]->GetBinContent(l)*tempErr[0]->GetBinContent(l) +
// tempErr[1]->GetBinContent(l)*tempErr[1]->GetBinContent(l) +
// tempErr[2]->GetBinContent(l)*tempErr[2]->GetBinContent(l) +
// tempErr[3]->GetBinContent(l)*tempErr[3]->GetBinContent(l)
// );
// err->SetBinContent(l, errVal);
// }
// plot stacked histos
handsomeTH1(hSigPdf);
mcStyle(hSigPdf);
sbStyle(hBckPdf);
cleverRange(hSigPdf,1.5);
hSigPdf->SetAxisRange(0.001,0.024,"X");
hSigPdf->SetNdivisions(505);
hSigPdf->GetYaxis()->SetTitleOffset(1.75);
hSigPdf->SetYTitle("Entries");
hSigPdf->SetXTitle("#sigma_{#eta #eta}");
hSigPdf->DrawCopy("hist");
//drawSys(hSigPdf, err, kRed, -1, 0.001);
hBckPdf->DrawCopy("same hist");
hData1->DrawCopy("same");
Float_t xpos = 0.44;
if(2*(k+j)*nPTBINS+i+1 == 1)
xpos = 0.54;
TLegend *t3=new TLegend(xpos, 0.45, 0.92, 0.71);
t3->AddEntry(hData1,LABEL,"pl");
t3->AddEntry(hSigPdf,"Signal","lf");
t3->AddEntry(hBckPdf,"Background","lf");
t3->SetFillColor(0);
t3->SetBorderSize(0);
t3->SetFillStyle(0);
t3->SetTextFont(43);
t3->SetTextSize(20);
//if(i == 0)
// TH1D *dummyHist = new TH1D("dummyHist","",10,0,10);
// dummyHist->Fill(1);
// dummyHist->SetFillColor(kRed);
// dummyHist->SetLineColor(kRed);
// dummyHist->SetFillStyle(1001);
// t3->AddEntry(dummyHist,"MC Sys. Error","f");
// if(i == 0)
// t3->Draw();
示例13: SetStyle
//.........这里部分代码省略.........
ggH ->Add(bbH);
#else
#ifndef DROP_SIGNAL
qqH ->Add(VH );
ggH ->Add(qqH);
#endif
#endif
}
else{
#ifdef MSSM
bbH ->Add(Ztt);
ggH ->Add(bbH);
#else
#ifndef DROP_SIGNAL
VH ->Add(Ztt);
qqH ->Add(VH );
ggH ->Add(qqH);
#endif
#endif
}
/*
Mass plot before and after fit
*/
TCanvas *canv = MakeCanvas("canv", "histograms", 600, 600);
canv->cd();
if(log){ canv->SetLogy(1); }
#if defined MSSM
if(!log){ data->GetXaxis()->SetRange(0, data->FindBin(350)); } else{ data->GetXaxis()->SetRange(0, data->FindBin(1000)); };
#else
data->GetXaxis()->SetRange(0, data->FindBin(350));
#endif
data->SetNdivisions(505);
data->SetMinimum(min);
data->SetMaximum(max>0 ? max : std::max(maximum(data, log), maximum(Ztt, log)));
data->Draw("e");
TH1F* errorBand = (TH1F*)Ztt ->Clone();
errorBand ->SetMarkerSize(0);
errorBand ->SetFillColor(1);
errorBand ->SetFillStyle(3013);
errorBand ->SetLineWidth(1);
for(int idx=0; idx<errorBand->GetNbinsX(); ++idx){
if(errorBand->GetBinContent(idx)>0){
std::cout << "Uncertainties on summed background samples: " << errorBand->GetBinError(idx)/errorBand->GetBinContent(idx) << std::endl;
break;
}
}
if(log){
Ztt ->Draw("histsame");
ttbar->Draw("histsame");
EWK ->Draw("histsame");
Fakes->Draw("histsame");
$DRAW_ERROR
#ifndef DROP_SIGNAL
ggH ->Draw("histsame");
#endif
}
else{
#ifndef DROP_SIGNAL
ggH ->Draw("histsame");
#endif
Ztt ->Draw("histsame");
ttbar->Draw("histsame");
EWK ->Draw("histsame");
示例14: SetStyle
// examples macro
void
etauAfterFit_novbf(bool scaled = true, bool log = true)
{
// defining the common canvas, axes pad styles
SetStyle();
// open example histogram file
TFile* exampleFile = new TFile("eleTau_sm.root");
//load example histograms
TH1F* data = (TH1F*)exampleFile->Get("eleTau_SM0/data_obs");
if(data) {InitHist(data, "#bf{m_{vis} [GeV]}", "#bf{Events}"); InitData(data);} else{std::cout << "can't find hitogram " << "eleTau_SM0/data_obs" << std::endl;}
TH1F* Fakes = refill((TH1F*)exampleFile->Get("eleTau_SM0/QCD")) ; InitHist(Fakes, "", "", kMagenta-10, 1001);
TH1F* EWK1 = refill((TH1F*)exampleFile->Get("eleTau_SM0/W" )) ; InitHist(EWK1 , "", "", kRed + 2, 1001);
TH1F* EWK2 = refill((TH1F*)exampleFile->Get("eleTau_SM0/ZJ" )) ; InitHist(EWK2 , "", "", kRed + 2, 1001);
TH1F* EWK3 = refill((TH1F*)exampleFile->Get("eleTau_SM0/ZL" )) ; InitHist(EWK3 , "", "", kRed + 2, 1001);
TH1F* EWK = refill((TH1F*)exampleFile->Get("eleTau_SM0/VV" )) ; InitHist(EWK , "", "", kRed + 2, 1001);
TH1F* ttbar = refill((TH1F*)exampleFile->Get("eleTau_SM0/TT" )) ; InitHist(ttbar, "", "", kBlue - 8, 1001);
TH1F* Ztt = refill((TH1F*)exampleFile->Get("eleTau_SM0/ZTT")) ; InitHist(Ztt , "", "", kOrange - 4, 1001);
TH1F* ggH = refill((TH1F*)exampleFile->Get("eleTau_SM0/SM120" )) ; InitSignal(ggH); ggH ->Scale(10*16.63*0.071*16.083/ggH ->Integral());
TH1F* qqH = refill((TH1F*)exampleFile->Get("eleTau_SM0/VBF120")) ; InitSignal(qqH); qqH ->Scale(10*1.269*0.071* 1.105/qqH ->Integral());
if(scaled){
rescale(Fakes, 2);
rescale(EWK1 , 3);
rescale(EWK2 , 4);
rescale(EWK3 , 5);
rescale(EWK , 7);
rescale(ttbar, 6);
rescale(Ztt , 1);
rescale(ggH , 8);
rescale(qqH , 9);
}
if(log){
qqH ->Add(ggH );
Fakes->Add(qqH );
EWK1 ->Add(Fakes);
EWK2 ->Add(EWK1 );
EWK3 ->Add(EWK2 );
EWK ->Add(EWK3 );
ttbar->Add(EWK );
Ztt ->Add(ttbar);
}
else{
EWK1 ->Add(Fakes);
EWK2 ->Add(EWK1 );
EWK3 ->Add(EWK2 );
EWK ->Add(EWK3 );
ttbar->Add(EWK );
Ztt ->Add(ttbar);
ggH ->Add(Ztt );
qqH ->Add(ggH );
}
// define canvas
TCanvas *canv = MakeCanvas("canv", "histograms", 600, 600);
canv->cd();
if(log){
canv->SetLogy(1);
data->SetMinimum(5.0);
data->SetMaximum(500000.);
}
else{
data->SetMaximum(4000.);
}
data->SetNdivisions(505);
data->Draw("e");
if(log){
Ztt->Draw("same");
ttbar->Draw("same");
EWK->Draw("same");
Fakes->Draw("same");
qqH->Draw("same");
}
else{
qqH->Draw("same");
Ztt->Draw("same");
ttbar->Draw("same");
EWK->Draw("same");
Fakes->Draw("same");
}
data->Draw("esame");
canv->RedrawAxis();
CMSPrelim("#tau_{e}#tau_{h}", 0.45, 0.75);
TLegend* leg = new TLegend(0.45, 0.45, 0.9, 0.75);
SetLegendStyle(leg);
leg->AddEntry(qqH , "(10x) H#rightarrow#tau#tau" , "L" );
leg->AddEntry(data , "Observed" , "LP");
leg->AddEntry(Ztt , "Z#rightarrow#tau#tau" , "F" );
leg->AddEntry(ttbar, "t#bar{t}" , "F" );
leg->AddEntry(EWK , "Electroweak" , "F" );
leg->AddEntry(Fakes, "QCD" , "F" );
leg->Draw();
TPaveText* mssm = new TPaveText(0.78, 0.70, 0.90, 0.74, "NDC");
//.........这里部分代码省略.........
示例15: W_MET_Ratio
/*#include <TSystem.h> // interface to OS
#include <TStyle.h> // class to handle ROOT plotting styles#include <TFile.h> // file handle class
#include <TTree.h> // class to access ntuples
#include <TBenchmark.h> // class to track macro running statistics
#include <TH1D.h> // histogram class
#include <vector> // STL vector class
#include <iostream> // standard I/O
#include <iomanip> // functions to format standard I/O
#include <fstream> // functions for file I/O
#include <string> // C++ string class
#include <sstream> // class for parsing strings
#include <TRandom3.h>
#include <TGaxis.h>
#include "Math/LorentzVector.h" // 4-vector class
#include "../Utils/MyTools.hh" // various helper functions
#include "../Utils/CPlot.hh" // helper class for plots
#include "../Utils/MitStyleRemix.hh" // style settings for drawing
#include "../Utils/WModels.hh" // definitions of PDFs for fitting
#include "../Utils/RecoilCorrector.hh" // class to handle recoil corrections for MET
*/
void W_MET_Ratio()
{
TCanvas *c = new TCanvas("c","c",800,800);
c->Divide(1,2,0,0);
c->cd(1)->SetPad(0,0.3,1.0,1.0);
c->cd(1)->SetTopMargin(0.1);
c->cd(1)->SetBottomMargin(0.01);
c->cd(1)->SetLeftMargin(0.15);
c->cd(1)->SetRightMargin(0.07);
c->cd(1)->SetTickx(1);
c->cd(1)->SetTicky(1);
c->cd(2)->SetPad(0,0,1.0,0.3);
c->cd(2)->SetTopMargin(0.05);
c->cd(2)->SetBottomMargin(0.45);
c->cd(2)->SetLeftMargin(0.15);
c->cd(2)->SetRightMargin(0.07);
c->cd(2)->SetTickx(1);
c->cd(2)->SetTicky(1);
c->cd(2)->SetGridy();
TLegend * lgc = new TLegend(0.59, 0.67, 0.89, 0.89);
lgc->SetTextSize(0.03);
lgc->SetBorderSize(0);
lgc->SetFillColor(0);
// TFile *file = new TFile("../ElectronHighPU/Ele_RD_HighPU_A_Analysis.root");
TFile *file = new TFile("./ElectronHighPU_N/Ele_WToENu_S10_Analysis.root");
///////////////Original Plot////////////////////////
c->cd(1);
lgc->AddEntry(h1_W_Neut_pt1,"UnCorrected");
h1_W_Neut_pt1->SetYTitle("Events");
h1_W_Neut_pt1->SetFillColor(kWhite);
h1_W_Neut_pt1->SetMarkerColor(kBlack);
h1_W_Neut_pt1->SetMarkerStyle(1);
h1_W_Neut_pt1->SetLineWidth(2);
h1_W_Neut_pt1->Draw();
lgc->AddEntry(h1_W_Neut_pt_Corr,"Corrected");
h1_W_Neut_pt_Corr->SetLineColor(kRed);
h1_W_Neut_pt_Corr->SetFillColor(kWhite);
h1_W_Neut_pt_Corr->SetMarkerColor(kRed);
h1_W_Neut_pt_Corr->SetMarkerStyle(1);
h1_W_Neut_pt_Corr->SetLineWidth(2);
h1_W_Neut_pt_Corr->Draw("same");
lgc->Draw();
///////////////////////////////////////////////////////
c->cd(2);
TH1F * h1_Ori = (TH1F*)file->Get("h1_W_Neut_pt1");
TH1F * h1_Corr = (TH1F*)file->Get("h1_W_Neut_pt_Corr");
int Nbins = h1_Ori->GetNbinsX();
TH1F * ratio = new TH1F("ratio","", Nbins, h1_Ori->GetXaxis()->GetXmin(), h1_Ori->GetXaxis()->GetXmax());
ratio->Divide(h1_Ori, h1_Corr);
ratio->SetXTitle("N_vtx");
ratio->SetMaximum(2);
ratio->SetMinimum(0);
ratio->SetNdivisions(10,"X");
ratio->SetNdivisions(4,"Y");
ratio->SetLabelSize(0.09,"XY");
ratio->SetTitleSize(0.12,"X");
ratio->SetMarkerStyle(20);
ratio->SetMarkerSize(0.7);
ratio->SetMarkerColor(kBlue);
ratio->Draw("P");
// c->SaveAs("W_MET_Ratio_RD.png");
c->SaveAs("W_MET_Ratio_MC.png");
}