本文整理汇总了C++中TPaveText::SetMargin方法的典型用法代码示例。如果您正苦于以下问题:C++ TPaveText::SetMargin方法的具体用法?C++ TPaveText::SetMargin怎么用?C++ TPaveText::SetMargin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPaveText
的用法示例。
在下文中一共展示了TPaveText::SetMargin方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawStatBox
void DrawStatBox(TObject** Histos, std::vector<char*> legend, bool Mean, double X, double Y, double W, double H)
{
int N = legend.size();
char buffer[255];
if(Mean)H*=3;
for(int i=0;i<N;i++){
TPaveText* stat = new TPaveText(X,Y-(i*H), X+W, Y-(i+1)*H, "NDC");
TH1* Histo = (TH1*)Histos[i];
sprintf(buffer,"Entries : %i\n",(int)Histo->GetEntries());
stat->AddText(buffer);
if(Mean){
sprintf(buffer,"Mean : %6.2f\n",Histo->GetMean());
stat->AddText(buffer);
sprintf(buffer,"RMS : %6.2f\n",Histo->GetRMS());
stat->AddText(buffer);
}
stat->SetFillColor(0);
stat->SetLineColor(Color[i]);
stat->SetTextColor(Color[i]);
stat->SetBorderSize(0);
stat->SetMargin(0.05);
stat->SetTextAlign(12);
stat->Draw();
}
}
示例2: banner4Plot
void banner4Plot (){
TPaveText* pt ;
pt = new TPaveText(.14,0.91,.25,.94,"NDC");
pt->AddText("Preliminary");
pt->SetFillColor(0);
pt->SetTextSize(0.035);
pt->SetFillStyle(0);
pt->SetLineColor(0);
pt->SetLineWidth(0);
pt->SetMargin(0);
pt->SetShadowColor(0);
pt->Draw();
}
示例3: arrangeCanvas
//*************************************************************
void arrangeCanvas(TCanvas *canv,TH1F* meanplots[100],TH1F* widthplots[100],Int_t nFiles, TString LegLabels[10], bool onlyBias){
//*************************************************************
TPaveText *ali = new TPaveText(0.18,0.87,0.50,0.93,"NDC");
ali->SetFillColor(10);
ali->SetTextColor(1);
ali->SetTextFont(42);
ali->SetMargin(0.);
ali->SetLineColor(10);
ali->SetShadowColor(10);
// pt->SetTextAlign(11);
TText *alitext = ali->AddText("Alignment: PCL"); //"Preliminary 2015 - 0T collision data");
alitext->SetTextSize(0.04);
TLegend *lego = new TLegend(0.18,0.80,0.78,0.92);
lego-> SetNColumns(2);
//TLegend *lego = new TLegend(0.18,0.77,0.50,0.86);
lego->SetFillColor(10);
lego->SetTextSize(0.04);
lego->SetTextFont(42);
lego->SetFillColor(10);
lego->SetLineColor(10);
lego->SetShadowColor(10);
TPaveText *pt = NULL;
TPaveText *pt2 = NULL;
TPaveText *pt3 = NULL;
if(!onlyBias){
pt =new TPaveText(0.179,0.955,0.260,0.985,"NDC");
} else {
pt =new TPaveText(0.179,0.955,0.260,0.985,"NDC");
}
pt->SetFillColor(10);
pt->SetTextColor(1);
pt->SetTextFont(61);
// pt->SetTextAlign(11);
TText *text1 = pt->AddText("CMS"); //"Preliminary 2015 - 0T collision data");
text1->SetTextSize(0.05);
float extraOverCmsTextSize = 0.76;
if(!onlyBias){
pt2 =new TPaveText(0.3,0.95,0.503,0.98,"NDC");
} else {
pt2 =new TPaveText(0.3,0.95,0.503,0.98,"NDC");
}
pt2->SetFillColor(10);
pt2->SetTextColor(1);
pt2->SetTextFont(52);
pt2->SetTextAlign(22);
TText *text2 = pt2->AddText("work in progress");
text2->SetTextSize(0.05*extraOverCmsTextSize);
if(!onlyBias){
pt3 =new TPaveText(0.6,0.95,0.98,0.98,"NDC");
} else {
pt3 =new TPaveText(0.6,0.95,0.98,0.98,"NDC");
}
pt3->SetFillColor(10);
pt3->SetTextColor(1);
pt3->SetTextFont(42);
// pt2->SetTextAlign(11);
TText *text3 = pt3->AddText("3.8T collision data 2015");
text3->SetTextSize(0.05*extraOverCmsTextSize);
canv->SetFillColor(10);
if(!onlyBias) {
canv->Divide(2,1);
canv->cd(1)->SetBottomMargin(0.12);
canv->cd(1)->SetLeftMargin(0.17);
canv->cd(1)->SetRightMargin(0.02);
canv->cd(1)->SetTopMargin(0.06);
canv->cd(2)->SetBottomMargin(0.12);
canv->cd(2)->SetLeftMargin(0.17);
canv->cd(2)->SetRightMargin(0.02);
canv->cd(2)->SetTopMargin(0.06);
canv->cd(1);
} else {
canv->cd()->SetBottomMargin(0.14);
canv->cd()->SetLeftMargin(0.17);
canv->cd()->SetRightMargin(0.02);
canv->cd()->SetTopMargin(0.06);
canv->cd();
}
Double_t absmin(999.);
Double_t absmax(-999.);
for(Int_t i=0; i<nFiles; i++){
if(meanplots[i]->GetMaximum()>absmax) absmax = meanplots[i]->GetMaximum();
//.........这里部分代码省略.........
示例4: stack_upgrade_42X
//.........这里部分代码省略.........
h_1d[iHist][iFile]->SetLineWidth(0);
h_1d[iHist][iFile]->SetFillStyle(3244);
if(iFile == 1){ h_1d[iHist][iFile]->SetFillColor(ZZ_Color); }
else if(iFile == 2){ h_1d[iHist][iFile]->SetFillColor(WZ_Color); }
else if(iFile == 3){ h_1d[iHist][iFile]->SetFillColor(TTbar_Color); }
else if(iFile == 4){ h_1d[iHist][iFile]->SetFillColor(Zjet_Color); }
else if(iFile == 5){
signal[iHist]->Add(h_1d[iHist][iFile+1]);
signal[iHist]->SetLineColor(kRed);
signal[iHist]->SetLineWidth(2.0);
}
if(iFile < 5) hs->Add(h_1d[iHist][iFile],"hist");
}
//hs->Add(signal[iHist],"hist");
h_1d[iHist][0]->SetMarkerStyle(21);
h_1d[iHist][0]->SetMarkerSize(0.7);
TLegend* leg = new TLegend(0.65,0.70,0.88,0.88,NULL,"brNDC");
leg->SetFillColor(0);
leg->SetTextSize(0.035);
leg->SetBorderSize(0);
leg->AddEntry(h_1d[iHist][0],"data 2011","p");
leg->AddEntry(h_1d[iHist][1],"ZZ","f");
leg->AddEntry(h_1d[iHist][2],"WZ","f");
leg->AddEntry(h_1d[iHist][3],"t#bar{t}","f");
leg->AddEntry(h_1d[iHist][4],"Zjet","f");
leg->AddEntry(signal[iHist],"ZH(120)#times 5","f");
TString lumist="4.9 fb^{-1}";
TPaveText *ll = new TPaveText(0.25, 0.95, 0.95, 0.99, "NDC");
ll->SetTextSize(0.03);
ll->SetTextFont(62);
ll->SetFillColor(0);
ll->SetBorderSize(0);
ll->SetMargin(0.01);
ll->SetTextAlign(12); // align left
TString text = PaveText[iHist];
ll->AddText(0.01,0.5,text);
text = "#sqrt{s} = 7 TeV L = ";
text = text + lumist;
// ll->SetTextAlign(32); // align right
ll->AddText(0.5, 0.5, text);
/*double max_dy = h_1d[iHist][4]->GetMaximum();
double max_data = h_1d[iHist][0]->GetMaximum();
double max = 0;
if (max_dy > max_data){
max = max_dy;}
else {
max = max_data;}
if (max != 0) hs->SetMaximum(max);
cout << "max data: " << max_data << endl;
cout << "max dy: " << max_dy << endl;
*/
h_1d[iHist][0]->Draw("PE01");
double max = h_1d[iHist][0]->GetMaximum();
h_1d[iHist][0]->GetYaxis()->SetRangeUser(1e-2,200*max);
// if(iHist > 0 && iHist < 4) h_1d[iHist][0]->GetXaxis()->SetRangeUser(0,150);
h_1d[iHist][0]->GetXaxis()->SetTitle(histTitles[iHist]);
hs->Draw("same");
signal[iHist]->Scale(10.);
signal[iHist]->Draw("histsame");
h_1d[iHist][0]->Draw("samePE01");
leg->Draw("same");
ll->Draw("same");
gPad->RedrawAxis();
c1->SetLogy();
c1->Print("NewCuts/Mu_"+histNames1[iHist]+"_all.png");
c1->Print("NewCuts/Mu_"+histNames1[iHist]+"_all.eps");
c1->SetLogy(0);
h_1d[iHist][0]->GetYaxis()->SetRangeUser(0,1.5*max);
c1->Print("NewCuts/Mu_"+histNames1[iHist]+"_all_normal.png");
c1->Print("NewCuts/Mu_"+histNames1[iHist]+"_all_normal.eps");
leg->Clear();
hs->Clear();
}
return 0;
}
示例5: stack_upgrade
//.........这里部分代码省略.........
//~
//~ //hs->Add(signal[iFile],"hist");
//~
h_1d_data[iHist]->SetMarkerStyle(21);
h_1d_data[iHist]->SetMarkerSize(0.7);
//~
TLegend* leg = new TLegend(0.65,0.60,0.88,0.88,NULL,"brNDC");
leg->SetFillColor(0);
leg->SetTextSize(0.035);
leg->SetBorderSize(0);
//~
leg->AddEntry(h_1d_data[iHist],"data 2012","p");
for(uint iFile=0; iFile < bg_names.size(); iFile++)
{
if(bg_plot[iFile]) leg->AddEntry((*(h_1d_bg[iFile]))[iHist],bg_titles[iFile],"f");
}
leg->AddEntry(h_1BG[iHist],"reducible","f");
//~
//~ leg->AddEntry(h_1d[iFile][4],"Z+jets","f");
//~ leg->AddEntry(signal[iFile],"ZH(125)","f");
//~
TString lumist="19.7 fb^{-1}";
TPaveText *ll = new TPaveText(0.25, 0.95, 0.95, 0.99, "NDC");
ll->SetTextSize(0.03);
ll->SetTextFont(62);
ll->SetFillColor(0);
ll->SetBorderSize(0);
ll->SetMargin(0.01);
ll->SetTextAlign(12); // align left
TString text = PaveText[iHist];
ll->AddText(0.01,0.5,text);
text = "#sqrt{s} = 8 TeV L = ";
text = text + lumist;
// ll->SetTextAlign(32); // align right
ll->AddText(0.5, 0.5, text);
//~
h_1d_data[iHist]->Draw("PE01");
//~ double max = h_1d[iFile][0]->GetMaximum();
//~ h_1d[iFile][0]->GetYaxis()->SetRangeUser(1e-2,200*max);
//~ // if(iHist > 0 && iHist < 4) h_1d[iFile][0]->GetXaxis()->SetRangeUser(0,150);
//~
h_1d_data[iHist]->GetXaxis()->SetTitle(histTitles[iHist]);
hs->Draw("same");
//~ // signal[iFile]->Scale(10.);
//~ signal[iFile]->Draw("histsame");
h_1d_data[iHist]->Draw("samePE01");
//~
//~
leg->Draw("same");
ll->Draw("same");
gPad->RedrawAxis();
//~
//~ c1->SetLogy();
c1->Print(outputDir+"/png/"+histNames1[iHist]+".png");
c1->Print(outputDir+"/pdf/"+histNames1[iHist]+".pdf");
//~ c1->Print("Moriond/Mu_"+histNames1[iFile]+"_all.eps");
//~ c1->SetLogy(0);
示例6: MultiHistoOverlap
void MultiHistoOverlap(TString namesandlabels, Int_t nOfFiles, const TString& outDir="./"){
gROOT->Reset();
gROOT->ProcessLine(".L tdrstyle.C");
gROOT->ProcessLine("setTDRStyle()");
// gSystem->Load("libRooFit");
// using namespace RooFit;
// preamble
TPaveText *cmsprel = new TPaveText(0.19, 0.95, 0.95, 0.99, "NDC");
cmsprel->SetTextSize(0.03);
cmsprel->SetTextFont(42);
cmsprel->SetFillColor(0);
cmsprel->SetBorderSize(0);
cmsprel->SetMargin(0.01);
cmsprel->SetTextAlign(12); // align left
TString text = "CMS Preliminary 2011";
cmsprel->AddText(0.0, 0.5,text);
TString text2 = "#sqrt{s} = 7 TeV |#eta_{#mu}|<2.4";
cmsprel->AddText(0.8, 0.5, text2);
TList* FileList = new TList();
TList* LabelList = new TList();
TObjArray *nameandlabelpairs = namesandlabels.Tokenize(",");
for (Int_t i = 0; i < nameandlabelpairs->GetEntries(); ++i) {
TObjArray *aFileLegPair = TString(nameandlabelpairs->At(i)->GetName()).Tokenize("=");
if(aFileLegPair->GetEntries() == 2) {
FileList->Add( TFile::Open(aFileLegPair->At(0)->GetName()) );
LabelList->Add( aFileLegPair->At(1) );
} else {
std::cout << "Please give file name and legend entry in the following form:\n" << " filename1=legendentry1,filename2=legendentry2\n";
}
}
Int_t NOfFiles = FileList->GetSize();
if ( NOfFiles!=nOfFiles ){
std::cout<<"&MSG-e: NOfFiles = "<<nOfFiles<<std::endl;
return;
}
std::vector<TString> LegLabels;
LegLabels.reserve(nOfFiles);
for(Int_t j=0; j < nOfFiles; j++) {
TObjString* legend = (TObjString*)LabelList->At(j);
LegLabels.push_back(legend->String());
std::cout<<"LegLabels["<<j<<"]"<<LegLabels[j]<<std::endl;
}
TLegend *leg=0;
TCanvas* c0 = new TCanvas("c0", "c0",50, 20, 800,600);
TCanvas* c1 = new TCanvas("c1", "c1",50, 20, 800,600);
TCanvas* c2 = new TCanvas("c2", "c2",50, 20, 800,600);
TCanvas* c3 = new TCanvas("c3", "c3",50, 20, 800,600);
TCanvas* c4 = new TCanvas("c4", "c4",50, 20, 800,600);
TCanvas* c5 = new TCanvas("c5", "c5",50, 20, 1200,800);
TCanvas* c6 = new TCanvas("c6", "c6",50, 20, 1200,800);
TCanvas* c0s = new TCanvas("c0s", "c0s",50, 20, 800,600);
TCanvas* c1s = new TCanvas("c1s", "c1s",50, 20, 800,600);
TCanvas* c2s = new TCanvas("c2s", "c2s",50, 20, 800,600);
TCanvas* c3s = new TCanvas("c3s", "c3s",50, 20, 800,600);
TCanvas* cFit = new TCanvas("cFit", "cFit",50, 20, 1600, 800);
//----------------- CANVAS C0 --------------//
c0->SetFillColor(0);
c0->cd();
leg = new TLegend(0.50,0.25,0.90,0.40);
leg->SetBorderSize(1);
leg->SetFillColor(0);
leg->SetTextFont(42);
// Mass VS muon phi plus -------------------------------
TH1D *histoMassVsPhiPlus[nOfFiles];
for(Int_t j=0; j < nOfFiles; j++) {
TFile *fin = (TFile*)FileList->At(j);
if (( histoMassVsPhiPlus[j] = (TH1D*)fin->Get("MassVsPhiPlus/allHistos/meanHisto"))){
histoMassVsPhiPlus[j]->SetLineStyle(linestylelist[j]);
histoMassVsPhiPlus[j]->SetMarkerColor(colorlist[j]);
histoMassVsPhiPlus[j]->SetLineColor(colorlist[j]);
histoMassVsPhiPlus[j]->SetMarkerStyle(markerstylelist[j]);
// histoMassVsPhiPlus[j]->SetMarkerSize(0.75);
if ( j == 0 ) {
histoMassVsPhiPlus[j]->GetXaxis()->SetTitle("positive muon #phi (rad)");
histoMassVsPhiPlus[j]->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)");
// histoMassVsPhiPlus[j]->GetYaxis()->SetRangeUser(88.5,93.5);
histoMassVsPhiPlus[j]->GetYaxis()->SetRangeUser(90.0,91.5);
histoMassVsPhiPlus[j]->GetXaxis()->SetRangeUser(-3.14,3.14);
histoMassVsPhiPlus[j]->Draw();
} else {
histoMassVsPhiPlus[j]->Draw("SAME");
}
leg->AddEntry(histoMassVsPhiPlus[j],LegLabels[j],"PL");
//.........这里部分代码省略.........
示例7: CompareAllHistos
//.........这里部分代码省略.........
newOverHist->SetBinError(iBin,overHist->GetBinError(iBin));
newDMHist2->SetBinContent(iBin,profileHist1[title_id][1]->GetBinContent(iBin));
newDMHist2->SetBinError(iBin,profileHist1[title_id][1]->GetBinError(iBin));
}
newBaseHist->Multiply(newDMHist);
newOverHist->Multiply(newDMHist2);
baseHist=newBaseHist;
overHist=newOverHist;
delete newDMHist;
delete newDMHist2;
}
if(title_id==0) baseHist->GetXaxis()->SetRangeUser(0,100);
baseHist->GetXaxis()->SetLabelOffset(0.1);
baseHist->GetXaxis()->SetTitle(XTitle[title_id]);
baseHist->GetYaxis()->SetTitle("Fake rate");
baseHist->SetMarkerStyle(20);
baseHist->SetMarkerSize(2);
baseHist->SetLineWidth(2);
overHist->SetMarkerColor(kRed);
overHist->SetMarkerStyle(25);
overHist->SetMarkerSize(2);
overHist->SetLineWidth(2);
overHist->SetLineStyle(2);
overHist->SetLineColor(kRed);
int binmax = baseHist->GetMaximumBin();
double max = 1.2*(baseHist->GetBinContent(binmax)+baseHist->GetBinError(binmax));
int binmax2 = overHist->GetMaximumBin();
double max2 = 1.2*(overHist->GetBinContent(binmax2)+overHist->GetBinError(binmax2));
max = max2 > max ? max2 : max;
baseHist->SetMaximum(10.0);
baseHist->SetMinimum(1e-3);
histPad->cd();
histPad->SetLogy();
baseHist->Draw();
overHist->Draw("same");
TLegend* leg = new TLegend(0.8,0.80,0.9,0.9,NULL,"brNDC");
leg->SetFillColor(0);
leg->SetTextSize(0.035);
leg->SetBorderSize(0);
leg->AddEntry(baseHist, leg1, "lp");
leg->AddEntry(overHist, leg2, "lp");
leg->Draw();
//~
TString lumist="";
TPaveText *ll = new TPaveText(0.15, 0.95, 0.95, 0.99, "NDC");
ll->SetTextSize(0.03);
ll->SetTextFont(62);
ll->SetFillColor(0);
ll->SetBorderSize(0);
ll->SetMargin(0.01);
ll->SetTextAlign(12); // align left
TString text = name;
ll->AddText(0.01,0.7,text);
text = "#sqrt{s} = 13 TeV";
text = text + lumist;
// ll->SetTextAlign(32); // align right
ll->AddText(0.7, 0.5, text);
ll->Draw("same");
c1->Update();
TH1D* h_diff=(TH1D*)baseHist->Clone();
h_diff->Divide(overHist);
diffPad->cd();
diffPad->SetGridy();
diffPad->SetGridx();
h_diff->GetYaxis()->SetLabelSize(0.1);
h_diff->GetYaxis()->SetTitleOffset(0.55);
h_diff->GetYaxis()->SetTitleSize(0.12);
h_diff->GetYaxis()->SetTitle("Ratio");
h_diff->GetXaxis()->SetLabelSize(0.12);
h_diff->GetXaxis()->SetLabelOffset(0.01);
h_diff->GetXaxis()->SetTitleSize(0.15);
h_diff->GetYaxis()->SetNdivisions(509);
h_diff->SetMinimum(0.9);
h_diff->SetMaximum(1.1);
h_diff->Draw("hist");
c1->Print(outdir+"/pdf/"+profileHist1[iProf12][0]->GetName()+".pdf");
c1->Print(outdir+"/png/"+profileHist1[iProf12][0]->GetName()+".png");
}
return 0;
}