本文整理汇总了C++中TH1::SetXTitle方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1::SetXTitle方法的具体用法?C++ TH1::SetXTitle怎么用?C++ TH1::SetXTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1
的用法示例。
在下文中一共展示了TH1::SetXTitle方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ratioPlots
void ratioPlots( TCanvas* c1, TH1* h_r, TH1* h_i,
string xTitle, string yTitle, string savePath,
double fitMin=-100000, double fitMax=100000, bool doubleColFit=0 ){
double xMaximum = h_r->GetXaxis()->GetBinUpEdge(h_r->GetXaxis()->GetLast());
double xMinimum = h_r->GetXaxis()->GetBinLowEdge(h_r->GetXaxis()->GetFirst());
double yMaximum;
double yMinimum;
h_i->Sumw2();
h_r->Sumw2();
TLine* line1 = new TLine(xMinimum,1,xMaximum,1);
line1->SetLineColor(1);
line1->SetLineWidth(2);
line1->SetLineStyle(7);
TF1* fpol1 = new TF1("fpol1", "pol1", fitMin, fitMax);
fpol1->SetLineColor(2);
fpol1->SetLineWidth(3);
fpol1->SetLineStyle(7);
TH1* hRatio = (TH1*)h_r->Clone("clone_record");
hRatio->Divide(h_i);
yMaximum = hRatio->GetMaximum();
yMinimum = hRatio->GetMinimum(0);
hRatio->GetYaxis()->SetRangeUser(yMinimum/2.5,yMaximum+yMaximum/5);
hRatio->SetXTitle(xTitle.c_str());
hRatio->SetYTitle(yTitle.c_str());
hRatio->SetLineColor(9);
hRatio->SetLineWidth(2);
hRatio->SetMarkerStyle(8);
hRatio->Draw("e");
hRatio->Fit("fpol1", "L");
line1->Draw("SAME");
if(doubleColFit){
double p0=fpol1->GetParameter(0);
double p1=fpol1->GetParameter(1);
double endPoint=double(fitMax*p1)+p0;
double p1new=(endPoint-1)/(fitMax-fitMin);
char fun[100], text[100];
sprintf(fun,"x*(%f)+1",p1new);
sprintf(text,"Tangent: %f",p1new);
TF1* fnew = new TF1("fnew", fun, fitMin, fitMax);
fnew->SetLineColor(2);
fnew->SetLineWidth(3);
fnew->Draw("SAME");
TText* Title = new TText( fitMax/12, yMinimum, text);
Title->SetTextColor(2);
Title->SetTextSize(0.035);
Title->Draw("SAME");
}
c1->SaveAs(savePath.c_str());
c1->cd();
}
示例2: main
//.........这里部分代码省略.........
s = 0;
for(int i = 1; i <= histoZMuMuNoIso->GetNbinsX(); ++i)
s += histoZMuMuNoIso->GetBinContent(i);
histoZMuMuNoIso->SetEntries(s);
s = 0;
for(int i = 1; i <= histoZMuMu->GetNbinsX(); ++i)
s += histoZMuMu->GetBinContent(i);
histoZMuMu->SetEntries(s);
s = 0;
for(int i = 1; i <= histoZMuMu1HLT->GetNbinsX(); ++i)
s += histoZMuMu1HLT->GetBinContent(i);
histoZMuMu1HLT->SetEntries(s);
s = 0;
for(int i = 1; i <= histoZMuMu2HLT->GetNbinsX(); ++i)
s += histoZMuMu2HLT->GetBinContent(i);
histoZMuMu2HLT->SetEntries(s);
s = 0;
for(int i = 1; i <= histoZMuTk->GetNbinsX(); ++i)
s += histoZMuTk->GetBinContent(i);
histoZMuTk->SetEntries(s);
s = 0;
for(int i = 1; i <= histoZMuSa->GetNbinsX(); ++i)
s += histoZMuSa->GetBinContent(i);
histoZMuSa->SetEntries(s);
string ZMuMu1HLTPlot = "ZMuMu1HLTFit_" + plot_string;
root::plot<Expr>(ZMuMu1HLTPlot.c_str(), *histoZMuMu1HLT, zMuMu1HLT, fMin, fMax,
effTk, effSa, effIso, effHLT, yieldZMuMu,
kRed, 2, kDashed, 100,
"Z -> #mu #mu mass", "#mu #mu invariant mass (GeV/c^{2})",
"Events");
string ZMuMu2HLTPlot = "ZMuMu2HLTFit_" + plot_string;
root::plot<Expr>(ZMuMu2HLTPlot.c_str(), *histoZMuMu2HLT, zMuMu2HLT, fMin, fMax,
effTk, effSa, effIso, effHLT, yieldZMuMu,
kRed, 2, kDashed, 100,
"Z -> #mu #mu mass", "#mu #mu invariant mass (GeV/c^{2})",
"Events");
string ZMuMuNoIsoPlot = "ZMuMuNoIsoFit_" + plot_string;
root::plot<Expr>(ZMuMuNoIsoPlot.c_str(), *histoZMuMuNoIso, zMuMuNoIso, fMin, fMax,
effTk, effSa, effIso, effHLT, yieldZMuMu,
kRed, 2, kDashed, 100,
"Z -> #mu #mu Not Iso mass", "#mu #mu invariant mass (GeV/c^{2})",
"Events");
string ZMuTkPlot = "ZMuTkFit_X_" + plot_string;
root::plot<Expr>(ZMuTkPlot.c_str(), *histoZMuTk, zMuTk, fMin, fMax,
effTk, effSa, effIso, effHLT, yieldZMuMu,
yieldBkgZMuTk, lambda, a0, a1, a2,
kRed, 2, kDashed, 100,
"Z -> #mu + (unmatched) track mass", "#mu #mu invariant mass (GeV/c^{2})",
"Events");
ZMuTkPlot = "ZMuTkFit_" + plot_string;
TF1 funZMuTk = root::tf1_t<sig_tag, Expr>("ZMuTkFunction", zMuTk, fMin, fMax,
effTk, effSa, effIso, effHLT, yieldZMuMu,
yieldBkgZMuTk, lambda, a0, a1, a2);
funZMuTk.SetLineColor(kRed);
funZMuTk.SetLineWidth(2);
funZMuTk.SetLineStyle(kDashed);
funZMuTk.SetNpx(10000);
TF1 funZMuTkBkg = root::tf1_t<bkg_tag, Expr>("ZMuTkBack", zMuTkBkgScaled, fMin, fMax,
yieldBkgZMuTk, lambda, a0, a1, a2);
funZMuTkBkg.SetLineColor(kGreen);
funZMuTkBkg.SetLineWidth(2);
funZMuTkBkg.SetLineStyle(kDashed);
funZMuTkBkg.SetNpx(10000);
histoZMuTk->SetTitle("Z -> #mu + (unmatched) track mass");
histoZMuTk->SetXTitle("#mu + (unmatched) track invariant mass (GeV/c^{2})");
histoZMuTk->SetYTitle("Events");
TCanvas *canvas = new TCanvas("canvas");
histoZMuTk->Draw("e");
funZMuTkBkg.Draw("same");
funZMuTk.Draw("same");
canvas->SaveAs(ZMuTkPlot.c_str());
canvas->SetLogy();
string logZMuTkPlot = "log_" + ZMuTkPlot;
canvas->SaveAs(logZMuTkPlot.c_str());
string ZMuSaPlot = "ZMuSaFit_" + plot_string;
root::plot<Expr>(ZMuSaPlot.c_str(), *histoZMuSa, zMuSa, fMin, fMax,
effSa, effTk, effIso,
yieldZMuMu, yieldBkgZMuSa,
kRed, 2, kDashed, 10000,
"Z -> #mu + (unmatched) standalone mass",
"#mu + (unmatched) standalone invariant mass (GeV/c^{2})",
"Events");
}
}
}
catch(std::exception& e) {
cerr << "error: " << e.what() << "\n";
return 1;
}
catch(...) {
cerr << "Exception of unknown type!\n";
}
return 0;
}
示例3: DrawKs
TCanvas* DrawKs(const char* filename)
{
TFile* file = TFile::Open(filename, "READ");
if (!file) {
Warning("DrawKs", "File %s couldn't be opened", filename);
return 0;
}
TH1* cent = static_cast<TH1*>(file->Get("cent"));
if (!cent) {
Warning("DrawKs", "Failed to find cent in %s", file->GetName());
return 0;
}
TString t(filename);
t.ReplaceAll("results/", "");
t.ReplaceAll("combine_","");
t.ReplaceAll("_0x3.root", "");
TString nm(filename);
nm.ReplaceAll(".root", "");
nm.ReplaceAll("results/", "plots/");
nm.ReplaceAll("combine", "ks");
if (t.Contains("none"))
t.ReplaceAll("none", "No weights");
else
t.Append(" weights");
Int_t cW = 1200;
Int_t cH = 800;
TCanvas* c = new TCanvas(nm,t,cW, cH);
c->SetTopMargin(0.07);
c->SetRightMargin(0.20);
c->SetTicks();
TLegend* l = new TLegend(1-c->GetRightMargin(),
c->GetBottomMargin(),
.99,
1-c->GetTopMargin());
l->SetFillStyle(0);
l->SetBorderSize(0);
THStack* s = new THStack("ks", "");
Int_t nCent = cent->GetXaxis()->GetNbins();
for (Int_t i = 1; i <= nCent; i++) {
Double_t c1 = cent->GetXaxis()->GetBinLowEdge(i);
Double_t c2 = cent->GetXaxis()->GetBinUpEdge(i);
TH1* h = GetCentK(file, c1, c2, nCent-i+1-2, l);
if (!h) continue;
s->Add(h);
}
s->Draw("nostack");
TH1* f = s->GetHistogram();
if (f) {
f->SetXTitle("#eta");
f->SetYTitle("#it{k}(#eta)");
}
TLatex* tit = new TLatex(0.55, 0.99, t);
tit->SetTextFont(42);
tit->SetTextAlign(23);
tit->SetTextSize(0.03);
tit->SetNDC();
tit->Draw();
l->SetBorderSize(0);
l->Draw();
c->Modified();
c->Update();
c->cd();
return c;
}
示例4: HwwNoteFigs
void HwwNoteFigs(TString filename = "../histo_tmva_new-ntuples-1_160_0.root",
int mass = 170, int ReBin = 4, int ysel = 0)
{
TFile* infile = new TFile(filename.Data(),"READ");
setTDRStyle(0);
//BDTD dists
TCanvas* c1 = new TCanvas("c1","c1",0,-200,500,500);
TH1F* histoBg = histo4->Clone();
histoBg->Add(histo3);
histoBg->Add(histo2);
histoBg->Add(histo1);
TH1F* histo_4 = histo4->Clone();
histo3->Add(histo_4);
TH1F* histo_3 = histo3->Clone();
histo2->Add(histo_3);
TH1F* histo_2 = histo2->Clone();
histo1->Add(histo_2);
histo1->Rebin(ReBin);
histo1->SetFillColor(kBlue);
histo1->SetFillStyle(1001);
histo1->SetLineStyle(0);
histo1->SetLineWidth(0);
histo2->Rebin(ReBin);
histo2->SetFillColor(kMagenta);
histo2->SetFillStyle(1001);
histo2->SetLineStyle(0);
histo2->SetLineWidth(0);
histo3->Rebin(ReBin);
histo3->SetFillColor(kGreen);
histo3->SetFillStyle(1001);
histo3->SetLineStyle(0);
histo3->SetLineWidth(0);
histo4->Rebin(ReBin);
histo4->SetFillColor(kCyan);
histo4->SetFillStyle(1001);
histo4->SetLineStyle(0);
histo4->SetLineWidth(0);
char YTitle[300];
sprintf(YTitle,"events / bin");
char XTitle[300];
sprintf(XTitle,"BDT Output");
histo0->SetYTitle(YTitle);
histo1->SetYTitle(YTitle);
histo2->SetYTitle(YTitle);
histo3->SetYTitle(YTitle);
histo4->SetYTitle(YTitle);
histo0->SetXTitle(XTitle);
histo1->SetXTitle(XTitle);
histo2->SetXTitle(XTitle);
histo3->SetXTitle(XTitle);
histo4->SetXTitle(XTitle);
histo1->SetTitleSize(0.05, "X");
histo1->GetXaxis()->SetTitleFont(62);
histo1->GetXaxis()->SetLabelFont(61);
histo1->GetYaxis()->SetLabelFont(61);
histo1->GetYaxis()->SetTitleOffset(1.3);
histo1->SetLabelSize(0.04, "Y");
histo1->SetLabelSize(0.04, "X");
int min = histoBg->FindBin(-1.5);
int max = histoBg->FindBin(1.5);
histoBg->GetXaxis()->SetRange(min,max);
histoBg->SetMarkerStyle(20);
histoBg->SetMarkerSize(1.0);
histoBg->GetYaxis()->SetTitleOffset(1.40);
histo0->SetMarkerStyle(21);
histo0->SetMarkerSize(1.0);
histoBg->Rebin(ReBin);
histo0->Rebin(ReBin);
histoBg->SetLineColor(4);
histo0->SetLineColor(1);
scaleHist(histoBg);
scaleHist(histo0);
cout << "bg events: " << histoBg->GetSumOfWeights() << endl;
cout << "si events: " << histo0->GetSumOfWeights() << endl;
histoBg->SetYTitle("Events");
histo1->SetMinimum(0.01);
if(ysel == 0) {
histo1->Draw("hist");
}
else {
histo0->Draw("E");
histo1->Draw("hist,same");
}
//.........这里部分代码省略.........
示例5: plot
//.........这里部分代码省略.........
ci = TColor::GetColor("#993399");
ewktau->SetFillColor(ci);
ewktau->SetLineWidth(0);
TH1* ewkDY = (TH1*)f->Get("EWK_DYx");
TH1* ewkVV = (TH1*)f->Get("EWK_VVx");
ewktau->Add(ewkDY);
ewktau->Add(ewkVV);
//TH1* qcd = (TH1*)f->Get("QCDInv");
TH1* qcd = (TH1*)f->Get("QCD");
ci = TColor::GetColor("#ffcc33");
qcd->SetFillColor(ci);
qcd->SetLineWidth(0);
TH1* fakett = (TH1*)f->Get("fake_tt");
ci = TColor::GetColor("#669900");
fakett->SetFillColor(ci);
fakett->SetLineWidth(0);
TH1* fakeW = (TH1*)f->Get("fake_W");
ci = TColor::GetColor("#cc3300");
fakeW->SetFillColor(ci);
fakeW->SetLineWidth(0);
TH1* faket = (TH1*)f->Get("fake_t");
TH1F *hFrame = new TH1F("hFrame","",20,0,400);
hFrame->SetMinimum(ymin);
if (log)
hFrame->SetMaximum(ymax*1.5);
else
hFrame->SetMaximum(ymax);
hFrame->SetDirectory(0);
hFrame->SetStats(0);
hFrame->SetLineStyle(0);
hFrame->SetMarkerStyle(20);
hFrame->SetXTitle("Transverse mass (#tau jet, E_{T}^{miss}), (GeV/c^{2})");
if (paperStatus)
hFrame->SetXTitle("Transverse mass (#tau_{h}, E_{T}^{miss}), (GeV/c^{2})");
hFrame->SetYTitle("Events / 20 GeV/c^{2}");
hFrame->GetXaxis()->SetTitleSize(0);
hFrame->GetXaxis()->SetLabelSize(0);
hFrame->GetYaxis()->SetTitleFont(43);
hFrame->GetYaxis()->SetTitleSize(27);
hFrame->GetYaxis()->SetTitleOffset(1.3);
// signal
hh->Scale(br*br);
hw->Scale(2*br*(1.0-br));
TH1* signal = (TH1*)hh->Clone();
signal->Add(hw);
ci = TColor::GetColor("#ff3399");
signal->SetLineColor(ci);
signal->SetLineStyle(2);
signal->SetLineWidth(2);
// Fakes
TH1* fakes = (TH1*)(fakett->Clone());
fakes->Add(fakeW);
fakes->Add(faket);
// stacked backgrounds
THStack *exp = new THStack();
exp->SetName("exp");
exp->SetTitle("exp");
exp->Add(fakes);
exp->Add(ewktau);
示例6: makeResidualsControlPlot
void Template::makeResidualsControlPlot(const string& tag, unsigned int rebin)
/*****************************************************************/
{
if(numberOfDimensions()>0 && m_template->GetNbinsX()%rebin!=0) return;
if(numberOfDimensions()>1 && m_template->GetNbinsY()%rebin!=0) return;
if(numberOfDimensions()>2 && m_template->GetNbinsZ()%rebin!=0) return;
stringstream cpName, cpRawName, resMapName, resDistName, relErrDistName;
cpName << m_name << "_cp";
cpRawName << m_name << "_rawcp";
resMapName << m_name << "_resmap_" << tag << "_rebin" << rebin;
resDistName << m_name << "_resdist_" << tag << "_rebin" << rebin;
relErrDistName << m_name << "_relerrdist_" << tag << "_rebin" << rebin;
TH1* cpTmp = NULL;
TH1* cpRawTmp = NULL;
if(rebin==1)
{
cpTmp = dynamic_cast<TH1*>(m_template->Clone(cpName.str().c_str()));
cpRawTmp = dynamic_cast<TH1*>(m_rawTemplate->Clone(cpRawName.str().c_str()));
}
else
{
if(numberOfDimensions()==2)
{
cpTmp = dynamic_cast<TH2F*>(m_template)->Rebin2D(rebin, rebin, cpName.str().c_str());
cpRawTmp = dynamic_cast<TH2F*>(m_rawTemplate)->Rebin2D(rebin, rebin, cpName.str().c_str());
}
else if(numberOfDimensions()==3)
{
cpTmp = dynamic_cast<TH3F*>(m_template)->Rebin3D(rebin, rebin, rebin, cpName.str().c_str());
cpRawTmp = dynamic_cast<TH3F*>(m_rawTemplate)->Rebin3D(rebin, rebin, rebin, cpName.str().c_str());
}
}
TH1* resMap = dynamic_cast<TH1*>(cpTmp->Clone(resMapName.str().c_str()));
TH1D* resDist = new TH1D(resDistName.str().c_str(), resDistName.str().c_str(), 30, -3, 3);
resDist->StatOverflows();
TH1D* relErrDist = new TH1D(relErrDistName.str().c_str(), relErrDistName.str().c_str(), 200, -1, 1);
relErrDist->StatOverflows();
unsigned int nbins1 = cpTmp->GetNbinsX();
unsigned int nbins2 = cpTmp->GetNbinsY();
unsigned int nbins3 = cpTmp->GetNbinsZ();
for(unsigned int b1=1;b1<=nbins1;b1++)
{
for(unsigned int b2=1;b2<=nbins2;b2++)
{
for(unsigned int b3=1;b3<=nbins3;b3++)
{
double tmpValue = cpTmp->GetBinContent(b1,b2,b3);
double tmpRawValue = cpRawTmp->GetBinContent(b1,b2,b3);
double tmpRawError = cpRawTmp->GetBinError(b1,b2,b3);
if(tmpValue>0. && tmpRawValue>0. && tmpRawError>0.)
{
double res = (tmpRawValue-tmpValue)/tmpRawError;
double relErr = (tmpRawValue-tmpValue)/tmpRawValue;
if(numberOfDimensions()==2)
{
resMap->SetBinContent(b1,b2,b3, res);
resMap->SetBinError(b1,b2,b3, 0.);
}
resDist->Fill(res);
relErrDist->Fill(relErr);
}
}
}
}
stringstream plotMapName, plotDistName, plotErrDistName;
plotMapName << "control_" << getName() << "_resMap" << "_" << tag << "_rebin" << rebin;
plotDistName << "control_" << getName() << "_resDist" << "_" << tag << "_rebin" << rebin;
plotErrDistName << "control_" << getName() << "_relErrDist" << "_" << tag << "_rebin" << rebin;
if(numberOfDimensions()==2)
{
TCanvas* c = new TCanvas(plotMapName.str().c_str(),plotMapName.str().c_str(), 700,700);
resMap->SetContour(99);
resMap->SetAxisRange(-3., 3., "z");
resMap->Draw("color z");
resMap->SetXTitle(getVariable(0).c_str());
resMap->SetYTitle(getVariable(1).c_str());
addControlPlot(c);
}
TCanvas* c2 = new TCanvas(plotDistName.str().c_str(),plotDistName.str().c_str(), 700,700);
resDist->SetLineColor(kBlack);
resDist->SetLineWidth(2);
resDist->SetMarkerColor(kBlack);
resDist->SetMarkerStyle(20);
resDist->SetXTitle("(raw-template)/error_{raw}");
resDist->Draw();
addControlPlot(c2);
TCanvas* c3 = new TCanvas(plotErrDistName.str().c_str(),plotErrDistName.str().c_str(), 700,700);
relErrDist->SetLineColor(kBlack);
relErrDist->SetLineWidth(2);
relErrDist->SetMarkerColor(kBlack);
relErrDist->SetMarkerStyle(20);
relErrDist->SetXTitle("(raw-template)/raw");
relErrDist->Draw();
addControlPlot(c3);
if(cpTmp) delete cpTmp;
if(cpRawTmp) delete cpRawTmp;
}