diff --git a/documentation/doxygen/converttonotebook.py b/documentation/doxygen/converttonotebook.py index f7383c96fabd5..a4bd96b7deb4d 100644 --- a/documentation/doxygen/converttonotebook.py +++ b/documentation/doxygen/converttonotebook.py @@ -64,7 +64,7 @@ # for the script to work correctly. gTypesList = ["void", "int", "Int_t", "TF1", "string", "bool", "double", "float", "char", "TCanvas", "TTree", "TString", "TSeqCollection", "Double_t", "TFile", "Long64_t", "Bool_t", "TH1", - "RooDataSet", "RooWorkspace" , "HypoTestInverterResult" , "TVectorD" , "TArrayF"] + "RooDataSet", "RooWorkspace" , "HypoTestInverterResult" , "TVectorD" , "TArrayF", "UInt_t"] # ------------------------------------- # -------- Fuction definitions--------- @@ -262,6 +262,8 @@ def readHeaderCpp(text): for line in lines[i:]: newtext += (line + "\n") description = description.replace("\\f$", "$") + description = description.replace("\\f[", "$$") + description = description.replace("\\f]", "$$") return newtext, description, author, isNotebook, isJsroot, nodraw, needsHeaderFile @@ -320,7 +322,10 @@ def cppComments(text): if line.startswith("//") and not inComment: # True if first line of comment inComment = True newtext += "# \n" - newtext += ("# " + line[2:]+"\n") + if line[2:].lstrip().startswith("#"): # Don't use .capitalize() if line starts with hash, ie it is a header + newtext += ("# " + line[2:]+"\n") + else: + newtext += ("# " + line[2:].lstrip().capitalize()+"\n") elif inComment and not line.startswith("//"): # True if first line after comment inComment = False newtext += "# \n" @@ -427,7 +432,7 @@ def split(text): newHelpers.append("\n# \n " + helperDescription + " \n# \n%%cpp -d\n" + helper) rest = rest.rstrip("\n /") # remove newlines and empty comments at the end of string - + return main, newHelpers, rest @@ -488,47 +493,53 @@ def processmain(text): ... }''') ('TCanvas function(){\\n content of function\\n spanning several\\n lines\\n return c1\\n}', '\\n# \\n# Call the main function \\n# \\nfunction();', True , '') """ + argumentsCell = '' - argumentsre = re.compile(r'(?<=\().*?(?=\))', flags = re.DOTALL | re.MULTILINE) - arguments = argumentsre.search(text) - if len(arguments.group()) > 3: - print arguments.group() - argumentsCell = "# \n Arguments are defined. \n# \n" - #argumentList = arguments.group().split(",") - individualArgumentre = re.compile(r'[^/\n,]*?=[^/\n,]*') #, flags = re.DOTALL) #| re.MULTILINE) - argumentList=individualArgumentre.findall(arguments.group()) - for argument in argumentList: print "ARGUMENT:", argument , "\n\n\n" - for argument in argumentList: - argumentsCell += argument.strip("\n ") + ";\n" - argumentsCell += "# \n" + if text: + argumentsre = re.compile(r'(?<=\().*?(?=\))', flags = re.DOTALL | re.MULTILINE) + arguments = argumentsre.search(text) + + if len(arguments.group()) > 3: + argumentsCell = "# \n Arguments are defined. \n# \n" + individualArgumentre = re.compile(r'[^/\n,]*?=[^/\n,]*') #, flags = re.DOTALL) #| re.MULTILINE) + argumentList=individualArgumentre.findall(arguments.group()) + for argument in argumentList: + argumentsCell += argument.strip("\n ") + ";\n" + argumentsCell += "# \n" return text, argumentsCell # now define text transformers def removePaletteEditor(code): - return code.replace("img->StartPaletteEditor();", "") + code = code.replace("img->StartPaletteEditor();", "") + code = code.replace("Open the color editor", "") + return code + def runEventExe(code): if "copytree" in tutName: return "# \n.! $ROOTSYS/test/eventexe 1000 1 1 1 \n" + code return code + def getLibMathMore(code): if "quasirandom" == tutName: return "# \ngSystem->Load(\"libMathMore\"); \n# \n" + code return code + def roofitRemoveSpacesComments(code): def changeString(matchObject): matchString = matchObject.group() + matchString = matchString[0] + " " + matchString[1:] matchString = matchString.replace(" " , "THISISASPACE") matchString = matchString.replace(" " , "") matchString = matchString.replace("THISISASPACE" , " ") return matchString - newcode = re.sub("#\s\s\w\s[\w-]\s\w.*", changeString , code) + newcode = re.sub("#\s\s?\w\s[\w-]\s\w.*", changeString , code) return newcode def declareNamespace(code): @@ -549,34 +560,38 @@ def rs401dGetFiles(code): """#if !defined(__CINT__) || defined(__MAKECINT__)\n#include "../tutorials/roostats/NuMuToNuE_Oscillation.h"\n#include "../tutorials/roostats/NuMuToNuE_Oscillation.cxx" // so that it can be executed directly\n#else\n#include "../tutorials/roostats/NuMuToNuE_Oscillation.cxx+" // so that it can be executed directly\n#endif""" , """std::string tutDir = gROOT->GetTutorialsDir();\nTString headerDir = TString::Format("#include \\\"%s/roostats/NuMuToNuE_Oscillation.h\\\"", tutDir.c_str());\nTString impDir = TString::Format("#include \\\"%s/roostats/NuMuToNuE_Oscillation.cxx\\\"", tutDir.c_str());\ngROOT->ProcessLine(headerDir);\ngROOT->ProcessLine(impDir);""") return code -def foamRemoveIfndef(code): - if tutName == "foam_demo": - code = code.replace("#if defined(__CINT__) && !defined(__MAKECINT__)\n{\n std::cout << \"Using ACliC to run this macro since it uses custom classes\" << std::endl;\n TString macroFileName = gSystem->UnixPathName(__FILE__);\n gSystem->CompileMacro(macroFileName, \"k\");\n foam_demo();\n}\n#else","") - code = code.replace("#endif", "") - return code - def declareIncludes(code): - print code - code = re.sub(r"# \s*#include", "# \n%%cpp -d\n#include" , code) - print code + if tutName != "fitcont": + code = re.sub(r"# \s*#include", "# \n%%cpp -d\n#include" , code) return code + def tree4GetFiles(code): if tutName == "tree4": code = code.replace( - """#include \"../test/Event.h\"""" , """std::string tutDir = gROOT->GetTutorialsDir();\nTString headerDir = TString::Format("#include \\\"%s/roostats/NuMuToNuE_Oscillation.h\\\"", tutDir.c_str());\nTString impDir = TString::Format("#include \\\"%s/roostats/NuMuToNuE_Oscillation.cxx\\\"", tutDir.c_str());\ngROOT->ProcessLine(headerDir);\ngROOT->ProcessLine(impDir);""") + """#include \"../test/Event.h\"""" , """# \nTString dir = "$ROOTSYS/test/Event.h";\ngSystem->ExpandPathName(dir);\nTString includeCommand = TString::Format("#include \\\"%s\\\"" , dir.Data());\ngROOT->ProcessLine(includeCommand);""") return code + def fixes(code): codeTransformers=[removePaletteEditor, runEventExe, getLibMathMore, roofitRemoveSpacesComments, declareNamespace, rs401dGetFiles , - foamRemoveIfndef, declareIncludes] + declareIncludes, tree4GetFiles] for transformer in codeTransformers: code = transformer(code) + return code + +def changeMarkdown(code): + code = code.replace("~~~" , "```") + code = code.replace("{.cpp}", "cpp") + code = code.replace("{.bash}", "bash") + return code + + def isCpp(): """ Return True if extension is a C++ file @@ -607,7 +622,7 @@ def mainfunction(text): main, helpers, rest = split(text) main, argumentsCell = processmain(main) main = cppComments(unindenter(cppFunction(main))) # Remove function, Unindent, and convert comments to Markdown cells - + if argumentsCell: main = argumentsCell + main @@ -632,11 +647,14 @@ def mainfunction(text): # Perform last minute fixes to the notebook, used for specific fixes needed by some tutorials text = fixes(text) + + # Change to standard Markdown + newDescription = changeMarkdown(description) # Add the title and header of the notebook - text = "# \n# # %s\n%s# \n# \n# **Author:** %s \n# This notebook tutorial was automatically generated " \ - "with [ROOTBOOK-izer (Beta)](https://github.com/root-mirror/root/blob/master/documentation/doxygen/converttonotebook.py) " \ - "from the macro found in the ROOT repository on %s.\n# \n%s" % (tutTitle, description, author, date, text) + text = "# \n# # %s\n%s# \n# \n# **Author:** %s \n# This notebook tutorial was automatically generated " \ + "with ROOTBOOK-izer (Beta) " \ + "from the macro found in the ROOT repository on %s.\n# \n%s" % (tutTitle, newDescription, author, date, text) # Add cell at the end of the notebook that draws all the canveses. Add a Markdown cell before explaining it. if isJsroot and not nodraw: diff --git a/tutorials/cont/TListAndSTL.C b/tutorials/cont/TListAndSTL.C index 28068dc785e2c..5366bd22e9e21 100644 --- a/tutorials/cont/TListAndSTL.C +++ b/tutorials/cont/TListAndSTL.C @@ -68,11 +68,11 @@ void TListAndSTL() } - //->>>>>>> Example #1 <<<<<<<- + // ### Example #1 // running the std::for_each algorithm on the list for_each(list1.begin(), list1.end(), SEnumFunctor()); - //->>>>>>> Example #2 <<<<<<<- + // ### Example #2 // we can try to find something in the container // using the std::find_if algorithm on the list string strToFind("test string #4"); diff --git a/tutorials/eve/track.C b/tutorials/eve/track.C index 38302fc45c0cf..8e87dbc0b7196 100644 --- a/tutorials/eve/track.C +++ b/tutorials/eve/track.C @@ -4,7 +4,7 @@ /// field configurations. /// Needs to be run in compiled mode. /// root -/// ~~~ {.cpp} +/// ~~~{.cpp} /// .L track.C+ /// track(3, kTRUE) /// ~~~ diff --git a/tutorials/fft/FFT.C b/tutorials/fft/FFT.C index 7f850a83504c1..fd727e5c090bc 100644 --- a/tutorials/fft/FFT.C +++ b/tutorials/fft/FFT.C @@ -47,7 +47,8 @@ void FFT() { - //********* Histograms ********// + // Histograms + // ========= //prepare the canvas for drawing TCanvas *myc = new TCanvas("myc", "Fast Fourier Transform", 800, 600); myc->SetFillColor(45); @@ -153,7 +154,8 @@ void FFT() delete fft_back; fft_back=0; -//********* Data array - same transform ********// +// Data array - same transform +// =========================== //Allocate an array big enough to hold the transform output //Transform output in 1d contains, for a transform of size N, @@ -169,12 +171,12 @@ void FFT() //Make our own TVirtualFFT object (using option "K") //Third parameter (option) consists of 3 parts: - //-transform type: + //- transform type: // real input/complex output in our case - //-transform flag: + //- transform flag: // the amount of time spent in planning // the transform (see TVirtualFFT class description) - //-to create a new TVirtualFFT object (option "K") or use the global (default) + //- to create a new TVirtualFFT object (option "K") or use the global (default) Int_t n_size = n+1; TVirtualFFT *fft_own = TVirtualFFT::FFT(1, &n_size, "R2C ES K"); if (!fft_own) return; diff --git a/tutorials/fit/ConfidenceIntervals.C b/tutorials/fit/ConfidenceIntervals.C index 1cddc7cf24ccf..e34e5e063ad7a 100644 --- a/tutorials/fit/ConfidenceIntervals.C +++ b/tutorials/fit/ConfidenceIntervals.C @@ -24,7 +24,7 @@ void ConfidenceIntervals() "Confidence intervals on the fitted function",1200, 500); myc->Divide(3,1); -/////1. A graph +//### 1. A graph //Create and fill a graph Int_t ngr = 100; TGraph *gr = new TGraph(ngr); @@ -58,7 +58,7 @@ void ConfidenceIntervals() gr->SetMarkerSize(0.7); gr->Draw("psame"); -/////2. A histogram +//### 2. A histogram myc->cd(2); //Create, fill and fit a histogram Int_t nh=5000; @@ -80,7 +80,7 @@ void ConfidenceIntervals() hint->SetFillColor(2); hint->Draw("e3 same"); -/////3. A 2d graph +//### 3. A 2d graph //Create and fill the graph Int_t ngr2 = 100; Double_t z, rnd, e=0.3; diff --git a/tutorials/fit/ErrorIntegral.C b/tutorials/fit/ErrorIntegral.C index 74502d98f8494..c8833f36d6464 100644 --- a/tutorials/fit/ErrorIntegral.C +++ b/tutorials/fit/ErrorIntegral.C @@ -8,7 +8,7 @@ /// /// run the macro doing: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// .x ErrorIntegral.C /// ~~~ /// diff --git a/tutorials/fit/Ifit.C b/tutorials/fit/Ifit.C index c518d0de07317..9eae64fa765cf 100644 --- a/tutorials/fit/Ifit.C +++ b/tutorials/fit/Ifit.C @@ -8,11 +8,11 @@ /// More details on the various functions or parameters for these functions /// can be obtained in an interactive ROOT session with: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// Root > TMinuit *minuit = new TMinuit(10); /// ~~~ /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// Root > minuit->mnhelp("*") to see the list of possible keywords /// Root > minuit->mnhelp("SET") explains most parameters /// ~~~ diff --git a/tutorials/fit/NumericalMinimization.C b/tutorials/fit/NumericalMinimization.C index 2fdd58d2e76d6..df37ffe0b2738 100644 --- a/tutorials/fit/NumericalMinimization.C +++ b/tutorials/fit/NumericalMinimization.C @@ -45,14 +45,14 @@ int NumericalMinimization(const char * minName = "Minuit2", // GSLMultiFit // GSLSimAn // Genetic - ROOT::Math::Minimizer* min = + ROOT::Math::Minimizer* minimum = ROOT::Math::Factory::CreateMinimizer(minName, algoName); // set tolerance , etc... - min->SetMaxFunctionCalls(1000000); // for Minuit/Minuit2 - min->SetMaxIterations(10000); // for GSL - min->SetTolerance(0.001); - min->SetPrintLevel(1); + minimum->SetMaxFunctionCalls(1000000); // for Minuit/Minuit2 + minimum->SetMaxIterations(10000); // for GSL + minimum->SetTolerance(0.001); + minimum->SetPrintLevel(1); // create function wrapper for minimizer // a IMultiGenFunction type @@ -67,21 +67,21 @@ int NumericalMinimization(const char * minName = "Minuit2", variable[1] = r.Uniform(-20,20); } - min->SetFunction(f); + minimum->SetFunction(f); // Set the free variables to be minimized ! - min->SetVariable(0,"x",variable[0], step[0]); - min->SetVariable(1,"y",variable[1], step[1]); + minimum->SetVariable(0,"x",variable[0], step[0]); + minimum->SetVariable(1,"y",variable[1], step[1]); // do the minimization - min->Minimize(); + minimum->Minimize(); - const double *xs = min->X(); + const double *xs = minimum->X(); std::cout << "Minimum: f(" << xs[0] << "," << xs[1] << "): " - << min->MinValue() << std::endl; + << minimum->MinValue() << std::endl; // expected minimum is 0 - if ( min->MinValue() < 1.E-4 && f(xs) < 1.E-4) + if ( minimum->MinValue() < 1.E-4 && f(xs) < 1.E-4) std::cout << "Minimizer " << minName << " - " << algoName << " converged to the right minimum" << std::endl; else { diff --git a/tutorials/fit/TestBinomial.C b/tutorials/fit/TestBinomial.C index 854ff312831ef..3a37334bc2fc7 100644 --- a/tutorials/fit/TestBinomial.C +++ b/tutorials/fit/TestBinomial.C @@ -19,13 +19,13 @@ /// /// to show the bias performing 100 fits for 1000 events per "experiment" /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root[0]: .x TestBinomial.C+ /// ~~~ /// /// to show the bias performing 100 fits for 1000 events per "experiment" /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// .x TestBinomial.C+(100, 1000) /// ~~~ /// @@ -49,7 +49,7 @@ #include #include -void TestBinomial(int nloop = 100, int nevts = 100, bool plot=false, bool debug = false, int seed = 111) +void TestBinomial(int nloop = 100, int nevts = 100, bool plot = false, bool debug = false, int seed = 111) { gStyle->SetMarkerStyle(20); gStyle->SetLineWidth(2.0); @@ -101,14 +101,14 @@ void TestBinomial(int nloop = 100, int nevts = 100, bool plot=false, bool debug // First try: use a single set of parameters. // For each try, we need to find the overall normalization - Double_t norm = 0.80; + Double_t normalization = 0.80; Double_t threshold = 25.0; Double_t width = 5.0; - fM2D->SetParameter(0, norm); + fM2D->SetParameter(0, normalization); fM2D->SetParameter(1, threshold); fM2D->SetParameter(2, width); - fM2N->SetParameter(0, norm); + fM2N->SetParameter(0, normalization); fM2N->SetParameter(1, threshold); fM2N->SetParameter(2, width); Double_t integralN = fM2N->Integral(xmin, xmax); @@ -240,7 +240,7 @@ void TestBinomial(int nloop = 100, int nevts = 100, bool plot=false, bool debug } TH1D* h = dynamic_cast(hbiasNorm[fit]); - h->Fill((fnorm-norm)/enorm); + h->Fill((fnorm-normalization)/enorm); h = dynamic_cast(hbiasThreshold[fit]); h->Fill((fthreshold-threshold)/ethreshold); h = dynamic_cast(hbiasWidth[fit]); diff --git a/tutorials/fit/combinedFit.C b/tutorials/fit/combinedFit.C index 81fd3d1338568..80a8a95399022 100644 --- a/tutorials/fit/combinedFit.C +++ b/tutorials/fit/combinedFit.C @@ -65,84 +65,84 @@ struct GlobalChi2 { void combinedFit() { - TH1D * hB = new TH1D("hB","histo B",100,0,100); - TH1D * hSB = new TH1D("hSB","histo S+B",100, 0,100); - - TF1 * fB = new TF1("fB","expo",0,100); - fB->SetParameters(1,-0.05); - hB->FillRandom("fB"); - - TF1 * fS = new TF1("fS","gaus",0,100); - fS->SetParameters(1,30,5); - - hSB->FillRandom("fB",2000); - hSB->FillRandom("fS",1000); - - // perform now global fit - - TF1 * fSB = new TF1("fSB","expo + gaus(2)",0,100); - - ROOT::Math::WrappedMultiTF1 wfB(*fB,1); - ROOT::Math::WrappedMultiTF1 wfSB(*fSB,1); - - ROOT::Fit::DataOptions opt; - ROOT::Fit::DataRange rangeB; - // set the data range - rangeB.SetRange(10,90); - ROOT::Fit::BinData dataB(opt,rangeB); - ROOT::Fit::FillData(dataB, hB); - - ROOT::Fit::DataRange rangeSB; - rangeSB.SetRange(10,50); - ROOT::Fit::BinData dataSB(opt,rangeSB); - ROOT::Fit::FillData(dataSB, hSB); - - ROOT::Fit::Chi2Function chi2_B(dataB, wfB); - ROOT::Fit::Chi2Function chi2_SB(dataSB, wfSB); - - GlobalChi2 globalChi2(chi2_B, chi2_SB); - - ROOT::Fit::Fitter fitter; - - const int Npar = 6; - double par0[Npar] = { 5,5,-0.1,100, 30,10}; - - // create before the parameter settings in order to fix or set range on them - fitter.Config().SetParamsSettings(6,par0); - // fix 5-th parameter - fitter.Config().ParSettings(4).Fix(); - // set limits on the third and 4-th parameter - fitter.Config().ParSettings(2).SetLimits(-10,-1.E-4); - fitter.Config().ParSettings(3).SetLimits(0,10000); - fitter.Config().ParSettings(3).SetStepSize(5); - - fitter.Config().MinimizerOptions().SetPrintLevel(0); - fitter.Config().SetMinimizer("Minuit2","Migrad"); - - // fit FCN function directly - // (specify optionally data size and flag to indicate that is a chi2 fit) - fitter.FitFCN(6,globalChi2,0,dataB.Size()+dataSB.Size(),true); - ROOT::Fit::FitResult result = fitter.Result(); - result.Print(std::cout); - - TCanvas * c1 = new TCanvas("Simfit","Simultaneous fit of two histograms", - 10,10,700,700); - c1->Divide(1,2); - c1->cd(1); - gStyle->SetOptFit(1111); - - fB->SetFitResult( result, iparB); - fB->SetRange(rangeB().first, rangeB().second); - fB->SetLineColor(kBlue); - hB->GetListOfFunctions()->Add(fB); - hB->Draw(); - - c1->cd(2); - fSB->SetFitResult( result, iparSB); - fSB->SetRange(rangeSB().first, rangeSB().second); - fSB->SetLineColor(kRed); - hSB->GetListOfFunctions()->Add(fSB); - hSB->Draw(); + TH1D * hB = new TH1D("hB","histo B",100,0,100); + TH1D * hSB = new TH1D("hSB","histo S+B",100, 0,100); + + TF1 * fB = new TF1("fB","expo",0,100); + fB->SetParameters(1,-0.05); + hB->FillRandom("fB"); + + TF1 * fS = new TF1("fS","gaus",0,100); + fS->SetParameters(1,30,5); + + hSB->FillRandom("fB",2000); + hSB->FillRandom("fS",1000); + + // perform now global fit + + TF1 * fSB = new TF1("fSB","expo + gaus(2)",0,100); + + ROOT::Math::WrappedMultiTF1 wfB(*fB,1); + ROOT::Math::WrappedMultiTF1 wfSB(*fSB,1); + + ROOT::Fit::DataOptions opt; + ROOT::Fit::DataRange rangeB; + // set the data range + rangeB.SetRange(10,90); + ROOT::Fit::BinData dataB(opt,rangeB); + ROOT::Fit::FillData(dataB, hB); + + ROOT::Fit::DataRange rangeSB; + rangeSB.SetRange(10,50); + ROOT::Fit::BinData dataSB(opt,rangeSB); + ROOT::Fit::FillData(dataSB, hSB); + + ROOT::Fit::Chi2Function chi2_B(dataB, wfB); + ROOT::Fit::Chi2Function chi2_SB(dataSB, wfSB); + + GlobalChi2 globalChi2(chi2_B, chi2_SB); + + ROOT::Fit::Fitter fitter; + + const int Npar = 6; + double par0[Npar] = { 5,5,-0.1,100, 30,10}; + + // create before the parameter settings in order to fix or set range on them + fitter.Config().SetParamsSettings(6,par0); + // fix 5-th parameter + fitter.Config().ParSettings(4).Fix(); + // set limits on the third and 4-th parameter + fitter.Config().ParSettings(2).SetLimits(-10,-1.E-4); + fitter.Config().ParSettings(3).SetLimits(0,10000); + fitter.Config().ParSettings(3).SetStepSize(5); + + fitter.Config().MinimizerOptions().SetPrintLevel(0); + fitter.Config().SetMinimizer("Minuit2","Migrad"); + + // fit FCN function directly + // (specify optionally data size and flag to indicate that is a chi2 fit) + fitter.FitFCN(6,globalChi2,0,dataB.Size()+dataSB.Size(),true); + ROOT::Fit::FitResult result = fitter.Result(); + result.Print(std::cout); + + TCanvas * c1 = new TCanvas("Simfit","Simultaneous fit of two histograms", + 10,10,700,700); + c1->Divide(1,2); + c1->cd(1); + gStyle->SetOptFit(1111); + + fB->SetFitResult( result, iparB); + fB->SetRange(rangeB().first, rangeB().second); + fB->SetLineColor(kBlue); + hB->GetListOfFunctions()->Add(fB); + hB->Draw(); + + c1->cd(2); + fSB->SetFitResult( result, iparSB); + fSB->SetRange(rangeSB().first, rangeSB().second); + fSB->SetLineColor(kRed); + hSB->GetListOfFunctions()->Add(fSB); + hSB->Draw(); } diff --git a/tutorials/fit/fit1.C b/tutorials/fit/fit1.C index cde6abdc948d2..17a6322af4b4d 100644 --- a/tutorials/fit/fit1.C +++ b/tutorials/fit/fit1.C @@ -33,7 +33,7 @@ void fit1() { gBenchmark->Start("fit1"); // // We connect the ROOT file generated in a previous tutorial - // (see begin_html Filling histograms with random numbers from a function) end_html + // (see Filling histograms with random numbers from a function) // TString dir = gROOT->GetTutorialsDir(); dir.Append("/fit/"); diff --git a/tutorials/fit/fit2.C b/tutorials/fit/fit2.C index a92185b4c5ce9..7c4d761ab07a0 100644 --- a/tutorials/fit/fit2.C +++ b/tutorials/fit/fit2.C @@ -10,7 +10,7 @@ /// /// This example can be executed via the interpreter or ACLIC /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root > .x fit2.C /// root > .x fit2.C++ /// ~~~ diff --git a/tutorials/fit/fit2a.C b/tutorials/fit/fit2a.C index a3e00a1f8f796..5309113a663cf 100644 --- a/tutorials/fit/fit2a.C +++ b/tutorials/fit/fit2a.C @@ -11,7 +11,7 @@ /// /// This example can be executed via the interpreter or/and the compiler /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root > .x fit2a.C /// root > .x fit2a.C++ /// ~~~ diff --git a/tutorials/fit/fit2dHist.C b/tutorials/fit/fit2dHist.C index 686a3669ac30b..357735df780fe 100644 --- a/tutorials/fit/fit2dHist.C +++ b/tutorials/fit/fit2dHist.C @@ -6,29 +6,29 @@ /// /// To execute this tutorial, you can do: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root > .x fit2dHist.C (executing via CINT, slow) /// ~~~ /// /// or -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root > .x fit2dHist.C+ (executing via ACLIC , fast, with Minuit) /// root > .x fit2dHist.C+(2) (executing via ACLIC , fast, with Minuit2) /// ~~~ /// /// or using the option to fit independently the 2 histos -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root > .x fit2dHist.C+(10) (via ACLIC, fast, independent fits with Minuit) /// root > .x fit2dHist.C+(12) (via ACLIC, fast, independent fits with Minuit2) /// ~~~ /// /// Note that you can also execute this script in batch with eg, -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root -b -q "fit2dHist.C+(12)" /// ~~~ /// /// or execute interactively from the shell -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root fit2dHist.C+ /// root "fit2dHist.C+(12)" /// ~~~ @@ -66,76 +66,76 @@ Int_t npfits; void myFcn(Int_t & /*nPar*/, Double_t * /*grad*/ , Double_t &fval, Double_t *p, Int_t /*iflag */ ) { - TAxis *xaxis1 = h1->GetXaxis(); - TAxis *yaxis1 = h1->GetYaxis(); - TAxis *xaxis2 = h2->GetXaxis(); - TAxis *yaxis2 = h2->GetYaxis(); - - int nbinX1 = h1->GetNbinsX(); - int nbinY1 = h1->GetNbinsY(); - int nbinX2 = h2->GetNbinsX(); - int nbinY2 = h2->GetNbinsY(); - - double chi2 = 0; - double x[2]; - double tmp; - npfits = 0; - for (int ix = 1; ix <= nbinX1; ++ix) { - x[0] = xaxis1->GetBinCenter(ix); - for (int iy = 1; iy <= nbinY1; ++iy) { - if ( h1->GetBinError(ix,iy) > 0 ) { - x[1] = yaxis1->GetBinCenter(iy); - tmp = (h1->GetBinContent(ix,iy) - my2Dfunc(x,p))/h1->GetBinError(ix,iy); - chi2 += tmp*tmp; - npfits++; + TAxis *xaxis1 = h1->GetXaxis(); + TAxis *yaxis1 = h1->GetYaxis(); + TAxis *xaxis2 = h2->GetXaxis(); + TAxis *yaxis2 = h2->GetYaxis(); + + int nbinX1 = h1->GetNbinsX(); + int nbinY1 = h1->GetNbinsY(); + int nbinX2 = h2->GetNbinsX(); + int nbinY2 = h2->GetNbinsY(); + + double chi2 = 0; + double x[2]; + double tmp; + npfits = 0; + for (int ix = 1; ix <= nbinX1; ++ix) { + x[0] = xaxis1->GetBinCenter(ix); + for (int iy = 1; iy <= nbinY1; ++iy) { + if ( h1->GetBinError(ix,iy) > 0 ) { + x[1] = yaxis1->GetBinCenter(iy); + tmp = (h1->GetBinContent(ix,iy) - my2Dfunc(x,p))/h1->GetBinError(ix,iy); + chi2 += tmp*tmp; + npfits++; + } } - } - } - for (int ix = 1; ix <= nbinX2; ++ix) { - x[0] = xaxis2->GetBinCenter(ix); - for (int iy = 1; iy <= nbinY2; ++iy) { - if ( h2->GetBinError(ix,iy) > 0 ) { - x[1] = yaxis2->GetBinCenter(iy); - tmp = (h2->GetBinContent(ix,iy) - my2Dfunc(x,p))/h2->GetBinError(ix,iy); - chi2 += tmp*tmp; - npfits++; + } + for (int ix = 1; ix <= nbinX2; ++ix) { + x[0] = xaxis2->GetBinCenter(ix); + for (int iy = 1; iy <= nbinY2; ++iy) { + if ( h2->GetBinError(ix,iy) > 0 ) { + x[1] = yaxis2->GetBinCenter(iy); + tmp = (h2->GetBinContent(ix,iy) - my2Dfunc(x,p))/h2->GetBinError(ix,iy); + chi2 += tmp*tmp; + npfits++; + } } - } - } - fval = chi2; + } + fval = chi2; } void FillHisto(TH2D * h, int n, double * p) { - const double mx1 = p[1]; - const double my1 = p[3]; - const double sx1 = p[2]; - const double sy1 = p[4]; - const double mx2 = p[6]; - const double my2 = p[8]; - const double sx2 = p[7]; - const double sy2 = p[9]; - //const double w1 = p[0]*sx1*sy1/(p[5]*sx2*sy2); - const double w1 = 0.5; - - double x, y; - for (int i = 0; i < n; ++i) { - // generate randoms with larger gaussians - rndm.Rannor(x,y); - - double r = rndm.Rndm(1); - if (r < w1) { - x = x*sx1 + mx1; - y = y*sy1 + my1; - } - else { - x = x*sx2 + mx2; - y = y*sy2 + my2; - } - h->Fill(x,y); - - } + const double mx1 = p[1]; + const double my1 = p[3]; + const double sx1 = p[2]; + const double sy1 = p[4]; + const double mx2 = p[6]; + const double my2 = p[8]; + const double sx2 = p[7]; + const double sy2 = p[9]; + //const double w1 = p[0]*sx1*sy1/(p[5]*sx2*sy2); + const double w1 = 0.5; + + double x, y; + for (int i = 0; i < n; ++i) { + // generate randoms with larger gaussians + rndm.Rannor(x,y); + + double r = rndm.Rndm(1); + if (r < w1) { + x = x*sx1 + mx1; + y = y*sy1 + my1; + } + else { + x = x*sx2 + mx2; + y = y*sy2 + my2; + } + h->Fill(x,y); + + } } @@ -143,118 +143,118 @@ void FillHisto(TH2D * h, int n, double * p) { int fit2dHist(int option=1) { - // create two histograms - - int nbx1 = 50; - int nby1 = 50; - int nbx2 = 50; - int nby2 = 50; - double xlow1 = 0.; - double ylow1 = 0.; - double xup1 = 10.; - double yup1 = 10.; - double xlow2 = 5.; - double ylow2 = 5.; - double xup2 = 20.; - double yup2 = 20.; - - h1 = new TH2D("h1","core",nbx1,xlow1,xup1,nby1,ylow1,yup1); - h2 = new TH2D("h2","tails",nbx2,xlow2,xup2,nby2,ylow2,yup2); - - double iniParams[10] = { 100, 6., 2., 7., 3, 100, 12., 3., 11., 2. }; - // create fit function - TF2 * func = new TF2("func",my2Dfunc,xlow2,xup2,ylow2,yup2, 10); - func->SetParameters(iniParams); - - // fill Histos - int n1 = 1000000; - int n2 = 1000000; - FillHisto(h1,n1,iniParams); - FillHisto(h2,n2,iniParams); - - // scale histograms to same heights (for fitting) - double dx1 = (xup1-xlow1)/double(nbx1); - double dy1 = (yup1-ylow1)/double(nby1); - double dx2 = (xup2-xlow2)/double(nbx2); - double dy2 = (yup2-ylow2)/double(nby2); - // scale histo 2 to scale of 1 - h2->Sumw2(); - h2->Scale( ( double(n1) * dx1 * dy1 ) / ( double(n2) * dx2 * dy2 ) ); - - bool global = false; - if (option > 10) global = true; - if (global) { - // fill data structure for fit (coordinates + values + errors) - std::cout << "Do global fit" << std::endl; - // fit now all the function together - - //The default minimizer is Minuit, you can also try Minuit2 - if (option%10 == 2) TVirtualFitter::SetDefaultFitter("Minuit2"); - else TVirtualFitter::SetDefaultFitter("Minuit"); - TVirtualFitter * minuit = TVirtualFitter::Fitter(0,10); - for (int i = 0; i < 10; ++i) { - minuit->SetParameter(i, func->GetParName(i), func->GetParameter(i), 0.01, 0,0); - } - minuit->SetFCN(myFcn); - - double arglist[100]; - arglist[0] = 0; - // set print level - minuit->ExecuteCommand("SET PRINT",arglist,2); - - // minimize - arglist[0] = 5000; // number of function calls - arglist[1] = 0.01; // tolerance - minuit->ExecuteCommand("MIGRAD",arglist,2); - - //get result - double minParams[10]; - double parErrors[10]; - for (int i = 0; i < 10; ++i) { - minParams[i] = minuit->GetParameter(i); - parErrors[i] = minuit->GetParError(i); - } - double chi2, edm, errdef; - int nvpar, nparx; - minuit->GetStats(chi2,edm,errdef,nvpar,nparx); - - func->SetParameters(minParams); - func->SetParErrors(parErrors); - func->SetChisquare(chi2); - int ndf = npfits-nvpar; - func->SetNDF(ndf); - - // add to list of functions - h1->GetListOfFunctions()->Add(func); - h2->GetListOfFunctions()->Add(func); - } - else { - // fit independently - h1->Fit(func); - h2->Fit(func); - } - - // Create a new canvas. - TCanvas * c1 = new TCanvas("c1","Two HIstogram Fit example",100,10,900,800); - c1->Divide(2,2); - gStyle->SetOptFit(); - gStyle->SetStatY(0.6); - - c1->cd(1); - h1->Draw(); - func->SetRange(xlow1,ylow1,xup1,yup1); - func->DrawCopy("cont1 same"); - c1->cd(2); - h1->Draw("lego"); - func->DrawCopy("surf1 same"); - c1->cd(3); - func->SetRange(xlow2,ylow2,xup2,yup2); - h2->Draw(); - func->DrawCopy("cont1 same"); - c1->cd(4); - h2->Draw("lego"); - gPad->SetLogz(); - func->Draw("surf1 same"); - - return 0; + // create two histograms + + int nbx1 = 50; + int nby1 = 50; + int nbx2 = 50; + int nby2 = 50; + double xlow1 = 0.; + double ylow1 = 0.; + double xup1 = 10.; + double yup1 = 10.; + double xlow2 = 5.; + double ylow2 = 5.; + double xup2 = 20.; + double yup2 = 20.; + + h1 = new TH2D("h1","core",nbx1,xlow1,xup1,nby1,ylow1,yup1); + h2 = new TH2D("h2","tails",nbx2,xlow2,xup2,nby2,ylow2,yup2); + + double iniParams[10] = { 100, 6., 2., 7., 3, 100, 12., 3., 11., 2. }; + // create fit function + TF2 * func = new TF2("func",my2Dfunc,xlow2,xup2,ylow2,yup2, 10); + func->SetParameters(iniParams); + + // fill Histos + int n1 = 1000000; + int n2 = 1000000; + FillHisto(h1,n1,iniParams); + FillHisto(h2,n2,iniParams); + + // scale histograms to same heights (for fitting) + double dx1 = (xup1-xlow1)/double(nbx1); + double dy1 = (yup1-ylow1)/double(nby1); + double dx2 = (xup2-xlow2)/double(nbx2); + double dy2 = (yup2-ylow2)/double(nby2); + // scale histo 2 to scale of 1 + h2->Sumw2(); + h2->Scale( ( double(n1) * dx1 * dy1 ) / ( double(n2) * dx2 * dy2 ) ); + + bool global = false; + if (option > 10) global = true; + if (global) { + // fill data structure for fit (coordinates + values + errors) + std::cout << "Do global fit" << std::endl; + // fit now all the function together + + //The default minimizer is Minuit, you can also try Minuit2 + if (option%10 == 2) TVirtualFitter::SetDefaultFitter("Minuit2"); + else TVirtualFitter::SetDefaultFitter("Minuit"); + TVirtualFitter * minuit = TVirtualFitter::Fitter(0,10); + for (int i = 0; i < 10; ++i) { + minuit->SetParameter(i, func->GetParName(i), func->GetParameter(i), 0.01, 0,0); + } + minuit->SetFCN(myFcn); + + double arglist[100]; + arglist[0] = 0; + // set print level + minuit->ExecuteCommand("SET PRINT",arglist,2); + + // minimize + arglist[0] = 5000; // number of function calls + arglist[1] = 0.01; // tolerance + minuit->ExecuteCommand("MIGRAD",arglist,2); + + //get result + double minParams[10]; + double parErrors[10]; + for (int i = 0; i < 10; ++i) { + minParams[i] = minuit->GetParameter(i); + parErrors[i] = minuit->GetParError(i); + } + double chi2, edm, errdef; + int nvpar, nparx; + minuit->GetStats(chi2,edm,errdef,nvpar,nparx); + + func->SetParameters(minParams); + func->SetParErrors(parErrors); + func->SetChisquare(chi2); + int ndf = npfits-nvpar; + func->SetNDF(ndf); + + // add to list of functions + h1->GetListOfFunctions()->Add(func); + h2->GetListOfFunctions()->Add(func); + } + else { + // fit independently + h1->Fit(func); + h2->Fit(func); + } + + // Create a new canvas. + TCanvas * c1 = new TCanvas("c1","Two HIstogram Fit example",100,10,900,800); + c1->Divide(2,2); + gStyle->SetOptFit(); + gStyle->SetStatY(0.6); + + c1->cd(1); + h1->Draw(); + func->SetRange(xlow1,ylow1,xup1,yup1); + func->DrawCopy("cont1 same"); + c1->cd(2); + h1->Draw("lego"); + func->DrawCopy("surf1 same"); + c1->cd(3); + func->SetRange(xlow2,ylow2,xup2,yup2); + h2->Draw(); + func->DrawCopy("cont1 same"); + c1->cd(4); + h2->Draw("lego"); + gPad->SetLogz(); + func->Draw("surf1 same"); + + return 0; } diff --git a/tutorials/fit/fitLinear2.C b/tutorials/fit/fitLinear2.C index 462e456815c91..34d8fc79510aa 100644 --- a/tutorials/fit/fitLinear2.C +++ b/tutorials/fit/fitLinear2.C @@ -20,7 +20,7 @@ void fitLinear2() { Int_t n=100; Int_t i; - TRandom rand1; + TRandom randNum; 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; iGetNpar(); ++i) f_sum->SetParName(i,fnorm_exp_cb->GetParName(i) ); - //GENERATE HISTOGRAM TO FIT .............................................................. + // GENERATE HISTOGRAM TO FIT .............................................................. TStopwatch w; w.Start(); TH1D *h_sum = new TH1D("h_ExpCB", "Exponential Bkg + CrystalBall function", NBins, -5., 5.); diff --git a/tutorials/fit/fitslicesy.C b/tutorials/fit/fitslicesy.C index fbf439855cff0..3bf8a2a79d58c 100644 --- a/tutorials/fit/fitslicesy.C +++ b/tutorials/fit/fitslicesy.C @@ -35,11 +35,11 @@ void fitslicesy() { TCanvas *c1 = new TCanvas("c1","c1",700,500); c1->SetFillColor(42); c1->Divide(2,1); - TPad *left = (TPad*)c1->cd(1);; - left->Divide(1,2); + TPad *leftPad = (TPad*)c1->cd(1);; + leftPad->Divide(1,2); // Draw 2-d original histogram - left->cd(1); + leftPad->cd(1); gPad->SetTopMargin(0.12); gPad->SetFillColor(33); hpxpy->Draw(); @@ -51,13 +51,13 @@ void fitslicesy() { hpxpy->FitSlicesY(0,7,32,20); // Show fitted "mean" for each slice - left->cd(2); + leftPad->cd(2); gPad->SetFillColor(33); TH2F *hpxpy_0 = (TH2F*)hsimpleFile->Get("hpxpy_0"); hpxpy_0->Draw(); - TPad *right = (TPad*)c1->cd(2); - right->Divide(1,2); - right->cd(1); + TPad *rightPad = (TPad*)c1->cd(2); + rightPad->Divide(1,2); + rightPad->cd(1); gPad->SetTopMargin(0.12); gPad->SetLeftMargin(0.15); gPad->SetFillColor(33); @@ -65,7 +65,7 @@ void fitslicesy() { hpxpy_1->Draw(); // Show fitted "sigma" for each slice - right->cd(2); + rightPad->cd(2); gPad->SetTopMargin(0.12); gPad->SetLeftMargin(0.15); gPad->SetFillColor(33); diff --git a/tutorials/fit/langaus.C b/tutorials/fit/langaus.C index 297b7804387e3..c21816d07563a 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 289f5e66da948..30e30837568c6 100644 --- a/tutorials/fit/line3Dfit.C +++ b/tutorials/fit/line3Dfit.C @@ -5,7 +5,7 @@ /// /// run this macro by doing: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root>.x line3Dfit.C+ /// ~~~ /// diff --git a/tutorials/fit/minuit2FitBench.C b/tutorials/fit/minuit2FitBench.C index 28dd3455159a1..ce155f150fca3 100644 --- a/tutorials/fit/minuit2FitBench.C +++ b/tutorials/fit/minuit2FitBench.C @@ -21,8 +21,7 @@ #include "TMath.h" #include "TROOT.h" #include "TFrame.h" - -//#include "Fit/FitConfig.h" +/*#include "Fit/FitConfig.h"*/ TF1 *fitFcn; diff --git a/tutorials/foam/foam_demo.C b/tutorials/foam/foam_demo.C index bebbb3b11b6ff..5d78c7c613ca4 100644 --- a/tutorials/foam/foam_demo.C +++ b/tutorials/foam/foam_demo.C @@ -5,7 +5,7 @@ /// /// To run this macro type from CINT command line /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root [0] gSystem->Load("libFoam.so") /// root [1] .x foam_demo.C+ /// ~~~ @@ -60,7 +60,7 @@ Int_t foam_demo() TFile RootFile("foam_demo.root","RECREATE","histograms"); long loop; Double_t MCresult,MCerror,MCwt; - //========================================================= + //----------------------------------------- long NevTot = 50000; // Total MC statistics Int_t kDim = 2; // total dimension Int_t nCells = 500; // Number of Cells @@ -70,12 +70,12 @@ Int_t foam_demo() Int_t OptDrive = 2; // (D=2) Option, type of Drive =0,1,2 for TrueVol,Sigma,WtMax Int_t EvPerBin = 25; // Maximum events (equiv.) per bin in buid-up Int_t Chat = 1; // Chat level - //========================================================= + //----------------------------------------- TRandom *PseRan = new TRandom3(); // Create random number generator TFoam *FoamX = new TFoam("FoamX"); // Create Simulator TFoamIntegrand *rho= new TFDISTR(); PseRan->SetSeed(4357); - //========================================================= + //----------------------------------------- cout<<"***** Demonstration Program for Foam version "<GetVersion()<<" *****"<SetkDim( kDim); // Mandatory!!! FoamX->SetnCells( nCells); // optional @@ -85,21 +85,21 @@ Int_t foam_demo() FoamX->SetOptDrive( OptDrive); // optional FoamX->SetEvPerBin( EvPerBin); // optional FoamX->SetChat( Chat); // optional - //=============================== + //----------------------------------------- FoamX->SetRho(rho); FoamX->SetPseRan(PseRan); FoamX->Initialize(); // Initialize simulator FoamX->Write("FoamX"); // Writing Foam on the disk, TESTING PERSISTENCY!!! - //=============================== + //----------------------------------------- long nCalls=FoamX->GetnCalls(); cout << "====== Initialization done, entering MC loop" << endl; - //====================================================================== + //----------------------------------------- //cout<<" About to start MC loop: "; cin.getline(question,20); Double_t *MCvect =new Double_t[kDim]; // vector generated in the MC run - //====================================================================== + //----------------------------------------- TH1D *hst_Wt = new TH1D("hst_Wt" , "Main weight of Foam",25,0,1.25); hst_Wt->Sumw2(); - //====================================================================== + //----------------------------------------- for(loop=0; loopMakeEvent(); // generate MC event @@ -116,8 +116,9 @@ Int_t foam_demo() cout<<" loop= "<Print("all"); @@ -143,7 +144,6 @@ Int_t foam_demo() cout << "***** End of Demonstration Program *****" << endl; return 0; -} // end of Demo +} -#endif diff --git a/tutorials/foam/foam_demo.root b/tutorials/foam/foam_demo.root deleted file mode 100644 index cc2cd2c626113..0000000000000 Binary files a/tutorials/foam/foam_demo.root and /dev/null differ diff --git a/tutorials/foam/foam_kanwa.C b/tutorials/foam/foam_kanwa.C index 92eeec3d7c906..c6143d9ab92a9 100644 --- a/tutorials/foam/foam_kanwa.C +++ b/tutorials/foam/foam_kanwa.C @@ -3,7 +3,7 @@ /// \notebook -js /// This program can be execute from the command line as folows: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root -l foam_kanwa.C /// ~~~ /// @@ -33,7 +33,7 @@ Double_t Camel2(Int_t nDim, Double_t *Xarg){ Dist +=exp(-(sqr(x-1./3) +sqr(y-1./3))/GamSq)/GamSq/TMath::Pi(); Dist +=exp(-(sqr(x-2./3) +sqr(y-2./3))/GamSq)/GamSq/TMath::Pi(); return 0.5*Dist; -}// Camel2 +} //_____________________________________________________________________________ Int_t foam_kanwa(){ @@ -79,5 +79,4 @@ Int_t foam_kanwa(){ cout<<"--- kanwa ended ---"<Load("libFoam.so") root [1] .x foam_demo.C+ -~~~ +``` to load FOAM library, compile and execute macro foam_demo.C. A shared object foam_demo_C.so is created in the current @@ -66,9 +66,9 @@ including distribution function will be written to disk. demonstrates persistency of FOAM classes. To run this macro type: -~~~ {.cpp} +```cpp root [0] .x foam_demopers.C -~~~ +``` Program reads the FOAM object from disk, checks its consistency and prints geometry of cells. Next starts the diff --git a/tutorials/geom/RadioNuclides.C b/tutorials/geom/RadioNuclides.C index ce4a8a053a9f9..2828f4e607818 100644 --- a/tutorials/geom/RadioNuclides.C +++ b/tutorials/geom/RadioNuclides.C @@ -9,7 +9,7 @@ /// /// The radionuclides table is loaded on demand by any call: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// TGeoElementRN *TGeoElementTable::GetElementRN(Int_t atomic_number, /// Int_t atomic_charge, /// Int_t isomeric_number) @@ -20,14 +20,14 @@ /// To create a radioactive material based on a radionuclide, one should use the /// constructor: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// TGeoMaterial(const char *name, TGeoElement *elem, Double_t density) /// ~~~ /// /// To create a radioactive mixture, one can use radionuclides as well as stable /// elements: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// TGeoMixture(const char *name, Int_t nelements, Double_t density); /// TGeoMixture::AddElement(TGeoElement *elem, Double_t weight_fraction); /// ~~~ @@ -35,7 +35,7 @@ /// Once defined, one can retrieve the time evolution for the radioactive /// materials/mixtures by using one of the 2 methods: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// void TGeoMaterial::FillMaterialEvolution(TObjArray *population, /// Double_t precision=0.001) /// ~~~ @@ -47,7 +47,7 @@ /// The POPULATION list may contain stable elements as well as radionuclides, /// depending on the initial elements. To test if an element is a radionuclide: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// Bool_t TGeoElement::IsRadioNuclide() const /// ~~~ /// @@ -56,7 +56,7 @@ /// top radionuclide in the decay chain. These objects (Bateman solutions) can be /// retrieved and drawn: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// TGeoBatemanSol *TGeoElementRN::Ratio(); /// void TGeoBatemanSol::Draw(); /// ~~~ @@ -64,7 +64,7 @@ /// Another method allows to create the evolution of a given radioactive /// material/mixture at a given moment in time: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// TGeoMaterial::DecayMaterial(Double_t time, Double_t precision=0.001) /// ~~~ /// diff --git a/tutorials/geom/runplugin.C b/tutorials/geom/runplugin.C index 71599613a4f61..986d0b6449c71 100644 --- a/tutorials/geom/runplugin.C +++ b/tutorials/geom/runplugin.C @@ -6,7 +6,7 @@ /// volumes acording some arbitrary criteria *WITHOUT* changing the color of the /// same volume drawn on branches that do not match the criteria. /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// To run: /// root[0] .L iterplugin.cxx+ /// root[1] .x runplugin.C diff --git a/tutorials/gl/glparametric.C b/tutorials/gl/glparametric.C index a722568b6514f..223bd08089191 100644 --- a/tutorials/gl/glparametric.C +++ b/tutorials/gl/glparametric.C @@ -9,7 +9,7 @@ /// - Call gStyle->SetCanvasPreferGL(kTRUE) /// - Or create canvas with name, wich contains "gl". /// 2. create TGLParametricEquation object. -/// ~~~ {.cpp} +/// ~~~{.cpp} /// TGLParametricEquation *eq = new TGLParametricEquation("name", /// "some FORMULA here - x(u, v)", /// "some FORMULA here - y(u, v)", diff --git a/tutorials/gl/glparametrics2.C b/tutorials/gl/glparametrics2.C index bc3923555daef..01afcd1867c43 100644 --- a/tutorials/gl/glparametrics2.C +++ b/tutorials/gl/glparametrics2.C @@ -9,7 +9,7 @@ /// - Call gStyle->SetCanvasPreferGL(kTRUE) /// - Or create canvas with name, wich contains "gl". /// 2. create TGLParametricEquation object. -/// ~~~ {.cpp} +/// ~~~{.cpp} /// TGLParametricEquation *eq = new TGLParametricEquation("name", /// "some FORMULA here - x(u, v)", /// "some FORMULA here - y(u, v)", diff --git a/tutorials/gl/glvox2.C b/tutorials/gl/glvox2.C index b3cec9cd959a1..5c05198e9613f 100644 --- a/tutorials/gl/glvox2.C +++ b/tutorials/gl/glvox2.C @@ -6,14 +6,14 @@ /// codomain is [0, 1] (1. - non-transparent, 0.5 is semitransparent, etc.) /// To pass transparency function into painting algorithm, you have to: /// 1. Create TF1 object (with symbolic expression like "0.5 * (sin(x) + 1)": -/// ~~~ {.cpp} +/// ~~~{.cpp} /// ... /// TF1 * tf = new TF1("TransferFunction", "0.5 * (sin(x) + 1)", -10., 10.); /// ... /// ~~~ /// IMPORTANT, the name of TF1 object MUST be "TransferFunction". /// 2. Add this function into a hist's list of functions: -/// ~~~ {.cpp} +/// ~~~{.cpp} /// ... /// TList * lof = hist->GetListOfFunctions(); /// if (lof) lof->Add(tf); diff --git a/tutorials/gl/viewer3DLocal.C b/tutorials/gl/viewer3DLocal.C index b604b721af8d4..92dcacb6086c1 100644 --- a/tutorials/gl/viewer3DLocal.C +++ b/tutorials/gl/viewer3DLocal.C @@ -15,7 +15,7 @@ /// As we overload TObject::Paint which is called directly from compiled /// code, this script must also be compiled to work correctly. /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// #if defined(__CINT__) && !defined(__MAKECINT__) /// { /// gSystem->CompileMacro("viewer3DLocal.C"); diff --git a/tutorials/graphics/gaxis.C b/tutorials/graphics/gaxis.C index ac224da6e3213..17abaaa1c1416 100644 --- a/tutorials/graphics/gaxis.C +++ b/tutorials/graphics/gaxis.C @@ -9,50 +9,50 @@ /// \author Rene Brun void gaxis(){ - TCanvas *c1 = new TCanvas("c1","Examples of TGaxis",10,10,700,500); - - c1->Range(-10,-1,10,1); - - TGaxis *axis1 = new TGaxis(-4.5,-0.2,5.5,-0.2,-6,8,510,""); - axis1->SetName("axis1"); - axis1->Draw(); - - TGaxis *axis2 = new TGaxis(-4.5,0.2,5.5,0.2,0.001,10000,510,"G"); - axis2->SetName("axis2"); - axis2->Draw(); - - TGaxis *axis3 = new TGaxis(-9,-0.8,-9,0.8,-8,8,50510,""); - axis3->SetName("axis3"); - axis3->SetTitle("axis3"); - axis3->SetTitleOffset(0.5); - axis3->Draw(); - - TGaxis *axis4 = new TGaxis(-7,-0.8,-7,0.8,1,10000,50510,"G"); - axis4->SetName("axis4"); - axis4->SetTitle("axis4"); - axis4->Draw(); - - TGaxis *axis5 = new TGaxis(-4.5,-0.6,5.5,-0.6,1.2,1.32,80506,"-+"); - axis5->SetName("axis5"); - axis5->SetLabelSize(0.03); - axis5->SetTextFont(72); - - axis5->Draw(); - - TGaxis *axis6 = new TGaxis(-4.5,0.5,5.5,0.5,100,900,50510,"-"); - axis6->SetName("axis6"); - axis6->Draw(); - TGaxis *axis6a = new TGaxis(-5.5,0.85,5.5,0.85,0,4.3e-6,510,""); - axis6a->SetName("axis6a"); - axis6a->Draw(); - - TGaxis *axis7 = new TGaxis(8,-0.8,8,0.8,0,9000,50510,"+L"); - axis7->SetName("axis7"); - axis7->Draw(); - - //one can make axis going top->bottom. However because of a long standing - //problem, the two x values should not be equal - TGaxis *axis8 = new TGaxis(6.5,0.8,6.499,-0.8,0,90,50510,"-"); - axis8->SetName("axis8"); - axis8->Draw(); + TCanvas *c1 = new TCanvas("c1","Examples of TGaxis",10,10,700,500); + + c1->Range(-10,-1,10,1); + + TGaxis *axis1 = new TGaxis(-4.5,-0.2,5.5,-0.2,-6,8,510,""); + axis1->SetName("axis1"); + axis1->Draw(); + + TGaxis *axis2 = new TGaxis(-4.5,0.2,5.5,0.2,0.001,10000,510,"G"); + axis2->SetName("axis2"); + axis2->Draw(); + + TGaxis *axis3 = new TGaxis(-9,-0.8,-9,0.8,-8,8,50510,""); + axis3->SetName("axis3"); + axis3->SetTitle("axis3"); + axis3->SetTitleOffset(0.5); + axis3->Draw(); + + TGaxis *axis4 = new TGaxis(-7,-0.8,-7,0.8,1,10000,50510,"G"); + axis4->SetName("axis4"); + axis4->SetTitle("axis4"); + axis4->Draw(); + + TGaxis *axis5 = new TGaxis(-4.5,-0.6,5.5,-0.6,1.2,1.32,80506,"-+"); + axis5->SetName("axis5"); + axis5->SetLabelSize(0.03); + axis5->SetTextFont(72); + + axis5->Draw(); + + TGaxis *axis6 = new TGaxis(-4.5,0.5,5.5,0.5,100,900,50510,"-"); + axis6->SetName("axis6"); + axis6->Draw(); + TGaxis *axis6a = new TGaxis(-5.5,0.85,5.5,0.85,0,4.3e-6,510,""); + axis6a->SetName("axis6a"); + axis6a->Draw(); + + TGaxis *axis7 = new TGaxis(8,-0.8,8,0.8,0,9000,50510,"+L"); + axis7->SetName("axis7"); + axis7->Draw(); + + //one can make axis going top->bottom. However because of a long standing + //problem, the two x values should not be equal + TGaxis *axis8 = new TGaxis(6.5,0.8,6.499,-0.8,0,90,50510,"-"); + axis8->SetName("axis8"); + axis8->Draw(); } diff --git a/tutorials/graphics/graph_edit_playback.C b/tutorials/graphics/graph_edit_playback.C index e3dad9a516c6f..8775076701bb6 100644 --- a/tutorials/graphics/graph_edit_playback.C +++ b/tutorials/graphics/graph_edit_playback.C @@ -3,7 +3,7 @@ /// This macro plays a recorded ROOT session showing how to perform various /// interactive graphical editing operations. The initial graphics setup /// was created using the following root commands: -/// ~~~ {.cpp} +/// ~~~{.cpp} /// TRecorder *t = new TRecorder(); /// t->Start("graphedit_playback.root"); /// gStyle->SetPalette(1); diff --git a/tutorials/graphics/manyaxis.C b/tutorials/graphics/manyaxis.C index c9ffaa2176cdc..4203083be1832 100644 --- a/tutorials/graphics/manyaxis.C +++ b/tutorials/graphics/manyaxis.C @@ -8,6 +8,7 @@ /// /// \author Olivier Couet +void manyaxis() { c1 = new TCanvas("c1","Examples of Gaxis",10,10,700,500); diff --git a/tutorials/graphics/quarks.C b/tutorials/graphics/quarks.C index f63de1472dc2e..1b42df21e66fa 100644 --- a/tutorials/graphics/quarks.C +++ b/tutorials/graphics/quarks.C @@ -47,7 +47,7 @@ void quarks () { tex.SetTextColor(kBlack); tex.SetTextSize(0.8); -// ------------>Create main pad and its subdivisions +// Create main pad and its subdivisions TPad *pad = new TPad("pad", "pad",0.15,0.11,0.85,0.79); pad->Draw(); pad->cd(); diff --git a/tutorials/graphics/tmathtext2.C b/tutorials/graphics/tmathtext2.C index 96a7684f56b10..c5e61f1baab3b 100644 --- a/tutorials/graphics/tmathtext2.C +++ b/tutorials/graphics/tmathtext2.C @@ -5,6 +5,7 @@ /// \macro_image /// \author Olivier Couet +TCanvas * tmathtext2() { TCanvas *c1 = new TCanvas("mathtext","TMathText symbol",1200,1400); diff --git a/tutorials/graphics/tornado.C b/tutorials/graphics/tornado.C index 9fd31e18ce1c8..dd650fa751a2f 100644 --- a/tutorials/graphics/tornado.C +++ b/tutorials/graphics/tornado.C @@ -9,59 +9,59 @@ /// \author Rene Brun void tornado() { - gBenchmark->Start("tornado"); + gBenchmark->Start("tornado"); - double PI = 3.141592653; - int d = 16; - int numberOfPoints=200; - int numberOfCircles=40; + double PI = 3.141592653; + int d = 16; + int numberOfPoints=200; + int numberOfCircles=40; - // create and open a canvas - TCanvas *sky = new TCanvas( "sky", "Tornado", 300, 10, 700, 500 ); - sky->SetFillColor(14); + // create and open a canvas + TCanvas *sky = new TCanvas( "sky", "Tornado", 300, 10, 700, 500 ); + sky->SetFillColor(14); - // creating view - TView *view = TView::CreateView(1,0,0); - float range = numberOfCircles*d; - view->SetRange( 0, 0, 0, 4.0*range, 2.0*range, range ); + // creating view + TView *view = TView::CreateView(1,0,0); + float range = numberOfCircles*d; + view->SetRange( 0, 0, 0, 4.0*range, 2.0*range, range ); - for( int j = d; j < numberOfCircles*d; j += d ) { + for( int j = d; j < numberOfCircles*d; j += d ) { - // create a PolyMarker3D - TPolyMarker3D *pm3d = new TPolyMarker3D( numberOfPoints ); + // create a PolyMarker3D + TPolyMarker3D *pm3d = new TPolyMarker3D( numberOfPoints ); - float x, y, z; + float x, y, z; - // set points - for( int i = 1; i < numberOfPoints; i++ ) { - float csin = sin(2*PI / (double)numberOfPoints * (double)i) + 1; - float ccos = cos(2*PI / (double)numberOfPoints * (double)i) + 1; - float esin = sin(2*PI / (double)(numberOfCircles*d) * (double)j) + 1; - x = j * ( csin + esin ); - y = j * ccos; - z = j; - pm3d->SetPoint( i, x, y, z ); - } + // set points + for( int i = 1; i < numberOfPoints; i++ ) { + float csin = sin(2*PI / (double)numberOfPoints * (double)i) + 1; + float ccos = cos(2*PI / (double)numberOfPoints * (double)i) + 1; + float esin = sin(2*PI / (double)(numberOfCircles*d) * (double)j) + 1; + x = j * ( csin + esin ); + y = j * ccos; + z = j; + pm3d->SetPoint( i, x, y, z ); + } - // set marker size, color & style - pm3d->SetMarkerSize( 1 ); - pm3d->SetMarkerColor( 2 + ( d == ( j & d ) ) ); - pm3d->SetMarkerStyle( 3 ); + // set marker size, color & style + pm3d->SetMarkerSize( 1 ); + pm3d->SetMarkerColor( 2 + ( d == ( j & d ) ) ); + pm3d->SetMarkerStyle( 3 ); - //draw - pm3d->Draw(); - } + //draw + pm3d->Draw(); + } - char timeStr[60]; - gBenchmark->Show("tornado"); + char timeStr[60]; + gBenchmark->Show("tornado"); - Float_t ct = gBenchmark->GetCpuTime("tornado"); - sprintf( timeStr, "Execution time: %g sec.", ct); + Float_t ct = gBenchmark->GetCpuTime("tornado"); + sprintf( timeStr, "Execution time: %g sec.", ct); - TPaveText *text = new TPaveText( 0.1, 0.81, 0.9, 0.97 ); - text->SetFillColor( 42 ); - text->AddText("ROOT example: tornado.C"); - text->AddText(timeStr); - text->Draw(); - sky->Update(); + TPaveText *text = new TPaveText( 0.1, 0.81, 0.9, 0.97 ); + text->SetFillColor( 42 ); + text->AddText("ROOT example: tornado.C"); + text->AddText(timeStr); + text->Draw(); + sky->Update(); } diff --git a/tutorials/graphics/triangles.C b/tutorials/graphics/triangles.C index a4ee104e11339..7be6e08559c31 100644 --- a/tutorials/graphics/triangles.C +++ b/tutorials/graphics/triangles.C @@ -4,7 +4,7 @@ /// Generate small triangles randomly in the canvas. /// Each triangle has a unique id and a random color in the color palette /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root > .x triangles.C /// ~~~ /// @@ -17,27 +17,27 @@ /// \author Rene Brun void triangles(Int_t ntriangles=50) { - TCanvas *c1 = new TCanvas("c1","triangles",10,10,700,700); - TRandom r; - Double_t dx = 0.2; Double_t dy = 0.2; - Int_t ncolors = gStyle->GetNumberOfColors(); - Double_t x[4],y[4]; - TColor *c; - Int_t ci; - for (Int_t i=0;iSetUniqueID(i); - ci = ncolors*r.Rndm(); - c = gROOT->GetColor(TColor::GetColorPalette(ci)); - c->SetAlpha(r.Rndm()); - pl->SetFillColor(ci); - pl->Draw("f"); - } - c1->AddExec("ex","TriangleClicked()"); + TCanvas *c1 = new TCanvas("c1","triangles",10,10,700,700); + TRandom r; + Double_t dx = 0.2; Double_t dy = 0.2; + Int_t ncolors = gStyle->GetNumberOfColors(); + Double_t x[4],y[4]; + TColor *c; + Int_t ci; + for (Int_t i=0;iSetUniqueID(i); + ci = ncolors*r.Rndm(); + c = gROOT->GetColor(TColor::GetColorPalette(ci)); + c->SetAlpha(r.Rndm()); + pl->SetFillColor(ci); + pl->Draw("f"); + } + c1->AddExec("ex","TriangleClicked()"); } void TriangleClicked() { diff --git a/tutorials/graphs/approx.C b/tutorials/graphs/approx.C index 238af0d63dc1e..baefe571744d9 100644 --- a/tutorials/graphs/approx.C +++ b/tutorials/graphs/approx.C @@ -1,6 +1,6 @@ /// \file /// \ingroup tutorial_graphs -/// \notebook +/// \notebook -js /// Macro to test interpolation function Approx /// /// \macro_image diff --git a/tutorials/graphs/bent.C b/tutorials/graphs/bent.C index db7929fab8359..8415dd5af88cc 100644 --- a/tutorials/graphs/bent.C +++ b/tutorials/graphs/bent.C @@ -1,6 +1,6 @@ /// \file /// \ingroup tutorial_graphs -/// \notebook +/// \notebook -js /// Bent error bars /// /// \macro_image diff --git a/tutorials/graphs/exclusiongraph.C b/tutorials/graphs/exclusiongraph.C index 949ed819bf7ad..98722e25c6f7e 100644 --- a/tutorials/graphs/exclusiongraph.C +++ b/tutorials/graphs/exclusiongraph.C @@ -16,28 +16,28 @@ TCanvas *exclusiongraph() { mg->SetTitle("Exclusion graphs"); const Int_t n = 35; - Double_t x1[n], x2[n], x3[n], y1[n], y2[n], y3[n]; + Double_t xvalues1[n], xvalues2[n], xvalues3[n], yvalues1[n], yvalues2[n], yvalues3[n]; for (Int_t i=0;iSetLineColor(2); gr1->SetLineWidth(1504); gr1->SetFillStyle(3005); - TGraph *gr2 = new TGraph(n,x2,y2); + TGraph *gr2 = new TGraph(n,xvalues2,yvalues2); gr2->SetLineColor(4); gr2->SetLineWidth(-2002); gr2->SetFillStyle(3004); gr2->SetFillColor(9); - TGraph *gr3 = new TGraph(n,x3,y3); + TGraph *gr3 = new TGraph(n,xvalues3,yvalues3); gr3->SetLineColor(5); gr3->SetLineWidth(-802); gr3->SetFillStyle(3002); diff --git a/tutorials/graphs/gerrors2.C b/tutorials/graphs/gerrors2.C index 64d421e8b8d08..fe632ac5d433a 100644 --- a/tutorials/graphs/gerrors2.C +++ b/tutorials/graphs/gerrors2.C @@ -13,14 +13,14 @@ void gerrors2() { c1->SetFillColor(42); c1->SetGrid(); - // draw a frame to define the range + // draw a frame to define the range TH1F *hr = c1->DrawFrame(-0.4,0,1.2,12); hr->SetXTitle("X title"); hr->SetYTitle("Y title"); c1->GetFrame()->SetFillColor(21); c1->GetFrame()->SetBorderSize(12); - // create first graph + // create first graph const Int_t n1 = 10; Double_t xval1[] = {-0.22, 0.05, 0.25, 0.35, 0.5, 0.61,0.7,0.85,0.89,0.95}; Double_t yval1[] = {1,2.9,5.6,7.4,9,9.6,8.7,6.3,4.5,1}; @@ -31,7 +31,7 @@ void gerrors2() { gr1->SetMarkerStyle(21); gr1->Draw("LP"); - // create second graph + // create second graph const Int_t n2 = 10; Float_t xval2[] = {-0.28, 0.005, 0.19, 0.29, 0.45, 0.56,0.65,0.80,0.90,1.01}; Float_t yval2[] = {0.82,3.86,7,9,10,10.55,9.64,7.26,5.42,2}; diff --git a/tutorials/graphs/graphApply.C b/tutorials/graphs/graphApply.C index a04be454d2a64..3eb6cce7350c0 100644 --- a/tutorials/graphs/graphApply.C +++ b/tutorials/graphs/graphApply.C @@ -12,6 +12,7 @@ /// /// \author Miro Helbich +void graphApply() { const Int_t npoints=3; Double_t xaxis[npoints] = {1.,2.,3.}; diff --git a/tutorials/graphs/graphstruct.C b/tutorials/graphs/graphstruct.C index 92edfee01f64e..1ed21c07ea72e 100644 --- a/tutorials/graphs/graphstruct.C +++ b/tutorials/graphs/graphstruct.C @@ -10,7 +10,7 @@ /// /// \author Olivier Couet -void graphstruct() +TCanvas * graphstruct() { TGraphStruct *gs = new TGraphStruct(); diff --git a/tutorials/graphs/multigraph.C b/tutorials/graphs/multigraph.C index c2dd8ff702cfe..7b00dcd817a27 100644 --- a/tutorials/graphs/multigraph.C +++ b/tutorials/graphs/multigraph.C @@ -8,15 +8,16 @@ /// /// \author Rene Brun +void multigraph() { gStyle->SetOptFit(); TCanvas *c1 = new TCanvas("c1","multigraph",700,500); c1->SetGrid(); - // draw a frame to define the range + // draw a frame to define the range TMultiGraph *mg = new TMultiGraph(); - // create first graph + // create first graph const Int_t n1 = 10; Double_t px1[] = {-0.1, 0.05, 0.25, 0.35, 0.5, 0.61,0.7,0.85,0.89,0.95}; Double_t py1[] = {-1,2.9,5.6,7.4,9,9.6,8.7,6.3,4.5,1}; @@ -28,7 +29,7 @@ gr1->Fit("pol6","q"); mg->Add(gr1); - // create second graph + // create second graph const Int_t n2 = 10; Float_t x2[] = {-0.28, 0.005, 0.19, 0.29, 0.45, 0.56,0.65,0.80,0.90,1.01}; Float_t y2[] = {2.1,3.86,7,9,10,10.55,9.64,7.26,5.42,2}; @@ -43,7 +44,7 @@ mg->Draw("ap"); - //force drawing of canvas to generate the fit TPaveStats + //force drawing of canvas to generate the fit TPaveStats c1->Update(); TPaveStats *stats1 = (TPaveStats*)gr1->GetListOfFunctions()->FindObject("stats"); TPaveStats *stats2 = (TPaveStats*)gr2->GetListOfFunctions()->FindObject("stats"); diff --git a/tutorials/graphs/splines_test.C b/tutorials/graphs/splines_test.C index 60f7836e19c3b..c88736d87ee69 100644 --- a/tutorials/graphs/splines_test.C +++ b/tutorials/graphs/splines_test.C @@ -10,99 +10,99 @@ void splines_test(Int_t np=23, Double_t a=-0.5, Double_t b=31) { - // array of points - Double_t *xx=0, *yy=0; - TSpline3 *spline3=0; - TSpline5 *spline5=0; - TLine *line5, *line3; - TText *text5, *text3, *textn; - char text[20]; - const Double_t power=0.75; + // array of points + Double_t *xx=0, *yy=0; + TSpline3 *spline3=0; + TSpline5 *spline5=0; + TLine *line5, *line3; + TText *text5, *text3, *textn; + char text[20]; + const Double_t power=0.75; - // Define the original function - TF1 *f=new TF1("f","sin(x)*sin(x/10)", - a-0.05*(b-a),b+0.05*(b-a)); - // Draw function - f->Draw("lc"); + // Define the original function + TF1 *f=new TF1("f","sin(x)*sin(x/10)", + a-0.05*(b-a),b+0.05*(b-a)); + // Draw function + f->Draw("lc"); - // Create text and legend - Double_t xx1, yy1, xx2, yy2, dx, dy; - gPad->Update(); - gPad->GetRangeAxis(xx1,yy1,xx2,yy2); - dx = xx2-xx1; - dy = yy2-yy1; - line5=new TLine(xx1+dx*0.3,yy1+dy*1.02, - xx1+dx*0.38,yy1+dy*1.02); - line5->SetLineColor(kRed); - line5->SetLineWidth(2); - text5 = new TText(xx1+dx*0.4, - yy1+dy*1.03,"quintic spline"); - text5->SetTextAlign(12); - text5->SetTextSize(0.04); - line3=new TLine(xx1+dx*0.67,yy1+dy*1.02, - xx1+dx*0.75,yy1+dy*1.02); - line3->SetLineColor(kGreen); - line3->SetLineWidth(2); - text3 = new TText(xx1+dx*0.77, - yy1+dy*1.03,"third spline"); - text3->SetTextAlign(12); - text3->SetTextSize(0.04); - textn = new TText(xx1+dx*0.8,yy1+dy*0.91," "); - textn->SetTextAlign(12); - textn->SetTextSize(0.04); - textn->Draw(); + // Create text and legend + Double_t xx1, yy1, xx2, yy2, dx, dy; + gPad->Update(); + gPad->GetRangeAxis(xx1,yy1,xx2,yy2); + dx = xx2-xx1; + dy = yy2-yy1; + line5=new TLine(xx1+dx*0.3,yy1+dy*1.02, + xx1+dx*0.38,yy1+dy*1.02); + line5->SetLineColor(kRed); + line5->SetLineWidth(2); + text5 = new TText(xx1+dx*0.4, + yy1+dy*1.03,"quintic spline"); + text5->SetTextAlign(12); + text5->SetTextSize(0.04); + line3=new TLine(xx1+dx*0.67,yy1+dy*1.02, + xx1+dx*0.75,yy1+dy*1.02); + line3->SetLineColor(kGreen); + line3->SetLineWidth(2); + text3 = new TText(xx1+dx*0.77, + yy1+dy*1.03,"third spline"); + text3->SetTextAlign(12); + text3->SetTextSize(0.04); + textn = new TText(xx1+dx*0.8,yy1+dy*0.91," "); + textn->SetTextAlign(12); + textn->SetTextSize(0.04); + textn->Draw(); - // Draw legenda - line5->Draw(); - text5->Draw(); - line3->Draw(); - text3->Draw(); + // Draw legenda + line5->Draw(); + text5->Draw(); + line3->Draw(); + text3->Draw(); - for(Int_t nnp=2; nnp<=np; ++nnp) { + for(Int_t nnp=2; nnp<=np; ++nnp) { - // Calculate the knots - if(xx) delete[] xx; - xx = new Double_t[nnp]; - if(yy) delete[] yy; - yy = new Double_t[nnp]; - for (Int_t i=0; iEval(xx[i]); - } + // Calculate the knots + if(xx) delete[] xx; + xx = new Double_t[nnp]; + if(yy) delete[] yy; + yy = new Double_t[nnp]; + for (Int_t i=0; iEval(xx[i]); + } - // Evaluate fifth spline coefficients - Double_t eps=(b-a)*1.e-5; - if(spline5) delete spline5; - spline5 = new TSpline5("Test",xx,f,nnp,"b1e1b2e2", - f->Derivative(a),f->Derivative(b), - (f->Derivative(a+eps)-f->Derivative(a))/eps, - (f->Derivative(b)-f->Derivative(b-eps))/eps); + // Evaluate fifth spline coefficients + Double_t eps=(b-a)*1.e-5; + if(spline5) delete spline5; + spline5 = new TSpline5("Test",xx,f,nnp,"b1e1b2e2", + f->Derivative(a),f->Derivative(b), + (f->Derivative(a+eps)-f->Derivative(a))/eps, + (f->Derivative(b)-f->Derivative(b-eps))/eps); - spline5->SetLineColor(kRed); - spline5->SetLineWidth(3); + spline5->SetLineColor(kRed); + spline5->SetLineWidth(3); - // Draw the quintic spline - spline5->Draw("lcsame"); + // Draw the quintic spline + spline5->Draw("lcsame"); - // Evaluate third spline coefficients - if(spline3) delete spline3; - spline3 = new TSpline3("Test",xx,yy,nnp,"b1e1", - f->Derivative(a),f->Derivative(b)); + // Evaluate third spline coefficients + if(spline3) delete spline3; + spline3 = new TSpline3("Test",xx,yy,nnp,"b1e1", + f->Derivative(a),f->Derivative(b)); - spline3->SetLineColor(kGreen); - spline3->SetLineWidth(3); - spline3->SetMarkerColor(kBlue); - spline3->SetMarkerStyle(20); - spline3->SetMarkerSize(1.5); + spline3->SetLineColor(kGreen); + spline3->SetLineWidth(3); + spline3->SetMarkerColor(kBlue); + spline3->SetMarkerStyle(20); + spline3->SetMarkerSize(1.5); - // Draw the third spline - spline3->Draw("lcpsame"); + // Draw the third spline + spline3->Draw("lcpsame"); - sprintf(text,"%3d knots",nnp); - textn->SetTitle(text); - gPad->Update(); + sprintf(text,"%3d knots",nnp); + textn->SetTitle(text); + gPad->Update(); - // - gSystem->Sleep(500); - } + // + gSystem->Sleep(500); + } } diff --git a/tutorials/graphs/timeonaxis.C b/tutorials/graphs/timeonaxis.C index 5767700ccfde8..1b8be6bc778cc 100644 --- a/tutorials/graphs/timeonaxis.C +++ b/tutorials/graphs/timeonaxis.C @@ -26,8 +26,6 @@ TCanvas *timeonaxis() { -//Author: - time_t script_time; script_time = time(0); script_time = 3600*(int)(script_time/3600); @@ -42,7 +40,7 @@ TCanvas *timeonaxis() int i; -//======= Build a signal : noisy damped sine ====== +//### Build a signal : noisy damped sine // Time interval : 30 minutes gStyle->SetTitleH(0.08); @@ -67,7 +65,7 @@ TCanvas *timeonaxis() // a reasonable tick interval value is chosen. ht->GetXaxis()->SetTimeDisplay(1); -//======= Build a simple graph beginning at a different time ====== +//### Build a simple graph beginning at a different time // Time interval : 5 seconds float x[100], t[100]; @@ -89,7 +87,7 @@ TCanvas *timeonaxis() gt->GetXaxis()->SetTimeDisplay(1); gPad->Modified(); -//======= Build a second simple graph for a very long time interval ====== +//### Build a second simple graph for a very long time interval // Time interval : a few years float x2[10], t2[10]; @@ -114,6 +112,7 @@ TCanvas *timeonaxis() // One can choose a different time format than the one chosen by default // The time format is the same as the one of the C strftime() function // It's a string containing the following formats : +// // for date : // %a abbreviated weekday name // %b abbreviated month name diff --git a/tutorials/graphs/waves.C b/tutorials/graphs/waves.C index d2e1e8f425a2f..7dfc7cb49f051 100644 --- a/tutorials/graphs/waves.C +++ b/tutorials/graphs/waves.C @@ -53,7 +53,7 @@ Double_t result( Double_t *x, Double_t *par) } -//_________________________________________________________________ +//_____________________________________________________________ void waves( Double_t d = 3, Double_t lambda = 1, Double_t amp = 10) { TCanvas *c1 = new TCanvas("waves", "A double slit experiment", diff --git a/tutorials/gui/guitest.C b/tutorials/gui/guitest.C index 0af2503cd0550..1e4b770c20c89 100644 --- a/tutorials/gui/guitest.C +++ b/tutorials/gui/guitest.C @@ -4,7 +4,7 @@ /// Exactly like $ROOTSYS/test/guitest.cxx but using the new signal and slots communication mechanism. /// It is now possible to run this entire test program in the interpreter. /// Do either: -/// ~~~ {.cpp} +/// ~~~{.cpp} /// .x guitest.C /// .x guitest.C++ /// ~~~ diff --git a/tutorials/hist/exec1.C b/tutorials/hist/exec1.C index 7446e0cbe1837..01f9231ed3c5c 100644 --- a/tutorials/hist/exec1.C +++ b/tutorials/hist/exec1.C @@ -3,7 +3,7 @@ /// Echo object at mouse position. /// Example of macro called when a pad is redrawn /// one must create a TExec object in the following way -/// ~~~ {.cpp} +/// ~~~{.cpp} /// TExec ex("ex",".x exec1.C"); /// ex.Draw(); /// ~~~ diff --git a/tutorials/hist/exec2.C b/tutorials/hist/exec2.C index 1a54b48aa96b4..e9dea324b7f2a 100644 --- a/tutorials/hist/exec2.C +++ b/tutorials/hist/exec2.C @@ -4,7 +4,7 @@ /// Example of macro called when a mouse event occurs in a pad. /// /// Example: -/// ~~~ {.cpp} +/// ~~~{.cpp} /// Root > TFile f("hsimple.root"); /// Root > hpxpy.Draw(); /// Root > c1.AddExec("ex2",".x exec2.C"); diff --git a/tutorials/hist/greyscale.C b/tutorials/hist/greyscale.C index 9c21f024025c3..ba739e9a1bb6e 100644 --- a/tutorials/hist/greyscale.C +++ b/tutorials/hist/greyscale.C @@ -8,6 +8,7 @@ /// /// \author Olivier Couet +void greyscale() { TCanvas *c = new TCanvas("grey", "Grey Scale", 500, 500); c->SetBorderMode(0); diff --git a/tutorials/hist/hsum.C b/tutorials/hist/hsum.C index 5d0f8b1d63b66..4a4887a43f4b9 100644 --- a/tutorials/hist/hsum.C +++ b/tutorials/hist/hsum.C @@ -11,56 +11,56 @@ /// \author Rene Brun void hsum() { - TCanvas *c1 = new TCanvas("c1","The HSUM example",200,10,600,400); - c1->SetGrid(); + TCanvas *c1 = new TCanvas("c1","The HSUM example",200,10,600,400); + c1->SetGrid(); - gBenchmark->Start("hsum"); + gBenchmark->Start("hsum"); -// Create some histograms. - auto total = new TH1F("total","This is the total distribution",100,-4,4); - auto main = new TH1F("main","Main contributor",100,-4,4); - auto s1 = new TH1F("s1","This is the first signal",100,-4,4); - auto s2 = new TH1F("s2","This is the second signal",100,-4,4); - total->Sumw2(); // store the sum of squares of weights - total->SetMarkerStyle(21); - total->SetMarkerSize(0.7); - main->SetFillColor(16); - s1->SetFillColor(42); - s2->SetFillColor(46); - TSlider *slider = 0; + // Create some histograms. + auto total = new TH1F("total","This is the total distribution",100,-4,4); + auto main = new TH1F("main","Main contributor",100,-4,4); + auto s1 = new TH1F("s1","This is the first signal",100,-4,4); + auto s2 = new TH1F("s2","This is the second signal",100,-4,4); + total->Sumw2(); // store the sum of squares of weights + total->SetMarkerStyle(21); + total->SetMarkerSize(0.7); + main->SetFillColor(16); + s1->SetFillColor(42); + s2->SetFillColor(46); + TSlider *slider = 0; -// Fill histograms randomly - gRandom->SetSeed(); - const Int_t kUPDATE = 500; - Float_t xs1, xs2, xmain; - for ( Int_t i=0; i<10000; i++) { - xmain = gRandom->Gaus(-1,1.5); - xs1 = gRandom->Gaus(-0.5,0.5); - xs2 = gRandom->Landau(1,0.15); - main->Fill(xmain); - s1->Fill(xs1,0.3); - s2->Fill(xs2,0.2); - total->Fill(xmain); - total->Fill(xs1,0.3); - total->Fill(xs2,0.2); - if (i && (i%kUPDATE) == 0) { - if (i == kUPDATE) { - total->Draw("e1p"); - main->Draw("same"); - s1->Draw("same"); - s2->Draw("same"); - c1->Update(); - slider = new TSlider("slider", - "test",4.2,0,4.6,total->GetMaximum(),38); - slider->SetFillColor(46); - } - if (slider) slider->SetRange(0,Float_t(i)/10000.); - c1->Modified(); - c1->Update(); - } - } - slider->SetRange(0,1); - total->Draw("sameaxis"); // to redraw axis hidden by the fill area - c1->Modified(); - gBenchmark->Show("hsum"); + // Fill histograms randomly + gRandom->SetSeed(); + const Int_t kUPDATE = 500; + Float_t xs1, xs2, xmain; + for ( Int_t i=0; i<10000; i++) { + xmain = gRandom->Gaus(-1,1.5); + xs1 = gRandom->Gaus(-0.5,0.5); + xs2 = gRandom->Landau(1,0.15); + main->Fill(xmain); + s1->Fill(xs1,0.3); + s2->Fill(xs2,0.2); + total->Fill(xmain); + total->Fill(xs1,0.3); + total->Fill(xs2,0.2); + if (i && (i%kUPDATE) == 0) { + if (i == kUPDATE) { + total->Draw("e1p"); + main->Draw("same"); + s1->Draw("same"); + s2->Draw("same"); + c1->Update(); + slider = new TSlider("slider", + "test",4.2,0,4.6,total->GetMaximum(),38); + slider->SetFillColor(46); + } + if (slider) slider->SetRange(0,Float_t(i)/10000.); + c1->Modified(); + c1->Update(); + } + } + slider->SetRange(0,1); + total->Draw("sameaxis"); // to redraw axis hidden by the fill area + c1->Modified(); + gBenchmark->Show("hsum"); } diff --git a/tutorials/hist/hsumTimer.C b/tutorials/hist/hsumTimer.C index c0748c08dc03f..8ce12e30299c5 100644 --- a/tutorials/hist/hsumTimer.C +++ b/tutorials/hist/hsumTimer.C @@ -27,51 +27,51 @@ void hsumUpdate() void hsumTimer(Int_t nfill=100000) { - c1 = new TCanvas("c1","The HSUM example",200,10,600,400); - c1->SetGrid(); + c1 = new TCanvas("c1","The HSUM example",200,10,600,400); + c1->SetGrid(); -// Create some histograms. - auto total = new TH1F("total","This is the total distribution",100,-4,4); - auto main = new TH1F("main","Main contributor",100,-4,4); - auto s1 = new TH1F("s1","This is the first signal",100,-4,4); - auto s2 = new TH1F("s2","This is the second signal",100,-4,4); - total->Sumw2(); // store the sum of squares of weights - total->SetMarkerStyle(21); - total->SetMarkerSize(0.7); - main->SetFillColor(16); - s1->SetFillColor(42); - s2->SetFillColor(46); - total->SetMaximum(nfill/20.); - total->Draw("e1p"); - main->Draw("same"); - s1->Draw("same"); - s2->Draw("same"); - c1->Update();slider = new TSlider("slider", - "test",4.2,0,4.6,0.8*total->GetMaximum(),38); - slider->SetFillColor(46); + // Create some histograms. + auto total = new TH1F("total","This is the total distribution",100,-4,4); + auto main = new TH1F("main","Main contributor",100,-4,4); + auto s1 = new TH1F("s1","This is the first signal",100,-4,4); + auto s2 = new TH1F("s2","This is the second signal",100,-4,4); + total->Sumw2(); // store the sum of squares of weights + total->SetMarkerStyle(21); + total->SetMarkerSize(0.7); + main->SetFillColor(16); + s1->SetFillColor(42); + s2->SetFillColor(46); + total->SetMaximum(nfill/20.); + total->Draw("e1p"); + main->Draw("same"); + s1->Draw("same"); + s2->Draw("same"); + c1->Update();slider = new TSlider("slider", + "test",4.2,0,4.6,0.8*total->GetMaximum(),38); + slider->SetFillColor(46); -// Create a TTimer (hsumUpdate called every 300 msec) - TTimer timer("hsumUpdate()",300); - timer.TurnOn(); + // Create a TTimer (hsumUpdate called every 300 msec) + TTimer timer("hsumUpdate()",300); + timer.TurnOn(); - // Fill histograms randomly - Float_t xs1, xs2, xmain; - gRandom->SetSeed(); - for (Int_t i=0; iProcessEvents()) break; - xmain = gRandom->Gaus(-1,1.5); - xs1 = gRandom->Gaus(-0.5,0.5); - xs2 = gRandom->Landau(1,0.15); - main->Fill(xmain); - s1->Fill(xs1,0.3); - s2->Fill(xs2,0.2); - total->Fill(xmain); - total->Fill(xs1,0.3); - total->Fill(xs2,0.2); - } - timer.TurnOff(); - hsumUpdate(); + // Fill histograms randomly + Float_t xs1, xs2, xmain; + gRandom->SetSeed(); + for (Int_t i=0; iProcessEvents()) break; + xmain = gRandom->Gaus(-1,1.5); + xs1 = gRandom->Gaus(-0.5,0.5); + xs2 = gRandom->Landau(1,0.15); + main->Fill(xmain); + s1->Fill(xs1,0.3); + s2->Fill(xs2,0.2); + total->Fill(xmain); + total->Fill(xs1,0.3); + total->Fill(xs2,0.2); + } + timer.TurnOff(); + hsumUpdate(); } diff --git a/tutorials/hist/multicolor.C b/tutorials/hist/multicolor.C index f0d91c486a8c1..e082e0b34d919 100644 --- a/tutorials/hist/multicolor.C +++ b/tutorials/hist/multicolor.C @@ -2,7 +2,7 @@ /// \ingroup tutorial_hist /// \notebook /// Use a THStack to show a 2-D hist with cells with different colors. -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root > .x multicolor.C /// root > .x multicolor.C(1) /// ~~~ @@ -16,7 +16,7 @@ #include "THStack.h" #include "TRandom.h" -void multicolor(Int_t stack=0) { +void multicolor(Int_t isStack=0) { TCanvas *c1 = new TCanvas; Int_t nbins = 20; TH2F *h1 = new TH2F("h1","h1",nbins,-4,4,nbins,-4,4); @@ -38,12 +38,12 @@ void multicolor(Int_t stack=0) { Int_t bin = h1->GetBin(ix,iy); Double_t val = h1->GetBinContent(bin); if (val <= 0) continue; - if (!stack) h1->SetBinContent(bin,0); + if (!isStack) h1->SetBinContent(bin,0); if (r.Rndm() > 0.5) { - if (!stack) h2->SetBinContent(bin,0); + if (!isStack) h2->SetBinContent(bin,0); h3->SetBinContent(bin,val); } else { - if (!stack) h3->SetBinContent(bin,0); + if (!isStack) h3->SetBinContent(bin,0); h2->SetBinContent(bin,val); } } diff --git a/tutorials/hist/sparsehist.C b/tutorials/hist/sparsehist.C index 3f28d8e6a265a..b15c48311b05e 100644 --- a/tutorials/hist/sparsehist.C +++ b/tutorials/hist/sparsehist.C @@ -27,7 +27,7 @@ /// interpreted one would not benchmark THnSparse but CINT. /// /// Run as: -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root[0] .L $ROOTSYS/tutorials/hist/sparsehist.C+ /// root[1] sparsehist() /// ~~~ diff --git a/tutorials/hist/th2polyBoxes.C b/tutorials/hist/th2polyBoxes.C index aa2a6909a60fb..ccfc752f825ee 100644 --- a/tutorials/hist/th2polyBoxes.C +++ b/tutorials/hist/th2polyBoxes.C @@ -19,21 +19,21 @@ TCanvas *th2polyBoxes() { Int_t i,j; Int_t nx = 40; Int_t ny = 40; - Double_t x1,y1,x2,y2; + Double_t xval1,yval1,xval2,yval2; Double_t dx=0.2, dy=0.1; - x1 = 0.; - x2 = dx; + xval1 = 0.; + xval2 = dx; for (i = 0; iAddBin(x1, y1, x2, y2); - y1 = y2; - y2 = y2+y2*dy; + h2p->AddBin(xval1, yval1, xval2, yval2); + yval1 = yval2; + yval2 = yval2+yval2*dy; } - x1 = x2; - x2 = x2+x2*dx; + xval1 = xval2; + xval2 = xval2+xval2*dx; } TRandom ran; diff --git a/tutorials/hist/th2polyEurope.C b/tutorials/hist/th2polyEurope.C index acf8980f007b4..ab71846c5f2c1 100644 --- a/tutorials/hist/th2polyEurope.C +++ b/tutorials/hist/th2polyEurope.C @@ -136,7 +136,6 @@ void th2polyEurope(Int_t npoints=500000) for (i=0; iSetBinContent(i+1, scale*p->GetBinContent(i+1)); gStyle->SetOptStat(1111); - gStyle->SetPalette(1); p->Draw("COLZ"); TCanvas *c1 = new TCanvas("c1", "c1",W+10,0,W-20,H); diff --git a/tutorials/htmlex.C b/tutorials/htmlex.C index 69354b1b6a4d5..2a21eddc1cecf 100644 --- a/tutorials/htmlex.C +++ b/tutorials/htmlex.C @@ -7,7 +7,7 @@ /// and [THtml's class documentation](https://root.cern.ch/doc/master/classTHtml.html). /// /// To see this demo script in action start up ROOT and run -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root [0] .x $(ROOTSYS)/tutorials/htmlex.C+ /// ~~~ /// and check the output in `./htmldoc`. diff --git a/tutorials/image/hsumanim.C b/tutorials/image/hsumanim.C index 306709e21d8d2..7d50be7a7fcc3 100644 --- a/tutorials/image/hsumanim.C +++ b/tutorials/image/hsumanim.C @@ -10,66 +10,66 @@ /// \authors Rene Brun, Valeriy Onuchin void hsumanim() { - c1 = new TCanvas("c1","The HSUM example",200,10,600,400); - c1->SetGrid(); + c1 = new TCanvas("c1","The HSUM example",200,10,600,400); + c1->SetGrid(); - gBenchmark->Start("hsum"); + gBenchmark->Start("hsum"); -// Create some histograms. - total = new TH1F("total","This is the total distribution",100,-4,4); - main = new TH1F("main","Main contributor",100,-4,4); - s1 = new TH1F("s1","This is the first signal",100,-4,4); - s2 = new TH1F("s2","This is the second signal",100,-4,4); - total->Sumw2(); // this makes sure that the sum of squares of weights will be stored - total->SetMarkerStyle(21); - total->SetMarkerSize(0.7); - main->SetFillColor(16); - s1->SetFillColor(42); - s2->SetFillColor(46); - TSlider *slider = 0; - gSystem->Unlink("hsumanim.gif"); // delete old file + // Create some histograms. + total = new TH1F("total","This is the total distribution",100,-4,4); + main = new TH1F("main","Main contributor",100,-4,4); + s1 = new TH1F("s1","This is the first signal",100,-4,4); + s2 = new TH1F("s2","This is the second signal",100,-4,4); + total->Sumw2(); // this makes sure that the sum of squares of weights will be stored + total->SetMarkerStyle(21); + total->SetMarkerSize(0.7); + main->SetFillColor(16); + s1->SetFillColor(42); + s2->SetFillColor(46); + TSlider *slider = 0; + gSystem->Unlink("hsumanim.gif"); // delete old file -// Fill histograms randomly - gRandom->SetSeed(); - const Int_t kUPDATE = 500; - Float_t xs1, xs2, xmain; - Int_t gifcnt = 0; - for ( Int_t i=0; i<10000; i++) { - xmain = gRandom->Gaus(-1,1.5); - xs1 = gRandom->Gaus(-0.5,0.5); - xs2 = gRandom->Landau(1,0.15); - main->Fill(xmain); - s1->Fill(xs1,0.3); - s2->Fill(xs2,0.2); - total->Fill(xmain); - total->Fill(xs1,0.3); - total->Fill(xs2,0.2); - if (i && (i%kUPDATE) == 0) { - if (i == kUPDATE) { - total->Draw("e1p"); - main->Draw("same"); - s1->Draw("same"); - s2->Draw("same"); - c1->Update(); - slider = new TSlider("slider","test",4.2,0,4.6,total->GetMaximum(),38); - slider->SetFillColor(46); - } - if (slider) slider->SetRange(0,Float_t(i)/10000.); - c1->Modified(); - c1->Update(); - if (gROOT->IsBatch()) { - c1->Print("hsumanim.gif+"); - printf("i = %d\n", i); - } - } - } - slider->SetRange(0,1); - total->Draw("sameaxis"); // to redraw axis hidden by the fill area - c1->Modified(); - // make infinite animation by adding "++" to the file name - if (gROOT->IsBatch()) c1->Print("hsumanim.gif++"); + // Fill histograms randomly + gRandom->SetSeed(); + const Int_t kUPDATE = 500; + Float_t xs1, xs2, xmain; + Int_t gifcnt = 0; + for ( Int_t i=0; i<10000; i++) { + xmain = gRandom->Gaus(-1,1.5); + xs1 = gRandom->Gaus(-0.5,0.5); + xs2 = gRandom->Landau(1,0.15); + main->Fill(xmain); + s1->Fill(xs1,0.3); + s2->Fill(xs2,0.2); + total->Fill(xmain); + total->Fill(xs1,0.3); + total->Fill(xs2,0.2); + if (i && (i%kUPDATE) == 0) { + if (i == kUPDATE) { + total->Draw("e1p"); + main->Draw("same"); + s1->Draw("same"); + s2->Draw("same"); + c1->Update(); + slider = new TSlider("slider","test",4.2,0,4.6,total->GetMaximum(),38); + slider->SetFillColor(46); + } + if (slider) slider->SetRange(0,Float_t(i)/10000.); + c1->Modified(); + c1->Update(); + if (gROOT->IsBatch()) { + c1->Print("hsumanim.gif+"); + printf("i = %d\n", i); + } + } + } + slider->SetRange(0,1); + total->Draw("sameaxis"); // to redraw axis hidden by the fill area + c1->Modified(); + // make infinite animation by adding "++" to the file name + if (gROOT->IsBatch()) c1->Print("hsumanim.gif++"); - //You can view the animated file hsumanim.gif with Netscape/IE or mozilla + //You can view the animated file hsumanim.gif with Netscape/IE or mozilla - gBenchmark->Show("hsum"); + gBenchmark->Show("hsum"); } diff --git a/tutorials/io/loopdir.C b/tutorials/io/loopdir.C index 72fbee74ccc2b..9b597c6be99a6 100644 --- a/tutorials/io/loopdir.C +++ b/tutorials/io/loopdir.C @@ -12,11 +12,11 @@ void loopdir() { TFile *f1 = TFile::Open("hsimple.root"); - TIter next(f1->GetListOfKeys()); + TIter keyList(f1->GetListOfKeys()); TKey *key; TCanvas c1; c1.Print("hsimple.ps["); - while ((key = (TKey*)next())) { + while ((key = (TKey*)keyList())) { TClass *cl = gROOT->GetClass(key->GetClassName()); if (!cl->InheritsFrom("TH1")) continue; TH1 *h = (TH1*)key->ReadObj(); diff --git a/tutorials/math/Bessel.C b/tutorials/math/Bessel.C index d69526538127d..de59d5d2bead5 100644 --- a/tutorials/math/Bessel.C +++ b/tutorials/math/Bessel.C @@ -4,7 +4,7 @@ /// Show the different kinds of Bessel functions available in ROOT /// To execute the macro type in: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root[0] .x Bessel.C /// ~~~ /// @@ -75,13 +75,13 @@ void Bessel() leg->Draw(); p1->Draw(); - //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + //------------------------------------------------ DistCanvas->cd(2); gPad->SetGrid(); gPad->SetFrameFillColor(19); TLegend *leg2 = new TLegend(0.75, 0.7, 0.89, 0.89); - //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + //------------------------------------------------ //Drawing Bessel k TF1* KBessel[5]; for(int nu = 0; nu < n; nu++){ @@ -110,12 +110,12 @@ void Bessel() leg2->AddEntry(KBessel[4]->DrawCopy("same"), " K_4(x)", "l"); leg2->Draw(); p2->Draw(); - //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + //------------------------------------------------ DistCanvas->cd(3); gPad->SetGrid(); gPad->SetFrameFillColor(19); TLegend *leg3 = new TLegend(0.75, 0.7, 0.89, 0.89); - //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + //------------------------------------------------ //Drawing Bessel i TF1* iBessel[5]; for(int nu = 0; nu <= 4; nu++){ @@ -145,12 +145,12 @@ void Bessel() leg3->AddEntry(iBessel[4]->DrawCopy("same"), " I_4(x)", "l"); leg3->Draw(); p3->Draw(); - //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + //------------------------------------------------ DistCanvas->cd(4); gPad->SetGrid(); gPad->SetFrameFillColor(19); TLegend *leg4 = new TLegend(0.75, 0.7, 0.89, 0.89); - //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + //------------------------------------------------ //drawing sph_bessel TF1* jBessel[5]; for(int nu = 0; nu <= 4; nu++){ diff --git a/tutorials/math/GammaFun.C b/tutorials/math/GammaFun.C index 933b16144c108..7c10119f7f137 100644 --- a/tutorials/math/GammaFun.C +++ b/tutorials/math/GammaFun.C @@ -4,7 +4,7 @@ /// Example showing the usage of the major special math functions (gamma, beta, erf) in ROOT /// To execute the macro type in: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root[0]: .x GammaFun.C /// ~~~ /// diff --git a/tutorials/math/Legendre.C b/tutorials/math/Legendre.C index 7a5a81a600ff2..c54ecf26f7d92 100644 --- a/tutorials/math/Legendre.C +++ b/tutorials/math/Legendre.C @@ -26,33 +26,33 @@ void Legendre() { - gSystem->Load("libMathMore"); - - TCanvas *Canvas = new TCanvas("DistCanvas", "Legendre polynomials example", 10, 10, 750, 600); - Canvas->SetFillColor(17); - Canvas->SetGrid(); - Canvas->SetFrameFillColor(19); - TLegend *leg = new TLegend(0.5, 0.7, 0.4, 0.89); -//drawing the set of Legendre functions - TF1* L[5]; - for(int nu = 0; nu <= 4; nu++) - { - L[nu]= new TF1("L_0", "ROOT::Math::legendre([0],x)", -1, 1); - L[nu]->SetParameters(nu, 0.0); - L[nu]->SetLineStyle(1); - L[nu]->SetLineWidth(2); - L[nu]->SetLineColor(nu+1); - } - L[0]->SetMaximum(1); - L[0]->SetMinimum(-1); - L[0]->SetTitle("Legendre polynomials"); - leg->AddEntry(L[0]->DrawCopy(), " L_{0}(x)", "l"); - leg->AddEntry(L[1]->DrawCopy("same"), " L_{1}(x)", "l"); - leg->AddEntry(L[2]->DrawCopy("same"), " L_{2}(x)", "l"); - leg->AddEntry(L[3]->DrawCopy("same"), " L_{3}(x)", "l"); - leg->AddEntry(L[4]->DrawCopy("same"), " L_{4}(x)", "l"); - leg->Draw(); - - Canvas->cd(); + gSystem->Load("libMathMore"); + + TCanvas *Canvas = new TCanvas("DistCanvas", "Legendre polynomials example", 10, 10, 750, 600); + Canvas->SetFillColor(17); + Canvas->SetGrid(); + Canvas->SetFrameFillColor(19); + TLegend *leg = new TLegend(0.5, 0.7, 0.4, 0.89); + //drawing the set of Legendre functions + TF1* L[5]; + for(int nu = 0; nu <= 4; nu++) + { + L[nu]= new TF1("L_0", "ROOT::Math::legendre([0],x)", -1, 1); + L[nu]->SetParameters(nu, 0.0); + L[nu]->SetLineStyle(1); + L[nu]->SetLineWidth(2); + L[nu]->SetLineColor(nu+1); + } + L[0]->SetMaximum(1); + L[0]->SetMinimum(-1); + L[0]->SetTitle("Legendre polynomials"); + leg->AddEntry(L[0]->DrawCopy(), " L_{0}(x)", "l"); + leg->AddEntry(L[1]->DrawCopy("same"), " L_{1}(x)", "l"); + leg->AddEntry(L[2]->DrawCopy("same"), " L_{2}(x)", "l"); + leg->AddEntry(L[3]->DrawCopy("same"), " L_{3}(x)", "l"); + leg->AddEntry(L[4]->DrawCopy("same"), " L_{4}(x)", "l"); + leg->Draw(); + + Canvas->cd(); } diff --git a/tutorials/math/LegendreAssoc.C b/tutorials/math/LegendreAssoc.C index b58f88c94d3b1..5410a82db92a7 100644 --- a/tutorials/math/LegendreAssoc.C +++ b/tutorials/math/LegendreAssoc.C @@ -4,7 +4,7 @@ /// Example describing the usage of different kinds of Associate Legendre Polynomials /// To execute the macro type in: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root[0] .x LegendreAssoc.C /// ~~~ /// @@ -44,7 +44,7 @@ void LegendreAssoc() TLegend *leg1 = new TLegend(0.5, 0.7, 0.8, 0.89); TLegend *leg2 = new TLegend(0.5, 0.7, 0.8, 0.89); - //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + //------------------------------------------- //drawing the set of Legendre functions TF1* L[5]; diff --git a/tutorials/math/TSVDUnfoldExample.C b/tutorials/math/TSVDUnfoldExample.C index 77656085beb00..b43c5492d787c 100644 --- a/tutorials/math/TSVDUnfoldExample.C +++ b/tutorials/math/TSVDUnfoldExample.C @@ -54,8 +54,9 @@ void TSVDUnfoldExample() const Double_t cutdummy= -99999.0; - // --- Data/MC toy generation ----------------------------------- - + // -------------------------------------- + // Data/MC toy generation + // // The MC input Int_t nbins = 40; TH1D *xini = new TH1D("xini", "MC truth", nbins, -10.0, 10.0); @@ -99,8 +100,9 @@ void TSVDUnfoldExample() statcov->SetBinContent(i,i,data->GetBinError(i)*data->GetBinError(i)); } - // --- Here starts the actual unfolding ------------------------- - + // ---------------------------- + // Here starts the actual unfolding + // // Create TSVDUnfold object and initialise TSVDUnfold *tsvdunf = new TSVDUnfold( data, statcov, bini, xini, Adet ); @@ -140,8 +142,9 @@ void TSVDUnfoldExample() TH2D* uinvcov = tsvdunf->GetXinv(); - // --- Only plotting stuff below ------------------------------ - + // --------------------------------- + // Only plotting stuff below + for (int i=1; i<=unfres->GetNbinsX(); i++) { unfres->SetBinError(i, TMath::Sqrt(utaucov->GetBinContent(i,i))); } diff --git a/tutorials/math/binomial.C b/tutorials/math/binomial.C index d2ee3d55390c2..cc715ee01a335 100644 --- a/tutorials/math/binomial.C +++ b/tutorials/math/binomial.C @@ -4,7 +4,7 @@ /// tutorial illustrating the use of TMath::Binomial /// can be run with: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root > .x binomial.C /// root > .x binomial.C+ with ACLIC /// ~~~ diff --git a/tutorials/math/exampleFunctor.C b/tutorials/math/exampleFunctor.C index 22b6808561891..43dfeaa210484 100644 --- a/tutorials/math/exampleFunctor.C +++ b/tutorials/math/exampleFunctor.C @@ -59,8 +59,9 @@ void exampleFunctor() { // in order to work with interpreter the function object must be created and lived all time for all time // of the TF1. In compiled mode, the function object can be passed by value (recommended) and there - // is also no need to specify the type of the function class. Example is as follow: - // TF1 * f2 = new TF1("f2",MyDerivFunc(f1), xmin, xmax,0); // only for C++ compiled mode + // is also no need to specify the type of the function class. Example is as follows: + // + // `TF1 * f2 = new TF1("f2",MyDerivFunc(f1), xmin, xmax,0); // only for C++ compiled mode` MyDerivFunc * deriv = new MyDerivFunc(f1); TF1 * f2 = new TF1("f2",deriv, xmin, xmax, 0); @@ -75,7 +76,8 @@ void exampleFunctor() { // in order to work with interpreter the function object must be created and lived all time for all time // of the TF1. In compiled mode there is no need to specify the type of the function class and the name // of the member function - // TF1 * f3 = new TF1("f3",intg,&MyIntegFunc::Integral,xmin,xmax, 0); // only for C++ compiled mode + // + // `TF1 * f3 = new TF1("f3",intg,&MyIntegFunc::Integral,xmin,xmax, 0); // only for C++ compiled mode` MyIntegFunc * intg = new MyIntegFunc(f1); TF1 * f3 = new TF1("f3",intg,&MyIntegFunc::Integral, xmin, xmax, 0); diff --git a/tutorials/math/exampleMultiRoot.C b/tutorials/math/exampleMultiRoot.C index 5cbae55891849..be8a4b87312e5 100644 --- a/tutorials/math/exampleMultiRoot.C +++ b/tutorials/math/exampleMultiRoot.C @@ -19,13 +19,13 @@ /// /// Usage: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// >.x exampleMultiRoot.C() /// ~~~ /// /// or /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// >.x exampleMultiRoot(algoname,printlevel) /// ~~~ /// @@ -58,7 +58,7 @@ void exampleMultiRoot(const char * algo = 0, int printlevel = 1) { #else ROOT::Math::MultiRootFinder r(algo); - //defining the function + //defining the function // use Rosenbrock functions TF2 * f1 = new TF2("f1","[0]*(1-x)+[1]*y"); TF2 * f2 = new TF2("f2","[0]*(y-x*x)"); diff --git a/tutorials/math/exampleTKDE.C b/tutorials/math/exampleTKDE.C index f110c2668c857..cf594baf2476e 100644 --- a/tutorials/math/exampleTKDE.C +++ b/tutorials/math/exampleTKDE.C @@ -12,7 +12,7 @@ #include "TF1.h" #include "TKDE.h" #include "TCanvas.h" -//#include "TStopwatch.h" +/*#include "TStopwatch.h"*/ #include "TRandom.h" #include "Math/DistFunc.h" #include "TLegend.h" diff --git a/tutorials/math/goftest.C b/tutorials/math/goftest.C index 5d661b1efd64b..bcd10daca270a 100644 --- a/tutorials/math/goftest.C +++ b/tutorials/math/goftest.C @@ -218,12 +218,12 @@ void goftest() { // a) User input PDF ROOT::Math::Functor1D f(&landau); - double min = 3*TMath::MinElement(nEvents3, sample3); - double max = 3*TMath::MaxElement(nEvents3, sample3); - ROOT::Math::GoFTest* goftest_3a = new ROOT::Math::GoFTest(nEvents3, sample3, f, ROOT::Math::GoFTest::kPDF, min,max); // need to specify am interval + double minimum = 3*TMath::MinElement(nEvents3, sample3); + double maximum = 3*TMath::MaxElement(nEvents3, sample3); + ROOT::Math::GoFTest* goftest_3a = new ROOT::Math::GoFTest(nEvents3, sample3, f, ROOT::Math::GoFTest::kPDF, minimum,maximum); // need to specify am interval // b) User input CDF ROOT::Math::Functor1D fI(&TMath::LandauI); - ROOT::Math::GoFTest* goftest_3b = new ROOT::Math::GoFTest(nEvents3, sample3, fI, ROOT::Math::GoFTest::kCDF,min,max); + ROOT::Math::GoFTest* goftest_3b = new ROOT::Math::GoFTest(nEvents3, sample3, fI, ROOT::Math::GoFTest::kCDF,minimum,maximum); // Returning the p-value for the Anderson-Darling test statistic diff --git a/tutorials/math/limit.C b/tutorials/math/limit.C index 9befb881614e7..99019931e4f81 100644 --- a/tutorials/math/limit.C +++ b/tutorials/math/limit.C @@ -32,15 +32,15 @@ void limit() { c1->SetFillColor(42); // Create some histograms - TH1D* background = new TH1D("background","The expected background",30,-4,4); - TH1D* signal = new TH1D("signal","the expected signal",30,-4,4); - TH1D* data = new TH1D("data","some fake data points",30,-4,4); - background->SetFillColor(48); - signal->SetFillColor(41); - data->SetMarkerStyle(21); - data->SetMarkerColor(kBlue); - background->Sumw2(); // needed for stat uncertainty - signal->Sumw2(); // needed for stat uncertainty + TH1D* backgroundHist = new TH1D("background","The expected background",30,-4,4); + TH1D* signalHist = new TH1D("signal","the expected signal",30,-4,4); + TH1D* dataHist = new TH1D("data","some fake data points",30,-4,4); + backgroundHist->SetFillColor(48); + signalHist->SetFillColor(41); + dataHist->SetMarkerStyle(21); + dataHist->SetMarkerColor(kBlue); + backgroundHist->Sumw2(); // needed for stat uncertainty + signalHist->Sumw2(); // needed for stat uncertainty // Fill histograms randomly TRandom2 r; @@ -48,18 +48,18 @@ void limit() { for (Int_t i = 0; i < 25000; i++) { bg = r.Gaus(0,1); sig = r.Gaus(1,.2); - background->Fill(bg,0.02); - signal->Fill(sig,0.001); + backgroundHist->Fill(bg,0.02); + signalHist->Fill(sig,0.001); } for (Int_t i = 0; i < 500; i++) { dt = r.Gaus(0,1); - data->Fill(dt); + dataHist->Fill(dt); } THStack *hs = new THStack("hs","Signal and background compared to data..."); - hs->Add(background); - hs->Add(signal); + hs->Add(backgroundHist); + hs->Add(signalHist); hs->Draw("hist"); - data->Draw("PE1,Same"); + dataHist->Draw("PE1,Same"); c1->Modified(); c1->Update(); c1->GetFrame()->SetFillColor(21); @@ -71,7 +71,7 @@ void limit() { // Compute the limits cout << "Computing limits... " << endl; - TLimitDataSource* mydatasource = new TLimitDataSource(signal,background,data); + TLimitDataSource* mydatasource = new TLimitDataSource(signalHist,backgroundHist,dataHist); TConfidenceLevel *myconfidence = TLimit::ComputeLimit(mydatasource,50000); cout << "CLs : " << myconfidence->CLs() << endl; cout << "CLsb : " << myconfidence->CLsb() << endl; @@ -104,7 +104,7 @@ void limit() { errors[0]=0; // error source 1: 0% errors[1]=0.01; // error source 2: 1% TLimitDataSource* mynewdatasource = new TLimitDataSource(); - mynewdatasource->AddChannel(signal,background,data,&errors,&errorb,names); + mynewdatasource->AddChannel(signalHist,backgroundHist,dataHist,&errors,&errorb,names); TConfidenceLevel *mynewconfidence = TLimit::ComputeLimit(mynewdatasource,50000,true); cout << "CLs : " << mynewconfidence->CLs() << endl; cout << "CLsb : " << mynewconfidence->CLsb() << endl; diff --git a/tutorials/math/mathcoreCDF.C b/tutorials/math/mathcoreCDF.C index f90087d6851b7..a3afb7221863a 100644 --- a/tutorials/math/mathcoreCDF.C +++ b/tutorials/math/mathcoreCDF.C @@ -5,7 +5,7 @@ /// The macro shows four of them with /// respect to their two variables. In order to run the macro type: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root [0] .x mathcoreCDF.C /// ~~~ /// diff --git a/tutorials/math/mathcoreGenVector.C b/tutorials/math/mathcoreGenVector.C index 0783322fc635e..db85df9369c05 100644 --- a/tutorials/math/mathcoreGenVector.C +++ b/tutorials/math/mathcoreGenVector.C @@ -14,7 +14,7 @@ /// /// To execute the macro type in: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root[0] .x mathcoreGenVector.C /// ~~~ /// diff --git a/tutorials/math/mathcoreSpecFunc.C b/tutorials/math/mathcoreSpecFunc.C index e82a7f278ec06..aa47b00696146 100644 --- a/tutorials/math/mathcoreSpecFunc.C +++ b/tutorials/math/mathcoreSpecFunc.C @@ -5,7 +5,7 @@ /// taking full advantage of the precision and speed of the C99 compliant /// environments. To execute the macro type in: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root[0] .x mathcoreSpecFunc.C /// ~~~ /// diff --git a/tutorials/math/mathcoreStatFunc.C b/tutorials/math/mathcoreStatFunc.C index d958fc25a8fb3..2c5393af60f36 100644 --- a/tutorials/math/mathcoreStatFunc.C +++ b/tutorials/math/mathcoreStatFunc.C @@ -5,7 +5,7 @@ /// The macro shows four of them with /// respect to their two variables. In order to run the macro type: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root [0] .x mathcoreStatFunc.C /// ~~~ /// diff --git a/tutorials/math/mathcoreVectorCollection.C b/tutorials/math/mathcoreVectorCollection.C index 4b8c3329b75f5..0a8ef417eaf36 100644 --- a/tutorials/math/mathcoreVectorCollection.C +++ b/tutorials/math/mathcoreVectorCollection.C @@ -11,7 +11,7 @@ /// /// To execute the macro type in: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root[0]: .x mathcoreVectorCollection.C /// ~~~ /// diff --git a/tutorials/math/mathcoreVectorFloatIO.C b/tutorials/math/mathcoreVectorFloatIO.C index 6a4d5f21019ae..f43e982d50f4f 100644 --- a/tutorials/math/mathcoreVectorFloatIO.C +++ b/tutorials/math/mathcoreVectorFloatIO.C @@ -7,7 +7,7 @@ /// /// To run this macro you must do /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root[0] .L mathcoreVectorFloatIO.C+ /// root[1] runIt(); /// ~~~ diff --git a/tutorials/math/mathcoreVectorIO.C b/tutorials/math/mathcoreVectorIO.C index 4b55134f964b7..aed84af49b68a 100644 --- a/tutorials/math/mathcoreVectorIO.C +++ b/tutorials/math/mathcoreVectorIO.C @@ -6,7 +6,7 @@ /// /// To execute the macro type in: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root[0] .x mathcoreVectorIO.C /// ~~~ /// diff --git a/tutorials/math/mathmoreIntegration.C b/tutorials/math/mathmoreIntegration.C index 80cfdf49d9ee1..2997518bc92a5 100644 --- a/tutorials/math/mathmoreIntegration.C +++ b/tutorials/math/mathmoreIntegration.C @@ -5,7 +5,7 @@ /// it calculates the numerically cumulative integral of a distribution (like in this case the BreitWigner) /// to execute the macro type it (you need to compile with AClic) /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root[0] .x mathmoreIntegration.C+ /// ~~~ /// @@ -26,7 +26,7 @@ #include "TCanvas.h" #include "TLegend.h" -//#include "TLabel.h" +/*#include "TLabel.h"*/ #include "Math/Functor.h" #include "Math/WrappedFunction.h" #include "Math/IFunction.h" diff --git a/tutorials/math/permute.C b/tutorials/math/permute.C index a1ed54d5004bb..c462bb6b7963e 100644 --- a/tutorials/math/permute.C +++ b/tutorials/math/permute.C @@ -4,7 +4,7 @@ /// Tutorial illustrating the use of TMath::Permute /// can be run with: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root > .x permute.C /// root > .x permute.C+ with ACLIC /// ~~~ diff --git a/tutorials/math/principal.C b/tutorials/math/principal.C index 41e879a93ee86..2233138a68b58 100644 --- a/tutorials/math/principal.C +++ b/tutorials/math/principal.C @@ -39,7 +39,7 @@ void principal(Int_t n=10, Int_t m=10000) TPrincipal* principal = new TPrincipal(n,"ND"); // Use a pseudo-random number generator - TRandom* random1 = new TRandom; + TRandom* randumNum = new TRandom; // Make the m data-points // Make a variable to hold our data @@ -50,9 +50,9 @@ void principal(Int_t n=10, Int_t m=10000) // First we create the un-correlated, random variables, according // to one of three distributions for (Int_t j = 0; j < n - c; j++) { - if (j % 3 == 0) data[j] = random1->Gaus(5,1); - else if (j % 3 == 1) data[j] = random1->Poisson(8); - else data[j] = random1->Exp(2); + if (j % 3 == 0) data[j] = randumNum->Gaus(5,1); + else if (j % 3 == 1) data[j] = randumNum->Poisson(8); + else data[j] = randumNum->Exp(2); } // Then we create the correlated variables diff --git a/tutorials/math/tStudent.C b/tutorials/math/tStudent.C index 88c0296c4d1f6..25e184e7142c8 100644 --- a/tutorials/math/tStudent.C +++ b/tutorials/math/tStudent.C @@ -3,7 +3,7 @@ /// \notebook /// Example macro describing the student t distribution /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root[0]: .x tStudent.C /// ~~~ /// diff --git a/tutorials/math/testrandom.C b/tutorials/math/testrandom.C index f412c2357f2c3..5128e37b75a68 100644 --- a/tutorials/math/testrandom.C +++ b/tutorials/math/testrandom.C @@ -32,7 +32,7 @@ /// /// Note that this tutorial can be executed in interpreted or compiled mode /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// Root > .x testrandom.C /// Root > .x testrandom.C++ /// ~~~ diff --git a/tutorials/matrix/invertMatrix.C b/tutorials/matrix/invertMatrix.C index a6a9291205ed2..4e954466b68bc 100644 --- a/tutorials/matrix/invertMatrix.C +++ b/tutorials/matrix/invertMatrix.C @@ -12,11 +12,11 @@ /// /// This macro can be executed with Cling or ACLIC /// - via the interpretor, do -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root > .x invertMatrix.C /// ~~~ /// - via ACLIC -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root > gSystem->Load("libMatrix"); /// root > .x invertMatrix.C+ /// ~~~ @@ -48,21 +48,21 @@ void invertMatrix(Int_t msize=6) TMatrixD H_square = THilbertMatrixD(msize,msize); - // 1. InvertFast(Double_t *det=0) - // It is identical to Invert() for sizes > 6 x 6 but for smaller sizes, the - // inversion is performed according to Cramer's rule by explicitly calculating - // all Jacobi's sub-determinants . For instance for a 6 x 6 matrix this means: - // # of 5 x 5 determinant : 36 - // # of 4 x 4 determinant : 75 - // # of 3 x 3 determinant : 80 - // # of 2 x 2 determinant : 45 (see TMatrixD/FCramerInv.cxx) + // ### 1. InvertFast(Double_t *det=0) + // It is identical to Invert() for sizes > 6 x 6 but for smaller sizes, the + // inversion is performed according to Cramer's rule by explicitly calculating + // all Jacobi's sub-determinants . For instance for a 6 x 6 matrix this means: + // \# of 5 x 5 determinant : 36 + // \# of 4 x 4 determinant : 75 + // \# of 3 x 3 determinant : 80 + // \# of 2 x 2 determinant : 45 (see TMatrixD/FCramerInv.cxx) // - // The only "quality" control in this process is to check whether the 6 x 6 - // determinant is unequal 0 . But speed gains are significant compared to Invert() , - // up to an order of magnitude for sizes <= 4 x 4 + // The only "quality" control in this process is to check whether the 6 x 6 + // determinant is unequal 0 . But speed gains are significant compared to Invert() , + // up to an order of magnitude for sizes <= 4 x 4 // - // The inversion is done "in place", so the original matrix will be overwritten - // If a pointer to a Double_t is supplied the determinant is calculated + // The inversion is done "in place", so the original matrix will be overwritten + // If a pointer to a Double_t is supplied the determinant is calculated // std::cout << "1. Use .InvertFast(&det)" < 1 - // - The last step is a standard forward/backward substitution . + // ### 2. Invert(Double_t *det=0) + // Again the inversion is performed in place . + // It consists out of a sequence of calls to the decomposition classes . For instance + // for the general dense matrix TMatrixD the LU decomposition is invoked: + // - The matrix is decomposed using a scheme according to Crout which involves + // "implicit partial pivoting", see for instance Num. Recip. (we have also available + // a decomposition scheme that does not the scaling and is therefore even slightly + // faster but less stable) + // With each decomposition, a tolerance has to be specified . If this tolerance + // requirement is not met, the matrix is regarded as being singular. The value + // passed to this decomposition, is the data member fTol of the matrix . Its + // default value is DBL_EPSILON, which is defined as the smallest number so that + // 1+DBL_EPSILON > 1 + // - The last step is a standard forward/backward substitution . // - // It is important to realize that both InvertFast() and Invert() are "one-shot" deals , speed - // comes at a price . If something goes wrong because the matrix is (near) singular, you have - // overwritten your original matrix and no factorization is available anymore to get more - // information like condition number or change the tolerance number . + // It is important to realize that both InvertFast() and Invert() are "one-shot" deals , speed + // comes at a price . If something goes wrong because the matrix is (near) singular, you have + // overwritten your original matrix and no factorization is available anymore to get more + // information like condition number or change the tolerance number . // - // All other calls in the matrix classes involving inversion like the ones with the "smart" - // constructors (kInverted,kInvMult...) use this inversion method . + // All other calls in the matrix classes involving inversion like the ones with the "smart" + // constructors (kInverted,kInvMult...) use this inversion method . // std::cout << "2. Use .Invert(&det)" << std::endl; @@ -118,13 +118,13 @@ void invertMatrix(Int_t msize=6) std::cout << " Maximum off-diagonal = " << U2_max_offdiag << std::endl; std::cout << " Determinant = " << det2 << std::endl; - // 3. Inversion through LU decomposition - // The (default) algorithms used are similar to 2. (Not identical because in 2, the whole - // calculation is done "in-place". Here the original matrix is copied (so more memory - // management => slower) and several operations can be performed without having to repeat - // the decomposition step . - // Inverting a matrix is nothing else than solving a set of equations where the rhs is given - // by the unit matrix, so the steps to take are identical to those solving a linear equation : + // ### 3. Inversion through LU decomposition + // The (default) algorithms used are similar to 2. (Not identical because in 2, the whole + // calculation is done "in-place". Here the original matrix is copied (so more memory + // management => slower) and several operations can be performed without having to repeat + // the decomposition step . + // Inverting a matrix is nothing else than solving a set of equations where the rhs is given + // by the unit matrix, so the steps to take are identical to those solving a linear equation : // std::cout << "3. Use TDecompLU" << std::endl; @@ -149,9 +149,9 @@ void invertMatrix(Int_t msize=6) std::cout << " Maximum off-diagonal = " << U3_max_offdiag << std::endl; std::cout << " Determinant = " << det3 << std::endl; - // 4. Inversion through SVD decomposition - // For SVD and QRH, the (n x m) matrix does only have to fulfill n >=m . In case n > m - // a pseudo-inverse is calculated + // ### 4. Inversion through SVD decomposition + // For SVD and QRH, the (n x m) matrix does only have to fulfill n >=m . In case n > m + // a pseudo-inverse is calculated std::cout << "4. Use TDecompSVD on non-square matrix" << std::endl; TMatrixD H_nsquare = THilbertMatrixD(msize,msize-1); diff --git a/tutorials/matrix/solveLinear.C b/tutorials/matrix/solveLinear.C index 304f4ba43e389..a16af787bb234 100644 --- a/tutorials/matrix/solveLinear.C +++ b/tutorials/matrix/solveLinear.C @@ -54,11 +54,11 @@ /// /// This macro can be executed via CINT or via ACLIC /// - via the interpretor, do -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root > .x solveLinear.C /// ~~~ /// - via ACLIC -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root > gSystem->Load("libMatrix"); /// root > gSystem->Load("libGpad"); /// root > .x solveLinear.C+ @@ -80,78 +80,78 @@ void solveLinear(Double_t eps = 1.e-12) { - cout << "Perform the fit y = c0 + c1 * x in four different ways" << endl; + cout << "Perform the fit y = c0 + c1 * x in four different ways" << endl; - const Int_t nrVar = 2; - const Int_t nrPnts = 4; + const Int_t nrVar = 2; + const Int_t nrPnts = 4; - Double_t ax[] = {0.0,1.0,2.0,3.0}; - Double_t ay[] = {1.4,1.5,3.7,4.1}; - Double_t ae[] = {0.5,0.2,1.0,0.5}; + Double_t ax[] = {0.0,1.0,2.0,3.0}; + Double_t ay[] = {1.4,1.5,3.7,4.1}; + Double_t ae[] = {0.5,0.2,1.0,0.5}; - // Make the vectors 'Use" the data : they are not copied, the vector data - // pointer is just set appropriately + // Make the vectors 'Use" the data : they are not copied, the vector data + // pointer is just set appropriately - TVectorD x; x.Use(nrPnts,ax); - TVectorD y; y.Use(nrPnts,ay); - TVectorD e; e.Use(nrPnts,ae); + TVectorD x; x.Use(nrPnts,ax); + TVectorD y; y.Use(nrPnts,ay); + TVectorD e; e.Use(nrPnts,ae); - TMatrixD A(nrPnts,nrVar); - TMatrixDColumn(A,0) = 1.0; - TMatrixDColumn(A,1) = x; + TMatrixD A(nrPnts,nrVar); + TMatrixDColumn(A,0) = 1.0; + TMatrixDColumn(A,1) = x; - cout << " - 1. solve through Normal Equations" << endl; + cout << " - 1. solve through Normal Equations" << endl; - const TVectorD c_norm = NormalEqn(A,y,e); + const TVectorD c_norm = NormalEqn(A,y,e); - cout << " - 2. solve through SVD" << endl; - // numerically preferred method + cout << " - 2. solve through SVD" << endl; + // numerically preferred method - // first bring the weights in place - TMatrixD Aw = A; - TVectorD yw = y; - for (Int_t irow = 0; irow < A.GetNrows(); irow++) { - TMatrixDRow(Aw,irow) *= 1/e(irow); - yw(irow) /= e(irow); - } + // first bring the weights in place + TMatrixD Aw = A; + TVectorD yw = y; + for (Int_t irow = 0; irow < A.GetNrows(); irow++) { + TMatrixDRow(Aw,irow) *= 1/e(irow); + yw(irow) /= e(irow); + } - TDecompSVD svd(Aw); - Bool_t ok; - const TVectorD c_svd = svd.Solve(yw,ok); + TDecompSVD svd(Aw); + Bool_t ok; + const TVectorD c_svd = svd.Solve(yw,ok); - cout << " - 3. solve with pseudo inverse" << endl; + cout << " - 3. solve with pseudo inverse" << endl; - const TMatrixD pseudo1 = svd.Invert(); - TVectorD c_pseudo1 = yw; - c_pseudo1 *= pseudo1; + const TMatrixD pseudo1 = svd.Invert(); + TVectorD c_pseudo1 = yw; + c_pseudo1 *= pseudo1; - cout << " - 4. solve with pseudo inverse, calculated brute force" << endl; + cout << " - 4. solve with pseudo inverse, calculated brute force" << endl; - TMatrixDSym AtA(TMatrixDSym::kAtA,Aw); - const TMatrixD pseudo2 = AtA.Invert() * Aw.T(); - TVectorD c_pseudo2 = yw; - c_pseudo2 *= pseudo2; + TMatrixDSym AtA(TMatrixDSym::kAtA,Aw); + const TMatrixD pseudo2 = AtA.Invert() * Aw.T(); + TVectorD c_pseudo2 = yw; + c_pseudo2 *= pseudo2; - cout << " - 5. Minuit through TGraph" << endl; + cout << " - 5. Minuit through TGraph" << endl; - TGraphErrors *gr = new TGraphErrors(nrPnts,ax,ay,0,ae); - TF1 *f1 = new TF1("f1","pol1",0,5); - gr->Fit("f1","Q"); - TVectorD c_graph(nrVar); - c_graph(0) = f1->GetParameter(0); - c_graph(1) = f1->GetParameter(1); + TGraphErrors *gr = new TGraphErrors(nrPnts,ax,ay,0,ae); + TF1 *f1 = new TF1("f1","pol1",0,5); + gr->Fit("f1","Q"); + TVectorD c_graph(nrVar); + c_graph(0) = f1->GetParameter(0); + c_graph(1) = f1->GetParameter(1); - // Check that all 4 answers are identical within a certain - // tolerance . The 1e-12 is somewhat arbitrary . It turns out that - // the TGraph fit is different by a few times 1e-13. + // Check that all 4 answers are identical within a certain + // tolerance . The 1e-12 is somewhat arbitrary . It turns out that + // the TGraph fit is different by a few times 1e-13. - Bool_t same = kTRUE; - same &= VerifyVectorIdentity(c_norm,c_svd,0,eps); - same &= VerifyVectorIdentity(c_norm,c_pseudo1,0,eps); - same &= VerifyVectorIdentity(c_norm,c_pseudo2,0,eps); - same &= VerifyVectorIdentity(c_norm,c_graph,0,eps); - if (same) - cout << " All solutions are the same within tolerance of " << eps << endl; - else - cout << " Some solutions differ more than the allowed tolerance of " << eps << endl; + Bool_t same = kTRUE; + same &= VerifyVectorIdentity(c_norm,c_svd,0,eps); + same &= VerifyVectorIdentity(c_norm,c_pseudo1,0,eps); + same &= VerifyVectorIdentity(c_norm,c_pseudo2,0,eps); + same &= VerifyVectorIdentity(c_norm,c_graph,0,eps); + if (same) + cout << " All solutions are the same within tolerance of " << eps << endl; + else + cout << " Some solutions differ more than the allowed tolerance of " << eps << endl; } diff --git a/tutorials/multicore/mp101_fillNtuples.C b/tutorials/multicore/mp101_fillNtuples.C index d26d35c11e4bd..a2ffd1606ed77 100644 --- a/tutorials/multicore/mp101_fillNtuples.C +++ b/tutorials/multicore/mp101_fillNtuples.C @@ -34,7 +34,8 @@ Int_t mp101_fillNtuples() // No nuisance for batch execution gROOT->SetBatch(); - // Perform the operation sequentially --------------------------------------- + //--------------------------------------- + // Perform the operation sequentially // Create a random generator and and Ntuple to hold the numbers TRandom3 rndm(1); @@ -44,7 +45,8 @@ Int_t mp101_fillNtuples() randomNumbers.Write(); ofile.Close(); - // We now go MP! ------------------------------------------------------------ + //--------------------------------------- + // We now go MP! // We define our work item auto workItem = [](UInt_t workerID) { diff --git a/tutorials/multicore/mp102_readNtuplesFillHistosAndFit.C b/tutorials/multicore/mp102_readNtuplesFillHistosAndFit.C index 2c612e526db55..0aee5525b8575 100644 --- a/tutorials/multicore/mp102_readNtuplesFillHistosAndFit.C +++ b/tutorials/multicore/mp102_readNtuplesFillHistosAndFit.C @@ -15,14 +15,16 @@ Int_t mp102_readNtuplesFillHistosAndFit() // No nuisance for batch execution gROOT->SetBatch(); - // Perform the operation sequentially --------------------------------------- + //--------------------------------------- + // Perform the operation sequentially TChain inputChain("multiCore"); inputChain.Add("mp101_multiCore_*.root"); TH1F outHisto("outHisto", "Random Numbers", 128, -4, 4); inputChain.Draw("r >> outHisto"); outHisto.Fit("gaus"); - // We now go MP! ------------------------------------------------------------ + //--------------------------------------- + // We now go MP! // TProcPool offers an interface to directly process trees and chains without // the need for the user to go through the low level implementation of a // map-reduce. diff --git a/tutorials/pyroot/parse_CSV_file_with_TTree_ReadStream.py b/tutorials/pyroot/parse_CSV_file_with_TTree_ReadStream.py index 5e291234078fe..dde4bf6ab71d3 100644 --- a/tutorials/pyroot/parse_CSV_file_with_TTree_ReadStream.py +++ b/tutorials/pyroot/parse_CSV_file_with_TTree_ReadStream.py @@ -11,7 +11,7 @@ ## This example is shipped with a data ## file that looks like: ## -## ~~~ {.cpp} +## ```cpp ## Date/Time Synchro Capacity Temp.Cold Head Temp. Electrode HV Supply Voltage Electrode 1 Electrode 2 Electrode 3 Electrode 4 ## # Example data to read out. Some data have oddities that might need to ## # dealt with, including the 'NaN' in Electrode 4 and the empty string in Date/Time (last row) @@ -23,7 +23,7 @@ ## 08112010.160628 7 5.702000E-10 8.786000 24.237400 -0.009141 0 0 0 0 ## 08112010.160633 7 5.710000E-10 9.016200 24.237200 -0.008818 0 0 0 0 ## 7 5.710000E-10 8.903400 24.237200 -0.008818 0 0 0 0 -## ~~~ +## ``` ## ## These data require some massaging, including: ## diff --git a/tutorials/pythia/pythia8.C b/tutorials/pythia/pythia8.C index e62c7102d3147..ce8a55748ec8b 100644 --- a/tutorials/pythia/pythia8.C +++ b/tutorials/pythia/pythia8.C @@ -4,7 +4,7 @@ /// /// to run, do: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root > .x pythia8.C /// ~~~ /// diff --git a/tutorials/pythia/pythiaExample.C b/tutorials/pythia/pythiaExample.C index 3de56475a6f96..a797e9a2bf02f 100644 --- a/tutorials/pythia/pythiaExample.C +++ b/tutorials/pythia/pythiaExample.C @@ -4,7 +4,7 @@ /// /// To make an event sample (of size 100) do /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// shell> root /// root [0] .L pythiaExample.C /// root [1] makeEventSample(1000) @@ -12,7 +12,7 @@ /// /// To start the tree view on the generated tree, do /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// shell> root /// root [0] .L pythiaExample.C /// root [1] showEventSample() @@ -20,7 +20,7 @@ /// /// The following session: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// shell> root /// root [0] .x pythiaExample.C(500) /// ~~~ @@ -30,13 +30,13 @@ /// Alternatively, you can compile this to a program /// and then generate 1000 events with /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// ./pythiaExample 1000 /// ~~~ /// /// To use the program to start the viewer, do /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// ./pythiaExample -1 /// ~~~ /// @@ -47,7 +47,7 @@ /// is in the pythia6 subdirectory of your $HOME. Locations /// that can specify this, are: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// Root.DynamicPath resource in your ROOT configuration file /// (/etc/root/system.rootrc or ~/.rootrc). /// Runtime load paths set on the executable (Using GNU ld, @@ -61,7 +61,7 @@ /// /// NOTE 2: The example can also be run with ACLIC: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root > gSystem->Load("libEG"); /// root > gSystem->Load("$ROOTSYS/../pythia6/libPythia6"); //change to your setup /// root > gSystem->Load("libEGPythia6"); diff --git a/tutorials/quadp/portfolio.C b/tutorials/quadp/portfolio.C index 990a59683d884..9f8bb8a9731a2 100644 --- a/tutorials/quadp/portfolio.C +++ b/tutorials/quadp/portfolio.C @@ -4,13 +4,13 @@ /// This macro shows in detail the use of the quadratic programming package quadp . /// Running this macro : /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// .x portfolio.C+ /// ~~~ /// /// or /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// gSystem->Load("libQuadp"); /// .L portFolio.C+; portfolio() /// ~~~ @@ -27,11 +27,11 @@ /// the unknowns, that can not be done by Minuit/Fumili . Well, we have in addition /// the following boundary conditions on \f$ x \f$: /// -/// \f[ +/// \f[ /// A x = b \\ /// clo \le C x \le cup \\ /// xlo \le x \le xup -/// \f] where A and C are arbitrary matrices and the rest are vectors +/// \f] where A and C are arbitrary matrices and the rest are vectors /// /// Not all these constraints have to be defined . Our example will only use \f$ xlo \f$, /// \f$ A \f$ and \f$ b \f$ @@ -74,10 +74,10 @@ /// /// The expected value of the utility function is : /// -/// \f[ +/// \f[ /// E(u(x)) = Int (1-exp(-k*x) N(x) dx \\ /// = 1-exp(-k (r^T x - 0.5 k x^T Covar x) ) \\ -/// \f] +/// \f] /// /// Its value is maximised by maximising \f$ r^T x -0.5 k x^T Covar x \f$ /// under the condition \f$ sum (x_i) = 1 \f$, meaning we want all our money invested and diff --git a/tutorials/roofit/rf102_dataimport.C b/tutorials/roofit/rf102_dataimport.C index 17315dd8a677b..45a5574727bff 100644 --- a/tutorials/roofit/rf102_dataimport.C +++ b/tutorials/roofit/rf102_dataimport.C @@ -28,9 +28,9 @@ TTree* makeTTree() ; void rf102_dataimport() { - //////////////////////////////////////////////////////// - // I m p o r t i n g R O O T h i s t o g r a m s // - //////////////////////////////////////////////////////// + // --------------------------------------------------- + // I m p o r t i n g R O O T h i s t o g r a m s + // =================================================== // I m p o r t T H 1 i n t o a R o o D a t a H i s t // --------------------------------------------------------- @@ -77,9 +77,9 @@ void rf102_dataimport() // fitted with a chi^2 fit (see rf602_chi2fit.C) - //////////////////////////////////////////////// - // I m p o r t i n g R O O T T T r e e s // - //////////////////////////////////////////////// + // ----------------------------------------- + // I m p o r t i n g R O O T T T r e e s + // ========================================= // I m p o r t T T r e e i n t o a R o o D a t a S e t diff --git a/tutorials/roofit/rf103_interprfuncs.C b/tutorials/roofit/rf103_interprfuncs.C index 21560e8040d1b..acaf70cd9b7d3 100644 --- a/tutorials/roofit/rf103_interprfuncs.C +++ b/tutorials/roofit/rf103_interprfuncs.C @@ -26,9 +26,9 @@ using namespace RooFit ; void rf103_interprfuncs() { - ///////////////////////////////////////////////////////// - // G e n e r i c i n t e r p r e t e d p . d . f . // - ///////////////////////////////////////////////////////// + // ---------------------------------------------------- + // G e n e r i c i n t e r p r e t e d p . d . f . + // ==================================================== // Declare observable x RooRealVar x("x","x",-20,20) ; @@ -58,12 +58,10 @@ void rf103_interprfuncs() genpdf.plotOn(xframe) ; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // S t a n d a r d p . d . f a d j u s t w i t h i n t e r p r e t e d h e l p e r f u n c t i o n // - // // - // Make a gauss(x,sqrt(mean2),sigma) from a standard RooGaussian // - // // - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ----------------------------------------------------------------------------------------------------------- + // S t a n d a r d p . d . f a d j u s t w i t h i n t e r p r e t e d h e l p e r f u n c t i o n + // ========================================================================================================== + // Make a gauss(x,sqrt(mean2),sigma) from a standard RooGaussian // C o n s t r u c t s t a n d a r d p d f w i t h f o r m u l a r e p l a c i n g p a r a m e t e r diff --git a/tutorials/roofit/rf104_classfactory.C b/tutorials/roofit/rf104_classfactory.C index be5f53f889368..6d078cece899f 100644 --- a/tutorials/roofit/rf104_classfactory.C +++ b/tutorials/roofit/rf104_classfactory.C @@ -88,9 +88,9 @@ void rf104_classfactory() pdf.plotOn(frame1) ; - /////////////////////////////////////////////////////////////////////// - // C o m p i l e d v e r s i o n o f e x a m p l e r f 1 0 3 // - /////////////////////////////////////////////////////////////////////// + // ----------------------------------------------------------------- + // C o m p i l e d v e r s i o n o f e x a m p l e r f 1 0 3 + // ================================================================= // Declare observable x RooRealVar x("x","x",-20,20) ; diff --git a/tutorials/roofit/rf105_funcbinding.C b/tutorials/roofit/rf105_funcbinding.C index a67c4e6389ea8..8fb2ef3dd14ef 100644 --- a/tutorials/roofit/rf105_funcbinding.C +++ b/tutorials/roofit/rf105_funcbinding.C @@ -1,6 +1,6 @@ /// \file /// \ingroup tutorial_roofit -/// \notebook +/// \notebook -js /// 'BASIC FUNCTIONALITY' RooFit tutorial macro #105 /// /// Demonstration of binding ROOT Math functions as RooFit functions @@ -33,14 +33,14 @@ void rf105_funcbinding() // Bind one-dimensional TMath::Erf function as RooAbsReal function RooRealVar x("x","x",-3,3) ; - RooAbsReal* erf = bindFunction("erf",TMath::Erf,x) ; + RooAbsReal* errorFunc = bindFunction("erf",TMath::Erf,x) ; // Print erf definition - erf->Print() ; + errorFunc->Print() ; // Plot erf on frame RooPlot* frame1 = x.frame(Title("TMath::Erf bound as RooFit function")) ; - erf->plotOn(frame1) ; + errorFunc->plotOn(frame1) ; // B i n d R O O T : : M a t h : : b e t a _ p d f C f u n c t i o n diff --git a/tutorials/roofit/rf201_composite.C b/tutorials/roofit/rf201_composite.C index bea4f61baa88d..ef3b6194d44a6 100644 --- a/tutorials/roofit/rf201_composite.C +++ b/tutorials/roofit/rf201_composite.C @@ -45,9 +45,9 @@ void rf201_composite() RooChebychev bkg("bkg","Background",x,RooArgSet(a0,a1)) ; - //////////////////////////////////////////////////// - // M E T H O D 1 - T w o R o o A d d P d f s // - //////////////////////////////////////////////////// + // --------------------------------------------- + // M E T H O D 1 - T w o R o o A d d P d f s + // ============================================= // A d d s i g n a l c o m p o n e n t s @@ -90,9 +90,9 @@ void rf201_composite() model.Print("t") ; - //////////////////////////////////////////////////////////////////////////////////////////////////// - // M E T H O D 2 - O n e R o o A d d P d f w i t h r e c u r s i v e f r a c t i o n s // - //////////////////////////////////////////////////////////////////////////////////////////////////// + // --------------------------------------------------------------------------------------------- + // M E T H O D 2 - O n e R o o A d d P d f w i t h r e c u r s i v e f r a c t i o n s + // ============================================================================================= // Construct sum of models on one go using recursive fraction interpretations // diff --git a/tutorials/roofit/rf202_extendedmlfit.C b/tutorials/roofit/rf202_extendedmlfit.C index 6dfbb866ff011..88932406de98d 100644 --- a/tutorials/roofit/rf202_extendedmlfit.C +++ b/tutorials/roofit/rf202_extendedmlfit.C @@ -48,9 +48,9 @@ void rf202_extendedmlfit() RooRealVar sig1frac("sig1frac","fraction of component 1 in signal",0.8,0.,1.) ; RooAddPdf sig("sig","Signal",RooArgList(sig1,sig2),sig1frac) ; - ///////////////////// - // M E T H O D 1 // - ///////////////////// + //---------------- + // M E T H O D 1 + //================ // C o n s t r u c t e x t e n d e d c o m p o s i t e m o d e l @@ -89,9 +89,9 @@ void rf202_extendedmlfit() model.Print("t") ; - ///////////////////// - // M E T H O D 2 // - ///////////////////// + //---------------- + // M E T H O D 2 + //================ // C o n s t r u c t e x t e n d e d c o m p o n e n t s f i r s t // --------------------------------------------------------------------- diff --git a/tutorials/roofit/rf207_comptools.C b/tutorials/roofit/rf207_comptools.C index 63ef801094860..d38f2bde59d59 100644 --- a/tutorials/roofit/rf207_comptools.C +++ b/tutorials/roofit/rf207_comptools.C @@ -65,9 +65,9 @@ void rf207_comptools() - ////////////////////////////////////////////////////////// - // B a s i c i n f o r m a t i o n r e q u e s t s // - ////////////////////////////////////////////////////////// + // --------------------------------------------------- + // B a s i c i n f o r m a t i o n r e q u e s t s + // =================================================== // G e t l i s t o f o b s e r v a b l e s @@ -104,9 +104,9 @@ void rf207_comptools() model_comps->Print("v") ; - ///////////////////////////////////////////////////////////////////////////////////// - // M o d i f i c a t i o n s t o s t r u c t u r e o f c o m p o s i t e s // - ///////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------------------------------------------------- + // M o d i f i c a t i o n s t o s t r u c t u r e o f c o m p o s i t e s + // =============================================================================== // Create a second Gaussian diff --git a/tutorials/roofit/rf704_amplitudefit.C b/tutorials/roofit/rf704_amplitudefit.C index 01b69f74d8f97..9a66a9c273d88 100644 --- a/tutorials/roofit/rf704_amplitudefit.C +++ b/tutorials/roofit/rf704_amplitudefit.C @@ -39,11 +39,11 @@ void rf704_amplitudefit() // Use RooTruthModel to obtain compiled implementation of sinh/cosh modulated decay functions RooRealVar tau("tau","#tau",1.5); RooRealVar deltaGamma("deltaGamma","deltaGamma", 0.3); - RooTruthModel tm("tm","tm",t) ; + RooTruthModel truthModel("tm","tm",t) ; RooFormulaVar coshGBasis("coshGBasis","exp(-@0/ @1)*cosh(@0*@2/2)",RooArgList(t,tau,deltaGamma)); RooFormulaVar sinhGBasis("sinhGBasis","exp(-@0/ @1)*sinh(@0*@2/2)",RooArgList(t,tau,deltaGamma)); - RooAbsReal* coshGConv = tm.convolution(&coshGBasis,&t); - RooAbsReal* sinhGConv = tm.convolution(&sinhGBasis,&t); + RooAbsReal* coshGConv = truthModel.convolution(&coshGBasis,&t); + RooAbsReal* sinhGConv = truthModel.convolution(&sinhGBasis,&t); // Construct polynomial amplitudes in cos(a) RooPolyVar poly1("poly1","poly1",cosa,RooArgList(RooConst(0.5),RooConst(0.2),RooConst(0.2)),0); diff --git a/tutorials/roofit/rf708_bphysics.C b/tutorials/roofit/rf708_bphysics.C index e6e358aa551a9..7ca00b794c06e 100644 --- a/tutorials/roofit/rf708_bphysics.C +++ b/tutorials/roofit/rf708_bphysics.C @@ -28,9 +28,9 @@ using namespace RooFit ; void rf708_bphysics() { - //////////////////////////////////////////////////// - // B - D e c a y w i t h m i x i n g // - //////////////////////////////////////////////////// + // ------------------------------------- + // B - D e c a y w i t h m i x i n g + // ===================================== // C o n s t r u c t p d f // ------------------------- @@ -54,10 +54,10 @@ void rf708_bphysics() tagFlav.defineType("B0bar",-1) ; // Use delta function resolution model - RooTruthModel tm("tm","truth model",dt) ; + RooTruthModel truthModel("tm","truth model",dt) ; // Construct Bdecay with mixing - RooBMixDecay bmix("bmix","decay",dt,mixState,tagFlav,tau,dm,w,dw,tm,RooBMixDecay::DoubleSided) ; + RooBMixDecay bmix("bmix","decay",dt,mixState,tagFlav,tau,dm,w,dw,truthModel,RooBMixDecay::DoubleSided) ; @@ -102,9 +102,9 @@ void rf708_bphysics() - /////////////////////////////////////////////////////// - // B - D e c a y w i t h C P v i o l a t i o n // - /////////////////////////////////////////////////////// + // ------------------------------------------------- + // B - D e c a y w i t h C P v i o l a t i o n + // ================================================= // C o n s t r u c t p d f // ------------------------- @@ -116,7 +116,7 @@ void rf708_bphysics() RooRealVar effR("effR","B0/B0bar reco efficiency ratio",1) ; // Construct Bdecay with CP violation - RooBCPEffDecay bcp("bcp","bcp", dt, tagFlav, tau, dm, w, CPeigen, absLambda, argLambda, effR, dw, tm, RooBCPEffDecay::DoubleSided) ; + RooBCPEffDecay bcp("bcp","bcp", dt, tagFlav, tau, dm, w, CPeigen, absLambda, argLambda, effR, dw, truthModel, RooBCPEffDecay::DoubleSided) ; @@ -156,9 +156,9 @@ void rf708_bphysics() - ////////////////////////////////////////////////////////////////////////////////// - // G e n e r i c B d e c a y w i t h u s e r c o e f f i c i e n t s // - ////////////////////////////////////////////////////////////////////////////////// + // --------------------------------------------------------------------------- + // G e n e r i c B d e c a y w i t h u s e r c o e f f i c i e n t s + // =========================================================================== // C o n s t r u c t p d f // ------------------------- @@ -178,7 +178,7 @@ void rf708_bphysics() RooFormulaVar fsinh("fsinh","fsinh","@0",RooArgList(Adel)); // Construct generic B decay pdf using above user coefficients - RooBDecay bcpg("bcpg","bcpg",dt,tau,DG,RooConst(1),fsinh,fcos,fsin,dm,tm,RooBDecay::DoubleSided); + RooBDecay bcpg("bcpg","bcpg",dt,tau,DG,RooConst(1),fsinh,fcos,fsin,dm,truthModel,RooBDecay::DoubleSided); diff --git a/tutorials/roostats/FourBinInstructional.C b/tutorials/roostats/FourBinInstructional.C index b759fbbcd2345..7e9f9b3969770 100644 --- a/tutorials/roostats/FourBinInstructional.C +++ b/tutorials/roostats/FourBinInstructional.C @@ -14,7 +14,7 @@ /// we observe noff events and expect tau*b events. /// Note the significance of tau. In the background only case: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// tau ~ / /// ~~~ /// @@ -29,7 +29,7 @@ /// - In the bottom left we observe noffbar events and expect tau bbar events /// Note again we have: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// tau ~ / /// ~~~ /// @@ -42,7 +42,7 @@ /// The "bar" measurements typically have more events (& smaller relative errors). /// If we choose /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// = tau * rho * /// ~~~ /// @@ -52,7 +52,7 @@ /// product will have an error `~1/sqrt(b))`, the contours will be more ameanable /// to numerical techniques. Thus, here we choose to define: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// tau := / () /// rho := / ( * tau) /// @@ -80,7 +80,7 @@ /// /// In the example, the initial values of the parameters are: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// - s = 40 /// - b = 100 /// - tau = 5 @@ -91,7 +91,7 @@ /// /// and in the toy dataset: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// - non = 139 /// - noff = 528 /// - nonbar = 993 @@ -105,7 +105,7 @@ /// /// This can be seen below. /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// GLOBAL b bbar rho s tau /// b 0.96820 1.000 0.191 -0.942 -0.762 -0.209 /// bbar 0.91191 0.191 1.000 0.000 -0.146 -0.912 @@ -188,7 +188,7 @@ void FourBinInstructional(bool doBayesian=false, bool doFeldmanCousins=false, bo wspace->factory("Uniform::prior_nuis({b,bbar,tau, rho})"); wspace->factory("PROD::prior(prior_poi,prior_nuis)"); - /////////////////////////////////////////// + // ---------------------------------- // Control some interesting variations // define parameers of interest // for 1-d plots @@ -206,7 +206,7 @@ void FourBinInstructional(bool doBayesian=false, bool doFeldmanCousins=false, bo // inspect workspace // wspace->Print(); - //////////////////////////////////////////////////////////// + // ---------------------------------------------------------- // Generate toy data // generate toy data assuming current value of the parameters // import into workspace. @@ -215,7 +215,7 @@ void FourBinInstructional(bool doBayesian=false, bool doFeldmanCousins=false, bo // data->Print("v"); wspace->import(*data); - ///////////////////////////////////////////////////// + // ---------------------------------- // Now the statistical tests // model config ModelConfig* modelConfig = new ModelConfig("FourBins"); @@ -227,7 +227,7 @@ void FourBinInstructional(bool doBayesian=false, bool doFeldmanCousins=false, bo wspace->import(*modelConfig); wspace->writeToFile("FourBin.root"); - ////////////////////////////////////////////////// + // ------------------------------------------------- // If you want to see the covariance matrix uncomment // wspace->pdf("model")->fitTo(*data); @@ -285,7 +285,7 @@ void FourBinInstructional(bool doBayesian=false, bool doFeldmanCousins=false, bo if(doMCMC) mcInt = mc.GetInterval(); - ////////////////////////////////////// + // ---------------------------------- // Make some plots TCanvas* c1 = (TCanvas*) gROOT->Get("c1"); if(!c1) @@ -321,7 +321,7 @@ void FourBinInstructional(bool doBayesian=false, bool doFeldmanCousins=false, bo mcPlot.Draw(); } - //////////////////////////////////// + // ---------------------------------- // querry intervals cout << "Profile Likelihood interval on s = [" << plInt->LowerLimit( *wspace->var("s") ) << ", " << diff --git a/tutorials/roostats/HybridInstructional.C b/tutorials/roostats/HybridInstructional.C index dc200d6dcbb25..b3f66e54345af 100644 --- a/tutorials/roostats/HybridInstructional.C +++ b/tutorials/roostats/HybridInstructional.C @@ -23,8 +23,8 @@ /// or try to base it on an auxiliary measurement. In this case, the auxiliary /// measurement (aka control measurement, sideband) is another counting experiment /// with measurement y and expectation tau*b. With an 'original prior' on b, -/// called \eta(b) then one can obtain a posterior from the auxiliary measurement -/// \pi(b) = \eta(b) * Pois(y|tau*b). This is a principled choice for a prior +/// called \f$\eta(b)\f$ then one can obtain a posterior from the auxiliary measurement +/// \f$\pi(b) = \eta(b) * Pois(y|tau*b).\f$ This is a principled choice for a prior /// on b in the main measurement of x, which can then be treated in a hybrid /// Bayesian/Frequentist way. Additionally, one can try to treat the two /// measurements simultaneously, which is detailed in Part 6 of the tutorial. @@ -81,12 +81,11 @@ using namespace RooFit; using namespace RooStats; -////////////////////////////////////////////////// +// ---------------------------------- // A New Test Statistic Class for this example. // It simply returns the sum of the values in a particular // column of a dataset. // You can ignore this class and focus on the macro below -////////////////////////////////////////////////// class BinCountTestStat : public TestStatistic { public: BinCountTestStat(void) : fColumnName("tmp") {} @@ -111,9 +110,8 @@ protected: ClassImp(BinCountTestStat) -////////////////////////////////////////////////// +// ---------------------------------- // The Actual Tutorial Macro -////////////////////////////////////////////////// void HybridInstructional() { @@ -139,11 +137,11 @@ void HybridInstructional() { TCanvas *c = new TCanvas; c->Divide(2,2); - /////////////////////////////////////////////////////// + // ---------------------------------------------------- // P A R T 1 : D I R E C T I N T E G R A T I O N - ////////////////////////////////////////////////////// + // ==================================================== // Make model for prototype on/off problem - // Pois(x | s+b) * Pois(y | tau b ) + // $Pois(x | s+b) * Pois(y | tau b )$ // for Z_Gamma, use uniform prior on b. RooWorkspace* w = new RooWorkspace("w"); w->factory("Poisson::px(x[150,0,500],sum::splusb(s[0,0,100],b[100,0,300]))"); @@ -159,12 +157,14 @@ void HybridInstructional() { // Use PROOF-lite on multi-core machines ProofConfig* pc = NULL; // uncomment below if you want to use PROOF + // ~~~ // pc = new ProofConfig(*w, 4, "workers=4", kFALSE); // machine with 4 cores // pc = new ProofConfig(*w, 2, "workers=2", kFALSE); // machine with 2 cores + // ~~~ - /////////////////////////////////////////////////////// + // ---------------------------------------------------- // P A R T 2 : D I R E C T I N T E G R A T I O N - ////////////////////////////////////////////////////// + // ==================================================== // This is not the 'RooStats' way, but in this case the distribution // of the test statistic is simply x and can be calculated directly // from the PDF using RooFit's built-in integration. @@ -172,7 +172,7 @@ void HybridInstructional() { // depends on many events (rows in a dataset). // construct the Bayesian-averaged model (eg. a projection pdf) - // p'(x|s) = \int db p(x|s+b) * [ p(y|b) * prior(b) ] + // $p'(x|s) = \int db p(x|s+b) * [ p(y|b) * prior(b) ]$ w->factory("PROJ::averagedModel(PROD::foo(px|b,py,prior_b),b)") ; RooMsgService::instance().setGlobalKillBelow(RooFit::ERROR); // lower message level @@ -202,9 +202,9 @@ void HybridInstructional() { PValueToSignificance(1-cdf->getVal()) << endl; RooMsgService::instance().setGlobalKillBelow(msglevel); // set it back - ///////////////////////////////////////////////// + // --------------------------------------------- // P A R T 3 : A N A L Y T I C R E S U L T - ///////////////////////////////////////////////// + // ============================================= // In this special case, the integrals are known analytically // and they are implemented in RooStats::NumberCountingUtils @@ -217,9 +217,9 @@ void HybridInstructional() { std::cout << "Z_Bi significance (analytic): " << Z_Bi << std::endl; t.Stop(); t.Print(); t.Reset(); t.Start(); - //////////////////////////////////////////////////////////////// + // ------------------------------------------------------------- // P A R T 4 : U S I N G H Y B R I D C A L C U L A T O R - //////////////////////////////////////////////////////////////// + // ============================================================= // Now we demonstrate the RooStats HybridCalculator. // // Like all RooStats calculators it needs the data and a ModelConfig @@ -242,8 +242,8 @@ void HybridInstructional() { RooDataSet *data = new RooDataSet("d", "d", *w->set("obs")); data->add(*w->set("obs")); - ////////////////////////////////////////////////////////// // Part 3a : Setup ModelConfigs + // ------------------------------------------------------- // create the null (background-only) ModelConfig with s=0 ModelConfig b_model("B_model", w); b_model.SetPdf(*w->pdf("px")); @@ -261,8 +261,8 @@ void HybridInstructional() { sb_model.SetSnapshot(*w->set("poi")); - ////////////////////////////////////////////////////////// // Part 3b : Choose Test Statistic + // ---------------------------------- // To make an equivalent calculation we need to use x as the test // statistic. This is not a built-in test statistic in RooStats // so we define it above. The new class inherits from the @@ -271,22 +271,22 @@ void HybridInstructional() { BinCountTestStat binCount("x"); - ////////////////////////////////////////////////////////// // Part 3c : Define Prior used to randomize nuisance parameters + // ------------------------------------------------------------- // // The prior used for the hybrid calculator is the posterior // from the auxiliary measurement y. The model for the aux. // measurement is Pois(y|tau*b), thus the likleihood function // is proportional to (has the form of) a Gamma distribution. - // if the 'original prior' \eta(b) is uniform, then from + // if the 'original prior' $\eta(b)$ is uniform, then from // Bayes's theorem we have the posterior: - // \pi(b) = Pois(y|tau*b) * \eta(b) - // If \eta(b) is flat, then we arrive at a Gamma distribution. + // $\pi(b) = Pois(y|tau*b) * \eta(b)$ + // If $\eta(b)$ is flat, then we arrive at a Gamma distribution. // Since RooFit will normalize the PDF we can actually supply - // py=Pois(y,tau*b) that will be equivalent to multiplying by a uniform. + // $py=Pois(y,tau*b)$ that will be equivalent to multiplying by a uniform. // // Alternatively, we could explicitly use a gamma distribution: - // w->factory("Gamma::gamma(b,sum::temp(y,1),1,0)"); + // `w->factory("Gamma::gamma(b,sum::temp(y,1),1,0)");` // // or we can use some other ad hoc prior that do not naturally // follow from the known form of the auxiliary measurement. @@ -298,8 +298,8 @@ void HybridInstructional() { w->factory("Lognormal::lognorm_prior(b,y, expr::kappa('1+1./sqrt(y)',y))"); // // Ideally, the HybridCalculator would be able to inspect the full - // model Pois(x | s+b) * Pois(y | tau b ) and be given the original - // prior \eta(b) to form \pi(b) = Pois(y|tau*b) * \eta(b). + // model $Pois(x | s+b) * Pois(y | tau b )$ and be given the original + // prior $\eta(b)$ to form $\pi(b) = Pois(y|tau*b) * \eta(b)$. // This is not yet implemented because in the general case // it is not easy to identify the terms in the PDF that correspond // to the auxiliary measurement. So for now, it must be set @@ -310,8 +310,8 @@ void HybridInstructional() { // this to be auto-detected, but will leave the option open // to force to a different prior for the nuisance parameters. - ////////////////////////////////////////////////////////// // Part 3d : Construct and configure the HybridCalculator + // ------------------------------------------------------- HybridCalculator hc1(*data, sb_model, b_model); ToyMCSampler *toymcs1 = (ToyMCSampler*)hc1.GetTestStatSampler(); @@ -321,16 +321,20 @@ void HybridInstructional() { hc1.ForcePriorNuisanceAlt(*w->pdf("py")); hc1.ForcePriorNuisanceNull(*w->pdf("py")); // if you wanted to use the ad hoc Gaussian prior instead + // ~~~ // hc1.ForcePriorNuisanceAlt(*w->pdf("gauss_prior")); // hc1.ForcePriorNuisanceNull(*w->pdf("gauss_prior")); + // ~~~ // if you wanted to use the ad hoc log-normal prior instead + // ~~~ // hc1.ForcePriorNuisanceAlt(*w->pdf("lognorm_prior")); // hc1.ForcePriorNuisanceNull(*w->pdf("lognorm_prior")); + // ~~~ // enable proof // NOTE: This test statistic is defined in this macro, and is not // working with PROOF currently. Luckily test stat is fast to evaluate. - // if(pc) toymcs1->SetProofConfig(pc); + // `if(pc) toymcs1->SetProofConfig(pc);` // these lines save current msg level and then kill any messages below ERROR RooMsgService::instance().setGlobalKillBelow(RooFit::ERROR); @@ -346,10 +350,9 @@ void HybridInstructional() { HypoTestPlot *p1 = new HypoTestPlot(*r1,30); // 30 bins, TS is discrete p1->Draw(); - //////////////////////////////////////////////////////////////////////////// - // P A R T 5 : U S I N G H Y B R I D C A L C U L A T O R W I T H - // A N A L T E R N A T I V E T E S T S T A T I S T I C - ///////////////////////////////////////////////////////////////////////////// + // ------------------------------------------------------------------------- + // # P A R T 5 : U S I N G H Y B R I D C A L C U L A T O R + // # W I T H A N A L T E R N A T I V E T E S T S T A T I S T I C // // A likelihood ratio test statistics should be 1-to-1 with the count x // when the value of b is fixed in the likelihood. This is implemented @@ -368,11 +371,15 @@ void HybridInstructional() { hc2.ForcePriorNuisanceAlt(*w->pdf("py")); hc2.ForcePriorNuisanceNull(*w->pdf("py")); // if you wanted to use the ad hoc Gaussian prior instead + // ~~~ // hc2.ForcePriorNuisanceAlt(*w->pdf("gauss_prior")); // hc2.ForcePriorNuisanceNull(*w->pdf("gauss_prior")); + // ~~~ // if you wanted to use the ad hoc log-normal prior instead + // ~~~ // hc2.ForcePriorNuisanceAlt(*w->pdf("lognorm_prior")); // hc2.ForcePriorNuisanceNull(*w->pdf("lognorm_prior")); + // ~~~ // enable proof if(pc) toymcs2->SetProofConfig(pc); @@ -391,11 +398,9 @@ void HybridInstructional() { HypoTestPlot *p2 = new HypoTestPlot(*r2,30); // 30 bins p2->Draw(); - //////////////////////////////////////////////////////////////////////////// - // P A R T 6 : U S I N G H Y B R I D C A L C U L A T O R W I T H - // A N A L T E R N A T I V E T E S T S T A T I S T I C - // A N D S I M U L T A N E O U S M O D E L - ///////////////////////////////////////////////////////////////////////////// + // ----------------------------------------------------------------------------- + // # P A R T 6 : U S I N G H Y B R I D C A L C U L A T O R W I T H A N A L T E R N A T I V E T E S T + // # S T A T I S T I C A N D S I M U L T A N E O U S M O D E L // // If one wants to use a test statistic in which the nuisance parameters // are profiled (in one way or another), then the PDF must constrain b. @@ -403,7 +408,7 @@ void HybridInstructional() { // // In this case, one is really thinking about the problem in a // different way. They are considering x,y simultaneously. - // and the PDF should be Pois(x | s+b) * Pois(y | tau b ) + // and the PDF should be $Pois(x | s+b) * Pois(y | tau b )$ // and the set 'obs' should be {x,y}. w->defineSet("obsXY","x,y"); @@ -441,24 +446,24 @@ void HybridInstructional() { // NOTE: These are slower because they have to run fits for each toy // Tevatron-style Ratio of profiled likelihoods - // Q_Tev = -log L(s=0,\hat\hat{b})/L(s=50,\hat\hat{b}) + // $Q_Tev = -log L(s=0,\hat\hat{b})/L(s=50,\hat\hat{b})$ RatioOfProfiledLikelihoodsTestStat ropl(*b_modelXY.GetPdf(), *sb_modelXY.GetPdf(), sb_modelXY.GetSnapshot()); ropl.SetSubtractMLE(false); // profile likelihood where alternate is best fit value of signal yield - // \lambda(0) = -log L(s=0,\hat\hat{b})/L(\hat{s},\hat{b}) + // $\lambda(0) = -log L(s=0,\hat\hat{b})/L(\hat{s},\hat{b})$ ProfileLikelihoodTestStat profll(*b_modelXY.GetPdf()); // just use the maximum likelihood estimate of signal yield - // MLE = \hat{s} + // $MLE = \hat{s}$ MaxLikelihoodEstimateTestStat mlets(*sb_modelXY.GetPdf(), *w->var("s")); // However, it is less clear how to justify the prior used in randomizing // the nuisance parameters (since that is a property of the ensemble, // and y is a property of each toy pseudo experiment. In that case, // one probably wants to consider a different y0 which will be held - // constant and the prior \pi(b) = Pois(y0 | tau b) * \eta(b). + // constant and the prior $\pi(b) = Pois(y0 | tau b) * \eta(b)$. w->factory("y0[100]"); w->factory("Gamma::gamma_y0(b,sum::temp0(y0,1),1,0)"); w->factory("Gaussian::gauss_prior_y0(b,y0, expr::sqrty0('sqrt(y0)',y0))"); @@ -473,8 +478,10 @@ void HybridInstructional() { hc3.ForcePriorNuisanceAlt(*w->pdf("gamma_y0")); hc3.ForcePriorNuisanceNull(*w->pdf("gamma_y0")); // if you wanted to use the ad hoc Gaussian prior instead - // hc3.ForcePriorNuisanceAlt(*w->pdf("gauss_prior_y0")); - // hc3.ForcePriorNuisanceNull(*w->pdf("gauss_prior_y0")); + // ~~~{.cpp} + // hc3.ForcePriorNuisanceAlt(*w->pdf("gauss_prior_y0")); + // hc3.ForcePriorNuisanceNull(*w->pdf("gauss_prior_y0")); + // ~~~ // choose fit-based test statistic toymcs3->SetTestStatistic(&profll); @@ -502,107 +509,103 @@ void HybridInstructional() { c->SaveAs("zbi.pdf"); - /////////////////////////////////////////////////////////// + // ----------------------------------------- // OUTPUT W/O PROOF (2.66 GHz Intel Core i7) - /////////////////////////////////////////////////////////// - - /* - ----------------------------------------- - Part 2 - Hybrid p-value from direct integration = 0.00094165 - Z_Gamma Significance = 3.10804 - ----------------------------------------- - Part 3 - Z_Bi p-value (analytic): 0.00094165 - Z_Bi significance (analytic): 3.10804 - Real time 0:00:00, CP time 0.610 - - ----------------------------------------- - Part 4 - Results HybridCalculator_result: - - Null p-value = 0.00115 +/- 0.000228984 - - Significance = 3.04848 sigma - - Number of S+B toys: 1000 - - Number of B toys: 20000 - - Test statistic evaluated on data: 150 - - CL_b: 0.99885 +/- 0.000239654 - - CL_s+b: 0.476 +/- 0.0157932 - - CL_s: 0.476548 +/- 0.0158118 - Real time 0:00:07, CP time 7.620 - - ----------------------------------------- - Part 5 - Results HybridCalculator_result: - - Null p-value = 0.0009 +/- 0.000206057 - - Significance = 3.12139 sigma - - Number of S+B toys: 1000 - - Number of B toys: 20000 - - Test statistic evaluated on data: 10.8198 - - CL_b: 0.9991 +/- 0.000212037 - - CL_s+b: 0.465 +/- 0.0157726 - - CL_s: 0.465419 +/- 0.0157871 - Real time 0:00:34, CP time 34.360 - - ----------------------------------------- - Part 6 - Results HybridCalculator_result: - - Null p-value = 0.000666667 +/- 0.000149021 - - Significance = 3.20871 sigma - - Number of S+B toys: 1000 - - Number of B toys: 30000 - - Test statistic evaluated on data: 5.03388 - - CL_b: 0.999333 +/- 0.000149021 - - CL_s+b: 0.511 +/- 0.0158076 - - CL_s: 0.511341 +/- 0.0158183 - Real time 0:05:06, CP time 306.330 - - */ - - - - /////////////////////////////////////////////////////////// + // ========================================= + + // ----------------------------------------- + // Part 2 + // Hybrid p-value from direct integration = 0.00094165 + // Z_Gamma Significance = 3.10804 + // ----------------------------------------- + // + // Part 3 + // Z_Bi p-value (analytic): 0.00094165 + // Z_Bi significance (analytic): 3.10804 + // Real time 0:00:00, CP time 0.610 + + // ----------------------------------------- + // Part 4 + // Results HybridCalculator_result: + // - Null p-value = 0.00115 +/- 0.000228984 + // - Significance = 3.04848 sigma + // - Number of S+B toys: 1000 + // - Number of B toys: 20000 + // - Test statistic evaluated on data: 150 + // - CL_b: 0.99885 +/- 0.000239654 + // - CL_s+b: 0.476 +/- 0.0157932 + // - CL_s: 0.476548 +/- 0.0158118 + // Real time 0:00:07, CP time 7.620 + + // ----------------------------------------- + // Part 5 + // Results HybridCalculator_result: + // - Null p-value = 0.0009 +/- 0.000206057 + // - Significance = 3.12139 sigma + // - Number of S+B toys: 1000 + // - Number of B toys: 20000 + // - Test statistic evaluated on data: 10.8198 + // - CL_b: 0.9991 +/- 0.000212037 + // - CL_s+b: 0.465 +/- 0.0157726 + // - CL_s: 0.465419 +/- 0.0157871 + // Real time 0:00:34, CP time 34.360 + + // ----------------------------------------- + // Part 6 + // Results HybridCalculator_result: + // - Null p-value = 0.000666667 +/- 0.000149021 + // - Significance = 3.20871 sigma + // - Number of S+B toys: 1000 + // - Number of B toys: 30000 + // - Test statistic evaluated on data: 5.03388 + // - CL_b: 0.999333 +/- 0.000149021 + // - CL_s+b: 0.511 +/- 0.0158076 + // - CL_s: 0.511341 +/- 0.0158183 + // Real time 0:05:06, CP time 306.330 + + + // --------------------------------------------------------- // OUTPUT w/ PROOF (2.66 GHz Intel Core i7, 4 virtual cores) - /////////////////////////////////////////////////////////// - /* - ----------------------------------------- - Part 5 - Results HybridCalculator_result: - - Null p-value = 0.00075 +/- 0.000173124 - - Significance = 3.17468 sigma - - Number of S+B toys: 1000 - - Number of B toys: 20000 - - Test statistic evaluated on data: 10.8198 - - CL_b: 0.99925 +/- 0.000193577 - - CL_s+b: 0.454 +/- 0.0157443 - - CL_s: 0.454341 +/- 0.0157564 - Real time 0:00:16, CP time 0.990 - - ----------------------------------------- - Part 6 - Results HybridCalculator_result: - - Null p-value = 0.0007 +/- 0.000152699 - - Significance = 3.19465 sigma - - Number of S+B toys: 1000 - - Number of B toys: 30000 - - Test statistic evaluated on data: 5.03388 - - CL_b: 0.9993 +/- 0.000152699 - - CL_s+b: 0.518 +/- 0.0158011 - - CL_s: 0.518363 +/- 0.0158124 - Real time 0:01:25, CP time 0.580 - - */ - - ////////////////////////////////////////// + // ========================================================= + + // ----------------------------------------- + // Part 5 + // Results HybridCalculator_result: + // - Null p-value = 0.00075 +/- 0.000173124 + // - Significance = 3.17468 sigma + // - Number of S+B toys: 1000 + // - Number of B toys: 20000 + // - Test statistic evaluated on data: 10.8198 + // - CL_b: 0.99925 +/- 0.000193577 + // - CL_s+b: 0.454 +/- 0.0157443 + // - CL_s: 0.454341 +/- 0.0157564 + // Real time 0:00:16, CP time 0.990 + + // ----------------------------------------- + // Part 6 + // Results HybridCalculator_result: + // - Null p-value = 0.0007 +/- 0.000152699 + // - Significance = 3.19465 sigma + // - Number of S+B toys: 1000 + // - Number of B toys: 30000 + // - Test statistic evaluated on data: 5.03388 + // - CL_b: 0.9993 +/- 0.000152699 + // - CL_s+b: 0.518 +/- 0.0158011 + // - CL_s: 0.518363 +/- 0.0158124 + // Real time 0:01:25, CP time 0.580 + + + // ---------------------------------- // Comparison - /////////////////////////////////////////// + // ---------------------------------- // LEPStatToolsForLHC // https://plone4.fnal.gov:4430/P0/phystat/packages/0703002 // Uses Gaussian prior // CL_b = 6.218476e-04, Significance = 3.228665 sigma // - ////////////////////////////////////////// + // ---------------------------------- // Comparison - /////////////////////////////////////////// + // ---------------------------------- // Asymptotics // From the value of the profile likelihood ratio (5.0338) // The significance can be estimated using Wilks's theorem diff --git a/tutorials/roostats/HybridStandardForm.C b/tutorials/roostats/HybridStandardForm.C index 6630c36e4aa4f..db214d14121a7 100644 --- a/tutorials/roostats/HybridStandardForm.C +++ b/tutorials/roostats/HybridStandardForm.C @@ -103,12 +103,12 @@ using namespace RooFit; using namespace RooStats; -////////////////////////////////////////////////// +//------------------------------------------------------- // A New Test Statistic Class for this example. // It simply returns the sum of the values in a particular // column of a dataset. // You can ignore this class and focus on the macro below -////////////////////////////////////////////////// + class BinCountTestStat : public TestStatistic { public: BinCountTestStat(void) : fColumnName("tmp") {} @@ -133,9 +133,9 @@ protected: ClassImp(BinCountTestStat) -////////////////////////////////////////////////// +//----------------------------- // The Actual Tutorial Macro -////////////////////////////////////////////////// +//----------------------------- void HybridStandardForm() { @@ -161,9 +161,9 @@ void HybridStandardForm() { TCanvas *c = new TCanvas; c->Divide(2,2); - /////////////////////////////////////////////////////// + //----------------------------------------------------- // P A R T 1 : D I R E C T I N T E G R A T I O N - ////////////////////////////////////////////////////// + // ==================================================== // Make model for prototype on/off problem // Pois(x | s+b) * Pois(y | tau b ) // for Z_Gamma, use uniform prior on b. @@ -190,9 +190,9 @@ void HybridStandardForm() { pc = new ProofConfig(*w, 4, "workers=4", kFALSE); // machine with 4 cores // pc = new ProofConfig(*w, 2, "workers=2", kFALSE); // machine with 2 cores - ///////////////////////////////////////////////// + //----------------------------------------------- // P A R T 3 : A N A L Y T I C R E S U L T - ///////////////////////////////////////////////// + // ============================================== // In this special case, the integrals are known analytically // and they are implemented in RooStats::NumberCountingUtils @@ -205,9 +205,9 @@ void HybridStandardForm() { std::cout << "Z_Bi significance (analytic): " << Z_Bi << std::endl; t.Stop(); t.Print(); t.Reset(); t.Start(); - //////////////////////////////////////////////////////////////// + //-------------------------------------------------------------- // P A R T 4 : U S I N G H Y B R I D C A L C U L A T O R - //////////////////////////////////////////////////////////////// + // ============================================================== // Now we demonstrate the RooStats HybridCalculator. // // Like all RooStats calculators it needs the data and a ModelConfig @@ -231,8 +231,8 @@ void HybridStandardForm() { // data->add(*w->set("obs")); RooDataSet* data = w->pdf("px")->generate(*w->set("obs"),150); - ////////////////////////////////////////////////////////// // Part 3a : Setup ModelConfigs + //------------------------------------------------------- // create the null (background-only) ModelConfig with s=0 ModelConfig b_model("B_model", w); b_model.SetPdf(*w->pdf("px")); @@ -250,8 +250,8 @@ void HybridStandardForm() { sb_model.SetSnapshot(*w->set("poi")); - ////////////////////////////////////////////////////////// // Part 3b : Choose Test Statistic + //-------------------------------------------------------------- // To make an equivalent calculation we need to use x as the test // statistic. This is not a built-in test statistic in RooStats // so we define it above. The new class inherits from the @@ -260,22 +260,23 @@ void HybridStandardForm() { NumEventsTestStat eventCount(*w->pdf("px")); - ////////////////////////////////////////////////////////// // Part 3c : Define Prior used to randomize nuisance parameters + //------------------------------------------------------------- // // The prior used for the hybrid calculator is the posterior // from the auxiliary measurement y. The model for the aux. // measurement is Pois(y|tau*b), thus the likleihood function // is proportional to (has the form of) a Gamma distribution. - // if the 'original prior' \eta(b) is uniform, then from + // if the 'original prior' $\eta(b)$ is uniform, then from // Bayes's theorem we have the posterior: - // \pi(b) = Pois(y|tau*b) * \eta(b) - // If \eta(b) is flat, then we arrive at a Gamma distribution. + // $\pi(b) = Pois(y|tau*b) * \eta(b)$ + // If $\eta(b)$ is flat, then we arrive at a Gamma distribution. // Since RooFit will normalize the PDF we can actually supply // py=Pois(y,tau*b) that will be equivalent to multiplying by a uniform. // // Alternatively, we could explicitly use a gamma distribution: - // w->factory("Gamma::gamma(b,sum::temp(y,1),1,0)"); + // + // `w->factory("Gamma::gamma(b,sum::temp(y,1),1,0)");` // // or we can use some other ad hoc prior that do not naturally // follow from the known form of the auxiliary measurement. @@ -288,7 +289,7 @@ void HybridStandardForm() { // // Ideally, the HybridCalculator would be able to inspect the full // model Pois(x | s+b) * Pois(y | tau b ) and be given the original - // prior \eta(b) to form \pi(b) = Pois(y|tau*b) * \eta(b). + // prior $\eta(b)$ to form $\pi(b) = Pois(y|tau*b) * \eta(b)$. // This is not yet implemented because in the general case // it is not easy to identify the terms in the PDF that correspond // to the auxiliary measurement. So for now, it must be set @@ -299,8 +300,8 @@ void HybridStandardForm() { // this to be auto-detected, but will leave the option open // to force to a different prior for the nuisance parameters. - ////////////////////////////////////////////////////////// // Part 3d : Construct and configure the HybridCalculator + //------------------------------------------------------- HybridCalculator hc1(*data, sb_model, b_model); ToyMCSampler *toymcs1 = (ToyMCSampler*)hc1.GetTestStatSampler(); @@ -311,11 +312,15 @@ void HybridStandardForm() { hc1.ForcePriorNuisanceAlt(*w->pdf("py")); hc1.ForcePriorNuisanceNull(*w->pdf("py")); // if you wanted to use the ad hoc Gaussian prior instead + // ~~~ // hc1.ForcePriorNuisanceAlt(*w->pdf("gauss_prior")); // hc1.ForcePriorNuisanceNull(*w->pdf("gauss_prior")); + // ~~~ // if you wanted to use the ad hoc log-normal prior instead + // ~~~ // hc1.ForcePriorNuisanceAlt(*w->pdf("lognorm_prior")); // hc1.ForcePriorNuisanceNull(*w->pdf("lognorm_prior")); + // ~~~ // enable proof // proof not enabled for this test statistic @@ -336,10 +341,9 @@ void HybridStandardForm() { p1->Draw(); return; // keep the running time sort by default - //////////////////////////////////////////////////////////////////////////// - // P A R T 5 : U S I N G H Y B R I D C A L C U L A T O R W I T H - // A N A L T E R N A T I V E T E S T S T A T I S T I C - ///////////////////////////////////////////////////////////////////////////// + //------------------------------------------------------------------------- + // # P A R T 5 : U S I N G H Y B R I D C A L C U L A T O R W I T H + // # A N A L T E R N A T I V E T E S T S T A T I S T I C // // A likelihood ratio test statistics should be 1-to-1 with the count x // when the value of b is fixed in the likelihood. This is implemented @@ -359,11 +363,15 @@ void HybridStandardForm() { hc2.ForcePriorNuisanceAlt(*w->pdf("py")); hc2.ForcePriorNuisanceNull(*w->pdf("py")); // if you wanted to use the ad hoc Gaussian prior instead + // ~~~ // hc2.ForcePriorNuisanceAlt(*w->pdf("gauss_prior")); // hc2.ForcePriorNuisanceNull(*w->pdf("gauss_prior")); + // ~~~ // if you wanted to use the ad hoc log-normal prior instead + // ~~~ // hc2.ForcePriorNuisanceAlt(*w->pdf("lognorm_prior")); // hc2.ForcePriorNuisanceNull(*w->pdf("lognorm_prior")); + // ~~~ // enable proof if(pc) toymcs2->SetProofConfig(pc); @@ -384,56 +392,54 @@ void HybridStandardForm() { return; // so standard tutorial runs faster - /////////////////////////////////////////////////////////// + //--------------------------------------------- // OUTPUT W/O PROOF (2.66 GHz Intel Core i7) - /////////////////////////////////////////////////////////// - - /* - ----------------------------------------- - Part 3 - Z_Bi p-value (analytic): 0.00094165 - Z_Bi significance (analytic): 3.10804 - Real time 0:00:00, CP time 0.610 - - Results HybridCalculator_result: - - Null p-value = 0.00103333 +/- 0.000179406 - - Significance = 3.08048 sigma - - Number of S+B toys: 1000 - - Number of B toys: 30000 - - Test statistic evaluated on data: 150 - - CL_b: 0.998967 +/- 0.000185496 - - CL_s+b: 0.495 +/- 0.0158106 - - CL_s: 0.495512 +/- 0.0158272 - Real time 0:04:43, CP time 283.780 - - */ - /* With PROOF - ----------------------------------------- - Part 5 - - Results HybridCalculator_result: - - Null p-value = 0.00105 +/- 0.000206022 - - Significance = 3.07571 sigma - - Number of S+B toys: 1000 - - Number of B toys: 20000 - - Test statistic evaluated on data: 10.8198 - - CL_b: 0.99895 +/- 0.000229008 - - CL_s+b: 0.491 +/- 0.0158088 - - CL_s: 0.491516 +/- 0.0158258 - Real time 0:02:22, CP time 0.990 - */ - - ////////////////////////////////////////// + // ============================================ + + // ----------------------------------------- + // Part 3 + // Z_Bi p-value (analytic): 0.00094165 + // Z_Bi significance (analytic): 3.10804 + // Real time 0:00:00, CP time 0.610 + + // Results HybridCalculator_result: + // - Null p-value = 0.00103333 +/- 0.000179406 + // - Significance = 3.08048 sigma + // - Number of S+B toys: 1000 + // - Number of B toys: 30000 + // - Test statistic evaluated on data: 150 + // - CL_b: 0.998967 +/- 0.000185496 + // - CL_s+b: 0.495 +/- 0.0158106 + // - CL_s: 0.495512 +/- 0.0158272 + // Real time 0:04:43, CP time 283.780 + + // With PROOF + // ----------------------------------------- + // Part 5 + + // Results HybridCalculator_result: + // - Null p-value = 0.00105 +/- 0.000206022 + // - Significance = 3.07571 sigma + // - Number of S+B toys: 1000 + // - Number of B toys: 20000 + // - Test statistic evaluated on data: 10.8198 + // - CL_b: 0.99895 +/- 0.000229008 + // - CL_s+b: 0.491 +/- 0.0158088 + // - CL_s: 0.491516 +/- 0.0158258 + // Real time 0:02:22, CP time 0.990 + + + //------------------------------------------------------- // Comparison - /////////////////////////////////////////// + //------------------------------------------------------- // LEPStatToolsForLHC // https://plone4.fnal.gov:4430/P0/phystat/packages/0703002 // Uses Gaussian prior // CL_b = 6.218476e-04, Significance = 3.228665 sigma // - ////////////////////////////////////////// + //------------------------------------------------------- // Comparison - /////////////////////////////////////////// + //------------------------------------------------------- // Asymptotics // From the value of the profile likelihood ratio (5.0338) // The significance can be estimated using Wilks's theorem diff --git a/tutorials/roostats/ModelInspector.C b/tutorials/roostats/ModelInspector.C index c09e754d80cb3..abb2712323e51 100644 --- a/tutorials/roostats/ModelInspector.C +++ b/tutorials/roostats/ModelInspector.C @@ -6,7 +6,7 @@ /// The usage is the same as the StandardXxxDemo.C macros. /// The macro expects a root file containing a workspace with a ModelConfig and a dataset /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// $ root /// .L ModelInspector.C+ /// ModelInspector(fileName, workspaceName, modelConfigName, dataSetName); @@ -497,67 +497,67 @@ void ModelInspector(const char* infile = "", const char* dataName = "obsData"){ - ///////////////////////////////////////////////////////////// - // First part is just to access a user-defined file - // or create the standard example file if it doesn't exist - //////////////////////////////////////////////////////////// + // ------------------------------------------------------- + // First part is just to access a user-defined file + // or create the standard example file if it doesn't exist + - const char* filename = ""; - if (!strcmp(infile,"")) { - filename = "results/example_combined_GaussExample_model.root"; - bool fileExist = !gSystem->AccessPathName(filename); // note opposite return code - // if file does not exists generate with histfactory - if (!fileExist) { + const char* filename = ""; + if (!strcmp(infile,"")) { + filename = "results/example_combined_GaussExample_model.root"; + bool fileExist = !gSystem->AccessPathName(filename); // note opposite return code + // if file does not exists generate with histfactory + if (!fileExist) { #ifdef _WIN32 - cout << "HistFactory file cannot be generated on Windows - exit" << endl; - return; + cout << "HistFactory file cannot be generated on Windows - exit" << endl; + return; #endif - // Normally this would be run on the command line - cout <<"will run standard hist2workspace example"<ProcessLine(".! prepareHistFactory ."); - gROOT->ProcessLine(".! hist2workspace config/example.xml"); - cout <<"\n\n---------------------"<ProcessLine(".! prepareHistFactory ."); + gROOT->ProcessLine(".! hist2workspace config/example.xml"); + cout <<"\n\n---------------------"<Get(workspaceName); + if(!w){ + cout <<"workspace not found" << endl; return; } - ///////////////////////////////////////////////////////////// - // Tutorial starts here - //////////////////////////////////////////////////////////// + // get the modelConfig out of the file + ModelConfig* mc = (ModelConfig*) w->obj(modelConfigName); - // get the workspace out of the file - RooWorkspace* w = (RooWorkspace*) file->Get(workspaceName); - if(!w){ - cout <<"workspace not found" << endl; - return; - } - - // get the modelConfig out of the file - ModelConfig* mc = (ModelConfig*) w->obj(modelConfigName); - - // get the modelConfig out of the file - RooAbsData* data = w->data(dataName); + // get the modelConfig out of the file + RooAbsData* data = w->data(dataName); - // make sure ingredients are found - if(!data || !mc){ - w->Print(); - cout << "data or ModelConfig was not found" <Print(); + cout << "data or ModelConfig was not found" <Get(workspaceName); @@ -203,16 +201,16 @@ void OneSidedFrequentistUpperLimitWithBands(const char* infile = "", return; } - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // Now get the POI for convenience // you may want to adjust the range of your POI - //////////////////////////////////////////////////////////// + RooRealVar* firstPOI = (RooRealVar*) mc->GetParametersOfInterest()->first(); - // firstPOI->setMin(0); - // firstPOI->setMax(10); + /* firstPOI->setMin(0);*/ + /* firstPOI->setMax(10);*/ - ///////////////////////////////////////////// - // create and use the FeldmanCousins tool + // -------------------------------------------- + // Create and use the FeldmanCousins tool // to find and plot the 95% confidence interval // on the parameter of interest as specified // in the model config @@ -220,20 +218,20 @@ void OneSidedFrequentistUpperLimitWithBands(const char* infile = "", // so this is NOT a Feldman-Cousins interval FeldmanCousins fc(*data,*mc); fc.SetConfidenceLevel(confidenceLevel); - // fc.AdditionalNToysFactor(0.25); // degrade/improve sampling that defines confidence belt - // fc.UseAdaptiveSampling(true); // speed it up a bit, don't use for expectd limits + /* fc.AdditionalNToysFactor(0.25); // degrade/improve sampling that defines confidence belt*/ + /* fc.UseAdaptiveSampling(true); // speed it up a bit, don't use for expectd limits*/ fc.SetNBins(nPointsToScan); // set how many points per parameter of interest to scan fc.CreateConfBelt(true); // save the information in the belt for plotting - ///////////////////////////////////////////// + // ------------------------------------------------------- // Feldman-Cousins is a unified limit by definition // but the tool takes care of a few things for us like which values // of the nuisance parameters should be used to generate toys. // so let's just change the test statistic and realize this is // no longer "Feldman-Cousins" but is a fully frequentist Neyman-Construction. - // ProfileLikelihoodTestStatModified onesided(*mc->GetPdf()); - // fc.GetTestStatSampler()->SetTestStatistic(&onesided); - // ((ToyMCSampler*) fc.GetTestStatSampler())->SetGenerateBinned(true); + /* ProfileLikelihoodTestStatModified onesided(*mc->GetPdf());*/ + /* fc.GetTestStatSampler()->SetTestStatistic(&onesided);*/ + /* ((ToyMCSampler*) fc.GetTestStatSampler())->SetGenerateBinned(true); */ ToyMCSampler* toymcsampler = (ToyMCSampler*) fc.GetTestStatSampler(); ProfileLikelihoodTestStat* testStat = dynamic_cast(toymcsampler->GetTestStatistic()); testStat->SetOneSided(true); @@ -255,7 +253,7 @@ void OneSidedFrequentistUpperLimitWithBands(const char* infile = "", // We can use PROOF to speed things along in parallel // However, the test statistic has to be installed on the workers // so either turn off PROOF or include the modified test statistic - // in your $ROOTSYS/roofit/roostats/inc directory, + // in your `$ROOTSYS/roofit/roostats/inc` directory, // add the additional line to the LinkDef.h file, // and recompile root. if (useProof) { @@ -315,9 +313,8 @@ void OneSidedFrequentistUpperLimitWithBands(const char* infile = "", histOfThresholds->Draw(); c1->cd(2); - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // Now we generate the expected bands and power-constriant - //////////////////////////////////////////////////////////// // First: find parameter point for mu=0, with conditional MLEs for nuisance parameters RooAbsReal* nll = mc->GetPdf()->createNLL(*data); diff --git a/tutorials/roostats/StandardBayesianMCMCDemo.C b/tutorials/roostats/StandardBayesianMCMCDemo.C index 69bc1d47d3b40..4bd15f66018f1 100644 --- a/tutorials/roostats/StandardBayesianMCMCDemo.C +++ b/tutorials/roostats/StandardBayesianMCMCDemo.C @@ -65,10 +65,9 @@ void StandardBayesianMCMCDemo(const char* infile = "", const char* modelConfigName = "ModelConfig", const char* dataName = "obsData"){ - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // First part is just to access a user-defined file // or create the standard example file if it doesn't exist - //////////////////////////////////////////////////////////// @@ -106,9 +105,9 @@ void StandardBayesianMCMCDemo(const char* infile = "", - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // Tutorial starts here - //////////////////////////////////////////////////////////// + // ------------------------------------------------------- // get the workspace out of the file RooWorkspace* w = (RooWorkspace*) file->Get(workspaceName); @@ -146,7 +145,7 @@ void StandardBayesianMCMCDemo(const char* infile = "", // this proposal function seems fairly robust SequentialProposal sp(0.1); - ///////////////////////////////////////////// + // ------------------------------------------------------- // create and use the MCMCCalculator // to find and plot the 95% credible interval // on the parameter of interest as specified diff --git a/tutorials/roostats/StandardBayesianNumericalDemo.C b/tutorials/roostats/StandardBayesianNumericalDemo.C index e1803f404d13a..51b4328e97b78 100644 --- a/tutorials/roostats/StandardBayesianNumericalDemo.C +++ b/tutorials/roostats/StandardBayesianNumericalDemo.C @@ -77,10 +77,9 @@ void StandardBayesianNumericalDemo(const char* infile = "", - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // First part is just to access a user-defined file // or create the standard example file if it doesn't exist - //////////////////////////////////////////////////////////// const char* filename = ""; if (!strcmp(infile,"")) { @@ -115,9 +114,9 @@ void StandardBayesianNumericalDemo(const char* infile = "", } - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // Tutorial starts here - //////////////////////////////////////////////////////////// + // ------------------------------------------------------- // get the workspace out of the file RooWorkspace* w = (RooWorkspace*) file->Get(workspaceName); @@ -139,7 +138,7 @@ void StandardBayesianNumericalDemo(const char* infile = "", return; } - ///////////////////////////////////////////// + // ------------------------------------------ // create and use the BayesianCalculator // to find and plot the 95% credible interval // on the parameter of interest as specified diff --git a/tutorials/roostats/StandardFeldmanCousinsDemo.C b/tutorials/roostats/StandardFeldmanCousinsDemo.C index f9a38aacb2c52..d444d5b031ab8 100644 --- a/tutorials/roostats/StandardFeldmanCousinsDemo.C +++ b/tutorials/roostats/StandardFeldmanCousinsDemo.C @@ -52,10 +52,9 @@ void StandardFeldmanCousinsDemo(const char* infile = "", const char* modelConfigName = "ModelConfig", const char* dataName = "obsData"){ - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // First part is just to access a user-defined file // or create the standard example file if it doesn't exist - //////////////////////////////////////////////////////////// const char* filename = ""; if (!strcmp(infile,"")) { filename = "results/example_combined_GaussExample_model.root"; @@ -89,9 +88,9 @@ void StandardFeldmanCousinsDemo(const char* infile = "", } - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // Tutorial starts here - //////////////////////////////////////////////////////////// + // ------------------------------------------------------- // get the workspace out of the file RooWorkspace* w = (RooWorkspace*) file->Get(workspaceName); @@ -113,7 +112,7 @@ void StandardFeldmanCousinsDemo(const char* infile = "", return; } - ///////////////////////////////////////////// + // ------------------------------------------------------- // create and use the FeldmanCousins tool // to find and plot the 95% confidence interval // on the parameter of interest as specified @@ -155,7 +154,7 @@ void StandardFeldmanCousinsDemo(const char* infile = "", interval->LowerLimit(*firstPOI) << ", "<< interval->UpperLimit(*firstPOI) <<"] "<Start(); diff --git a/tutorials/roostats/StandardHistFactoryPlotsWithCategories.C b/tutorials/roostats/StandardHistFactoryPlotsWithCategories.C index 700c62c2e753d..5b1c51a13e270 100644 --- a/tutorials/roostats/StandardHistFactoryPlotsWithCategories.C +++ b/tutorials/roostats/StandardHistFactoryPlotsWithCategories.C @@ -26,7 +26,7 @@ /// You can also change the signal rate by changing muVal. /// /// The script produces a lot plots, you can merge them by doing: -/// ~~~ {.cpp} +/// ~~~{.cpp} /// gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged.pdf `ls *pdf` /// ~~~ /// @@ -66,10 +66,9 @@ void StandardHistFactoryPlotsWithCategories(const char* infile = "", double muVal=0; bool doFit=false; - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // First part is just to access a user-defined file // or create the standard example file if it doesn't exist - //////////////////////////////////////////////////////////// const char* filename = ""; if (!strcmp(infile,"")) { filename = "results/example_combined_GaussExample_model.root"; @@ -102,9 +101,9 @@ void StandardHistFactoryPlotsWithCategories(const char* infile = "", return; } - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // Tutorial starts here - //////////////////////////////////////////////////////////// + // ------------------------------------------------------- // get the workspace out of the file RooWorkspace* w = (RooWorkspace*) file->Get(workspaceName); @@ -126,7 +125,7 @@ void StandardHistFactoryPlotsWithCategories(const char* infile = "", return; } - ////////////////////////////////////////////// + // ------------------------------------------------------- // now use the profile inspector RooRealVar* obs = (RooRealVar*)mc->GetObservables()->first(); @@ -141,9 +140,8 @@ void StandardHistFactoryPlotsWithCategories(const char* infile = "", mc->GetPdf()->fitTo(*data); } - //////////////////////////////////////// - //////////////////////////////////////// - //////////////////////////////////////// + // ------------------------------------------------------- + mc->GetNuisanceParameters()->Print("v"); int nPlotsMax = 1000; @@ -300,9 +298,8 @@ void StandardHistFactoryPlotsWithCategories(const char* infile = "", - //////////////////////////////////////// - //////////////////////////////////////// - //////////////////////////////////////// + // ------------------------------------------------------- + // now make plots TCanvas* c1 = new TCanvas("c1","ProfileInspectorDemo",800,200); diff --git a/tutorials/roostats/StandardHypoTestDemo.C b/tutorials/roostats/StandardHypoTestDemo.C index b540baf28c6e6..0a01540b825b2 100644 --- a/tutorials/roostats/StandardHypoTestDemo.C +++ b/tutorials/roostats/StandardHypoTestDemo.C @@ -6,7 +6,7 @@ /// /// Usage: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root>.L StandardHypoTestDemo.C /// root> StandardHypoTestDemo("fileName","workspace name","S+B modelconfig name","B model name","data set name",calculator type, test statistic type, number of toys) /// @@ -94,36 +94,34 @@ void StandardHypoTestDemo(const char* infile = "", bool useProof = optHT.useProof; // use Proof bool enableDetOutput = optHT.enableDetailedOutput; -/* - Other Parameter to pass in tutorial - apart from standard for filename, ws, modelconfig and data + // Other Parameter to pass in tutorial + // apart from standard for filename, ws, modelconfig and data - type = 0 Freq calculator - type = 1 Hybrid calculator - type = 2 Asymptotic calculator + // type = 0 Freq calculator + // type = 1 Hybrid calculator + // type = 2 Asymptotic calculator - testStatType = 0 LEP - = 1 Tevatron - = 2 Profile Likelihood - = 3 Profile Likelihood one sided (i.e. = 0 if mu < mu_hat) + // testStatType = 0 LEP + // = 1 Tevatron + // = 2 Profile Likelihood + // = 3 Profile Likelihood one sided (i.e. = 0 if mu < mu_hat) - ntoys: number of toys to use + // ntoys: number of toys to use - useNumberCounting: set to true when using number counting events + // useNumberCounting: set to true when using number counting events - nuisPriorName: name of prior for the nnuisance. This is often expressed as constraint term in the global model - It is needed only when using the HybridCalculator (type=1) - If not given by default the prior pdf from ModelConfig is used. + // nuisPriorName: name of prior for the nnuisance. This is often expressed as constraint term in the global model + // It is needed only when using the HybridCalculator (type=1) + // If not given by default the prior pdf from ModelConfig is used. - extra options are available as global paramwters of the macro. They major ones are: + // extra options are available as global paramwters of the macro. They major ones are: - generateBinned generate binned data sets for toys (default is false) - be careful not to activate with - a too large (>=3) number of observables - nToyRatio ratio of S+B/B toys (default is 2) - printLevel + // generateBinned generate binned data sets for toys (default is false) - be careful not to activate with + // a too large (>=3) number of observables + // nToyRatio ratio of S+B/B toys (default is 2) + // printLevel -*/ // disable - can cause some problems //ToyMCSampler::SetAlwaysUseMultiGen(true); @@ -135,14 +133,15 @@ void StandardHypoTestDemo(const char* infile = "", //RooRandom::randomGenerator()->SetSeed(0); // to change minimizers + // ~~~{.bash} // ROOT::Math::MinimizerOptions::SetDefaultStrategy(0); // ROOT::Math::MinimizerOptions::SetDefaultMinimizer("Minuit2"); // ROOT::Math::MinimizerOptions::SetDefaultTolerance(1); + // ~~~ - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // First part is just to access a user-defined file // or create the standard example file if it doesn't exist - //////////////////////////////////////////////////////////// const char* filename = ""; if (!strcmp(infile,"")) { filename = "results/example_combined_GaussExample_model.root"; @@ -176,33 +175,33 @@ void StandardHypoTestDemo(const char* infile = "", } - ///////////////////////////////////////////////////////////// - // Tutorial starts here - //////////////////////////////////////////////////////////// + // ------------------------------------------------------- + // Tutorial starts here + // ------------------------------------------------------- - // get the workspace out of the file - RooWorkspace* w = (RooWorkspace*) file->Get(workspaceName); - if(!w){ - cout <<"workspace not found" << endl; - return; - } - w->Print(); + // get the workspace out of the file + RooWorkspace* w = (RooWorkspace*) file->Get(workspaceName); + if(!w){ + cout <<"workspace not found" << endl; + return; + } + w->Print(); - // get the modelConfig out of the file - ModelConfig* sbModel = (ModelConfig*) w->obj(modelSBName); + // get the modelConfig out of the file + ModelConfig* sbModel = (ModelConfig*) w->obj(modelSBName); - // get the modelConfig out of the file - RooAbsData* data = w->data(dataName); + // get the modelConfig out of the file + RooAbsData* data = w->data(dataName); - // make sure ingredients are found - if(!data || !sbModel){ - w->Print(); - cout << "data or ModelConfig was not found" <obj(modelBName); + // make sure ingredients are found + if(!data || !sbModel){ + w->Print(); + cout << "data or ModelConfig was not found" <obj(modelBName); // case of no systematics @@ -279,9 +278,9 @@ void StandardHypoTestDemo(const char* infile = "", } - // profll.SetReuseNLL(mOptimize); - // slrts.SetReuseNLL(mOptimize); - // ropl.SetReuseNLL(mOptimize); + /* profll.SetReuseNLL(mOptimize);*/ + /* slrts.SetReuseNLL(mOptimize);*/ + /* ropl.SetReuseNLL(mOptimize);*/ AsymptoticCalculator::SetPrintLevel(printLevel); @@ -345,8 +344,8 @@ void StandardHypoTestDemo(const char* infile = "", ((HybridCalculator*)hypoCalc)->ForcePriorNuisanceNull(*nuisPdf); } - // hypoCalc->ForcePriorNuisanceAlt(*sbModel->GetPriorPdf()); - // hypoCalc->ForcePriorNuisanceNull(*bModel->GetPriorPdf()); + /* hypoCalc->ForcePriorNuisanceAlt(*sbModel->GetPriorPdf());*/ + /* hypoCalc->ForcePriorNuisanceNull(*bModel->GetPriorPdf());*/ ToyMCSampler * sampler = (ToyMCSampler *)hypoCalc->GetTestStatSampler(); diff --git a/tutorials/roostats/StandardHypoTestInvDemo.C b/tutorials/roostats/StandardHypoTestInvDemo.C index 9350f65754f72..ffa3f22a422ff 100644 --- a/tutorials/roostats/StandardHypoTestInvDemo.C +++ b/tutorials/roostats/StandardHypoTestInvDemo.C @@ -7,7 +7,7 @@ /// /// Usage: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root>.L StandardHypoTestInvDemo.C /// root> StandardHypoTestInvDemo("fileName","workspace name","S+B modelconfig name","B model name","data set name",calculator type, test statistic type, use CLS, /// number of points, xmin, xmax, number of toys, use number counting) diff --git a/tutorials/roostats/StandardProfileInspectorDemo.C b/tutorials/roostats/StandardProfileInspectorDemo.C index 24ee95c97eb4e..dd14a9c7b558a 100644 --- a/tutorials/roostats/StandardProfileInspectorDemo.C +++ b/tutorials/roostats/StandardProfileInspectorDemo.C @@ -48,10 +48,9 @@ void StandardProfileInspectorDemo(const char* infile = "", const char* modelConfigName = "ModelConfig", const char* dataName = "obsData") { - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // First part is just to access a user-defined file // or create the standard example file if it doesn't exist - //////////////////////////////////////////////////////////// const char* filename = ""; if (!strcmp(infile,"")) { @@ -86,9 +85,9 @@ void StandardProfileInspectorDemo(const char* infile = "", } - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // Tutorial starts here - //////////////////////////////////////////////////////////// + // ------------------------------------------------------- // get the workspace out of the file RooWorkspace* w = (RooWorkspace*) file->Get(workspaceName); @@ -110,7 +109,7 @@ void StandardProfileInspectorDemo(const char* infile = "", return; } - ////////////////////////////////////////////// + // ----------------------------- // now use the profile inspector ProfileInspector p; TList* list = p.GetListOfProfilePlots(*data,mc); diff --git a/tutorials/roostats/StandardProfileLikelihoodDemo.C b/tutorials/roostats/StandardProfileLikelihoodDemo.C index 8ccb86020c29d..07cd28800f6b5 100644 --- a/tutorials/roostats/StandardProfileLikelihoodDemo.C +++ b/tutorials/roostats/StandardProfileLikelihoodDemo.C @@ -69,10 +69,9 @@ void StandardProfileLikelihoodDemo(const char* infile = "", bool doHypoTest = optPL.doHypoTest; double nullParamValue = optPL.nullValue; - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // First part is just to access a user-defined file // or create the standard example file if it doesn't exist - //////////////////////////////////////////////////////////// const char* filename = ""; if (!strcmp(infile,"")) { filename = "results/example_combined_GaussExample_model.root"; @@ -105,9 +104,9 @@ void StandardProfileLikelihoodDemo(const char* infile = "", return; } - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // Tutorial starts here - //////////////////////////////////////////////////////////// + // ------------------------------------------------------- // get the workspace out of the file RooWorkspace* w = (RooWorkspace*) file->Get(workspaceName); @@ -129,7 +128,7 @@ void StandardProfileLikelihoodDemo(const char* infile = "", return; } - ///////////////////////////////////////////// + // --------------------------------------------- // create and use the ProfileLikelihoodCalculator // to find and plot the 95% confidence interval // on the parameter of interest as specified diff --git a/tutorials/roostats/StandardTestStatDistributionDemo.C b/tutorials/roostats/StandardTestStatDistributionDemo.C index 5a1260ce4d49f..4be5eff5fdd9a 100644 --- a/tutorials/roostats/StandardTestStatDistributionDemo.C +++ b/tutorials/roostats/StandardTestStatDistributionDemo.C @@ -52,7 +52,7 @@ using namespace RooStats; bool useProof = false; // flag to control whether to use Proof int nworkers = 0; // number of workers (default use all available cores) -///////////////////////////////////////////////////////////////////////// +// ------------------------------------------------------- // The actual macro void StandardTestStatDistributionDemo(const char* infile = "", @@ -68,10 +68,9 @@ void StandardTestStatDistributionDemo(const char* infile = "", bool allowNegativeMu=true; - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // First part is just to access a user-defined file // or create the standard example file if it doesn't exist - //////////////////////////////////////////////////////////// const char* filename = ""; if (!strcmp(infile,"")) { filename = "results/example_combined_GaussExample_model.root"; @@ -105,9 +104,8 @@ void StandardTestStatDistributionDemo(const char* infile = "", } - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // Now get the data and workspace - //////////////////////////////////////////////////////////// // get the workspace out of the file RooWorkspace* w = (RooWorkspace*) file->Get(workspaceName); @@ -130,9 +128,8 @@ void StandardTestStatDistributionDemo(const char* infile = "", } mc->Print(); - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // Now find the upper limit based on the asymptotic results - //////////////////////////////////////////////////////////// RooRealVar* firstPOI = (RooRealVar*) mc->GetParametersOfInterest()->first(); ProfileLikelihoodCalculator plc(*data,*mc); LikelihoodInterval* interval = plc.GetInterval(); @@ -146,8 +143,8 @@ void StandardTestStatDistributionDemo(const char* infile = "", mc->GetParametersOfInterest()->Print("v"); } - ///////////////////////////////////////////// - // create thte test stat sampler + // ------------------------------------------------------- + // create the test stat sampler ProfileLikelihoodTestStat ts(*mc->GetPdf()); // to avoid effects from boundary and simplify asymptotic comparison, set min=-max diff --git a/tutorials/roostats/TwoSidedFrequentistUpperLimitWithBands.C b/tutorials/roostats/TwoSidedFrequentistUpperLimitWithBands.C index 6e61f71c28a1c..691c36ce0d5ec 100644 --- a/tutorials/roostats/TwoSidedFrequentistUpperLimitWithBands.C +++ b/tutorials/roostats/TwoSidedFrequentistUpperLimitWithBands.C @@ -16,7 +16,7 @@ /// that it produces. /// /// You may want to control: -/// ~~~ {.cpp} +/// ~~~{.cpp} /// double confidenceLevel=0.95; /// double additionalToysFac = 1.; /// int nPointsToScan = 30; @@ -126,7 +126,7 @@ using namespace std; bool useProof = false; // flag to control whether to use Proof int nworkers = 0; // number of workers (default use all available cores) -///////////////////////////////////////////////////////////////////////// +// ------------------------------------------------------- void TwoSidedFrequentistUpperLimitWithBands(const char* infile = "", const char* workspaceName = "combined", @@ -141,10 +141,9 @@ void TwoSidedFrequentistUpperLimitWithBands(const char* infile = "", int nPointsToScan = 20; // number of steps in the parameter of interest int nToyMC = 200; // number of toys used to define the expected limit and band - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // First part is just to access a user-defined file // or create the standard example file if it doesn't exist - //////////////////////////////////////////////////////////// const char* filename = ""; if (!strcmp(infile,"")) { filename = "results/example_combined_GaussExample_model.root"; @@ -177,9 +176,8 @@ void TwoSidedFrequentistUpperLimitWithBands(const char* infile = "", return; } - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // Now get the data and workspace - //////////////////////////////////////////////////////////// // get the workspace out of the file RooWorkspace* w = (RooWorkspace*) file->Get(workspaceName); @@ -204,15 +202,14 @@ void TwoSidedFrequentistUpperLimitWithBands(const char* infile = "", cout << "Found data and ModelConfig:" <Print(); - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // Now get the POI for convenience // you may want to adjust the range of your POI - //////////////////////////////////////////////////////////// RooRealVar* firstPOI = (RooRealVar*) mc->GetParametersOfInterest()->first(); - // firstPOI->setMin(0); - // firstPOI->setMax(10); + /* firstPOI->setMin(0);*/ + /* firstPOI->setMax(10);*/ - ///////////////////////////////////////////// + // ------------------------------------------------------- // create and use the FeldmanCousins tool // to find and plot the 95% confidence interval // on the parameter of interest as specified @@ -226,7 +223,7 @@ void TwoSidedFrequentistUpperLimitWithBands(const char* infile = "", fc.SetNBins(nPointsToScan); // set how many points per parameter of interest to scan fc.CreateConfBelt(true); // save the information in the belt for plotting - ///////////////////////////////////////////// + // ------------------------------------------------------- // Feldman-Cousins is a unified limit by definition // but the tool takes care of a few things for us like which values // of the nuisance parameters should be used to generate toys. @@ -314,9 +311,8 @@ void TwoSidedFrequentistUpperLimitWithBands(const char* infile = "", histOfThresholds->Draw(); c1->cd(2); - ///////////////////////////////////////////////////////////// + // ------------------------------------------------------- // Now we generate the expected bands and power-constriant - //////////////////////////////////////////////////////////// // First: find parameter point for mu=0, with conditional MLEs for nuisance parameters RooAbsReal* nll = mc->GetPdf()->createNLL(*data); diff --git a/tutorials/roostats/rs101_limitexample.C b/tutorials/roostats/rs101_limitexample.C index 3fea9f4f7742b..2a0a979c9f95e 100644 --- a/tutorials/roostats/rs101_limitexample.C +++ b/tutorials/roostats/rs101_limitexample.C @@ -1,6 +1,6 @@ /// \file /// \ingroup tutorial_roostats -/// \notebook -js +/// \notebook /// 'Limit Example' RooStats tutorial macro #101 /// This tutorial shows an example of creating a simple /// model for a number counting experiment with uncertainty @@ -50,17 +50,16 @@ using namespace RooStats; void rs101_limitexample() { - ///////////////////////////////////////// + // -------------------------------------- // An example of setting a limit in a number counting experiment with uncertainty on background and signal - ///////////////////////////////////////// // to time the macro TStopwatch t; t.Start(); - ///////////////////////////////////////// + // -------------------------------------- // The Model building stage - ///////////////////////////////////////// + // -------------------------------------- RooWorkspace* wspace = new RooWorkspace(); wspace->factory("Poisson::countingModel(obs[150,0,300], sum(s[50,0,120]*ratioSigEff[1.,0,3.],b[100]*ratioBkgEff[1.,0.,3.]))"); // counting model // wspace->factory("Gaussian::sigConstraint(ratioSigEff,1,0.05)"); // 5% signal efficiency uncertainty @@ -116,14 +115,14 @@ void rs101_limitexample() //ProfileLikelihoodCalculator plc(*data, *modelWithConstraints, paramOfInterest); ProfileLikelihoodCalculator plc(*data, modelConfig); plc.SetTestSize(.05); - ConfInterval* lrint = plc.GetInterval(); // that was easy. + ConfInterval* lrinterval = plc.GetInterval(); // that was easy. // Let's make a plot TCanvas* dataCanvas = new TCanvas("dataCanvas"); dataCanvas->Divide(2,1); dataCanvas->cd(1); - LikelihoodIntervalPlot plotInt((LikelihoodInterval*)lrint); + LikelihoodIntervalPlot plotInt((LikelihoodInterval*)lrinterval); plotInt.SetTitle("Profile Likelihood Ratio and Posterior for S"); plotInt.Draw(); @@ -159,8 +158,8 @@ void rs101_limitexample() // Get Lower and Upper limits from Profile Calculator - cout << "Profile lower limit on s = " << ((LikelihoodInterval*) lrint)->LowerLimit(*s) << endl; - cout << "Profile upper limit on s = " << ((LikelihoodInterval*) lrint)->UpperLimit(*s) << endl; + cout << "Profile lower limit on s = " << ((LikelihoodInterval*) lrinterval)->LowerLimit(*s) << endl; + cout << "Profile upper limit on s = " << ((LikelihoodInterval*) lrinterval)->UpperLimit(*s) << endl; // Get Lower and Upper limits from FeldmanCousins with profile construction if (fcint != NULL) { @@ -226,12 +225,12 @@ void rs101_limitexample() delete wspace; - delete lrint; + delete lrinterval; delete mcInt; delete fcint; delete data; - /// print timing info + // print timing info t.Stop(); t.Print(); } diff --git a/tutorials/roostats/rs102_hypotestwithshapes.C b/tutorials/roostats/rs102_hypotestwithshapes.C index f286fcd6daba8..1ed2e0549b86d 100644 --- a/tutorials/roostats/rs102_hypotestwithshapes.C +++ b/tutorials/roostats/rs102_hypotestwithshapes.C @@ -90,7 +90,7 @@ void AddModel(RooWorkspace* wks){ RooRealVar invMass("invMass", "M_{inv}", lowRange, highRange,"GeV"); - ///////////////////////////////////////////// + // -------------------------------------- // make a simple signal model. RooRealVar mH("mH","Higgs Mass",130,90,160) ; RooRealVar sigma1("sigma1","Width of Gaussian",12.,2,100) ; @@ -100,7 +100,7 @@ void AddModel(RooWorkspace* wks){ // and we assume we know the mass resolution sigma1.setConstant(); - ///////////////////////////////////////////// + // -------------------------------------- // make zjj model. Just like signal model RooRealVar mZ("mZ", "Z Mass", 91.2, 0, 100); RooRealVar sigma1_z("sigma1_z","Width of Gaussian",10.,6,100) ; @@ -111,7 +111,7 @@ void AddModel(RooWorkspace* wks){ sigma1_z.setConstant(); - ////////////////////////////////////////////// + // -------------------------------------- // make QCD model RooRealVar a0("a0","a0",0.26,-1,1) ; RooRealVar a1("a1","a1",-0.17596,-1,1) ; @@ -124,7 +124,7 @@ void AddModel(RooWorkspace* wks){ a1.setConstant(); a2.setConstant(); - ////////////////////////////////////////////// + // -------------------------------------- // combined model // Setting the fraction of Zjj to be 40% for initial guess. @@ -232,7 +232,7 @@ void MakePlots(RooWorkspace* wks) { RooAbsData* data = wks->data("data"); - ////////////////////////////////////////////////////////// + // -------------------------------------- // Make plots for the Alternate hypothesis, eg. let mu float mu->setConstant(kFALSE); @@ -252,7 +252,7 @@ void MakePlots(RooWorkspace* wks) { frame->Draw() ; // cdata->SaveAs("alternateFit.gif"); - ////////////////////////////////////////////////////////// + // -------------------------------------- // Do Fit to the Null hypothesis. Eg. fix mu=0 mu->setVal(0); // set signal fraction to 0 diff --git a/tutorials/roostats/rs301_splot.C b/tutorials/roostats/rs301_splot.C index 9a19738a2f5a9..df686444da52a 100644 --- a/tutorials/roostats/rs301_splot.C +++ b/tutorials/roostats/rs301_splot.C @@ -97,7 +97,7 @@ void AddModel(RooWorkspace* ws){ RooRealVar isolation("isolation", "isolation", 0., 20., "GeV"); - ///////////////////////////////////////////// + // -------------------------------------- // make 2-d model for Z including the invariant mass // distribution and an isolation distribution which we want to // unfold from QCD. @@ -123,7 +123,7 @@ void AddModel(RooWorkspace* ws){ RooProdPdf zModel("zModel", "4-d model for Z", RooArgSet(mZModel, zIsolationModel)); - ////////////////////////////////////////////// + // -------------------------------------- // make QCD model std::cout << "make qcd model" << std::endl; @@ -152,7 +152,7 @@ void AddModel(RooWorkspace* ws){ RooProdPdf qcdModel("qcdModel", "2-d model for QCD", RooArgSet(qcdMassModel, qcdIsolationModel)); - ////////////////////////////////////////////// + // -------------------------------------- // combined model // These variables represent the number of Z or QCD events diff --git a/tutorials/roostats/rs401d_FeldmanCousins.C b/tutorials/roostats/rs401d_FeldmanCousins.C index 133a01297eac8..ba474c8c5b52a 100644 --- a/tutorials/roostats/rs401d_FeldmanCousins.C +++ b/tutorials/roostats/rs401d_FeldmanCousins.C @@ -158,7 +158,7 @@ void rs401d_FeldmanCousins(bool doFeldmanCousins=false, bool doMCMC = true) RooMsgService::instance().setStreamStatus(2,kFALSE); - ////////////////////////////////////////////// + // -------------------------------------- // n events in data to data, simply sum of sig+bkg Int_t nEventsData = bkgNorm.getVal()+sigNorm.getVal(); cout << "generate toy data with nEvents = " << nEventsData << endl; @@ -168,7 +168,7 @@ void rs401d_FeldmanCousins(bool doFeldmanCousins=false, bool doMCMC = true) // create a toy dataset RooDataSet* data = model.generate(RooArgSet(E), nEventsData); - ///////////////////////////////////////////// + // -------------------------------------- // make some plots TCanvas* dataCanvas = new TCanvas("dataCanvas"); dataCanvas->Divide(2,2); @@ -206,8 +206,8 @@ void rs401d_FeldmanCousins(bool doFeldmanCousins=false, bool doMCMC = true) - ////////////////////////////////////////////////////////// - //////// show use of Feldman-Cousins utility in RooStats + // -------------------------------------------------------------- + // show use of Feldman-Cousins utility in RooStats // set the distribution creator, which encodes the test statistic RooArgSet parameters(deltaMSq, sinSq2theta); RooWorkspace* w = new RooWorkspace(); @@ -228,15 +228,15 @@ void rs401d_FeldmanCousins(bool doFeldmanCousins=false, bool doMCMC = true) interval = fc.GetInterval(); - /////////////////////////////////////////////////////////////////// - ///////// show use of ProfileLikeihoodCalculator utility in RooStats + // --------------------------------------------------------- + // show use of ProfileLikeihoodCalculator utility in RooStats RooStats::ProfileLikelihoodCalculator plc(*data, modelConfig); plc.SetTestSize(.1); ConfInterval* plcInterval = plc.GetInterval(); - /////////////////////////////////////////////////////////////////// - ///////// show use of MCMCCalculator utility in RooStats + // -------------------------------------------- + // show use of MCMCCalculator utility in RooStats MCMCInterval* mcInt = NULL; if (doMCMC) { @@ -260,7 +260,7 @@ void rs401d_FeldmanCousins(bool doFeldmanCousins=false, bool doMCMC = true) mcmcWatch.Stop(); mcmcWatch.Print(); } - //////////////////////////////////////////// + // ------------------------------- // make plot of resulting interval dataCanvas->cd(4); diff --git a/tutorials/roostats/rs_numberCountingCombination.C b/tutorials/roostats/rs_numberCountingCombination.C index 42912f02bbea8..628d10b16f7e3 100644 --- a/tutorials/roostats/rs_numberCountingCombination.C +++ b/tutorials/roostats/rs_numberCountingCombination.C @@ -45,7 +45,7 @@ void rs_numberCountingCombination_expected(); void rs_numberCountingCombination_observed(); void rs_numberCountingCombination_observedWithTau(); -//////////////////////////////////////////// +// ------------------------------- // main driver to choose one void rs_numberCountingCombination(int flag=1) { @@ -57,7 +57,7 @@ void rs_numberCountingCombination(int flag=1) rs_numberCountingCombination_observedWithTau(); } -///////////////////////////////////////////// +// ------------------------------- void rs_numberCountingCombination_expected() { diff --git a/tutorials/roostats/rs_numbercountingutils.C b/tutorials/roostats/rs_numbercountingutils.C index 32adeddeeb473..a03101a69cc6b 100644 --- a/tutorials/roostats/rs_numbercountingutils.C +++ b/tutorials/roostats/rs_numbercountingutils.C @@ -48,7 +48,7 @@ void rs_numbercountingutils() { // From the root prompt, you can see the full list of functions by using tab-completion - + // ~~~{.bash} // root [0] RooStats::NumberCountingUtils:: // BinomialExpZ // BinomialWithTauExpZ @@ -58,21 +58,22 @@ void rs_numbercountingutils() // BinomialWithTauExpP // BinomialObsP // BinomialWithTauObsP + // ~~~ // For each of the utilities you can inspect the arguments by tab completion - + // ~~~{.bash} //root [1] NumberCountingUtils::BinomialExpZ( //Double_t BinomialExpZ(Double_t sExp, Double_t bExp, Double_t fractionalBUncertainty) + // ~~~ - ///////////////////////////////////////////////////// + // ------------------------------------------------- // Here we see common usages where the experimenter // has a relative background uncertainty, without // explicit reference to the auxiliary or sideband // measurement - ///////////////////////////////////////////////////// + // ------------------------------------------------------------- // Expected p-values and significance with background uncertainty - //////////////////////////////////////////////////// double sExpected = 50; double bExpected = 100; double relativeBkgUncert = 0.1; @@ -81,16 +82,15 @@ void rs_numbercountingutils() double zExp = NumberCountingUtils::BinomialExpZ(sExpected, bExpected, relativeBkgUncert); cout << "expected p-value ="<< pExp << " Z value (Gaussian sigma) = "<< zExp << endl; - ///////////////////////////////////////////////////// + // ------------------------------------------------- // Expected p-values and significance with background uncertainty - //////////////////////////////////////////////////// double observed = 150; double pObs = NumberCountingUtils::BinomialObsP(observed, bExpected, relativeBkgUncert); double zObs = NumberCountingUtils::BinomialObsZ(observed, bExpected, relativeBkgUncert); cout << "observed p-value ="<< pObs << " Z value (Gaussian sigma) = "<< zObs << endl; - ///////////////////////////////////////////////////// + // --------------------------------------------------------- // Here we see usages where the experimenter has knowledge // about the properties of the auxiliary or sideband // measurement. In particular, the ratio tau of background @@ -99,22 +99,21 @@ void rs_numbercountingutils() // because the sideband is very constraining. // Usage: + // ~~~{.bash} // root [0] RooStats::NumberCountingUtils::BinomialWithTauExpP( // Double_t BinomialWithTauExpP(Double_t sExp, Double_t bExp, Double_t tau) + // ~~~ - - ///////////////////////////////////////////////////// + // -------------------------------------------------------------- // Expected p-values and significance with background uncertainty - //////////////////////////////////////////////////// double tau = 1; double pExpWithTau = NumberCountingUtils::BinomialWithTauExpP(sExpected, bExpected, tau); double zExpWithTau = NumberCountingUtils::BinomialWithTauExpZ(sExpected, bExpected, tau); cout << "expected p-value ="<< pExpWithTau << " Z value (Gaussian sigma) = "<< zExpWithTau << endl; - ///////////////////////////////////////////////////// + // --------------------------------------------------------------- // Expected p-values and significance with background uncertainty - //////////////////////////////////////////////////// double pObsWithTau = NumberCountingUtils::BinomialWithTauObsP(observed, bExpected, tau); double zObsWithTau = NumberCountingUtils::BinomialWithTauObsZ(observed, bExpected, tau); cout << "observed p-value ="<< pObsWithTau << " Z value (Gaussian sigma) = "<< zObsWithTau << endl; diff --git a/tutorials/spectrum/peaks.C b/tutorials/spectrum/peaks.C index abe2ea3657d97..d7486e06bb9a9 100644 --- a/tutorials/spectrum/peaks.C +++ b/tutorials/spectrum/peaks.C @@ -12,7 +12,7 @@ /// /// To execute this example, do: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root > .x peaks.C (generate 10 peaks by default) /// root > .x peaks.C++ (use the compiler) /// root > .x peaks.C++(30) (generates 30 peaks) @@ -21,7 +21,7 @@ /// To execute only the first part of the script (without fitting) /// specify a negative value for the number of peaks, eg /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root > .x peaks.C(-20) /// ~~~ /// diff --git a/tutorials/spectrum/peaks2.C b/tutorials/spectrum/peaks2.C index 617b763a4b8e9..76cc5ab70da84 100644 --- a/tutorials/spectrum/peaks2.C +++ b/tutorials/spectrum/peaks2.C @@ -7,7 +7,7 @@ /// The position of the peaks is found via TSpectrum2 /// To execute this example, do: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root > .x peaks2.C (generate up to 50 peaks by default) /// root > .x peaks2.C(10) (generate up to 10 peaks) /// root > .x peaks2.C+(200) (generate up to 200 peaks via ACLIC) diff --git a/tutorials/thread/stressThreadPool.C b/tutorials/thread/stressThreadPool.C index 83ebaa9499335..fbdfd80befb6d 100644 --- a/tutorials/thread/stressThreadPool.C +++ b/tutorials/thread/stressThreadPool.C @@ -3,7 +3,7 @@ /// /// Usage: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root [0] .L stressThreadPool.C++ /// root [1] stressThreadPool(5, true) /// ~~~ diff --git a/tutorials/thread/threadPool.C b/tutorials/thread/threadPool.C index 8c5694092c682..b326e4cf093cc 100644 --- a/tutorials/thread/threadPool.C +++ b/tutorials/thread/threadPool.C @@ -3,7 +3,7 @@ /// /// Usage: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root [0] .L threadPool.C++ /// root [1] threadPool(10) 10 = numThreads /// ~~~ diff --git a/tutorials/thread/threads.C b/tutorials/thread/threads.C index eda6c7c520e74..b0fbc1a891ae0 100644 --- a/tutorials/thread/threads.C +++ b/tutorials/thread/threads.C @@ -4,7 +4,7 @@ /// This script can only be executed via ACliC: .x threads.C++. /// Before executing the script, load the Thread library with: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// gSystem->Load("libThread"); /// ~~~ /// diff --git a/tutorials/tree/basic2.C b/tutorials/tree/basic2.C index ce9a540985a5c..41c9cb6cf33da 100644 --- a/tutorials/tree/basic2.C +++ b/tutorials/tree/basic2.C @@ -1,6 +1,6 @@ /// \file /// \ingroup tutorial_tree -/// \notebook +/// \notebook -js /// Create can ntuple reading data from an ascii file. /// This macro is a variant of basic.C /// \macro_image diff --git a/tutorials/tree/circular.C b/tutorials/tree/circular.C index 165bc468f90f0..c34eb49a84ff5 100644 --- a/tutorials/tree/circular.C +++ b/tutorials/tree/circular.C @@ -13,18 +13,18 @@ void circular() { auto T = new TTree("T","test circular buffers"); TRandom r; Float_t px,py,pz; - Double_t random; + Double_t randomNum; UShort_t i; T->Branch("px",&px,"px/F"); T->Branch("py",&py,"px/F"); T->Branch("pz",&pz,"px/F"); - T->Branch("random",&random,"random/D"); + T->Branch("random",&randomNum,"random/D"); T->Branch("i",&i,"i/s"); T->SetCircular(20000); //keep a maximum of 20000 entries in memory for (i = 0; i < 65000; i++) { r.Rannor(px,py); pz = px*px + py*py; - random = r.Rndm(); + randomNum = r.Rndm(); T->Fill(); } T->Print(); diff --git a/tutorials/tree/spider.C b/tutorials/tree/spider.C index 4739c6a48d226..f6e762a7bd37e 100644 --- a/tutorials/tree/spider.C +++ b/tutorials/tree/spider.C @@ -19,9 +19,9 @@ void spider() { } TNtuple* ntuple = (TNtuple*)f->Get("ntuple"); TString varexp = "px:py:pz:random:sin(px):log(px/py):log(pz)"; - TString select = "px>0 && py>0 && pz>0"; + TString selection = "px>0 && py>0 && pz>0"; TString options = "average"; - TSpider *spider = new TSpider(ntuple,varexp.Data(),select.Data(),options.Data()); + TSpider *spider = new TSpider(ntuple,varexp.Data(),selection.Data(),options.Data()); spider->Draw(); c1->ToggleEditor(); c1->Selected(c1,spider,1); diff --git a/tutorials/tree/treegetval.C b/tutorials/tree/treegetval.C index d39635421743a..6dc5503a81ff1 100644 --- a/tutorials/tree/treegetval.C +++ b/tutorials/tree/treegetval.C @@ -19,7 +19,7 @@ /// with GetVal with a length corresponding to the parameter `fEstimate`. /// By default fEstimate=1000000 and can be modified /// via TTree::SetEstimate. To keep in memory all the results use: -/// ~~~ {.cpp} +/// ~~~{.cpp} /// tree->SetEstimate(-1); /// ~~~ /// SetEstimate should be called if the expected number of selected rows diff --git a/tutorials/unuran/unuranDemo.C b/tutorials/unuran/unuranDemo.C index 08a555be909a4..3e9b5daf02c4c 100644 --- a/tutorials/unuran/unuranDemo.C +++ b/tutorials/unuran/unuranDemo.C @@ -11,7 +11,7 @@ /// /// To execute the macro type in: /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// root[0]: gSystem->Load("libMathCore"); /// root[0]: gSystem->Load("libUnuran"); /// root[0]: .x unuranDemo.C+ diff --git a/tutorials/unuran/unuranFoamTest.C b/tutorials/unuran/unuranFoamTest.C index 48f68ae0211da..c388f4f31fb2b 100644 --- a/tutorials/unuran/unuranFoamTest.C +++ b/tutorials/unuran/unuranFoamTest.C @@ -2,7 +2,7 @@ /// \ingroup tutorial_unuran /// This program must be compiled and executed with Aclic as follows /// -/// ~~~ {.cpp} +/// ~~~{.cpp} /// .x unuranFoamTest.C+ /// ~~~ /// diff --git a/tutorials/xml/DOMParsePerson.C b/tutorials/xml/DOMParsePerson.C index 25cf8d23666e1..c8b17d2ed24d5 100644 --- a/tutorials/xml/DOMParsePerson.C +++ b/tutorials/xml/DOMParsePerson.C @@ -8,7 +8,7 @@ /// A DTD validation will be run on this example. /// /// To run this program -/// ~~~ {.cpp} +/// ~~~{.cpp} /// .x DOMParsePerson.C+ /// ~~~ /// diff --git a/tutorials/xml/DOMRecursive.C b/tutorials/xml/DOMRecursive.C index 9d4f95e535fd7..36a2f53cd188c 100644 --- a/tutorials/xml/DOMRecursive.C +++ b/tutorials/xml/DOMRecursive.C @@ -7,7 +7,7 @@ /// This example will parse any xml file. /// /// To run this program -/// ~~~ {.cpp} +/// ~~~{.cpp} /// .x DOMRecursive.C+ /// ~~~ /// diff --git a/tutorials/xml/SAXHandler.C b/tutorials/xml/SAXHandler.C index d1e12edb119d7..694b653728bc8 100644 --- a/tutorials/xml/SAXHandler.C +++ b/tutorials/xml/SAXHandler.C @@ -8,7 +8,7 @@ /// file, if successfully parsed. /// /// To run this program do: -/// ~~~ {.cpp} +/// ~~~{.cpp} /// .x SAXHandler.C /// ~~~ ///