Top Banner
New Developments of ROOT Mathematical Software Libraries Lorenzo Moneta CERN/PH-SFT
25

New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

Feb 12, 2018

Download

Documents

trinhtruc
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

New Developments of ROOT

Mathematical Software Libraries

Lorenzo Moneta

CERN/PH-SFT

Page 2: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

Root Math Work Package Main responsibilities for this work package:

Evaluation of basic mathematical functions Numerical algorithms Random numbers Linear algebra Physics and geometry vectors (3D and 4D) Fitting and minimization Histograms (math and statistical part) Statistics (confidence levels, multivariate analysis)

People contributing: A. Kreshuk, L. Moneta (CERN) E. Offermann (TMatrix and L.A.), J. Palacios (SMatrix) J. Leydold, Vienna (Unuran) M. Fischler, J. Marraffino, W. Brown, FNAL others: W. Verkerke (RooFit), TMVA team, etc..

2

Page 3: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

Outline

Recent developments of ROOT Math Libraries : Physics and vector package (GenVector) new matrix package (SMatrix) Random numbers (UNURAN) Numerical algorithms from GSL (MathMore)

Fitting and Minimization new C++ Minuit (Minuit2) on-going fitting developments GUI for fitting

Other recent developments: FFT (based on FFTW) Histogram comparison (new χ2 test)

Future plans and Conclusions

3

Page 4: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

Current Status of ROOT Math Libs

4

TMatrixPhysics Vectors

Basic Math functions

Basic algorithms

Function interfaces

StatisticalUtilities

MathCore

TMinuit

TFumili Minuit2(new C++ Minuit)

Fitting and Minimization

Linear Fitter

Extra Math functions

Extra algorithms

GSL and more

MathMore

TH1

TMath

New Fitter RooFit

SMatrix

Linear Algebra

TMVA MLP

Statistical Libraries

Random Numbers

TF1

Histogram library

libCore

TRandomno dependency

with dependency

not yet released

Page 5: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

Evaluation of Mathematical Functions

Special Functions: use interface proposed to the C++ standard:

double cyl_bessel_i (double nu, double x);

Statistical Functions: Probability density functions (pdf) Cumulative distributions (lower tail and upper tail) Inverse of cumulative distributions (quantiles)

Coherent naming scheme. Example for χ2 distribution:chisquared_pdfchisquared_cdf, chisquared_cdf_c,chisquared_quantile, chisquare_quantile_c

Large variety of new functions complementing TMath tested for quality (comparison Mathematica and Nag)

5

Page 6: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

Physics and Geometry Vectors Classes for 3D and 4D vectors with their operations and

transformations (rotations) functionality as in CLHEP Vector and Geometry packages

Work done in collaboration with Fermilab computing group (M. Fischler, W. Brown and J. Marraffino)

Main features of the new classes: generic scalar contained type

i.e. single, double precision or Double32_t generic coordinate system concept

i.e. cartesian, polar and cylindrical

Used now by CMS and LHCb Classes do not inherit from TObject and cannot be used in ROOT

collections (like TClonesArray) Plan in the future to re-implement TLorentzVector using the new

classes

6

Page 7: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT 7

GenVector Performances Optimal run-time performance

✦ no virtual calls and use of inline methods

✦ user can choose best coordinate system

Page 8: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

SMatrix Package Package initially developed by T. Glebe for HeraB Matrix and vector classes of arbitrary type For fixed (not dynamic) matrix and vector sizes :

size must be knows at compile timeSMatrix< double, 2 , 5>SVector< double, 5 >

Complementary and NOT a replacement of TMatrix Optimized for small matrix sizes (dim <= 6):

use expression templates to avoid temporaries Support for symmetric matrices (thanks to J.Palacios, LHCb)

storage of only n*(n+1)/2 elements Support for basic operations and matrix inversion

not full linear algebra functionality Used by LHCb, CMS and now ATLAS to replace CLHEP

significant improvement observed in their reconstruction code

8

Page 9: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

Matrix Operations Performances✦ Comparison ROOT (TMatrix/SMatrix) and CLHEP (HepMatrix)

✦ lxplus ( new Intel dual-core 64 bits) running slc4 with gcc 3.4.6

9

Page 10: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

Kalman Filter Tests

10

✦ CPU performances in the Kalman filter update equations✦ addition,multiplication and

inversion✦ test varying matrix sizes

✦ 2 <N1,N2 ≤ 6✦ 6 < max(N1,N2) ≤ 10

✦ Strong performance gains for both SMatrix and TMatrix compared to the CLHEP matrix✦ Observed large

improvements in the real tracking code

Page 11: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

MathMore Library C++ interface to GSL algorithms and functions

requires a GSL (version >= 1.8) already installed Numerical algorithms for 1D functions:

Numerical Derivation central evaluation (5 points rule) and forward/backward

Numerical Integration adaptive integration for finite and infinite intervals

Root Finders bracketing and polishing algorithms using derivatives

Minimization Golden section and Brent algorithm

Interpolation linear, polynomial, cubic and Akima spline

Chebyshev polynomials (for function approximation)

Random Numbers generation and distributions

11

Page 12: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

ROOT Pseudo-Random Number Generators

TRandom3 : Mersenne-Twister generator (recommended one) fast and excellent pseudo-random quality

very long period, ~106000 large state (624 words)

TRandom2: TausWorthe generator from L’Ecuyer fast and good qualityperiod: 1026 (only 3 Words)

TRandom1: RanLux generator proven random quality, but slow (more x10)

TRandom: linear congruential generator bad quality even though improved recently state of only 32 bits (very short period : 231 ~ 109) must NOT be used in any statistics application maintain only for backward compatibility

