本文整理汇总了C++中TVirtualPad::SetLeftMargin方法的典型用法代码示例。如果您正苦于以下问题:C++ TVirtualPad::SetLeftMargin方法的具体用法?C++ TVirtualPad::SetLeftMargin怎么用?C++ TVirtualPad::SetLeftMargin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TVirtualPad
的用法示例。
在下文中一共展示了TVirtualPad::SetLeftMargin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_R2m
void draw_R2m(void)
{
const double er[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
double ccnt[9];
double eccnt[9];
double dcnt[9];
TGraphErrors *gr;
TGraphErrors *grd;
TH1D *hst;
TH1D *hstd;
double effUp, effDown, C, shift, size;
double eeffUp, eeffDown, eC, eshift, esize;
double fmin, fedm, errdef;
int npari, nparx;
int i, irc;
char str[1024];
TF1 *fR2;
TVirtualPad *pd;
gStyle->SetOptStat(0);
gStyle->SetOptFit(0);
MyMinuit = new TMinuit(5);
MyMinuit->SetFCN(chi2fun);
MyMinuit->DefineParameter(0, "Const", 1000, 10, 0, 1E10);
MyMinuit->DefineParameter(1, "EffUp", 1, 0.1, 0.5, 1.5);
MyMinuit->DefineParameter(2, "EffDown", 1, 0.1, 0.5, 1.5);
MyMinuit->DefineParameter(3, "Shift", 0, 0.1, -10, 10);
MyMinuit->DefineParameter(4, "Size", 3, 1, 0, 10);
MyMinuit->FixParameter(3);
MyMinuit->FixParameter(4);
MyMinuit->Migrad();
MyMinuit->GetParameter(0, C, eC);
MyMinuit->GetParameter(1, effUp, eeffUp);
MyMinuit->GetParameter(2, effDown, eeffDown);
MyMinuit->GetParameter(3, shift, eshift);
MyMinuit->GetParameter(4, size, esize);
MyMinuit->mnstat(fmin, fedm, errdef, npari, nparx, irc);
// Renorm top and bottom sections to the middle
for (i=0; i<3; i++) {
ccnt[i] = DataArray.cnt[i] / effUp;
ccnt[i+3] = DataArray.cnt[i+3];
ccnt[i+6] = DataArray.cnt[i+6] / effDown;
eccnt[i] = DataArray.ecnt[i] / effUp;
eccnt[i+3] = DataArray.ecnt[i+3];
eccnt[i+6] = DataArray.ecnt[i+6] / effDown;
}
// for (i=0; i<9; i++) printf("L = %8.3f CNT = %6.1f +- %4.1f\n", r[i], cnt[i], ecnt[i]);
gr = new TGraphErrors(9, DataArray.r, ccnt, er, eccnt);
gr->SetLineColor(kBlue);
gr->SetLineWidth(4);
gr->SetMarkerStyle(20);
gr->SetMarkerColor(kBlue);
gr->SetMarkerSize(2);
fR2 = new TF1("fR2", "[0] / ((x - [1]) * (x - [1]) - [2] * [2] / 4.0)", 1, 100);
fR2->SetParameter(0, C);
fR2->SetParameter(1, shift);
fR2->SetParameter(2, size);
fR2->SetLineColor(kRed);
fR2->SetLineWidth(3);
hst = new TH1D("H", ";Distance to reactor core center, m;Events per day", 35, 10, 13.5);
hst->SetMinimum(DataArray.cnt[4] * 0.5);
hst->SetMaximum(DataArray.cnt[4] * 1.5);
hst->GetXaxis()->SetLabelSize(0.06);
hst->GetYaxis()->SetLabelSize(0.06);
hst->GetXaxis()->SetTitleSize(0.06);
hst->GetYaxis()->SetTitleSize(0.06);
hst->GetYaxis()->SetTitleOffset(1.25);
hstd = new TH1D("H", ";Distance to reactor core center, m;Events per day", 35, 10, 13.5);
hstd->SetMinimum(-40);
hstd->SetMaximum(40);
hstd->GetXaxis()->SetLabelSize(0.06);
hstd->GetYaxis()->SetLabelSize(0.06);
hstd->GetXaxis()->SetTitleSize(0.06);
hstd->GetYaxis()->SetTitleSize(0.06);
hstd->GetYaxis()->SetTitleOffset(1.25);
TCanvas *cv = new TCanvas("CV", "R2", 800, 1200);
cv->Divide(1, 2);
// Do common fit and draw
pd = cv->cd(1);
pd->SetLeftMargin(0.15);
pd->SetBottomMargin(0.15);
pd->SetTopMargin(0.03);
hst->Draw();
gr->Draw("p");
fR2->Draw("same");
TLatex txt;
txt.SetTextSize(0.07);
sprintf(str, "#chi^{2}/n.d.f. = %6.2f/5", fmin);
txt.DrawLatex(11.3, DataArray.cnt[4] * 1.3, str);
// Draw difference
for (i=0; i<9; i++) dcnt[i] = ccnt[i] - fR2->Eval(DataArray.r[i]);
grd = new TGraphErrors(9, DataArray.r, dcnt, er, eccnt);
grd->SetLineColor(kBlue);
grd->SetLineWidth(4);
//.........这里部分代码省略.........
示例2: plotParEvolution
///
/// Plot the evolution of best fit nuisance paramters
/// along the 1-CL curve.
///
/// By changing the code at the beginning of the function
/// one can chose whether all scan results are plotted, or
/// only those comprising the 1-CL curve.
///
void ParameterEvolutionPlotter::plotParEvolution()
{
vector<RooSlimFitResult*> results = allResults;
// vector<RooSlimFitResult*> results = curveResults;
cout << "ParameterEvolutionPlotter::plotParEvolution() : plotting ..." << endl;
selectNewCanvas(title+" 1");
// get all parameters, loop over them
TIterator* it = w->set(parsName)->createIterator();
while ( RooRealVar* p = (RooRealVar*)it->Next() )
{
if ( p->isConstant() && p->GetName()!=scanVar1 ) continue;
if ( arg->debug ) cout << "ParameterEvolutionPlotter::plotParEvolution() : var = " << p->GetName() << endl;
TVirtualPad *pad = selectNewPad();
pad->SetLeftMargin(0.25);
pad->SetTopMargin(0.10);
// create a graph of the nominal evolution of one parameter
TGraph *g = makeEvolutionGraph(curveResults, p->GetName());
g->SetTitle(p->GetTitle());
g->GetXaxis()->SetTitle(scanVar1);
g->GetXaxis()->SetTitleSize(0.08);
g->GetXaxis()->SetLabelSize(0.06);
g->GetXaxis()->SetNdivisions(-406);
g->GetYaxis()->SetTitleSize(0.08);
g->GetYaxis()->SetLabelSize(0.06);
g->GetYaxis()->SetTitleOffset(1.4);
g->GetYaxis()->SetTitle(p->GetName());
g->SetLineColor(kBlue);
g->SetLineWidth(2);
TGaxis::SetMaxDigits(3); // forces scienfific notation
g->Draw("al");
// add error bands
TGraphErrors *g2 = makeEvolutionGraphErrors(curveResults, p->GetName());
g2->SetFillColorAlpha(kBlue,0.15);
g2->Draw("3");
// create a graph of the full evolution of one parameter
if ( arg->isQuickhack(16) ){
TGraph *g3 = makeEvolutionGraph(allResults, p->GetName());
g3->Draw("p");
}
updateCurrentCanvas();
// plot a red line at minimum
drawLinesAtMinima(pad);
}
// plot the chi2 to the last pad
TVirtualPad *pad = selectNewPad();
pad->SetLeftMargin(0.25);
TGraph *g = makeChi2Graph(curveResults);
g->SetLineWidth(2);
g->SetTitle("chi2");
g->GetXaxis()->SetTitle(scanVar1);
g->GetXaxis()->SetTitleSize(0.08);
g->GetXaxis()->SetLabelSize(0.06);
g->GetXaxis()->SetNdivisions(-406);
g->GetYaxis()->SetTitleSize(0.08);
g->GetYaxis()->SetLabelSize(0.06);
g->GetYaxis()->SetTitleOffset(1.4);
g->GetYaxis()->SetTitle("#chi^{2}");
g->Draw("al");
drawLinesAtMinima(pad);
updateCurrentCanvas();
// save plots
saveEvolutionPlots();
}
示例3: Error
/**
* Draw the Poisson estimate of the occupancy
*
* @param filename Input file name
* @param folder Input folder name in file
*
* @deprecated Use QATrender instead
* @ingroup pwglf_forward_scripts_qa
*/
void
DrawOccupancy(const char* filename="forward.root",
const char* folder="ForwardResults")
{
gStyle->SetPalette(1);
gStyle->SetOptFit(0);
gStyle->SetOptStat(0);
gStyle->SetOptTitle(0);
gStyle->SetTitleW(.4);
gStyle->SetTitleH(.1);
gStyle->SetTitleX(.4);
// gStyle->SetTitleY(.1);
gStyle->SetTitleColor(0);
gStyle->SetTitleStyle(0);
gStyle->SetTitleBorderSize(0);
TFile* file = TFile::Open(filename, "READ");
if (!file) {
Error("DrawOccupancy", "failed to open %s", filename);
return;
}
TList* forward = static_cast<TList*>(file->Get(folder));
if (!forward) {
Error("DrawOccupancy", "List %s not found in %s", folder, filename);
return;
}
TList* dc = static_cast<TList*>(forward->FindObject("fmdDensityCalculator"));
if (!dc) {
Error("DrawOccupancy", "List fmdDensityCalculator not found in Forward");
return;
}
TCanvas* c = new TCanvas("occupancy",
"Mean Occupancy", 900, 700);
c->SetFillColor(0);
c->SetBorderSize(0);
c->SetBorderMode(0);
c->SetHighLightColor(0);
c->SetBottomMargin(.15);
c->SetTopMargin(.02);
c->SetRightMargin(.02);
c->SetLeftMargin(.15);
c->Divide(3, 2, 0, 0);
Double_t corrs[5];
c->cd(1); corrs[0] = DrawRingOccupancy(dc, 1, 'I');
c->cd(2); corrs[1] = DrawRingOccupancy(dc, 2, 'I');
c->cd(5); corrs[2] = DrawRingOccupancy(dc, 2, 'O');
c->cd(3); corrs[3] = DrawRingOccupancy(dc, 3, 'I');
c->cd(6); corrs[4] = DrawRingOccupancy(dc, 3, 'O');
TVirtualPad* p = c->cd(4);
p->SetTopMargin(0.05);
p->SetRightMargin(0.10);
p->SetLeftMargin(0.15);
p->SetBottomMargin(0.15);
p->SetFillColor(0);
TH1D* hc = new TH1D("occ", "Mean occupancy", 5, .5, 5.5);
hc->SetFillColor(kRed+1);
hc->SetFillStyle(3001);
hc->SetMinimum(0.0);
hc->GetXaxis()->SetBinLabel(1,"FMD1i"); hc->SetBinContent(1,corrs[0]);
hc->GetXaxis()->SetBinLabel(2,"FMD2i"); hc->SetBinContent(2,corrs[1]);
hc->GetXaxis()->SetBinLabel(3,"FMD2o"); hc->SetBinContent(3,corrs[2]);
hc->GetXaxis()->SetBinLabel(4,"FMD3i"); hc->SetBinContent(4,corrs[3]);
hc->GetXaxis()->SetBinLabel(5,"FMD3o"); hc->SetBinContent(5,corrs[4]);
hc->GetXaxis()->SetLabelSize(0.08);
hc->GetYaxis()->SetTitle("#bar{occupancy}");
hc->SetMarkerSize(1.5);
hc->Draw("text hist");
hc->SetMaximum(hc->GetMaximum()*1.5);
// TH2D* highCuts = static_cast<TH2D*>(dc->FindObject("highCuts"));
// if (highCuts) highCuts->Draw("colz");
c->cd();
c->SaveAs("occupancy.png");
}
示例4: DrawTwoInPad
void DrawTwoInPad(TVirtualPad* p,
Int_t sub,
TH1* h1,
TH1* h2,
Bool_t ratio,
Bool_t logy=false,
Bool_t legend=false)
{
TVirtualPad* pp = p->cd(sub);
pp->SetRightMargin(0.02);
pp->SetLeftMargin(0.10);
TVirtualPad* ppp = pp;
if (ratio) {
pp->Divide(1,2,0,0);
ppp = pp->cd(1);
ppp->SetRightMargin(0.02);
}
if (logy) ppp->SetLogy();
TH1* hs[] = { h1, h2, 0 };
if (h1->GetMaximum() < h2->GetMaximum()) {
hs[0] = h2;
hs[1] = h1;
}
TH1** ph = hs;
Double_t size = (ratio ? 0.1 : 0.05);
Double_t off = (ratio ? 0.6 : 0.5);
h1->SetFillStyle(3004);
h2->SetFillStyle(3005);
while (*ph) {
TString opt("hist");
if (ph != hs) opt.Append(" same");
TH1* copy = (*ph)->DrawCopy(opt);
copy->GetXaxis()->SetLabelSize(2*size);
copy->GetYaxis()->SetLabelSize(size);
copy->GetYaxis()->SetTitleSize(size);
copy->GetYaxis()->SetTitleOffset(off);
copy->SetYTitle(copy->GetTitle());
copy->SetTitle("");
copy->SetDirectory(0);
ph++;
}
TString s1 = h1->GetYaxis()->GetTitle();
TString s2 = h2->GetYaxis()->GetTitle();
if (legend) {
TLegend* l = new TLegend(0.6, 0.1, 0.9, 0.9);
l->SetBorderSize(0);
TLegendEntry* e = l->AddEntry("dummy", s1, "lf");
l->SetFillColor(kWhite);
e->SetFillColor(kBlack);
e->SetFillStyle(h1->GetFillStyle());
e = l->AddEntry("dummy", s2, "lf");
e->SetFillColor(kBlack);
e->SetFillStyle(h2->GetFillStyle());
l->Draw();
}
if (!ratio) return;
ppp = pp->cd(2);
ppp->SetRightMargin(0.02);
TH1* r = static_cast<TH1*>(h1->Clone(Form("ratio%s", h1->GetName())));
r->SetDirectory(0);
r->SetTitle("");
r->GetXaxis()->SetLabelSize(size);
r->GetYaxis()->SetLabelSize(size);
r->GetYaxis()->SetTitleSize(0.9*size);
r->GetYaxis()->SetTitleOffset(0.9*off);
r->SetMarkerStyle(20);
r->SetMarkerColor(h1->GetFillColor()+1);
r->SetFillStyle(3007);
r->SetYTitle(Form("#frac{%s}{%s}", s1.Data(), s2.Data()));
// r->Add(h2, -1);
// r->Divide(h1);
if (!r->IsA()->InheritsFrom(TProfile::Class())) {
r->GetSumw2()->Set(0); // r->Sumw2(false);
h2->GetSumw2()->Set(0); // h2->Sumw2(false);
}
r->Divide(h2);
Printf("%s", r->GetName());
for (UShort_t bin = 1; bin <= r->GetNbinsX(); bin++) {
Printf(" bin # %2d: Diff=%g+/-%g", bin, r->GetBinContent(bin),
r->GetBinError(bin));
r->SetBinError(bin, 0);
}
r->GetSumw2()->Set(0); //r->Sumw2(false);
r->SetMarkerSize(4);
r->SetMaximum(r->GetMaximum()*1.2);
r->SetMinimum(r->GetMinimum()*0.8);
r->Draw("hist text30");
p->Modified();
p->Update();
p->cd();
}