From c6109e85f6a190021aa2a255274c91dcfd65bc9d Mon Sep 17 00:00:00 2001 From: Vanya Belyaev Date: Wed, 22 Nov 2023 10:28:19 +0100 Subject: [PATCH] 1. Reduce usage of `Ostap::Utils::Iterator` --- ReleaseNotes/release_notes.md | 1 + source/include/Ostap/Iterator.h | 8 ++++++- source/src/FormulaVar.cpp | 2 +- source/src/Funcs.cpp | 25 ++++++++------------ source/src/HistoProject.cpp | 32 +++++++------------------ source/src/Iterator.cpp | 2 ++ source/src/MoreRooFit.cpp | 4 ++-- source/src/PDFs.cpp | 1 - source/src/PDFs2D.cpp | 1 - source/src/PDFs3D.cpp | 1 - source/src/PyPdf.cpp | 28 ++++++++++++++-------- source/src/PyVar.cpp | 28 ++++++++++++++-------- source/src/StatVar.cpp | 8 +++++-- source/src/Tmva.cpp | 10 ++++++-- source/src/UStat.cpp | 41 +++++++++++++++++++++++++++++---- source/src/local_roofit.h | 6 ++--- 16 files changed, 122 insertions(+), 76 deletions(-) diff --git a/ReleaseNotes/release_notes.md b/ReleaseNotes/release_notes.md index d18f3e14..8d1d85be 100644 --- a/ReleaseNotes/release_notes.md +++ b/ReleaseNotes/release_notes.md @@ -4,6 +4,7 @@ 1. Slight optimisation in `Ostap::Math::ChebyshedSum` 1. Further optimisation in `Ostap::Math::ChebyshedSum` 1. add new test `ostap/math/tests/test_math.poly.py` + 1. Reduce usage of `Ostap::Utils::Iterator` ## Backward incompatible: diff --git a/source/include/Ostap/Iterator.h b/source/include/Ostap/Iterator.h index e6f0d9dc..5e83eafe 100644 --- a/source/include/Ostap/Iterator.h +++ b/source/include/Ostap/Iterator.h @@ -16,6 +16,10 @@ class TCollection ; // ROOT class RooLinkedList ; // RooFit class RooAbsCollection ; // RooFit // ============================================================================ +// ROOT +// ============================================================================ +#include "RVersion.h" +// ============================================================================ namespace Ostap { // ========================================================================== @@ -32,8 +36,10 @@ namespace Ostap { public: // ====================================================================== +#if ROOT_VERSION_CODE < ROOT_VERSION(6,31,0) /// standard constructor: create and keep the ietrator - Iterator ( const RooAbsCollection& collection ) ; + Iterator ( const RooAbsCollection& collection ) ; // only for ROOT < 6.31 +#endif /// standard constructor: create and keep the ietrator Iterator ( const TCollection& collection ) ; /// standard constructor: create and keep the ietrator diff --git a/source/src/FormulaVar.cpp b/source/src/FormulaVar.cpp index e0720b68..ca37768f 100644 --- a/source/src/FormulaVar.cpp +++ b/source/src/FormulaVar.cpp @@ -65,7 +65,7 @@ namespace // #if ROOT_VERSION_CODE < ROOT_VERSION(6,18,0) // - Ostap::Utils::Iterator tmp ( variables ) ; + Ostap::Utils::Iterator tmp ( variables ) ; // only for ROOT < 6.18 RooAbsArg* c = 0 ; while ( c = (RooAbsArg*) tmp.next() ) { if ( c && actual.contains ( *c ) ) { used.add ( *c ) ; } } diff --git a/source/src/Funcs.cpp b/source/src/Funcs.cpp index c8b8a633..56c5abc7 100644 --- a/source/src/Funcs.cpp +++ b/source/src/Funcs.cpp @@ -5,7 +5,6 @@ // ============================================================================ #include "Ostap/Funcs.h" #include "Ostap/Formula.h" -#include "Ostap/Iterator.h" #include "Ostap/StatusCode.h" #include "Ostap/HFuncs.h" #include "Ostap/FormulaVar.h" @@ -22,6 +21,7 @@ // ============================================================================ #include "Exception.h" #include "local_utils.h" +#include "local_roofit.h" // ============================================================================ /** @file * Implementation file for classes from namespace Ostap::Functions @@ -190,9 +190,10 @@ bool Ostap::Functions::FuncRooFormula::make_formula () const { throw Ostap::Exception ( "Invalid RooArgSet", "Ostap::Function::FuncRooFormula" , Ostap::StatusCode(705) ) ; } + // RooArgList varlst ; - Ostap::Utils::Iterator iter ( *varset ) ; - while ( RooAbsArg* a = iter.static_next() ) { varlst.add ( *a ) ; } + // + ::copy ( *varset , varlst ) ; // m_formula = std::make_unique ( m_name , m_expression , varlst , false ) ; // @@ -759,8 +760,7 @@ bool Ostap::Functions::FuncRoo1D::make_xvar () const Ostap::StatusCode(705) ) ; } // RooArgList varlst ; - Ostap::Utils::Iterator iter ( *varset ) ; - while ( RooAbsArg* a = iter.static_next() ) { varlst.add ( *a ) ; } + ::copy ( *varset , varlst ) ; // m_xvar = std::make_unique ( m_xvar_exp , varlst , false ) ; // @@ -826,8 +826,7 @@ bool Ostap::Functions::FuncRoo2D::make_xvar () const Ostap::StatusCode(705) ) ; } // RooArgList varlst ; - Ostap::Utils::Iterator iter ( *varset ) ; - while ( RooAbsArg* a = iter.static_next() ) { varlst.add ( *a ) ; } + ::copy ( *varset , varlst ) ; // m_xvar = std::make_unique ( m_xvar_exp , varlst , false ) ; // @@ -849,8 +848,7 @@ bool Ostap::Functions::FuncRoo2D::make_yvar () const Ostap::StatusCode(705) ) ; } // RooArgList varlst ; - Ostap::Utils::Iterator iter ( *varset ) ; - while ( RooAbsArg* a = iter.static_next() ) { varlst.add ( *a ) ; } + ::copy ( *varset , varlst ) ; // m_yvar = std::make_unique ( m_yvar_exp , varlst , false ) ; // @@ -926,8 +924,7 @@ bool Ostap::Functions::FuncRoo3D::make_xvar () const Ostap::StatusCode(705) ) ; } // RooArgList varlst ; - Ostap::Utils::Iterator iter ( *varset ) ; - while ( RooAbsArg* a = iter.static_next() ) { varlst.add ( *a ) ; } + ::copy ( *varset , varlst ) ; // m_xvar = std::make_unique ( m_xvar_exp , varlst , false ) ; // @@ -949,8 +946,7 @@ bool Ostap::Functions::FuncRoo3D::make_yvar () const Ostap::StatusCode(705) ) ; } // RooArgList varlst ; - Ostap::Utils::Iterator iter ( *varset ) ; - while ( RooAbsArg* a = iter.static_next() ) { varlst.add ( *a ) ; } + ::copy ( *varset , varlst ) ; // m_yvar = std::make_unique ( m_yvar_exp , varlst , false ) ; // @@ -972,8 +968,7 @@ bool Ostap::Functions::FuncRoo3D::make_zvar () const Ostap::StatusCode(705) ) ; } // RooArgList varlst ; - Ostap::Utils::Iterator iter ( *varset ) ; - while ( RooAbsArg* a = iter.static_next() ) { varlst.add ( *a ) ; } + ::copy ( *varset , varlst ) ; // m_zvar = std::make_unique ( m_zvar_exp , varlst , false ) ; // diff --git a/source/src/HistoProject.cpp b/source/src/HistoProject.cpp index b2ca1962..8ae04d39 100644 --- a/source/src/HistoProject.cpp +++ b/source/src/HistoProject.cpp @@ -19,7 +19,6 @@ #include "Ostap/Formula.h" #include "Ostap/FormulaVar.h" #include "Ostap/HistoProject.h" -#include "Ostap/Iterator.h" #include "Ostap/ProgressBar.h" #include "Ostap/Notifier.h" #include "Ostap/Exception.h" @@ -34,6 +33,7 @@ #include "Exception.h" #include "local_math.h" #include "local_utils.h" +#include "local_roofit.h" // ============================================================================ /** @file * Implementation file for class Ostap::HistoProject @@ -136,9 +136,7 @@ namespace RooArgList alst ; const RooArgSet* aset = data->get() ; if ( 0 == aset ) { return 0 ; } // RETURN - Ostap::Utils::Iterator iter ( *aset ); - RooAbsArg* coef = 0 ; - while ( ( coef = (RooAbsArg*) iter.next() ) ){ alst.add ( *coef ); } + ::copy ( *aset , alst ) ; // // convert expressions into FormulaVar const bool with_cuts = !selection.empty() ; @@ -253,9 +251,7 @@ namespace RooArgList alst ; const RooArgSet* aset = data->get() ; if ( 0 == aset ) { return 0 ; } // RETURN - Ostap::Utils::Iterator iter ( *aset ); - RooAbsArg* coef = 0 ; - while ( ( coef = (RooAbsArg*) iter.next() ) ){ alst.add ( *coef ); } + ::copy ( *aset , alst ) ; // // convert expressions into FormulaVar const bool with_cuts = !selection.empty() ; @@ -392,9 +388,7 @@ namespace RooArgList alst ; const RooArgSet* aset = data->get() ; if ( 0 == aset ) { return 0 ; } // RETURN - Ostap::Utils::Iterator iter ( *aset ); - RooAbsArg* coef = 0 ; - while ( ( coef = (RooAbsArg*) iter.next() ) ){ alst.add ( *coef ); } + ::copy ( *aset , alst ); // // convert expressions into FormulaVar const bool with_cuts = !selection.empty() ; @@ -552,9 +546,7 @@ namespace RooArgList alst ; const RooArgSet* aset = data->get() ; if ( 0 == aset ) { return 0 ; } // RETURN - Ostap::Utils::Iterator iter ( *aset ); - RooAbsArg* coef = 0 ; - while ( ( coef = (RooAbsArg*) iter.next() ) ){ alst.add ( *coef ); } + ::copy ( *aset , alst ) ; // // convert expressions into FormulaVar const bool with_cuts = !selection.empty() ; @@ -2435,9 +2427,7 @@ Ostap::HistoProject::project RooArgList alst ; const RooArgSet* aset = data->get() ; if ( 0 == aset ) { return 0 ; } // RETURN - Ostap::Utils::Iterator iter ( *aset ); - RooAbsArg* coef = 0 ; - while ( ( coef = (RooAbsArg*) iter.next() ) ){ alst.add ( *coef ); } + ::copy ( *aset , alst ) ; // // convert expressions into FormulaVar const bool with_cuts = !selection.empty() ; @@ -2528,10 +2518,7 @@ Ostap::HistoProject::project2 RooArgList alst ; const RooArgSet* aset = data->get() ; if ( 0 == aset ) { return 0 ; } // RETURN - // - Ostap::Utils::Iterator iter ( *aset ); - RooAbsArg* coef = 0 ; - while ( ( coef = (RooAbsArg*) iter.next() ) ){ alst.add ( *coef ); } + ::copy ( *aset , alst ) ; // // convert expressions into FormulaVar const bool with_cuts = !selection.empty() ; @@ -2636,10 +2623,7 @@ Ostap::HistoProject::project3 RooArgList alst ; const RooArgSet* aset = data->get() ; if ( 0 == aset ) { return 0 ; } // RETURN - // - Ostap::Utils::Iterator iter ( *aset ); - RooAbsArg* coef = 0 ; - while ( ( coef = (RooAbsArg*) iter.next() ) ){ alst.add ( *coef ); } + ::copy ( *aset , alst ) ; // // convert expressions into FormulaVar const bool with_cuts = !selection.empty() ; diff --git a/source/src/Iterator.cpp b/source/src/Iterator.cpp index b9e6966d..e9a69b2c 100644 --- a/source/src/Iterator.cpp +++ b/source/src/Iterator.cpp @@ -14,9 +14,11 @@ // ============================================================================ // standard constructor: create and keep the ietrator // ============================================================================ +#if ROOT_VERSION_CODE < ROOT_VERSION(6,31,0) Ostap::Utils::Iterator::Iterator ( const RooAbsCollection& collection ) : m_iterator ( collection.createIterator() ) {} +#endif // ============================================================================ // standard constructor: create and keep the ietrator // ============================================================================ diff --git a/source/src/MoreRooFit.cpp b/source/src/MoreRooFit.cpp index 5f848ff7..29bb0a46 100644 --- a/source/src/MoreRooFit.cpp +++ b/source/src/MoreRooFit.cpp @@ -1408,7 +1408,7 @@ Double_t Ostap::MoreRooFit::Minimal::evaluate () const // ========================================================================== #if ROOT_VERSION_CODE < ROOT_VERSION(6,18,0) // - Ostap::Utils::Iterator tmp ( this->m_vars ) ; + Ostap::Utils::Iterator tmp ( this->m_vars ) ; // only for ROOT < 6.18 RooAbsArg* c = 0 ; while ( c = (RooAbsArg*) tmp.next() ) { @@ -1538,7 +1538,7 @@ Double_t Ostap::MoreRooFit::Maximal::evaluate () const // ========================================================================== #if ROOT_VERSION_CODE < ROOT_VERSION(6,18,0) // - Ostap::Utils::Iterator tmp ( this->m_vars ) ; + Ostap::Utils::Iterator tmp ( this->m_vars ) ; // only for ROOT < 6.18 RooAbsArg* c = 0 ; while ( c = (RooAbsArg*) tmp.next() ) { diff --git a/source/src/PDFs.cpp b/source/src/PDFs.cpp index c0d553d2..d73c2ea2 100644 --- a/source/src/PDFs.cpp +++ b/source/src/PDFs.cpp @@ -7,7 +7,6 @@ // ============================================================================ // Local // ============================================================================ -#include "Ostap/Iterator.h" #include "Ostap/Integrator.h" #include "Ostap/HistoHash.h" #include "Ostap/PDFs.h" diff --git a/source/src/PDFs2D.cpp b/source/src/PDFs2D.cpp index c7b3940f..87fa9242 100644 --- a/source/src/PDFs2D.cpp +++ b/source/src/PDFs2D.cpp @@ -9,7 +9,6 @@ // ============================================================================ #include "Ostap/StatusCode.h" #include "Ostap/PDFs2D.h" -#include "Ostap/Iterator.h" // ============================================================================ // ROOT // ============================================================================ diff --git a/source/src/PDFs3D.cpp b/source/src/PDFs3D.cpp index aa41021d..29c8e969 100644 --- a/source/src/PDFs3D.cpp +++ b/source/src/PDFs3D.cpp @@ -9,7 +9,6 @@ // ============================================================================ #include "Ostap/StatusCode.h" #include "Ostap/PDFs3D.h" -#include "Ostap/Iterator.h" // ============================================================================ // ROOT // ============================================================================ diff --git a/source/src/PyPdf.cpp b/source/src/PyPdf.cpp index dacdb1d1..6920a77d 100644 --- a/source/src/PyPdf.cpp +++ b/source/src/PyPdf.cpp @@ -18,11 +18,11 @@ // ============================================================================ #include "Ostap/PyPdf.h" #include "Ostap/PyVar.h" -#include "Ostap/Iterator.h" // ============================================================================ // Local // ============================================================================ #include "CallPython.h" +#include "local_roofit.h" // ============================================================================ /** @file * Implementation file for class Ostap::Models::PyPdf @@ -66,8 +66,7 @@ Ostap::Models::PyPdf::PyPdf "PyPdf::consructor" , Ostap::StatusCode(400) ) ; // - Ostap::Utils::Iterator it ( variables ) ; - while ( RooAbsReal* v = it.static_next() ) { m_varlist.add ( *v ) ; } + ::copy_real ( variables , m_variables , "Variable is not RooAbsReal" , "Ostap::Functions::PyPdf::PyPdf" ); // Py_XINCREF ( m_self ) ; } @@ -88,8 +87,7 @@ Ostap::Models::PyPdf::PyPdf , m_varlist ( "!varlist" , "All variables(list)" , this ) { // - Ostap::Utils::Iterator it ( variables ) ; - while ( RooAbsReal* v = it.static_next() ) { m_varlist.add ( *v ) ; } + ::copy_real ( variables , m_varlist , "Variable is not RooAbsReal" , "Ostap::Functions::PyPdf::PyPdf" ); // } // ============================================================================ @@ -522,8 +520,7 @@ Ostap::Models::PyPdf2::PyPdf2 "PyPdf2::consructor" , Ostap::StatusCode(400) ) ; // - Ostap::Utils::Iterator it ( variables ) ; - while ( RooAbsReal* v = it.static_next() ) { m_varlist.add ( *v ) ; } + ::copy_real ( variables , m_varlist , "Variable is not RooAbsReal" , "Ostap::Functions::PyPdf2::PyPdf2" ); // if ( m_function ) { Py_XINCREF ( m_function ) ; } m_arguments = PyTuple_New ( m_varlist.getSize() ) ; @@ -574,11 +571,24 @@ Double_t Ostap::Models::PyPdf2::evaluate() const "PyPdf2::evaluate" , Ostap::StatusCode(500) ) ; // - Ostap::Utils::Iterator it ( m_varlist ) ; unsigned short index = 0 ; + // +#if ROOT_VERSION_CODE < ROOT_VERSION(6,18,0) + // + Ostap::Utils::Iterator it ( m_varlist ) ; // onlyu for ROOT < 6.18 while ( RooAbsReal* v = it.static_next() ) { - PyObject* pv = PyFloat_FromDouble ( v->getVal() ) ; + // +#else + // + for ( auto* vv : m_varlist ) + { + RooAbsReal* v = static_cast( vv ) ; + // +#endif + // + const double value = v->getVal() ; + PyObject* pv = PyFloat_FromDouble ( value ) ; if ( 0 != PyTuple_SetItem ( m_arguments , index , pv ) ) { PyErr_Print () ; diff --git a/source/src/PyVar.cpp b/source/src/PyVar.cpp index bccf3883..5a5b6080 100644 --- a/source/src/PyVar.cpp +++ b/source/src/PyVar.cpp @@ -17,12 +17,12 @@ // Ostap // ============================================================================ #include "Ostap/PyVar.h" -#include "Ostap/Iterator.h" // ============================================================================ // Local // ============================================================================ #include "CallPython.h" #include "Exception.h" +#include "local_roofit.h" // ============================================================================ /** @file * Implementation file for classes Ostap::Functions::PyVar @@ -56,8 +56,7 @@ Ostap::Functions::PyVar::PyVar , m_variables ( "variables", "The actual variables/parameters" , this ) { // - Ostap::Utils::Iterator it ( variables ) ; - while ( RooAbsReal* v = it.static_next() ) { m_variables.add ( *v ) ; } + ::copy_real ( variables , m_variables , "Variable is not RooAbsReal" , "Ostap::Functions::PyVar::PyVar" ); // Py_XINCREF ( m_self ) ; } @@ -72,8 +71,7 @@ Ostap::Functions::PyVar::PyVar , m_variables ( "variables", "The actual variables/parameters" , this ) { // - Ostap::Utils::Iterator it ( variables ) ; - while ( RooAbsReal* v = it.static_next() ) { m_variables.add ( *v ) ; } + ::copy_real ( variables , m_variables , "Variable is not RooAbsReal" , "Ostap::Functions::PyVar::PyVar" ); // } // ============================================================================ @@ -306,8 +304,7 @@ Ostap::Functions::PyVar2::PyVar2 , m_variables ( "variables", "The actual variables/parameters" , this ) { // - Ostap::Utils::Iterator it ( variables ) ; - while ( RooAbsReal* v = it.static_next() ) { m_variables.add ( *v ) ; } + ::copy_real ( variables , m_variables , "Variable is not RooAbsReal" , "Ostap::Functions::PyVar2::PyVar2" ); // Py_XINCREF ( m_function ) ; m_arguments = PyTuple_New ( m_variables.getSize() ) ; @@ -357,11 +354,24 @@ Double_t Ostap::Functions::PyVar2::evaluate() const "PyVar2::evaluate" , Ostap::StatusCode(500) ) ; // - Ostap::Utils::Iterator it ( m_variables ) ; unsigned short index = 0 ; + // +#if ROOT_VERSION_CODE < ROOT_VERSION(6,18,0) + // + Ostap::Utils::Iterator it ( m_variables ) ; // only for ROOT < 6.18 while ( RooAbsReal* v = it.static_next() ) { - PyObject* pv = PyFloat_FromDouble ( v->getVal() ) ; + // +#else + // + for ( auto* vv : m_variables ) + { + RooAbsReal* v = static_cast( vv ) ; + // +#endif + // + const double value = v->getVal() ; + PyObject* pv = PyFloat_FromDouble ( value ) ; if ( 0 != PyTuple_SetItem ( m_arguments , index , pv ) ) { PyErr_Print () ; diff --git a/source/src/StatVar.cpp b/source/src/StatVar.cpp index 0edbee94..52118760 100644 --- a/source/src/StatVar.cpp +++ b/source/src/StatVar.cpp @@ -67,7 +67,6 @@ namespace { if ( allow_empty && expression.empty() ) { return nullptr ; } // RETURN! // - RooArgList alst ; const RooArgSet* aset = data.get() ; // if ( allow_null && nullptr == aset ) { return nullptr ; } @@ -76,10 +75,15 @@ namespace "Invalid varset" , "Ostap::StatVar::make_formula" ) ; // - Ostap::Utils::Iterator iter ( *aset ); +#if ROOT_VERSION_CODE < ROOT_VERSION(6,18,0) + RooArgList alst ; + Ostap::Utils::Iterator iter ( *aset ); // ONLY FOR ROOT < 6.18 // RooAbsArg* coef = 0 ; while ( ( coef = (RooAbsArg*) iter.next() ) ) { alst.add ( *coef ); } +#else + RooArgList alst { *aset } ; +#endif // auto result = std::make_unique ( expression , alst , false ) ; // diff --git a/source/src/Tmva.cpp b/source/src/Tmva.cpp index 56aa693a..071814ea 100644 --- a/source/src/Tmva.cpp +++ b/source/src/Tmva.cpp @@ -75,12 +75,18 @@ namespace Ostap::StatusCode build ( const std::string& options = "" ) { // - RooArgList varlst ; const RooArgSet* varset = m_data->get() ; if ( nullptr == varset ) { return Ostap::TMVA::InvalidDataSet ; } - Ostap::Utils::Iterator iter ( *varset ); + // +#if ROOT_VERSION_CODE < ROOT_VERSION(6,18,0) + // + RooArgList varlst ; + Ostap::Utils::Iterator iter ( *varset ); // only for ROOT < 6.18 // RooAbsArg* coef = 0 ; while ( RooAbsArg* coef = iter.static_next() ) { varlst.add ( *coef ); } +#else + RooArgList varlst { *varset } ; +#endif // // 1) create variables for ( const auto& i : m_inputs ) diff --git a/source/src/UStat.cpp b/source/src/UStat.cpp index 5ba67257..5444a276 100644 --- a/source/src/UStat.cpp +++ b/source/src/UStat.cpp @@ -40,15 +40,18 @@ namespace { // ========================================================================== - double getDistance ( const RooArgSet* x , - const RooArgSet* y ) + double getDistance + ( const RooArgSet* x , + const RooArgSet* y ) { if ( 0 == x || 0 == y ) { return -1 ; } // RETURN // double result = 0.; // - Ostap::Utils::Iterator xIter ( *x ) ; - Ostap::Utils::Iterator yIter ( *y ) ; +#if ROOT_VERSION_CODE < ROOT_VERSION(6,18,0) + // + Ostap::Utils::Iterator xIter ( *x ) ; // only for ROOT < 6.18 + Ostap::Utils::Iterator yIter ( *y ) ; // only for ROOT < 6.18 // RooRealVar* xVar = 0 ; RooRealVar* yVar = 0 ; @@ -58,6 +61,21 @@ namespace const double val = xVar->getVal() - yVar->getVal() ; result += val*val ; } +#else + // + RooArgSet::const_iterator xIter = x -> begin () ; + RooArgSet::const_iterator yIter = y -> begin () ; + RooArgSet::const_iterator xEnd = x -> end () ; + RooArgSet::const_iterator yEnd = y -> begin () ; + for ( ; xIter != xEnd && yIter != yEnd ; ++xIter, ++yIter ) + { + const RooRealVar* xVar = static_cast ( *xIter ) ; + const RooRealVar* yVar = static_cast ( *yIter ) ; + const double val = xVar->getVal() - yVar->getVal() ; + result += val*val ; + } + // +#endif // return std::sqrt ( result ) ; } @@ -120,11 +138,24 @@ Ostap::StatusCode Ostap::UStat::calculate { return Ostap::StatusCode ( InvalidItem2 ) ; } // RETURN // // 2.Evaluate PDF - Ostap::Utils::Iterator iter ( *args ) ; + // +#if ROOT_VERSION_CODE < ROOT_VERSION(6,18,0) + // + Ostap::Utils::Iterator iter ( *args ) ; // only for ROOT < 6.18 RooRealVar * var = 0 ; while ( (var = (RooRealVar*)iter->Next() ) ) { var->setVal( event_i->getRealValue( var->GetName() ) ); } // +#else + // + for ( auto* vv : *args ) + { + RooRealVar* var = static_cast ( vv ) ; + var -> setVal ( event_i -> getRealValue ( var -> GetName () ) ) ; + } + // +#endif + // const double pdfValue = pdf . getVal( args ) ; // double min_distance = 1.e+100 ; diff --git a/source/src/local_roofit.h b/source/src/local_roofit.h index c8ce3135..82087537 100644 --- a/source/src/local_roofit.h +++ b/source/src/local_roofit.h @@ -51,7 +51,7 @@ namespace // #if ROOT_VERSION_CODE < ROOT_VERSION(6,18,0) // - Ostap::Utils::Iterator tmp ( from ) ; + Ostap::Utils::Iterator tmp ( from ) ; // only for ROOT < 6.18 RooAbsArg* c = 0 ; while ( c = (RooAbsArg*) tmp.next() ) { to.add ( *c ) ; } // @@ -76,7 +76,7 @@ namespace // #if ROOT_VERSION_CODE < ROOT_VERSION(6,18,0) // - Ostap::Utils::Iterator tmp ( from ) ; + Ostap::Utils::Iterator tmp ( from ) ; // only for ROOT < 6.18 RooAbsArg* c = 0 ; while ( c = (RooAbsArg*) tmp.next() ) { @@ -124,7 +124,7 @@ namespace // #if ROOT_VERSION_CODE < ROOT_VERSION(6,18,0) // - Ostap::Utils::Iterator it ( lst ) ; + Ostap::Utils::Iterator it ( lst ) ; // only for ROOT < 6.18 RooAbsArg* p = 0 ; unsigned int k = 0 ; while ( ( p = (RooAbsArg*) it.next() ) )