本文整理汇总了C++中TText::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ TText::Draw方法的具体用法?C++ TText::Draw怎么用?C++ TText::Draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TText
的用法示例。
在下文中一共展示了TText::Draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: greyscale
void greyscale()
{
TCanvas *c = new TCanvas("grey", "Grey Scale", 500, 500);
c->SetBorderMode(0);
Int_t n = 200; // tunable parameter
Float_t n1 = 1./n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
TBox *b = new TBox(n1*j, n1*(n-1-i), n1*(j+1), n1*(n-i));
Float_t grey = Float_t(i*n+j)/(n*n);
b->SetFillColor(TColor::GetColor(grey, grey, grey));
b->Draw();
}
}
TPad *p = new TPad("p","p",0.3, 0.3, 0.7,0.7);
const char *guibackground = gEnv->GetValue("Gui.BackgroundColor", "");
p->SetFillColor(TColor::GetColor(guibackground));
p->Draw();
p->cd();
TText *t = new TText(0.5, 0.5, "GUI Background Color");
t->SetTextAlign(22);
t->SetTextSize(.09);
t->Draw();
c->SetEditable(kFALSE);
}
示例2: PaintOverflow
void PaintOverflow(TH1 *h)
{
// This function paint the histogram h with an extra bin for overflows
char* name = h->GetName();
char* title = h->GetTitle();
Int_t nx = h->GetNbinsX()+1;
Double_t x1 = h->GetBinLowEdge(1);
Double_t bw = h->GetBinWidth(nx);
Double_t x2 = h->GetBinLowEdge(nx)+bw;
// Book a temporary histogram having ab extra bin for overflows
TH1F *htmp = new TH1F(name, title, nx, x1, x2);
// Fill the new hitogram including the extra bin for overflows
for (Int_t i=1; i<=nx; i++) {
htmp->Fill(htmp->GetBinCenter(i), h->GetBinContent(i));
}
// Fill the underflows
htmp->Fill(x1-1, h->GetBinContent(0));
// Restore the number of entries
htmp->SetEntries(h->GetEntries());
// Draw the temporary histogram
htmp->Draw();
TText *t = new TText(x2-bw/2,h->GetBinContent(nx),"Overflow");
t->SetTextAngle(90);
t->SetTextAlign(12);
t->SetTextSize(0.03);;
t->Draw();
}
示例3: highlight1
void highlight1()
{
TCanvas *ch = new TCanvas("ch", "ch", 0, 0, 700, 500);
const Int_t n = 500;
Double_t x[n], y[n];
TH1F *h[n];
for (Int_t i = 0; i < n; i++) {
h[i] = new TH1F(TString::Format("h_%02d", i), "", 100, -3.0, 3.0);
// in practice gaus need reset parameters
h[i]->FillRandom("gaus", 1000);
h[i]->Fit("gaus", "Q");
h[i]->SetMaximum(250); // for n > 200
x[i] = i;
y[i] = h[i]->GetFunction("gaus")->GetParameter(2);
}
TGraph *g = new TGraph(n, x, y);
g->SetMarkerStyle(6);
for (Int_t i = 0; i < n; i++) g->AddHighlight(i, h[i]);
g->Draw("AP");
g->SetHighlight();
TPad *ph = new TPad("ph", "ph", 0.3, 0.4, 1.0, 1.0);
ph->SetFillColor(kBlue - 10);
ph->Draw();
ph->cd();
TText *info = new TText(0.5, 0.5, "please move the mouse over the graph");
info->SetTextAlign(22);
info->Draw();
ch->cd();
TGraph::SetHighlightPad(ph);
}
示例4: 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();
}
示例5: standardCutFlowPlot
void CutFlow::standardCutFlowPlot(TH1D* data, THStack *hs, AllSamples samples, Variable variable){
//Style
TdrStyle style;
style.setTDRStyle();
//draw histos to files
TCanvas *c1 = new TCanvas("Plot","Plot",900, 600);
data->Draw();
hs->Draw("hist");
setBinLabels(hs, data);
if(Globals::addHashErrors){
TH1D* hashErrs = hashErrors(samples, variable);
hashErrs->Draw("same e2");
}
data->Draw("E same");
data->SetMarkerStyle(20);
data->SetMarkerSize(0.5);
hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.3);
hs->GetXaxis()->SetLimits(variable.minX, variable.maxX);
hs->GetXaxis()->SetTitle(variable.xTitle); hs->GetXaxis()->SetTitleSize(0.05);
hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05);
TLegend* leg = legend(samples);
leg->Draw();
TText* textChan = doChan(0.12,0.96);
textChan->Draw();
TText* textPrelim = doPrelim(0.58,0.96);
textPrelim->Draw();
c1->SetLogy();
c1->SaveAs("Plots/ControlPlots/"+objName+"/Log/"+variable.name+".png");
c1->SaveAs("Plots/ControlPlots/"+objName+"/Log/"+variable.name+".pdf");
delete c1;
delete leg;
delete textChan;
delete textPrelim;
}
示例6: TText
void drift_chisq()
{
int i;
events = (TTree*)f.Get("events");
c1.Divide(2, 2, 0.01, 0.02);
c2.Divide(2, 2, 0.01, 0.02);
i = 0;
c1.cd(++i);
makehist("t3X", 2);
c1.cd(++i);
makehist("t4X", 2);
c1.cd(++i);
makehist("t3Y", 2);
c1.cd(++i);
makehist("t4Y", 2);
i = 0;
c2.cd(++i);
makehist("t3X", 1);
c2.cd(++i);
makehist("t4X", 1);
c2.cd(++i);
makehist("t3Y", 1);
c2.cd(++i);
makehist("t4Y", 1);
TText *t;
TTree *info = (TTree*)f.FindObjectAny("info");
TString info_str = get_info_str(info);
c1.cd(0);
t = new TText(0.005, 0.005, info_str);
t->SetTextSize(0.02);
t->Draw();
c2.cd(0);
t = new TText(0.005, 0.005, info_str);
t->SetTextSize(0.02);
t->Draw();
c1.Show();
c2.Show();
}
示例7: do2DPlots
void do2DPlots(bool muon, TString variable, TString ytitle){
TString leptonFolder;
if(muon == true){
leptonFolder = "MuonMET/";
}else{
leptonFolder = "ElectronMET/";
}
setTDRStyle();
gStyle->SetPalette(1);
TString dir = "rootFilesV4/central/";
TFile* tt_file = new TFile(dir + sample+"_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root");
cout << "Getting histo: " << "Binning/"+leptonFolder+variable+"/GenMET_vs_RecoMET"<<endl;
TH2D* tt_2d = (TH2D*) tt_file->Get("Binning/"+leptonFolder+variable+"/GenMET_vs_RecoMET_2btags");
TH2D* tt_2d_3b = (TH2D*) tt_file->Get("Binning/"+leptonFolder+variable+"/GenMET_vs_RecoMET_3btags");
TH2D* tt_2d_4b = (TH2D*) tt_file->Get("Binning/"+leptonFolder+variable+"/GenMET_vs_RecoMET_4orMoreBtags");
tt_2d->Add(tt_2d_3b);
tt_2d->Add(tt_2d_4b);
tt_2d->Rebin2D(5,5);
tt_2d->GetYaxis()->SetTitle(ytitle);
tt_2d->GetXaxis()->SetTitle("Gen MET (GeV)");
tt_2d->GetYaxis()->SetTitleOffset(1.8);
tt_2d->GetXaxis()->SetTitleOffset(1.5);
TCanvas *c= new TCanvas("c","c",10,10,800,600);
tt_2d->Draw("COLZ");
int bin[5] = {25, 45, 70, 100, 150};//MET
for(int i = 0; i < 5; i++){
TLine *line = new TLine(bin[i],0,bin[i],300);
TLine *liney = new TLine(0,bin[i],300,bin[i]);
//TLine *line = new TLine(bin[i],0,bin[i],500);
//TLine *liney = new TLine(0,bin[i],500,bin[i]);
line->SetLineWidth(2);
liney->SetLineWidth(2);
liney->Draw();
line->Draw();
}
TText* textPrelim = doPrelim(0.2,0.96);
textPrelim->Draw();
TString plotName("plots/"+leptonFolder);
plotName += sample+"_"+variable;
plotName += "_2btags.pdf";
c->SaveAs(plotName);
delete c;
}
示例8: DrawPeriod
//______________________________________________________________________________
void DrawPeriod(int runmin, int runmax, int run1, int run2, double ymin, double ymax, const char* label)
{
if ( run1 < runmin || run1 > runmax || run2 < runmin || run2 > runmax ) return;
TBox* b = new TBox(run1,ymin,run2,ymax);
b->SetFillColor(5);
b->Draw();
TText* text = new TText((run1+run2)/2.0,ymax*0.6,label);
text->SetTextAlign(22);
text->SetTextSize(0.02);
text->Draw();
}
示例9: TCanvas
void Plots2D::standardPlot(TH2D* ttbar, Variable variable){
//Style
TdrStyle style;
style.setTDRStyle();
gStyle->SetPalette(1);
gStyle->SetPadRightMargin(0.12);
//draw histos to files
TCanvas *c1 = new TCanvas("Plot","Plot",900, 800);
ttbar->Draw("COLZ");
// ttbar->SetMaximum(ttbar->GetBinContent(ttbar->GetMaximumBin())*1.3);
ttbar->SetAxisRange(variable.minX, variable.maxX, "X");
ttbar->SetAxisRange(variable.minX, variable.maxX, "Y");
ttbar->GetXaxis()->SetTitle("Gen " +variable.xTitle);
ttbar->GetXaxis()->SetTitleSize(0.05);
ttbar->GetYaxis()->SetTitle("Reco " +variable.xTitle);
ttbar->GetYaxis()->SetTitleSize(0.05);
for(unsigned int i = 0; i < bins.size(); i++){
TLine *line = new TLine(bins[i],variable.minX,bins[i], variable.maxX);
TLine *liney = new TLine(variable.minX,bins[i], variable.maxX, bins[i]);
line->SetLineWidth(2);
liney->SetLineWidth(2);
liney->Draw();
line->Draw();
}
TText* textChan = doChan(0.12,0.96);
textChan->Draw();
TText* textPrelim = doPrelim(0.58,0.96);
textPrelim->Draw();
c1->SaveAs("Plots/ControlPlots/2DPlots/"+variable.name+".png");
c1->SaveAs("Plots/ControlPlots/2DPlots/"+variable.name+".pdf");
delete c1;
delete textChan;
delete textPrelim;
}
示例10: postprocess
void postprocess(TCanvas* c2, const char* name, Int_t rWrite, Int_t rPerformance) {
if (rPerformance){
TLatex *alice = new TLatex(0.65,0.47,"Performance");
alice->SetNDC();
alice->SetTextColor(myDarkRed);
alice->SetTextFont(42);
alice->SetTextSize(0.05);
alice->SetLineWidth(2);
alice->Draw();
TLatex *alice2 = new TLatex(0.62,0.41,"LHC10h - Pass2");
alice2->SetNDC();
alice2->SetTextColor(myDarkRed);
alice->SetTextFont(42);
alice2->SetTextSize(0.05);
alice2->SetLineWidth(2);
alice2->Draw();
TText *date = new TText(0.68,0.35,cStamp2);
date->SetNDC();
date->SetTextFont(42);
date->SetTextSize(0.04);
date->Draw();
//Acquire canvas proportions
Double_t AliLogo_LowX = 0.67;
Double_t AliLogo_LowY = 0.53;
Double_t AliLogo_Height = 0.22;
//ALICE logo is a png file that is 821x798 pixels->should be wider than a square
Double_t AliLogo_Width = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw();
TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height);
// myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment !
myPadSetUp(myPadLogo,0,0,0,0);
//myPadLogo->SetFixedAspectRatio(1);
myPadLogo->Draw();
myPadLogo->cd();
TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png");
myAliceLogo->Draw();
}
if (rWrite == 1)
c2->SaveAs(Form("%s.png",name));
if (rWrite == 2)
c2->SaveAs(Form("%s.eps",name));
}
示例11: fill_with_text
void fill_with_text(TGraph *real, TGraph *down, TGraph *up, TVirtualPad *can, int scantype, std::string scanx = "") {
can->cd();
float xpos_of_text = 0.22;
TLegend* this_leg = new TLegend(xpos_of_text,0.6,0.38,0.75);
//TLegend* this_leg = new TLegend(xpos_of_text,0.55,0.45,0.75,"n_{jets} #geq 3"); // this was the style of the paper.
this_leg->SetFillColor(0);
this_leg->SetBorderSize(0);
this_leg->SetTextSize(0.035);
//this_leg->SetTextSize(0.04); // paper style.
if(scantype==PlottingSetup::SMS||scantype==PlottingSetup::GMSB) {
//this_leg->AddEntry(real,"#sigma^{prod} = #sigma^{NLO-QCD}" , "l");
//this_leg->AddEntry(up,"#sigma^{prod} = 3 #times #sigma^{NLO-QCD}" , "l");
//this_leg->AddEntry(down,"#sigma^{prod} = 1/3 #times #sigma^{NLO-QCD}" , "l");
this_leg->AddEntry(real,"#sigma^{NLO-QCD}" , "l");
this_leg->AddEntry(up,"3 #times #sigma^{NLO-QCD}" , "l");
this_leg->AddEntry(down,"1/3 #times #sigma^{NLO-QCD}" , "l");
} else {
write_warning(__FUNCTION__,"Not implemented yet for mSUGRA");
}
this_leg->Draw();
TText *title = write_text(xpos_of_text+0.005,0.52,"JZB");
title->SetTextSize(0.04);
title->SetTextAlign(13);
title->SetTextFont(62);
title->Draw();
write_SMS_text( scantype, scanx, xpos_of_text );
// //string legT5zz="pp #rightarrow #tilde{g} #tilde{g}, #tilde{g} #rightarrow 2j + #chi^{0}_{1}, #chi^{0}_{1} #rightarrow Z + #tilde{G}";
// string legT5zz="pp #rightarrow #tilde{g} #tilde{g}, #tilde{g} #rightarrow 2j + #chi^{0}_{2}, #chi^{0}_{2} #rightarrow Z #chi^{0}_{1}";
// string legT5zzl2="m(#tilde{q}) >> m(#tilde{g}), x = "+scanx;
// string legT5zzl3=" GMSB";
// TText *title = write_text(xpos_of_text,0.85,legT5zz);
// title->SetTextAlign(11);
// title->SetTextSize(0.035);
// if(scantype!=PlottingSetup::mSUGRA) title->Draw("same");
// TText *title2 = write_text(xpos_of_text,0.79,legT5zzl2);
// title2->SetTextAlign(11);
// title2->SetTextSize(0.035);
// if(scantype!=PlottingSetup::mSUGRA) title2->Draw("same");
// TText *title3 = write_text(0.40,0.79,legT5zzl3);
// title3->SetTextAlign(11);
// title3->SetTextSize(0.035);
// title3->SetTextColor(kRed);
//// if(scantype==PlottingSetup::GMSB) title3->Draw("same");
DrawPrelim();
draw_diagonal_xchange( scantype, scanx );
}
示例12: 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;
}
示例13: write_SMS_text
void write_SMS_text(int scantype, std::string& scanx, float xpos = 0.22 ) {
string legT5zz="pp #rightarrow #tilde{g} #tilde{g}, #tilde{g} #rightarrow 2j + #chi^{0}_{2}, #chi^{0}_{2} #rightarrow Z #chi^{0}_{1}";
if ( scantype==PlottingSetup::GMSB) legT5zz="pp #rightarrow #tilde{g} #tilde{g}, #tilde{g} #rightarrow 2j + #chi^{0}_{1}, #chi^{0}_{1} #rightarrow Z #tilde{G}";
string legT5zzl2="m(#tilde{q}) >> m(#tilde{g})";
if (scantype==PlottingSetup::SMS) legT5zzl2 += ", x = "+scanx;
string legT5zzl3=" GMSB";
TText *title = write_text(xpos,0.85,legT5zz);
title->SetTextAlign(11);
title->SetTextSize(0.035);
if(scantype!=PlottingSetup::mSUGRA) title->Draw("same");
TText *title2 = write_text(xpos,0.79,legT5zzl2);
title2->SetTextAlign(11);
title2->SetTextSize(0.035);
if(scantype!=PlottingSetup::mSUGRA) title2->Draw("same");
TText *title3 = write_text(0.40,0.79,legT5zzl3);
title3->SetTextAlign(11);
title3->SetTextSize(0.035);
title3->SetTextColor(kRed);
// if(scantype==PlottingSetup::GMSB) title3->Draw("same");
}
示例14: hlHisto4
void hlHisto4()
{
TCanvas *c1 = new TCanvas("c1", "", 0, 0, 600, 400);
TF1 *f1 = new TF1("f1", "x*gaus(0) + [3]*abs(sin(x)/x)", -50.0, 50.0);
f1->SetParameters(20.0, 4.0, 1.0, 20.0);
TH1F *h1 = new TH1F("h1", "Test random numbers", 200, -50.0, 50.0);
h1->FillRandom("f1", 100000);
h1->Draw();
h1->Fit(f1, "Q");
gStyle->SetGridColor(kGray);
c1->SetGrid();
TText *info = new TText(0.0, h1->GetMaximum()*0.7, "please move the mouse over the frame");
info->SetTextSize(0.04);
info->SetTextAlign(22);
info->SetTextColor(kRed-1);
info->SetBit(kCannotPick);
info->Draw();
c1->Update();
h1->SetHighlight();
c1->HighlightConnect("HighlightZoom(TVirtualPad*,TObject*,Int_t,Int_t)");
}
示例15: doPlotsBtag_Log
//.........这里部分代码省略.........
wjets->Add(w2jets);
wjets->Add(w3jets);
wjets->Add(w4jets);
//make combined top and single top template
TH1D* qcd_all = (TH1D*)qcd->Clone("qcd_all");
qcd_all->Add(qcd2);
qcd_all->Add(qcd3);
qcd_all->Add(qcd4);
qcd_all->Add(qcd5);
qcd_all->Add(qcd6);
qcd_all->Add(qcd7);
qcd_all->Add(qcd8);
qcd_all->Add(qcd9);
qcd_all->Add(qcd10);
qcd_all->Add(qcd11);
THStack *hs = new THStack("hs","test");
qcd_all->SetLineColor(kBlack);
zjets->SetLineColor(kBlack);
wjets->SetLineColor(kBlack);
sing_top->SetLineColor(kBlack);
tt->SetLineColor(kBlack);
hs->Add(qcd_all);
hs->Add(zjets);
hs->Add(wjets);
hs->Add(sing_top);
hs->Add(tt);
//draw histos to files
TCanvas *c1 = new TCanvas("Plot","Plot",900, 600);
hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.2);
hs->SetMinimum(1.);
hs->Draw();
data->Draw("E same");
data->SetMarkerStyle(20);
//events:
cout << "ttbar: " << tt->Integral() << endl;
cout << "data: " << data->Integral() << endl;
if(logPlot == true){
hs->GetXaxis()->SetLimits(MinX, MaxX);
}else{
hs->GetXaxis()->SetLimits(MinX, 4.5);
}
hs->GetXaxis()->SetTitle(Xtitle); hs->GetXaxis()->SetTitleSize(0.05);
hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05);
TLegend *tleg2;
tleg2 = new TLegend(0.7,0.7,0.8,0.9);
tleg2->SetTextSize(0.04);
tleg2->SetBorderSize(0);
tleg2->SetFillColor(10);
tleg2->AddEntry(data , "2012 data", "lpe");
tleg2->AddEntry(tt , "t#bar{t}", "f");
tleg2->AddEntry(sing_top, "single top", "f");
tleg2->AddEntry(wjets , "w+jets", "f");
tleg2->AddEntry(zjets , "z+jets", "f");
tleg2->AddEntry(qcd_all , "QCD", "f");
//tleg2->AddEntry(singtEff, "single-t" , "l");
//tleg2->AddEntry(singtwEff, "single-tW" , "l");
tleg2->Draw("same");
if(logPlot == true){
TText* textPrelim = doPrelim(0.12,0.96, "#geq 0 btags");
textPrelim->Draw();
}else{
TText* textPrelim = doPrelim(0.2,0.96, "");
textPrelim->Draw();
}
if(logPlot ==true){
c1->SetLogy();
}
TString plotName("Plots/TTbarPlusVarAnalysis/Nbtags/");
if(logPlot ==true){
plotName += Variable+"_Log";
}else{
plotName += Variable;
}
c1->SaveAs(plotName+".pdf");
c1->SaveAs(plotName+".png");
delete c1;
}
}