本文整理汇总了C++中TCanvas::GetTopMargin方法的典型用法代码示例。如果您正苦于以下问题:C++ TCanvas::GetTopMargin方法的具体用法?C++ TCanvas::GetTopMargin怎么用?C++ TCanvas::GetTopMargin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCanvas
的用法示例。
在下文中一共展示了TCanvas::GetTopMargin方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
//____________________________________________________________________
void Run(const char* newName, const char* oldName,
const char* newTitle="New", const char* oldTitle="Old")
{
TFile* newFile = TFile::Open(newName,"READ");
TFile* oldFile = TFile::Open(oldName,"READ");
if (!newFile || !oldFile) return;
TH1* newCent = GetH1(newFile, "realCent");
TH1* oldCent = GetH1(oldFile, "realCent");
if (!newCent || !oldCent) return;
TString t; t.Form("#it{R}=#frac{%s}{%s}", newTitle, oldTitle);
TCanvas* c = new TCanvas("c", t, 1200, 800);
c->SetTopMargin(0.01);
c->SetRightMargin(0.20);
fLegend = new TLegend(1-c->GetRightMargin(),
c->GetBottomMargin(),
1, 1-c->GetTopMargin(),
t);
fLegend->SetFillStyle(0);
fLegend->SetBorderSize(0);
THStack* stack = new THStack("ratios","");
fMin = +1e6;
fMax = -1e6;
TH1* one = 0;
for (Int_t i = newCent->GetNbinsX(); i--;) {
Double_t c1 = newCent->GetXaxis()->GetBinLowEdge(i+1);
Double_t c2 = newCent->GetXaxis()->GetBinUpEdge(i+1);
Info("", "c1=%f c2=%f", c1, c2);
TH1* r = One(newFile, oldFile, c1, c2);
if (!r) continue;
if (!one) {
one = static_cast<TH1*>(r->Clone("one"));
one->SetDirectory(0);
one->Reset();
for (Int_t j = 1; j <= one->GetNbinsX(); j++) {
one->SetBinContent(j,1);
one->SetBinError (j,0);
}
}
// r->Add(one, i-1);
// r->Scale(TMath::Power(10,i));
stack->Add(r);
}
stack->Draw("nostack");
stack->SetMinimum(0.95*fMin);
stack->SetMaximum(1.05*fMax);
stack->GetHistogram()->SetXTitle("#eta");
stack->GetHistogram()->SetYTitle("#it{R}");
fLegend->Draw();
c->Modified();
c->Update();
c->cd();
c->SaveAs(Form("%sover%s.png", newTitle, oldTitle));
}
示例2: annconvergencetest
void annconvergencetest( TDirectory *lhdir )
{
TCanvas* c = new TCanvas( "MLPConvergenceTest", "MLP Convergence Test", 150, 0, 600, 580*0.8 );
TH1* estimatorHistTrain = (TH1*)lhdir->Get( "estimatorHistTrain" );
TH1* estimatorHistTest = (TH1*)lhdir->Get( "estimatorHistTest" );
Double_t m1 = estimatorHistTrain->GetMaximum();
Double_t m2 = estimatorHistTest ->GetMaximum();
Double_t max = TMath::Max( m1, m2 );
m1 = estimatorHistTrain->GetMinimum();
m2 = estimatorHistTest ->GetMinimum();
Double_t min = TMath::Min( m1, m2 );
estimatorHistTrain->SetMaximum( max + 0.1*(max - min) );
estimatorHistTrain->SetMinimum( min - 0.1*(max - min) );
estimatorHistTrain->SetLineColor( 2 );
estimatorHistTrain->SetLineWidth( 2 );
estimatorHistTrain->SetTitle( TString("MLP Convergence Test") );
estimatorHistTest->SetLineColor( 4 );
estimatorHistTest->SetLineWidth( 2 );
estimatorHistTrain->GetXaxis()->SetTitle( "Epochs" );
estimatorHistTrain->GetYaxis()->SetTitle( "Estimator" );
estimatorHistTrain->GetXaxis()->SetTitleOffset( 1.20 );
estimatorHistTrain->GetYaxis()->SetTitleOffset( 1.65 );
estimatorHistTrain->Draw();
estimatorHistTest ->Draw("same");
// need a legend
TLegend *legend= new TLegend( 1 - c->GetRightMargin() - 0.45, 1-c->GetTopMargin() - 0.20,
1 - c->GetRightMargin() - 0.05, 1-c->GetTopMargin() - 0.05 );
legend->AddEntry(estimatorHistTrain,"Training Sample","l");
legend->AddEntry(estimatorHistTest,"Test sample","l");
legend->Draw("same");
legend->SetMargin( 0.3 );
c->cd();
TMVAGlob::plot_logo(); // don't understand why this doesn't work ... :-(
c->Update();
TString fname = "plots/annconvergencetest";
TMVAGlob::imgconv( c, fname );
}
示例3: makeNiceCanvasByPixMargins
TCanvas* makeNiceCanvasByPixMargins(Int_t pixelPerBinX, Int_t pixelPerBinY, Int_t nbinx, Int_t nbiny, Int_t top, Int_t bottom, Int_t left, Int_t right) {
Int_t rubaX = 4; //determinato sperimentalmente
Int_t rubaY = 28; //determinato sperimentalmente
TString name = generateRandomName();
Int_t plotBaseDimX = pixelPerBinX*nbinx;
Int_t plotBaseDimY = pixelPerBinY*nbiny;
Int_t XX = (Int_t)(plotBaseDimX+left+right);
Int_t YY = (Int_t)(plotBaseDimY+top+bottom);
TCanvas* can = new TCanvas(name,name,XX+rubaX,YY+rubaY);
can->SetTopMargin((1.*top)/(1.*YY));
can->SetBottomMargin((1.*bottom)/(1.*YY));
can->SetRightMargin(right/(1.*XX));
can->SetLeftMargin(left/(1.*XX));
can->SetBorderMode(0);
std::cout << "Nice canvas " << XX << " * " << YY << " Margin: t " << can->GetTopMargin() << " b " << can->GetBottomMargin() << " l " << can->GetLeftMargin() << " r " << can->GetRightMargin() << std::endl;
return can;
}
示例4: next
/**
* Extract ALICE PbPb @ 5.02TeV over |eta|<2
*
* @param filename Input file name
* @param outname Output file name
* @param reweigh Whether it is reweighed
*/
void
Extract(const char* filename="dndneta.pbpb502.20151124.root",
const char* outname="TRACKLETS_5023_PbPb.input",
Bool_t reweigh=false)
{
if (filename == 0) return;
TFile* file = TFile::Open(filename, "READ");
TObjArray* arr = static_cast<TObjArray*>(file->Get("TObjArray"));
// Now count number of bins
Int_t nBins = 0;
TIter next(arr);
TObject* obj = 0;
while ((obj = next())) {
if (TString(obj->GetName()).Contains("DataCorrSignal"))
nBins++;
}
Info("ExtractdNdeta", "Defining %d centrality bins", nBins);
TArrayD c(nBins+1);
if (nBins == 5) {
c[0] = 0; c[1] = 10; c[2] = 20; c[3] = 40; c[4] = 60; c[5] = 80;
}
else if (nBins >= 9) {
c[0] = 0; c[1] = 5; c[2] = 10; c[3] = 20; c[4] = 30; c[5] = 40;
c[6] = 50; c[7] = 60; c[8] = 70; c[9] = 80;
if (nBins >= 10) c[10] = 90;
if (nBins >= 11) c[11] = 100;
}
THStack* all = new THStack("all","all");
std::ofstream out(outname);
std::ostream& o = out; // std::cout;
// std::ostream& o = std::cout;
o << "*author: SHAHOYAN : 2015\n"
<< "*title: Full centrality dependence of the charged "
<< "particle pseudo-rapidity density over the widest "
<< "possible pseudo-rapidity range in Pb-Pb collisions "
<< "at 5.02 TeV\n"
<< "*detector: TRACKLETS\n"
<< "*experiment: CERN-LHC-TRACKLETS\n"
<< "*comment: CERN-LHC: We present the charged particle pseudo-rapidity "
<< "density of charged particles in Pb-Pb collisions at sqrt(s)/nucleon "
"= 5.02 over the widest possible pseudo-rapidity and centrality range "
<< "possible.\n" << std::endl;
for (Int_t i = 0; i < nBins; i++) {
TString hName = Form("bin%d_DataCorrSignal_PbPb",i);
TH1* h = static_cast<TH1*>(arr->FindObject(hName));
if (!h) {
hName.ReplaceAll("PbPb", "PBPB");
h = static_cast<TH1*>(arr->FindObject(hName));
if (!h) {
Warning("", "Histogram (%s) missing for bin %d", hName.Data(), i);
arr->Print();
continue;
}
}
Color_t col = PbPbColor(c[i], c[i+1]);
h->SetLineColor(col);
h->SetMarkerColor(col);
h->SetFillColor(col);
all->Add(h);
Info("","Making GSE for %0d%% to %3d%% (%d)",
Int_t(c[i]), Int_t(c[i+1]), col);
MakeGSE(o, h, c[i], c[i+1], reweigh);
}
// all->Draw("nostack");
o << "*E" << std::endl;
out.close();
TCanvas* can = new TCanvas("c","C", 1600, 800);
can->SetRightMargin(0.2);
can->SetTopMargin(0.01);
TLegend* cl = new TLegend(1-can->GetRightMargin(),
can->GetBottomMargin(),.99,
1-can->GetTopMargin());
cl->SetFillStyle(0);
cl->SetBorderSize(0);
gROOT->LoadMacro("$HOME/GraphSysErr/GraphSysErr.C+");
TList* ll = GraphSysErr::Import(outname);
// ll->ls();
TIter next(ll);
TObject* obj = 0;
Bool_t first = true;
TH1* frame = 0;
Double_t min=100000, max=0;
Int_t i = 0;
while ((obj = next())) {
//.........这里部分代码省略.........
示例5: mvas
//.........这里部分代码省略.........
Float_t nrms = 4;
cout << "--- Mean and RMS (S): " << sig->GetMean() << ", " << sig->GetRMS() << endl;
cout << "--- Mean and RMS (B): " << bgd->GetMean() << ", " << bgd->GetRMS() << endl;
Float_t xmin = TMath::Max( TMath::Min(sig->GetMean() - nrms*sig->GetRMS(),
bgd->GetMean() - nrms*bgd->GetRMS() ),
sig->GetXaxis()->GetXmin() );
Float_t xmax = TMath::Min( TMath::Max(sig->GetMean() + nrms*sig->GetRMS(),
bgd->GetMean() + nrms*bgd->GetRMS() ),
sig->GetXaxis()->GetXmax() );
Float_t ymin = 0;
Float_t maxMult = (htype == CompareType) ? 1.3 : 1.2;
Float_t ymax = TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*maxMult;
// build a frame
Int_t nb = 500;
TString hFrameName(TString("frame") + methodTitle);
TObject *o = gROOT->FindObject(hFrameName);
if(o) delete o;
TH2F* frame = new TH2F( hFrameName, sig->GetTitle(),
nb, xmin, xmax, nb, ymin, ymax );
frame->GetXaxis()->SetTitle( methodTitle + ((htype == MVAType || htype == CompareType) ? " response" : "") );
if (htype == ProbaType ) frame->GetXaxis()->SetTitle( "Signal probability" );
else if (htype == RarityType ) frame->GetXaxis()->SetTitle( "Signal rarity" );
frame->GetYaxis()->SetTitle("Normalized");
TMVAGlob::SetFrameStyle( frame );
// eventually: draw the frame
frame->Draw();
c->GetPad(0)->SetLeftMargin( 0.105 );
frame->GetYaxis()->SetTitleOffset( 1.2 );
// Draw legend
TLegend *legend= new TLegend( c->GetLeftMargin(), 1 - c->GetTopMargin() - 0.12,
c->GetLeftMargin() + (htype == CompareType ? 0.40 : 0.3), 1 - c->GetTopMargin() );
legend->SetFillStyle( 1 );
legend->AddEntry(sig,TString("Signal") + ((htype == CompareType) ? " (test sample)" : ""), "F");
legend->AddEntry(bgd,TString("Background") + ((htype == CompareType) ? " (test sample)" : ""), "F");
legend->SetBorderSize(1);
legend->SetMargin( (htype == CompareType ? 0.2 : 0.3) );
legend->Draw("same");
// overlay signal and background histograms
sig->Draw("samehist");
bgd->Draw("samehist");
if (htype == CompareType) {
// if overtraining check, load additional histograms
TH1* sigOv = 0;
TH1* bgdOv = 0;
TString ovname = hname += "_Train";
sigOv = dynamic_cast<TH1*>(titDir->Get( ovname + "_S" ));
bgdOv = dynamic_cast<TH1*>(titDir->Get( ovname + "_B" ));
if (sigOv == 0 || bgdOv == 0) {
cout << "+++ Problem in \"mvas.C\": overtraining check histograms do not exist" << endl;
}
else {
cout << "--- Found comparison histograms for overtraining check" << endl;
TLegend *legend2= new TLegend( 1 - c->GetRightMargin() - 0.42, 1 - c->GetTopMargin() - 0.12,
1 - c->GetRightMargin(), 1 - c->GetTopMargin() );
legend2->SetFillStyle( 1 );
legend2->SetBorderSize(1);
legend2->AddEntry(sigOv,"Signal (training sample)","P");
示例6: DrawIt
//------------------------------------------------------------------------------
// DrawIt
//------------------------------------------------------------------------------
void DrawIt(TString filename,
TString hname,
TString cname,
TString title)
{
TFile* inputfile = TFile::Open("../AuxiliaryFilesWZXS8TeV/" + filename + ".root");
TH2F* h = (TH2F*)inputfile->Get(hname)->Clone(cname);
h->SetDirectory(0);
inputfile->Close();
TString name = h->GetName();
TCanvas* canvas = new TCanvas(name, name, 600, 600);
if (name.Contains("PR")) canvas->SetLogx();
if (name.Contains("SF")) canvas->SetLogx();
canvas->SetLeftMargin (0.9 * canvas->GetLeftMargin());
canvas->SetRightMargin(3.5 * canvas->GetRightMargin());
canvas->SetTopMargin (1.2 * canvas->GetTopMargin());
TH2FAxisFonts(h, "x", "p_{T} [GeV]");
TH2FAxisFonts(h, "y", "#eta");
h->Draw("colz");
h->SetTitle("");
DrawTLatex(42, 0.940, 0.976, _bigLabelSize, 33, title);
if (!title.Contains("trigger")) {
Double_t hmin = h->GetMinimum();
Double_t hmax = h->GetMaximum();
for (Int_t i=1; i<=h->GetNbinsX(); i++) {
for (Int_t j=1; j<=h->GetNbinsY(); j++) {
Double_t value = h->GetBinContent(i,j);
Double_t ypos = h->GetYaxis()->GetBinCenter(j);
Double_t xpos = h->GetXaxis()->GetBinCenter(i);
if (gPad->GetLogx()) xpos = h->GetXaxis()->GetBinCenterLog(i);
TLatex* latex = new TLatex(xpos, ypos, Form("%.2f", value));
latex->SetTextAlign( 22);
latex->SetTextFont ( 42);
latex->SetTextSize (0.027);
if (value < hmin + 0.3*(hmax - hmin)) latex->SetTextColor(kWhite);
latex->Draw();
}
}
}
// Set the palette font
//----------------------------------------------------------------------------
canvas->Update();
TPaletteAxis* palette = (TPaletteAxis*)h->GetListOfFunctions()->FindObject("palette");
palette->SetLabelFont(42);
// Save the plot
//----------------------------------------------------------------------------
canvas->Update();
canvas->Modified();
canvas->GetFrame()->DrawClone();
canvas->SaveAs("pdf/scale_factors/" + name + ".pdf");
canvas->SaveAs("png/scale_factors/" + name + ".png");
}
示例7: probas
//.........这里部分代码省略.........
}
if ((sigF == NULL || bkgF == NULL) &&!hname.Contains("hist") ) {
cout << "*** probas.C: big troubles - did not found histogram " << hspline.Data() << " "
<< sigF << " " << bkgF << endl;
return;
}
else {
// remove the signal suffix
// check that exist
if (NULL != sigF && NULL != bkgF && NULL!=sig && NULL!=bgd) {
TString hname = sig->GetName();
// chop off useless stuff
sig->SetTitle( TString("TMVA output for classifier: ") + methodTitle );
// create new canvas
cout << "--- Book canvas no: " << countCanvas << endl;
char cn[20];
sprintf( cn, "canvas%d", countCanvas+1 );
c = new TCanvas( cn, Form("TMVA Output Fit Variables %s",methodTitle.Data()),
countCanvas*50+200, countCanvas*20, width, width*0.78 );
// set the histogram style
TMVAGlob::SetSignalAndBackgroundStyle( sig, bgd );
TMVAGlob::SetSignalAndBackgroundStyle( sigF, bkgF );
// frame limits (choose judicuous x range)
Float_t nrms = 4;
Float_t xmin = TMath::Max( TMath::Min(sig->GetMean() - nrms*sig->GetRMS(),
bgd->GetMean() - nrms*bgd->GetRMS() ),
sig->GetXaxis()->GetXmin() );
Float_t xmax = TMath::Min( TMath::Max(sig->GetMean() + nrms*sig->GetRMS(),
bgd->GetMean() + nrms*bgd->GetRMS() ),
sig->GetXaxis()->GetXmax() );
Float_t ymin = 0;
Float_t ymax = TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*1.5;
if (Draw_CFANN_Logy && mvaName[imva] == "CFANN") ymin = 0.01;
// build a frame
Int_t nb = 500;
TH2F* frame = new TH2F( TString("frame") + sig->GetName() + "_proba", sig->GetTitle(),
nb, xmin, xmax, nb, ymin, ymax );
frame->GetXaxis()->SetTitle(methodTitle);
frame->GetYaxis()->SetTitle("Normalized");
TMVAGlob::SetFrameStyle( frame );
// eventually: draw the frame
frame->Draw();
if (Draw_CFANN_Logy && mvaName[imva] == "CFANN") c->SetLogy();
// overlay signal and background histograms
sig->SetMarkerColor( TMVAGlob::c_SignalLine );
sig->SetMarkerSize( 0.7 );
sig->SetMarkerStyle( 20 );
sig->SetLineWidth(1);
bgd->SetMarkerColor( TMVAGlob::c_BackgroundLine );
bgd->SetMarkerSize( 0.7 );
bgd->SetMarkerStyle( 24 );
bgd->SetLineWidth(1);
sig->Draw("samee");
bgd->Draw("samee");
sigF->SetFillStyle( 0 );
bkgF->SetFillStyle( 0 );
sigF->Draw("samehist");
bkgF->Draw("samehist");
// redraw axes
frame->Draw("sameaxis");
// Draw legend
TLegend *legend= new TLegend( c->GetLeftMargin(), 1 - c->GetTopMargin() - 0.2,
c->GetLeftMargin() + 0.4, 1 - c->GetTopMargin() );
legend->AddEntry(sig,"Signal data","P");
legend->AddEntry(sigF,"Signal PDF","L");
legend->AddEntry(bgd,"Background data","P");
legend->AddEntry(bkgF,"Background PDF","L");
legend->Draw("same");
legend->SetBorderSize(1);
legend->SetMargin( 0.3 );
// save canvas to file
c->Update();
TMVAGlob::plot_logo();
sprintf( fname, "plots/mva_pdf_%s_c%i", methodTitle.Data(), countCanvas+1 );
if (Save_Images) TMVAGlob::imgconv( c, fname );
countCanvas++;
}
}
}
}
}
}
}
示例8: 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;
}
示例9: plotLimit
//.........这里部分代码省略.........
band_exp1_4->Draw("3same");
limit_obs_4->Draw("Lsame");
limit_obs_4->SetLineWidth(2);
limit_obs_4->SetMarkerSize(1.0);
limit_obs_4->SetMarkerStyle(20);
limit_exp_2->Draw("L same");
limit_exp_2->SetLineStyle(2);
limit_exp_2->SetLineWidth(2);
limit_exp_2->SetMarkerSize(1.0);
limit_exp_3->Draw("L same");
limit_exp_3->SetLineStyle(2);
limit_exp_3->SetLineWidth(2);
limit_exp_3->SetMarkerSize(1.0);
limit_exp_4->Draw("L same");
limit_exp_4->SetLineStyle(2);
limit_exp_4->SetLineWidth(2);
limit_exp_4->SetMarkerSize(1.0);
canvas->RedrawAxis();
double x1 = 595;
double y1 = 1.0;
double x2 = 905;
double y2 = 1.0;
TLine * line = new TLine(x1, y1, x2, y2);
theory->SetLineColor(2);
theory->SetLineWidth(2);
theory->Draw("same");
theory2->SetLineColor(kBlue);
theory2->SetLineWidth(2);
theory2->Draw("same");
theory3->SetLineColor(kMagenta);
theory3->SetLineWidth(2);
theory3->Draw("same");
theory4->SetLineColor(kCyan);
theory4->SetLineWidth(2);
theory4->Draw("same");
CMS_lumi(canvas, 4, 10);
float t = canvas->GetTopMargin();
float r = canvas->GetRightMargin();
//Legend
TLegend *l = new TLegend(0.51,0.63,0.99-r,0.99-t);
l->AddEntry(limit_obs,"Observed", "L");
l->AddEntry(limit_exp,"Expected", "L");
l->AddEntry(band_exp1,"#pm1 #sigma Exp.", "F");
l->AddEntry(band_exp2,"#pm2 #sigma Exp.", "F");
l->AddEntry(theory, "Z' 1 TeV (NLO)", "L");
l->AddEntry(theory2, "Z' 2 TeV (NLO)", "L");
l->AddEntry(theory3, "Z' 3 TeV (NLO x 0.1)", "L");
l->AddEntry(theory4, "Z' 4 TeV (NLO x 0.01)", "L");
l->SetFillColor(0);
l->SetLineColor(0);
l->SetTextSize(0.04);
l->SetTextFont(42);
l->Draw();
//TLatex * label = new TLatex();
//label->SetNDC();
//label->DrawLatex(0.2,0.86,"CMS Preliminary, 19.7 fb^{-1}");
//label->DrawLatex(0.2,0.80,"#sqrt{s} = 8 TeV");
//label->DrawLatex(0.6,0.80, Form("BR(b'#rightarrow %s) = 1", channel.Data()));
//label->DrawLatex(0.55,0.80, "BR(b'#rightarrow tW) = 0.5");
//label->DrawLatex(0.55,0.74, "BR(b'#rightarrow bH) = 0.25");
//label->DrawLatex(0.55,0.68, "BR(b'#rightarrow bZ) = 0.25");
//label->DrawLatex(0.2,0.74, lepton.Data());
canvas->SetLogy(1);
canvas->SetLogx(1);
canvas->SetTickx(1);
canvas->SetTicky(1);
if (signal == 0){
canvas->Print("Limits/comb_ZPN_limit.pdf");
canvas->Print("Limits/comb_ZPN_limit.root");
}
else if (signal == 1){
canvas->Print("Limits/comb_ZPW_limit.pdf");
canvas->Print("Limits/comb_ZPW_limit.root");
}
else if (signal == 2){
canvas->Print("Limits/comb_ZPXW_limit.pdf");
canvas->Print("Limits/comb_ZPXW_limit.root");
}
else if (signal == 3){
canvas->Print("Limits/comb_RSG_limit.pdf");
canvas->Print("Limits/comb_RSG_limit.root");
}
}
示例10: vs_PlotQCDcomp
//.........这里部分代码省略.........
if ( hptFOR != 0 ) {
for (int b = 0; b < hptFOR->GetNbinsX(); b++) {
Double_t mainHistoContent = hptFOR->GetBinContent(b);
Double_t systUpHistoContent = hptSUR->GetBinContent(b);
Double_t systDnHistoContent = hptSDR->GetBinContent(b);
Double_t systDiffUp = fabs( (double) systUpHistoContent - mainHistoContent );
Double_t systDiffDn = fabs( (double) mainHistoContent - systDnHistoContent );
// use average error for histogram
Double_t systDiff = ( systDiffUp + systDiffDn ) / 2.;
Double_t statErr = hptFOR->GetBinError(b);
Double_t combError = sqrt( systDiff * systDiff + statErr * statErr );
hptFOR->SetBinError(b, combError);
} //for
}//if
cPt->SetLogy(1);
gPad->Update();
cPt->Update();
// hptR->Scale(1,"width");
// hptR->SetMinimum(0.02);
// hptR->SetMaximum(1000);
hptR->GetXaxis()->SetTitle("1^{st} photon p_{T} [GeV]");
hptR->GetYaxis()->SetTitle("Number of Events / GeV");
if(isMC) hptR->SetMarkerSize(0);
if(isMC) hptR->Draw("histE");
else hptR->Draw("E X0");
hptFOR->SetMarkerSize(0);
hptFOR->SetLineColor(2);
hptFOR->SetFillColor(2);
hptFOR->SetFillStyle(3004);
hptFOR->Draw("same hist ][ E2");
legend->Clear();
if(isMC) legend->SetHeader("#gamma/QCD (Sim)");
else legend->SetHeader("#gamma/QCD (Data)");
if(isMC) legend->AddEntry(hptR, "#gamma", "l");
else legend->AddEntry(hptR, "#gamma", "p");
legend->AddEntry(hptFOR, "Pred (from #gamma_{jet})", "f");
legend->Draw();
as->DrawLatex(0.17, 0.93, outLumi.c_str() );
cPt->Update();
cPt->SetBottomMargin(0.2 + 0.8 * cPt->GetBottomMargin() - 0.2 * cPt->GetTopMargin());
TPad *ratioPt = new TPad("BottomPad", "", 0, 0, 1, 1);
ratioPt->SetTopMargin(0.8 - 0.8 * ratioPt->GetBottomMargin() + 0.2 * ratioPt->GetTopMargin());
ratioPt->SetFillStyle(0);
ratioPt->SetFrameFillColor(10);
ratioPt->SetFrameBorderMode(0);
ratioPt->Draw();
ratioPt->cd();
ratioPt->SetLogy(0);
TH1F *hptRat = (TH1F*) divideHistosForRatio(hptR,hptFOR);
hptRat->SetMinimum(0.);
hptRat->SetMaximum(10.);
hptRat->GetXaxis()->SetNdivisions(505);
if(isMC) hptRat->GetYaxis()->SetTitle("Sim/Pred");
else hptRat->GetYaxis()->SetTitle("Data/Pred");
hptRat->GetYaxis()->SetTitleSize(0.04);
hptRat->GetYaxis()->SetLabelSize(0.03);
hptRat->GetYaxis()->SetTitleOffset(1.3);
hptRat->GetYaxis()->SetNdivisions(505);
hptRat->SetMarkerStyle(20);
hptRat->SetMarkerSize(1);
hptRat->SetMarkerColor(1);
hptRat->SetLineColor(1);
hptRat->Draw("E X0");
TH1F *hptFRat = (TH1F*) getSystErrForRatio(hptFOR);
hptFRat->SetLineColor(2);
hptFRat->SetFillColor(2);
hptFRat->SetFillStyle(3004);
hptFRat->Draw("same hist ][ E2");
TLine * line = new TLine( hptRat->GetXaxis()->GetXmin(), 1., hptRat->GetXaxis()->GetXmax(), 1. );
line->SetLineColor(1);
line->SetLineWidth(0.5);
line->SetLineStyle(1);
line->Draw("same");
hptR->GetXaxis()->SetLabelSize(0);
hptR->GetXaxis()->SetTitle("");
cPt->RedrawAxis();
gPad->Update();
cPt->Update();
return;
}
示例11: DrawMLPoutputMovie
//.........这里部分代码省略.........
countCanvas++;
TString ctitle = Form("TMVA response %s",methodTitle.Data());
c = new TCanvas( Form("canvas%d", countCanvas), ctitle, 0, 0, width, (Int_t)width*0.78 );
TH1F* sig = (TH1F*)titkeyTit->ReadObj();
sig->SetTitle( Form("TMVA response for classifier: %s", methodTitle.Data()) );
TString dataType = (name.Contains("_train_") ? "(training sample)" : "(test sample)");
// find background
TString nbn = sig->GetName(); nbn[nbn.Length()-1] = 'B';
TH1F* bgd = dynamic_cast<TH1F*>(epochDir->Get( nbn ));
if (bgd == 0) {
cout << "Big troubles with histogram: " << bgd << " -> cannot find!" << endl;
exit(1);
}
cout << "sig = " << sig->GetName() << endl;
cout << "bgd = " << bgd->GetName() << endl;
// set the histogram style
TMVAGlob::SetSignalAndBackgroundStyle( sig, bgd );
// normalise both signal and background
TMVAGlob::NormalizeHists( sig, bgd );
// set only first time, then same for all plots
if (first) {
if (xmin == 0 && xmax == 0) {
xmin = TMath::Max( TMath::Min(sig->GetMean() - nrms*sig->GetRMS(),
bgd->GetMean() - nrms*bgd->GetRMS() ),
sig->GetXaxis()->GetXmin() );
xmax = TMath::Min( TMath::Max(sig->GetMean() + nrms*sig->GetRMS(),
bgd->GetMean() + nrms*bgd->GetRMS() ),
sig->GetXaxis()->GetXmax() );
}
ymin = 0;
ymax = TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*maxMult;
first = kFALSE;
}
// build a frame
Int_t nb = 100;
TString hFrameName(TString("frame") + methodTitle);
TObject *o = gROOT->FindObject(hFrameName);
if(o) delete o;
TH2F* frame = new TH2F( hFrameName, sig->GetTitle(),
nb, xmin, xmax, nb, ymin, ymax );
frame->GetXaxis()->SetTitle( methodTitle + " response" );
frame->GetYaxis()->SetTitle("(1/N) dN^{ }/^{ }dx");
TMVAGlob::SetFrameStyle( frame );
// find epoch number (4th token)
TObjArray* tokens = name.Tokenize("_");
TString es = ((TObjString*)tokens->At(4))->GetString();
if (!es.IsFloat()) {
cout << "Big troubles in epoch parsing: \"" << es << "\" is not float" << endl;
exit(1);
}
Int_t epoch = es.Atoi();
// eventually: draw the frame
frame->Draw();
c->GetPad(0)->SetLeftMargin( 0.105 );
frame->GetYaxis()->SetTitleOffset( 1.2 );
// Draw legend
TLegend *legend= new TLegend( c->GetLeftMargin(), 1 - c->GetTopMargin() - 0.12,
c->GetLeftMargin() + 0.5, 1 - c->GetTopMargin() );
legend->SetFillStyle( 1 );
legend->AddEntry(sig,TString("Signal ") + dataType, "F");
legend->AddEntry(bgd,TString("Background ") + dataType, "F");
legend->SetBorderSize(1);
legend->SetMargin( 0.15 );
legend->Draw("same");
TText* t = new TText();
t->SetTextSize( 0.04 );
t->SetTextColor( 1 );
t->SetTextAlign( 31 );
t->DrawTextNDC( 1 - c->GetRightMargin(), 1 - c->GetTopMargin() + 0.015, Form( "Epoch: %i", epoch) );
// overlay signal and background histograms
sig->Draw("samehist");
bgd->Draw("samehist");
// save to file
TString dirname = "movieplots";
TString foutname = dirname + "/" + name;
foutname.Resize( foutname.Length()-2 );
foutname.ReplaceAll("convergencetest___","");
foutname += ".gif";
cout << "storing file: " << foutname << endl;
c->Update();
c->Print(foutname);
}
}