SLIDE 1 David’s W ork at CERN ( so far…)
- 1. TF1 methods delegation
- 2. TMath reimplementation
- 3. Hierarchy Restructure
- 4. Documentation and Testing
- 5. Genetic Minimizer
- 6. Future Work
New Math Developm ents
SLIDE 2 TF1 * f a1 = new TF1( " f a1" , " si n( x) / x" , 0, 10) ;
TF1 : 1 -Dim function class Some TF1 methods re‐implemented:
- GetX()
- GetMinimum() & GetMinimumX()
- GetMaximum() & GetMaximumX()
- Integral(), IntegralFast() & IntegralMultiple()
- Derivate(), Derivate2() & Derivate3()
- MinimBrent() & MinimStep()
SLIDE 3
TF1 : New Function I m plem entation MinimBrent(),MinimStep() GetX() GetMinimum(), GetMinimumX() GetMaximum(), GetMaximumX() Integral() IntegralFast() IntegralMultiple() Derivate(),Derivate2(), Derivate3() BrentRootFinder BrentMinimizer BrentMethods GaussIntegrator GaussLegendreIntegrator AdaptiveIntegratorMultiDim RichardsonDerivator now uses now uses now uses now uses now uses now uses now uses TF1 Method New Class
SLIDE 4 Doubl e_t TF1: : Der i vat i ve( Doubl e_t x, Doubl e_t * par am s, Doubl e_t eps) const { RO O T: : M at h: : W r appedTF1 wf 1( * ( const _cast <TF1 * > ( t hi s) ) ) ; i f ( par am s ) wf 1. Set Par am et er s( par am s ) ; RO O T: : M at h: : Ri char dsonDer i vat or Ri char dsonDer i vat or r d; doubl e xm i n, xm ax; G et Range( xm i n, xm ax) ; r d. Set Funct i on( wf 1, xm i n, xm ax) ; r d. Set Rel Tol er ance( eps) ; r et ur n r d. Der i vat i ve1( x) ; }
Exam ple of New I m plem entation Wrap the function Choose the method Set the parameters Calculate the derivative Inconvenient:
- There is a small time penalty with this new method.
Advantages:
- Can easily change the method used in the calculation.
- Easy to implement new methods.
Derivate from the new Interfaces.
SLIDE 5 doubl e f 2( const doubl e * x) { r et ur n x[ 0] + x[ 1] ; } 3 RO O T: : M at h: : W r appedM ul t i Funct i on<> wf ( f 2, 2) ; doubl e a[ 2] = { 0, 0} ; doubl e b[ 2] = { 1, 1} ; RO O T: : M at h: : I nt egr at or M ul t i Di m i g( RO O T: : M at h: : I nt egr at i onM ul t i Di m : : ADAPTI VE) ; i g. Set Funct i on( wf ) ; doubl e val = i g. I nt egr al ( a, b) ; st d: : cout << " i nt egr al r esul t i s " << val << st d: : endl ; RO O T: : M at h: : I nt egr at or M ul t i Di m i g2( RO O T: : M at h: : I nt egr at i onM ul t i Di m : : VEG AS) ; i g2. Set Funct i on( wf ) ; val = i g2. I nt egr al ( a, b) ; st d: : cout << " i nt egr al r esul t i s " << val << st d: : endl ;
Using the Plug-in Manager to get a VirtualI ntegrator Function wrapped AdaptiveIntegratorMultiDim Vegas Multidimensional Integrator
Code example with the plug-in manager
SLIDE 6 TMath Nam espace Lots of code duplication.
- Standard C/C++ Library
- In ROOT::Math namespace (both MathCore and MathMore)
Old interfaces. Look for best performance and maintainability Tests for:
- Backward compatibility
- Stress and Performance
- Compiler and OS compatibility
SLIDE 7
Perform ance Tim es TMath method STD method GSL method
SLIDE 8
Reim plem ented Methods Templates Iterators STD Loc{Min,Max} X X X {Min,Max}Element X X Mean X X GeomMean X X RMS X X Median X X KOrdStat X BinarySearch X X X Sort X X X Norm X NormCross X Cross X IsInside X Normal2Plane X
SLIDE 9
Exam ple of New Tem plate Method
t em pl at e <t ypenam e T> Long64_t LocM i n( Long64_t n, const T * a) ; t em pl at e <t ypenam e I t er at or > I t er at or LocM i n( I t er at or f i r st , I t er at or l ast ) ; Long64_t LocM i n( Long64_t n, const Shor t _t * a) ; Long64_t LocM i n( Long64_t n, const I nt _t * a) ; Long64_t LocM i n( Long64_t n, const Fl oat _t * a) ; Long64_t LocM i n( Long64_t n, const Doubl e_t * a) ; Long64_t LocM i n( Long64_t n, const Long_t * a) ; Long64_t LocM i n( Long64_t n, const Long64_t * a) ;
SLIDE 10
Tim e Perform ances for Real Time/Call (micro seconds) Mac OSX MathDev Branch ROOT 5.18 Loc{Min,Max} 317.703 84.9406 Sort 10589.1 22712.4 BinarySearch 0.0665884 0.0788558 Total Test Time 4.4 7.34 Time/Call (micro seconds) LXPlus (64 Bits) MathDev Branch ROOT 5.18 Loc{Min,Max} 398.70 129.113 Sort 12121.8 25815.9 BinarySearch 0.1 0.098 Total Test Time 7.56 7.85
SLIDE 11
Tim e Perform ances for Real 2 Time/Call (micro seconds) Linux (32 bits) MathDev Branch ROOT 5.18 Loc{Min,Max} 412.82 623.95 Sort 33780.3 70364.7 BinarySearch 0.21 0.49 Total Test Time 11.35 17.88 LocMin and LocMax were not finally replaced. As well as TMath::Permute. Also TMath::BinarySearch returned inconsistent results with repeated elements.
SLIDE 12 Special Functions TMath::Erf TMath::Erfc TMath::Gamma(x) TMath::LnGamma TMath::Beta TMath::BetaIncomplete TMath::Gamma(a,b) ROOT::Math::erf ROOT::Math::erfc ROOT::Math::tgamma(x) ROOT::Math::lgamma ROOT::Math::beta ROOT::Math::inc_beta ROOT::Math::inc_gamma(a,b)
- ROOT::Math proved to implement better the functionality
- These changes produced secondary effects (like the TMath::Prob function!)
SLIDE 13 Hierarchy Restructure Hierarchy restructure:
- Integrate TMath into the MathCore library
- Integration of Complex and random numbers into MathCore.
- Mayor ROOT libraries depend now on MathCore (i.e. Hist).
- MathCore is now a ‘must be built’ library.
- Separate GenVector from MathCore.
- Added classes for basic numerical algorithms.
- Added interfaces for using the plug‐in manager.
- Current size in the order of 1.5 ‐ 2 MB.
SLIDE 14 Docum entation and Testing Documentation:
- For all the new methods and classes.
- Compatible with Doxygen and the ROOT documentation system.
- TMath new user’s guide:
- Expanded with the new interfaces.
- Linked with tutorials in ROOTSYS.
Script to test any test directory plus roottest:
- Make the tests to behave uniformly:
- Return a value indicating whether the test worked fine
- Compare to a template output.
- Make the tests available to run in batch mode:
- Force the test to be in compile mode
- Make the test work with the option of showing no graphics
SLIDE 15 Genetic Minim izer Implement a GeneticMinimizer:
- Derivates from ROOT::Math::Miminizer.
- Uses the algorithms from TMVA.
- Creation of a new package.
G enet i c M i ni m i zer ( bet ween 0- 10) M i ni m um Xs f ound ( 6. 84698, 2. 25318) M i nui t 2 wi t h i ni t i al val ues ( 0, 0) M i ni m um Xs f ound ( 2. 00421 , 3. 83938) M i nui t 2 wi t h i ni t i al val ues( 6. 84698 2. 25318) M i ni m um Xs f ound ( 6. 97915 , 1. 997)
Example of Use
SLIDE 16 Future W ork Design proposals for TF1 and THX:
- Correct the use of const methods from TF1.
- Code improvement in THX: Encapsulate code (projection, drawer...)
Create an User’s guide for the new classes added in MathCore. http://cern.ch/dmgonzal
. . . case 5: / / " yx“ i f ( i zbi n < i zm i n | | i zbi n > i zm ax) cont i nue; i f ( cont ) p2- >Fi l l ( f Xaxi s. G et Bi nCent er ( i xbi n) , f Yaxi s. G et Bi nCent er ( i ybi n) , f Zaxi s. G et Bi nCent er ( i zbi n) , cont ) ; br eak; case 6: / / " xz" i f ( i ybi n < i ym i n | | i ybi n > i ym ax) cont i nue; i f ( cont ) p2- >Fi l l ( f Zaxi s. G et Bi nCent er ( i zbi n) , f Xaxi s. G et Bi nCent er ( i xbi n) , f Yaxi s. G et Bi nCent er ( i zbi n) , cont ) ; br eak; case 7: / / " zx” i f ( i ybi n < i ym i n | | i ybi n > i ym ax) cont i nue; i f ( cont ) p2- >Fi l l ( f Xaxi s. G et Bi nCent er ( i xbi n) , f Zaxi s. G et Bi nCent er ( i zbi n) , f Yaxi s. G et Bi nCent er ( i zbi n) , cont ) ; br eak; . . .