本文整理汇总了C++中THStack::GetMaximum方法的典型用法代码示例。如果您正苦于以下问题:C++ THStack::GetMaximum方法的具体用法?C++ THStack::GetMaximum怎么用?C++ THStack::GetMaximum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THStack
的用法示例。
在下文中一共展示了THStack::GetMaximum方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void Draw(const int &rebin=1) {
Color_t _sampleColor[nSamples];
//_sampleColor[iHWW ] = kRed+1;
//_sampleColor[iWW ] = kAzure-9;
//_sampleColor[iZJets] = kGreen+2;
//_sampleColor[iZTau] = kGreen+2;
//_sampleColor[iTop ] = kYellow;
//_sampleColor[iWZ ] = kAzure-2;
//_sampleColor[iWJets] = kGray+1;
//_sampleColor[iWJets] = kViolet-9;
//_sampleColor[iWJets] = kCyan;
_sampleColor[itH ] = kRed;
_sampleColor[iWZ ] = kAzure-9;
_sampleColor[iZZ ] = kAzure-5;
_sampleColor[iWW ] = kAzure-1;
_sampleColor[itt ] = kGray;
_sampleColor[ittw ] = kOrange+7;
_sampleColor[ittz ] = kOrange+1;
_sampleColor[iwww ] = kSpring+9;
_sampleColor[iwwz ] = kSpring+3;
_sampleColor[iwzz ] = kSpring-7;
_sampleColor[idyl ] = kViolet-1;
_sampleColor[idy ] = kViolet-1;
//setUpStyle();
if(!gPad) new TCanvas();
THStack* hstack = new THStack();
for (int i=0; i<nSamples; i++) {
// in case the user doesn't set it
if( !_hist[i] ) continue;
_hist[i]->Rebin(rebin);
_hist[i]->SetLineColor(_sampleColor[i]);
// signal gets overlaid
if (i == itH) continue;
_hist[i]->SetFillColor(_sampleColor[i]);
_hist[i]->SetFillStyle(1001);
hstack->Add(_hist[i]);
}
if(_hist[itH]) _hist[itH]->SetLineWidth(3);
if(_data) _data->Rebin(rebin);
if(_data) _data->SetLineColor (kBlack);
if(_data) _data->SetMarkerStyle(kFullCircle);
if(_nostack) {
for(int ihist=0;ihist<(int)_hist.size();ihist++) {
_hist[ihist]->SetFillStyle(0);
_hist[ihist]->SetLineWidth(2);
}
hstack->Draw("hist,nostack");
if(_hist[itH]) _hist[itH]->Draw("hist,same");
if(_data) _data->Draw("ep,same");
} else {
hstack->Draw("hist");
if(_hist[itH]) _hist[itH]->Draw("hist,same");
if(_data) _data->Draw("ep,same");
}
//hstack->SetTitle("CMS preliminary");
Float_t theMax = hstack->GetMaximum();
Float_t theMin = hstack->GetMinimum();
theMax = 1.0;
//Float_t theMin = hstack->GetMinimum();
if (_hist[itH]) {
if (_hist[itH]->GetMaximum() > theMax) theMax = _hist[itH]->GetMaximum();
if (_hist[itH]->GetMinimum() < theMin) theMin = _hist[itH]->GetMinimum();
}
if (_data) {
Float_t dataMax = GetMaximumIncludingErrors(_data);
if (dataMax > theMax) theMax = dataMax;
}
if (gPad->GetLogy()) {
hstack->SetMaximum(500 * theMax);
hstack->SetMinimum(0.05);
} else {
hstack->SetMaximum(1.55 * theMax);
}
if(_breakdown) {
THStackAxisFonts(hstack, "y", "entries");
hstack->GetHistogram()->LabelsOption("v");
} else {
THStackAxisFonts(hstack, "x", TString::Format("%s [%s]",_xLabel.Data(),_units.Data()));
if(_units.Sizeof() == 1) {
THStackAxisFonts(hstack, "x", _xLabel.Data());
THStackAxisFonts(hstack, "y", "entries");
//.........这里部分代码省略.........
示例2: makePlots_csvSF_13TeV
//.........这里部分代码省略.........
}
TH1D* h_diff = (TH1D*) h_csv_data->Clone( Form("csv_diff_Pt%i_Eta%i",iPt,iEta) );
THStack *hs = new THStack("hs","");
if( isHF ){
hs->Add(h_csv_mc_b);
hs->Add(h_csv_mc_nonb);
h_diff->Add(h_csv_mc_nonb,-1);
}
else{
hs->Add(h_csv_mc_nonb);
hs->Add(h_csv_mc_b);
h_diff->Add(h_csv_mc_b,-1);
}
TH1D* h_ratio = (TH1D*) h_diff->Clone( Form("csv_ratio_Pt%i_Eta%i",iPt,iEta) );
if( isHF ) h_ratio->Divide( h_csv_mc_b );
else h_ratio->Divide( h_csv_mc_nonb );
TString title = Form("%s SF Pt%i Eta%i",flavor.Data(),iPt,iEta);
TLatex BinInfoLatex(0.6, 0.81, title.Data());//(0.6, 0.86, title.Data());
BinInfoLatex.SetNDC();
BinInfoLatex.SetTextFont(42);
BinInfoLatex.SetTextSize(0.04);
h_csv_data->GetYaxis()->SetTitleOffset(1.2);
// h_csv_data->GetXaxis()->SetRangeUser(-0.041,0.9489);
h_csv_data->SetMaximum(1.3*TMath::Max(h_csv_data->GetMaximum(), hs->GetMaximum()));
h_csv_data->Draw("pe1");
hs->Draw("histsame");
h_csv_data->Draw("pe1same");
legend->Draw();
// BinInfoLatex.Draw();
LumiInfoLatex.Draw();
CMSInfoLatex.Draw();
PublishInfoLatex.Draw();
ETASELECTIONInfoLatex.Draw();
PTSELECTIONInfoLatex.Draw();
c1->RedrawAxis();
plotName = dirprefix + Form("%s_%s_SF_Pt%i_Eta%i_astack",taggerName.Data(),flavor.Data(),iPt,iEta) + ".pdf";
c1->Print(plotName.Data());
// TLegend *legend_diff = new TLegend(0.14,0.85,0.9,0.9);//new TLegend(0.14,0.93,0.9,0.98);
TLegend *legend_diff = new TLegend(0.57,0.57,0.87,0.77);
legend_diff->SetFillColor(kWhite);
legend_diff->SetLineColor(kWhite);
legend_diff->SetShadowColor(kWhite);
legend_diff->SetTextFont(42);
legend_diff->SetTextSize(0.05);
legend_diff->SetNColumns(1);
if( isHF ){
示例3: shape
//.........这里部分代码省略.........
ttbarH.push_back(new TH1D(sttbarH.c_str(), "ttbar", vvariable[i].GetBins(), vvariable[i].GetXMin(), vvariable[i].GetXMax()));
wjetsH.push_back(new TH1D(swjetsH.c_str(), "wjets", vvariable[i].GetBins(), vvariable[i].GetXMin(), vvariable[i].GetXMax()));
stopH.push_back(new TH1D(sstopH.c_str(), "Signal", vvariable[i].GetBins(), vvariable[i].GetXMin(), vvariable[i].GetXMax()));
backgroundH.push_back(new TH1D(sbackgroundH.c_str(), "Background", vvariable[i].GetBins(), vvariable[i].GetXMin(), vvariable[i].GetXMax()));
ttbarH[i]->SetFillColor(kGreen-7);
ttbarH[i]->SetLineColor(kGreen-7);
wjetsH[i]->SetFillColor(kAzure+5);
wjetsH[i]->SetLineColor(kAzure+5);
//stopH->SetFillColor(kRed);
stopH[i]->SetLineColor(kRed);
if(vvariable.size()!=1)
c1->cd(i+1);
else
c1->cd();
//Create TCuts
TCut muon = "(abs(LepID)==13)&&(LepIso03<0.2)";
TCut electron = "(abs(LepID)==11)&&(LepIso03<0.2)";
TCut emu = muon||electron;
TCut ISRjet = "Jet1Pt > 110";
TCut met = "Met > 300";
TCut jetLepMass = "JetLepMass < 100";
//TCut njets = "Njet > 1";
TCut lepPt = "LepPt < 17";
//TCut ht30 = "HT30 > 300";
//TCut ht20 = "HT20 > 450";
//TCut mt = "mt < 70";
TCut jethbpt = "JetHBpt < 80";
TCut selection = emu && ISRjet && met;
// Fill histogram(s) signal & BACKGROUND & DATA
ttbarTree->Draw((vvariable[i].GetExpression()+">>"+sttbarH).c_str(),"XS*5000/Nevt"*(selection),"goff");
wjetsTree->Draw((vvariable[i].GetExpression()+">>"+swjetsH).c_str(),"XS*5000/Nevt"*(selection),"goff");
stopTree->Draw((vvariable[i].GetExpression()+">>"+sstopH).c_str(),"XS*5000/Nevt"*(selection),"goff"); //MULTIPLICAR O SINAL
// Normalize
double BGIntegral = ttbarH[i]->Integral(0,ttbarH[i]->GetNbinsX()+2) + wjetsH[i]->Integral(0,wjetsH[i]->GetNbinsX()+2);
double stopIntegral = stopH[i]->Integral(0,stopH[i]->GetNbinsX()+2);
for(int j=0; j < stopH[i]->GetNbinsX()+2; j++)
{
stopH[i]->SetBinContent(j, stopH[i]->GetBinContent(j)/stopIntegral);
ttbarH[i]->SetBinContent(j, ttbarH[i]->GetBinContent(j)/BGIntegral);
wjetsH[i]->SetBinContent(j, wjetsH[i]->GetBinContent(j)/BGIntegral);
}
THStack *Stack = new THStack(vvariable[i].GetName().c_str(), (vvariable[i].GetName()+";"+vvariable[i].GetLeg().c_str()+";AU").c_str());
Stack->Add(ttbarH[i]);
Stack->Add(wjetsH[i]);
gPad->SetLogy(vvariable[i].GetLogy());
// Draw plots
gStyle->SetOptStat(0);
Stack->Draw("HIST");
stopH[i]->Draw("HIST same");
if(Stack->GetMaximum() > stopH[i]->GetMaximum())
{
Stack->SetMaximum(Stack->GetMaximum()*1.05);
}
else
{
Stack->SetMaximum(stopH[i]->GetMaximum()*1.05);
}
//TLegend * legenda = gPad->BuildLegend(0.895,0.69,0.65,0.89,"NDC");
// Draw in Canvas c2 - Pad1
c2->cd();
gPad->SetLogy(vvariable[i].GetLogy());
Stack->Draw("HIST goff");
stopH[i]->Draw("HIST same goff");
//TLegend * legenda2 = gPad->BuildLegend(0.8,0.69,0.65,0.89,"NDC");
// Save individual plots as .pdf and .C
//c2->SaveAs(("plots/"+vvariable[i].GetName()+".pdf").c_str());
//c2->SaveAs(("plots/"+vvariable[i].GetName()+".C").c_str());
delete c2;
}
//delete the vectors
//Save file with all the plots
c1->SaveAs("plots/shape.png");
c1->SaveAs("plots/shape.C");
return 0;
}
示例4: postFitPlotsCOMBINEINSERT
//.........这里部分代码省略.........
THStack* stack = new THStack("stack","");
stack->Add(hFAKES);
stack->Add(hWW);
stack->Add(hWGamma);
stack->Add(hDY);
stack->Add(hTT);
stack->Add(hTOP);
stack->Add(hZTauTau);
stack->Add(hSMHIGGS);;
stack->Add(hSMHWWHIGGS);
stack->Add(hSignal);
int bins=hdata_obs->GetNbinsX()+1;
/*
cout<<"Yields "<<endl;
cout<<"DATA \t" <<hdata_obs->Integral()+hdata_obs->GetBinContent(bins)<<endl;
cout<<"VV \t" <<hWW->Integral()+hWW->GetBinContent(bins)<<endl;
cout<<"TOP \t" <<hTOP->Integral()+hTOP->GetBinContent(bins)<<endl;
cout<<"TT \t" <<hTT->Integral()+hTT->GetBinContent(bins)<<endl;
cout<<"DY \t" <<hDY->Integral()+hDY->GetBinContent(bins)<<endl;
cout<<"ZTauTau \t" <<hZTauTau->Integral()+hZTauTau->GetBinContent(bins)<<endl;
cout<<"FAKES \t" <<hFAKES->Integral()+hFAKES->GetBinContent(bins)<<endl;
cout<<"hFAKESLEPTON \t" <<hFAKESLEPTON->Integral()+hFAKESLEPTON->GetBinContent(bins)<<endl;
cout<<"hSMHIGGS \t" <<hSMHIGGS->Integral()+hSMHWWHIGGS->Integral()+hSMHIGGS->GetBinContent(bins)+hSMHWWHIGGS->GetBinContent(bins)<<endl;
cout<<"LFVGG126 \t" <<hLFVGG126->Integral()+hLFVGG126->GetBinContent(bins)<<endl;
cout<<"LFVVBF126 \t" <<hLFVVBF126->Integral()+hLFVVBF126->GetBinContent(bins)<<endl;
*/
stack->Draw("samehist");
fullMC2->Draw("sames,E2");
// hSignal->Draw("sameshist");
double maxData=hdata_obs->GetMaximum();
double maxMC=stack->GetMaximum()*1.2;
double maxLFV=hSignal->GetMaximum();
double minMC=stack->GetMinimum();
if(maxData>maxMC) {maxMC=1.2*maxData;}
if(maxLFV>maxMC) {maxMC=1.2*maxLFV;}
if(MAX!=-1) {maxMC=MAX;}
if(minMC<1) minMC=0;
stack->SetMaximum(maxMC);
stack->GetYaxis()->SetRangeUser(minMC,maxMC);
fullMC2->SetMaximum(maxMC);
fullMC2->GetYaxis()->SetRangeUser(minMC,maxMC);
hdata_obs->Draw("sames");
TLegend *leg = new TLegend(legx1,legy1,legx2,legy2,NULL,"brNDC");
leg->SetFillColor(0);
leg->SetBorderSize(0);
leg->SetFillStyle(0);
TLegendEntry *entry;
entry=leg->AddEntry(hdata_obs,"Data","p");
entry=leg->AddEntry(fullMC2,"Bkgd. uncertainty","f");
//entry=leg->AddEntry(hSMHWWHIGGS,"SM HWW","f");
entry=leg->AddEntry(hSMHIGGS,"SM H","f");
entry=leg->AddEntry(hZTauTau,"Z#rightarrow#tau#tau","f");
entry=leg->AddEntry(hDY,"Other","f");
entry=leg->AddEntry(hTOP,"t#bar{t}, t, #bar{t}","f");
entry=leg->AddEntry(hFAKES,"MisID'd #tau, e, #mu","f");
entry=leg->AddEntry(hSignal,"LFV Higgs, (B=0.9%)","l");
// entry=leg->AddEntry("NULL","Br(h#rightarrow#mu#tau)=1%","");
示例5: compareDataStackMC
//.........这里部分代码省略.........
h_deno[ifile] -> SetFillColor(COLORCODE[ifile]);
h_deno[ifile] -> SetFillStyle(1001);
h_deno[ifile] -> SetMarkerColor(COLORCODE[ifile]);
h_deno[ifile] -> Sumw2();
double weight = myMCFiles[ifile].scaleFactor;
h_deno[ifile] -> Scale(weight);
if(ifile==nfiles-1)
{
h_all -> Rebin(rebin);
h_all -> Sumw2();
}
h_all -> Add(h_deno[ifile]);
hs -> Add(h_deno[ifile]);
// to be used with TEfficiency methods
cout << h_deno[ifile]->GetEntries() << endl;
} // end of loop over files
float x1NDC = 0.620968;
float y1NDC = 0.684322;
float x2NDC = 0.762097;
float y2NDC = 0.898305;
TLegend* leg = new TLegend(x1NDC,y1NDC,x2NDC,y2NDC);
leg->SetFillColor(0);
leg->SetFillStyle(0);
leg->SetTextSize(0.04);
leg->SetBorderSize(0);
leg->AddEntry(h_data,mcName[0].data());
for(int i=0; i < nfiles; i++)
leg->AddEntry(h_deno[i], mcName[i+1].data());
int maxBin = h_data->GetMaximumBin();
double max = h_data->GetMaximum()+h_data->GetBinError(maxBin);
double maxmc = hs->GetMaximum();
if(maxmc>max)max=maxmc;
h_data->SetMaximum(1.1*max);
TCanvas* c1 = new TCanvas("c1",inputFile.data(),0,0,500,500);
h_data->SetMarkerSize(1);
h_data->SetMarkerStyle(24);
h_data->SetTitle("");
h_data->Draw("e");
if(xmin>-9999 && xmax>-9999) {
h_data->GetXaxis()->SetRangeUser(xmin,xmax);
}
cout << "Data integral = " << h_data->Integral() << endl;
hs->Draw("histsame");
h_data->Draw("esame");
leg->Draw("same");
std::string dirName = "compareDataMC_" + leptonName;
gSystem->mkdir(dirName.data());
std::string filename;
std::string psname ;
psname = dirName+ "/overlay_" + histoName;
filename = psname + ".eps";
c1->Print(filename.data());
filename = psname + ".gif";
c1->Print(filename.data());
filename = psname + ".pdf";
示例6: DrawFit
//===============================
void DrawFit(Double_t nSigma, Int_t iRapBin, Int_t iPTBin){
Char_t name[100];
//prepare the drawing of the individual components:
fBG->SetFillColor(colour[BG]);
fBG->SetLineColor(colour[BG]);
fBG->SetFillStyle(1001);
fBG->SetNpx(1000);
TH1 *hBG = fBG->GetHistogram();
fUps1S->SetNpx(1000);
fUps1S->SetFillColor(colour[UPS1S]);
fUps1S->SetLineColor(colour[UPS1S]);
fUps1S->SetFillStyle(1001);
fUps2S->SetNpx(1000);
fUps2S->SetFillColor(colour[UPS2S]);
fUps2S->SetLineColor(colour[UPS2S]);
fUps2S->SetFillStyle(1001);
fUps3S->SetNpx(1000);
fUps3S->SetFillColor(colour[UPS3S]);
fUps3S->SetLineColor(colour[UPS3S]);
fUps3S->SetFillStyle(1001);
TH1 *hUps1S = fUps1S->GetHistogram();
TH1 *hUps2S = fUps2S->GetHistogram();
TH1 *hUps3S = fUps3S->GetHistogram();
THStack *hStack = new THStack("hMass_Stack", "");
hStack->Add(hBG);
hStack->Add(hUps3S);
hStack->Add(hUps2S);
hStack->Add(hUps1S);
hStack->Draw("same");
hMass->Draw("same");
fRECO->Draw("same");
TLine *line[3];
Double_t max[3] = {0.5, 0.5, 0.3};
for(int iL = 0; iL < 3; iL++){
line[iL]= new TLine(massMin[iL], 0.1, massMin[iL], max[iL]*hUps1S->GetMaximum());
line[iL]->SetLineStyle(2); line[iL]->SetLineColor(colour[iL]);
line[iL]->SetLineWidth(2); line[iL]->Draw();
line[iL]->DrawLine(massMax[iL], 0.1, massMax[iL], max[iL]*hUps1S->GetMaximum());
}
if(iRapBin == 0) sprintf(name, "|y| < %1.1f", onia::rapYPS);
else if(iRapBin == 1) sprintf(name, "|y| < %1.1f", onia::rapForPTRange[iRapBin]);
else if(iRapBin > 1) sprintf(name, "%1.1f < |y| < %1.1f", onia::rapForPTRange[iRapBin-1], onia::rapForPTRange[iRapBin]);
TLatex *tex = new TLatex(8.5, hStack->GetMaximum(), name);
tex->SetTextSize(0.04); tex->Draw();
if(iPTBin == 0) sprintf(name, "all p_{T}");
// else if(iPTBin == 1) sprintf(name, "p_{T} < %1.1f GeV", onia::pTRange[iRapBin][iPTBin]);
else sprintf(name, "%1.1f < p_{T} < %1.1f", onia::pTRange[iRapBin][iPTBin-1], onia::pTRange[iRapBin][iPTBin]);
tex->DrawLatex(8.5, 0.94*hStack->GetMaximum(), name);
sprintf(name, "frac(BG) in #pm %1.1f#sigma:", nSigma);
tex->DrawLatex(8.5, 0.86*hStack->GetMaximum(), name);
sprintf(name, "%1.2f, %1.2f, %1.2f", fracBG[0], fracBG[1], fracBG[2]);
tex->DrawLatex(8.5, 0.80*hStack->GetMaximum(), name);
sprintf(name, "Figures/massFit_rap%d_pT%d.pdf", iRapBin, iPTBin); gPad->Print(name);
}
示例7: Draw
//.........这里部分代码省略.........
THStack *stack = new THStack("stack","stack");
if (b_ordering){
stack ->Add(hist_b);
stack ->Add(hist_gsplit);
stack ->Add(hist_c);
stack ->Add(hist_l);
}
else {
stack ->Add(hist_l);
stack ->Add(hist_c);
stack ->Add(hist_gsplit);
stack ->Add(hist_b);
}
gStyle->SetOptTitle(0);
gStyle->SetOptStat(0);
//gStyle->SetLogy(log);
TCanvas *c1 = new TCanvas("c1", "c1",10,32,782,552);
c1->SetFillColor(10);
c1-> cd();
TPad* canvas_1 = new TPad("canvas_1", "canvas_1",0,0.25,1.0,0.98);
canvas_1 ->Draw();
canvas_1 ->cd();
canvas_1->SetLogy(log);
if (hist_data->GetMaximum() > stack->GetMaximum() ) stack->SetMaximum( hist_data->GetMaximum()*1.1) ;
float xmov=1;
if (move_legend==2) {
if (log) xmov=5;
else xmov=1.1;
stack->SetMaximum( xmov*stack->GetMaximum() ) ;
}
if (stack->GetMinimum()> hist_l->GetMinimum()) {
if (log && hist_l->GetMinimum()>0.) stack->SetMinimum(hist_l->GetMinimum());
else if (!log) stack->SetMinimum(hist_l->GetMinimum());
}
stack ->Draw("hist");
stack ->GetHistogram()->GetXaxis()->SetTitle(name);
stack ->GetHistogram()->GetYaxis()->SetTitle("entries");
stack ->GetHistogram()->SetTitleSize(0.08,"Y");
stack ->GetHistogram()->SetTitleOffset(0.65,"Y");
hist_data->Draw("same e");
// TLegend* qw = new TLegend(0.54,0.63,0.88,0.9);
TLegend* qw;
if (move_legend==1) {
qw = new TLegend(0.35,0.15,0.70,0.42);
}
else if (move_legend==3) {
qw = new TLegend(0.35,0.63,0.70,0.90);
}
else qw = new TLegend(0.6,0.73,0.95,1.);
示例8: DrawTTbar
void DrawTTbar(TString name, TString histotitle, bool log, int move_legend)
{
TH1F* hist_ttbar;
TH1F* hist_dy;
TH1F* hist_st;
TH1F* hist_data;
TFile *myFile = new TFile(filename);
myFile->cd();
hist_ttbar = (TH1F*)gROOT->FindObject(name+"_ttbar");
hist_dy = (TH1F*)gROOT->FindObject(name+"_dy");
hist_st = (TH1F*)gROOT->FindObject(name+"_st");
hist_data = (TH1F*)gROOT->FindObject(name+"_data");
if (bOverflow) {
OverFlowBinFix(hist_ttbar);
OverFlowBinFix(hist_dy);
OverFlowBinFix(hist_st);
OverFlowBinFix(hist_data);
}
TH1F* histo_tot = (TH1F*) hist_ttbar->Clone();
histo_tot->Sumw2();
histo_tot ->Add(hist_dy);
histo_tot ->Add(hist_st);
/*
float scale_f = (hist_data->Integral())/(hist_tot->Integral());
hist_ttbar ->Scale(scale_f);
hist_dy ->Scale(scale_f);
hist_st ->Scale(scale_f);
histo_tot ->Scale(scale_f);
*/
double titleoffsety=0.2;
double titlesizex=0.17;
double titlesizey=0.2;
double labelsizex=0.14;
double labelsizey=0.12;
hist_data ->GetYaxis()->SetLabelSize(labelsizey);
hist_data ->GetYaxis()->SetTitleSize(titlesizey);
hist_data ->GetYaxis()->SetTitleOffset(titleoffsety);
hist_ttbar ->GetYaxis()->SetLabelSize(labelsizey);
hist_ttbar ->GetYaxis()->SetTitleSize(titlesizey);
hist_ttbar ->GetYaxis()->SetTitleOffset(titleoffsety);
TH1F* histo_ratio;
histo_ratio = (TH1F*) hist_data->Clone();
histo_ratio->SetName("histo_ratio");
histo_ratio->SetTitle("");
histo_ratio->Divide(histo_tot);
hist_data ->SetLineWidth(2);
hist_data ->SetMarkerStyle(20);
hist_data ->SetMarkerSize(0.75);
hist_dy ->SetFillColor(kAzure-2);
hist_ttbar ->SetFillColor(kRed+1);
hist_st ->SetFillColor(kMagenta);
THStack *stack = new THStack("stack","stack");
stack ->Add(hist_ttbar);
stack ->Add(hist_st);
stack ->Add(hist_dy);
gStyle->SetOptTitle(0);
gStyle->SetOptStat(0);
//gStyle->SetLogy(log);
TCanvas *c1 = new TCanvas("c1", "c1",10,32,782,552);
c1->SetFillColor(10);
c1-> cd();
TPad* canvas_1 = new TPad("canvas_1", "canvas_1",0,0.25,1.0,0.98);
canvas_1 ->Draw();
canvas_1 ->cd();
canvas_1->SetLogy(log);
if (hist_data->GetMaximum() > stack->GetMaximum() ) stack->SetMaximum( hist_data->GetMaximum()*1.1) ;
//.........这里部分代码省略.........
示例9: if
void
Draw(string filename, bool norm, bool logy, bool eff, bool cum, TLine* line){
if(debug) printf(" Draw (norm is %i) %s\n",norm, filename.c_str());
TCanvas c1;
if(logy) c1.SetLogy();
string title;
if(Data.size()){
title = Data[0].hist->GetTitle();
title += ";";
title += Data[0].hist->GetXaxis()->GetTitle();
title += ";";
title += Data[0].hist->GetYaxis()->GetTitle();
}else if(Bkg.size()){
title = Bkg[0].hist->GetTitle();
title += ";";
title += Bkg[0].hist->GetXaxis()->GetTitle();
title += ";";
title += Bkg[0].hist->GetYaxis()->GetTitle();
}
TH1F* hData = NULL;
for(uint i=0; i<Data.size(); i++){
if(i==0) hData = (TH1F*)Data[i].hist->Clone("hData");
else hData->Add(Data[i].hist);
}
hData->SetMarkerSize(5);
if(!eff){
THStack* sBkg = new THStack("sBkg",title.c_str());
THStack* sSigs[Sig.size()];
for(uint i=0; i<Bkg.size(); i++){
sBkg->Add(Bkg[i].hist);
}
for(uint i=0; i<Sig.size(); i++){
sSigs[i] = (THStack*) sBkg->Clone();
sSigs[i]->Add(Sig[i].hist);
}
Double_t max = sBkg->GetMaximum();
sBkg->Draw("HIST");
for(unsigned int i=0; i<Sig.size(); i++){
max = TMath::Max(max, sSigs[i]->GetMaximum());
sSigs[i]->Draw("HIST SAME");
}
if(hData){
max = TMath::Max(max, hData->GetMaximum());
hData->Draw("E1 SAME");
}
sBkg->SetMaximum(1.1*max);
}else{
THStack* hs = new THStack("hs",title.c_str());
hs->Add(hData);
for(unsigned int i=0; i<Bkg.size(); ++i){
hs->Add(Bkg[i].hist);
}
for(unsigned int i=0; i<Sig.size(); ++i){
hs->Add(Sig[i].hist);
}
hs->Draw("nostack HIST");
}
if(debug) cout<<"Title: "<<title<<endl;
if(debug) cout<<"Creating Legend\n";
TLegend *legend = new TLegend(0.65,0.50,0.88,0.89,"");
if(Data.size()) legend->AddEntry(hData, "Data", "PLE");
for(unsigned int i=0; i<Bkg.size(); ++i){
legend->AddEntry(Bkg[i].hist,SampleNames[Bkg[i].name].c_str(), "L");
}
for(unsigned int i=0; i<Sig.size(); ++i){
legend->AddEntry(Sig[i].hist,SampleNames[Sig[i].name].c_str(), "L");
}
if(norm){//????
//TAxis* axis = samples[0]->at(0).hist->GetXaxis();
//int first = axis->GetFirst();
//int last = axis->GetLast();
//float sum = hists[i]->Integral(first,last);
//hists[i]->Scale(1./sum);
//axis->SetRange(first,last);
}
//hs->GetXaxis()->SetNdivisions(10);
if(debug) printf("Setting title\n");
legend->SetTextSize(0.03);
legend->SetBorderSize(0);
legend->SetFillStyle(0);
legend->Draw();
if(line) line->Draw();
c1.SaveAs(filename.c_str());
c1.Print("Summary.pdf","pdf");
}
示例10: PlotHistos
//=======================
void PlotHistos(Char_t *enLabel, Char_t *fileNameIn) {
Bool_t plotBG = kTRUE;
gStyle->SetOptStat(kFALSE);
// gStyle->SetOptFit(kTRUE);
Char_t name[100];
//plot the mass histograms:
TCanvas *c1Mass[kNbCath+2];
TLatex *texMass[kNbCath+2];
for(int iCat = 0; iCat < kNbCath+2; iCat++) {
if(iCat > 2 && iCat < kNbCath) continue;
sprintf(name, "c1Mass_%d", iCat);
c1Mass[iCat] = new TCanvas(name, "mass");
// if(iCat == 2 && plotBG)
// hReco_mass[0][iCat]->SetMaximum(5.);
if(iCat == kNbCath+1 && plotBG)
hReco_mass[0][iCat]->SetMaximum(12.);
hReco_mass[0][iCat]->Draw();
hReco_mass[0][iCat]->Fit("gaus", "", "", 3.05, 3.15);
// (hReco_mass[0][iCat]->GetFunction("gaus"))->SetLineWidth(1);
if(iCat < kNbCath)
(hReco_mass[0][iCat]->GetFunction("gaus"))->SetLineColor(colour[iCat]);
texMass[iCat] = new TLatex(3.7, 0.65*hReco_mass[0][iCat]->GetMaximum(), enLabel);
texMass[iCat]->SetTextSize(0.04);
texMass[iCat]->Draw();
texMass[iCat]->DrawLatex(2.1, 0.6*hReco_mass[0][iCat]->GetMaximum(), catNames[iCat]);
// sprintf(name, "#J/#psi per L_{int}=1 nb^{-1}: %1.0f #pm %1.0f",
// integral[iCat], errPossonian[iCat]);
// sprintf(name, "#J/#psi per L_{int}=1 nb^{-1}: %1.0f", integral[iCat]);
sprintf(name, "#J/#psi per nb^{-1}: %1.0f", integral[iCat]);
texMass[iCat]->DrawLatex(2.1, 0.5*hReco_mass[0][iCat]->GetMaximum(), name);
if(plotBG)
hRecoBG_mass[0][iCat]->Draw("same");
if(iCat < kNbCath) {
sprintf(name, "Figures/%s_mass_%s.gif", fileNameIn, oniaCatName[iCat]);
c1Mass[iCat]->Print(name);
sprintf(name, "Figures/%s_mass_%s.pdf", fileNameIn, oniaCatName[iCat]);
c1Mass[iCat]->Print(name);
}
else if(iCat == kNbCath) {
sprintf(name, "Figures/%s_mass_GGandGT.gif", fileNameIn);
c1Mass[iCat]->Print(name);
sprintf(name, "Figures/%s_mass_GGandGT.pdf", fileNameIn);
c1Mass[iCat]->Print(name);
}
else if(iCat == kNbCath+1) {
sprintf(name, "Figures/%s_mass_all.gif", fileNameIn);
c1Mass[iCat]->Print(name);
sprintf(name, "Figures/%s_mass_all.pdf", fileNameIn);
c1Mass[iCat]->Print(name);
}
}
//plot the GG and GT combination with its BG AND
//the GG with its BG overlayed:
//plot the mass histograms:
TCanvas *c1Massa[kNbCath+2];
TLatex *texMassa[kNbCath+2];
for(int iCat = kNbCath+1; iCat < kNbCath+2; iCat++) {
sprintf(name, "c1Massa_%d", iCat);
c1Massa[iCat] = new TCanvas(name, "mass special");
//gl-gl and gl-tr and tr-tr
hReco_mass[0][iCat]->SetLineColor(4);
(hReco_mass[0][iCat]->GetFunction("gaus"))->SetLineColor(4);
hReco_mass[0][iCat]->Draw();
//gl-gl and gl-tr
hReco_mass[0][kNbCath]->SetLineColor(2);
(hReco_mass[0][kNbCath]->GetFunction("gaus"))->SetLineColor(2);
hReco_mass[0][kNbCath]->Draw("same");
//gl-gl
// hReco_mass[0][0]->SetLineColor(4);
// (hReco_mass[0][0]->GetFunction("gaus"))->SetLineColor(4);
hReco_mass[0][0]->Draw("same");
// hReco_mass[0][iCat]->Fit("gaus", "", "", 3.05, 3.15);
// hReco_mass[0][iCat]->SetLineWidth(1);
texMassa[iCat] = new TLatex(3.6, 0.65*hReco_mass[0][iCat]->GetMaximum(), enLabel);
texMassa[iCat]->SetTextSize(0.04);
texMassa[iCat]->Draw();
texMassa[iCat]->DrawLatex(2.45, 11., catNames[iCat]);
// sprintf(name, "#J/#psi per L_{int}=1 nb^{-1}: %1.0f #pm %1.0f",
// integral[iCat], errPossonian[iCat]);
// sprintf(name, "#J/#psi per L_{int}=1 nb^{-1}: %1.0f", integral[iCat]);
sprintf(name, "#J/#psi per nb^{-1}: %1.0f", integral[iCat]);
//.........这里部分代码省略.........
示例11: fake
void fake()
{
gROOT->SetBatch();
gROOT->SetStyle("Plain");
gStyle->SetOptStat(0);
SetStyle();
TCanvas *c1 = new TCanvas("c1","c1",0,0,600,500);
c1->Draw();
c1->cd();
TPad *c1_1;
gStyle->SetHistTopMargin(0);
TLegend *leg = new TLegend(0.65,0.90,0.90,0.70);
leg->SetFillColor(253);
leg->SetBorderSize(0);
std::string fpath = "histTEST_MERGED/QCD_Pt_170to300_TuneCUETP8M1_13TeV_pythia8/data.root";
// std::string histnameFake = "h_muFake_pt";
// std::string histnameReal = "h_muReal_pt";
// std::string histnameFake = "h_muFake_trackerLayersWithMeasurement";
// std::string histnameReal = "h_muReal_trackerLayersWithMeasurement";
// std::string histnameFake = "h_muFake_numberOfValidMuonHits";
// std::string histnameReal = "h_muReal_numberOfValidMuonHits";
// std::string histnameFake = "h_muFake_numberOfMatches";
// std::string histnameReal = "h_muReal_numberOfMatches";
// std::string histnameFake = "h_muFake_numberOfMatchedStations";
// std::string histnameReal = "h_muReal_numberOfMatchedStations";
// std::string histnameFake = "h_muFake_numberOfValidHits";
// std::string histnameReal = "h_muReal_numberOfValidHits";
// std::string histnameFake = "h_muFake_numberOfValidPixelHits";
// std::string histnameReal = "h_muReal_numberOfValidPixelHits";
std::string histnameFake = "h_muFake_numberOfHits";
std::string histnameReal = "h_muReal_numberOfHits";
// std::string histnameFake = "h_muFake_normalizedChi2GlobalTrack";
// std::string histnameReal = "h_muReal_normalizedChi2GlobalTrack";
// std::string histnameFake = "h_muFake_normalizedChi2InnerTrack";
// std::string histnameReal = "h_muReal_normalizedChi2InnerTrack";
TFile *f;
TH1D *hFake;
TH1D *hReal;
f = TFile::Open(fpath.c_str());
{
TH1D *hFake_c = (TH1D*)f->Get(histnameFake.c_str());
hFake_c->SetMarkerSize(0.0);
TH1D *hReal_c = (TH1D*)f->Get(histnameReal.c_str());
hReal_c->SetMarkerSize(0.0);
hFake = (TH1D*)hFake_c->Clone("hFake");
hReal = (TH1D*)hReal_c->Clone("hReal");
}
addbin(hFake);
addbin(hReal);
std::cout << hReal->Integral() << std::endl;
std::cout << hFake->Integral() << std::endl;
double iFake = hFake->Integral();
double iReal = hReal->Integral();
// double iAll = iFake+iReal;
// hFake->Scale(1./iAll);
// hReal->Scale(1./iAll);
hFake->SetLineColor(9);
hFake->SetFillColor(9);
hReal->SetLineColor(46);
hReal->SetFillColor(46);
THStack *hst = new THStack();
hst->Add(hReal);
hst->Add(hFake);
hst->Draw("hist e1");
float max = hst->GetMaximum();
hst->SetMaximum(1.3*max);
hst->SetMinimum(0.);
//.........这里部分代码省略.........
示例12: GetStack
THStack* BasePlot::GetStack(bool isLog) {
THStack* hstack = new THStack();
float binWidth = 0;
for (int i=0; i<nSamples; i++) if( _hist[i] && i != iHWW) {
_hist[i]->SetLineColor(sampleColor[i]);
_hist[i]->SetFillColor(sampleColor[i]);
_hist[i]->SetFillStyle(1001);
binWidth = _hist[i]->GetBinWidth(1);
hstack->Add(_hist[i]);
}
for (size_t i=0; i<_autreHists.size(); i++) {
_autreHists[i].second->SetLineColor(autreColors[i]);
_autreHists[i].second->SetFillColor(autreColors[i]);
_autreHists[i].second->SetFillStyle(1001);
hstack->Add(_autreHists[i].second);
}
hstack->Draw("GOFF");
if(_prelim) hstack->SetTitle("CMS preliminary");
else hstack->SetTitle("CMS, #sqrt{s} = 7 TeV");
Float_t theMax = hstack->GetMaximum();
Float_t theMin = hstack->GetMinimum();
if (_hist[iHWW]) {
if (_hist[iHWW]->GetMaximum() > theMax) theMax = _hist[iHWW]->GetMaximum();
if (_hist[iHWW]->GetMinimum() < theMin) theMin = _hist[iHWW]->GetMinimum();
}
if (_data) {
Float_t dataMax = GetMaximumIncludingErrors(_data);
if (dataMax > theMax) theMax = dataMax;
}
int sampCount = GetSampCount();
float scaleBy = 1.35 + 0.2*(sampCount>6) + 0.2*(sampCount>10) + 0.2*(sampCount>14);
// Min --- only need to change if log
theMin = theMin==0?0.1:theMin/10;
if(isLog) hstack->SetMinimum(theMin);
// Max
if (_myMax != -1) {
hstack->SetMaximum(_myMax);
} else if (isLog) {
hstack->SetMaximum(pow(10,(log(theMax)/log(10)-log(theMin)/log(10)+1)*scaleBy+log(theMin)/log(10)-1));
} else {
hstack->SetMaximum(scaleBy * theMax);
}
if(_breakdown) {
THStackAxisFonts(hstack, "y", "entries");
hstack->GetHistogram()->LabelsOption("v");
} else {
THStackAxisFonts(hstack, "x", TString::Format("%s [%s]",_xLabel.Data(),_units.Data()));
THStackAxisFonts(hstack, "y", TString::Format("entries / %.1f %s", binWidth,_units.Data()));
if(_units.Sizeof() == 1) {
THStackAxisFonts(hstack, "x", _xLabel.Data());
// THStackAxisFonts(hstack, "y", "entries");
}
}
return hstack;
}
示例13: drawChannelYieldPlot
//.........这里部分代码省略.........
h1_yields_mc->SetBinContent( 3, eem );
h1_yields_mc->SetBinContent( 4, eee );
h1_yields_mc->SetFillColor( db->get_mcFile(iMC).fillColor );
vh1_yields_mc.push_back( (TH1D*)h1_yields_mc );
stackMC->Add(h1_yields_mc, "HISTO");
if( db->get_mcFiles()[iMC].legendName=="t#bar{t} + Z" ) {
s_mmm += mmm;
s_mme += mme;
s_eem += eem;
s_eee += eee;
s += total;
} else {
yieldsFile << db->get_mcFiles()[iMC].legendName;
for( unsigned ichar=0; ichar<20-db->get_mcFiles()[iMC].legendName.size(); ++ichar ) yieldsFile << " ";
yieldsFile << Form("%.4f \t %.4f \t %.4f \t %.4f \t %.4f", mmm, mme, eem, eee, total) << std::endl;
b_mmm += mmm;
b_mme += mme;
b_eem += eem;
b_eee += eee;
b += total;
}
delete h1_mc_mmm;
delete h1_mc_mme;
delete h1_mc_eem;
delete h1_mc_eee;
}
yieldsFile << "Total BG " << Form("%.4f \t %.4f \t %.4f \t %.4f \t %.4f", b_mmm, b_mme, b_eem, b_eee, b) << std::endl;
yieldsFile << std::endl;
yieldsFile << "Signal " << Form("%.4f \t %.4f \t %.4f \t %.4f \t %.4f", s_mmm, s_mme, s_eem, s_eee, s) << std::endl;
yieldsFile << "s / b " << Form("%.4f \t %.4f \t %.4f \t %.4f \t %.4f", s_mmm/b_mmm, s_mme/b_mme, s_eem/b_eem, s_eee/b_eee, s/b) << std::endl;
yieldsFile << "s / sqrt(b) " << Form("%.4f \t %.4f \t %.4f \t %.4f \t %.4f", s_mmm/sqrt(b_mmm), s_mme/sqrt(b_mme), s_eem/sqrt(b_eem), s_eee/sqrt(b_eee), s/sqrt(b)) << std::endl;
yieldsFile.close();
for( unsigned i=0; i<db->get_mcFiles().size(); ++i) {
int inverseIndex = db->get_mcFiles().size()-i-1;
if( vh1_yields_mc[inverseIndex]->Integral()>0 )
legend->AddEntry( vh1_yields_mc[inverseIndex], db->get_mcFile(i).legendName.c_str(), "F" );
}
float yMax = stackMC->GetMaximum();
yMax *= 2.2;
TH2D* h2_axes = new TH2D("axes", "", 4, 0., 4., 10, 0., yMax);
h2_axes->GetXaxis()->SetLabelSize(0.085);
h2_axes->GetXaxis()->SetBinLabel(1, "(#mu#mu)#mu");
h2_axes->GetXaxis()->SetBinLabel(2, "(#mu#mu)e");
h2_axes->GetXaxis()->SetBinLabel(3, "(ee)#mu");
h2_axes->GetXaxis()->SetBinLabel(4, "(ee)e");
h2_axes->SetYTitle("Events");
TPaveText* label_sqrt = db->get_labelSqrt();
TCanvas* c1 = new TCanvas("c1", "", 600, 600);
c1->cd();
h2_axes->Draw();
stackMC->Draw("histo same");
legend->Draw("same");
label_sqrt->Draw("same");
gPad->RedrawAxis();
char canvasName[500];
if( saveName!="" )
sprintf( canvasName, "%s/channelYields_%s.eps", db->get_outputdir().c_str(), saveName.c_str() );
else
sprintf( canvasName, "%s/channelYields.eps", db->get_outputdir().c_str() );
c1->SaveAs(canvasName);
delete c1;
delete h2_axes;
for( unsigned i=0; i<vh1_yields_mc.size(); ++i )
delete vh1_yields_mc[vh1_yields_mc.size()-i-1];
}
示例14: makePlot
void HistogramPlotter::makePlot(std::map<std::string, TH1F*> plotMap, std::string plotName, std::string subLabel, std::vector<std::string> xAxisLabels){
std::cerr << "Making a plot called: " << plotName << std::endl;
//Make the legend. This is clearly the first thing I should do.
TLegend legend_ = TLegend(0.7,0.7,0.94,0.94);
legend_.SetFillStyle(1001);
legend_.SetBorderSize(1);
legend_.SetFillColor(kWhite);
for (std::vector<std::string>::iterator leg_iter = legOrder_.begin(); leg_iter != legOrder_.end(); leg_iter++){
legend_.AddEntry(plotMap[*leg_iter], dsetMap_[*leg_iter].legLabel.c_str(), dsetMap_[*leg_iter].legType.c_str());
}
//Initialise the stack
THStack mcStack = THStack(plotName.c_str(),plotName.c_str());
//Do a few colour changing things and add MC to the stack.
for (std::vector<std::string>::reverse_iterator plot_iter = plotOrder_.rbegin(); plot_iter != plotOrder_.rend(); plot_iter++){
plotMap[*plot_iter]->SetFillColor(dsetMap_[*plot_iter].colour);
plotMap[*plot_iter]->SetLineColor(kBlack);
plotMap[*plot_iter]->SetLineWidth(1);
if( *plot_iter == "data"){
plotMap["data"]->SetMarkerStyle(20);
plotMap["data"]->SetMarkerSize(1.2);
plotMap["data"]->SetMarkerColor(kBlack);
continue;
}
mcStack.Add(plotMap[*plot_iter]);
}
TCanvas * canvy = new TCanvas((plotName + subLabel + postfix_).c_str(), (plotName + subLabel + postfix_).c_str());
canvy->cd();
mcStack.Draw("");
if (xAxisLabels.size() > 0){
for (unsigned int i = 1; i <= xAxisLabels.size(); i++){
mcStack.GetXaxis()->SetBinLabel(i,xAxisLabels[i-1].c_str());
}
}
setLabelThree(subLabel);
//labelThree_->Draw();
// labelTwo_->Draw();
// labelOne_->Draw();
float max = mcStack.GetMaximum();
if (plotMap.find("data") != plotMap.end()){
max = TMath::Max(mcStack.GetMaximum(),plotMap["data"]->GetMaximum());
plotMap["data"]->Draw("e x0, same");
}
mcStack.SetMaximum(max*1.3);
legend_.Draw();
// Save the plots.
for (unsigned int ext_it = 0; ext_it < extensions_.size(); ext_it++){
canvy->SaveAs((outputFolder_ + plotName + subLabel + postfix_ + extensions_[ext_it]).c_str());
}
//Make log plots
canvy->SetLogy();
mcStack.SetMaximum(max*10);
//Save the log plots
for (unsigned int ext_it = 0; ext_it < extensions_.size(); ext_it++){
canvy->SaveAs((outputFolder_ + plotName + subLabel + postfix_ + "_log" + extensions_[ext_it]).c_str());
}
delete canvy;
}
示例15: browseStacks
void browseStacks( bool makePictures=false, bool wait=true , bool addHistName = false, Double_t maxYScaleF = 1.,
bool logScale = false, bool setMinZero = true) {
gStyle->SetOptTitle(0);
bool keep2D=false;
//fix the hNJet histos
TList *list = gDirectory->GetList();
TIterator *iter = list->MakeIterator();
TObject *obj = 0;
while(obj = iter->Next()) {
if(TString(obj->GetName()).Contains("hnJet") && obj->InheritsFrom(TH1::Class())) {
int nbins = ((TH1F*)obj)->GetNbinsX();
float overflow = ((TH1F*)obj)->GetBinContent(nbins+1);
float lastbinval = ((TH1F*)obj)->GetBinContent(nbins);
((TH1F*)obj)->SetBinContent(nbins, overflow+lastbinval);
((TH1F*)obj)->GetXaxis()->SetBinLabel(nbins, "#geq4");
}
}
// Find out what the names of the existing histograms are
// The histogram names are XX_YY_ZZ, where XX is the sample,
// eg, "tt", YY is the actual name, ZZ is the final state, eg, "ee"
TObjArray* myNames = getMyHistosNames("ttdil","ee",keep2D);
// Now loop over histograms, and make stacks
TCanvas *c = new TCanvas();
c->Divide(2,2);
char* suffix[4];
suffix[0] = "ee";
suffix[1] = "mm";
suffix[2] = "em";
suffix[3] = "all";
if (makePictures) c->Print("out/stacks.ps[");
for (int i=0; i<myNames->GetEntries(); i++) {
for (int sample=0; sample<4; sample++) {
hist::stack(Form("st_%s_%s",myNames->At(i)->GetName(),suffix[sample]),
Form("%s_%s$",myNames->At(i)->GetName(), suffix[sample]));
THStack* thisStack = (THStack*) gROOT->FindObjectAny(
Form("st_%s_%s", myNames->At(i)->GetName(), suffix[sample]));
thisStack->SetMaximum(thisStack->GetMaximum()*maxYScaleF);
if(TString(myNames->At(i)->GetName()).Contains("hnJet")) {
TList* histolist = thisStack->GetHists();
int hatchcount = 0;
// for(int j = 0; j<histolist->GetSize();j++) {
// if(TString(histolist->At(j)->GetName()).Contains("tt") ||
// TString(histolist->At(j)->GetName()).Contains("tautau") ||
// TString(histolist->At(j)->GetName()).Contains("ww") ) continue;
// hatch(histolist->At(j)->GetName(), FavoriteHatches[hatchcount]);
// hatchcount++;
// }
}
TLegend* thisLeg = hist::legend(thisStack, "lpf", 0, 0, 0.75, 0.65, 0.99, 0.99);
c->cd(sample+1);
if (logScale) gPad->SetLogy(); else gPad->SetLogy(0);
double stackMax = ((TH1*)thisStack->GetHists()->At(0))->GetMaximum();
double stackMin = ((TH1*)thisStack->GetHists()->At(0))->GetMinimum();
thisStack->SetMinimum(stackMin);
if (setMinZero) thisStack->SetMinimum(0);
if (logScale && stackMin <=0) thisStack->SetMinimum(1e-2*stackMax);
if (logScale && stackMax == 0) thisStack->SetMinimum(1e-12);
thisStack->Draw("hist");
string xtitle( ((TH1*)gROOT->FindObjectAny(Form("ttdil_%s_%s", myNames->At(i)->GetName(), suffix[sample])))->GetXaxis()->GetTitle());
string ytitle( ((TH1*)gROOT->FindObjectAny(Form("ttdil_%s_%s", myNames->At(i)->GetName(), suffix[sample])))->GetYaxis()->GetTitle());
thisStack->GetXaxis()->SetTitle(xtitle.c_str());
thisStack->GetYaxis()->SetTitle(ytitle.c_str());
TString hname = thisStack->GetName();
if(hname.Contains("hnJet")) {
thisStack->GetXaxis()->SetLabelSize(0.075);
thisStack->GetYaxis()->SetLabelSize(0.05);
thisStack->GetXaxis()->SetTitle("N_{jets}");
}
thisLeg->Draw();
TPaveText *pt1 = new TPaveText(0.1, 0.95, 0.4, 0.999, "brNDC");
pt1->SetName("pt1name");
pt1->SetBorderSize(0);
pt1->SetFillStyle(0);
TText *blah;
if (addHistName) blah = pt1->AddText(hname);
else blah = pt1->AddText("CMS Preliminary");
blah->SetTextSize(0.05);
pt1->Draw();
c->Modified();
//.........这里部分代码省略.........