本文整理汇总了C++中TPad::GetLeftMargin方法的典型用法代码示例。如果您正苦于以下问题:C++ TPad::GetLeftMargin方法的具体用法?C++ TPad::GetLeftMargin怎么用?C++ TPad::GetLeftMargin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPad
的用法示例。
在下文中一共展示了TPad::GetLeftMargin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: can
void HiggsPlot::PlotChi2(){
styles style; style.setPadsStyle(1);
style.PadLeftMargin = 0.14; style.PadBottomMargin = 0.17;
style.yTitleOffset = 0.7; style.xTitleOffset = 0.7;
style.TitleSize = 0.1; style.LabelSize = 0.1;
style.setDefaultStyle();
TCanvas can("can","Likelihood scan");
TPad *cPad = static_cast<TPad *>(can.cd(0));
TString xTitle[] = {"R(D)", "R(D*)"};
double nSig = 4.2;
int nBins = 60;
_varyRD = 0;
double RD[2], RDs[2], frac=0.018;
Compute(0,RD,1); Compute(0,RDs,2);
double Limit[2][2] = {{Measurement[1][0]-nSig*Measurement[1][1], Measurement[1][0]+nSig*Measurement[1][1]},
{Measurement[2][0]-nSig*Measurement[2][1], Measurement[2][0]+nSig*Measurement[2][1]}};
TH2F hChi2("hChi2","",nBins, Limit[0][0],Limit[0][1], nBins, Limit[1][0],Limit[1][1]);
for(int iRD=1; iRD<=nBins; iRD++){
for(int iRDs=1; iRDs<=nBins; iRDs++){
RD[0] = hChi2.GetXaxis()->GetBinCenter(iRD);
RDs[0] = hChi2.GetYaxis()->GetBinCenter(iRDs);
hChi2.SetBinContent(iRD, iRDs, ProbChi2(3, 0, RD, RDs));
//cout<<1-ProbChi2(3, 0, RD, RDs)<<endl;
}
//cout<<endl;
}
hChi2.SetXTitle(xTitle[0]); hChi2.SetYTitle(xTitle[1]);
//int colors[] = {kBlue+2, kBlue+1, kBlue-4, kBlue-7, kBlue-9, kBlue-10, 0};
int colors[] = {kBlue-3, kBlue-4, kBlue-7, kBlue-9, kBlue-10, 0};
gStyle->SetPalette(Nsigma, colors);
double zCont[Nsigma];
for(int ns=1; ns<=Nsigma; ns++) zCont[ns] = IntG(0,1,-ns,ns);//cout<<endl<<zCont[ns]<<endl;}
hChi2.SetContour(Nsigma,zCont);
hChi2.GetXaxis()->CenterTitle(true); hChi2.GetYaxis()->CenterTitle(true);
hChi2.SetLabelOffset(0.009,"xy");
hChi2.SetLabelSize(0.09,"xy");
hChi2.SetTitleOffset(1,"x");
hChi2.SetTitleOffset(0.6,"y");
hChi2.Draw("cont4");
double padL[2][2] = {{cPad->GetLeftMargin(), 1-cPad->GetRightMargin()}, // Margins are reversed for x-y!
{cPad->GetBottomMargin(), 1-cPad->GetTopMargin()}};
double SMyield[2];
Compute(0,RD,1); Compute(0,RDs,2); RD[1] = RDs[0];
TLine line; line.SetLineWidth(2); line.SetLineColor(1);
for(int chan=0; chan<2; chan++){
double range = Limit[chan][1]-Limit[chan][0];
SMyield[chan] = padL[chan][0] + (padL[chan][1]-padL[chan][0])*(RD[chan]-Limit[chan][0])/range;
}
line.DrawLineNDC(SMyield[0]-frac, SMyield[1], SMyield[0]+frac, SMyield[1]);
line.DrawLineNDC(SMyield[0], SMyield[1]-2*frac, SMyield[0], SMyield[1]+2*frac);
TLatex latex; latex.SetNDC(kTRUE); latex.SetTextAlign(33); latex.SetTextSize(style.TitleSize);
latex.DrawLatex(SMyield[0]-frac,SMyield[1]-frac,"SM");
line.SetLineColor(0);
for(int chan=0; chan<2; chan++){
double range = Limit[chan][1]-Limit[chan][0];
SMyield[chan] = padL[chan][0] + (padL[chan][1]-padL[chan][0])*(Measurement[1+chan][0]-Limit[chan][0])/range;
}
line.DrawLineNDC(SMyield[0]-frac, SMyield[1], SMyield[0]+frac, SMyield[1]);
line.DrawLineNDC(SMyield[0], SMyield[1]-2*frac, SMyield[0], SMyield[1]+2*frac);
TH1F *histo[Nsigma];
double legW = 0.08, legH = 0.07*Nsigma;
double legX = 1-style.PadRightMargin-0.02, legY = 1-style.PadTopMargin-0.02;
TLegend *leg = new TLegend(legX-legW, legY-legH, legX, legY);
leg->SetTextSize(0.08); leg->SetFillColor(0); leg->SetTextFont(style.nFont);
for(int ileg=0; ileg<Nsigma-1; ileg++) {
TString label = "histo"; label += ileg+1;
histo[ileg] = new TH1F(label,"histo",10,0,10);
histo[ileg]->SetLineColor(colors[ileg]);histo[ileg]->SetFillColor(colors[ileg]);
label = " "; label += ileg+1; label += "#sigma";
leg->AddEntry(histo[ileg],label);
}
leg->Draw();
TString pName = "public_html/Higgs_Chi2.eps";
can.SaveAs(pName);
for(int ileg=0; ileg<Nsigma-1; ileg++) histo[ileg]->Delete();
}
示例2: variables
//.........这里部分代码省略.........
// sig->SetTitle( tit.ReplaceAll("Input variable", "Regression target" ) );
// }
// }
sig->SetTitle( "" );
// finally plot and overlay
Float_t sc = 1.1;
if (countPad == 1) sc = 1.3;
sig->SetMaximum( TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*sc );
sig->Draw( "hist" );
cPad->SetLeftMargin( 0.17 );
sig->GetYaxis()->SetTitleOffset( 1.50 );
if (!isRegression) {
bgd->Draw("histsame");
TString ytit = TString("(1/N) ") + sig->GetYaxis()->GetTitle();
ytit = TString("Fraction of Events");
sig->GetYaxis()->SetTitle( ytit ); // histograms are normalised
}
if (countPad == 1) sig->GetXaxis()->SetTitle("Leading Lepton p_{T} [GeV/c]");
if (countPad == 2) sig->GetXaxis()->SetTitle("Trailing Lepton p_{T} [GeV/c]");
if (countPad == 3) sig->GetXaxis()->SetTitle("#Delta#phi(l,l)");
if (countPad == 4) sig->GetXaxis()->SetTitle("#Delta R(l,l)");
if (countPad == 5) sig->GetXaxis()->SetTitle("Dilepton Mass [GeV/c^{2}]");
if (countPad == 6) sig->GetXaxis()->SetTitle("Dilepton Flavor Final State");
if (countPad == 7) sig->GetXaxis()->SetTitle("M_{T} (Higgs) [GeV/c^{2}]");
if (countPad == 8) sig->GetXaxis()->SetTitle("#Delta#phi(Dilepton System, MET)");
if (countPad == 9) sig->GetXaxis()->SetTitle("#Delta#phi(Dilepton System, Jet)");
// Draw legend
// if (countPad == 1 && !isRegression) {
TLegend *legend= new TLegend( cPad->GetLeftMargin(),
1-cPad->GetTopMargin()-.15,
cPad->GetLeftMargin()+.4,
1-cPad->GetTopMargin() );
if(countPad == 1 || countPad == 2 ||countPad == 3 ||countPad == 4 ||countPad == 5 ||countPad == 7 ) {
legend= new TLegend( 0.50,
1-cPad->GetTopMargin()-.15,
0.90,
1-cPad->GetTopMargin() );
}
legend->SetFillStyle(0);
legend->AddEntry(sig,"Signal","F");
legend->AddEntry(bgd,"Background","F");
legend->SetBorderSize(0);
legend->SetMargin( 0.3 );
legend->SetTextSize( 0.03 );
legend->Draw("same");
// }
// redraw axes
sig->Draw("sameaxis");
// text for overflows
Int_t nbin = sig->GetNbinsX();
Double_t dxu = sig->GetBinWidth(0);
Double_t dxo = sig->GetBinWidth(nbin+1);
TString uoflow = "";
if (isRegression) {
uoflow = Form( "U/O-flow: %.1f%% / %.1f%%",
sig->GetBinContent(0)*dxu*100, sig->GetBinContent(nbin+1)*dxo*100 );
}
else {
uoflow = Form( "U/O-flow (S,B): (%.1f, %.1f)%% / (%.1f, %.1f)%%",
sig->GetBinContent(0)*dxu*100, bgd->GetBinContent(0)*dxu*100,
sig->GetBinContent(nbin+1)*dxo*100, bgd->GetBinContent(nbin+1)*dxo*100 );
}
TText* t = new TText( 0.98, 0.14, uoflow );
t->SetNDC();
t->SetTextSize( 0.040 );
t->SetTextAngle( 90 );
// t->AppendPad();
// save canvas to file
if (countPad%noPadPerCanv==0) {
TString fname = Form( "plots/%s_c%i", outfname.Data(), countCanvas );
TMVAGlob::plot_logo();
TMVAGlob::imgconv( canv, fname );
createNewFig = kFALSE;
}
else {
createNewFig = kTRUE;
}
}
if (createNewFig) {
TString fname = Form( "plots/%s_c%i", outfname.Data(), countCanvas );
TMVAGlob::plot_logo();
TMVAGlob::imgconv( canv, fname );
createNewFig = kFALSE;
}
return;
}
示例3: likelihoodrefs
void likelihoodrefs( TDirectory *lhdir ) {
Bool_t newCanvas = kTRUE;
const UInt_t maxCanvas = 200;
TCanvas** c = new TCanvas*[maxCanvas];
Int_t width = 670;
Int_t height = 380;
// avoid duplicated printing
std::vector<std::string> hasBeenUsed;
const TString titName = lhdir->GetName();
UInt_t ic = -1;
TIter next(lhdir->GetListOfKeys());
TKey *key;
while ((key = TMVAGlob::NextKey(next,"TH1"))) { // loop over all TH1
TH1 *h = (TH1*)key->ReadObj();
TH1F *b( 0 );
TString hname( h->GetName() );
// avoid duplicated plotting
Bool_t found = kFALSE;
for (UInt_t j = 0; j < hasBeenUsed.size(); j++) {
if (hasBeenUsed[j] == hname.Data()) found = kTRUE;
}
if (!found) {
// draw original plots
if (hname.EndsWith("_sig_nice")) {
if (newCanvas) {
char cn[20];
sprintf( cn, "cv%d_%s", ic+1, titName.Data() );
++ic;
TString n = hname;
c[ic] = new TCanvas( cn, Form( "%s reference for variable: %s",
titName.Data(),(n.ReplaceAll("_sig","")).Data() ),
ic*50+50, ic*20, width, height );
c[ic]->Divide(2,1);
newCanvas = kFALSE;
}
// signal
Int_t color = 4;
TPad * cPad = (TPad*)c[ic]->cd(1);
TString plotname = hname;
h->SetMaximum(h->GetMaximum()*1.3);
h->SetMinimum( 0 );
h->SetMarkerColor(color);
h->SetMarkerSize( 0.7 );
h->SetMarkerStyle( 24 );
h->SetLineWidth(1);
h->SetLineColor(color);
color++;
h->Draw("e1");
Double_t hSscale = 1.0/(h->GetSumOfWeights()*h->GetBinWidth(1));
TLegend *legS= new TLegend( cPad->GetLeftMargin(),
1-cPad->GetTopMargin()-.14,
cPad->GetLeftMargin()+.77,
1-cPad->GetTopMargin() );
legS->SetBorderSize(1);
legS->AddEntry(h,"Input data (signal)","p");
// background
TString bname( hname );
b = (TH1F*)lhdir->Get( bname.ReplaceAll("_sig","_bgd") );
cPad = (TPad*)c[ic]->cd(2);
color = 2;
b->SetMaximum(b->GetMaximum()*1.3);
b->SetMinimum( 0 );
b->SetLineWidth(1);
b->SetLineColor(color);
b->SetMarkerColor(color);
b->SetMarkerSize( 0.7 );
b->SetMarkerStyle( 24 );
b->Draw("e1");
Double_t hBscale = 1.0/(b->GetSumOfWeights()*b->GetBinWidth(1));
TLegend *legB= new TLegend( cPad->GetLeftMargin(),
1-cPad->GetTopMargin()-.14,
cPad->GetLeftMargin()+.77,
1-cPad->GetTopMargin() );
legB->SetBorderSize(1);
legB->AddEntry(b,"Input data (backgr.)","p");
// register
hasBeenUsed.push_back( bname.Data() );
// the PDFs --------------
// check for splines
h = 0;
b = 0;
TString pname = hname; pname.ReplaceAll("_nice","");
for (int i=0; i<= 5; i++) {
TString hspline = pname + Form( "_smoothed_hist_from_spline%i", i );
h = (TH1F*)lhdir->Get( hspline );
if (h) {
b = (TH1F*)lhdir->Get( hspline.ReplaceAll("_sig","_bgd") );
//.........这里部分代码省略.........
示例4: rulevisHists
//.........这里部分代码省略.........
TPad *cPad = (TPad *)(c[countCanvas]->GetPad(countPad));
c[countCanvas]->cd(countPad);
countPad++;
// find the corredponding background histo
TString bgname = hname;
bgname.ReplaceAll("__S","__B");
hkey = vardir->GetKey(bgname);
bgd = (TH1F*)hkey->ReadObj();
if (bgd == NULL) {
cout << "ERROR!!! couldn't find backgroung histo for" << hname << endl;
exit;
}
TString rfname = hname;
rfname.ReplaceAll("__S","__RF");
TKey *hrfkey = rfdir->GetKey(rfname);
TH2F *hrf = (TH2F*)hrfkey->ReadObj();
Double_t wv = hrf->GetMaximum();
// if (rfmax>0.0)
// hrf->Scale(1.0/rfmax);
hrf->SetMinimum(rfmin); // make sure it's zero -> for palette axis
hrf->SetMaximum(rfmax); // make sure max is 1.0 -> idem
hrf->SetContour(nContours,&contourLevels[0]);
// this is set but not stored during plot creation in MVA_Factory
// TMVAGlob::SetSignalAndBackgroundStyle( sigK, bgd );
sig->SetFillStyle(3002);
sig->SetFillColor(1);
sig->SetLineColor(1);
sig->SetLineWidth(2);
bgd->SetFillStyle(3554);
bgd->SetFillColor(1);
bgd->SetLineColor(1);
bgd->SetLineWidth(2);
// chop off "signal"
TString title(hrf->GetTitle());
title.ReplaceAll("signal","");
// finally plot and overlay
Float_t sc = 1.1;
if (countPad==2) sc = 1.3;
sig->SetMaximum( TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*sc );
Double_t smax = sig->GetMaximum();
if (first) {
hrf->SetTitle( maintitle );
first = kFALSE;
} else {
hrf->SetTitle( "" );
}
hrf->Draw("colz ah");
TMVAGlob::SetFrameStyle( hrf, 1.2 );
sig->Draw("same ah");
bgd->Draw("same ah");
// draw axis using range [0,smax]
hrf->GetXaxis()->SetTitle( title );
hrf->GetYaxis()->SetTitleOffset( 1.30 );
hrf->GetYaxis()->SetTitle("Events");
hrf->GetYaxis()->SetLimits(0,smax);
hrf->Draw("same axis");
cPad->SetRightMargin(0.13);
cPad->Update();
// Draw legend
if (countPad==2){
TLegend *legend= new TLegend( cPad->GetLeftMargin(),
1-cPad->GetTopMargin()-.18,
cPad->GetLeftMargin()+.4,
1-cPad->GetTopMargin() );
legend->AddEntry(sig,"Signal","F");
legend->AddEntry(bgd,"Background","F");
legend->Draw("same");
legend->SetBorderSize(1);
legend->SetMargin( 0.3 );
legend->SetFillColor(19);
legend->SetFillStyle(1);
}
// save canvas to file
if (countPad > noPad) {
c[countCanvas]->Update();
TString fname = Form( "plots/%s_c%i", outputName.Data(), countCanvas+1 );
TMVAGlob::imgconv( c[countCanvas], fname );
// TMVAGlob::plot_logo(); // don't understand why this doesn't work ... :-(
countCanvas++;
}
}
}
if (countPad <= noPad) {
c[countCanvas]->Update();
TString fname = Form( "plots/%s_c%i", outputName.Data(), countCanvas+1 );
TMVAGlob::imgconv( c[countCanvas], fname );
}
}
示例5: boostcontrolplots
void boostcontrolplots( TDirectory *boostdir ) {
const Int_t nPlots = 4;
Int_t width = 900;
Int_t height = 900;
char cn[100];
const TString titName = boostdir->GetName();
sprintf( cn, "cv_%s", titName.Data() );
TCanvas *c = new TCanvas( cn, Form( "%s Control Plots", titName.Data() ),
width, height );
c->Divide(2,3);
const TString titName = boostdir->GetName();
TString hname[nPlots]={"Booster_BoostWeight","Booster_MethodWeight","Booster_ErrFraction","Booster_OrigErrFraction"};
for (Int_t i=0; i<nPlots; i++){
Int_t color = 4;
TPad * cPad = (TPad*)c->cd(i+1);
TH1 *h = (TH1*) boostdir->Get(hname[i]);
TString plotname = h->GetName();
h->SetMaximum(h->GetMaximum()*1.3);
h->SetMinimum( 0 );
h->SetMarkerColor(color);
h->SetMarkerSize( 0.7 );
h->SetMarkerStyle( 24 );
h->SetLineWidth(2);
h->SetLineColor(color);
h->Draw();
c->Update();
}
// draw combined ROC plots
TString hname_roctest[2] ={"Booster_ROCIntegral_test", "Booster_ROCIntegralBoosted_test"};
TString hname_roctrain[2]={"Booster_ROCIntegral_train", "Booster_ROCIntegralBoosted_train"};
TString htitle[2] = {"ROC integral of single classifier", "ROC integral of boosted method"}
for (Int_t i=0; i<2; i++){
Int_t color = 4;
TPad * cPad = (TPad*)c->cd(nPlots+i+1);
TH1 *htest = (TH1*) boostdir->Get(hname_roctest[i]);
TH1 *htrain = (TH1*) boostdir->Get(hname_roctrain[i]);
// check if filled
Bool_t histFilled = (htest->GetMaximum() > 0 || htrain->GetMaximum() > 0);
htest->SetTitle(htitle[i]);
htest->SetMaximum(1.0);
htest->SetMinimum(0.0);
htest->SetMarkerColor(color);
htest->SetMarkerSize( 0.7 );
htest->SetMarkerStyle( 24 );
htest->SetLineWidth(2);
htest->SetLineColor(color);
htest->Draw();
htrain->SetMaximum(1.0);
htrain->SetMinimum(0.0);
htrain->SetMarkerColor(color-2);
htrain->SetMarkerSize( 0.7 );
htrain->SetMarkerStyle( 24 );
htrain->SetLineWidth(2);
htrain->SetLineColor(color-2);
htrain->Draw("same");
if (histFilled) {
TLegend *legend= new TLegend( cPad->GetLeftMargin(),
0.2 + cPad->GetBottomMargin(),
cPad->GetLeftMargin() + 0.6,
cPad->GetBottomMargin() );
legend->AddEntry(htest, TString("testing sample"), "L");
legend->AddEntry(htrain, TString("training sample (orig. weights)"), "L");
legend->SetFillStyle( 1 );
legend->SetBorderSize(1);
legend->SetMargin( 0.3 );
legend->Draw("same");
}
else {
TText* t = new TText();
t->SetTextSize( 0.056 );
t->SetTextColor( 2 );
t->DrawText( 1, 0.6, "Use MethodBoost option: \"DetailedMonitoring\" " );
t->DrawText( 1, 0.51, "to fill this histograms" );
}
c->Update();
}
// write to file
TString fname = Form( "plots/%s_ControlPlots", titName.Data() );
TMVAGlob::imgconv( c, fname );
}