12

TRandom

TRandom1

TRandom2

TRandom3

Page 13: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

Performances of Random Number Generators

Tests run on lxplus machine linux slc4 machine (gcc 3.4) with Intel dual core 64 bits

13

Page 14: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

Improvements in Random Number Distributions

New faster algorithm for generating Gaussian number acceptance-complement ratio method (W.Hörmann,G.Derflinger)

from UNU.RAN faster than polar method (Box-Muller) which requires 2 math

numbers + some math function evaluations one of the fastest existing methods

New Poisson algorithm previous one was buggy for large mu values exact algorithm (rejection from a Lorentzian distribution) if µ constant not very efficient

better using algorithm from UNU.RAN

14

Page 15: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

new package for generating non-uniform pseudo-random numbers developed ROOT interface to a C package developed by a

group in Vienna (J. Leydold et al.) various methods for 1D, multi-dimensional discrete and

empirical distributions (from a set of data) methods also for standard distributions (like Gauss,

Poisson, etc..)

provides efficient, exact methods and works for non truncated functions TF1::GetRandom() requires a range and it is approximate

UNURAN

15

Page 16: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

Random Number Performances Gauss random numbers Poisson random numbers

16

UNURANGaus

TF1Gaus

CLHEP Gaus

GSL Gaus

Rannor

New (ACR)

Old TRandom

0 50 100 150 200

183

42

130

54

90

102

50

Random Gauss

ns/callTests run on lxplus slc4 dual-core Intel 64

Very efficient when distribution parameters are constant

Page 17: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

Fitting and MinimizationNew C++ version of Minuit (Minuit2) since ROOT v5.08

Same basic functionality as in old version Migrad, Simplex, Minos algorithms

Extended functionality: single side parameter limits added Fumili method for least square and likelihood fits

validated with extensive testing same results and number of function calls to find minimum

implemented a ROOT fitter interface (TVirtualFitter)

OO package for generic function minimization easy to extend by inserting new minimization algorithms plan to add constrained minimization

17

Page 18: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

Proposal for new ROOT Fitter Plan to introduce in ROOT new fitting classes

improve and extend functionality of TVirtualFitter a mini fitting and minimization framework

complementary to RooFit

with possibility to : perform parallel fits (use in a multi-threads environment) use various pre-defined fitting methods use different minimization algorithms (via plug-in manager) use analytical derivative whenever possible

easier maintainability in the long term easier to use various fitting and minimization methods

18

Page 19: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

developed a new Fit Panel for fitting ROOT objects (TH1, TGraph etc...)

New GUI for Fitting

19

Page 20: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

Fast Fourier Transform Implemented an interface to the popular FFTW package

(see www.fftw.org) support for one and multi-dimensional transforms support for complex and real transformations

20

TFFTComplex for complex input/complex output transforms

TFFTRealComplex for real input/complex output

TFFTComplexReal for complex input/real output

TFFTReal for real input/output

Page 21: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

Histogram Comparison Improvements in χ2 test for comparing histograms

algorithm from N. Gagunashvili (see talk at this conference) and implemented in C++ by D. Haertl

21

add possibility to use weighted histograms

comparison of histograms with different scales

produce normalized residuals

Page 22: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

Statistical Tools New in ROOT: TMVA (see H. Voss)

sophisticated tools for multi-variate analysis (signal/background discrimination)

Plan for a re-organization of statistical tools in ROOT driven by requirements from LHC experiments

will be discussed in June at Phystat-LHC workshop

on-going developments for framework for evaluating discovery significances and confidence levels (RooStat)

Plan to introduce new algorithms multi-dim smoothing, cluster analysis

22

Page 23: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

Future Plans and Conclusions MathCore library

complete integration with existing ROOT core Math functionality remove duplication (obsolete algorithms or functions)

MathMore library extend the GSL C++ wrapper

quasi-random numbers, differential equations, multi-dimensional algorithms (minimization, integration, etc..)

Introduce in ROOT the new fitting classes Statistical tools developments Work on requests and feedback from LHC experiments

23

Page 24: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

Documentation New Math chapter in the ROOT User Guide (chapter 13,

227-248) describe random numbers, MathCore (GenVector),

mathematical functions, SMatrix see ftp://root.cern.ch/root/doc/chapter13.pdf

Online Reference documentation for each release with THtml

http://root.cern.ch/root/htmldoc/MATH_Index.html

Doxygen (for MathCore, MathMore, SMatrix and Minuit2) http://www.cern.ch/mathlibs/sw/SMatrix/html/index.html

Separate docs exist for other packages Minuit2, RooFit, TMVA

24

Page 25: New Developments of ROOT Mathematical Software Libraries · PDF fileNew Developments of ROOT Mathematical ... significant improvement observed in their reconstruction code 8. ACAT

ACAT 2007, Amsterdam, April 23-27, 2007 Lorenzo Moneta, CERN/PH-SFT

References MathCore online doc: http://www.cern.ch/mathlibs/sw/MathCore/html/index.html

MathMore online doc: http://www.cern.ch/mathlibs/sw/MathMore/html/index.html

SMatrix online doc: http://www.cern.ch/mathlibs/sw/SMatrix/html/index.html

Minuit2 online doc: http://www.cern.ch/mathlibs/sw/Minuit2/html/index.html

RooFit homepage: http://roofit.sourceforge.net/

TMVA homepage: http://tmva.sourceforge.net/

FFTW homepage: http://www.fftw.org/

Histogram comparison paper: http://arxiv.org/abs/physics/0605123

SPlot paper: http://arxiv.org/abs/physics/0402083

UNURAN homepage: http://statmath.wu-wien.ac.at/unuran/

25