diff --git a/CMakeLists.txt b/CMakeLists.txt index bedd4f5ca696e..f09f0c84bb199 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,14 +29,12 @@ foreach(policy ${policy_new}) endif() endforeach() -# ignore JAVA_ROOT when find_package(Java 1.8 ...) called -if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.27) - cmake_policy(SET CMP0144 OLD) -endif() - -if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) - cmake_policy(SET CMP0135 OLD) -endif() +set(policy_old CMP0116 CMP0135 CMP0144) +foreach(policy ${policy_old}) + if(POLICY ${policy}) + cmake_policy(SET ${policy} OLD) + endif() +endforeach() include(cmake/modules/CaptureCommandLine.cmake) diff --git a/README/ReleaseNotes/v632/index.md b/README/ReleaseNotes/v632/index.md index 1bb16bc30bfe1..280ff4302796a 100644 --- a/README/ReleaseNotes/v632/index.md +++ b/README/ReleaseNotes/v632/index.md @@ -164,6 +164,18 @@ They should be replaced with the suitable STL-compatible interfaces, or you can - `RooWorkspace::componentIterator()`: use `RooWorkspace::components()` with range-based loop +### Deprecation of legacy test statistics classes in public interface + +Instantiating the following classes and even including their header files is deprecated, and the headers will be removed in ROOT 6.34: + +* RooAbsTestStatistic +* RooAbsOptTestStatistic +* RooNLLVar +* RooChi2Var +* RooXYChi2Var + +Please use the higher-level functions `RooAbsPdf::createNLL()` and `RooAbsPdf::createChi2()` if you want to create objects that represent test statistics. + ## 2D Graphics Libraries diff --git a/build/unix/makepchinput.py b/build/unix/makepchinput.py index eec73f946da3b..cd5d57d411db3 100755 --- a/build/unix/makepchinput.py +++ b/build/unix/makepchinput.py @@ -457,6 +457,11 @@ def makePCHInput(): allHeadersContent = getSTLIncludes() allHeadersContent += getExtraIncludes(clingetpchList) + # Make sure we don't get warnings from the old RooFit test statistics + # headers that are deprecated. This line can be removed once the deprecaded + # headers are gone (ROOT 6.32.00): + allHeadersContent += "#define ROOFIT_BUILDS_ITSELF\n" + allLinkdefsContent = "" # Loop over the dictionaries, ROOT modules diff --git a/cmake/modules/FindR.cmake b/cmake/modules/FindR.cmake index 3b9bc03f3426f..f63d720c7a352 100644 --- a/cmake/modules/FindR.cmake +++ b/cmake/modules/FindR.cmake @@ -12,15 +12,70 @@ # R_INCLUDE_DIRS - the R include directories # R_LIBRARIES - link these to use R # R_ROOT_DIR - As reported by R +# R_EXECUTABLE - the R executable +# R_SCRIPT - the Rscript executable, which runs R non-interactively +# # Autor: Omar Andres Zapata Mesa 31/05/2013 +# Contributor: Blake Madden 2023-12-10 if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(CMAKE_FIND_APPBUNDLE "LAST") endif() +# Lists subdirectories in a directory +# https://stackoverflow.com/questions/7787823/cmake-how-to-get-the-name-of-all-subdirectories-of-a-directory +macro(SUBDIRLIST result curdir) + FILE(GLOB children RELATIVE ${curdir} ${curdir}/*) + set(dirlist "") + foreach(child ${children}) + if(IS_DIRECTORY ${curdir}/${child}) + list(APPEND dirlist ${child}) + endif() + endforeach() + set(${result} ${dirlist}) +endmacro() + find_program(R_EXECUTABLE NAMES R R.exe) +find_program(R_SCRIPT NAMES Rscript Rscript.exe) + +# If not found and we are on Windows, try to look for it in the default installation path +if(WIN32 AND R_EXECUTABLE MATCHES "R_EXECUTABLE-NOTFOUND") + GET_FILENAME_COMPONENT(RX64PATH "C:\\Program Files\\R" REALPATH) + GET_FILENAME_COMPONENT(RX86PATH "C:\\Program Files (x86)\\R" REALPATH) + # default 64-bit Windows installation + if(EXISTS "${RX64PATH}") + SUBDIRLIST(SUBDIRS "${RX64PATH}") + foreach(subdir ${SUBDIRS}) + if(${subdir} MATCHES "R[-]([0-9][.]).*") + set(R_VERSIONED_SUBDIR "${subdir}") + if(EXISTS "${RX64PATH}\\${R_VERSIONED_SUBDIR}\\bin\\x64\\R.exe") + set(R_EXECUTABLE "${RX64PATH}\\${R_VERSIONED_SUBDIR}\\bin\\x64\\R.exe") + endif() + if(EXISTS "${RX64PATH}\\${R_VERSIONED_SUBDIR}\\bin\\x64\\Rscript.exe") + set(R_SCRIPT "${RX64PATH}\\${R_VERSIONED_SUBDIR}\\bin\\x64\\Rscript.exe") + endif() + break() + endif() + endforeach() + # ...or the 32-bit installation + elseif(EXISTS "${RX86PATH}") + SUBDIRLIST(SUBDIRS "${RX86PATH}") + foreach(subdir ${SUBDIRS}) + if(${subdir} MATCHES "R[-]([0-9][.]).*") + set(R_VERSIONED_SUBDIR "${subdir}") + if(EXISTS "${RX86PATH}\\${R_VERSIONED_SUBDIR}\\bin\\x86\\R.exe") + set(R_EXECUTABLE "${RX86PATH}\\${R_VERSIONED_SUBDIR}\\bin\\x86\\R.exe") + endif() + if(EXISTS "${RX86PATH}\\${R_VERSIONED_SUBDIR}\\bin\\x86\\Rscript.exe") + set(R_SCRIPT "${RX86PATH}\\${R_VERSIONED_SUBDIR}\\bin\\x86\\Rscript.exe") + endif() + break() + endif() + endforeach() + endif() +endif() -#---searching R installtion unsing R executable +#---searching R installtion using R executable if(R_EXECUTABLE) execute_process(COMMAND ${R_EXECUTABLE} RHOME OUTPUT_VARIABLE R_ROOT_DIR @@ -35,6 +90,11 @@ if(R_EXECUTABLE) find_library(R_LIBRARY R HINTS ${R_ROOT_DIR}/lib DOC "R library (example libR.a, libR.dylib, etc.).") + # On Windows, this may not be defined. Fall back to the library + # folder that holds the DLLs. + if(R_LIBRARY MATCHES "R_LIBRARY-NOTFOUND" AND EXISTS "${R_ROOT_DIR}\\library") + set(R_LIBRARY "${R_ROOT_DIR}\\library") + endif() endif() #---setting include dirs and libraries diff --git a/core/foundation/inc/TError.h b/core/foundation/inc/TError.h index 0099d8e538704..2948a70e6844e 100644 --- a/core/foundation/inc/TError.h +++ b/core/foundation/inc/TError.h @@ -39,15 +39,14 @@ class TVirtualMutex; -constexpr Int_t kUnset = -1; -constexpr Int_t kPrint = 0; -constexpr Int_t kInfo = 1000; -constexpr Int_t kWarning = 2000; -constexpr Int_t kError = 3000; -constexpr Int_t kBreak = 4000; -constexpr Int_t kSysError = 5000; -constexpr Int_t kFatal = 6000; - +R__EXTERN const Int_t kUnset; +R__EXTERN const Int_t kPrint; +R__EXTERN const Int_t kInfo; +R__EXTERN const Int_t kWarning; +R__EXTERN const Int_t kError; +R__EXTERN const Int_t kBreak; +R__EXTERN const Int_t kSysError; +R__EXTERN const Int_t kFatal; // TROOT sets the error ignore level handler, the system error message handler, and the error abort handler on // construction such that the "Root.ErrorIgnoreLevel" environment variable is used for the ignore level diff --git a/core/foundation/src/RLogger.cxx b/core/foundation/src/RLogger.cxx index de9eb939ab8ec..18ba9f954d959 100644 --- a/core/foundation/src/RLogger.cxx +++ b/core/foundation/src/RLogger.cxx @@ -52,7 +52,7 @@ inline bool RLogHandlerDefault::Emit(const RLogEntry &entry) if (!entry.fLocation.fFuncName.empty()) strm << " in " << entry.fLocation.fFuncName; - static constexpr const int errorLevelOld[] = {kFatal /*unset*/, kFatal, kError, kWarning, kInfo, kInfo /*debug*/}; + static const int errorLevelOld[] = {kFatal /*unset*/, kFatal, kError, kWarning, kInfo, kInfo /*debug*/}; (*::GetErrorHandler())(errorLevelOld[cappedLevel], entry.fLevel == ELogLevel::kFatal, strm.str().c_str(), entry.fMessage.c_str()); return true; diff --git a/core/foundation/src/TError.cxx b/core/foundation/src/TError.cxx index 8f27b76c5d72b..969f11f48a33a 100644 --- a/core/foundation/src/TError.cxx +++ b/core/foundation/src/TError.cxx @@ -28,6 +28,15 @@ to be replaced by the proper DefaultErrorHandler() #include #include +const Int_t kUnset = -1; +const Int_t kPrint = 0; +const Int_t kInfo = 1000; +const Int_t kWarning = 2000; +const Int_t kError = 3000; +const Int_t kBreak = 4000; +const Int_t kSysError = 5000; +const Int_t kFatal = 6000; + Int_t gErrorIgnoreLevel = kUnset; Int_t gErrorAbortLevel = kSysError+1; Bool_t gPrintViaErrorHandler = kFALSE; diff --git a/math/mathmore/inc/Math/Polynomial.h b/math/mathmore/inc/Math/Polynomial.h index ff149e6997de3..238214eb91acd 100644 --- a/math/mathmore/inc/Math/Polynomial.h +++ b/math/mathmore/inc/Math/Polynomial.h @@ -105,26 +105,29 @@ class Polynomial : public ParamFunction, // using ParamFunction::operator(); - /** Find the polynomial roots. For n <= 4, the roots are found analytically while for larger order an iterative numerical method is used - The numerical method used is from GSL (see documentation ) + For the case of n = 4 by default an analytical algorithm is used from an implementation by + Andrew W. Steiner and Andy Buckley which is a translation from the original Cenrlib routine + (< HREF="https://cds.cern.ch/record/2050876/files/c208.html">RRTEQ4 ). + Note that depending on the coefficients the result could be not very accurate if the discriminant of the resolvent cubic + equation is very small. In that case it might be more robust to use the numerical method, by calling directly FindNumRoots() + */ const std::vector > & FindRoots(); - /** Find the only the real polynomial roots. For n <= 4, the roots are found analytically while for larger order an iterative numerical method is used - The numerical method used is from GSL (see documentation ) */ std::vector FindRealRoots(); - /** Find the polynomial roots using always an iterative numerical methods - The numerical method used is from GSL (see documentation ) */ const std::vector > & FindNumRoots(); diff --git a/math/mathmore/src/complex_quartic.h b/math/mathmore/src/complex_quartic.h index a4ef4625222ac..8cfa34a61b359 100644 --- a/math/mathmore/src/complex_quartic.h +++ b/math/mathmore/src/complex_quartic.h @@ -151,9 +151,11 @@ gsl_poly_complex_solve_quartic (double a, double b, double c, double d, disc = R2 - Q3; // more numerical problems with this calculation of disc -// double CR2 = 729 * rcub * rcub; -// double CQ3 = 2916 * qcub * qcub * qcub; -// disc = (CR2 - CQ3) / 2125764.0; +//LM - use this since it fixes case reported in issue #6900 when disc is approx 0 +// (needs to add additional test cases where disc is ~ 0) + double CR2 = 729 * rcub * rcub; + double CQ3 = 2916 * qcub * qcub * qcub; + disc = (CR2 - CQ3) / 2125764.0; if (0 == R && 0 == Q) @@ -162,7 +164,7 @@ gsl_poly_complex_solve_quartic (double a, double b, double c, double d, u[1] = -rc / 3; u[2] = -rc / 3; } - else if (R2 == Q3) + else if (disc == 0) { double sqrtQ = sqrt (Q); if (R > 0) @@ -398,4 +400,3 @@ gsl_poly_complex_solve_quartic (double a, double b, double c, double d, return 4; } - diff --git a/math/mathmore/test/CMakeLists.txt b/math/mathmore/test/CMakeLists.txt index 11b796f131f30..9f575db1b0422 100644 --- a/math/mathmore/test/CMakeLists.txt +++ b/math/mathmore/test/CMakeLists.txt @@ -55,3 +55,4 @@ foreach(file ${TestMathMoreSource}) endforeach() ROOT_ADD_GTEST(stressMathMoreUnit testStress.cxx StatFunction.cxx LIBRARIES Core MathCore MathMore) +ROOT_ADD_GTEST(testPolynomialRoots testPolynomialRoots LIBRARIES Core MathCore MathMore) diff --git a/math/mathmore/test/testPolynomialRoots.cxx b/math/mathmore/test/testPolynomialRoots.cxx new file mode 100644 index 0000000000000..a9ad68e707cfe --- /dev/null +++ b/math/mathmore/test/testPolynomialRoots.cxx @@ -0,0 +1,226 @@ +// test finding Roots of polynomials + +#include "gtest/gtest.h" + +#include "Math/Polynomial.h" +#include +#include + +using namespace ROOT::Math; +using namespace std; + +class QuarticPolynomial : public ::testing::Test { + +protected: + enum EModeType { kAnalytical = 1, kNumerical = 2 }; + vector coeff; + vector> expectedResult; + double a, b, c, d, e = 0; + double tolerance = 0; + bool debug = false; + EModeType algoType; + + void checkResult(vector> &result) + { + // sort first result + auto smallerComplex = [&](complex c1, complex c2) { + double diff = std::abs( c1.real()-c2.real() ); + // in case of numerical roots difference can be small + //if (c1.real() != c2.real()) + if (diff > std::max(tolerance, 4 * std::numeric_limits::epsilon() ) ) + return c1.real() < c2.real(); + else + return c1.imag() < c2.imag(); + }; + std::sort(result.begin(), result.end(), smallerComplex); + + ASSERT_EQ(result.size(), expectedResult.size()); + ASSERT_EQ(result.size(), 4 ); + + // unrolll loop to have test printing component when failed + if (tolerance <= 0) { + // in this case check with 4 ulp + EXPECT_DOUBLE_EQ(result[0].real(), expectedResult[0].real()); + EXPECT_DOUBLE_EQ(result[0].imag(), expectedResult[0].imag()); + + EXPECT_DOUBLE_EQ(result[1].real(), expectedResult[1].real()); + EXPECT_DOUBLE_EQ(result[1].imag(), expectedResult[1].imag()); + + EXPECT_DOUBLE_EQ(result[2].real(), expectedResult[2].real()); + EXPECT_DOUBLE_EQ(result[2].imag(), expectedResult[2].imag()); + + EXPECT_DOUBLE_EQ(result[3].real(), expectedResult[3].real()); + EXPECT_DOUBLE_EQ(result[3].imag(), expectedResult[3].imag()); + } + else { + // check within a given absolute tolerance + EXPECT_NEAR(result[0].real(), expectedResult[0].real(), tolerance); + EXPECT_NEAR(result[0].imag(), expectedResult[0].imag(), tolerance); + + EXPECT_NEAR(result[1].real(), expectedResult[1].real(), tolerance); + EXPECT_NEAR(result[1].imag(), expectedResult[1].imag(), tolerance); + + EXPECT_NEAR(result[2].real(), expectedResult[2].real(), tolerance); + EXPECT_NEAR(result[2].imag(), expectedResult[2].imag(), tolerance); + + EXPECT_NEAR(result[3].real(), expectedResult[3].real(),tolerance); + EXPECT_NEAR(result[3].imag(), expectedResult[3].imag(),tolerance); + } + } + + void print(const vector> &result) + { + std::string algoName = (algoType == kNumerical) ? "Numerical" : "Analytical"; + std::cout << algoName << " solution for " << a << "*x^4 + " << b << "*x^3 + " << c << "*x^2 + " << d << "*x + " << e << " = 0" + << std::endl; + for (unsigned int i = 0; i < result.size(); i++) + { + std::cout << " root " << i << " : " << result[i] << std::endl; + } + } + + void runTest(EModeType type, double tol = 0) + { + a = coeff[0]; + b = coeff[1]; + c = coeff[2]; + d = coeff[3]; + e = coeff[4]; + + tolerance = tol; + algoType = type; + + Polynomial pol(a, b, c, d, e); + + auto result = (type != kNumerical) ? pol.FindRoots() : pol.FindNumRoots(); + + checkResult(result); + + if (debug) + print(result); + } +}; + +// test x^4 - 16 = 0 +TEST_F(QuarticPolynomial, FindRoots_DegPol1) +{ + coeff = {1, 0, 0, 0, -16}; + + expectedResult = {complex(-2, 0), + complex( 0,-2), + complex( 0, 2), + complex( 2, 0)}; + + runTest(kAnalytical); + runTest(kNumerical, 1.E-13); +} + +// test (x+1)^4 = 0 +TEST_F(QuarticPolynomial, FindRoots_DegPol2) +{ + coeff = {1, 4, 6, 4, 1}; + + expectedResult = {complex(-1, 0), + complex(-1, 0), + complex(-1, 0), + complex(-1, 0)}; + + runTest(kAnalytical); + // bad tolerance for this test + debug = true; + // numerical method has a large error for this case + runTest(kNumerical, 1.E-3); +} + +// test x4 + 5x^2 + 4 = 0 +//4 imaginary roots (x-i)(x+i)(x-2i)(x+2i)=0 +TEST_F(QuarticPolynomial, FindRoots_4ImagRoots) +{ + coeff = {1, 0, 5, 0, 4}; + + expectedResult = {complex(0, -2), + complex(0, -1), + complex(0, 1), + complex(0, 2)}; + + //debug = true; + runTest(kAnalytical, 0); + runTest(kNumerical, 1.E-12); +} + +// +// four full complex roots, (x-1-i)(x-1+i)(x-1-2i)(x-1+2i)=0") +TEST_F(QuarticPolynomial, FindRoots_4CompRoots) +{ + coeff = {1.0, -4.0, 11.0, -14.0, 10.0}; + + expectedResult = {complex(1, -2), + complex(1, -1), + complex(1, 1), + complex(1, 2)}; + + runTest(kAnalytical, 0); + runTest(kNumerical, 1.E-12); +} + +// four real roots (x+1)(x+2)(x+3)(x+4)=0 +TEST_F(QuarticPolynomial, FindRoots_4RealRoots) +{ + + coeff = {1.0, 10.0, 35.0, 50.0, 24.0}; + + expectedResult = {complex(-4, 0), + complex(-3, 0), + complex(-2, 0), + complex(-1, 0)}; + + runTest(kAnalytical, 0); + runTest(kNumerical, 1.E-12); +} + +// test x^4-8x^3+12x^2+16x+4=0 +// 4 real roots where 2 are degeenrates + +TEST_F(QuarticPolynomial, FindRoots_4RealDegRoots) +{ + + coeff = {1.0, -8.0, 12.0, 16.0, 4.0}; + + expectedResult = {complex(-0.44948974278317788, 0), + complex(-0.44948974278317788, 0), + complex(4.44948974278317788, 0), // this is 4 - r0 + complex(4.44948974278317788, 0)}; + + runTest(kAnalytical, 0); + debug = true; + runTest(kNumerical, 1.E-7); +} + +// test 5x^4 + 4x^3 + 3x^2 + 2x + 1 + +TEST_F(QuarticPolynomial, FindRoots_54321) +{ + coeff = {5, 4, 3, 2, 1}; + + expectedResult = {complex(-0.5378322749029899, -0.358284686345128), + complex(-0.5378322749029899, +0.358284686345128), + complex(+0.13783227490298988, -0.6781543891053364), + complex(+0.13783227490298988, +0.6781543891053364)}; + + runTest(kAnalytical); + runTest(kNumerical, 1.E-13); +} +// special case reported in issue #6900 by S. Binet +TEST_F(QuarticPolynomial, FindRoots_4RealDegRootsR0) +{ + coeff = {2.2206846808021337, 7.643281053997895, 8.831759446092846, 3.880673545129404, 0.5724551380144077}; + + expectedResult = {complex(-1.3429253, 0.), + complex(-1.3427327, 0 ), + complex(-0.3781962, 0 ), + complex(-0.3780036, 0) }; + + debug = true; + runTest(kAnalytical, 1.E-6); + runTest(kNumerical, 1.E-4); +} diff --git a/roofit/histfactory/src/HistoToWorkspaceFactoryFast.cxx b/roofit/histfactory/src/HistoToWorkspaceFactoryFast.cxx index 2c38227ac3c6f..a33bc20e2d6fa 100644 --- a/roofit/histfactory/src/HistoToWorkspaceFactoryFast.cxx +++ b/roofit/histfactory/src/HistoToWorkspaceFactoryFast.cxx @@ -822,6 +822,7 @@ RooArgList HistoToWorkspaceFactoryFast::createObservables(const TH1 *hist, RooWo constraintTermNames.push_back("lumiConstraint"); } else { proto.var("Lumi")->setConstant(); + proto.defineSet("globalObservables",RooArgSet()); // create empty set as is assumed it exists later } /////////////////////////////////// // loop through estimates, add expectation, floating bin predictions, diff --git a/roofit/roofit/inc/RooGExpModel.h b/roofit/roofit/inc/RooGExpModel.h index 6a0a9dbaf305a..63a975b1e10de 100644 --- a/roofit/roofit/inc/RooGExpModel.h +++ b/roofit/roofit/inc/RooGExpModel.h @@ -25,22 +25,10 @@ class RooGExpModel : public RooResolutionModel { public: - enum RooGExpBasis { noBasis=0, expBasisMinus= 1, expBasisSum= 2, expBasisPlus= 3, - sinBasisMinus=11, sinBasisSum=12, sinBasisPlus=13, - cosBasisMinus=21, cosBasisSum=22, cosBasisPlus=23, - sinhBasisMinus=31,sinhBasisSum=32,sinhBasisPlus=33, - coshBasisMinus=41,coshBasisSum=42,coshBasisPlus=43} ; - - - - enum BasisType { none=0, expBasis=1, sinBasis=2, cosBasis=3, sinhBasis=4, coshBasis=5 } ; - enum BasisSign { Both=0, Plus=+1, Minus=-1 } ; enum Type { Normal, Flipped }; // Constructors, assignment etc - inline RooGExpModel() { - // coverity[UNINIT_CTOR] - } + RooGExpModel() = default; RooGExpModel(const char *name, const char *title, RooAbsRealLValue& x, RooAbsReal& mean, RooAbsReal& sigma, RooAbsReal& rlife, @@ -109,8 +97,8 @@ class RooGExpModel : public RooResolutionModel { bool _flip ; bool _nlo ; - bool _flatSFInt ; - bool _asympInt ; // added FMV,07/24/03 + bool _flatSFInt = false; + bool _asympInt = false; // added FMV,07/24/03 ClassDefOverride(RooGExpModel,2) // Gauss (x) Exponential resolution model }; diff --git a/roofit/roofit/inc/RooGaussModel.h b/roofit/roofit/inc/RooGaussModel.h index a2c12b162b5ba..c6bca22c89e29 100644 --- a/roofit/roofit/inc/RooGaussModel.h +++ b/roofit/roofit/inc/RooGaussModel.h @@ -24,20 +24,8 @@ class RooGaussModel : public RooResolutionModel { public: - - enum RooGaussBasis { noBasis=0, expBasisMinus= 1, expBasisSum= 2, expBasisPlus= 3, - sinBasisMinus=11, sinBasisSum=12, sinBasisPlus=13, - cosBasisMinus=21, cosBasisSum=22, cosBasisPlus=23, - linBasisPlus=33, - quadBasisPlus=43, - coshBasisMinus=51,coshBasisSum=52,coshBasisPlus=53, - sinhBasisMinus=61,sinhBasisSum=62,sinhBasisPlus=63}; - enum BasisType { none=0, expBasis=1, sinBasis=2, cosBasis=3, - linBasis=4, quadBasis=5, coshBasis=6, sinhBasis=7 } ; - enum BasisSign { Both=0, Plus=+1, Minus=-1 } ; - // Constructors, assignment etc - inline RooGaussModel() : _flatSFInt(false), _asympInt(false) { } + RooGaussModel() = default; RooGaussModel(const char *name, const char *title, RooAbsRealLValue& x, RooAbsReal& mean, RooAbsReal& sigma) ; RooGaussModel(const char *name, const char *title, RooAbsRealLValue& x, @@ -60,7 +48,7 @@ class RooGaussModel : public RooResolutionModel { void computeBatch(double* output, size_t size, RooFit::Detail::DataMap const&) const override; - bool canComputeBatchWithCuda() const override { return getBasisType(_basisCode) == expBasis; } + bool canComputeBatchWithCuda() const override; protected: @@ -71,15 +59,9 @@ class RooGaussModel : public RooResolutionModel { std::complex evalCerfInt(double sign, double wt, double tau, double umin, double umax, double c) const; private: + bool _flatSFInt = false; - static BasisType getBasisType(int basisCode) - { - return static_cast(basisCode == 0 ? 0 : (basisCode / 10) + 1); - } - - bool _flatSFInt ; - - bool _asympInt ; // added FMV,07/24/03 + bool _asympInt = false; // added FMV,07/24/03 RooRealProxy mean ; RooRealProxy sigma ; diff --git a/roofit/roofit/src/RooGExpModel.cxx b/roofit/roofit/src/RooGExpModel.cxx index 0fa2546a8d4c5..d7e49027f1ff3 100644 --- a/roofit/roofit/src/RooGExpModel.cxx +++ b/roofit/roofit/src/RooGExpModel.cxx @@ -35,8 +35,33 @@ for analytical convolutions with classes inheriting from RooAbsAnaConvPdf. #include "RooRandom.h" #include "TMath.h" +namespace { + +enum RooGExpBasis { + noBasis = 0, + expBasisMinus = 1, + expBasisSum = 2, + expBasisPlus = 3, + sinBasisMinus = 11, + sinBasisSum = 12, + sinBasisPlus = 13, + cosBasisMinus = 21, + cosBasisSum = 22, + cosBasisPlus = 23, + sinhBasisMinus = 31, + sinhBasisSum = 32, + sinhBasisPlus = 33, + coshBasisMinus = 41, + coshBasisSum = 42, + coshBasisPlus = 43 +}; + +enum BasisType { none = 0, expBasis = 1, sinBasis = 2, cosBasis = 3, sinhBasis = 4, coshBasis = 5 }; + +enum BasisSign { Both = 0, Plus = +1, Minus = -1 }; + +} // namespace -using namespace std; ClassImp(RooGExpModel); @@ -179,22 +204,28 @@ RooGExpModel::RooGExpModel(const RooGExpModel& other, const char* name) : Int_t RooGExpModel::basisCode(const char* name) const { - if (!TString("exp(-@0/@1)").CompareTo(name)) return expBasisPlus ; - if (!TString("exp(@0/@1)").CompareTo(name)) return expBasisMinus ; - if (!TString("exp(-abs(@0)/@1)").CompareTo(name)) return expBasisSum ; - if (!TString("exp(-@0/@1)*sin(@0*@2)").CompareTo(name)) return sinBasisPlus ; - if (!TString("exp(@0/@1)*sin(@0*@2)").CompareTo(name)) return sinBasisMinus ; - if (!TString("exp(-abs(@0)/@1)*sin(@0*@2)").CompareTo(name)) return sinBasisSum ; - if (!TString("exp(-@0/@1)*cos(@0*@2)").CompareTo(name)) return cosBasisPlus ; - if (!TString("exp(@0/@1)*cos(@0*@2)").CompareTo(name)) return cosBasisMinus ; - if (!TString("exp(-abs(@0)/@1)*cos(@0*@2)").CompareTo(name)) return cosBasisSum ; - if (!TString("exp(-@0/@1)*sinh(@0*@2/2)").CompareTo(name)) return sinhBasisPlus; - if (!TString("exp(@0/@1)*sinh(@0*@2/2)").CompareTo(name)) return sinhBasisMinus; - if (!TString("exp(-abs(@0)/@1)*sinh(@0*@2/2)").CompareTo(name)) return sinhBasisSum; - if (!TString("exp(-@0/@1)*cosh(@0*@2/2)").CompareTo(name)) return coshBasisPlus; - if (!TString("exp(@0/@1)*cosh(@0*@2/2)").CompareTo(name)) return coshBasisMinus; - if (!TString("exp(-abs(@0)/@1)*cosh(@0*@2/2)").CompareTo(name)) return coshBasisSum; - return 0 ; + std::string str = name; + + // Remove whitespaces from the input string + str.erase(remove(str.begin(),str.end(),' '),str.end()); + + if (str == "exp(-@0/@1)") return expBasisPlus ; + if (str == "exp(@0/@1)") return expBasisMinus ; + if (str == "exp(-abs(@0)/@1)") return expBasisSum ; + if (str == "exp(-@0/@1)*sin(@0*@2)") return sinBasisPlus ; + if (str == "exp(@0/@1)*sin(@0*@2)") return sinBasisMinus ; + if (str == "exp(-abs(@0)/@1)*sin(@0*@2)") return sinBasisSum ; + if (str == "exp(-@0/@1)*cos(@0*@2)") return cosBasisPlus ; + if (str == "exp(@0/@1)*cos(@0*@2)") return cosBasisMinus ; + if (str == "exp(-abs(@0)/@1)*cos(@0*@2)") return cosBasisSum ; + if (str == "exp(-@0/@1)*sinh(@0*@2/2)") return sinhBasisPlus; + if (str == "exp(@0/@1)*sinh(@0*@2/2)") return sinhBasisMinus; + if (str == "exp(-abs(@0)/@1)*sinh(@0*@2/2)") return sinhBasisSum; + if (str == "exp(-@0/@1)*cosh(@0*@2/2)") return coshBasisPlus; + if (str == "exp(@0/@1)*cosh(@0*@2/2)") return coshBasisMinus; + if (str == "exp(-abs(@0)/@1)*cosh(@0*@2/2)") return coshBasisSum; + + return 0 ; } @@ -297,7 +328,7 @@ double RooGExpModel::evaluate() const // *** 1st form: Straight GExp, used for unconvoluted PDF or expBasis with 0 lifetime *** if (basisType==none || ((basisType==expBasis || basisType==cosBasis) && tau==0.)) { - if (verboseEval()>2) cout << "RooGExpModel::evaluate(" << GetName() << ") 1st form" << endl ; + if (verboseEval()>2) std::cout << "RooGExpModel::evaluate(" << GetName() << ") 1st form" << std::endl ; double expArg = sig*sig/(2*rtau*rtau) + fsign*(x - _mean*_meanSF)/rtau ; @@ -321,13 +352,13 @@ double RooGExpModel::evaluate() const //double result = 0.5*evalCerf(fsign*u,c).real() ; // sign=-1 ! if (_basisCode!=0 && basisSign==Both) result *= 2 ; - //cout << "1st form " << "x= " << x << " result= " << result << endl; + //cout << "1st form " << "x= " << x << " result= " << result << std::endl; return result ; } // *** 2nd form: 0, used for sinBasis and cosBasis with tau=0 *** if (tau==0) { - if (verboseEval()>2) cout << "RooGExpModel::evaluate(" << GetName() << ") 2nd form" << endl ; + if (verboseEval()>2) std::cout << "RooGExpModel::evaluate(" << GetName() << ") 2nd form" << std::endl ; return 0. ; } @@ -335,35 +366,35 @@ double RooGExpModel::evaluate() const // *** 3nd form: Convolution with exp(-t/tau), used for expBasis and cosBasis(omega=0) *** if (basisType==expBasis || (basisType==cosBasis && omega==0.)) { - if (verboseEval()>2) cout << "RooGExpModel::evaluate(" << GetName() << ") 3d form tau=" << tau << endl ; + if (verboseEval()>2) std::cout << "RooGExpModel::evaluate(" << GetName() << ") 3d form tau=" << tau << std::endl ; double result(0) ; if (basisSign!=Minus) result += calcDecayConv(+1,tau,sig,rtau,fsign) ; // modified FMV,08/13/03 if (basisSign!=Plus) result += calcDecayConv(-1,tau,sig,rtau,fsign) ; // modified FMV,08/13/03 - //cout << "3rd form " << "x= " << x << " result= " << result << endl; + //cout << "3rd form " << "x= " << x << " result= " << result << std::endl; return result ; } // *** 4th form: Convolution with exp(-t/tau)*sin(omega*t), used for sinBasis(omega<>0,tau<>0) *** double wt = omega *tau ; if (basisType==sinBasis) { - if (verboseEval()>2) cout << "RooGExpModel::evaluate(" << GetName() << ") 4th form omega = " - << omega << ", tau = " << tau << endl ; + if (verboseEval()>2) std::cout << "RooGExpModel::evaluate(" << GetName() << ") 4th form omega = " + << omega << ", tau = " << tau << std::endl ; double result(0) ; if (wt==0.) return result ; if (basisSign!=Minus) result += -1*calcSinConv(+1,sig,tau,omega,rtau,fsign).imag() ; if (basisSign!=Plus) result += -1*calcSinConv(-1,sig,tau,omega,rtau,fsign).imag() ; - //cout << "4th form " << "x= " << x << " result= " << result << endl; + //cout << "4th form " << "x= " << x << " result= " << result << std::endl; return result ; } // *** 5th form: Convolution with exp(-t/tau)*cos(omega*t), used for cosBasis(omega<>0) *** if (basisType==cosBasis) { - if (verboseEval()>2) cout << "RooGExpModel::evaluate(" << GetName() - << ") 5th form omega = " << omega << ", tau = " << tau << endl ; + if (verboseEval()>2) std::cout << "RooGExpModel::evaluate(" << GetName() + << ") 5th form omega = " << omega << ", tau = " << tau << std::endl ; double result(0) ; if (basisSign!=Minus) result += calcSinConv(+1,sig,tau,omega,rtau,fsign).real() ; if (basisSign!=Plus) result += calcSinConv(-1,sig,tau,omega,rtau,fsign).real() ; - //cout << "5th form " << "x= " << x << " result= " << result << endl; + //cout << "5th form " << "x= " << x << " result= " << result << std::endl; return result ; } @@ -372,8 +403,8 @@ double RooGExpModel::evaluate() const if (basisType==sinhBasis) { double dgamma = (static_cast(basis().getParameter(2)))->getVal(); - if (verboseEval()>2) cout << "RooGExpModel::evaluate(" << GetName() - << ") 6th form = " << dgamma << ", tau = " << tau << endl; + if (verboseEval()>2) std::cout << "RooGExpModel::evaluate(" << GetName() + << ") 6th form = " << dgamma << ", tau = " << tau << std::endl; double result(0); //if (basisSign!=Minus) result += calcSinhConv(+1,+1,-1,tau,dgamma,sig,rtau,fsign); //if (basisSign!=Plus) result += calcSinhConv(-1,-1,+1,tau,dgamma,sig,rtau,fsign); @@ -384,7 +415,7 @@ double RooGExpModel::evaluate() const // modified FMV,08/13/03 if (basisSign!=Plus) result += 0.5*(calcDecayConv(-1,tau2,sig,rtau,fsign)-calcDecayConv(-1,tau1,sig,rtau,fsign)); // modified FMV,08/13/03 - //cout << "6th form " << "x= " << x << " result= " << result << endl; + //cout << "6th form " << "x= " << x << " result= " << result << std::endl; return result; } @@ -392,8 +423,8 @@ double RooGExpModel::evaluate() const if (basisType==coshBasis) { double dgamma = (static_cast(basis().getParameter(2)))->getVal(); - if (verboseEval()>2) cout << "RooGExpModel::evaluate(" << GetName() - << ") 7th form = " << dgamma << ", tau = " << tau << endl; + if (verboseEval()>2) std::cout << "RooGExpModel::evaluate(" << GetName() + << ") 7th form = " << dgamma << ", tau = " << tau << std::endl; double result(0); //if (basisSign!=Minus) result += calcCoshConv(+1,tau,dgamma,sig,rtau,fsign); //if (basisSign!=Plus) result += calcCoshConv(-1,tau,dgamma,sig,rtau,fsign); @@ -404,7 +435,7 @@ double RooGExpModel::evaluate() const // modified FMV,08/13/03 if (basisSign!=Plus) result += 0.5*(calcDecayConv(-1,tau1,sig,rtau,fsign)+calcDecayConv(-1,tau2,sig,rtau,fsign)); // modified FMV,08/13/03 - //cout << "7th form " << "x= " << x << " result= " << result << endl; + //cout << "7th form " << "x= " << x << " result= " << result << std::endl; return result; } R__ASSERT(0) ; @@ -684,7 +715,7 @@ double RooGExpModel::analyticalIntegral(Int_t code, const char* rangeName) const // *** 1st form???? if (basisType==none || ((basisType==expBasis || basisType==cosBasis) && tau==0.)) { - if (verboseEval()>0) cout << "RooGExpModel::analyticalIntegral(" << GetName() << ") 1st form" << endl ; + if (verboseEval()>0) std::cout << "RooGExpModel::analyticalIntegral(" << GetName() << ") 1st form" << std::endl ; //double result = 1.0 ; // WVE inferred from limit(tau->0) of cosBasisNorm // finite+asymtotic normalization, added FMV, 07/24/03 @@ -701,7 +732,7 @@ double RooGExpModel::analyticalIntegral(Int_t code, const char* rangeName) const } if (_basisCode!=0 && basisSign==Both) result *= 2 ; - //cout << "Integral 1st form " << " result= " << result*ssfInt << endl; + //cout << "Integral 1st form " << " result= " << result*ssfInt << std::endl; return result*ssfInt ; } @@ -710,7 +741,7 @@ double RooGExpModel::analyticalIntegral(Int_t code, const char* rangeName) const // *** 2nd form: unity, used for sinBasis and cosBasis with tau=0 (PDF is zero) *** //if (tau==0&&omega!=0) { if (tau==0) { // modified, FMV 07/24/03 - if (verboseEval()>0) cout << "RooGExpModel::analyticalIntegral(" << GetName() << ") 2nd form" << endl ; + if (verboseEval()>0) std::cout << "RooGExpModel::analyticalIntegral(" << GetName() << ") 2nd form" << std::endl ; return 0. ; } @@ -722,16 +753,16 @@ double RooGExpModel::analyticalIntegral(Int_t code, const char* rangeName) const double result(0.); if (basisSign!=Minus) result += calcSinConvNorm(+1,tau,sig,rtau,fsign,rangeName); if (basisSign!=Plus) result += calcSinConvNorm(-1,tau,sig,rtau,fsign,rangeName); - //cout << "Integral 3rd form " << " result= " << result*ssfInt << endl; + //cout << "Integral 3rd form " << " result= " << result*ssfInt << std::endl; return result*ssfInt ; } // *** 4th form: Convolution with exp(-t/tau)*sin(omega*t), used for sinBasis(omega<>0,tau<>0) *** double wt = omega * tau ; if (basisType==sinBasis) { - if (verboseEval()>0) cout << "RooGExpModel::analyticalIntegral(" << GetName() << ") 4th form omega = " - << omega << ", tau = " << tau << endl ; - //cout << "sin integral" << endl; + if (verboseEval()>0) std::cout << "RooGExpModel::analyticalIntegral(" << GetName() << ") 4th form omega = " + << omega << ", tau = " << tau << std::endl ; + //cout << "sin integral" << std::endl; double result(0) ; if (wt==0) return result ; //if (basisSign!=Minus) result += calcSinConvNorm(+1,tau,omega).imag() ; @@ -739,22 +770,22 @@ double RooGExpModel::analyticalIntegral(Int_t code, const char* rangeName) const // finite+asymtotic normalization, added FMV, 07/24/03 if (basisSign!=Minus) result += -1*calcSinConvNorm(+1,tau,omega,sig,rtau,fsign,rangeName).imag(); if (basisSign!=Plus) result += -1*calcSinConvNorm(-1,tau,omega,sig,rtau,fsign,rangeName).imag(); - //cout << "Integral 4th form " << " result= " << result*ssfInt << endl; + //cout << "Integral 4th form " << " result= " << result*ssfInt << std::endl; return result*ssfInt ; } // *** 5th form: Convolution with exp(-t/tau)*cos(omega*t), used for cosBasis(omega<>0) *** if (basisType==cosBasis) { - if (verboseEval()>0) cout << "RooGExpModel::analyticalIntegral(" << GetName() - << ") 5th form omega = " << omega << ", tau = " << tau << endl ; - //cout << "cos integral" << endl; + if (verboseEval()>0) std::cout << "RooGExpModel::analyticalIntegral(" << GetName() + << ") 5th form omega = " << omega << ", tau = " << tau << std::endl ; + //cout << "cos integral" << std::endl; double result(0) ; //if (basisSign!=Minus) result += calcSinConvNorm(+1,tau,omega).real() ; //if (basisSign!=Plus) result += calcSinConvNorm(-1,tau,omega).real() ; // finite+asymtotic normalization, added FMV, 07/24/03 if (basisSign!=Minus) result += calcSinConvNorm(+1,tau,omega,sig,rtau,fsign,rangeName).real(); if (basisSign!=Plus) result += calcSinConvNorm(-1,tau,omega,sig,rtau,fsign,rangeName).real(); - //cout << "Integral 5th form " << " result= " << result*ssfInt << endl; + //cout << "Integral 5th form " << " result= " << result*ssfInt << std::endl; return result*ssfInt ; } @@ -762,11 +793,11 @@ double RooGExpModel::analyticalIntegral(Int_t code, const char* rangeName) const // *** 6th form: Convolution with exp(-t/tau)*sinh(dgamma*t/2), used for sinhBasis *** if (basisType==sinhBasis) { - if (verboseEval()>0) cout << "RooGExpModel::analyticalIntegral(" << GetName() - << ") 6th form dgamma = " << dgamma << ", tau = " << tau << endl ; + if (verboseEval()>0) std::cout << "RooGExpModel::analyticalIntegral(" << GetName() + << ") 6th form dgamma = " << dgamma << ", tau = " << tau << std::endl ; double tau1 = 1/(1/tau-dgamma/2); double tau2 = 1/(1/tau+dgamma/2); - //cout << "sinh integral" << endl; + //cout << "sinh integral" << std::endl; double result(0) ; //if (basisSign!=Minus) result += tau1-tau2 ; //if (basisSign!=Plus) result += tau2-tau1 ; @@ -775,15 +806,15 @@ double RooGExpModel::analyticalIntegral(Int_t code, const char* rangeName) const calcSinConvNorm(+1,tau2,sig,rtau,fsign,rangeName)); if (basisSign!=Plus) result += 0.5*(calcSinConvNorm(-1,tau2,sig,rtau,fsign,rangeName)- calcSinConvNorm(-1,tau1,sig,rtau,fsign,rangeName)); - //cout << "Integral 6th form " << " result= " << result*ssfInt << endl; + //cout << "Integral 6th form " << " result= " << result*ssfInt << std::endl; return result; } // ** 7th form: Convolution with exp(-t/tau)*cosh(dgamma*t/2), used for coshBasis *** if (basisType==coshBasis) { - if (verboseEval()>0) cout << "RooGExpModel::analyticalIntegral(" << GetName() - << ") 6th form dgamma = " << dgamma << ", tau = " << tau << endl ; - //cout << "cosh integral" << endl; + if (verboseEval()>0) std::cout << "RooGExpModel::analyticalIntegral(" << GetName() + << ") 6th form dgamma = " << dgamma << ", tau = " << tau << std::endl ; + //cout << "cosh integral" << std::endl; double tau1 = 1/(1/tau-dgamma/2); double tau2 = 1/(1/tau+dgamma/2); //double result = (tau1+tau2) ; @@ -794,7 +825,7 @@ double RooGExpModel::analyticalIntegral(Int_t code, const char* rangeName) const calcSinConvNorm(+1,tau2,sig,rtau,fsign,rangeName)); if (basisSign!=Plus) result += 0.5*(calcSinConvNorm(-1,tau1,sig,rtau,fsign,rangeName)+ calcSinConvNorm(-1,tau2,sig,rtau,fsign,rangeName)); - //cout << "Integral 7th form " << " result= " << result*ssfInt << endl; + //cout << "Integral 7th form " << " result= " << result*ssfInt << std::endl; return result; } @@ -860,7 +891,7 @@ double RooGExpModel::calcSinConvNorm(double sign, double tau, double sig, double // WVE Handle 0/0 numeric divergence if (std::abs(tau-rtau)<1e-10 && std::abs(term1+term2)<1e-10) { - cout << "epsilon method" << endl ; + std::cout << "epsilon method" << std::endl ; static double epsilon = 1e-4 ; return calcSinConvNorm(sign,tau+epsilon,sig,rtau-epsilon,fsign,rangeName) ; } diff --git a/roofit/roofit/src/RooGaussModel.cxx b/roofit/roofit/src/RooGaussModel.cxx index 2145996c967ad..7fbc29ed8b8cd 100644 --- a/roofit/roofit/src/RooGaussModel.cxx +++ b/roofit/roofit/src/RooGaussModel.cxx @@ -34,7 +34,48 @@ for analytical convolutions with classes inheriting from RooAbsAnaConvPdf #include -using namespace std; +namespace { + +enum RooGaussBasis { + noBasis = 0, + expBasisMinus = 1, + expBasisSum = 2, + expBasisPlus = 3, + sinBasisMinus = 11, + sinBasisSum = 12, + sinBasisPlus = 13, + cosBasisMinus = 21, + cosBasisSum = 22, + cosBasisPlus = 23, + linBasisPlus = 33, + quadBasisPlus = 43, + coshBasisMinus = 51, + coshBasisSum = 52, + coshBasisPlus = 53, + sinhBasisMinus = 61, + sinhBasisSum = 62, + sinhBasisPlus = 63 +}; + +enum BasisType { + none = 0, + expBasis = 1, + sinBasis = 2, + cosBasis = 3, + linBasis = 4, + quadBasis = 5, + coshBasis = 6, + sinhBasis = 7 +}; + +enum BasisSign { Both = 0, Plus = +1, Minus = -1 }; + +BasisType getBasisType(int basisCode) +{ + return static_cast(basisCode == 0 ? 0 : (basisCode / 10) + 1); +} + +} // namespace using RooHeterogeneousMath::evalCerf; using RooHeterogeneousMath::evalCerfApprox; @@ -43,30 +84,17 @@ ClassImp(RooGaussModel); //////////////////////////////////////////////////////////////////////////////// -RooGaussModel::RooGaussModel(const char *name, const char *title, RooAbsRealLValue& xIn, - RooAbsReal& _mean, RooAbsReal& _sigma) : - RooResolutionModel(name,title,xIn), - _flatSFInt(false), - _asympInt(false), - mean("mean","Mean",this,_mean), - sigma("sigma","Width",this,_sigma), - msf("msf","Mean Scale Factor",this,RooRealConstant::value(1)), - ssf("ssf","Sigma Scale Factor",this,RooRealConstant::value(1)) +RooGaussModel::RooGaussModel(const char *name, const char *title, RooAbsRealLValue &xIn, RooAbsReal &_mean, + RooAbsReal &_sigma) + : RooGaussModel{name, title, xIn, _mean, _sigma, RooRealConstant::value(1), RooRealConstant::value(1)} { } //////////////////////////////////////////////////////////////////////////////// -RooGaussModel::RooGaussModel(const char *name, const char *title, RooAbsRealLValue& xIn, - RooAbsReal& _mean, RooAbsReal& _sigma, - RooAbsReal& _msSF) : - RooResolutionModel(name,title,xIn), - _flatSFInt(false), - _asympInt(false), - mean("mean","Mean",this,_mean), - sigma("sigma","Width",this,_sigma), - msf("msf","Mean Scale Factor",this,_msSF), - ssf("ssf","Sigma Scale Factor",this,_msSF) +RooGaussModel::RooGaussModel(const char *name, const char *title, RooAbsRealLValue &xIn, RooAbsReal &_mean, + RooAbsReal &_sigma, RooAbsReal &_msSF) + : RooGaussModel{name, title, xIn, _mean, _sigma, _msSF, _msSF} { } @@ -102,24 +130,30 @@ RooGaussModel::RooGaussModel(const RooGaussModel& other, const char* name) : Int_t RooGaussModel::basisCode(const char* name) const { - if (!TString("exp(-@0/@1)").CompareTo(name)) return expBasisPlus ; - if (!TString("exp(@0/@1)").CompareTo(name)) return expBasisMinus ; - if (!TString("exp(-abs(@0)/@1)").CompareTo(name)) return expBasisSum ; - if (!TString("exp(-@0/@1)*sin(@0*@2)").CompareTo(name)) return sinBasisPlus ; - if (!TString("exp(@0/@1)*sin(@0*@2)").CompareTo(name)) return sinBasisMinus ; - if (!TString("exp(-abs(@0)/@1)*sin(@0*@2)").CompareTo(name)) return sinBasisSum ; - if (!TString("exp(-@0/@1)*cos(@0*@2)").CompareTo(name)) return cosBasisPlus ; - if (!TString("exp(@0/@1)*cos(@0*@2)").CompareTo(name)) return cosBasisMinus ; - if (!TString("exp(-abs(@0)/@1)*cos(@0*@2)").CompareTo(name)) return cosBasisSum ; - if (!TString("(@0/@1)*exp(-@0/@1)").CompareTo(name)) return linBasisPlus ; - if (!TString("(@0/@1)*(@0/@1)*exp(-@0/@1)").CompareTo(name)) return quadBasisPlus ; - if (!TString("exp(-@0/@1)*cosh(@0*@2/2)").CompareTo(name)) return coshBasisPlus; - if (!TString("exp(@0/@1)*cosh(@0*@2/2)").CompareTo(name)) return coshBasisMinus; - if (!TString("exp(-abs(@0)/@1)*cosh(@0*@2/2)").CompareTo(name)) return coshBasisSum; - if (!TString("exp(-@0/@1)*sinh(@0*@2/2)").CompareTo(name)) return sinhBasisPlus; - if (!TString("exp(@0/@1)*sinh(@0*@2/2)").CompareTo(name)) return sinhBasisMinus; - if (!TString("exp(-abs(@0)/@1)*sinh(@0*@2/2)").CompareTo(name)) return sinhBasisSum; - return 0 ; + std::string str = name; + + // Remove whitespaces from the input string + str.erase(remove(str.begin(),str.end(),' '),str.end()); + + if (str == "exp(-@0/@1)") return expBasisPlus ; + if (str == "exp(@0/@1)") return expBasisMinus ; + if (str == "exp(-abs(@0)/@1)") return expBasisSum ; + if (str == "exp(-@0/@1)*sin(@0*@2)") return sinBasisPlus ; + if (str == "exp(@0/@1)*sin(@0*@2)") return sinBasisMinus ; + if (str == "exp(-abs(@0)/@1)*sin(@0*@2)") return sinBasisSum ; + if (str == "exp(-@0/@1)*cos(@0*@2)") return cosBasisPlus ; + if (str == "exp(@0/@1)*cos(@0*@2)") return cosBasisMinus ; + if (str == "exp(-abs(@0)/@1)*cos(@0*@2)") return cosBasisSum ; + if (str == "(@0/@1)*exp(-@0/@1)") return linBasisPlus ; + if (str == "(@0/@1)*(@0/@1)*exp(-@0/@1)") return quadBasisPlus ; + if (str == "exp(-@0/@1)*cosh(@0*@2/2)") return coshBasisPlus; + if (str == "exp(@0/@1)*cosh(@0*@2/2)") return coshBasisMinus; + if (str == "exp(-abs(@0)/@1)*cosh(@0*@2/2)") return coshBasisSum; + if (str == "exp(-@0/@1)*sinh(@0*@2/2)") return sinhBasisPlus; + if (str == "exp(@0/@1)*sinh(@0*@2/2)") return sinhBasisMinus; + if (str == "exp(-abs(@0)/@1)*sinh(@0*@2/2)") return sinhBasisSum; + + return 0; } //////////////////////////////////////////////////////////////////////////////// @@ -342,7 +376,7 @@ double RooGaussModel::analyticalIntegral(Int_t code, const char* rangeName) cons } if (basisType==none || ((basisType==expBasis || basisType==cosBasis) && tau==0.)) { double xscale = root2*(sigma*ssf); - if (verboseEval()>0) cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 1st form" << endl ; + if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 1st form" << std::endl ; double xpmin = (x.min(rangeName)-(mean*msf))/xscale ; double xpmax = (x.max(rangeName)-(mean*msf))/xscale ; @@ -355,8 +389,8 @@ double RooGaussModel::analyticalIntegral(Int_t code, const char* rangeName) cons } if (_basisCode!=0 && basisSign==Both) result *= 2 ; - //cout << "Integral 1st form " << " result= " << result*ssfInt << endl; - if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 1 " << endl; } + //cout << "Integral 1st form " << " result= " << result*ssfInt << std::endl; + if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 1 " << std::endl; } return result*ssfInt ; } @@ -366,7 +400,7 @@ double RooGaussModel::analyticalIntegral(Int_t code, const char* rangeName) cons // *** 2nd form: unity, used for sinBasis and linBasis with tau=0 (PDF is zero) *** if (tau==0) { - if (verboseEval()>0) cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 2nd form" << endl ; + if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 2nd form" << std::endl ; return 0. ; } @@ -378,11 +412,11 @@ double RooGaussModel::analyticalIntegral(Int_t code, const char* rangeName) cons double umax = xpmax/(2*c) ; if (basisType==expBasis || (basisType==cosBasis && omega==0.)) { - if (verboseEval()>0) cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 3d form tau=" << tau << endl ; + if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 3d form tau=" << tau << std::endl ; double result(0) ; if (basisSign!=Minus) result += evalCerfInt(+1,0,tau,-umin,-umax,c).real(); if (basisSign!=Plus) result += evalCerfInt(-1,0,tau, umin, umax,c).real(); - if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 3 " << endl; } + if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 3 " << std::endl; } return result*ssfInt ; } @@ -391,40 +425,40 @@ double RooGaussModel::analyticalIntegral(Int_t code, const char* rangeName) cons double _y = tau*dgamma/2; if (basisType==sinBasis) { - if (verboseEval()>0) cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 4th form omega = " << omega << ", tau = " << tau << endl ; + if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 4th form omega = " << omega << ", tau = " << tau << std::endl ; double result(0) ; if (_x==0) return result*ssfInt ; if (basisSign!=Minus) result += -1*evalCerfInt(+1,-_x,tau,-umin,-umax,c).imag(); if (basisSign!=Plus) result += -1*evalCerfInt(-1, _x,tau, umin, umax,c).imag(); - if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 4 " << endl; } + if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 4 " << std::endl; } return result*ssfInt ; } // *** 5th form: Convolution with exp(-t/tau)*cos(omega*t), used for cosBasis(omega<>0) *** if (basisType==cosBasis) { - if (verboseEval()>0) cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 5th form omega = " << omega << ", tau = " << tau << endl ; + if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 5th form omega = " << omega << ", tau = " << tau << std::endl ; double result(0) ; if (basisSign!=Minus) result += evalCerfInt(+1,-_x,tau,-umin,-umax,c).real(); if (basisSign!=Plus) result += evalCerfInt(-1, _x,tau, umin, umax,c).real(); - if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 5 " << endl; } + if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 5 " << std::endl; } return result*ssfInt ; } // *** 8th form: Convolution with exp(-|t|/tau)*cosh(dgamma*t/2), used for coshBasis *** // *** 9th form: Convolution with exp(-|t|/tau)*sinh(dgamma*t/2), used for sinhBasis *** if (basisType==coshBasis || basisType == sinhBasis) { - if (verboseEval()>0) {cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 8th form tau=" << tau << endl ; } + if (verboseEval()>0) {std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 8th form tau=" << tau << std::endl ; } double result(0) ; int sgn = ( basisType == coshBasis ? +1 : -1 ); if (basisSign!=Minus) result += 0.5*( evalCerfInt(+1,0,tau/(1-_y),-umin,-umax,c*(1-_y)).real()+ sgn*evalCerfInt(+1,0,tau/(1+_y),-umin,-umax,c*(1+_y)).real()); if (basisSign!=Plus) result += 0.5*(sgn*evalCerfInt(-1,0,tau/(1-_y), umin, umax,c*(1-_y)).real()+ evalCerfInt(-1,0,tau/(1+_y), umin, umax,c*(1+_y)).real()); - if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 6 " << endl; } + if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 6 " << std::endl; } return result*ssfInt ; } // *** 6th form: Convolution with (t/tau)*exp(-t/tau), used for linBasis *** if (basisType==linBasis) { - if (verboseEval()>0) cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 6th form tau=" << tau << endl ; + if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 6th form tau=" << tau << std::endl ; double f0 = RooMath::erf(-umax) - RooMath::erf(-umin); double f1 = std::exp(-umax*umax) - std::exp(-umin*umin); @@ -446,7 +480,7 @@ double RooGaussModel::analyticalIntegral(Int_t code, const char* rangeName) cons // *** 7th form: Convolution with (t/tau)*(t/tau)*exp(-t/tau), used for quadBasis *** if (basisType==quadBasis) { - if (verboseEval()>0) cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 7th form tau=" << tau << endl ; + if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 7th form tau=" << tau << std::endl ; double f0 = RooMath::erf(-umax) - RooMath::erf(-umin); @@ -495,8 +529,7 @@ std::complex RooGaussModel::evalCerfInt(double sign, double _x, double t Int_t RooGaussModel::getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, bool /*staticInitOK*/) const { - if (matchArgs(directVars,generateVars,x)) return 1 ; - return 0 ; + return matchArgs(directVars,generateVars,x) ? 1 : 0; } //////////////////////////////////////////////////////////////////////////////// @@ -515,3 +548,8 @@ void RooGaussModel::generateEvent(Int_t code) } } } + +bool RooGaussModel::canComputeBatchWithCuda() const +{ + return getBasisType(_basisCode) == expBasis; +} diff --git a/roofit/roofitcore/CMakeLists.txt b/roofit/roofitcore/CMakeLists.txt index 36d5182e4671b..771b7ef1b7faa 100644 --- a/roofit/roofitcore/CMakeLists.txt +++ b/roofit/roofitcore/CMakeLists.txt @@ -498,6 +498,10 @@ if(fftw3) target_compile_definitions(RooFitCore PUBLIC ROOFIT_MATH_FFTW3) endif() +# To avoid deprecation warnings when including old test statistics headers. +# RooFit has to include them to build the documentation. +target_compile_definitions(RooFitCore PUBLIC ROOFIT_BUILDS_ITSELF) + target_include_directories(RooFitCore INTERFACE $) # For recent clang, this can facilitate auto-vectorisation. diff --git a/roofit/roofitcore/inc/RooAbsOptTestStatistic.h b/roofit/roofitcore/inc/RooAbsOptTestStatistic.h index b3f0b9ef9a826..4c5e47bfa7ffc 100644 --- a/roofit/roofitcore/inc/RooAbsOptTestStatistic.h +++ b/roofit/roofitcore/inc/RooAbsOptTestStatistic.h @@ -16,6 +16,31 @@ #ifndef ROO_ABS_OPT_TEST_STATISTIC #define ROO_ABS_OPT_TEST_STATISTIC +// We can't print deprecation warnings when including headers in cling, because +// this will be done automatically anyway. +#ifdef __CLING__ +#ifndef ROOFIT_BUILDS_ITSELF +// These warnings should only be suppressed when building ROOT itself! +#warning "Including RooAbsOptTestStatistic.h is deprecated, and this header will be removed in ROOT v6.34: it is an implementation detail that should not be part of the public user interface" +#else +// If we are builting RooFit itself, this will serve as a reminder to actually +// remove this deprecate public header. Here is now this needs to be done: +// 1. Move this header file from inc/ to src/ +// 2. Remove the LinkDef entry, ClassDefOverride, and ClassImpl macros for +// this class +// 3. If there are are tests using this class in the test/ directory, change +// the include to use a relative path the moved header file in the src/ +// directory, e.g. #include becomes #include +// "../src/RemovedInterface.h" +// 4. Remove this ifndef-else-endif block from the header +// 5. Remove the deprecation warning at the end of the class declaration +#include +#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 34, 00) +#error "Please remove this deprecated public interface." +#endif +#endif +#endif + #include "RooAbsTestStatistic.h" #include "RooSetProxy.h" #include "RooCategoryProxy.h" @@ -93,6 +118,10 @@ class RooAbsOptTestStatistic : public RooAbsTestStatistic { double _integrateBinsPrecision{-1.}; // Precision for finer sampling of bins. ClassDefOverride(RooAbsOptTestStatistic,0) // Abstract base class for optimized test statistics +#ifndef ROOFIT_BUILDS_ITSELF +} R__DEPRECATED(6,34, "RooAbsOptTestStatistic is a RooFit implementation detail that should not be instantiated in user code."); +#else }; +#endif #endif diff --git a/roofit/roofitcore/inc/RooAbsTestStatistic.h b/roofit/roofitcore/inc/RooAbsTestStatistic.h index 33f390ba98c4d..f1519318ca62e 100644 --- a/roofit/roofitcore/inc/RooAbsTestStatistic.h +++ b/roofit/roofitcore/inc/RooAbsTestStatistic.h @@ -16,6 +16,31 @@ #ifndef ROO_ABS_TEST_STATISTIC #define ROO_ABS_TEST_STATISTIC +// We can't print deprecation warnings when including headers in cling, because +// this will be done automatically anyway. +#ifdef __CLING__ +#ifndef ROOFIT_BUILDS_ITSELF +// These warnings should only be suppressed when building ROOT itself! +#warning "Including RooAbsTestStatistic.h is deprecated, and this header will be removed in ROOT v6.34: it is an implementation detail that should not be part of the public user interface" +#else +// If we are builting RooFit itself, this will serve as a reminder to actually +// remove this deprecate public header. Here is now this needs to be done: +// 1. Move this header file from inc/ to src/ +// 2. Remove the LinkDef entry, ClassDefOverride, and ClassImpl macros for +// this class +// 3. If there are are tests using this class in the test/ directory, change +// the include to use a relative path the moved header file in the src/ +// directory, e.g. #include becomes #include +// "../src/RemovedInterface.h" +// 4. Remove this ifndef-else-endif block from the header +// 5. Remove the deprecation warning at the end of the class declaration +#include +#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 34, 00) +#error "Please remove this deprecated public interface." +#endif +#endif +#endif + #include "RooAbsReal.h" #include "RooSetProxy.h" #include "RooRealProxy.h" @@ -162,6 +187,10 @@ class RooAbsTestStatistic : public RooAbsReal { ClassDefOverride(RooAbsTestStatistic,0) // Abstract base class for real-valued test statistics +#ifndef ROOFIT_BUILDS_ITSELF +} R__DEPRECATED(6,34, "RooAbsTestStatistic is a RooFit implementation detail that should not be instantiated in user code."); +#else }; +#endif #endif diff --git a/roofit/roofitcore/inc/RooChi2Var.h b/roofit/roofitcore/inc/RooChi2Var.h index 5382f244f1cca..0c2391da5f43e 100644 --- a/roofit/roofitcore/inc/RooChi2Var.h +++ b/roofit/roofitcore/inc/RooChi2Var.h @@ -17,6 +17,31 @@ #ifndef ROO_CHI2_VAR #define ROO_CHI2_VAR +// We can't print deprecation warnings when including headers in cling, because +// this will be done automatically anyway. +#ifdef __CLING__ +#ifndef ROOFIT_BUILDS_ITSELF +// These warnings should only be suppressed when building ROOT itself! +#warning "Including RooChi2Var.h is deprecated, and this header will be removed in ROOT v6.34: Please use RooAbsReal::createChi2() to create chi-square test statistics objects" +#else +// If we are builting RooFit itself, this will serve as a reminder to actually +// remove this deprecate public header. Here is now this needs to be done: +// 1. Move this header file from inc/ to src/ +// 2. Remove the LinkDef entry, ClassDefOverride, and ClassImpl macros for +// this class +// 3. If there are are tests using this class in the test/ directory, change +// the include to use a relative path the moved header file in the src/ +// directory, e.g. #include becomes #include +// "../src/RemovedInterface.h" +// 4. Remove this ifndef-else-endif block from the header +// 5. Remove the deprecation warning at the end of the class declaration +#include +#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 34, 00) +#error "Please remove this deprecated public interface." +#endif +#endif +#endif + #include "RooAbsOptTestStatistic.h" #include "RooCmdArg.h" #include "RooDataHist.h" @@ -65,7 +90,12 @@ class RooChi2Var : public RooAbsOptTestStatistic { FuncMode _funcMode ; ///< Function, P.d.f. or extended p.d.f? ClassDefOverride(RooChi2Var,0) // Chi^2 function of p.d.f w.r.t a binned dataset + +#ifndef ROOFIT_BUILDS_ITSELF +} R__DEPRECATED(6,34, "Please use RooAbsReal::createChi2() to create chi-square test statistics objects."); +#else }; +#endif #endif diff --git a/roofit/roofitcore/inc/RooNLLVar.h b/roofit/roofitcore/inc/RooNLLVar.h index abbee518df5f0..80cf3a4f4b42d 100644 --- a/roofit/roofitcore/inc/RooNLLVar.h +++ b/roofit/roofitcore/inc/RooNLLVar.h @@ -16,6 +16,31 @@ #ifndef ROO_NLL_VAR #define ROO_NLL_VAR +// We can't print deprecation warnings when including headers in cling, because +// this will be done automatically anyway. +#ifdef __CLING__ +#ifndef ROOFIT_BUILDS_ITSELF +// These warnings should only be suppressed when building ROOT itself! +#warning "Including RooNLLVar.h is deprecated, and this header will be removed in ROOT v6.34: please use RooAbsPdf::createNLL() to create likelihood objects" +#else +// If we are builting RooFit itself, this will serve as a reminder to actually +// remove this deprecate public header. Here is now this needs to be done: +// 1. Move this header file from inc/ to src/ +// 2. Remove the LinkDef entry, ClassDefOverride, and ClassImpl macros for +// this class +// 3. If there are are tests using this class in the test/ directory, change +// the include to use a relative path the moved header file in the src/ +// directory, e.g. #include becomes #include +// "../src/RemovedInterface.h" +// 4. Remove this ifndef-else-endif block from the header +// 5. Remove the deprecation warning at the end of the class declaration +#include +#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 34, 00) +#error "Please remove this deprecated public interface." +#endif +#endif +#endif + #include "RooAbsOptTestStatistic.h" #include "RooCmdArg.h" #include "RooAbsPdf.h" @@ -82,7 +107,12 @@ class RooNLLVar : public RooAbsOptTestStatistic { std::unique_ptr _offsetPdf; /// becomes #include +// "../src/RemovedInterface.h" +// 4. Remove this ifndef-else-endif block from the header +// 5. Remove the deprecation warning at the end of the class declaration +#include +#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 34, 00) +#error "Please remove this deprecated public interface." +#endif +#endif +#endif + #include "RooAbsOptTestStatistic.h" #include "RooCmdArg.h" #include "RooDataSet.h" @@ -86,7 +111,12 @@ class RooXYChi2Var : public RooAbsOptTestStatistic { std::list _binList ; /// #include +#include + #include #include #include +#include #include -using namespace std ; +namespace { + +enum RooTruthBasis { + noBasis = 0, + expBasisMinus = 1, + expBasisSum = 2, + expBasisPlus = 3, + sinBasisMinus = 11, + sinBasisSum = 12, + sinBasisPlus = 13, + cosBasisMinus = 21, + cosBasisSum = 22, + cosBasisPlus = 23, + linBasisPlus = 33, + quadBasisPlus = 43, + coshBasisMinus = 51, + coshBasisSum = 52, + coshBasisPlus = 53, + sinhBasisMinus = 61, + sinhBasisSum = 62, + sinhBasisPlus = 63, + genericBasis = 100 +}; + +enum BasisType { + none = 0, + expBasis = 1, + sinBasis = 2, + cosBasis = 3, + linBasis = 4, + quadBasis = 5, + coshBasis = 6, + sinhBasis = 7 +}; + +enum BasisSign { Both = 0, Plus = +1, Minus = -1 }; -ClassImp(RooTruthModel); +} // namespace +ClassImp(RooTruthModel); //////////////////////////////////////////////////////////////////////////////// /// Constructor of a truth resolution model, i.e. a delta function in observable 'xIn' @@ -51,18 +90,6 @@ RooTruthModel::RooTruthModel(const char *name, const char *title, RooAbsRealLVal { } - - -//////////////////////////////////////////////////////////////////////////////// -/// Copy constructor - -RooTruthModel::RooTruthModel(const RooTruthModel& other, const char* name) : - RooResolutionModel(other,name) -{ -} - - - //////////////////////////////////////////////////////////////////////////////// /// Return basis code for given basis definition string. Return special /// codes for 'known' bases for which compiled definition exists. Return @@ -174,32 +201,31 @@ double RooTruthModel::evaluate() const // Return desired basis function switch(basisType) { case expBasis: { - //cout << " RooTruthModel::eval(" << GetName() << ") expBasis mode ret = " << exp(-std::abs((double)x)/tau) << " tau = " << tau << endl ; - return exp(-std::abs((double)x)/tau) ; + return std::exp(-std::abs((double)x)/tau) ; } case sinBasis: { double dm = (static_cast(basis().getParameter(2)))->getVal() ; - return exp(-std::abs((double)x)/tau)*sin(x*dm) ; + return std::exp(-std::abs((double)x)/tau)*std::sin(x*dm) ; } case cosBasis: { double dm = (static_cast(basis().getParameter(2)))->getVal() ; - return exp(-std::abs((double)x)/tau)*cos(x*dm) ; + return std::exp(-std::abs((double)x)/tau)*std::cos(x*dm) ; } case linBasis: { double tscaled = std::abs((double)x)/tau; - return exp(-tscaled)*tscaled ; + return std::exp(-tscaled)*tscaled ; } case quadBasis: { double tscaled = std::abs((double)x)/tau; - return exp(-tscaled)*tscaled*tscaled; + return std::exp(-tscaled)*tscaled*tscaled; } case sinhBasis: { double dg = (static_cast(basis().getParameter(2)))->getVal() ; - return exp(-std::abs((double)x)/tau)*sinh(x*dg/2) ; + return std::exp(-std::abs((double)x)/tau)*std::sinh(x*dg/2) ; } case coshBasis: { double dg = (static_cast(basis().getParameter(2)))->getVal() ; - return exp(-std::abs((double)x)/tau)*cosh(x*dg/2) ; + return std::exp(-std::abs((double)x)/tau)*std::cosh(x*dg/2) ; } default: R__ASSERT(0) ; @@ -411,16 +437,16 @@ inline double indefiniteIntegralCoshBasisPlus(double x, double tau, double dm) // evaluate the integrals for the "Minus" and "Sum" cases. template double definiteIntegral(Function indefiniteIntegral, double xmin, double xmax, double tau, double dm, - RooTruthModel::BasisSign basisSign, bool isSymmetric) + BasisSign basisSign, bool isSymmetric) { // Note: isSymmetric == false implies antisymmetric if (tau == 0.0) return isSymmetric ? 1.0 : 0.0; double result = 0.0; - if (basisSign != RooTruthModel::Minus) { + if (basisSign != Minus) { result += indefiniteIntegral(xmax, tau, dm) - indefiniteIntegral(xmin, tau, dm); } - if (basisSign != RooTruthModel::Plus) { + if (basisSign != Plus) { const double resultMinus = indefiniteIntegral(-xmax, tau, dm) - indefiniteIntegral(-xmin, tau, dm); result += isSymmetric ? -resultMinus : resultMinus; } diff --git a/tree/treeplayer/inc/TBranchProxy.h b/tree/treeplayer/inc/TBranchProxy.h index 19fb124af9baa..120ab4e0e6f97 100644 --- a/tree/treeplayer/inc/TBranchProxy.h +++ b/tree/treeplayer/inc/TBranchProxy.h @@ -194,44 +194,36 @@ namespace Detail { kReadNoParentBranchCountNoCollection }; - EReadType GetReadType() { + EReadType GetReadType() + { if (fParent) { if (!fCollection) { return EReadType::kReadParentNoCollection; - } else { - if (IsaPointer()) { - return EReadType::kReadParentCollectionPointer; - } else { - return EReadType::kReadParentCollectionNoPointer; - } } - } if (fHasLeafCount) { + if (IsaPointer()) { + return EReadType::kReadParentCollectionPointer; + } + return EReadType::kReadParentCollectionNoPointer; + } + if (fHasLeafCount) { return EReadType::kDefault; - } else { - if (fBranchCount) { - if (fCollection) { - if (IsaPointer()) { - return EReadType::kReadNoParentBranchCountCollectionPointer; - } else { - return EReadType::kReadNoParentBranchCountCollectionNoPointer; - } - } else { - return EReadType::kReadNoParentBranchCountNoCollection; - } - - } else { - if (fCollection) { - if (IsaPointer()) { - return EReadType::kReadNoParentNoBranchCountCollectionPointer; - } else { - return EReadType::kReadNoParentNoBranchCountCollectionNoPointer; - } - } else { - return EReadType::kReadNoParentNoBranchCountNoCollection; + } + if (fBranchCount) { + if (fCollection) { + if (IsaPointer()) { + return EReadType::kReadNoParentBranchCountCollectionPointer; } + return EReadType::kReadNoParentBranchCountCollectionNoPointer; + } + return EReadType::kReadNoParentBranchCountNoCollection; + } + if (fCollection) { + if (IsaPointer()) { + return EReadType::kReadNoParentNoBranchCountCollectionPointer; } + return EReadType::kReadNoParentNoBranchCountCollectionNoPointer; } - return EReadType::kDefault; + return EReadType::kReadNoParentNoBranchCountNoCollection; } Bool_t ReadNoDirector() {