RooFit Modeling (example: Gaussian) β’ Represent relations between variables and functions as client/server links between objects Gaus(π¦, π, π) Math RooGaussian g RooFit diagram RooRealVar π RooRealVar π RooRealVar π RooFit code RooRealVar x(βxβ,βxβ,2, -10,10) ; RooRealVar m(βmβ,βmβ,0) ; RooRealVar s(βsβ,β s β,3) ; RooGaussian model(β gaus β,β gaus β, x,m,s) ; 31
RooFit: Variables Observables and parameters are both defined as RooRealVar Several constructors available, depending on the needs: RooRealVar var1(β v1 β,βMy 1st varβ, 4.1); //constant variable RooRealVar var2(βv2β,β My 2nd varβ,1.,10.); //valid range, no initial value RooRealVar var3(βv3β,β My 3rd varβ,3.,1., 10.); //valid range, initial value You can also specify the unit (mostly for plotting purposes) RooRealVar time(βtimeβ,βDecay timeβ,0.,100.,β[ ps ]β ); You can change the properties of your RooRealVar later ( setRange(..) , setBins(..) , etc.) If you want to be 100% sure a variable will stay constant, use RooConstVar 32
RooFit: Probability Density Functions Each PDF in RooFit must inherit from RooAbsPdf . RooAbsPdf provides methods for numerical integration, events generation (hit &miss), fitting methods, etc. RooFit provides a very extensive list of predefined functions ( RooGaussian , RooPolynomial , RooCBShape , RooExponential , RooPoisson , RooUniform , etc β¦) If possible, always use a predefined function (if analytical integration or inversion method for generation are available, it will speed your computation) You can always define a custom function using RooGenericPdf 33
RooFit: Data Handling Two basic classes to handle data in RooFit: β’ RooDataSet : an unbinned dataset (think of it as a TTree). An ntuple of data β’ RooDataHist : a binned dataset (think of it as a THnF) Both types of data handlers can have multiple dimensions, contain discrete variables, weights, etc. Both inherit from RooAbsData. 34
RooFit functionalities PDF Visualization // Create an empty plot frame RooPlot* xframe = x.frame() ; // Plot model on frame model.plotOn(xframe) ; // Draw frame on canvas xframe->Draw() ; Axis label from gauss title Unit A RooPlot is an empty frame normalization capable of holding anything plotted versus it variable Plot range taken from limits of x
RooFit functionalities Toy MC generation from any pdf // Generate a toy MC set (10000 events) RooDataSet* data = model.generate(x,10000) ; Returned dataset is unbinned dataset (like a ROOT TTree with a RooRealVar as branch buffer) Data Visualization // Plot PDF RooPlot* xframe = x.frame() ; data->plotOn(xframe) ; xframe->Draw() ; Binning into histogram is performed in data->plotOn() call 36
RooFit functionalities Fit of model to data // ML fit of gauss to data model.fitTo(*data) ; // Parameters if gauss now reflect fitted values mean.Print() RooRealVar::mean = 0.0172335 +/- 0.0299542 sigma.Print() RooRealVar::sigma = 2.98094 +/- 0.0217306 Data and pdf visualization after fit // Plot fitted PDF and toy data overlaid PDF RooPlot* xframe2 = x.frame() ; automatically data->plotOn(xframe2) ; normalized gauss.plotOn(xframe2) ; to dataset xframe2->Draw() ; 37
RooFit Workspace 38
RooFit Workspace RooWorkspace class: container for all objected created: β’ full model configuration β’ PDF and parameter/observables descriptions β’ uncertainty/shape of nuisance parameters β’ (multiple) data sets β’ Maintain a complete description of all the model β’ possibility to save entire model in a ROOT file β’ Combination of results joining workspaces in a single one β’ All information is available for further analysis β’ common format for combining and sharing physics results RooWorkspace w(βwβ); w.import(data); w.import(pdf); w.writeToFile (β myWorkspace.root β) 39
RooFit Factory RooRealVar x(βxβ,βxβ,2, -10,10) RooRealVar s(βsβ,βsβ,3) ; RooRealVar m(βmβ,βmβ,0) ; RooGaussian g(βgβ,βgβ, x,m,s) The workspace provides a factory method to autogenerates objects from a math-like language (the p.d.f is made with 1 line of code instead of 4) RooWorkspace w; w.factory (βGaussian::g(x[2, -10,10],m[0],s[3 ])β) We will work using the workspace factory to build models 40
Using the workspace β’ Workspace β A generic container class for all RooFit objects of your project β Helps to organize analysis projects β’ Creating a workspace RooWorkspace w(βwβ) ; β’ Putting variables and function into a workspace β When importing a function or pdf, all its components (variables) are automatically imported too RooRealVar x(βxβ,βxβ, -10,10) ; RooRealVar mean(βmeanβ,βmeanβ,5) ; RooRealVar sigma(βsigmaβ,βsigmaβ,3) ; RooGaussian f(βfβ,βfβ,x,mean,sigma ) ; // imports f,x,mean and sigma w.import(f) ; 41
Using the workspace β’ Looking into a workspace w.Print() ; variables --------- (mean,sigma,x) p.d.f.s ------- RooGaussian::f[ x=x mean=mean sigma=sigma ] = 0.249352 β’ Getting variables and functions out of a workspace // Variety of accessors available RooPlot* frame = w.var(βxβ) ->frame() ; w.pdf(βfβ) ->plotOn(frame) ; 42
Using the workspace β’ Organizing your code β Separate construction and use of models void driver() { RooWorkspace w(βwβ0 ; makeModel(w) ; useModel(w) ; } void makeModel(RooWorkspace& w) { // Construct model here } void useModel(RooWorkspace& w) { // Make fit, plots etc here } 43
Factory syntax β’ Rule #1 β Create a variable x[-10,10] // Create variable with given range x[5,-10,10] // Create variable with initial value and range x[5] // Create initially constant variable β’ Rule #2 β Create a function or pdf object ClassName::Objectname(arg1,[arg2],...) β Leading βRooβ in class name can be omitted β Arguments are names of objects that already exist in the workspace β Named objects must be of correct type, if not factory issues error β Set and List arguments can be constructed with brackets {} Gaussian::g(x,mean,sigma) ο RooGaussian(βgβ,βgβ,x,mean,sigma ) Polynomial::p(x,{a0,a1}) ο RooPolynomial (βpβ,βpβ,xβ,RooArgList (a0,a1)); 44
Factory syntax β’ Rule #3 β Each creation expression returns the name of the object created β Allows to create input arguments to functions βin placeβ rather than in advance Gaussian::g(x[-10,10],mean[-10,10],sigma[3]) ο x[-10,10] mean[-10,10] sigma[3] Gaussian::g(x,mean,sigma) β’ Miscellaneous points β You can always use numeric literals where values or functions are expected Gaussian::g(x[-10,10], 0,3 ) β It is not required to give component objects a name, e.g. SUM::model(0.5* Gaussian (x[-10,10],0,3), Uniform (x)) ; 45
Model building β (Re)using standard components β’ RooFit provides a collection of compiled standard PDF classes Physics inspired RooBMixDecay ARGUS,Crystal Ball, RooPolynomial Breit-Wigner, Voigtian, B/D- Decay,β¦. RooHistPdf Non-parametric RooArgusBG Histogram, KEYS RooGaussian Basic Gaussian, Exponential, Polynomial,β¦ Chebychev polynomial Easy to extend the library: each p.d.f. is a separate C++ class 46
Model building β (Re)using standard components β’ List of most frequently used pdfs and their factory spec Gaussian Gaussian::g(x,mean,sigma) Breit-Wigner BreitWigner::bw(x,mean,gamma) Landau Landau::l(x,mean,sigma) Exponential Exponental::e(x,alpha) Polynomial Polynomial::p(x,{a0,a1,a2}) Chebychev Chebychev::p(x,{a0,a1,a2}) Kernel Estimation KeysPdf::k(x,dataSet) Poisson Poisson::p(x,mu) Voigtian Voigtian::v(x,mean,gamma,sigma) (=BW β G ) 47
Model building β using expressions β’ Customized p.d.f from interpreted expressions w.factory (βEXPR:: mypdf( β sqrt (a*x)+bβ ,x,a,b )β) ; β’ Customized class, compiled and linked on the fly w.factory (βCEXPR:: mypdf( β sqrt (a*x)+bβ ,x,a,b )β) ; β’ re-parametrization of variables (making functions) w.factory (βexpr::w(β(1 - D)/2β,D[0,1])β) ; β note using expr (builds a function , a RooAbsReal) β instead of EXPR (builds a pdf , a RooAbsPdf) This usage of upper vs lower case applies also for other factory commands (SUM, PROD,.... ) 48
Composite Models β’ Most realistic models are constructed as the sum of one or more p.d.f.s (e.g. signal and background) β’ Facilitated through operator p.d.f RooAddPdf RooBMixDecay RooPolynomial RooHistPdf RooArgusBG RooGaussian + RooAddPdf 49
26 Factory syntax: Adding p.d.f. β’ Additions of PDF (using fractions) β Note that last PDF does not have an associated fraction β’ PDF additions (using expected events instead of fractions) β the resulting model will be extended β the likelihood will contain a Poisson term depending on the total number of expected events (Nsig+Nbkg) SUM::name(frac1*PDF1,frac2*PDF2,...,PDFN) SUM::name(frac1*PDF1,PDFN) SUM::name(Nsig*SigPDF,Nbkg*BkgPDF) L (x | p) -> L(x|p)Poisson(N obs ,N exp ) 50
Component plotting - Introduction β’ Plotting, toy event generation and fitting works identically for composite p.d.f.s β Several optimizations applied behind the scenes that are specific to composite models (e.g. delegate event generation to components) β’ Extra plotting functionality specific to composite pdfs β Component plotting // Plot only argus components w::sum.plotOn(frame,Components (β argus β) ,LineStyle(kDashed)) ; // Wildcards allowed w::sum.plotOn(frame,Components (βgauss*β) ,LineStyle(kDashed)) ; 51
Convolution β’ Many experimental observable quantities are well described by convolutions β Typically physics distribution smeared with experimental resolution (e.g. for B0 ο J/ y K S exponential decay distribution smeared with Gaussian) ο = β By explicitly describing observed distribution with a convolution p.d.f can disentangle detector and physics β’ To the extent that enough information is in the data to make this possible 52
Convolution operation in RooFit β’ RooFit has several options to construct convolution p.d.f.s β Class RooNumConvPdf β βBrute forceβ numeric calculation of convolution (and normalization integrals) β Class RooFFTConvPdf β Calculate convolution integral using discrete FFT technology in fourier-transformed space. β Bases classes RooAbsAnaConvPdf , RooResolutionModel . Framework to construct analytical convolutions (with implementations mostly for B physics) β Class RooVoigtian β Analytical convolution of non-relativistic Breit-Wigner shape with a Gaussian β’ All convolution in one dimension so far β N-dim extension of RooFFTConvPdf foreseen in future 53
Numeric Convolution β’ Example w.factory (βLandau::L(x[ - 10,30],5,1)β) : w.factory (βGaussian::G(x,0,2)β) ; w::x.setBins (βcacheβ,10000) ; // FFT sampling density w.factory (β FCONV::LGf(x,L,G) β) ; // FFT convolution w.factory (β NCONV::LGb(x,L,G) β) ; // Numeric convolution β’ FFT usually best β Fast: unbinned ML fit to 10K events take ~5 seconds β NB: Requires installation of FFTW package (free, but not default) β Beware of cyclical effects (some tools available to mitigate) 54
Common Fitting Errors i.e. : - Understanding MINUIT output - Instabilities and correlation coefficients 55
What happens when you do pdf->fitTo(*data) ? 56
Fitting and likelihood minimization β’ What happens when you do pdf->fitTo(*data) β 1) Construct object representing β log of (extended) likelihood β 2) Minimize likelihood w.r.t floating parameters using MINUIT β’ Can also do these two steps explicitly by hand // Construct function object representing β log(L) RooAbsReal* nll = pdf.createNLL(data) ; // Minimize nll w.r.t its parameters RooMinuit m(*nll) ; m.migrad() ; m.hesse() ; 57
Let take a closer look at Minuit 58
A brief description of MINUIT functionality β’ MIGRAD β Find function minimum. Calculates function gradient, follow to (local) minimum, recalculate gradient, iterate until minimum found β’ To see what MIGRAD does, it is very instructive to do RooMinuit::setVerbose(1). It will print a line for each step through parameter space β Number of function calls required depends greatly on number of floating parameters, distance from function minimum and shape of function β’ HESSE β Calculation of error matrix from 2 nd derivatives at minimum β Gives symmetric error. Valid in assumption that likelihood is (locally parabolic) ο 1 ο¦ οΆ 2 ln d L Λ ο³ ο½ ο½ ο§ ο· Λ 2 ( ) ( ) p V p ο§ ο· 2 ο¨ οΈ d p β Requires roughly N 2 likelihood evaluations (with N = number of floating parameters) 59
A brief description of MINUIT functionality β’ MINOS β Calculate errors by explicit finding points (or contour for >1D) where D -log(L)=0.5 β Reported errors can be asymmetric β Can be very expensive in with large number of floating parameters β’ CONTOUR β Find contours of equal D -log(L) in two parameters and draw corresponding shape β Mostly an interactive analysis tool 60
Note of MIGRAD function minimization β’ For all but the most trivial scenarios it is not possible to automatically find reasonable starting values of parameters β So you need to supply βreasonableβ starting values for your parameters -log(L) Reason: There may exist multiple (local) minima in the likelihood or c 2 Local minimum True minimum p β You may also need to supply βreasonableβ initial step size in parameters. (A step size 10x the range of the above plot is clearly unhelpful) β Using RooMinuit, the initial step size is the value of RooRealVar::getError(), so you can control this by supplying initial error values 61
Minuit function MIGRAD β’ Purpose: find minimum Progress information, watch for errors here ********** ** 13 **MIGRAD 1000 1 ********** (some output omitted) MIGRAD MINIMIZATION HAS CONVERGED. MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX. COVARIANCE MATRIX CALCULATED SUCCESSFULLY FCN=257.304 FROM MIGRAD STATUS=CONVERGED 31 CALLS 32 TOTAL EDM=2.36773e-06 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER STEP FIRST NO. NAME VALUE ERROR SIZE DERIVATIVE 1 mean 8.84225e-02 3.23862e-01 3.58344e-04 -2.24755e-02 2 sigma 3.20763e+00 2.39540e-01 2.78628e-04 -5.34724e-02 ERR DEF= 0.5 EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5 1.049e-01 3.338e-04 3.338e-04 5.739e-02 Parameter values and approximate PARAMETER CORRELATION COEFFICIENTS errors reported by MINUIT NO. GLOBAL 1 2 1 0.00430 1.000 0.004 Error definition (in this case 0.5 for 2 0.00430 0.004 1.000 a likelihood fit) 62
Minuit function MIGRAD β’ Purpose: find minimum Value of c 2 or likelihood at ********** minimum ** 13 **MIGRAD 1000 1 ********** (NB: c 2 values are not divided (some output omitted) by N d.o.f ) MIGRAD MINIMIZATION HAS CONVERGED. MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX. COVARIANCE MATRIX CALCULATED SUCCESSFULLY FCN=257.304 FROM MIGRAD STATUS=CONVERGED 31 CALLS 32 TOTAL EDM=2.36773e-06 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER STEP FIRST NO. NAME VALUE ERROR SIZE DERIVATIVE 1 mean 8.84225e-02 3.23862e-01 3.58344e-04 -2.24755e-02 2 sigma 3.20763e+00 2.39540e-01 2.78628e-04 -5.34724e-02 ERR DEF= 0.5 EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5 1.049e-01 3.338e-04 3.338e-04 5.739e-02 Approximate PARAMETER CORRELATION COEFFICIENTS Error matrix NO. GLOBAL 1 2 And covariance matrix 1 0.00430 1.000 0.004 2 0.00430 0.004 1.000 63
Minuit function MIGRAD Status : Should be βconvergedβ but can be βfailedβ β’ Purpose: find minimum Estimated Distance to Minimum should be small O(10 -6 ) ********** ** 13 **MIGRAD 1000 1 Error Matrix Quality ********** should be βaccurateβ, but can be (some output omitted) βapproximateβ in case of trouble MIGRAD MINIMIZATION HAS CONVERGED. MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX. COVARIANCE MATRIX CALCULATED SUCCESSFULLY FCN=257.304 FROM MIGRAD STATUS=CONVERGED 31 CALLS 32 TOTAL EDM=2.36773e-06 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER STEP FIRST NO. NAME VALUE ERROR SIZE DERIVATIVE 1 mean 8.84225e-02 3.23862e-01 3.58344e-04 -2.24755e-02 2 sigma 3.20763e+00 2.39540e-01 2.78628e-04 -5.34724e-02 ERR DEF= 0.5 EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5 1.049e-01 3.338e-04 3.338e-04 5.739e-02 PARAMETER CORRELATION COEFFICIENTS NO. GLOBAL 1 2 1 0.00430 1.000 0.004 2 0.00430 0.004 1.000 64
Minuit function HESSE β’ Purpose: calculate error matrix from 2 d L 2 dp ********** ** 18 **HESSE 1000 Error matrix ********** (Covariance Matrix) COVARIANCE MATRIX CALCULATED SUCCESSFULLY calculated from ο FCN=257.304 FROM HESSE STATUS=OK 10 CALLS 42 TOTAL 1 ο¦ οΆ ο 2 ( ln ) d L EDM=2.36534e-06 STRATEGY= 1 ERROR MATRIX ACCURATE ο§ ο· ο½ V ο§ ο· EXT PARAMETER INTERNAL INTERNAL ij dp dp ο¨ οΈ NO. NAME VALUE ERROR STEP SIZE VALUE i j 1 mean 8.84225e-02 3.23861e-01 7.16689e-05 8.84237e-03 2 sigma 3.20763e+00 2.39539e-01 5.57256e-05 3.26535e-01 ERR DEF= 0.5 EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5 1.049e-01 2.780e-04 2.780e-04 5.739e-02 PARAMETER CORRELATION COEFFICIENTS NO. GLOBAL 1 2 1 0.00358 1.000 0.004 2 0.00358 0.004 1.000 65
Minuit function HESSE β’ Purpose: calculate error matrix from 2 d L 2 dp ********** ** 18 **HESSE 1000 ********** COVARIANCE MATRIX CALCULATED SUCCESSFULLY FCN=257.304 FROM HESSE STATUS=OK 10 CALLS 42 TOTAL EDM=2.36534e-06 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER INTERNAL INTERNAL NO. NAME VALUE ERROR STEP SIZE VALUE 1 mean 8.84225e-02 3.23861e-01 7.16689e-05 8.84237e-03 Correlation matrix r ij 2 sigma 3.20763e+00 2.39539e-01 5.57256e-05 3.26535e-01 calculated from ERR DEF= 0.5 ο½ ο³ ο³ r V EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5 ij i j ij 1.049e-01 2.780e-04 2.780e-04 5.739e-02 PARAMETER CORRELATION COEFFICIENTS NO. GLOBAL 1 2 1 0.00358 1.000 0.004 2 0.00358 0.004 1.000 66
Minuit function HESSE β’ Purpose: calculate error matrix from 2 d L 2 dp ********** ** 18 **HESSE 1000 ********** COVARIANCE MATRIX CALCULATED SUCCESSFULLY FCN=257.304 FROM HESSE STATUS=OK 10 CALLS 42 TOTAL EDM=2.36534e-06 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER INTERNAL INTERNAL NO. NAME VALUE ERROR STEP SIZE VALUE 1 mean 8.84225e-02 3.23861e-01 7.16689e-05 8.84237e-03 Global correlation vector: 2 sigma 3.20763e+00 2.39539e-01 5.57256e-05 3.26535e-01 correlation of each parameter ERR DEF= 0.5 with all other parameters EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5 1.049e-01 2.780e-04 2.780e-04 5.739e-02 PARAMETER CORRELATION COEFFICIENTS NO. GLOBAL 1 2 1 0.00358 1.000 0.004 2 0.00358 0.004 1.000 67
Minuit function MINOS β’ Error analysis through D nll contour finding ********** ** 23 **MINOS 1000 ********** FCN=257.304 FROM MINOS STATUS=SUCCESSFUL 52 CALLS 94 TOTAL EDM=2.36534e-06 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER PARABOLIC MINOS ERRORS NO. NAME VALUE ERROR NEGATIVE POSITIVE 1 mean 8.84225e-02 3.23861e-01 -3.24688e-01 3.25391e-01 2 sigma 3.20763e+00 2.39539e-01 -2.23321e-01 2.58893e-01 ERR DEF= 0.5 Symmetric error MINOS error Can be asymmetric (repeated result from HESSE) (in this example the βsigmaβ error is slightly asymmetric) 68
Difference between HESSE and MINOS errors β’ βPathologicalβ example likelihood with multiple minima and non-parabolic behavior MINOS error Extrapolation of parabolic approximation at minimum HESSE error 69
Practical estimation β Fit converge problems β’ Sometimes fits donβt converge because, e.g. β MIGRAD unable to find minimum β HESSE finds negative second derivatives (which would imply negative errors) β’ Reason is usually numerical precision and stability problems, but β The underlying cause of fit stability problems is usually by highly correlated parameters in fit β’ HESSE correlation matrix in primary investigative tool PARAMETER CORRELATION COEFFICIENTS Signs of troubleβ¦ NO. GLOBAL 1 2 1 0.99835 1.000 0.998 2 0.99835 0.998 1.000 β In limit of 100% correlation, the usual point solution becomes a line solution (or surface solution) in parameter space. Minimization problem is no longer well defined 70
Mitigating fit stability problems β’ Strategy I β More orthogonal choice of parameters β Example: fitting sum of 2 Gaussians of similar width ο½ ο« ο ( ; , , , ) ( ; , ) ( 1 ) ( ; , ) F x f m s s fG x s m f G x s m 1 2 1 1 2 2 HESSE correlation matrix PARAMETER CORRELATION COEFFICIENTS NO. GLOBAL [ f] [ m] [s1] [s2] [ f] 0.96973 1.000 -0.135 0.918 0.915 Widths s 1 ,s 2 [ m] 0.14407 -0.135 1.000 -0.144 -0.114 strongly correlated [s1] 0.92762 0.918 -0.144 1.000 0.786 fraction f [s2] 0.92486 0.915 -0.114 0.786 1.000 71
Mitigating fit stability problems β Different parameterization: ο« ο ο ( ; , ) ( 1 ) ( ; , ) fG x s m f G x s s m 1 1 1 2 1 2 2 PARAMETER CORRELATION COEFFICIENTS NO. GLOBAL [f] [m] [s1] [s2] [ f] 0.96951 1.000 -0.134 0.917 -0.681 [ m] 0.14312 -0.134 1.000 -0.143 0.127 [s1] 0.98879 0.917 -0.143 1.000 -0.895 [s2] 0.96156 -0.681 0.127 -0.895 1.000 β Correlation of width s2 and fraction f reduced from 0.92 to 0.68 β Choice of parameterization matters! β’ Strategy II β Fix all but one of the correlated parameters β If floating parameters are highly correlated, some of them may be redundant and not contribute to additional degrees of freedom in your model 72
Mitigating fit stability problems -- Polynomials β’ Warning: Regular parameterization of polynomials a 0 +a 1 x+a 2 x 2 +a 3 x 3 nearly always results in strong correlations between the coefficients a i . β Fit stability problems, inability to find right solution common at higher orders β’ Solution: Use existing parameterizations of polynomials that have (mostly) uncorrelated variables β Example: Chebychev polynomials 73
Minuit CONTOUR useful to examine βbadβ correlations β’ Example of 1,2 sigma contour of two uncorrelated variables β Elliptical shape. In this example parameters are uncorrelation β’ Example of 1,2 sigma contour of two variables with problematic correlation β Pdf = f ο G1(x,0,3)+(1-f) ο G2(x,0,s) with s=4 in data 74
Practical estimation β Bounding fit parameters β’ Sometimes is it desirable to bound the allowed range of parameters in a fit β Example: a fraction parameter is only defined in the range [0,1] β MINUIT option βBβ maps finite range parameter to an internal infinite range using an arcsin(x) transformation: Bounded Parameter space External Error MINUIT internal parameter space (- β,+β) Internal Error 75
Working with Likelihood and RooMinuit 76
Fitting and likelihood minimization β’ What happens when you do pdf->fitTo(*data) β 1) Construct object representing β log of (extended) likelihood β 2) Minimize likelihood w.r.t floating parameters using MINUIT β’ Can also do these two steps explicitly by hand // Construct function object representing β log(L) RooAbsReal* nll = pdf.createNLL(data) ; // Minimize nll w.r.t its parameters RooMinuit m(*nll) ; m.migrad() ; m.hesse() ; 77
Plotting the likelihood β’ A likelihood function is a regular RooFit function β’ Can e.g. plot is as usual RooAbsReal* nll = w::model.createNLL(data) ; RooPlot* frame = w::param.frame() ; nll->plotOn(frame,ShiftToZero()) ; 78
Constructing a π 2 function β’ Along similar lines it is also possible to construct a c 2 function β Only takes binned datasets (class RooDataHist ) β Normalized p.d.f is multiplied by Ndata to obtain c 2 // Construct function object representing β log(L) RooAbsReal* chi2 = pdf.createChi2(data) ; // Minimize nll w.r.t its parameters RooMinuit m(chi2) ; m.migrad() ; m.hesse() ; β MINUIT error definition for c 2 automatically adjusted to 1 (it is 0.5 for likelihoods) as default error level is supplied through virtual method of function base class RooAbsReal 79
Automatic optimizations in calculation of likelihood β’ Several automatic computational optimizations are applied the calculation of likelihoods inside RooNLLVar β Components that have all constant parameters are pre-calculated β Dataset variables not used by the PDF are dropped β PDF normalization integrals are only recalculated when the ranges of their observables or the value of their parameters are changed β Simultaneous fits: When a parameters changes only parts of the total likelihood that depend on that parameter are recalculated β’ Lazy evaluation: calculation only done when intergal value is requested β’ Applicability of optimization techniques is re-evaluated for each use β Maximum benefit for each use case β’ βTypicalβ large -scale fits see significant speed increase β Factor of 3x β 10x not uncommon. 80
Statistical procedures involving likelihood β’ βSimpleβ Parameter and error estimation (MINUIT/HESSE/MINOS) β’ Construct Bayesian credible intervals β Likelihood appears in Bayes theorem for hypothesis with continuous parameters β’ Construct (Profile) Likelihood Ratio intervals β βApproximate Confidence intervalsβ (Wilks theoreom) β Connection to MINOS errors β’ NB: Can also construct Frequentist intervals (Neyman construction), but these are based on PDFs, not likelihoods 81
Likelihood minimization β class RooMinuit β’ Class RooMinuit is an interface to the ROOT implementation of the MINUIT minimization and error analysis package. β’ RooMinuit takes care of β Passing value of miminized RooFit function to MINUIT β Propagated changes in parameters both from RooRealVar to MINUIT and back from MINUIT to RooRealVar , i.e. it keeps the state of RooFit objects synchronous with the MINUIT internal state β Propagate error analysis information back to RooRealVar parameters objects β Exposing high-level MINUIT operations to RooFit uses (MIGRAD,HESSE,MINOS) etcβ¦ β Making optional snapshots of complete MINUIT information (e.g. convergence state, full error matrix etc) 82
Demonstration of RooMinuit use // Start Minuit session on above nll RooMinuit m(nll) ; // MIGRAD likelihood minimization m.migrad() ; // Run HESSE error analysis m.hesse() ; // Set sx to 3, keep fixed in fit sx.setVal(3) ; sx.setConstant(kTRUE) ; // MIGRAD likelihood minimization m.migrad() ; // Run MINOS error analysis m.minos() // Draw 1,2,3 βsigmaβ contours in sx,sy m.contour(sx,sy) ; 83
Nuisance parameters β’ Nuisance parameters are parameters in the problem which affect the result but which are not of prime interest. β’ Two examples: β’ Measure the x-sec for dark matter annihilation and estimate an interval on it. Mass of dark matter particle is then a nuisance parameter. β’ Measure the rate of a process and estimate an interval on it. Background expectation is a nuisance parameter. 85
86
Likelihood ratio intervals β’ Definition of Likelihood Ratio interval (identical to MINOS for 1 parameter) Likelihood ratio interval ο² ο ο² ( , ) L x Extrapolation ο ο½ of parabolic ( , ) LR x ο² approximation ο Λ ( , ) L x at minimum HESSE error 87
Dealing with nuisance pars in Likelihood ratio intervals β’ Nuisance parameters in LR interval β For each value of the parameter of interest, search the full subspace of nuisance parameters for the point at which the likelihood is maximized. β Associate that value of the likelihood with that value of the parameter of interest ο βProfile likelihoodβ -logLR(mean,sigma) -logLR(mean,sigma) -logPLR(mean) MLE fit fit data Λ ο ο³ ο Λ β’ best L( ΞΌ ) for any value of s ( , ( )) L ο¬ ο ο½ ( ) ο ο³ Λ Λ ( , ) β’ best L( ΞΌ , Ο ) L 88
Working with profile likelihood Λ Λ Best L for given p ( , ) L p q ο¬ p ο½ ( ) β’ A profile likelihood ratio Λ Λ Best L ( , ) L p q can be represent by a regular RooFit function (albeit an expensive one to evaluate) RooAbsReal* ll = model.createNLL(data,NumCPU(8)) ; RooAbsReal* pll = ll->createProfile(params) ; RooPlot* frame = w::frac.frame() ; nll->plotOn(frame,ShiftToZero()) ; pll->plotOn(frame,LineColor(kRed)) ; 89
Dealing with nuisance pars in Likelihood ratio intervals β’ Likelihood Ratio β’ Profile Likelihood Ratio β’ Minimizes β log(L) for each value of f sig by changing bkg shape params (a 6 th order Chebychev Pol) 90
On the equivalence of profile likelihood and MINOS β’ Demonstration of equivalence of (RooFit) profile likelihood and MINOS errors β Macro to make above plots is 34 lines of code (+23 to beautify graphics appearance) 91
TMVA 92
TMVA β’ The Toolkit for Multivariate Analysis (TMVA) provides a ROOT-integrated machine learning environment. β’ Good for processing and parallel evaluation of β multivariate classification β regression techniques (*) β’ TMVA is specifically designed to the needs of high- energy physics (HEP) application, but should not be restricted to these. (*) out of topics for this course 93
Classification Problems β’ Start with a large data sample β millions or billions of collisions or decays per second β’ Want to look at a rare or very rare process β a few Higgses per day, a few ΞΌβeee decays per year β’ Need to pump up the signal-to-background ratio β at good signal efficiency! β’ Start with the trigger β only record interesting events - a few hundred per second) β’ Perform event selection on recorded data β topic for TMVA 94
Ideal case: PDFs completely known β’ If the signal and background PDFs are both known: Neyman-Pearson Lemma: π π¦ π) Likelihood ratio: π’ π¦ = π π¦ πΆ) is the best possible selection criterion β’ How well we can select is given by the overlap of the PDFs 95
ROC Curve R eceiver O perating C haracteristics SIG BCK originally from signal transmission in electrical engineering 1 Background Rejection 0 Signal Efficiency 1 96
ROC Curve Randomly throwing away events Ideal case: Completely disjoint PDFs 1 How far you can go to the Background Rejection Better upper right is limited by selection Neyman-Pearson Some selection How to find good selections if PDFs are not known ? 0 Signal Efficiency 1 this model is predicting signal as background and vice versa ( worst case). 97
TMVA β’ All multivariate techniques in TMVA belong to the family of supervised learning algorithms. β’ They make use of training events, for which the desired output is known, to determine the mapping function that describes β a decision boundary (classification) or β an approximation of the underlying functional behaviour dening the target value (regression). β’ The analysis is performed in 2 phases: β Training β’ This phase includes training, testing and evaluation β Application 98
TMVA algorythms Provides support with uniform interface to many Multivariate Analysis technologies: β’ Rectangular cut optimisation β’ Linear discriminant analysis (H-Matrix, Fisher and linear (LD) discriminants) β’ Neural networks (Deep networks, Multilayer perceptron) β’ Bagged/Boosted decision trees β’ Function discriminant analysis (FDA) β’ Multidimensional probability density estimation (PDE-range-search, PDE-Foam) β’ Multidimensional k-nearest neighbour method β’ Predictive learning via rule ensembles (RuleFit) β’ Projective likelihood estimation (PDE approach) β’ Support Vector Machine (SVM) 99
Using TMVA β’ TMVA comes with β example jobs for the training phase using the TMVA Factory β the application of the training results in a classification or regression analysis using the TMVA Reader . β’ training examples are β TMVAClassification.C, TMVAMulticlass.C and TMVARegression.C, β’ application examples are β TMVAClassificationApplication.C, TMVAMulticlassApplication.C and TMVARegressionApplication.C. β’ The above macros (extension .C) are located in the directory $ROOTSYS/tutorials/tmva where $ROOTSYS is the path to your ROOT installation. β’ Additionally TMVACrossValidation.C shows how cross validation is performed. 100
Recommend
More recommend