本文整理汇总了C++中TPad::SetFillStyle方法的典型用法代码示例。如果您正苦于以下问题:C++ TPad::SetFillStyle方法的具体用法?C++ TPad::SetFillStyle怎么用?C++ TPad::SetFillStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPad
的用法示例。
在下文中一共展示了TPad::SetFillStyle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: overlayFrame
//--------------------------------------------------------------------------------------------------
void overlayFrame(TString text, bool align)
{
// Overlay a linear frame from user coordinates (0 - 1, 0 - 1) and put the frame text
// Create new transparent pad for the text
TPad *transPad = new TPad("transPad","Transparent Pad",0,0,1,1);
transPad->SetFillStyle(4000);
transPad->Draw();
transPad->cd();
// Overlay the text in a well defined frame
TText *plotText = new TText();
plotText->SetTextColor(kBlue);
plotText->SetTextSize(0.04);
plotText->SetNDC();
// Draw text at top right
if (align) {
plotText->SetTextColor(kBlack);
plotText->SetTextAlign(33);
plotText->DrawText(0.92,0.95,text.Data());
}
// Draw text at bottom left
else
plotText->DrawText(0.01,0.01,text.Data());
return;
}
示例2: overlayFrame
//--------------------------------------------------------------------------------------------------
void overlayFrame(TString text)
{
// Overlay a linear frame from user coordinates (0 - 1, 0 - 1) and put the frame text
// create new transparent pad for the text
TPad *transPad = new TPad("transPad","Transparent Pad",0,0,1,1);
transPad->SetFillStyle(4000);
transPad->Draw();
transPad->cd();
// overlay the text in a well defined frame
TText *plotText = new TText(0.01,0.01,text.Data());
plotText->SetTextSize(0.04);
plotText->SetTextColor(kBlue);
plotText->Draw();
return;
}
示例3: DrawGrid
void DrawGrid()
{
Int_t ncol = 100;
Int_t nrow = 200;
TPad *grid = new TPad("grid","",0,0,1,1);
grid->Draw();
grid->cd();
grid->SetGrid();
grid->SetFillStyle(4000);
grid->SetFrameFillStyle(0);
TH2 *hgrid = new TH2C("hgrid","", ncol+1, -5, ncol+5, nrow, -5, nrow-1+5);
hgrid->Draw();
hgrid->GetXaxis()->SetNdivisions(6,100);
hgrid->GetYaxis()->SetNdivisions(200);
hgrid->GetYaxis()->SetLabelOffset(999.);
hgrid->GetXaxis()->SetLabelOffset(999.);
}
示例4: zj_ptj_8TeV
void zj_ptj_8TeV()
{
//=========Macro generated from canvas: default_Canvas/defaultCanvas
//========= (Thu Apr 28 10:19:34 2016) by ROOT version6.04/10
TCanvas *default_Canvas = new TCanvas("default_Canvas", "defaultCanvas",0,0,800,800);
gStyle->SetOptStat(0);
gStyle->SetOptTitle(0);
default_Canvas->SetHighLightColor(2);
default_Canvas->Range(0,0,1,1);
default_Canvas->SetFillColor(0);
default_Canvas->SetBorderMode(0);
default_Canvas->SetBorderSize(2);
default_Canvas->SetTickx(1);
default_Canvas->SetTicky(1);
default_Canvas->SetLeftMargin(0.14);
default_Canvas->SetRightMargin(0.05);
default_Canvas->SetTopMargin(0.05);
default_Canvas->SetBottomMargin(0.16);
default_Canvas->SetFrameLineWidth(2);
default_Canvas->SetFrameBorderMode(0);
// ------------>Primitives in pad: bottomPad
TPad *bottomPad = new TPad("bottomPad", "bottomPad",0.005,0.05,0.995,0.995);
bottomPad->Draw();
bottomPad->cd();
bottomPad->Range(0,0,1,1);
bottomPad->SetFillColor(0);
bottomPad->SetFillStyle(4000);
bottomPad->SetBorderMode(0);
bottomPad->SetBorderSize(2);
bottomPad->SetTickx(1);
bottomPad->SetTicky(1);
bottomPad->SetLeftMargin(0.14);
bottomPad->SetRightMargin(0.05);
bottomPad->SetTopMargin(0.05);
bottomPad->SetBottomMargin(0.16);
bottomPad->SetFrameLineWidth(2);
bottomPad->SetFrameBorderMode(0);
bottomPad->Modified();
default_Canvas->cd();
// ------------>Primitives in pad: upperPad
TPad *upperPad = new TPad("upperPad", "upperPad",0.005,0.05,0.995,0.995);
upperPad->Draw();
upperPad->cd();
upperPad->Range(6.172839,-0.2132695,104.9383,0.4330016);
upperPad->SetFillColor(0);
upperPad->SetFillStyle(4000);
upperPad->SetBorderMode(0);
upperPad->SetBorderSize(2);
upperPad->SetTickx(1);
upperPad->SetTicky(1);
upperPad->SetLeftMargin(0.14);
upperPad->SetRightMargin(0.05);
upperPad->SetTopMargin(0.05);
upperPad->SetBottomMargin(0.33);
upperPad->SetFrameLineWidth(2);
upperPad->SetFrameBorderMode(0);
upperPad->SetFrameLineWidth(2);
upperPad->SetFrameBorderMode(0);
Double_t xAxis19[6] = {20, 25, 30, 40, 50, 100};
TH1F *z_ptj_toterr__19 = new TH1F("z_ptj_toterr__19","z_ptj",5, xAxis19);
z_ptj_toterr__19->SetBinContent(1,0.3608738);
z_ptj_toterr__19->SetBinContent(2,0.225932);
z_ptj_toterr__19->SetBinContent(3,0.1253807);
z_ptj_toterr__19->SetBinContent(4,0.06703913);
z_ptj_toterr__19->SetBinContent(5,0.01561868);
z_ptj_toterr__19->SetBinContent(6,0.780934);
z_ptj_toterr__19->SetBinError(1,0.02073388);
z_ptj_toterr__19->SetBinError(2,0.01400757);
z_ptj_toterr__19->SetBinError(3,0.009350811);
z_ptj_toterr__19->SetBinError(4,0.004623786);
z_ptj_toterr__19->SetBinError(5,0.001395185);
z_ptj_toterr__19->SetBinError(6,0.06975923);
z_ptj_toterr__19->SetEntries(12);
z_ptj_toterr__19->SetStats(0);
Int_t ci; // for color index setting
TColor *color; // for color definition with alpha
ci = TColor::GetColor("#ffff00");
z_ptj_toterr__19->SetFillColor(ci);
ci = TColor::GetColor("#ffff00");
z_ptj_toterr__19->SetLineColor(ci);
z_ptj_toterr__19->SetLineWidth(2);
ci = TColor::GetColor("#ffff00");
z_ptj_toterr__19->SetMarkerColor(ci);
z_ptj_toterr__19->SetMarkerStyle(0);
z_ptj_toterr__19->GetXaxis()->SetNdivisions(4);
z_ptj_toterr__19->GetXaxis()->SetLabelFont(132);
z_ptj_toterr__19->GetXaxis()->SetLabelOffset(999);
z_ptj_toterr__19->GetXaxis()->SetLabelSize(0);
z_ptj_toterr__19->GetXaxis()->SetTitleSize(0.06);
z_ptj_toterr__19->GetXaxis()->SetTitleFont(132);
z_ptj_toterr__19->GetYaxis()->SetTitle("d#sigma(#it{Zj})/d#it{p}_{T}^{jet} [pb/GeV]");
z_ptj_toterr__19->GetYaxis()->SetLabelFont(132);
z_ptj_toterr__19->GetYaxis()->SetLabelSize(0.05);
z_ptj_toterr__19->GetYaxis()->SetTitleSize(0.06);
//.........这里部分代码省略.........
示例5: test
//.........这里部分代码省略.........
//double x3 = ( 2. * ps.pt3_bins[imeff] ) / ( ps.meff_bins[imeff] + ps.pt3_bins[imeff] );
// Fill 2D cross-section plot
for ( int x2_bin = 0; x2_bin < ps.nbins; ++x2_bin ) {
for ( int x1_bin = 0; x1_bin < ps.nbins; ++x1_bin ) {
// std::cout << " Fill:"
// << " x2_bin: " << x2_bin
// << " x2: " << val(x2_bin,nbins)
// << " x1_bin: " << x1_bin
// << " x1: " << val(x1_bin,nbins)
// << " val: " << dalitz[x2_bin][x1_bin]
// << std::endl;
if (his) his->Fill( val(x2_bin,ps)+ps.width/2.,
val(x1_bin,ps)+ps.width/2.,
dalitz[x2_bin][x1_bin] );
}
}
// Draw 2D cross-section plot
gStyle->SetPalette(1);
if (his) {
//his->SetMaximum( his->GetMaximum()*10. );
//his->SetMinimum( his->GetMinimum(1.e-12)*0.1 );
// his->SetMaximum( 1.e9 );
// his->SetMinimum( 1.e0 );
his->Draw("COLZsame");
}
// Pad for AlphaT contours
if (c1) c1->cd();
TPad* overlay = 0;
if (draw) overlay = new TPad(TString("Overlay"+ss.str()),"",0.,0.,1.,1.);
if (overlay) {
overlay->SetFillStyle(4000);
overlay->SetFillColor(0);
overlay->SetFrameFillStyle(4000);
overlay->Draw();
overlay->cd();
}
//TH1F* hframe = 0;
if (draw) overlay->DrawFrame(pad->GetUxmin(),
pad->GetUymin(),
pad->GetUxmax(),
pad->GetUymax());
// Graphs of AlphaT contours
TMultiGraph* mg = 0;
if (draw) {
mg = new TMultiGraph();
for ( Int_t icut = 0; icut < (int)ps.cutValues.size(); icut++ ) {
Double_t alpha_t = ps.cutValues[icut];
const Int_t n = ps.nbins;
DoubleV x1(n,0.);
DoubleV x2(n,0.);
for ( Int_t x2_bin = 0; x2_bin < ps.nbins; x2_bin++ ) {
x2[x2_bin] = x2_bin * ps.width;
x1[x2_bin] = cutAlgoInverse(ps.cutValues[icut],x2[x2_bin],ALGO_TYPE);
}
TGraph* gr = new TGraph(n,&x2.front(),&x1.front());
mg->Add(gr,"l");
}
mg->Draw();
}
if (c1) c1->cd();
if (c1) c1->SaveAs(TString(ss.str()+".png"));
示例6: ptBestFit
//.........这里部分代码省略.........
TH1F *hUnc2H = new TH1F("hUnc2H"+ds_name,"hUnc2H"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX);
TH1F *hUnc2L = new TH1F("hUnc2L"+ds_name,"hUnc2L"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX);
TH1F *hUncC = new TH1F("hUncC"+ds_name,"hUncC"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX);
RooCurve *errorBand,*gFit,*gQCDFit,*gBkgFit;
//list->Print();
if (BLIND) {
errorBand = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]_errorband_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
gFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]"+"_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
}
else {
//errorBand = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]_errorband");
errorBand = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]_errorband_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
gFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]");
}
gQCDFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]"+"_Comp[shapeBkg_qcd_"+ds_name+"]");
gBkgFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]"+"_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
for(int i=0;i<hUncH->GetNbinsX();i++) {
double x0 = hUncH->GetBinCenter(i+1);
double e1 = fabs(errorBand->Eval(x0)-gBkgFit->Eval(x0));
//double e1 = fabs(errorBand->Eval(x0)-gFit->Eval(x0));
double e2 = eNqcd/hUncH->GetNbinsX();
hUncH->SetBinContent(i+1,sqrt(pow(e2,2)+pow(e1,2)));
hUnc2H->SetBinContent(i+1,2*sqrt(pow(e2,2)+pow(e1,2)));
hUncL->SetBinContent(i+1,-sqrt(pow(e2,2)+pow(e1,2)));
hUnc2L->SetBinContent(i+1,-2*sqrt(pow(e2,2)+pow(e1,2)));
hUncC->SetBinContent(i+1,0.);
}
TPad* pad = new TPad("pad", "pad", 0., 0., 1., 1.);
pad->SetTopMargin(0.63);
pad->SetFillColor(0);
pad->SetFillStyle(0);
pad->Draw();
pad->cd(0);
hUnc2H->GetXaxis()->SetTitle("m_{bb} (GeV)");
hUnc2H->GetYaxis()->SetTitle("Data - Bkg");
//hUnc2H->GetYaxis()->SetTitle("Data - Fit");
double YMAX = 1.1*frame2->GetMaximum();
double YMIN = -1.1*frame2->GetMaximum();
hUnc2H->GetYaxis()->SetRangeUser(YMIN,YMAX);
hUnc2H->GetYaxis()->SetNdivisions(507);
// hUnc2H->GetXaxis()->SetTitleOffset(0.9);
// hUnc2H->GetYaxis()->SetTitleOffset(1.0);
hUnc2H->GetYaxis()->SetTickLength(0.0);
// hUnc2H->GetYaxis()->SetTitleSize(0.05);
// hUnc2H->GetYaxis()->SetLabelSize(0.04);
hUnc2H->GetYaxis()->CenterTitle(kTRUE);
hUnc2H->SetFillColor(kGreen);
hUnc2L->SetFillColor(kGreen);
hUncH->SetFillColor(kYellow);
hUncL->SetFillColor(kYellow);
hUncC->SetLineColor(kBlack);
hUncC->SetLineStyle(7);
hUnc2H->Draw("HIST");
hUnc2L->Draw("same HIST");
hUncH->Draw("same HIST");
hUncL->Draw("same HIST");
hUncC->Draw("same HIST");
frame2->GetYaxis()->SetTickLength(0.03/0.4);
frame2->Draw("same");
TList *list1 = (TList*)gPad->GetListOfPrimitives();
//list1->Print();
RooCurve *gSigFit = (RooCurve*)list1->FindObject("shapeSig_qqH_"+ds_name+"_Norm[mbbReg_"+ds_name+"]");
示例7: create_plot
void create_plot(
TH1D * hw,
TH1D * emu,
int runNo,
const char * dataset,
const char * xLabel,
const char * exportPath,
int rebin = 1,
int energy = 13,
long rangeLow = 0,
long rangeHigh = 0
) {
// define latex container to hold the title
TLatex n;
n.SetNDC();
n.SetTextFont(52);
n.SetTextSize(0.05);
// create canvas that will hold each plot
TCanvas* canv = new TCanvas("canv","canvas");
// top pad (comparison)
TPad* pad1 = new TPad("mainPad","mainPad",0,0.3,1,1);
// bottom (resuduals) pad
TPad* pad2 = new TPad("ratioPad","ratioPad",0,0.05,1,0.3);
// pad to contain trendline for hw-emu ratio of 1
TPad* overlayPad = new TPad("pInv","pInv", 0,0.05,1,0.3);
overlayPad->SetFillStyle(0);
// create legend that will describe appearance of data points
TLegend * leg = new TLegend(0.65,0.85,0.91,1);
leg->SetFillColor(0);
leg->SetNColumns(2);
leg->AddEntry(hw,"Hardware", "p");//"l");
leg->AddEntry(emu,"Emulator", "l");
leg->SetBorderSize(0);
leg->SetFillStyle(0);
// optionally reduce segmentation in x to improve visibility of some plots
hw->Rebin(rebin);
emu->Rebin(rebin);
hw->SetMarkerStyle(21);
hw->SetMarkerColor(1);
hw->SetMarkerSize(0.5);
emu->SetLineColor(kRed);
hw->GetYaxis()->SetTitle("Number of candidates");
hw->GetYaxis()->SetTitleSize(0.062);
hw->GetYaxis()->SetTitleOffset(0.80);
hw->GetYaxis()->SetLabelSize(0.045);
hw->GetYaxis()->SetTickSize(0.01);
hw->GetXaxis()->SetLabelSize(0);
emu->GetXaxis()->SetLabelSize(0);
pad1->SetBottomMargin(0.02);
pad1->SetGridx();
//pad1->SetLogy();
pad1->Draw();
pad1->cd();
hw->SetStats(0);
emu->SetStats(0);
if (emu->GetMaximum() > hw->GetMaximum()) {
hw->SetMaximum(1.1*emu->GetMaximum());
}
if (rangeLow != 0 || rangeHigh != 0) {
emu->GetXaxis()->SetRangeUser(rangeLow, rangeHigh);
hw->GetXaxis()->SetRangeUser(rangeLow, rangeHigh);
}
hw->DrawCopy("p");
emu->Draw("same");
if (rangeLow != 0 || rangeHigh != 0) {
emu->GetXaxis()->SetRangeUser(rangeLow, rangeHigh);
hw->GetXaxis()->SetRangeUser(rangeLow, rangeHigh);
}
leg->Draw();
stringstream caption;
caption << "#bf{CMS Preliminary}: " << dataset;
/*
caption << "#bf{CMS Preliminary, 2016 Data}:" << ", #sqrt{s} = " << energy
<< " TeV ";
*/
n.DrawLatex(0.1, 0.915, caption.str().c_str());
canv->cd();
pad2->SetTopMargin(0);
pad2->SetBottomMargin(0.39);
pad2->Draw();
pad2->cd();
pad2->SetGridy();
pad2->SetGridx();
//.........这里部分代码省略.........
示例8: CreateDataTemplates
//.........这里部分代码省略.........
tr->Draw(MASS_VAR[isel]+">>"+h->GetName(),cut);
tr->Draw(MASS_VAR[isel]+">>"+hBlind->GetName(),cutBlind);
sprintf(name,"yield_data_CAT%d",counter);
RooRealVar *Yield = new RooRealVar(name,name,h->Integral());
sprintf(name,"data_hist_CAT%d",counter);
roohist[icat] = new RooDataHist(name,name,x,h);
sprintf(name,"data_hist_blind_CAT%d",counter);
roohist_blind[icat] = new RooDataHist(name,name,x,hBlind);
RooAbsPdf *qcd_pdf;
if (icat == 0) {
for(int ib=0;ib<=NPAR;ib++) {
brn[ib]->setConstant(kFALSE);
}
sprintf(name,"qcd_model_CAT%d",counter);
RooBernstein *qcd_pdf_aux = new RooBernstein(name,name,x,brn_params);
qcd_pdf = dynamic_cast<RooAbsPdf*> (qcd_pdf_aux);
}
else {
for(int ib=0;ib<=NPAR;ib++) {
brn[ib]->setConstant(kTRUE);
}
sprintf(name,"qcd_model_aux1_CAT%d",counter);
RooBernstein *qcd_pdf_aux1 = new RooBernstein(name,name,x,brn_params);
sprintf(name,"qcd_model_CAT%d",counter);
RooProdPdf *qcd_pdf_aux2 = new RooProdPdf(name,name,RooArgSet(*transfer,*qcd_pdf_aux1));
qcd_pdf = dynamic_cast<RooAbsPdf*> (qcd_pdf_aux2);
}
sprintf(name,"Z_model_CAT%d",counter);
RooAbsPdf *z_pdf = (RooAbsPdf*)wBkg->pdf(name);
sprintf(name,"Top_model_CAT%d",counter);
RooAbsPdf *top_pdf = (RooAbsPdf*)wBkg->pdf(name);
sprintf(name,"yield_ZJets_CAT%d",counter);
RooRealVar *nZ = (RooRealVar*)wBkg->var(name);
sprintf(name,"yield_Top_CAT%d",counter);
RooRealVar *nT = (RooRealVar*)wBkg->var(name);
sprintf(name,"yield_QCD_CAT%d",counter);
RooRealVar nQCD(name,name,1000,0,1e+10);
nZ->setConstant(kTRUE);
nT->setConstant(kTRUE);
sprintf(name,"bkg_model_CAT%d",counter);
RooAddPdf model(name,name,RooArgList(*z_pdf,*top_pdf,*qcd_pdf),RooArgList(*nZ,*nT,nQCD));
RooFitResult *res = model.fitTo(*roohist[icat],RooFit::Save());
res->Print();
RooPlot* frame = x.frame();
RooPlot* frame1 = x.frame();
roohist[icat]->plotOn(frame);
model.plotOn(frame,LineWidth(2));
cout<<"chi2/ndof = "<<frame->chiSquare()<<endl;
RooHist *hresid = frame->residHist();
//model.plotOn(frame,RooFit::VisualizeError(*res,1,kFALSE),FillColor(kGray)MoveToBack());
model.plotOn(frame,Components(*qcd_pdf),LineWidth(2),LineColor(kBlack),LineStyle(kDashed));
model.plotOn(frame,Components(*z_pdf),LineWidth(2),LineColor(kBlue));
model.plotOn(frame,Components(*top_pdf),LineWidth(2),LineColor(kGreen+1));
frame->Draw();
gPad->Update();
TPad* pad = new TPad("pad", "pad", 0., 0., 1., 1.);
pad->SetTopMargin(0.6);
pad->SetFillColor(0);
pad->SetFillStyle(0);
pad->Draw();
pad->cd(0);
frame1->addPlotable(hresid,"p");
frame1->Draw();
for(int ib=0;ib<=NPAR;ib++) {
brn[ib]->setConstant(kFALSE);
}
if (icat > 0) {
trans_p2.setConstant(kFALSE);
trans_p1.setConstant(kFALSE);
trans_p0.setConstant(kFALSE);
}
if (isel == 0) {
w->import(trans_p1);
w->import(trans_p0);
}
else {
w->import(trans_p2);
w->import(trans_p1);
w->import(trans_p0);
}
w->import(*roohist[icat]);
w->import(*roohist_blind[icat]);
w->import(model);
w->import(*Yield);
counter++;
}// category loop
}// selection loop
w->Print();
w->writeToFile("data_shapes_workspace_"+TString::Format("BRN%d",BRN_ORDER)+".root");
}
示例9: DrawBoosted
void DrawBoosted(TString VAR, float XMIN, float XMAX, int REBIN, TString XTITLE)
{
gROOT->ForceStyle();
const int N = 7;
float XSEC[N] = {1.74e+6,3.67e+5,2.94e+4,6.524e+03,1.064e+03,121.5,2.542e+01};
TString SAMPLE[N] = {
"QCD_HT200to300",
"QCD_HT300to500",
"QCD_HT500to700",
"QCD_HT700to1000",
"QCD_HT1000to1500",
"QCD_HT1500to2000",
"QCD_HT2000toInf"
};
TFile *inf[N];
TH1F *h0[N],*h1[N];
TH1F *hQCD0,*hQCD1;
TCanvas *can = new TCanvas("Boosted","Boosted",900,600);
can->cd(1);
can->SetBottomMargin(0.3);
//can->SetRightMargin(0.15);
for(int k=0;k<N;k++) {
inf[k] = TFile::Open("Histo_"+SAMPLE[k]+".root");
h0[k] = (TH1F*)inf[k]->Get("hadtopBoost/h_"+VAR+"_Cut_ctl");
h0[k]->Sumw2();
h0[k]->Rebin(REBIN);
h1[k] = (TH1F*)inf[k]->Get("hadtopBoost/h_"+VAR+"_Cut_sig");
h1[k]->Sumw2();
h1[k]->Rebin(REBIN);
h0[k]->Scale(XSEC[k]/((TH1F*)inf[k]->Get("hadtopBoost/TriggerPass"))->GetBinContent(1));
h1[k]->Scale(XSEC[k]/((TH1F*)inf[k]->Get("hadtopBoost/TriggerPass"))->GetBinContent(1));
cout<<SAMPLE[k]<<": "<<h0[k]->GetEntries()<<" "<<h0[k]->Integral()<<endl;
if (k == 0) {
hQCD0 = (TH1F*)h0[k]->Clone();
hQCD1 = (TH1F*)h1[k]->Clone();
}
if (k > 0) {
hQCD0->Add(h0[k]);
hQCD1->Add(h1[k]);
}
}
hQCD0->Scale(1/hQCD0->Integral());
hQCD1->Scale(1/hQCD1->Integral());
double max1 = TMath::Max(hQCD0->GetBinContent(hQCD0->GetMaximumBin()),hQCD1->GetBinContent(hQCD1->GetMaximumBin()));
hQCD0->SetMaximum(1.2*max1);
hQCD0->SetMinimum(1e-4);
hQCD0->GetXaxis()->SetLabelSize(0.0);
hQCD0->GetXaxis()->SetRangeUser(XMIN,XMAX);
hQCD0->Draw("HIST");
hQCD1->Draw("sameE");
TLegend *leg = new TLegend(0.6,0.7,0.9,0.9);
leg->SetHeader("QCD Closure");
leg->SetBorderSize(0);
leg->SetTextFont(42);
leg->SetTextSize(0.05);
leg->AddEntry(hQCD1,"Signal sample","P");
leg->AddEntry(hQCD0,"Control sample","F");
leg->Draw();
TH1F *hRatio = (TH1F*)hQCD1->Clone("Ratio");
hRatio->Divide(hQCD0);
hRatio->SetLineColor(kBlack);
hRatio->SetMarkerColor(kBlack);
TPad* pad = new TPad("pad", "pad", 0., 0., 1., 1.);
pad->SetTopMargin(0.7);
//pad->SetRightMargin(0.15);
pad->SetFillColor(0);
pad->SetFillStyle(0);
pad->Draw();
pad->cd(0);
gPad->SetGridy();
hRatio->GetXaxis()->SetTitle(XTITLE);
hRatio->GetXaxis()->SetRangeUser(XMIN,XMAX);
hRatio->GetYaxis()->SetNdivisions(505);
hRatio->GetYaxis()->SetRangeUser(0,2);
hRatio->GetYaxis()->SetLabelSize(0.04);
hRatio->Draw();
hRatio->Draw("same");
}
示例10: wmj_fit_stack
void wmj_fit_stack()
{
//=========Macro generated from canvas: default_Canvas/defaultCanvas
//========= (Tue May 3 07:35:30 2016) by ROOT version6.04/10
TCanvas *default_Canvas = new TCanvas("default_Canvas", "defaultCanvas",0,0,700,500);
gStyle->SetOptStat(0);
gStyle->SetOptTitle(0);
default_Canvas->SetHighLightColor(2);
default_Canvas->Range(0,0,1,1);
default_Canvas->SetFillColor(0);
default_Canvas->SetBorderMode(0);
default_Canvas->SetBorderSize(2);
default_Canvas->SetTickx(1);
default_Canvas->SetTicky(1);
default_Canvas->SetLeftMargin(0.14);
default_Canvas->SetRightMargin(0.05);
default_Canvas->SetTopMargin(0.05);
default_Canvas->SetBottomMargin(0.16);
default_Canvas->SetFrameLineWidth(2);
default_Canvas->SetFrameBorderMode(0);
// ------------>Primitives in pad: upperPad
TPad *upperPad = new TPad("upperPad", "upperPad",0.005,0.05,0.995,0.995);
upperPad->Draw();
upperPad->cd();
upperPad->Range(-0.1730123,-5358.989,1.06279,32919.5);
upperPad->SetFillColor(0);
upperPad->SetFillStyle(4000);
upperPad->SetBorderMode(0);
upperPad->SetBorderSize(2);
upperPad->SetTickx(1);
upperPad->SetTicky(1);
upperPad->SetLeftMargin(0.14);
upperPad->SetRightMargin(0.05);
upperPad->SetTopMargin(0.05);
upperPad->SetBottomMargin(0.14);
upperPad->SetFrameLineWidth(2);
upperPad->SetFrameBorderMode(0);
upperPad->SetFrameLineWidth(2);
upperPad->SetFrameBorderMode(0);
Double_t h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fx3005[20] = {
0.025,
0.075,
0.125,
0.175,
0.225,
0.275,
0.325,
0.375,
0.425,
0.475,
0.525,
0.575,
0.625,
0.675,
0.725,
0.775,
0.825,
0.875,
0.925,
0.975};
Double_t h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fy3005[20] = {
0,
0,
9,
26,
118,
315,
881,
1812,
3086,
4575,
5856,
6537,
6824,
6348,
5662,
4769,
4941,
6726,
13179,
28019};
Double_t h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_felx3005[20] = {
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
//.........这里部分代码省略.........
示例11: ATLASCMSCOMPARISON
void ATLASCMSCOMPARISON(TString quantity="ttbarMass"){
bool cmssim=true;
// ---
// canvas style
// ---
TStyle myStyle("HHStyle","HHStyle");
setHHStyle(myStyle);
myStyle.SetErrorX(0.5);
myStyle.cd();
gROOT->SetStyle("HHStyle");
gStyle->SetEndErrorSize(10);
gStyle->SetOptFit(0);
// ---
// top Pt 7 TeV
// ---
int Nbins7=7;
if( quantity=="topPt" ) Nbins7=7;
else if(quantity=="ttbarMass") Nbins7=5;
else if(quantity=="ttbarY" ) Nbins7=6;
// CMS data
TGraphAsymmErrors* CMSdata7 = new TGraphAsymmErrors(Nbins7);
if(quantity=="topPt"){
CMSdata7->SetPoint( 0, 25.0 , 0.004032 );
CMSdata7->SetPoint( 1, 75.0 , 0.006746 );
CMSdata7->SetPoint( 2, 125.0, 0.004737 );
CMSdata7->SetPoint( 3, 175.0, 0.002506 );
CMSdata7->SetPoint( 4, 225.0, 0.001140 );
CMSdata7->SetPoint( 5, 300.0, 0.000334 );
CMSdata7->SetPoint( 6, 575.0, 0.000019 );
CMSdata7->SetPointError( 0, 25., 25., ( 5.5/100)*0.004032, ( 5.5/100)*0.004032 );
CMSdata7->SetPointError( 1, 25., 25., ( 4.1/100)*0.006746, ( 4.1/100)*0.006746 );
CMSdata7->SetPointError( 2, 25., 25., ( 4.0/100)*0.004737, ( 4.0/100)*0.004737 );
CMSdata7->SetPointError( 3, 25., 25., ( 5.4/100)*0.002506, ( 5.4/100)*0.002506 );
CMSdata7->SetPointError( 4, 25., 25., ( 5.6/100)*0.001140, ( 5.6/100)*0.001140 );
CMSdata7->SetPointError( 5, 50., 50., ( 8.4/100)*0.000334, ( 8.4/100)*0.000334 );
CMSdata7->SetPointError( 6, 225.,225., (14.1/100)*0.000019, (14.1/100)*0.000019 );
}
else if(quantity=="ttbarMass"){
CMSdata7->SetPoint( 0, 350.0 , 0.002588 );
CMSdata7->SetPoint( 1, 500.0 , 0.002685 );
CMSdata7->SetPoint( 2, 625.0 , 0.000953 );
CMSdata7->SetPoint( 3, 825.0 , 0.000232 );
CMSdata7->SetPoint( 4, 1725.0, 0.000008 );
CMSdata7->SetPointError( 0, 100., 100., ( 4.9 /100)*0.002588, (4.9 /100)*0.002588 );
CMSdata7->SetPointError( 1, 50. , 50. , ( 6.9 /100)*0.002685, (6.9 /100)*0.002685 );
CMSdata7->SetPointError( 2, 75. , 75. , ( 7.7 /100)*0.000953, (7.7 /100)*0.000953 );
CMSdata7->SetPointError( 3, 125., 125., ( 14.4/100)*0.000232, (14.4/100)*0.000232 );
CMSdata7->SetPointError( 4, 775., 775., ( 27.6/100)*0.000008, (27.6/100)*0.000008 );
}
else if(quantity=="ttbarY"){
CMSdata7->SetPoint( 0, -1.75, 0.082140 );
CMSdata7->SetPoint( 1, -0.75, 0.318979 );
CMSdata7->SetPoint( 2, -0.25, 0.427823 );
CMSdata7->SetPoint( 3, 0.25, 0.44591 );
CMSdata7->SetPoint( 4, 0.75, 0.318820 );
CMSdata7->SetPoint( 5, 1.75, 0.080457 );
CMSdata7->SetPointError( 0, 0.75, 0.75, (8.1/100)*0.082140, (8.1/100)*0.082140 );
CMSdata7->SetPointError( 1, 0.25, 0.25, (3.3/100)*0.318979, (3.3/100)*0.318979 );
CMSdata7->SetPointError( 2, 0.25, 0.25, (3.0/100)*0.427823, (3.0/100)*0.427823 );
CMSdata7->SetPointError( 3, 0.25, 0.25, (3.5/100)*0.44591 , (3.5/100)*0.44591 );
CMSdata7->SetPointError( 4, 0.25, 0.25, (3.5/100)*0.318820, (3.5/100)*0.318820 );
CMSdata7->SetPointError( 5, 0.75, 0.75, (5.9/100)*0.080457, (5.9/100)*0.080457 );
}
CMSdata7->SetLineWidth(3.);
CMSdata7->SetMarkerSize(1.2);
CMSdata7->SetMarkerStyle(24);
CMSdata7->SetLineStyle(1);
CMSdata7->SetMarkerColor(kBlue);
CMSdata7->SetLineColor(kBlue);
CMSdata7->SetFillStyle(3004);
CMSdata7->SetFillColor(kBlue);
// CMS MadGraph+Pythia(Z2*)
TGraphAsymmErrors* CMSMadGraph7 = new TGraphAsymmErrors(Nbins7);
if(quantity=="topPt"){
CMSMadGraph7->SetPoint( 0, 25.0 , 0.003331 );
CMSMadGraph7->SetPoint( 1, 75.0 , 0.006495 );
CMSMadGraph7->SetPoint( 2, 125.0, 0.005077 );
CMSMadGraph7->SetPoint( 3, 175.0, 0.002748 );
CMSMadGraph7->SetPoint( 4, 225.0, 0.001282 );
CMSMadGraph7->SetPoint( 5, 300.0, 0.000413 );
CMSMadGraph7->SetPoint( 6, 575.0, 0.000027 );
CMSMadGraph7->SetPointError( 0, 25., 25., 0., 0. );
CMSMadGraph7->SetPointError( 1, 25., 25., 0., 0. );
CMSMadGraph7->SetPointError( 2, 25., 25., 0., 0. );
CMSMadGraph7->SetPointError( 3, 25., 25., 0., 0. );
CMSMadGraph7->SetPointError( 4, 25., 25., 0., 0. );
CMSMadGraph7->SetPointError( 5, 50., 50., 0., 0. );
CMSMadGraph7->SetPointError( 6, 225., 225., 0., 0. );
}
else if(quantity=="ttbarMass"){
//.........这里部分代码省略.........
示例12: test3
void test3()
{
//=========Macro generated from canvas: default_Canvas/defaultCanvas
//========= (Fri May 6 10:50:13 2016) by ROOT version6.04/10
TCanvas *default_Canvas = new TCanvas("default_Canvas", "defaultCanvas",0,0,700,500);
gStyle->SetOptStat(0);
gStyle->SetOptTitle(0);
default_Canvas->SetHighLightColor(2);
default_Canvas->Range(0,0,1,1);
default_Canvas->SetFillColor(0);
default_Canvas->SetBorderMode(0);
default_Canvas->SetBorderSize(2);
default_Canvas->SetTickx(1);
default_Canvas->SetTicky(1);
default_Canvas->SetLeftMargin(0.14);
default_Canvas->SetRightMargin(0.05);
default_Canvas->SetTopMargin(0.05);
default_Canvas->SetBottomMargin(0.16);
default_Canvas->SetFrameLineWidth(2);
default_Canvas->SetFrameBorderMode(0);
// ------------>Primitives in pad: upperPad
TPad *upperPad = new TPad("upperPad", "upperPad",0.005,0.05,0.995,0.995);
upperPad->Draw();
upperPad->cd();
upperPad->Range(1.567901,0.02811051,4.654321,0.1367104);
upperPad->SetFillColor(0);
upperPad->SetFillStyle(4000);
upperPad->SetBorderMode(0);
upperPad->SetBorderSize(2);
upperPad->SetTickx(1);
upperPad->SetTicky(1);
upperPad->SetLeftMargin(0.14);
upperPad->SetRightMargin(0.05);
upperPad->SetTopMargin(0.05);
upperPad->SetBottomMargin(0.14);
upperPad->SetFrameLineWidth(2);
upperPad->SetFrameBorderMode(0);
upperPad->SetFrameLineWidth(2);
upperPad->SetFrameBorderMode(0);
TH1F *test3_red_0_0_norm__1 = new TH1F("test3_red_0_0_norm__1","ETA",10,2,4.5);
test3_red_0_0_norm__1->SetBinContent(1,0.1040398);
test3_red_0_0_norm__1->SetBinContent(2,0.1186439);
test3_red_0_0_norm__1->SetBinContent(3,0.1256071);
test3_red_0_0_norm__1->SetBinContent(4,0.1229555);
test3_red_0_0_norm__1->SetBinContent(5,0.118442);
test3_red_0_0_norm__1->SetBinContent(6,0.1127067);
test3_red_0_0_norm__1->SetBinContent(7,0.09951538);
test3_red_0_0_norm__1->SetBinContent(8,0.08332527);
test3_red_0_0_norm__1->SetBinContent(9,0.06651872);
test3_red_0_0_norm__1->SetBinContent(10,0.0482457);
test3_red_0_0_norm__1->SetBinError(1,0.001708584);
test3_red_0_0_norm__1->SetBinError(2,0.001736969);
test3_red_0_0_norm__1->SetBinError(3,0.001484444);
test3_red_0_0_norm__1->SetBinError(4,0.001426268);
test3_red_0_0_norm__1->SetBinError(5,0.001336676);
test3_red_0_0_norm__1->SetBinError(6,0.00122978);
test3_red_0_0_norm__1->SetBinError(7,0.00125216);
test3_red_0_0_norm__1->SetBinError(8,0.00113555);
test3_red_0_0_norm__1->SetBinError(9,0.0009819959);
test3_red_0_0_norm__1->SetBinError(10,0.0009418311);
test3_red_0_0_norm__1->SetEntries(58129);
test3_red_0_0_norm__1->SetStats(0);
Int_t ci; // for color index setting
TColor *color; // for color definition with alpha
ci = TColor::GetColor("#ff0000");
test3_red_0_0_norm__1->SetFillColor(ci);
test3_red_0_0_norm__1->SetFillStyle(0);
ci = TColor::GetColor("#ff0000");
test3_red_0_0_norm__1->SetLineColor(ci);
test3_red_0_0_norm__1->SetLineWidth(2);
ci = TColor::GetColor("#ff0000");
test3_red_0_0_norm__1->SetMarkerColor(ci);
test3_red_0_0_norm__1->SetMarkerStyle(20);
test3_red_0_0_norm__1->GetXaxis()->SetTitle("#eta");
test3_red_0_0_norm__1->GetXaxis()->SetNdivisions(1005);
test3_red_0_0_norm__1->GetXaxis()->SetLabelFont(132);
test3_red_0_0_norm__1->GetXaxis()->SetLabelOffset(0.02);
test3_red_0_0_norm__1->GetXaxis()->SetLabelSize(0.05);
test3_red_0_0_norm__1->GetXaxis()->SetTitleSize(0.06);
test3_red_0_0_norm__1->GetXaxis()->SetTitleFont(132);
test3_red_0_0_norm__1->GetYaxis()->SetNdivisions(505);
test3_red_0_0_norm__1->GetYaxis()->SetLabelFont(132);
test3_red_0_0_norm__1->GetYaxis()->SetLabelSize(0.05);
test3_red_0_0_norm__1->GetYaxis()->SetTitleSize(0.06);
test3_red_0_0_norm__1->GetYaxis()->SetTitleFont(132);
test3_red_0_0_norm__1->GetZaxis()->SetLabelFont(132);
test3_red_0_0_norm__1->GetZaxis()->SetLabelSize(0.05);
test3_red_0_0_norm__1->GetZaxis()->SetTitleSize(0.06);
test3_red_0_0_norm__1->GetZaxis()->SetTitleFont(132);
test3_red_0_0_norm__1->Draw("");
Double_t xAxis1[11] = {2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 4, 4.25, 4.5};
TH1F *test3_green_0_1_norm__2 = new TH1F("test3_green_0_1_norm__2","ETA",10, xAxis1);
test3_green_0_1_norm__2->SetBinContent(1,0.1214835);
test3_green_0_1_norm__2->SetBinContent(2,0.1235428);
//.........这里部分代码省略.........
示例13: DrawQCDClosure
void DrawQCDClosure(TString VAR,TString XTITLE)
{
gROOT->ForceStyle();
TString FileName[7] = {"QCD_HT200to300","QCD_HT300to500","QCD_HT500to700","QCD_HT700to1000","QCD_HT1000to1500","QCD_HT1500to2000","QCD_HT2000toInf"};
float XSEC[7] = {1.74e+6,3.67e+5,2.94e+4,6.524e+03,1.064e+03,121.5,2.542e+01};
TFile *inf[7];
TH1F *h[7],*h1[7];
TCanvas *can = new TCanvas("can_QCDClosure_"+VAR,"can_QCDClosure_"+VAR,900,600);
can->cd(1);
can->SetBottomMargin(0.3);
can->SetRightMargin(0.15);
for(int i=0;i<7;i++) {
inf[i] = TFile::Open("Histo_"+FileName[i]+".root");
TH1F *hTriggerPass = (TH1F*)inf[i]->Get("hadtopL/TriggerPass");
h[i] = (TH1F*)inf[i]->Get("hadtopL/h_"+VAR);
h1[i] = (TH1F*)inf[i]->Get("hadtop/h_"+VAR);
h[i]->Sumw2();
h1[i]->Sumw2();
h[i]->Rebin(5);
h1[i]->Rebin(5);
h[i]->Scale(XSEC[i]/hTriggerPass->GetBinContent(1));
h1[i]->Scale(XSEC[i]/hTriggerPass->GetBinContent(1));
cout<<hTriggerPass->GetBinContent(1)<<endl;
}
TH1F *hQCD = (TH1F*)h[0]->Clone("hQCD");
TH1F *hQCD1 = (TH1F*)h1[0]->Clone("hQCD1");
for(int i=0;i<7;i++) {
hQCD->Add(h[i]);
hQCD1->Add(h1[i]);
}
hQCD->SetFillColor(kGray);
hQCD->Scale(1./hQCD->Integral());
hQCD1->Scale(1./hQCD1->Integral());
hQCD->GetXaxis()->SetLabelSize(0.0);
double max = 1.1*TMath::Max(hQCD->GetBinContent(hQCD->GetMaximumBin()),hQCD1->GetBinContent(hQCD1->GetMaximumBin()));
hQCD->SetMinimum(1e-5);
hQCD->SetMaximum(max);
hQCD->Draw("hist");
hQCD1->Draw("sameE");
gPad->RedrawAxis();
TLegend *leg = new TLegend(0.86,0.65,0.99,0.9);
leg->SetFillColor(0);
leg->SetTextFont(42);
leg->SetTextSize(0.03);
leg->AddEntry(hQCD,"Control","F");
leg->AddEntry(hQCD1,"Signal","LP");
leg->Draw();
TH1F *hRatio = (TH1F*)hQCD1->Clone("Ratio");
hRatio->Divide(hQCD);
TPad* pad = new TPad("pad", "pad", 0., 0., 1., 1.);
pad->SetTopMargin(0.7);
pad->SetRightMargin(0.15);
pad->SetFillColor(0);
pad->SetFillStyle(0);
pad->Draw();
pad->cd(0);
gPad->SetGridy();
hRatio->GetXaxis()->SetTitle(XTITLE);
hRatio->GetYaxis()->SetNdivisions(505);
hRatio->GetYaxis()->SetRangeUser(0,2);
hRatio->GetYaxis()->SetLabelSize(0.04);
hRatio->Draw();
}
示例14: DrawQCDClosure
//.........这里部分代码省略.........
"QCD_Pt_1000to1400",
"QCD_Pt_1400to1800",
"QCD_Pt_1800to2400",
"QCD_Pt_2400to3200",
"QCD_Pt_3200toInf"
};
TFile *inf[N];
TTree *tr0[N],*tr1[N],*tr2[N];
TH1F *h0[N],*h1[N],*h2[N];
TCanvas *can = new TCanvas("can_QCDClosure_"+VAR,"can_QCDClosure_"+VAR,900,600);
can->cd(1);
can->SetBottomMargin(0.3);
can->SetRightMargin(0.15);
for(int i=0;i<N;i++) {
inf[i] = TFile::Open("flatTree_"+SAMPLE[i]+".root");
tr0[i] = (TTree*)inf[i]->Get("hadtopNoBtag/events");
tr1[i] = (TTree*)inf[i]->Get("hadtopOneBtag/events");
tr2[i] = (TTree*)inf[i]->Get("hadtop/events");
TH1F *hpu = (TH1F*)inf[i]->Get("hadtop/pileup");
h0[i] = new TH1F("h0_"+SAMPLE[i],"h0_"+SAMPLE[i],NBINS,XMIN,XMAX);
h1[i] = new TH1F("h1_"+SAMPLE[i],"h1_"+SAMPLE[i],NBINS,XMIN,XMAX);
h2[i] = new TH1F("h2_"+SAMPLE[i],"h2_"+SAMPLE[i],NBINS,XMIN,XMAX);
h0[i]->Sumw2();
h1[i]->Sumw2();
h2[i]->Sumw2();
tr0[i]->Draw(VAR+">>"+"h0_"+SAMPLE[i],"triggerBit[0] && prob>0.05 && nBJets==0 && dRbbTop>2");
tr1[i]->Draw(VAR+">>"+"h1_"+SAMPLE[i],"triggerBit[0] && prob>0.05 && nBJets==1 && dRbbTop>2");
tr2[i]->Draw(VAR+">>"+"h2_"+SAMPLE[i],"triggerBit[0] && prob>0.05 && nBJets>1 && dRbbTop>2");
h0[i]->Scale(XSEC[i]/hpu->GetEntries());
h1[i]->Scale(XSEC[i]/hpu->GetEntries());
h2[i]->Scale(XSEC[i]/hpu->GetEntries());
cout<<SAMPLE[i]<<" "<<hpu->GetEntries()<<" "<<h0[i]->GetEntries()<<" "<<h1[i]->GetEntries()<<" "<<h2[i]->GetEntries()<<endl;
}
TH1F *hQCD0 = (TH1F*)h0[0]->Clone("hQCD0");
TH1F *hQCD1 = (TH1F*)h1[0]->Clone("hQCD1");
TH1F *hQCD2 = (TH1F*)h2[0]->Clone("hQCD2");
for(int i=1;i<N;i++) {
hQCD0->Add(h0[1]);
hQCD1->Add(h1[1]);
hQCD2->Add(h2[1]);
}
hQCD0->SetFillColor(kGray);
hQCD1->SetLineColor(kBlack);
hQCD1->SetMarkerColor(kBlack);
hQCD1->SetMarkerStyle(21);
hQCD2->SetLineColor(kRed);
hQCD2->SetMarkerColor(kRed);
hQCD2->SetMarkerStyle(20);
hQCD0->Scale(1./hQCD0->Integral());
hQCD1->Scale(1./hQCD1->Integral());
hQCD2->Scale(1./hQCD2->Integral());
hQCD0->GetXaxis()->SetLabelSize(0.0);
double max = 1.1*TMath::Max(hQCD0->GetBinContent(hQCD0->GetMaximumBin()),hQCD2->GetBinContent(hQCD2->GetMaximumBin()));
hQCD0->SetMinimum(1e-5);
hQCD0->SetMaximum(max);
hQCD0->Draw("hist");
hQCD1->Draw("sameE");
hQCD2->Draw("sameE");
gPad->RedrawAxis();
TLegend *leg = new TLegend(0.86,0.65,0.99,0.9);
leg->SetFillColor(0);
leg->SetTextFont(42);
leg->SetTextSize(0.03);
leg->AddEntry(hQCD0,"Zero btag","F");
leg->AddEntry(hQCD1,"One btag","LP");
leg->AddEntry(hQCD2,"Two btag","LP");
leg->Draw();
TH1F *hRatio0 = (TH1F*)hQCD2->Clone("Ratio0");
hRatio0->Divide(hQCD0);
TH1F *hRatio1 = (TH1F*)hQCD2->Clone("Ratio1");
hRatio1->Divide(hQCD1);
hRatio0->SetLineColor(kBlack);
hRatio0->SetMarkerColor(kBlack);
TPad* pad = new TPad("pad", "pad", 0., 0., 1., 1.);
pad->SetTopMargin(0.7);
pad->SetRightMargin(0.15);
pad->SetFillColor(0);
pad->SetFillStyle(0);
pad->Draw();
pad->cd(0);
gPad->SetGridy();
hRatio0->GetXaxis()->SetTitle(XTITLE);
hRatio0->GetYaxis()->SetNdivisions(505);
hRatio0->GetYaxis()->SetRangeUser(0,2);
hRatio0->GetYaxis()->SetLabelSize(0.04);
hRatio0->Draw();
hRatio1->Draw("same");
}
示例15: DrawVariable
//.........这里部分代码省略.........
hQCD->Scale(kfactor);
TH1F *hBkg = (TH1F*)hQCD->Clone("hBkg");
hBkg->Add(h[1]);
hBkg->Add(h[2]);
hBkg->Add(h[3]);
hBkg->Add(h[4]);
hBkg->Add(hST);
//hBkg->SetFillColor(kGray);
cout<<"======== "<<VAR<<"====================="<<endl;
cout<<"Data events: "<<h[0]->Integral()<<endl;
cout<<"QCD events: "<<hQCD->Integral()<<endl;
cout<<"WJets events: "<<h[2]->Integral()<<endl;
cout<<"ZJets events: "<<h[3]->Integral()<<endl;
cout<<"ST events: "<<hST->Integral()<<endl;
cout<<"TTbar events: "<<h[1]->Integral()<<endl;
cout<<"kfactor: "<<kfactor<<endl;
THStack *hs = new THStack("hs","hs");
if (LOG) {
hs->Add(h[2]);
hs->Add(h[3]);
hs->Add(hST);
hs->Add(hQCD);
hs->Add(h[1]);
}
else {
hs->Add(h[3]);
hs->Add(hST);
hs->Add(h[2]);
hs->Add(hQCD);
hs->Add(h[1]);
}
TH1F *hRatio = (TH1F*)h[0]->Clone("Ratio");
hRatio->SetLineWidth(2);
hRatio->Divide(hBkg);
TLegend *leg = new TLegend(0.86,0.7,0.99,0.9);
leg->SetFillColor(0);
leg->SetTextFont(42);
leg->SetTextSize(0.03);
leg->AddEntry(hQCD,"QCD","F");
leg->AddEntry(h[1],"TTbar","F");
leg->AddEntry(hST,"ST","F");
leg->AddEntry(h[2],"WJets","F");
leg->AddEntry(h[3],"ZJets","F");
can->SetBottomMargin(0.25);
TH1F *hAux = (TH1F*)h[0]->Clone("aux");
hAux->Reset();
hAux->GetXaxis()->SetNdivisions(XNDIV);
if (isINT) {
hAux->GetXaxis()->CenterLabels();
}
hAux->GetYaxis()->SetRangeUser(0.5,1.1*TMath::Max(hBkg->GetBinContent(hBkg->GetMaximumBin()),h[0]->GetBinContent(h[0]->GetMaximumBin())));
if (LOG) {
gPad->SetLogy();
hAux->GetYaxis()->SetRangeUser(0.5,2*TMath::Max(hBkg->GetBinContent(hBkg->GetMaximumBin()),h[0]->GetBinContent(h[0]->GetMaximumBin())));
}
hAux->GetXaxis()->SetRangeUser(XMIN,XMAX);
hAux->GetYaxis()->SetTitle(TString::Format("Number of events / %1.2f fb^{-1}",LUMI/1000));
hAux->GetXaxis()->SetTitle("");
hAux->GetXaxis()->SetLabelSize(0.0);
hAux->Draw();
hs->Draw("hist same");
//hBkg->Draw("sames hist");
h[0]->Draw("sames E");
leg->Draw();
gPad->RedrawAxis();
TPad *pad = new TPad("pad","pad",0.,0.,1.,1.);
pad->SetTopMargin(0.77);
pad->SetRightMargin(0.15);
pad->SetFillColor(0);
pad->SetFillStyle(0);
pad->Draw();
pad->cd(0);
pad->SetGridy();
hRatio->GetXaxis()->SetTitleOffset(0.95);
hRatio->GetYaxis()->SetTitleOffset(1.5);
hRatio->GetYaxis()->SetTickLength(0.06);
hRatio->GetYaxis()->SetTitleSize(0.03);
hRatio->GetYaxis()->SetLabelSize(0.03);
hRatio->GetYaxis()->SetTitle("Data/MC");
hRatio->GetXaxis()->SetTitle(XTITLE);
hRatio->GetXaxis()->SetRangeUser(XMIN,XMAX);
hRatio->GetYaxis()->SetRangeUser(0.5,1.5);
hRatio->GetYaxis()->SetNdivisions(505);
hRatio->GetXaxis()->SetNdivisions(XNDIV);
if (isINT) {
hRatio->GetXaxis()->CenterLabels();
}
hRatio->Draw();
if (PRINT) {
can->Print("plots/"+TString(can->GetName())+".pdf");
can->Print("plots/"+TString(can->GetName())+".png");
}
}