Skip to content

Commit b7344a6

Browse files
authored
Some tutorials did not show correctly in the ref guide. (root-project#9125)
1 parent f0ace64 commit b7344a6

File tree

3 files changed

+37
-34
lines changed

3 files changed

+37
-34
lines changed

tutorials/fit/ConfidenceIntervals.C

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
/// This method computes confidence intervals for the fitted function
66
///
77
/// \macro_image
8-
/// \macro_output
98
/// \macro_code
109
///
1110
/// \author Rene Brun
@@ -21,7 +20,7 @@
2120
void ConfidenceIntervals()
2221
{
2322
TCanvas *myc = new TCanvas("myc",
24-
"Confidence intervals on the fitted function",1200, 500);
23+
"Confidence intervals on the fitted function",1000, 500);
2524
myc->Divide(3,1);
2625

2726
//### 1. A graph

tutorials/fit/fit1.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ void fit1() {
3333
gBenchmark->Start("fit1");
3434
//
3535
// We connect the ROOT file generated in a previous tutorial
36-
// (see <a href="fillrandom.C.nbconvert.ipynb">Filling histograms with random numbers from a function</a>)
36+
// (see <a href="fillrandom.C.nbconvert.ipynb">Filling histograms with random numbers from a function</a>)
3737
//
3838
TString dir = gROOT->GetTutorialDir();
3939
dir.Append("/fit/");
4040
TFile *file = TFile::Open("fillrandom.root");
4141
if (!file) {
42-
gROOT->ProcessLine(Form(".x %s../hist/fillrandom.C",dir.Data()));
42+
gROOT->ProcessLine(Form(".x %s../hist/fillrandom.C(0)",dir.Data()));
4343
file = TFile::Open("fillrandom.root");
4444
if (!file) return;
4545
}

tutorials/hist/fillrandom.C

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,56 @@
88
///
99
/// \author Rene Brun
1010

11-
void fillrandom() {
12-
TCanvas *c1 = new TCanvas("c1","The FillRandom example",200,10,700,900);
13-
14-
auto pad1 = new TPad("pad1","The pad with the function",0.05,0.50,0.95,0.95);
15-
auto pad2 = new TPad("pad2","The pad with the histogram",0.05,0.05,0.95,0.45);
16-
pad1->Draw();
17-
pad2->Draw();
18-
pad1->cd();
19-
11+
void fillrandom(int plot=1) {
2012
gBenchmark->Start("fillrandom");
21-
//
13+
2214
// A function (any dimension) or a formula may reference
2315
// an already defined formula
24-
//
2516
auto form1 = new TFormula("form1","abs(sin(x)/x)");
2617
auto sqroot = new TF1("sqroot","x*gaus(0) + [3]*form1",0,10);
27-
sqroot->SetParameters(10,4,1,20);
28-
pad1->SetGridx();
29-
pad1->SetGridy();
30-
pad1->GetFrame()->SetBorderMode(-1);
31-
pad1->GetFrame()->SetBorderSize(5);
3218
sqroot->SetLineColor(4);
3319
sqroot->SetLineWidth(6);
34-
sqroot->Draw();
35-
auto lfunction = new TPaveLabel(5,39,9.8,46,"The sqroot function");
36-
lfunction->Draw();
37-
c1->Update();
20+
sqroot->SetParameters(10,4,1,20);
3821

39-
//
4022
// Create a one dimensional histogram (one float per bin)
4123
// and fill it following the distribution in function sqroot.
42-
//
43-
pad2->cd();
44-
pad2->GetFrame()->SetBorderMode(-1);
45-
pad2->GetFrame()->SetBorderSize(5);
4624
auto h1f = new TH1F("h1f","Test random numbers",200,0,10);
47-
h1f->SetFillColor(45);
4825
h1f->FillRandom("sqroot",10000);
49-
h1f->Draw();
50-
c1->Update();
51-
//
26+
5227
// Open a ROOT file and save the formula, function and histogram
53-
//
5428
TFile myfile("fillrandom.root","RECREATE");
5529
form1->Write();
5630
sqroot->Write();
5731
h1f->Write();
32+
33+
// Produce a plot if requested
34+
if (plot) {
35+
TCanvas *c1 = new TCanvas("c1","The FillRandom example",200,10,700,900);
36+
37+
auto pad1 = new TPad("pad1","The pad with the function",0.05,0.50,0.95,0.95);
38+
auto pad2 = new TPad("pad2","The pad with the histogram",0.05,0.05,0.95,0.45);
39+
pad1->Draw();
40+
pad2->Draw();
41+
pad1->cd();
42+
43+
pad1->SetGridx();
44+
pad1->SetGridy();
45+
pad1->GetFrame()->SetBorderMode(-1);
46+
pad1->GetFrame()->SetBorderSize(5);
47+
48+
sqroot->Draw();
49+
auto lfunction = new TPaveLabel(5,39,9.8,46,"The sqroot function");
50+
lfunction->Draw();
51+
c1->Update();
52+
53+
pad2->cd();
54+
pad2->GetFrame()->SetBorderMode(-1);
55+
pad2->GetFrame()->SetBorderSize(5);
56+
57+
h1f->SetFillColor(45);
58+
h1f->Draw();
59+
c1->Update();
60+
}
61+
5862
gBenchmark->Show("fillrandom");
5963
}

0 commit comments

Comments
 (0)