From 36c858488fbd452be04a0f66da302eff2b15febd Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Mon, 23 Oct 2023 18:47:31 +0200 Subject: [PATCH] [RF] More member initialization in class declarations in RooFit --- .../RooStats/HistFactory/RooBarlowBeestonLL.h | 4 +- roofit/histfactory/src/HistFactoryImpl.cxx | 6 +- .../src/HistoToWorkspaceFactoryFast.cxx | 14 ++--- .../src/MakeModelAndMeasurementsFast.cxx | 2 +- roofit/histfactory/src/RooBarlowBeestonLL.cxx | 7 +-- roofit/multiprocess/src/JobManager.cxx | 8 +-- roofit/multiprocess/src/Messenger.cxx | 20 +++--- roofit/roofit/inc/RooChi2MCSModule.h | 10 +-- roofit/roofit/inc/RooFunctorBinding.h | 20 +++--- roofit/roofit/inc/RooIntegralMorph.h | 6 +- roofit/roofit/inc/RooKeysPdf.h | 19 +++--- roofit/roofit/inc/RooTFnBinding.h | 4 +- roofit/roofit/inc/RooTFnPdfBinding.h | 4 +- roofit/roofit/src/RooChi2MCSModule.cxx | 14 +---- roofit/roofit/src/RooIntegralMorph.cxx | 6 +- roofit/roofit/src/RooKeysPdf.cxx | 15 +---- roofit/roofitZMQ/test/test_HWM.cxx | 4 +- roofit/roofitZMQ/test/test_ZMQ.cpp | 18 +++--- .../test/test_ZMQ_load_balancing.cxx | 4 +- roofit/roofitZMQ/test/test_polling.cxx | 8 +-- roofit/roofitcore/inc/RooAbsGenContext.h | 2 +- roofit/roofitcore/inc/RooAbsStudy.h | 10 +-- roofit/roofitcore/inc/RooArgProxy.h | 3 +- roofit/roofitcore/inc/RooBinning.h | 12 ++-- roofit/roofitcore/inc/RooCustomizer.h | 12 ++-- .../inc/RooDLLSignificanceMCSModule.h | 8 +-- roofit/roofitcore/inc/RooDataProjBinding.h | 4 +- roofit/roofitcore/inc/RooDerivative.h | 14 ++--- .../roofitcore/inc/RooFitLegacy/RooTreeData.h | 4 +- roofit/roofitcore/inc/RooLinkedListElem.h | 18 +++--- roofit/roofitcore/inc/RooMappedCategory.h | 6 +- roofit/roofitcore/inc/RooMsgService.h | 29 +++++++-- roofit/roofitcore/inc/RooResolutionModel.h | 4 +- roofit/roofitcore/inc/RooSimultaneous.h | 2 +- roofit/roofitcore/inc/RooVectorDataStore.h | 30 +++++---- roofit/roofitcore/src/BidirMMapPipe.h | 4 +- roofit/roofitcore/src/RooAbsData.cxx | 2 +- roofit/roofitcore/src/RooAbsGenContext.cxx | 3 +- roofit/roofitcore/src/RooAbsNumGenerator.cxx | 2 +- roofit/roofitcore/src/RooAbsProxy.cxx | 16 +---- roofit/roofitcore/src/RooAbsStudy.cxx | 16 ++--- roofit/roofitcore/src/RooAcceptReject.cxx | 6 +- roofit/roofitcore/src/RooAddModel.cxx | 1 - roofit/roofitcore/src/RooArgProxy.cxx | 2 +- roofit/roofitcore/src/RooBinning.cxx | 14 ++--- roofit/roofitcore/src/RooCustomizer.cxx | 18 +----- .../src/RooDLLSignificanceMCSModule.cxx | 8 +-- roofit/roofitcore/src/RooDataProjBinding.cxx | 22 ++----- roofit/roofitcore/src/RooDataSet.cxx | 2 +- roofit/roofitcore/src/RooDerivative.cxx | 18 ++---- roofit/roofitcore/src/RooFit/Evaluator.cxx | 2 +- roofit/roofitcore/src/RooFitResult.cxx | 13 +--- roofit/roofitcore/src/RooFoamGenerator.h | 12 ++-- roofit/roofitcore/src/RooFormula.cxx | 2 +- roofit/roofitcore/src/RooLinkedList.cxx | 8 +-- roofit/roofitcore/src/RooMsgService.cxx | 49 --------------- roofit/roofitcore/src/RooProfileLL.cxx | 2 +- .../roostats/inc/RooStats/SamplingDistPlot.h | 26 ++++---- roofit/roostats/src/HypoTestInverter.cxx | 2 +- roofit/roostats/src/SamplingDistPlot.cxx | 62 +++++-------------- 60 files changed, 247 insertions(+), 416 deletions(-) diff --git a/roofit/histfactory/inc/RooStats/HistFactory/RooBarlowBeestonLL.h b/roofit/histfactory/inc/RooStats/HistFactory/RooBarlowBeestonLL.h index c5f364a72049b..316cb38760c42 100644 --- a/roofit/histfactory/inc/RooStats/HistFactory/RooBarlowBeestonLL.h +++ b/roofit/histfactory/inc/RooStats/HistFactory/RooBarlowBeestonLL.h @@ -56,8 +56,8 @@ class RooBarlowBeestonLL : public RooAbsReal { protected: RooRealProxy _nll ; ///< Input -log(L) function - RooAbsPdf* _pdf; - RooAbsData* _data; + RooAbsPdf* _pdf = nullptr; + RooAbsData* _data = nullptr; mutable std::map< std::string, std::vector< BarlowCache > > _barlowCache; mutable std::set< std::string > _statUncertParams; mutable std::map _paramFixed ; ///< Parameter constant status at last time of use diff --git a/roofit/histfactory/src/HistFactoryImpl.cxx b/roofit/histfactory/src/HistFactoryImpl.cxx index 910ca0a47b7b3..eaed0b98e4a7d 100644 --- a/roofit/histfactory/src/HistFactoryImpl.cxx +++ b/roofit/histfactory/src/HistFactoryImpl.cxx @@ -72,7 +72,7 @@ void configureConstrainedGammas(RooArgList const &gammas, std::span(nullptr), HistFactory) + oocxcoutW(nullptr, HistFactory) << "Warning: relative sigma " << sigmaRel << " for \"" << gamma.GetName() << "\" falls below threshold of " << minSigma << ". Setting: " << gamma.GetName() << " to constant" << std::endl; gamma.setConstant(true); @@ -102,7 +102,7 @@ CreateGammaConstraintsOutput createGammaConstraints(RooArgList const ¶mSet, RooRealVar &gamma = static_cast(paramSet[i]); - oocxcoutI(static_cast(nullptr), HistFactory) + oocxcoutI(nullptr, HistFactory) << "Creating constraint for: " << gamma.GetName() << ". Type of constraint: " << type << std::endl; const double sigmaRel = relSigmas[i]; @@ -110,7 +110,7 @@ CreateGammaConstraintsOutput createGammaConstraints(RooArgList const ¶mSet, // If the sigma is <= 0, // do cont create the term if (sigmaRel <= 0) { - oocxcoutI(static_cast(nullptr), HistFactory) + oocxcoutI(nullptr, HistFactory) << "Not creating constraint term for " << gamma.GetName() << " because sigma = " << sigmaRel << " (sigma<=0)" << " (bin number = " << i << ")" << std::endl; diff --git a/roofit/histfactory/src/HistoToWorkspaceFactoryFast.cxx b/roofit/histfactory/src/HistoToWorkspaceFactoryFast.cxx index 0f33f29acb7f0..181c722e5e4e0 100644 --- a/roofit/histfactory/src/HistoToWorkspaceFactoryFast.cxx +++ b/roofit/histfactory/src/HistoToWorkspaceFactoryFast.cxx @@ -161,7 +161,7 @@ namespace HistFactory{ throw hf_exc(); } if(!measurement.GetPOIList().empty()){ - proto_config->GuessObsAndNuisance(*expData, RooMsgService::instance().isActive(static_cast(nullptr), RooFit::HistFactory, RooFit::INFO)); + proto_config->GuessObsAndNuisance(*expData, RooMsgService::instance().isActive(nullptr, RooFit::HistFactory, RooFit::INFO)); } // Now, let's loop over any additional asimov datasets @@ -534,7 +534,7 @@ RooArgList HistoToWorkspaceFactoryFast::createObservables(const TH1 *hist, RooWo // build the gamma parameter k = as y_s + 1 RooAbsArg * kappa = factory(proto, "sum::k_%s(%s,1.)",name,yvar->GetName()); RooAbsArg * gamma = factory(proto, "Gamma::%sConstraint(%s, %s, %s, 0.0)",beta->GetName(),beta->GetName(), kappa->GetName(), theta->GetName()); - if (RooMsgService::instance().isActive(static_cast(nullptr), RooFit::HistFactory, RooFit::DEBUG)) { + if (RooMsgService::instance().isActive(nullptr, RooFit::HistFactory, RooFit::DEBUG)) { alphaOfBeta->Print("t"); gamma->Print("t"); } @@ -578,7 +578,7 @@ RooArgList HistoToWorkspaceFactoryFast::createObservables(const TH1 *hist, RooWo tauName.c_str(),kappaName.c_str(),alphaName); cxcoutI(HistFactory) << "Added a log-normal constraint for " << name << std::endl; - if (RooMsgService::instance().isActive(static_cast(nullptr), RooFit::HistFactory, RooFit::DEBUG)) + if (RooMsgService::instance().isActive(nullptr, RooFit::HistFactory, RooFit::DEBUG)) alphaOfBeta->Print("t"); params.add(*alphaOfBeta); } @@ -1331,8 +1331,8 @@ RooArgList HistoToWorkspaceFactoryFast::createObservables(const TH1 *hist, RooWo // New Asimov Generation: Use the code in the Asymptotic calculator // Need to get the ModelConfig... int asymcalcPrintLevel = 0; - if (RooMsgService::instance().isActive(static_cast(nullptr), RooFit::HistFactory, RooFit::INFO)) asymcalcPrintLevel = 1; - if (RooMsgService::instance().isActive(static_cast(nullptr), RooFit::HistFactory, RooFit::DEBUG)) asymcalcPrintLevel = 2; + if (RooMsgService::instance().isActive(nullptr, RooFit::HistFactory, RooFit::INFO)) asymcalcPrintLevel = 1; + if (RooMsgService::instance().isActive(nullptr, RooFit::HistFactory, RooFit::DEBUG)) asymcalcPrintLevel = 2; AsymptoticCalculator::SetPrintLevel(asymcalcPrintLevel); unique_ptr asimov_dataset(AsymptoticCalculator::GenerateAsimovData(*model, observables)); proto.import(*asimov_dataset, RooFit::Rename("asimovData")); @@ -1369,7 +1369,7 @@ RooArgList HistoToWorkspaceFactoryFast::createObservables(const TH1 *hist, RooWo } - if (RooMsgService::instance().isActive(static_cast(nullptr), RooFit::HistFactory, RooFit::INFO)) { + if (RooMsgService::instance().isActive(nullptr, RooFit::HistFactory, RooFit::INFO)) { proto.Print(); } @@ -1529,7 +1529,7 @@ RooArgList HistoToWorkspaceFactoryFast::createObservables(const TH1 *hist, RooWo } - if (RooMsgService::instance().isActive(static_cast(nullptr), RooFit::HistFactory, RooFit::INFO)) + if (RooMsgService::instance().isActive(nullptr, RooFit::HistFactory, RooFit::INFO)) combined->Print(); cxcoutP(HistFactory) << "\n-----------------------------------------\n" diff --git a/roofit/histfactory/src/MakeModelAndMeasurementsFast.cxx b/roofit/histfactory/src/MakeModelAndMeasurementsFast.cxx index 311ec51ef15fe..5333a32cef895 100644 --- a/roofit/histfactory/src/MakeModelAndMeasurementsFast.cxx +++ b/roofit/histfactory/src/MakeModelAndMeasurementsFast.cxx @@ -316,7 +316,7 @@ void RooStats::HistFactory::FitModelAndPlot(const std::string &MeasurementName, cxcoutPHF << "\n---------------" << "\nDoing "<< channel << " Fit" << "\n---------------\n\n" << std::endl; - const int printLevel = RooMsgService::instance().isActive(static_cast(nullptr), RooFit::HistFactory, RooFit::DEBUG) ? 1 : -1; + const int printLevel = RooMsgService::instance().isActive(nullptr, RooFit::HistFactory, RooFit::DEBUG) ? 1 : -1; model->fitTo(*simData, Minos(true), PrintLevel(printLevel)); // If there are no parameters of interest, diff --git a/roofit/histfactory/src/RooBarlowBeestonLL.cxx b/roofit/histfactory/src/RooBarlowBeestonLL.cxx index cb831bff5f25b..86ee6dae097f8 100644 --- a/roofit/histfactory/src/RooBarlowBeestonLL.cxx +++ b/roofit/histfactory/src/RooBarlowBeestonLL.cxx @@ -48,10 +48,9 @@ ClassImp(RooStats::HistFactory::RooBarlowBeestonLL); RooStats::HistFactory::RooBarlowBeestonLL::RooBarlowBeestonLL() : RooAbsReal("RooBarlowBeestonLL","RooBarlowBeestonLL"), - _nll(), + _nll() // _obs("paramOfInterest","Parameters of interest",this), // _par("nuisanceParam","Nuisance parameters",this,false,false), - _pdf(nullptr), _data(nullptr) { // Default constructor // Should only be used by proof. @@ -63,10 +62,9 @@ ClassImp(RooStats::HistFactory::RooBarlowBeestonLL); RooStats::HistFactory::RooBarlowBeestonLL::RooBarlowBeestonLL(const char *name, const char *title, RooAbsReal& nllIn /*, const RooArgSet& observables*/) : RooAbsReal(name,title), - _nll("input","-log(L) function",this,nllIn), + _nll("input","-log(L) function",this,nllIn) // _obs("paramOfInterest","Parameters of interest",this), // _par("nuisanceParam","Nuisance parameters",this,false,false), - _pdf(nullptr), _data(nullptr) { // Constructor of profile likelihood given input likelihood nll w.r.t // the given set of variables. The input log likelihood is minimized w.r.t @@ -92,7 +90,6 @@ RooStats::HistFactory::RooBarlowBeestonLL::RooBarlowBeestonLL(const RooBarlowBee _nll("nll",this,other._nll), // _obs("obs",this,other._obs), // _par("par",this,other._par), - _pdf(nullptr), _data(nullptr), _paramFixed(other._paramFixed) { // Copy constructor diff --git a/roofit/multiprocess/src/JobManager.cxx b/roofit/multiprocess/src/JobManager.cxx index ae9b9808b65cc..c84a40d41aebf 100644 --- a/roofit/multiprocess/src/JobManager.cxx +++ b/roofit/multiprocess/src/JobManager.cxx @@ -102,9 +102,9 @@ JobManager::~JobManager() // and led to assertion failures, which left the Messenger and ProcessManager // objects intact, leading to the forked processes and their ZeroMQ resources // to remain after exiting the main/master/parent process. - messenger_ptr_.reset(nullptr); - process_manager_ptr_.reset(nullptr); - queue_ptr_.reset(nullptr); + messenger_ptr_.reset(); + process_manager_ptr_.reset(); + queue_ptr_.reset(); } // static function @@ -138,7 +138,7 @@ bool JobManager::remove_job_object(std::size_t job_object_id) { bool removed_successfully = job_objects_.erase(job_object_id) == 1; if (job_objects_.empty()) { - instance_.reset(nullptr); + instance_.reset(); } return removed_successfully; } diff --git a/roofit/multiprocess/src/Messenger.cxx b/roofit/multiprocess/src/Messenger.cxx index ae430d936ea66..da9d2d5688aab 100644 --- a/roofit/multiprocess/src/Messenger.cxx +++ b/roofit/multiprocess/src/Messenger.cxx @@ -215,10 +215,10 @@ Messenger::~Messenger() { if (close_MQ_on_destruct_) { try { - mq_push_.reset(nullptr); - mq_pull_.reset(nullptr); - mw_pub_.reset(nullptr); - wm_pull_.reset(nullptr); + mq_push_.reset(); + mq_pull_.reset(); + mw_pub_.reset(); + wm_pull_.reset(); // remove bound files for (const auto &address : bound_ipc_addresses_) { // no need to check return value, they are only zero byte /tmp files, the OS should eventually clean them up @@ -230,17 +230,17 @@ Messenger::~Messenger() } } if (close_this_QW_on_destruct_) { - this_worker_qw_push_.reset(nullptr); - this_worker_qw_pull_.reset(nullptr); - mw_sub_.reset(nullptr); - wm_push_.reset(nullptr); + this_worker_qw_push_.reset(); + this_worker_qw_pull_.reset(); + mw_sub_.reset(); + wm_push_.reset(); } if (close_QW_container_on_destruct_) { for (auto &socket : qw_push_) { - socket.reset(nullptr); + socket.reset(); } for (auto &socket : qw_pull_) { - socket.reset(nullptr); + socket.reset(); } } // Dev note: do not call zmqSvc()::close_context from here! The Messenger diff --git a/roofit/roofit/inc/RooChi2MCSModule.h b/roofit/roofit/inc/RooChi2MCSModule.h index 878368df7d340..87c4a8f5e9af0 100644 --- a/roofit/roofit/inc/RooChi2MCSModule.h +++ b/roofit/roofit/inc/RooChi2MCSModule.h @@ -33,11 +33,11 @@ class RooChi2MCSModule : public RooAbsMCStudyModule { private: - RooDataSet* _data ; // Summary dataset to store results - RooRealVar* _chi2 ; // Chi^2 of function w.r.t. data - RooRealVar* _ndof ; // Number of degrees of freedom - RooRealVar* _chi2red ; // Reduced Chi^2 w.r.t data - RooRealVar* _prob ; // Probability of chi^2,nDOF combination + RooDataSet* _data = nullptr; // Summary dataset to store results + RooRealVar* _chi2 = nullptr; // Chi^2 of function w.r.t. data + RooRealVar* _ndof = nullptr; // Number of degrees of freedom + RooRealVar* _chi2red = nullptr; // Reduced Chi^2 w.r.t data + RooRealVar* _prob = nullptr; // Probability of chi^2,nDOF combination ClassDefOverride(RooChi2MCSModule,0) // MCStudy module to calculate chi2 between binned data and fit } ; diff --git a/roofit/roofit/inc/RooFunctorBinding.h b/roofit/roofit/inc/RooFunctorBinding.h index d1ab54a625f03..ecb27ea08f978 100644 --- a/roofit/roofit/inc/RooFunctorBinding.h +++ b/roofit/roofit/inc/RooFunctorBinding.h @@ -30,9 +30,7 @@ RooAbsPdf* bindPdf(const char* name, const ROOT::Math::IBaseFunctionMultiDim& f class RooFunctorBinding : public RooAbsReal { public: - RooFunctorBinding() : func(nullptr), x(nullptr) { - // Default constructor - } ; + RooFunctorBinding() = default; RooFunctorBinding(const char *name, const char *title, const ROOT::Math::IBaseFunctionMultiDim& ftor, const RooArgList& vars); RooFunctorBinding(const RooFunctorBinding& other, const char* name=nullptr) ; TObject* clone(const char* newname) const override { return new RooFunctorBinding(*this,newname); } @@ -43,9 +41,9 @@ class RooFunctorBinding : public RooAbsReal { double evaluate() const override ; - const ROOT::Math::IBaseFunctionMultiDim* func ; // Functor - RooListProxy vars ; // Argument reference - double* x ; // Argument value array + const ROOT::Math::IBaseFunctionMultiDim* func = nullptr; // Functor + RooListProxy vars; // Argument reference + double *x = nullptr; // Argument value array private: @@ -57,9 +55,7 @@ class RooFunctorBinding : public RooAbsReal { class RooFunctorPdfBinding : public RooAbsPdf { public: - RooFunctorPdfBinding() : func(nullptr), x(nullptr) { - // Default constructor - } ; + RooFunctorPdfBinding() = default; RooFunctorPdfBinding(const char *name, const char *title, const ROOT::Math::IBaseFunctionMultiDim& ftor, const RooArgList& vars); RooFunctorPdfBinding(const RooFunctorPdfBinding& other, const char* name=nullptr) ; TObject* clone(const char* newname) const override { return new RooFunctorPdfBinding(*this,newname); } @@ -70,9 +66,9 @@ class RooFunctorPdfBinding : public RooAbsPdf { double evaluate() const override ; - const ROOT::Math::IBaseFunctionMultiDim* func ; // Functor - RooListProxy vars ; // Argument reference - double* x ; // Argument value array + const ROOT::Math::IBaseFunctionMultiDim* func = nullptr; // Functor + RooListProxy vars ; // Argument reference + double *x = nullptr; // Argument value array private: diff --git a/roofit/roofit/inc/RooIntegralMorph.h b/roofit/roofit/inc/RooIntegralMorph.h index ae553bf5249bb..cc18f386f5d4a 100644 --- a/roofit/roofit/inc/RooIntegralMorph.h +++ b/roofit/roofit/inc/RooIntegralMorph.h @@ -25,9 +25,7 @@ class TH1D; class RooIntegralMorph : public RooAbsCachedPdf { public: - RooIntegralMorph() : _cache(nullptr) { - // coverity[UNINIT_CTOR] - } ; + RooIntegralMorph() = default; RooIntegralMorph(const char *name, const char *title, RooAbsReal& _pdf1, RooAbsReal& _pdf2, @@ -102,7 +100,7 @@ class RooIntegralMorph : public RooAbsCachedPdf { RooRealProxy x ; // Observable RooRealProxy alpha ; // Interpolation parameter bool _cacheAlpha ; // If true, both (x,alpha) are cached - mutable MorphCacheElem* _cache ; // Current morph cache element in use + mutable MorphCacheElem* _cache = nullptr; // Current morph cache element in use double evaluate() const override ; diff --git a/roofit/roofit/inc/RooKeysPdf.h b/roofit/roofit/inc/RooKeysPdf.h index 2600a59ede57b..df0e41232e419 100644 --- a/roofit/roofit/inc/RooKeysPdf.h +++ b/roofit/roofit/inc/RooKeysPdf.h @@ -4,8 +4,7 @@ * File: $Id: RooKeysPdf.h,v 1.10 2007/05/11 09:13:07 verkerke Exp $ * Authors: * * GR, Gerhard Raven, UC San Diego, raven@slac.stanford.edu * - * DK, David Kirkby, UC Irvine, dkirkby@uci.edu * - * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu * + * DK, David Kirkby, UC Irvine, dkirkby@uci.edu * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu * * * * Copyright (c) 2000-2005, Regents of the University of California * * and Stanford University. All rights reserved. * @@ -57,19 +56,21 @@ class RooKeysPdf : public RooAbsPdf { // machine precision static const double _nSigma; //! - Int_t _nEvents; - double *_dataPts; //[_nEvents] - double *_dataWgts; //[_nEvents] - double *_weights; //[_nEvents] - double _sumWgt ; + Int_t _nEvents = 0; + double *_dataPts = nullptr; //[_nEvents] + double *_dataWgts = nullptr; //[_nEvents] + double *_weights = nullptr; //[_nEvents] + double _sumWgt = 0.0; constexpr static int _nPoints{1000}; double _lookupTable[_nPoints+1]; double g(double x,double sigma) const; - bool _mirrorLeft, _mirrorRight; - bool _asymLeft, _asymRight; + bool _mirrorLeft = false; + bool _mirrorRight = false; + bool _asymLeft = false; + bool _asymRight = false; // cached info on variable Char_t _varName[128]; diff --git a/roofit/roofit/inc/RooTFnBinding.h b/roofit/roofit/inc/RooTFnBinding.h index 2553771733397..bf0a59645eff5 100644 --- a/roofit/roofit/inc/RooTFnBinding.h +++ b/roofit/roofit/inc/RooTFnBinding.h @@ -15,7 +15,7 @@ class TF3 ; class RooTFnBinding : public RooAbsReal { public: - RooTFnBinding() : _func(nullptr) {} + RooTFnBinding() = default; RooTFnBinding(const char *name, const char *title, TF1* func, const RooArgList& list); RooTFnBinding(const char *name, const char *title, TF1* func, const RooArgList& list, const RooArgList& plist); RooTFnBinding(const RooTFnBinding& other, const char* name=nullptr) ; @@ -31,7 +31,7 @@ class RooTFnBinding : public RooAbsReal { RooListProxy _olist ; RooListProxy _plist ; - TF1* _func ; + TF1* _func = nullptr; double evaluate() const override ; diff --git a/roofit/roofit/inc/RooTFnPdfBinding.h b/roofit/roofit/inc/RooTFnPdfBinding.h index a5c604bf5c72a..d83cb5495f794 100644 --- a/roofit/roofit/inc/RooTFnPdfBinding.h +++ b/roofit/roofit/inc/RooTFnPdfBinding.h @@ -15,7 +15,7 @@ class TF3 ; class RooTFnPdfBinding : public RooAbsPdf { public: - RooTFnPdfBinding() : _func(nullptr) {} + RooTFnPdfBinding() = default; RooTFnPdfBinding(const char *name, const char *title, TF1* func, const RooArgList& list); RooTFnPdfBinding(const RooTFnPdfBinding& other, const char* name=nullptr) ; TObject* clone(const char* newname) const override { return new RooTFnPdfBinding(*this,newname); } @@ -25,7 +25,7 @@ class RooTFnPdfBinding : public RooAbsPdf { protected: RooListProxy _list ; - TF1* _func ; + TF1* _func = nullptr; double evaluate() const override ; diff --git a/roofit/roofit/src/RooChi2MCSModule.cxx b/roofit/roofit/src/RooChi2MCSModule.cxx index f315d7ad1a5a8..d90f3e5ba5934 100644 --- a/roofit/roofit/src/RooChi2MCSModule.cxx +++ b/roofit/roofit/src/RooChi2MCSModule.cxx @@ -42,22 +42,12 @@ ClassImp(RooChi2MCSModule); //////////////////////////////////////////////////////////////////////////////// -RooChi2MCSModule::RooChi2MCSModule() : - RooAbsMCStudyModule("RooChi2MCSModule","RooChi2Module"), - _data(nullptr), _chi2(nullptr), _ndof(nullptr), _chi2red(nullptr), _prob(nullptr) - -{ - // Constructor of module -} +RooChi2MCSModule::RooChi2MCSModule() : RooAbsMCStudyModule("RooChi2MCSModule", "RooChi2Module") {} //////////////////////////////////////////////////////////////////////////////// /// Copy constructor -RooChi2MCSModule::RooChi2MCSModule(const RooChi2MCSModule& other) : - RooAbsMCStudyModule(other), - _data(nullptr), _chi2(nullptr), _ndof(nullptr), _chi2red(nullptr), _prob(nullptr) -{ -} +RooChi2MCSModule::RooChi2MCSModule(const RooChi2MCSModule &other) : RooAbsMCStudyModule(other) {} //////////////////////////////////////////////////////////////////////////////// /// Destructor diff --git a/roofit/roofit/src/RooIntegralMorph.cxx b/roofit/roofit/src/RooIntegralMorph.cxx index cda913c346fb0..c1940fb0ff675 100644 --- a/roofit/roofit/src/RooIntegralMorph.cxx +++ b/roofit/roofit/src/RooIntegralMorph.cxx @@ -109,8 +109,7 @@ RooIntegralMorph::RooIntegralMorph(const char *name, const char *title, pdf2("pdf2","pdf2",this,_pdf2), x("x","x",this,_x), alpha("alpha","alpha",this,_alpha), - _cacheAlpha(doCacheAlpha), - _cache(nullptr) + _cacheAlpha(doCacheAlpha) { } @@ -123,8 +122,7 @@ RooIntegralMorph::RooIntegralMorph(const RooIntegralMorph& other, const char* na pdf2("pdf2",this,other.pdf2), x("x",this,other.x), alpha("alpha",this,other.alpha), - _cacheAlpha(other._cacheAlpha), - _cache(nullptr) + _cacheAlpha(other._cacheAlpha) { } diff --git a/roofit/roofit/src/RooKeysPdf.cxx b/roofit/roofit/src/RooKeysPdf.cxx index 5994551acf78f..35f416375c6cb 100644 --- a/roofit/roofit/src/RooKeysPdf.cxx +++ b/roofit/roofit/src/RooKeysPdf.cxx @@ -54,11 +54,9 @@ const double RooKeysPdf::_nSigma = std::sqrt(-2. * //////////////////////////////////////////////////////////////////////////////// /// coverity[UNINIT_CTOR] - RooKeysPdf::RooKeysPdf() : _nEvents(0), _dataPts(nullptr), _dataWgts(nullptr), _weights(nullptr), _sumWgt(0), - _mirrorLeft(false), _mirrorRight(false), - _asymLeft(false), _asymRight(false) +RooKeysPdf::RooKeysPdf() { - TRACE_CREATE + TRACE_CREATE; } //////////////////////////////////////////////////////////////////////////////// @@ -69,10 +67,6 @@ RooKeysPdf::RooKeysPdf(const char *name, const char *title, Mirror mirror, double rho) : RooAbsPdf(name,title), _x("x","observable",this,x), - _nEvents(0), - _dataPts(nullptr), - _dataWgts(nullptr), - _weights(nullptr), _mirrorLeft(mirror==MirrorLeft || mirror==MirrorBoth || mirror==MirrorLeftAsymRight), _mirrorRight(mirror==MirrorRight || mirror==MirrorBoth || mirror==MirrorAsymLeftRight), _asymLeft(mirror==MirrorAsymLeft || mirror==MirrorAsymLeftRight || mirror==MirrorAsymBoth), @@ -98,10 +92,6 @@ RooKeysPdf::RooKeysPdf(const char *name, const char *title, Mirror mirror, double rho) : RooAbsPdf(name,title), _x("x","Observable",this,xpdf), - _nEvents(0), - _dataPts(nullptr), - _dataWgts(nullptr), - _weights(nullptr), _mirrorLeft(mirror==MirrorLeft || mirror==MirrorBoth || mirror==MirrorLeftAsymRight), _mirrorRight(mirror==MirrorRight || mirror==MirrorBoth || mirror==MirrorAsymLeftRight), _asymLeft(mirror==MirrorAsymLeft || mirror==MirrorAsymLeftRight || mirror==MirrorAsymBoth), @@ -123,7 +113,6 @@ RooKeysPdf::RooKeysPdf(const char *name, const char *title, RooKeysPdf::RooKeysPdf(const RooKeysPdf& other, const char* name): RooAbsPdf(other,name), _x("x",this,other._x), _nEvents(other._nEvents), - _dataPts(nullptr), _dataWgts(nullptr), _weights(nullptr), _sumWgt(0), _mirrorLeft( other._mirrorLeft ), _mirrorRight( other._mirrorRight ), _asymLeft(other._asymLeft), _asymRight(other._asymRight), _rho( other._rho ) { diff --git a/roofit/roofitZMQ/test/test_HWM.cxx b/roofit/roofitZMQ/test/test_HWM.cxx index 69639294d3ea1..a84d56e3d3f23 100644 --- a/roofit/roofitZMQ/test/test_HWM.cxx +++ b/roofit/roofitZMQ/test/test_HWM.cxx @@ -68,10 +68,10 @@ class HighWaterMarkTest : public ::testing::Test { if (-1 == pid) { throw std::runtime_error(std::string("waitpid, errno ") + std::to_string(errno)); } - pusher.reset(nullptr); + pusher.reset(); zmqSvc().close_context(); } else { // child - puller.reset(nullptr); + puller.reset(); zmqSvc().close_context(); _Exit(0); } diff --git a/roofit/roofitZMQ/test/test_ZMQ.cpp b/roofit/roofitZMQ/test/test_ZMQ.cpp index f072d64e9ed44..cbf1f2fba1691 100644 --- a/roofit/roofitZMQ/test/test_ZMQ.cpp +++ b/roofit/roofitZMQ/test/test_ZMQ.cpp @@ -123,7 +123,7 @@ TEST_P(AllSocketTypes, forkHandshake) EXPECT_EQ(receipt, 1212); - socket.reset(nullptr); + socket.reset(); zmqSvc().close_context(); // if you don't close context in parent process as well, the next repeat will hang wait_for_child(child_pid, true, 5); @@ -139,7 +139,7 @@ TEST_P(AllSocketTypes, forkHandshake) } // take care, don't just use _exit, it will not cleanly destroy context etc! // if you really need to, at least close and destroy everything properly - socket.reset(nullptr); + socket.reset(); zmqSvc().close_context(); _Exit(0); } @@ -189,7 +189,7 @@ TEST_P(AsyncSocketTypes, forkMultiSendReceive) EXPECT_ANY_THROW(zmqSvc().send(*socket, std::string("anybody out there?"))); // NOTE: also in case of a throw, be sure to properly close down the connection! // Otherwise, you may get zombies waiting for a reply. - socket.reset(nullptr); + socket.reset(); zmqSvc().close_context(); // if you don't close context in parent process as well, the next repeat will hang wait_for_child(child_pid, true, 5); return; @@ -203,7 +203,7 @@ TEST_P(AsyncSocketTypes, forkMultiSendReceive) zmqSvc().send(*socket, std::string("kthxbye")); - socket.reset(nullptr); + socket.reset(); zmqSvc().close_context(); // if you don't close context in parent process as well, the next repeat will hang wait_for_child(child_pid, true, 5); @@ -218,7 +218,7 @@ TEST_P(AsyncSocketTypes, forkMultiSendReceive) EXPECT_ANY_THROW(zmqSvc().receive(*socket)); // NOTE: also in case of a throw, be sure to properly close down the connection! // Otherwise, you may get zombies waiting for a reply. - socket.reset(nullptr); + socket.reset(); zmqSvc().close_context(); _Exit(0); } else { @@ -235,7 +235,7 @@ TEST_P(AsyncSocketTypes, forkMultiSendReceive) // take care, don't just use _exit, it will not cleanly destroy context etc! // if you really need to, at least close and destroy everything properly - socket.reset(nullptr); + socket.reset(); zmqSvc().close_context(); _Exit(0); } @@ -263,7 +263,7 @@ TEST_P(AsyncSocketTypes, forkIgnoreSomeMessages) EXPECT_ANY_THROW(zmqSvc().send(*socket, std::string("anybody out there?"))); // NOTE: also in case of a throw, be sure to properly close down the connection! // Otherwise, you may get zombies waiting for a reply. - socket.reset(nullptr); + socket.reset(); zmqSvc().close_context(); // if you don't close context in parent process as well, the next repeat will hang wait_for_child(child_pid, true, 5); return; @@ -277,7 +277,7 @@ TEST_P(AsyncSocketTypes, forkIgnoreSomeMessages) zmqSvc().send(*socket, std::string("kthxbye")); - socket.reset(nullptr); + socket.reset(); zmqSvc().close_context(); // if you don't close context in parent process as well, the next repeat will hang wait_for_child(child_pid, true, 5); @@ -300,7 +300,7 @@ TEST_P(AsyncSocketTypes, forkIgnoreSomeMessages) // take care, don't just use _exit, it will not cleanly destroy context etc! // if you really need to, at least close and destroy everything properly - socket.reset(nullptr); + socket.reset(); zmqSvc().close_context(); _Exit(0); } diff --git a/roofit/roofitZMQ/test/test_ZMQ_load_balancing.cxx b/roofit/roofitZMQ/test/test_ZMQ_load_balancing.cxx index aead1d63cf6f2..e75ea22a83139 100644 --- a/roofit/roofitZMQ/test/test_ZMQ_load_balancing.cxx +++ b/roofit/roofitZMQ/test/test_ZMQ_load_balancing.cxx @@ -76,10 +76,10 @@ class ZMQPushPullTest : public ::testing::Test { throw std::runtime_error(std::string("waitpid, errno ") + std::to_string(errno)); } } - pusher.reset(nullptr); + pusher.reset(); zmqSvc().close_context(); } else { // child - puller.reset(nullptr); + puller.reset(); zmqSvc().close_context(); _Exit(0); } diff --git a/roofit/roofitZMQ/test/test_polling.cxx b/roofit/roofitZMQ/test/test_polling.cxx index b832d0b0fae4b..459192da9b281 100644 --- a/roofit/roofitZMQ/test/test_polling.cxx +++ b/roofit/roofitZMQ/test/test_polling.cxx @@ -84,8 +84,8 @@ TEST(Polling, doublePoll) kill(child_pid, SIGTERM); - pusher.reset(nullptr); - puller.reset(nullptr); + pusher.reset(); + puller.reset(); zmqSvc().close_context(); // if you don't close context in parent process as well, the next repeat will hang // wait for child @@ -156,8 +156,8 @@ TEST(Polling, doublePoll) while (!terminated) { } - puller.reset(nullptr); - pusher.reset(nullptr); + puller.reset(); + pusher.reset(); zmqSvc().close_context(); _Exit(0); } diff --git a/roofit/roofitcore/inc/RooAbsGenContext.h b/roofit/roofitcore/inc/RooAbsGenContext.h index 7dfef4a32c7c2..49767f7bd3fb3 100644 --- a/roofit/roofitcore/inc/RooAbsGenContext.h +++ b/roofit/roofitcore/inc/RooAbsGenContext.h @@ -84,7 +84,7 @@ class RooAbsGenContext : public TNamed, public RooPrintable { std::vector _protoOrder ; ///< LUT with traversal order of prototype data TString _normRange ; ///< Normalization range of pdf - RooDataSet* _genData ; /// _boundaries; ///< Boundaries - mutable double* _array; /// _superCat; ///< Supercategory constructed from _data's category variables + std::unique_ptr _catTable; ///< Supercategory table generated from _data ClassDefOverride(RooDataProjBinding,0) // RealFunc/Dataset binding for data projection of a real function }; diff --git a/roofit/roofitcore/inc/RooDerivative.h b/roofit/roofitcore/inc/RooDerivative.h index 40f80b9c41bad..1a5bb655cdf23 100644 --- a/roofit/roofitcore/inc/RooDerivative.h +++ b/roofit/roofitcore/inc/RooDerivative.h @@ -46,13 +46,13 @@ class RooDerivative : public RooAbsReal { protected: - Int_t _order ; ///< Derivation order - double _eps ; ///< Precision - RooSetProxy _nset ; ///< Normalization set (optional) - RooRealProxy _func ; ///< Input function - RooRealProxy _x ; ///< Observable - mutable RooFunctor* _ftor ; ///::min(); // Constructors etc. - inline RooMappedCategory() : _defCat(0), _mapcache(nullptr) { } + inline RooMappedCategory() : _defCat(0) { } RooMappedCategory(const char *name, const char *title, RooAbsCategory& inputCat, const char* defCatName="NotMapped", Int_t defCatIdx=NoCatIdx); RooMappedCategory(const RooMappedCategory& other, const char *name=nullptr) ; TObject* clone(const char* newname) const override { return new RooMappedCategory(*this,newname); } @@ -49,7 +49,7 @@ class RooMappedCategory : public RooAbsCategory { class Entry { public: - inline Entry() : _regexp(nullptr), _catIdx() {} + inline Entry() : _catIdx() {} virtual ~Entry(); Entry(const char* exp, RooAbsCategory::value_type cat); Entry(const Entry& other); @@ -75,7 +75,7 @@ class RooMappedCategory : public RooAbsCategory { value_type _defCat{NoCatIdx}; ///< Default (unmapped) output type RooCategoryProxy _inputCat ; ///< Input category std::map _mapArray ; ///< List of mapping rules - mutable RooMappedCategoryCache* _mapcache; ///(obj)); + } + bool active ; bool universal ; @@ -175,8 +180,13 @@ class RooMsgService : public TObject { inline std::ostream& log(std::nullptr_t, RooFit::MsgLevel level, RooFit::MsgTopic facility, bool forceSkipPrefix=false) { return log(static_cast(nullptr), level, facility, forceSkipPrefix); } - bool isActive(const RooAbsArg* self, RooFit::MsgTopic facility, RooFit::MsgLevel level) ; - bool isActive(const TObject* self, RooFit::MsgTopic facility, RooFit::MsgLevel level) ; + + /// Check if logging is active for given object/topic/RooFit::%MsgLevel combination. + template + bool isActive(T self, RooFit::MsgTopic topic, RooFit::MsgLevel level) + { + return activeStream(self, topic, level) >= 0; + } static Int_t _debugCount ; std::map _levelNames ; @@ -198,8 +208,19 @@ class RooMsgService : public TObject { protected: - Int_t activeStream(const RooAbsArg* self, RooFit::MsgTopic facility, RooFit::MsgLevel level) ; - Int_t activeStream(const TObject* self, RooFit::MsgTopic facility, RooFit::MsgLevel level) ; + /// Find appropriate logging stream for message from given object with given topic and message level. + template + Int_t activeStream(T self, RooFit::MsgTopic topic, RooFit::MsgLevel level) + { + if (level < _globMinLevel) + return -1; + for (UInt_t i = 0; i < _streams.size(); i++) { + if (_streams[i].match(level, topic, self)) { + return i; + } + } + return -1; + } std::vector _streams ; std::stack > _streamsSaved ; diff --git a/roofit/roofitcore/inc/RooResolutionModel.h b/roofit/roofitcore/inc/RooResolutionModel.h index b15cbf0e77e9b..6386a815cf317 100644 --- a/roofit/roofitcore/inc/RooResolutionModel.h +++ b/roofit/roofitcore/inc/RooResolutionModel.h @@ -27,7 +27,7 @@ class RooResolutionModel : public RooAbsPdf { public: // Constructors, assignment etc - inline RooResolutionModel() : _basis(nullptr) { } + inline RooResolutionModel() = default; RooResolutionModel(const char *name, const char *title, RooAbsRealLValue& x) ; RooResolutionModel(const RooResolutionModel& other, const char* name=nullptr); TObject* clone(const char* newname) const override = 0; @@ -75,7 +75,7 @@ class RooResolutionModel : public RooAbsPdf { friend class RooAbsAnaConvPdf ; Int_t _basisCode ; ///< Identifier code for selected basis function - RooFormulaVar* _basis ; ///< Basis function convolved with this resolution model + RooFormulaVar* _basis = nullptr; ///< Basis function convolved with this resolution model bool _ownBasis ; ///< Flag indicating ownership of _basis ClassDefOverride(RooResolutionModel, 2) // Abstract Resolution Model diff --git a/roofit/roofitcore/inc/RooSimultaneous.h b/roofit/roofitcore/inc/RooSimultaneous.h index 9ad75012c5423..84c181290b1f6 100644 --- a/roofit/roofitcore/inc/RooSimultaneous.h +++ b/roofit/roofitcore/inc/RooSimultaneous.h @@ -53,7 +53,7 @@ class RooSimultaneous : public RooAbsPdf { }; // Constructors, assignment etc - inline RooSimultaneous() : _plotCoefNormRange(nullptr), _partIntMgr(this,10) {} + inline RooSimultaneous() : _partIntMgr(this,10) {} RooSimultaneous(const char *name, const char *title, RooAbsCategoryLValue& indexCat) ; RooSimultaneous(const char *name, const char *title, std::map pdfMap, RooAbsCategoryLValue& inIndexCat) ; RooSimultaneous(const char *name, const char *title, const RooArgList& pdfList, RooAbsCategoryLValue& indexCat) ; diff --git a/roofit/roofitcore/inc/RooVectorDataStore.h b/roofit/roofitcore/inc/RooVectorDataStore.h index bd717db735f1e..3ecf1df8d2548 100644 --- a/roofit/roofitcore/inc/RooVectorDataStore.h +++ b/roofit/roofitcore/inc/RooVectorDataStore.h @@ -194,13 +194,12 @@ class RooVectorDataStore : public RooAbsDataStore { class RealVector { public: - RealVector(UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(double))) : - _nativeReal(nullptr), _real(nullptr), _buf(nullptr), _nativeBuf(nullptr), _tracker(nullptr), _nset(nullptr) { + RealVector(UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(double))) { _vec.reserve(initialCapacity); } RealVector(RooAbsReal* arg, UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(double))) : - _nativeReal(arg), _real(nullptr), _buf(nullptr), _nativeBuf(nullptr), _tracker(nullptr), _nset(nullptr) { + _nativeReal(arg) { _vec.reserve(initialCapacity); } @@ -210,7 +209,7 @@ class RooVectorDataStore : public RooAbsDataStore { } RealVector(const RealVector& other, RooAbsReal* real=nullptr) : - _vec(other._vec), _nativeReal(real?real:other._nativeReal), _real(real?real:other._real), _buf(other._buf), _nativeBuf(other._nativeBuf), _nset(nullptr) { + _vec(other._vec), _nativeReal(real?real:other._nativeReal), _real(real?real:other._real), _buf(other._buf), _nativeBuf(other._nativeBuf) { if (other._tracker) { _tracker = new RooChangeTracker(Form("track_%s",_nativeReal->GetName()),"tracker",other._tracker->parameters()) ; } else { @@ -328,12 +327,12 @@ class RooVectorDataStore : public RooAbsDataStore { private: friend class RooVectorDataStore ; - RooAbsReal* _nativeReal ; ///< Instance which our data belongs to. This is the variable in the dataset. - RooAbsReal* _real ; ///< Instance where we should write data into when load() is called. - double* _buf ; /// _vec; ClassDef(CatVector,2) // STL-vector-based Data Storage class } ; diff --git a/roofit/roofitcore/src/BidirMMapPipe.h b/roofit/roofitcore/src/BidirMMapPipe.h index 959490b55d4b7..b04abc31294f1 100644 --- a/roofit/roofitcore/src/BidirMMapPipe.h +++ b/roofit/roofitcore/src/BidirMMapPipe.h @@ -144,7 +144,7 @@ namespace BidirMMapPipe_impl { } impl; public: /// default constructor - Pages() : m_pimpl(nullptr) { } + Pages() = default; /// destructor ~Pages(); @@ -194,7 +194,7 @@ namespace BidirMMapPipe_impl { friend class BidirMMapPipe_impl::PageChunk; /// pointer to implementation - impl* m_pimpl; + impl* m_pimpl = nullptr; /// constructor Pages(PageChunk* parent, Page* pages, unsigned npg); diff --git a/roofit/roofitcore/src/RooAbsData.cxx b/roofit/roofitcore/src/RooAbsData.cxx index e7a328b1201bd..21f59716d39f8 100644 --- a/roofit/roofitcore/src/RooAbsData.cxx +++ b/roofit/roofitcore/src/RooAbsData.cxx @@ -270,7 +270,7 @@ void RooAbsData::copyGlobalObservables(const RooAbsData& other) { else _globalObservables->clear(); other._globalObservables->snapshot(*_globalObservables); } else { - _globalObservables.reset(nullptr); + _globalObservables.reset(); } } diff --git a/roofit/roofitcore/src/RooAbsGenContext.cxx b/roofit/roofitcore/src/RooAbsGenContext.cxx index a240dfc7e6f80..8f00728712443 100644 --- a/roofit/roofitcore/src/RooAbsGenContext.cxx +++ b/roofit/roofitcore/src/RooAbsGenContext.cxx @@ -51,8 +51,7 @@ RooAbsGenContext::RooAbsGenContext(const RooAbsPdf& model, const RooArgSet &vars TNamed(model), _prototype(prototype), _isValid(true), - _verbose(verbose), - _genData(nullptr) + _verbose(verbose) { // Check PDF dependents if (model.recursiveCheckObservables(&vars)) { diff --git a/roofit/roofitcore/src/RooAbsNumGenerator.cxx b/roofit/roofitcore/src/RooAbsNumGenerator.cxx index 5a789d3c10218..4c05e2a962889 100644 --- a/roofit/roofitcore/src/RooAbsNumGenerator.cxx +++ b/roofit/roofitcore/src/RooAbsNumGenerator.cxx @@ -50,7 +50,7 @@ RooAbsNumGenerator::RooAbsNumGenerator() = default; /// cloned and so will not be disturbed during the generation process. RooAbsNumGenerator::RooAbsNumGenerator(const RooAbsReal &func, const RooArgSet &genVars, bool verbose, const RooAbsReal* maxFuncVal) : - _funcClone(nullptr), _funcMaxVal(maxFuncVal), _verbose(verbose) + _funcMaxVal(maxFuncVal), _verbose(verbose) { // Clone the function and all nodes that it depends on so that this generator // is independent of any existing objects. diff --git a/roofit/roofitcore/src/RooAbsProxy.cxx b/roofit/roofitcore/src/RooAbsProxy.cxx index e072c4bb70c99..5a5e04f44b698 100644 --- a/roofit/roofitcore/src/RooAbsProxy.cxx +++ b/roofit/roofitcore/src/RooAbsProxy.cxx @@ -31,19 +31,9 @@ of the owning class **/ -using namespace std; - ClassImp(RooAbsProxy); - -//////////////////////////////////////////////////////////////////////////////// -/// Constructor - -RooAbsProxy::RooAbsProxy() : _nset(nullptr) -{ -} - - +RooAbsProxy::RooAbsProxy() = default; //////////////////////////////////////////////////////////////////////////////// /// Copy constructor @@ -67,7 +57,7 @@ void RooAbsProxy::changeNormSet(const RooArgSet* newNormSet) //////////////////////////////////////////////////////////////////////////////// /// Print proxy name -void RooAbsProxy::print(ostream& os, bool /*addContents*/) const +void RooAbsProxy::print(std::ostream& os, bool /*addContents*/) const { - os << name() << endl ; + os << name() << std::endl; } diff --git a/roofit/roofitcore/src/RooAbsStudy.cxx b/roofit/roofitcore/src/RooAbsStudy.cxx index e1833021b6baa..092927768c653 100644 --- a/roofit/roofitcore/src/RooAbsStudy.cxx +++ b/roofit/roofitcore/src/RooAbsStudy.cxx @@ -33,28 +33,24 @@ RooAbsStudy is an abstract base class for RooStudyManager modules using namespace std ; ClassImp(RooAbsStudy); - ; //////////////////////////////////////////////////////////////////////////////// /// Constructor -RooAbsStudy::RooAbsStudy(const char* name, const char* title) : TNamed(name,title), _storeDetails(false), _summaryData(nullptr), _detailData(nullptr), _ownDetailData(true) -{ -} - - +RooAbsStudy::RooAbsStudy(const char *name, const char *title) : TNamed(name, title) {} //////////////////////////////////////////////////////////////////////////////// /// Copy constructor -RooAbsStudy::RooAbsStudy(const RooAbsStudy& other) : TNamed(other), _storeDetails(other._storeDetails), _summaryData(other._summaryData), - _detailData(nullptr), _ownDetailData(other._ownDetailData) +RooAbsStudy::RooAbsStudy(const RooAbsStudy &other) + : TNamed(other), + _storeDetails(other._storeDetails), + _summaryData(other._summaryData), + _ownDetailData(other._ownDetailData) { } - - //////////////////////////////////////////////////////////////////////////////// /// Destructor diff --git a/roofit/roofitcore/src/RooAcceptReject.cxx b/roofit/roofitcore/src/RooAcceptReject.cxx index b97932aa8e93c..412f256a69894 100644 --- a/roofit/roofitcore/src/RooAcceptReject.cxx +++ b/roofit/roofitcore/src/RooAcceptReject.cxx @@ -178,7 +178,7 @@ const RooArgSet *RooAcceptReject::generateEvent(UInt_t remaining, double& resamp while(nullptr == event) { // Use any cached events first if (_maxFuncVal>oldMax2) { - oocxcoutD(static_cast(nullptr), Generation) << "RooAcceptReject::generateEvent maxFuncVal has changed, need to resample already accepted events by factor" + oocxcoutD(nullptr, Generation) << "RooAcceptReject::generateEvent maxFuncVal has changed, need to resample already accepted events by factor" << oldMax2 << "/" << _maxFuncVal << "=" << oldMax2/_maxFuncVal << endl ; resampleRatio=oldMax2/_maxFuncVal ; } @@ -197,12 +197,12 @@ const RooArgSet *RooAcceptReject::generateEvent(UInt_t remaining, double& resamp double eff= _funcSum/(_totalEvents*_maxFuncVal); Long64_t extra= 1 + (Long64_t)(1.05*remaining/eff); - oocxcoutD(static_cast(nullptr), Generation) << "RooAcceptReject::generateEvent: adding " << extra << " events to the cache, eff = " << eff << endl; + oocxcoutD(nullptr, Generation) << "RooAcceptReject::generateEvent: adding " << extra << " events to the cache, eff = " << eff << endl; double oldMax(_maxFuncVal); while(extra--) { addEventToCache(); if((_maxFuncVal > oldMax)) { - oocxcoutD(static_cast(nullptr), Generation) << "RooAcceptReject::generateEvent: estimated function maximum increased from " + oocxcoutD(nullptr, Generation) << "RooAcceptReject::generateEvent: estimated function maximum increased from " << oldMax << " to " << _maxFuncVal << endl; oldMax = _maxFuncVal ; // Trim cache here diff --git a/roofit/roofitcore/src/RooAddModel.cxx b/roofit/roofitcore/src/RooAddModel.cxx index fdc55bdd20006..496ede7ef2291 100644 --- a/roofit/roofitcore/src/RooAddModel.cxx +++ b/roofit/roofitcore/src/RooAddModel.cxx @@ -81,7 +81,6 @@ RooAddModel::RooAddModel() : RooAddModel::RooAddModel(const char *name, const char *title, const RooArgList& inPdfList, const RooArgList& inCoefList, bool ownPdfList) : RooResolutionModel(name,title,(static_cast(inPdfList.at(0)))->convVar()), _refCoefNorm("!refCoefNorm","Reference coefficient normalization set",this,false,false), - _refCoefRangeName(nullptr), _projCacheMgr(this,10), _intCacheMgr(this,10), _codeReg(10), diff --git a/roofit/roofitcore/src/RooArgProxy.cxx b/roofit/roofitcore/src/RooArgProxy.cxx index 77b9d27c6555e..d81b4374dbe50 100644 --- a/roofit/roofitcore/src/RooArgProxy.cxx +++ b/roofit/roofitcore/src/RooArgProxy.cxx @@ -46,7 +46,7 @@ ClassImp(RooArgProxy); RooArgProxy::RooArgProxy(const char* inName, const char* desc, RooAbsArg* owner, bool valueServer, bool shapeServer, bool proxyOwnsArg) : - TNamed(inName,desc), _owner(owner), _arg(nullptr), + TNamed(inName,desc), _owner(owner), _valueServer(valueServer), _shapeServer(shapeServer), _ownArg(proxyOwnsArg) { _owner->registerProxy(*this) ; diff --git a/roofit/roofitcore/src/RooBinning.cxx b/roofit/roofitcore/src/RooBinning.cxx index 60732c35b2b00..dc9b0e6949a89 100644 --- a/roofit/roofitcore/src/RooBinning.cxx +++ b/roofit/roofitcore/src/RooBinning.cxx @@ -49,9 +49,7 @@ ClassImp(RooBinning); /// Constructor for an initially empty binning defining the range [xlo,xhi] RooBinning::RooBinning(double xlo, double xhi, const char* name) : - RooAbsBinning(name), - _xlo(0), _xhi(0), _ownBoundLo(true), _ownBoundHi(true), - _array(nullptr), _blo(0) + RooAbsBinning(name) { setRange(xlo,xhi); } @@ -60,9 +58,7 @@ RooBinning::RooBinning(double xlo, double xhi, const char* name) : /// Constructor for a uniform binning in 'nbins' bins in the range [xlo,xhi] RooBinning::RooBinning(Int_t nbins, double xlo, double xhi, const char* name) : - RooAbsBinning(name), - _xlo(0), _xhi(0), _ownBoundLo(true), _ownBoundHi(true), - _array(nullptr), _blo(0) + RooAbsBinning(name) { _boundaries.reserve(1 + nbins); setRange(xlo, xhi); @@ -74,9 +70,7 @@ RooBinning::RooBinning(Int_t nbins, double xlo, double xhi, const char* name) : /// array 'boundaries' RooBinning::RooBinning(Int_t nbins, const double* boundaries, const char* name) : - RooAbsBinning(name), - _xlo(0), _xhi(0), _ownBoundLo(true), _ownBoundHi(true), - _array(nullptr), _blo(0) + RooAbsBinning(name) { // Variable bin size constructor _boundaries.reserve(1 + nbins); @@ -90,7 +84,7 @@ RooBinning::RooBinning(Int_t nbins, const double* boundaries, const char* name) RooBinning::RooBinning(const RooBinning& other, const char* name) : RooAbsBinning(name), _xlo(other._xlo), _xhi(other._xhi), _ownBoundLo(other._ownBoundLo), _ownBoundHi(other._ownBoundHi), - _nbins(other._nbins), _boundaries(other._boundaries), _array(nullptr), + _nbins(other._nbins), _boundaries(other._boundaries), _blo(other._blo) { } diff --git a/roofit/roofitcore/src/RooCustomizer.cxx b/roofit/roofitcore/src/RooCustomizer.cxx index f09674e1bc0d0..c08ef49930d8b 100644 --- a/roofit/roofitcore/src/RooCustomizer.cxx +++ b/roofit/roofitcore/src/RooCustomizer.cxx @@ -251,12 +251,9 @@ RooCustomizer::RooCustomizer(const RooAbsArg& pdf, const char* name) : _owning(false), _name(name), _masterPdf((RooAbsArg*)&pdf), - _masterCat(nullptr), _masterBranchList("masterBranchList"), _masterLeafList("masterLeafList"), - _internalCloneBranchList("cloneBranchList"), - _cloneNodeListAll(nullptr), - _cloneNodeListOwned(nullptr) + _internalCloneBranchList("cloneBranchList") { _cloneBranchList = &_internalCloneBranchList ; @@ -275,19 +272,6 @@ void RooCustomizer::initialize() _masterPdf->branchNodeServerList(&_masterBranchList) ; } - - -//////////////////////////////////////////////////////////////////////////////// -/// Destructor - -RooCustomizer::~RooCustomizer() -{ - -} - - - - //////////////////////////////////////////////////////////////////////////////// /// Split all arguments in 'set' into individualized clones for each /// defined state of 'splitCat'. The 'splitCats' category must be diff --git a/roofit/roofitcore/src/RooDLLSignificanceMCSModule.cxx b/roofit/roofitcore/src/RooDLLSignificanceMCSModule.cxx index e9675181eb33d..51bddabdc3b28 100644 --- a/roofit/roofitcore/src/RooDLLSignificanceMCSModule.cxx +++ b/roofit/roofitcore/src/RooDLLSignificanceMCSModule.cxx @@ -44,8 +44,6 @@ to test that assumption. using namespace std; ClassImp(RooDLLSignificanceMCSModule); - ; - //////////////////////////////////////////////////////////////////////////////// @@ -55,7 +53,7 @@ ClassImp(RooDLLSignificanceMCSModule); RooDLLSignificanceMCSModule::RooDLLSignificanceMCSModule(const RooRealVar& param, double nullHypoValue) : RooAbsMCStudyModule(Form("RooDLLSignificanceMCSModule_%s",param.GetName()),Form("RooDLLSignificanceMCSModule_%s",param.GetName())), _parName(param.GetName()), - _data(nullptr), _nll0h(nullptr), _dll0h(nullptr), _sig0h(nullptr), _nullValue(nullHypoValue) + _nullValue(nullHypoValue) { } @@ -68,7 +66,7 @@ RooDLLSignificanceMCSModule::RooDLLSignificanceMCSModule(const RooRealVar& param RooDLLSignificanceMCSModule::RooDLLSignificanceMCSModule(const char* parName, double nullHypoValue) : RooAbsMCStudyModule(Form("RooDLLSignificanceMCSModule_%s",parName),Form("RooDLLSignificanceMCSModule_%s",parName)), _parName(parName), - _data(nullptr), _nll0h(nullptr), _dll0h(nullptr), _sig0h(nullptr), _nullValue(nullHypoValue) + _nullValue(nullHypoValue) { } @@ -80,7 +78,7 @@ RooDLLSignificanceMCSModule::RooDLLSignificanceMCSModule(const char* parName, do RooDLLSignificanceMCSModule::RooDLLSignificanceMCSModule(const RooDLLSignificanceMCSModule& other) : RooAbsMCStudyModule(other), _parName(other._parName), - _data(nullptr), _nll0h(nullptr), _dll0h(nullptr), _sig0h(nullptr), _nullValue(other._nullValue) + _nullValue(other._nullValue) { } diff --git a/roofit/roofitcore/src/RooDataProjBinding.cxx b/roofit/roofitcore/src/RooDataProjBinding.cxx index 32803cc267edb..c199e7126f6c1 100644 --- a/roofit/roofitcore/src/RooDataProjBinding.cxx +++ b/roofit/roofitcore/src/RooDataProjBinding.cxx @@ -44,8 +44,6 @@ constructed from all the categories in the dataset using namespace std; ClassImp(RooDataProjBinding); -; - //////////////////////////////////////////////////////////////////////////////// /// Constructor of a data weighted average function binding with @@ -54,8 +52,7 @@ ClassImp(RooDataProjBinding); RooDataProjBinding::RooDataProjBinding(const RooAbsReal &real, const RooAbsData& data, const RooArgSet &vars, const RooArgSet* nset) : - RooRealBinding(real,vars,nullptr), _first(true), _real(&real), _data(&data), _nset(nset), - _superCat(nullptr), _catTable(nullptr) + RooRealBinding(real,vars,nullptr), _first(true), _real(&real), _data(&data), _nset(nset) { // Determine if dataset contains only categories bool allCat(true) ; @@ -65,23 +62,12 @@ RooDataProjBinding::RooDataProjBinding(const RooAbsReal &real, const RooAbsData& // Determine weights of various super categories fractions if (allCat) { - _superCat = new RooSuperCategory("superCat","superCat",*data.get()) ; - _catTable = data.table(*_superCat) ; + _superCat = std::make_unique("superCat","superCat",*data.get()) ; + _catTable = std::unique_ptr{data.table(*_superCat)}; } } - - -//////////////////////////////////////////////////////////////////////////////// -/// Destructor, delete owned objects - -RooDataProjBinding::~RooDataProjBinding() -{ - if (_superCat) delete _superCat ; - if (_catTable) delete _catTable ; -} - - +RooDataProjBinding::~RooDataProjBinding() = default; //////////////////////////////////////////////////////////////////////////////// /// Evaluate data-projected values of the bound real function. diff --git a/roofit/roofitcore/src/RooDataSet.cxx b/roofit/roofitcore/src/RooDataSet.cxx index 40fc8ebe1d19f..4584dedc97c68 100644 --- a/roofit/roofitcore/src/RooDataSet.cxx +++ b/roofit/roofitcore/src/RooDataSet.cxx @@ -929,7 +929,7 @@ std::span RooDataSet::getWeightBatch(std::size_t first, std::size_ // Treat the sumW2 case with a result buffer, first reset buffer if the // number of entries doesn't match with the dataset anymore - if(_sumW2Buffer && _sumW2Buffer->size() != nEntries) _sumW2Buffer.reset(nullptr); + if(_sumW2Buffer && _sumW2Buffer->size() != nEntries) _sumW2Buffer.reset(); if (!_sumW2Buffer) { _sumW2Buffer = std::make_unique>(); diff --git a/roofit/roofitcore/src/RooDerivative.cxx b/roofit/roofitcore/src/RooDerivative.cxx index f94a057bd77a1..ac452cfb07c57 100644 --- a/roofit/roofitcore/src/RooDerivative.cxx +++ b/roofit/roofitcore/src/RooDerivative.cxx @@ -48,11 +48,7 @@ ClassImp(RooDerivative); //////////////////////////////////////////////////////////////////////////////// /// Default constructor -RooDerivative::RooDerivative() : _order(1), _eps(1e-7), _ftor(nullptr), _rd(nullptr) -{ -} - - +RooDerivative::RooDerivative() = default; //////////////////////////////////////////////////////////////////////////////// @@ -62,9 +58,7 @@ RooDerivative::RooDerivative(const char* name, const char* title, RooAbsReal& fu _eps(epsIn), _nset("nset","nset",this,false,false), _func("function","function",this,func), - _x("x","x",this,x), - _ftor(nullptr), - _rd(nullptr) + _x("x","x",this,x) { if (_order<0 || _order>3 ) { throw std::string(Form("RooDerivative::ctor(%s) ERROR, derivation order must be 1,2 or 3",name)) ; @@ -79,9 +73,7 @@ RooDerivative::RooDerivative(const char* name, const char* title, RooAbsReal& fu _eps(epsIn), _nset("nset","nset",this,false,false), _func("function","function",this,func), - _x("x","x",this,x), - _ftor(nullptr), - _rd(nullptr) + _x("x","x",this,x) { if (_order<0 || _order>3) { throw std::string(Form("RooDerivative::ctor(%s) ERROR, derivation order must be 1,2 or 3",name)) ; @@ -99,9 +91,7 @@ RooDerivative::RooDerivative(const RooDerivative& other, const char* name) : _eps(other._eps), _nset("nset",this,other._nset), _func("function",this,other._func), - _x("x",this,other._x), - _ftor(nullptr), - _rd(nullptr) + _x("x",this,other._x) { } diff --git a/roofit/roofitcore/src/RooFit/Evaluator.cxx b/roofit/roofitcore/src/RooFit/Evaluator.cxx index ab39971632c95..93e5bb3134b5a 100644 --- a/roofit/roofitcore/src/RooFit/Evaluator.cxx +++ b/roofit/roofitcore/src/RooFit/Evaluator.cxx @@ -64,7 +64,7 @@ void logArchitectureInfo(bool useGPU) // We have to exit early if the message stream is not active. Otherwise it's // possible that this function skips logging because it thinks it has // already logged, but actually it didn't. - if (!RooMsgService::instance().isActive(static_cast(nullptr), RooFit::Fitting, RooFit::INFO)) { + if (!RooMsgService::instance().isActive(nullptr, RooFit::Fitting, RooFit::INFO)) { return; } diff --git a/roofit/roofitcore/src/RooFitResult.cxx b/roofit/roofitcore/src/RooFitResult.cxx index 2c2faf6d75272..b5724ba6e354c 100644 --- a/roofit/roofitcore/src/RooFitResult.cxx +++ b/roofit/roofitcore/src/RooFitResult.cxx @@ -63,11 +63,10 @@ ClassImp(RooFitResult); //////////////////////////////////////////////////////////////////////////////// /// Constructor with name and title -RooFitResult::RooFitResult(const char* name, const char* title) : - TNamed(name,title), _constPars(nullptr), _initPars(nullptr), _finalPars(nullptr), _globalCorr(nullptr), _randomPars(nullptr), _Lt(nullptr), - _CM(nullptr), _VM(nullptr), _GC(nullptr) +RooFitResult::RooFitResult(const char *name, const char *title) : TNamed(name, title) { - if (name) appendToDir(this,true) ; + if (name) + appendToDir(this, true); } @@ -83,12 +82,6 @@ RooFitResult::RooFitResult(const RooFitResult& other) : _numBadNLL(other._numBadNLL), _minNLL(other._minNLL), _edm(other._edm), - _globalCorr(nullptr), - _randomPars(nullptr), - _Lt(nullptr), - _CM(nullptr), - _VM(nullptr), - _GC(nullptr), _statusHistory(other._statusHistory) { _constPars = new RooArgList; diff --git a/roofit/roofitcore/src/RooFoamGenerator.h b/roofit/roofitcore/src/RooFoamGenerator.h index d64c512e547c8..2fccbd11fa391 100644 --- a/roofit/roofitcore/src/RooFoamGenerator.h +++ b/roofit/roofitcore/src/RooFoamGenerator.h @@ -30,7 +30,7 @@ class RooNumGenFactory ; class RooFoamGenerator : public RooAbsNumGenerator { public: - RooFoamGenerator() : _binding(nullptr), _tfoam(nullptr), _xmin(nullptr), _range(nullptr), _vec(nullptr) {} + RooFoamGenerator() = default; RooFoamGenerator(const RooAbsReal &func, const RooArgSet &genVars, const RooNumGenConfig& config, bool verbose=false, const RooAbsReal* maxFuncVal=nullptr); RooAbsNumGenerator* clone(const RooAbsReal& func, const RooArgSet& genVars, const RooArgSet& /*condVars*/, const RooNumGenConfig& config, bool verbose=false, const RooAbsReal* maxFuncVal=nullptr) const override { @@ -52,11 +52,11 @@ class RooFoamGenerator : public RooAbsNumGenerator { friend class RooNumGenFactory ; static void registerSampler(RooNumGenFactory& fact) ; - RooTFoamBinding* _binding ; ///< Binding of RooAbsReal to TFoam function interface - TFoam* _tfoam ; ///< Instance of TFOAM generator - double* _xmin ; ///< Lower bound of observables to be generated ; - double* _range ; ///< Range of observables to be generated ; - double* _vec ; ///< Transfer array for FOAM output + RooTFoamBinding *_binding = nullptr; ///< Binding of RooAbsReal to TFoam function interface + TFoam *_tfoam = nullptr; ///< Instance of TFOAM generator + double *_xmin = nullptr; ///< Lower bound of observables to be generated ; + double *_range = nullptr; ///< Range of observables to be generated ; + double *_vec = nullptr; ///< Transfer array for FOAM output }; #endif diff --git a/roofit/roofitcore/src/RooFormula.cxx b/roofit/roofitcore/src/RooFormula.cxx index e5607c26af6c9..04b013f57fbde 100644 --- a/roofit/roofitcore/src/RooFormula.cxx +++ b/roofit/roofitcore/src/RooFormula.cxx @@ -195,7 +195,7 @@ void replaceVarNamesWithIndexStyle(std::string &formula, RooArgList const &varLi /// the formula expression. RooFormula::RooFormula(const char* name, const char* formula, const RooArgList& varList, bool checkVariables) : - TNamed(name, formula), _tFormula{nullptr} + TNamed(name, formula) { _origList.add(varList); _isCategory = findCategoryServers(_origList); diff --git a/roofit/roofitcore/src/RooLinkedList.cxx b/roofit/roofitcore/src/RooLinkedList.cxx index 80b6bb6571668..09490ab41f7ab 100644 --- a/roofit/roofitcore/src/RooLinkedList.cxx +++ b/roofit/roofitcore/src/RooLinkedList.cxx @@ -341,8 +341,8 @@ void RooLinkedList::setHashTableSize(Int_t size) return ; } else { // Remove existing hash table - _htableName.reset(nullptr); - _htableLink.reset(nullptr); + _htableName.reset(); + _htableLink.reset(); } } else { @@ -368,8 +368,8 @@ RooLinkedList::~RooLinkedList() // Required since we overload TObject::Hash. ROOT::CallRecursiveRemoveIfNeeded(*this); - _htableName.reset(nullptr); - _htableLink.reset(nullptr); + _htableName.reset(); + _htableLink.reset(); Clear() ; if (_pool->release()) { diff --git a/roofit/roofitcore/src/RooMsgService.cxx b/roofit/roofitcore/src/RooMsgService.cxx index d75d3b4dd4d76..0c5de945cb3ea 100644 --- a/roofit/roofitcore/src/RooMsgService.cxx +++ b/roofit/roofitcore/src/RooMsgService.cxx @@ -370,55 +370,6 @@ void RooMsgService::restoreState() } - -//////////////////////////////////////////////////////////////////////////////// -/// Check if logging is active for given object/topic/RooFit::%MsgLevel combination - -bool RooMsgService::isActive(const RooAbsArg* self, RooFit::MsgTopic topic, RooFit::MsgLevel level) -{ - return (activeStream(self,topic,level)>=0) ; -} - - -//////////////////////////////////////////////////////////////////////////////// -/// Check if logging is active for given object/topic/RooFit::%MsgLevel combination - -bool RooMsgService::isActive(const TObject* self, RooFit::MsgTopic topic, RooFit::MsgLevel level) -{ - return (activeStream(self,topic,level)>=0) ; -} - - -//////////////////////////////////////////////////////////////////////////////// -/// Find appropriate logging stream for message from given object with given topic and message level - -Int_t RooMsgService::activeStream(const RooAbsArg* self, RooFit::MsgTopic topic, RooFit::MsgLevel level) -{ - if (level<_globMinLevel) return -1 ; - for (UInt_t i=0 ; i<_streams.size() ; i++) { - if (_streams[i].match(level,topic,self)) { - return i ; - } - } - return -1 ; -} - - -//////////////////////////////////////////////////////////////////////////////// -/// Find appropriate logging stream for message from given object with given topic and message level - -Int_t RooMsgService::activeStream(const TObject* self, RooFit::MsgTopic topic, RooFit::MsgLevel level) -{ - if (level<_globMinLevel) return -1 ; - for (UInt_t i=0 ; i<_streams.size() ; i++) { - if (_streams[i].match(level,topic,self)) { - return i ; - } - } - return -1 ; -} - - //////////////////////////////////////////////////////////////////////////////// /// Determine if message from given object at given level on given topic is logged diff --git a/roofit/roofitcore/src/RooProfileLL.cxx b/roofit/roofitcore/src/RooProfileLL.cxx index 660867d6628d4..32412a859b1bd 100644 --- a/roofit/roofitcore/src/RooProfileLL.cxx +++ b/roofit/roofitcore/src/RooProfileLL.cxx @@ -273,7 +273,7 @@ void RooProfileLL::validateAbsMin() const bool RooProfileLL::redirectServersHook(const RooAbsCollection& newServerList, bool mustReplaceAll, bool nameChange, bool isRecursive) { - _minimizer.reset(nullptr); + _minimizer.reset(); return RooAbsReal::redirectServersHook(newServerList, mustReplaceAll, nameChange, isRecursive); } diff --git a/roofit/roostats/inc/RooStats/SamplingDistPlot.h b/roofit/roostats/inc/RooStats/SamplingDistPlot.h index d89b20d9e72a2..fc5da3bcda5e6 100644 --- a/roofit/roostats/inc/RooStats/SamplingDistPlot.h +++ b/roofit/roostats/inc/RooStats/SamplingDistPlot.h @@ -20,6 +20,7 @@ #include "TLegend.h" #include "TList.h" +#include #include #include "RooStats/SamplingDistribution.h" @@ -103,29 +104,32 @@ namespace RooStats { std::vector fSamplingDistr; std::vector fSampleWeights; - bool fIsWeighted; + bool fIsWeighted = false; Int_t fBins; - Int_t fMarkerType; - Int_t fColor; + Int_t fMarkerType = 20; + Int_t fColor = 1; TString fVarName; protected: - TH1F* fHist; - TLegend *fLegend; + TH1F* fHist = nullptr; + TLegend *fLegend = nullptr; TList fItems; ///< holds TH1Fs only TList fOtherItems; ///< other objects to be drawn like TLine etc. - RooPlot* fRooPlot; - bool fLogXaxis; - bool fLogYaxis; + RooPlot* fRooPlot = nullptr; + bool fLogXaxis = false; + bool fLogYaxis = false; - double fXMin, fXMax, fYMin, fYMax; + double fXMin = std::numeric_limits::quiet_NaN(); + double fXMax = std::numeric_limits::quiet_NaN(); + double fYMin = std::numeric_limits::quiet_NaN(); + double fYMax = std::numeric_limits::quiet_NaN(); - bool fApplyStyle; - Style_t fFillStyle; + bool fApplyStyle = true; + Style_t fFillStyle = 3004; void SetSampleWeights(const SamplingDistribution *samplingDist); diff --git a/roofit/roostats/src/HypoTestInverter.cxx b/roofit/roostats/src/HypoTestInverter.cxx index 5f9a6bebade4b..d369b42757c0a 100644 --- a/roofit/roostats/src/HypoTestInverter.cxx +++ b/roofit/roostats/src/HypoTestInverter.cxx @@ -448,7 +448,7 @@ bool HypoTestInverter::SetTestStatistic(TestStatistic& stat) void HypoTestInverter::Clear() { if (fResults) delete fResults; fResults = nullptr; - fLimitPlot.reset(nullptr); + fLimitPlot.reset(); } //////////////////////////////////////////////////////////////////////////////// diff --git a/roofit/roostats/src/SamplingDistPlot.cxx b/roofit/roostats/src/SamplingDistPlot.cxx index 0f88d836a68db..12708944c125d 100644 --- a/roofit/roostats/src/SamplingDistPlot.cxx +++ b/roofit/roostats/src/SamplingDistPlot.cxx @@ -32,10 +32,7 @@ objects. #include "RooMsgService.h" -#include -#define NaN std::numeric_limits::quiet_NaN() #include "TMath.h" -#define IsNaN(a) TMath::IsNaN(a) ClassImp(RooStats::SamplingDistPlot); @@ -45,45 +42,14 @@ using namespace std; //////////////////////////////////////////////////////////////////////////////// /// SamplingDistPlot default constructor with bin size -SamplingDistPlot::SamplingDistPlot(Int_t nbins) : - fHist(nullptr), - fLegend(nullptr), - fItems(), - fOtherItems(), - fRooPlot(nullptr), - fLogXaxis(false), - fLogYaxis(false), - fXMin(NaN), fXMax(NaN), fYMin(NaN), fYMax(NaN), - fApplyStyle(true), - fFillStyle(3004) -{ - fIsWeighted = false; - fBins = nbins; - fMarkerType = 20; - fColor = 1; -} +SamplingDistPlot::SamplingDistPlot(Int_t nbins) : fBins{nbins} {} //////////////////////////////////////////////////////////////////////////////// /// SamplingDistPlot constructor with bin size, min and max -SamplingDistPlot::SamplingDistPlot(Int_t nbins, double min, double max) : - fHist(nullptr), - fLegend(nullptr), - fItems(), - fOtherItems(), - fRooPlot(nullptr), - fLogXaxis(false), - fLogYaxis(false), - fXMin(NaN), fXMax(NaN), fYMin(NaN), fYMax(NaN), - fApplyStyle(true), - fFillStyle(3004) +SamplingDistPlot::SamplingDistPlot(Int_t nbins, double min, double max) : fBins{nbins} { - fIsWeighted = false; - fBins = nbins; - fMarkerType = 20; - fColor = 1; - - SetXRange( min, max ); + SetXRange(min, max); } //////////////////////////////////////////////////////////////////////////////// @@ -133,8 +99,8 @@ double SamplingDistPlot::AddSamplingDistribution(const SamplingDistribution *sam double binWidth = (xmax-xmin)/(fBins); double xlow = xmin - 1.5*binWidth; double xup = xmax + 1.5*binWidth; - if( !IsNaN(fXMin) ) xlow = fXMin; - if( !IsNaN(fXMax) ) xup = fXMax; + if( !TMath::IsNaN(fXMin) ) xlow = fXMin; + if( !TMath::IsNaN(fXMax) ) xup = fXMax; fHist = new TH1F(samplingDist->GetName(), samplingDist->GetTitle(), fBins, xlow, xup); fHist->SetDirectory(nullptr); // make the object managed by this class @@ -296,12 +262,12 @@ void SamplingDistPlot::addOtherObject(TObject *obj, Option_t *drawOptions) void SamplingDistPlot::Draw(Option_t * /*options */) { ApplyDefaultStyle(); - double theMin(0.), theMax(0.), theYMin(NaN), theYMax(0.); + double theMin(0.), theMax(0.), theYMin(std::numeric_limits::quiet_NaN()), theYMax(0.); GetAbsoluteInterval(theMin, theMax, theYMax); - if( !IsNaN(fXMin) ) theMin = fXMin; - if( !IsNaN(fXMax) ) theMax = fXMax; - if( !IsNaN(fYMin) ) theYMin = fYMin; - if( !IsNaN(fYMax) ) theYMax = fYMax; + if( !TMath::IsNaN(fXMin) ) theMin = fXMin; + if( !TMath::IsNaN(fXMax) ) theMax = fXMax; + if( !TMath::IsNaN(fYMin) ) theYMin = fYMin; + if( !TMath::IsNaN(fYMax) ) theYMax = fYMax; RooRealVar xaxis("xaxis", fVarName.Data(), theMin, theMax); @@ -318,11 +284,11 @@ void SamplingDistPlot::Draw(Option_t * /*options */) { return; } fRooPlot->SetTitle(""); - if( !IsNaN(theYMax) ) { + if( !TMath::IsNaN(theYMax) ) { //coutI(InputArguments) << "Setting maximum to " << theYMax << endl; fRooPlot->SetMaximum(theYMax); } - if( !IsNaN(theYMin) ) { + if( !TMath::IsNaN(theYMin) ) { //coutI(InputArguments) << "Setting minimum to " << theYMin << endl; fRooPlot->SetMinimum(theYMin); } @@ -331,11 +297,11 @@ void SamplingDistPlot::Draw(Option_t * /*options */) { //obj->Draw(fIterator->GetOption()); // add cloned objects to avoid mem leaks TH1 * cloneObj = (TH1*)obj->Clone(); - if( !IsNaN(theYMax) ) { + if( !TMath::IsNaN(theYMax) ) { //coutI(InputArguments) << "Setting maximum of TH1 to " << theYMax << endl; cloneObj->SetMaximum(theYMax); } - if( !IsNaN(theYMin) ) { + if( !TMath::IsNaN(theYMin) ) { //coutI(InputArguments) << "Setting minimum of TH1 to " << theYMin << endl; cloneObj->SetMinimum(theYMin); }