From a0dd81a91509b981e9eb20b6c2cfda2e434c7893 Mon Sep 17 00:00:00 2001 From: Pau Miquel <paumm2006@yahoo.es> Date: Tue, 2 Aug 2016 13:14:45 +0200 Subject: [PATCH] Added notebooks to tutorials, fixed other notebooks, changed variable name --- documentation/doxygen/converttonotebook.py | 9 +-- tutorials/fit/ConfidenceIntervals.C | 1 + tutorials/fit/ErrorIntegral.C | 1 + tutorials/fit/fit2dHist.C | 2 +- tutorials/fit/fitLinear2.C | 28 +++---- tutorials/fit/fitMultiGraph.C | 90 +++++++++++----------- tutorials/fit/fitcont.C | 1 + tutorials/fit/fitslicesy.C | 4 +- tutorials/fit/langaus.C | 8 +- tutorials/fit/line3Dfit.C | 7 +- tutorials/fit/myfit.C | 4 +- tutorials/graphics/anim.C | 1 - tutorials/graphics/earth.C | 4 +- tutorials/graphics/polytest1.C | 1 + tutorials/graphics/psview.C | 1 - tutorials/graphs/graphstruct.C | 2 + tutorials/graphs/motorcycle.C | 5 +- tutorials/graphs/waves.C | 2 +- tutorials/hist/FirstContour.C | 4 +- tutorials/hist/candleplotstack.C | 1 + tutorials/hist/draw2dopt.C | 1 + tutorials/hist/exec1.C | 1 - tutorials/hist/h1draw.C | 4 +- tutorials/hist/hbars.C | 4 +- tutorials/hist/th2polyHoneycomb.C | 1 - tutorials/hist/th2polyUSA.C | 1 - tutorials/hsimple.C | 8 +- tutorials/io/copyFiles.C | 1 + tutorials/io/dirs.C | 1 + tutorials/io/fildir.C | 1 + tutorials/io/file.C | 1 + tutorials/io/hadd.C | 1 + tutorials/io/importCode.C | 4 +- tutorials/io/loopdir.C | 1 + tutorials/io/mergeSelective.C | 5 +- tutorials/io/readCode.C | 1 + tutorials/io/testMergeCont.C | 45 ++++++----- 37 files changed, 135 insertions(+), 122 deletions(-) diff --git a/documentation/doxygen/converttonotebook.py b/documentation/doxygen/converttonotebook.py index df0a7e3934f..33d49fc347c 100644 --- a/documentation/doxygen/converttonotebook.py +++ b/documentation/doxygen/converttonotebook.py @@ -196,7 +196,7 @@ def split(text): """ #p = re.compile(r'^void\s\w*?\s?\([\w\n=,*\_ ]*\)\s*\{.*?^\}|^int\s\w*?\s?\([\w\n=,*\_ ]*\)\s*\{.*?^\}|^string\s\w*?\s?\([\w\n=,*\_ ]*\)\s*\{.*?^\}|^double\s\w*?\s?\([\w\n=,*\_ ]*\)\s*\{.*?^\}|^float\s\w*?\s?\([\w\n=,*\_ ]*\)\s*\{.*?^\}|^char\s\w*?\s?\([\w\n=,*\_ ]*\)\s*\{.*?^\}|^TCanvas\s\*\w*\(.*?\).*?\{.*?^\}|^TString\s\w*?\s?\([\w\n=,*\_ ]*\)\s*\{.*?^\}|^Double_t\s\w*?\s?\([\w\n=,*\_ ]*\)\s*\{.*?^\}', flags = re.DOTALL | re.MULTILINE) - p = re.compile(r'(^void|^int|^Int_t|^TF1|^string|^bool|^double|^float|^char|^TCanvas|^TString|^Double_t)\s?\*?\s?\w*?\s?\([^\)]*\)\s*\{.*?^\}', flags = re.DOTALL | re.MULTILINE) + p = re.compile(r'(^void|^int|^Int_t|^TF1|^string|^bool|^double|^float|^char|^TCanvas|^TString|^TSeqCollection|^Double_t|^TFile)\s?\*?\s?\w*?\s?\([^\)]*\)\s*\{.*?^\}', flags = re.DOTALL | re.MULTILINE) matches = p.finditer(text) helpers=[] main = "" @@ -232,7 +232,6 @@ def split(text): rest = rest.rstrip() #remove newlines at the end of string - print "MAIN \n\n\n" , main, "\n\n HELPERS\n\n\n", newhelpers, "\n\nREST\n\n\n",rest return main, newhelpers, rest def processmain(text): @@ -246,15 +245,13 @@ def processmain(text): regex = re.compile(r'(?<=\().*?(?=\))',flags = re.DOTALL | re.MULTILINE) arguments = regex.search(text) - print "\n\nTEXT\n\n" , text , "ENDTEXT" if text: if text.startswith("TCanvas") or len(arguments.group())>3: keepfunction = True - p = re.compile(r'(?<=(?<=int)|(?<=void)|(?<=TF1)|(?<=Int_t)|(?<=string)|(?<=double)|(?<=float)|(?<=char)|(?<=TString)|(?<=bool)|(?<=TCanvas))\s?\*?\s?[^\s]*?(?=\s?\()',flags = re.DOTALL | re.MULTILINE) + p = re.compile(r'(?<=(?<=int)|(?<=void)|(?<=TF1)|(?<=Int_t)|(?<=string)|(?<=double)|(?<=float)|(?<=char)|(?<=TString)|(?<=bool)|(?<=TSeqCollection)|(?<=TCanvas)|(?<=TFile))\s?\*?\s?[^\s]*?(?=\s?\()',flags = re.DOTALL | re.MULTILINE) match = p.search(text) functionname=match.group().strip(" *") - print "FUCNITONNAME", functionname addition = "\n# <markdowncell> \n# Call the main function \n# <codecell>\n%s();" %functionname return text, addition, keepfunction @@ -419,7 +416,7 @@ def mainfunction(text): #subprocess.call(["jupyter", "nbconvert","--ExecutePreprocessor.timeout=60", "--to=html", "--execute", outdir+outname]) r = subprocess.call(["jupyter", "nbconvert","--ExecutePreprocessor.timeout=90", "--to=notebook", "--execute", outdir+outname]) if r != 0: - sys.stderr.write( "ERROR: Nbconvert failed for notebook %s \n" % outname) + sys.stderr.write( "WARNING: Nbconvert failed for notebook %s \n" % outname) if jsroot: subprocess.call(["jupyter", "trust", outdir+outnameconverted]) os.remove(outdir+outname) diff --git a/tutorials/fit/ConfidenceIntervals.C b/tutorials/fit/ConfidenceIntervals.C index 95fb9d17643..b3fca2012a8 100644 --- a/tutorials/fit/ConfidenceIntervals.C +++ b/tutorials/fit/ConfidenceIntervals.C @@ -1,5 +1,6 @@ /// \file /// \ingroup tutorial_fit +/// \notebook /// Illustrates TVirtualFitter::GetConfidenceIntervals /// This method computes confidence intervals for the fitted function /// diff --git a/tutorials/fit/ErrorIntegral.C b/tutorials/fit/ErrorIntegral.C index 869487d0736..c79013d1eb5 100644 --- a/tutorials/fit/ErrorIntegral.C +++ b/tutorials/fit/ErrorIntegral.C @@ -1,5 +1,6 @@ /// \file /// \ingroup tutorial_fit +/// \notebook /// Estimate the error in the integral of a fitted function /// taking into account the errors in the parameters resulting from the fit. /// The error is estimated also using the correlations values obtained from diff --git a/tutorials/fit/fit2dHist.C b/tutorials/fit/fit2dHist.C index a1ffa5bc260..686a3669ac3 100644 --- a/tutorials/fit/fit2dHist.C +++ b/tutorials/fit/fit2dHist.C @@ -1,6 +1,6 @@ /// \file /// \ingroup tutorial_fit -/// \notebook -js +/// \notebook /// /// Example to fit two histograms at the same time via TVirtualFitter /// diff --git a/tutorials/fit/fitLinear2.C b/tutorials/fit/fitLinear2.C index a4b89f15153..114f3f8998c 100644 --- a/tutorials/fit/fitLinear2.C +++ b/tutorials/fit/fitLinear2.C @@ -14,13 +14,13 @@ #include "TLinearFitter.h" #include "TF1.h" -#include "TRandom.h" +#include "Trandom.h" void fitLinear2() { Int_t n=100; Int_t i; - TRandom rand; + TRandom rand1; TLinearFitter *lf=new TLinearFitter(5); //The predefined "hypN" functions are the fastest to fit @@ -32,13 +32,13 @@ void fitLinear2() //Create the points and put them into the fitter for (i=0; i<n; i++){ - x[0 + i*5] = rand.Uniform(-10, 10); - x[1 + i*5] = rand.Uniform(-10, 10); - x[2 + i*5] = rand.Uniform(-10, 10); - x[3 + i*5] = rand.Uniform(-10, 10); - x[4 + i*5] = rand.Uniform(-10, 10); + x[0 + i*5] = rand1.Uniform(-10, 10); + x[1 + i*5] = rand1.Uniform(-10, 10); + x[2 + i*5] = rand1.Uniform(-10, 10); + x[3 + i*5] = rand1.Uniform(-10, 10); + x[4 + i*5] = rand1.Uniform(-10, 10); e[i] = 0.01; - y[i] = 4*x[0+i*5] + x[1+i*5] + 2*x[2+i*5] + 3*x[3+i*5] + 0.2*x[4+i*5] + rand.Gaus()*e[i]; + y[i] = 4*x[0+i*5] + x[1+i*5] + 2*x[2+i*5] + 3*x[3+i*5] + 0.2*x[4+i*5] + rand1.Gaus()*e[i]; } //To avoid copying the data into the fitter, the following function can be used: @@ -61,13 +61,13 @@ void fitLinear2() //Now suppose you want to add some more points and see if the parameters will change for (i=n; i<n*2; i++) { - x[0+i*5] = rand.Uniform(-10, 10); - x[1+i*5] = rand.Uniform(-10, 10); - x[2+i*5] = rand.Uniform(-10, 10); - x[3+i*5] = rand.Uniform(-10, 10); - x[4+i*5] = rand.Uniform(-10, 10); + x[0+i*5] = rand1.Uniform(-10, 10); + x[1+i*5] = rand1.Uniform(-10, 10); + x[2+i*5] = rand1.Uniform(-10, 10); + x[3+i*5] = rand1.Uniform(-10, 10); + x[4+i*5] = rand1.Uniform(-10, 10); e[i] = 0.01; - y[i] = 4*x[0+i*5] + x[1+i*5] + 2*x[2+i*5] + 3*x[3+i*5] + 0.2*x[4+i*5] + rand.Gaus()*e[i]; + y[i] = 4*x[0+i*5] + x[1+i*5] + 2*x[2+i*5] + 3*x[3+i*5] + 0.2*x[4+i*5] + rand1.Gaus()*e[i]; } //Assign the data the same way as before diff --git a/tutorials/fit/fitMultiGraph.C b/tutorials/fit/fitMultiGraph.C index 7c7cdabd04c..01add414635 100644 --- a/tutorials/fit/fitMultiGraph.C +++ b/tutorials/fit/fitMultiGraph.C @@ -20,35 +20,35 @@ void fitMultiGraph() { Int_t n = 30; - Double_t *x1 = new Double_t[n]; - Double_t *x2 = new Double_t[n]; - Double_t *x3 = new Double_t[n]; - Double_t *y1 = new Double_t[n]; - Double_t *y2 = new Double_t[n]; - Double_t *y3 = new Double_t[n]; - Double_t *e1 = new Double_t[n]; - Double_t *e2 = new Double_t[n]; - Double_t *e3 = new Double_t[n]; + Double_t *xvalues1 = new Double_t[n]; + Double_t *xvalues2 = new Double_t[n]; + Double_t *xvalues3 = new Double_t[n]; + Double_t *yvalues1 = new Double_t[n]; + Double_t *yvalues2 = new Double_t[n]; + Double_t *yvalues3 = new Double_t[n]; + Double_t *evalues1 = new Double_t[n]; + Double_t *evalues2 = new Double_t[n]; + Double_t *evalues3 = new Double_t[n]; //generate the data for the graphs TRandom r; Int_t i; for (i=0; i<n; i++) { - x1[i] = r.Uniform(0.1, 5); - x2[i] = r.Uniform(3, 8); - x3[i] = r.Uniform(9, 15); - y1[i] = 3 + 2*x1[i] + x1[i]*x1[i] + r.Gaus(); - y2[i] = 3 + 2*x2[i] + x2[i]*x2[i] + r.Gaus()*10; - e1[i] = 1; - e2[i] = 10; - e3[i] = 20; - y3[i] = 3 + 2*x3[i] + x3[i]*x3[i] + r.Gaus()*20; + xvalues1[i] = r.Uniform(0.1, 5); + xvalues2[i] = r.Uniform(3, 8); + xvalues3[i] = r.Uniform(9, 15); + yvalues1[i] = 3 + 2*xvalues1[i] + xvalues1[i]*xvalues1[i] + r.Gaus(); + yvalues2[i] = 3 + 2*xvalues2[i] + xvalues2[i]*xvalues2[i] + r.Gaus()*10; + evalues1[i] = 1; + evalues2[i] = 10; + evalues3[i] = 20; + yvalues3[i] = 3 + 2*xvalues3[i] + xvalues3[i]*xvalues3[i] + r.Gaus()*20; } //create the graphs and set their drawing options - TGraphErrors *gr1 = new TGraphErrors(n, x1, y1, 0, e1); - TGraphErrors *gr2 = new TGraphErrors(n, x2, y2, 0, e2); - TGraphErrors *gr3 = new TGraphErrors(n, x3, y3, 0, e3); + TGraphErrors *gr1 = new TGraphErrors(n, xvalues1, yvalues1, 0, evalues1); + TGraphErrors *gr2 = new TGraphErrors(n, xvalues2, yvalues2, 0, evalues2); + TGraphErrors *gr3 = new TGraphErrors(n, xvalues3, yvalues3, 0, evalues3); gr1->SetLineColor(kRed); gr2->SetLineColor(kBlue); gr2->SetMarkerStyle(24); @@ -83,15 +83,15 @@ void fitMultiGraph() void fitminuit() { Int_t n = 30; - Double_t *x1 = new Double_t[n]; - Double_t *x2 = new Double_t[n]; - Double_t *x3 = new Double_t[n]; - Double_t *y1 = new Double_t[n]; - Double_t *y2 = new Double_t[n]; - Double_t *y3 = new Double_t[n]; - Double_t *e1 = new Double_t[n]; - Double_t *e2 = new Double_t[n]; - Double_t *e3 = new Double_t[n]; + Double_t *xvalues1 = new Double_t[n]; + Double_t *xvalues2 = new Double_t[n]; + Double_t *xvalues3 = new Double_t[n]; + Double_t *yvalues1 = new Double_t[n]; + Double_t *yvalues2 = new Double_t[n]; + Double_t *yvalues3 = new Double_t[n]; + Double_t *evalues1 = new Double_t[n]; + Double_t *evalues2 = new Double_t[n]; + Double_t *evalues3 = new Double_t[n]; Double_t *xtotal = new Double_t[n*3]; Double_t *ytotal = new Double_t[n*3]; Double_t *etotal = new Double_t[n*3]; @@ -99,27 +99,27 @@ void fitminuit() TRandom r; Int_t i; for (i=0; i<n; i++) { - x1[i] = r.Uniform(-3, -1); - x2[i] = r.Uniform(-1, 1); - x3[i] = r.Uniform(1, 3); - y1[i] = TMath::Gaus(x1[i], 0, 1); - y2[i] = TMath::Gaus(x2[i], 0, 1); - e1[i] = 0.00001; - e2[i] = 0.00001; - e3[i] = 0.00001; - y3[i] = TMath::Gaus(x3[i], 0, 1); + xvalues1[i] = r.Uniform(-3, -1); + xvalues2[i] = r.Uniform(-1, 1); + xvalues3[i] = r.Uniform(1, 3); + yvalues1[i] = TMath::Gaus(xvalues1[i], 0, 1); + yvalues2[i] = TMath::Gaus(xvalues2[i], 0, 1); + evalues1[i] = 0.00001; + evalues2[i] = 0.00001; + evalues3[i] = 0.00001; + yvalues3[i] = TMath::Gaus(xvalues3[i], 0, 1); } for (i=0; i<n; i++) - {xtotal[i]=x1[i]; ytotal[i]=y1[i]; etotal[i]=0.00001;} + {xtotal[i]=xvalues1[i]; ytotal[i]=yvalues1[i]; etotal[i]=0.00001;} for (i=n; i<2*n; i++) - {xtotal[i] = x2[i-n]; ytotal[i]=y2[i-n]; etotal[i]=0.00001;} + {xtotal[i] = xvalues2[i-n]; ytotal[i]=yvalues2[i-n]; etotal[i]=0.00001;} for (i=2*n; i<3*n; i++) - {xtotal[i] = x3[i-2*n]; ytotal[i]=y3[i-2*n]; etotal[i]=0.00001;} + {xtotal[i] = xvalues3[i-2*n]; ytotal[i]=yvalues3[i-2*n]; etotal[i]=0.00001;} //create the graphs and set their drawing options - TGraphErrors *gr1 = new TGraphErrors(n, x1, y1, 0, e1); - TGraphErrors *gr2 = new TGraphErrors(n, x2, y2, 0, e2); - TGraphErrors *gr3 = new TGraphErrors(n, x3, y3, 0, e3); + TGraphErrors *gr1 = new TGraphErrors(n, xvalues1, yvalues1, 0, evalues1); + TGraphErrors *gr2 = new TGraphErrors(n, xvalues2, yvalues2, 0, evalues2); + TGraphErrors *gr3 = new TGraphErrors(n, xvalues3, yvalues3, 0, evalues3); TGraphErrors *grtotal = new TGraphErrors(n*3, xtotal, ytotal, 0, etotal); TMultiGraph *mg=new TMultiGraph("mg", "TMultiGraph of 3 TGraphErrors"); mg->Add(gr1); diff --git a/tutorials/fit/fitcont.C b/tutorials/fit/fitcont.C index 4332be96ce8..0a1eeb2842e 100644 --- a/tutorials/fit/fitcont.C +++ b/tutorials/fit/fitcont.C @@ -1,5 +1,6 @@ /// \file /// \ingroup tutorial_fit +/// \notebook /// Example illustrating how to draw the n-sigma contour of a Minuit fit. /// To get the n-sigma contour the ERRDEF parameter in Minuit has to set /// to n^2. The fcn function has to be set before the routine is called. diff --git a/tutorials/fit/fitslicesy.C b/tutorials/fit/fitslicesy.C index 4c39b36d526..2c71d91b9a0 100644 --- a/tutorials/fit/fitslicesy.C +++ b/tutorials/fit/fitslicesy.C @@ -23,8 +23,8 @@ void fitslicesy() { gStyle->SetTitleH(0.1); // Connect the input file and get the 2-d histogram in memory - TString dir = gROOT.GetTutorialsDir() - dir.Append("/hsimple.C") + TString dir = gROOT->GetTutorialsDir(); + dir.Append("/hsimple.C"); dir.ReplaceAll("/./","/"); if (!gInterpreter->IsLoaded(dir.Data())) gInterpreter->LoadMacro(dir.Data()); TFile *hsimple = (TFile*)gROOT->ProcessLineFast("hsimple(1)"); diff --git a/tutorials/fit/langaus.C b/tutorials/fit/langaus.C index 72d4cccb69b..297b7804387 100644 --- a/tutorials/fit/langaus.C +++ b/tutorials/fit/langaus.C @@ -8,15 +8,15 @@ /// /// to execute this example, do: /// -/// ~~~ {.cpp} +/// ```cpp /// root > .x langaus.C -/// ~~~ +/// ``` /// /// or /// -/// ~~~ {.cpp} +/// ```cpp /// root > .x langaus.C++ -/// ~~~ +/// ``` /// /// \macro_image /// \macro_output diff --git a/tutorials/fit/line3Dfit.C b/tutorials/fit/line3Dfit.C index f75305c3182..99deed32c6d 100644 --- a/tutorials/fit/line3Dfit.C +++ b/tutorials/fit/line3Dfit.C @@ -1,5 +1,6 @@ /// \file /// \ingroup tutorial_fit +/// \notebook /// Fitting of a TGraph2D with a 3D straight line /// /// run this macro by doing: @@ -98,8 +99,8 @@ Int_t line3Dfit() Int_t nd = 10000; -// double xmin = 0; double ymin = 0; -// double xmax = 10; double ymax = 10; + // double xmin = 0; double ymin = 0; + // double xmax = 10; double ymax = 10; TGraph2D * gr = new TGraph2D(); @@ -129,7 +130,9 @@ Int_t line3Dfit() SumDistance2 sdist(gr); #ifdef __CINT__ ROOT::Math::Functor fcn(&sdist,4,"SumDistance2"); + cout << "CINT" << endl; #else + cout << "NOT CINT" << endl; ROOT::Math::Functor fcn(sdist,4); #endif // set the function and the initial parameter values diff --git a/tutorials/fit/myfit.C b/tutorials/fit/myfit.C index e292b6d0044..20c693970c1 100644 --- a/tutorials/fit/myfit.C +++ b/tutorials/fit/myfit.C @@ -25,8 +25,8 @@ Double_t fitf(Double_t *x, Double_t *par) } void myfit() { - TString dir = gROOT.GetTutorialsDir() - dir.Append("/hsimple.C") + TString dir = gROOT->GetTutorialsDir(); + dir.Append("/hsimple.C"); dir.ReplaceAll("/./","/"); if (!gInterpreter->IsLoaded(dir.Data())) gInterpreter->LoadMacro(dir.Data()); TFile *hsimple = (TFile*)gROOT->ProcessLineFast("hsimple(1)"); diff --git a/tutorials/graphics/anim.C b/tutorials/graphics/anim.C index 8208fcdd2a9..efdaaedb81b 100644 --- a/tutorials/graphics/anim.C +++ b/tutorials/graphics/anim.C @@ -1,6 +1,5 @@ /// \file /// \ingroup tutorial_graphics -/// \notebook /// Macro illustrating how to animate a picture using a Timer. /// /// \macro_code diff --git a/tutorials/graphics/earth.C b/tutorials/graphics/earth.C index 05aceee301a..66f2470b8de 100644 --- a/tutorials/graphics/earth.C +++ b/tutorials/graphics/earth.C @@ -27,8 +27,8 @@ TCanvas *earth(){ TH2F *hs = new TH2F("hs","Sinusoidal",180, -180, 180, 181, -90.5, 90.5); TH2F *hp = new TH2F("hp","Parabolic", 180, -180, 180, 181, -90.5, 90.5); - TString dat = gSystem->UnixPathName(__FILE__); - dat.ReplaceAll(".C",".dat"); + TString dat = gROOT->GetTutorialsDir(); + dat.Append("/graphics/earth.dat"); dat.ReplaceAll("/./","/"); ifstream in; diff --git a/tutorials/graphics/polytest1.C b/tutorials/graphics/polytest1.C index f6bf2b4506b..5712c2ad8a8 100644 --- a/tutorials/graphics/polytest1.C +++ b/tutorials/graphics/polytest1.C @@ -1,5 +1,6 @@ /// \file /// \ingroup tutorial_graphics +/// \notebook /// This macro is testing the "compacting" algorithm in TPadPainter. /// It reduces the number of polygon's vertices using actual pixel coordinates. /// diff --git a/tutorials/graphics/psview.C b/tutorials/graphics/psview.C index 6e4c2f7b8ed..3cd25dd1250 100644 --- a/tutorials/graphics/psview.C +++ b/tutorials/graphics/psview.C @@ -1,6 +1,5 @@ /// \file /// \ingroup tutorial_graphics -/// \notebook /// An example how to display PS, EPS, PDF files in canvas. /// To load a PS file in a TCanvas, the ghostscript program needs to be install. /// - On most unix systems it is installed by default. diff --git a/tutorials/graphs/graphstruct.C b/tutorials/graphs/graphstruct.C index 999dc948df1..92edfee01f6 100644 --- a/tutorials/graphs/graphstruct.C +++ b/tutorials/graphs/graphstruct.C @@ -1,5 +1,6 @@ /// \file /// \ingroup tutorial_graphs +/// \notebook /// Draw a simple graph structure. /// The graph layout is made using graphviz. This macro creates some /// nodes and edges and change a few graphical attributes on some of them. @@ -9,6 +10,7 @@ /// /// \author Olivier Couet +void graphstruct() { TGraphStruct *gs = new TGraphStruct(); diff --git a/tutorials/graphs/motorcycle.C b/tutorials/graphs/motorcycle.C index d7e6d76fc65..8c12977bf52 100644 --- a/tutorials/graphs/motorcycle.C +++ b/tutorials/graphs/motorcycle.C @@ -1,5 +1,6 @@ /// \file /// \ingroup tutorial_graphs +/// \notebook /// Macro to test scatterplot smoothers: ksmooth, lowess, supsmu /// as described in: /// @@ -42,8 +43,8 @@ void DrawSmooth(Int_t pad, const char *title, const char *xt, const char *yt) void motorcycle() { // data taken from R library MASS: mcycle.txt - TString dir = gSystem->UnixPathName(__FILE__); - dir.ReplaceAll("motorcycle.C",""); + TString dir = gROOT->GetTutorialsDir(); + dir.Append("/graphs/"); dir.ReplaceAll("/./","/"); // read file and add to fit object diff --git a/tutorials/graphs/waves.C b/tutorials/graphs/waves.C index 05602ee73d7..d2e1e8f425a 100644 --- a/tutorials/graphs/waves.C +++ b/tutorials/graphs/waves.C @@ -1,6 +1,6 @@ /// \file /// \ingroup tutorial_graphs -/// +/// \notebook /// Hint: Spherical waves /// /// \macro_image diff --git a/tutorials/hist/FirstContour.C b/tutorials/hist/FirstContour.C index 58c42122749..04b2da74eb9 100644 --- a/tutorials/hist/FirstContour.C +++ b/tutorials/hist/FirstContour.C @@ -13,8 +13,8 @@ void FirstContour() { - TString dir = gSystem->UnixPathName(__FILE__); - dir.ReplaceAll("FirstContour.C","../hsimple.C"); + TString dir = gROOT->GetTutorialsDir(); + dir.Append("/hsimple.C"); dir.ReplaceAll("/./","/"); if (!gInterpreter->IsLoaded(dir.Data())) gInterpreter->LoadMacro(dir.Data()); TFile *file = (TFile*)gROOT->ProcessLineFast("hsimple(1)"); diff --git a/tutorials/hist/candleplotstack.C b/tutorials/hist/candleplotstack.C index 4f0f1f1ca6c..821aedcc6a8 100644 --- a/tutorials/hist/candleplotstack.C +++ b/tutorials/hist/candleplotstack.C @@ -1,5 +1,6 @@ /// \file /// \ingroup tutorial_hist +/// \notebook /// Example showing how a THStack with candle plot option. /// /// \macro_image diff --git a/tutorials/hist/draw2dopt.C b/tutorials/hist/draw2dopt.C index 99446adb808..8efc19428b0 100644 --- a/tutorials/hist/draw2dopt.C +++ b/tutorials/hist/draw2dopt.C @@ -7,6 +7,7 @@ /// /// \author Rene Brun +void draw2dopt() { gStyle->SetOptStat(0); gStyle->SetPalette(1); diff --git a/tutorials/hist/exec1.C b/tutorials/hist/exec1.C index b0d80427b83..7446e0cbe18 100644 --- a/tutorials/hist/exec1.C +++ b/tutorials/hist/exec1.C @@ -1,6 +1,5 @@ /// \file /// \ingroup tutorial_hist -/// \notebook /// Echo object at mouse position. /// Example of macro called when a pad is redrawn /// one must create a TExec object in the following way diff --git a/tutorials/hist/h1draw.C b/tutorials/hist/h1draw.C index 1c7a4303518..96605209cf8 100644 --- a/tutorials/hist/h1draw.C +++ b/tutorials/hist/h1draw.C @@ -25,8 +25,8 @@ void h1draw() { - TString dir = gSystem->UnixPathName(__FILE__); - dir.ReplaceAll("h1draw.C","../hsimple.C"); + TString dir = gROOT->GetTutorialsDir(); + dir.Append("/hsimple.C"); dir.ReplaceAll("/./","/"); if (gBenchmark->GetBench("hsimple") < 0) gInterpreter->LoadMacro(dir.Data()); TFile *example = (TFile*)gROOT->ProcessLineFast("hsimple(1)"); diff --git a/tutorials/hist/hbars.C b/tutorials/hist/hbars.C index 491526b1a33..81aad5bc085 100644 --- a/tutorials/hist/hbars.C +++ b/tutorials/hist/hbars.C @@ -12,8 +12,8 @@ TCanvas *hbars() { cout << gSystem->DirName(__FILE__) << endl; // Try to open first the file cernstaff.root in tutorials/tree directory - TString filedir = gSystem->DirName(__FILE__); - filedir += TString("/../tree/"); + TString filedir = gROOT->GetTutorialsDir(); + filedir += TString("/tree/"); TString filename = "cernstaff.root"; bool fileNotFound = gSystem->AccessPathName(filename); // note opposite return code diff --git a/tutorials/hist/th2polyHoneycomb.C b/tutorials/hist/th2polyHoneycomb.C index 1d58f486a21..45fc31eaa79 100644 --- a/tutorials/hist/th2polyHoneycomb.C +++ b/tutorials/hist/th2polyHoneycomb.C @@ -1,6 +1,5 @@ /// \file /// \ingroup tutorial_hist -/// \notebook /// This tutorial illustrates how to create an histogram with hexagonal /// bins (TH2Poly), fill it and draw it using GL. /// diff --git a/tutorials/hist/th2polyUSA.C b/tutorials/hist/th2polyUSA.C index 1086cd9b1b9..84aa00ac0ba 100644 --- a/tutorials/hist/th2polyUSA.C +++ b/tutorials/hist/th2polyUSA.C @@ -1,6 +1,5 @@ /// \file /// \ingroup tutorial_hist -/// \notebook /// This tutorial illustrates how to create an histogram with polygonal /// bins (TH2Poly), fill it and draw it using GL. The initial data are stored /// in TMultiGraphs. They represent the USA. diff --git a/tutorials/hsimple.C b/tutorials/hsimple.C index 2d819f5ab3a..ebcd1edd6c2 100644 --- a/tutorials/hsimple.C +++ b/tutorials/hsimple.C @@ -1,5 +1,6 @@ /// \file /// \ingroup Tutorials +/// \notebook /// This program creates : /// - a one dimensional histogram /// - a two dimensional histogram @@ -33,8 +34,7 @@ TFile *hsimple(Int_t get=0) { TString filename = "hsimple.root"; - TString dir = gSystem->UnixPathName(__FILE__); - dir.ReplaceAll("hsimple.C",""); + TString dir = gROOT->GetTutorialsDir(); dir.ReplaceAll("/./","/"); TFile *hfile = 0; if (get) { @@ -106,6 +106,6 @@ TFile *hsimple(Int_t get=0) c1->Modified(); return hfile; -// Note that the file is automatically close when application terminates -// or when the file destructor is called. + // Note that the file is automatically close when application terminates + // or when the file destructor is called. } diff --git a/tutorials/io/copyFiles.C b/tutorials/io/copyFiles.C index 8ebce6c1dbb..e6fa0e46ce2 100644 --- a/tutorials/io/copyFiles.C +++ b/tutorials/io/copyFiles.C @@ -1,5 +1,6 @@ /// \file /// \ingroup tutorial_io +/// \notebook -nodraw /// Example of script showing how to copy all objects (including directories) /// from a source file. /// For each input file, a new directory is created in the current directory diff --git a/tutorials/io/dirs.C b/tutorials/io/dirs.C index 55bf234b75d..9b3f3e41098 100644 --- a/tutorials/io/dirs.C +++ b/tutorials/io/dirs.C @@ -1,5 +1,6 @@ /// \file /// \ingroup tutorial_io +/// \notebook -nodraw /// This macro illustrates how to create a hierarchy of directories /// in a Root file. /// Ten directories called plane0, plane1, ..., plane9 are created. diff --git a/tutorials/io/fildir.C b/tutorials/io/fildir.C index bb777e7369c..7466b2c637a 100644 --- a/tutorials/io/fildir.C +++ b/tutorials/io/fildir.C @@ -1,5 +1,6 @@ /// \file /// \ingroup tutorial_io +/// \notebook /// This macro displays the ROOT Directory data structure /// /// \macro_image diff --git a/tutorials/io/file.C b/tutorials/io/file.C index 96b5fad8072..daf9f722307 100644 --- a/tutorials/io/file.C +++ b/tutorials/io/file.C @@ -1,5 +1,6 @@ /// \file /// \ingroup tutorial_io +/// \notebook /// This macro displays the physical ROOT file structure /// /// \macro_image diff --git a/tutorials/io/hadd.C b/tutorials/io/hadd.C index 49230efb79b..d6f250d4071 100644 --- a/tutorials/io/hadd.C +++ b/tutorials/io/hadd.C @@ -1,5 +1,6 @@ /// \file /// \ingroup tutorial_io +/// \notebook -nodraw /// Macro to add histogram files /// This macro is kept for didactical purposes only: use instead the executable $ROOTSYS/bin/hadd ! /// diff --git a/tutorials/io/importCode.C b/tutorials/io/importCode.C index bcf57d14074..9799610d861 100644 --- a/tutorials/io/importCode.C +++ b/tutorials/io/importCode.C @@ -1,5 +1,6 @@ /// \file /// \ingroup tutorial_io +/// \notebook -nodraw /// Example of script showing how to create a ROOT file with subdirectories. /// The script scans a given directory tree and recreates the same structure in the ROOT file. /// All source files of type .h,cxx,c,dat,py are imported as TMacro objects. @@ -53,6 +54,7 @@ void importdir(const char *dirname) { } void importCode() { TFile *f = new TFile("code.root","recreate"); - importdir("../tutorials"); //change the directory as you like + TString dir = gROOT->GetTutorialsDir(); + importdir(dir); //change the directory as you like delete f; } diff --git a/tutorials/io/loopdir.C b/tutorials/io/loopdir.C index 7b136288173..72fbee74ccc 100644 --- a/tutorials/io/loopdir.C +++ b/tutorials/io/loopdir.C @@ -1,5 +1,6 @@ /// \file /// \ingroup tutorial_io +/// \notebook -nodraw /// Example of script to loop on all the objects of a ROOT file directory /// and print on Postscript all TH1 derived objects. /// This script uses the file generated by tutorial hsimple.C diff --git a/tutorials/io/mergeSelective.C b/tutorials/io/mergeSelective.C index 4532e6a505d..f71e9ce8eec 100644 --- a/tutorials/io/mergeSelective.C +++ b/tutorials/io/mergeSelective.C @@ -1,5 +1,6 @@ /// \file /// \ingroup tutorial_io +/// \notebook /// Merge only part of the content of a set of files. /// This macro demonstrates how to merge only a part of the content of a set /// of input files, specified via the interface. @@ -17,8 +18,8 @@ /// /// 2. kSkipListed: via <tt>TFileMerger::PartialMerge(kSkipListed)</tt> /// This will skip merging of specified objects. If a folder is specified, its -/// whole content will be skipped. -/// +/// whole content will be skipped. +/// /// Important note: the kOnlyListed and kSkipListed flags have to be bitwise OR-ed /// on top of the merging defaults: kAll | kIncremental (as in the example) /// diff --git a/tutorials/io/readCode.C b/tutorials/io/readCode.C index d4e54790c9b..e124830153b 100644 --- a/tutorials/io/readCode.C +++ b/tutorials/io/readCode.C @@ -1,5 +1,6 @@ /// \file /// \ingroup tutorial_io +/// \notebook -nodraw /// Example of script showing how to navigate in a ROOT file /// with sub-directories and read the objects in each sub-directory. /// This example uses the file produced by the tutorial importCode.C diff --git a/tutorials/io/testMergeCont.C b/tutorials/io/testMergeCont.C index 244b6e621cd..96f2cbef85d 100644 --- a/tutorials/io/testMergeCont.C +++ b/tutorials/io/testMergeCont.C @@ -1,5 +1,6 @@ /// \file /// \ingroup tutorial_io +/// \notebook /// Macro demonstrating the merging of containers. /// \macro_code /// @@ -7,29 +8,6 @@ TFile *f; -TSeqCollection *GetCollection(); - -void testMergeCont() -{ - TString tutdir = gROOT->GetTutorialsDir(); - gROOT->LoadMacro(tutdir+"/hsimple.C"); - TList *list = (TList *)GetCollection(); - TList *inputs = new TList(); - for (Int_t i=0; i<10; i++) { - inputs->AddAt(GetCollection(),0); - list->Merge(inputs); - inputs->Delete(); - f->Close(); - } - delete inputs; - TH1F *hpx = (TH1F*)(((TList*)list->At(1))->At(0)); - printf("============================================\n"); - printf("Total hpx: %d entries\n", (int)hpx->GetEntries()); - hpx->Draw(); - list->Delete(); - delete list; -} - TSeqCollection *GetCollection() { @@ -58,3 +36,24 @@ TSeqCollection *GetCollection() l0->Add(l01); return l0; } + +void testMergeCont() +{ + TString tutdir = gROOT->GetTutorialsDir(); + gROOT->LoadMacro(tutdir+"/hsimple.C"); + TList *list1 = (TList *)GetCollection(); + TList *inputs = new TList(); + for (Int_t i=0; i<10; i++) { + inputs->AddAt(GetCollection(),0); + list1->Merge(inputs); + inputs->Delete(); + f->Close(); + } + delete inputs; + TH1F *hpx = (TH1F*)(((TList*)list1->At(1))->At(0)); + printf("============================================\n"); + printf("Total hpx: %d entries\n", (int)hpx->GetEntries()); + hpx->Draw(); + list1->Delete(); + delete list1; +} -- GitLab