Skip to content

Commit

Permalink
[RF] More member initialization in class declarations in RooFit
Browse files Browse the repository at this point in the history
  • Loading branch information
guitargeek committed Oct 24, 2023
1 parent a113110 commit 36c8584
Show file tree
Hide file tree
Showing 60 changed files with 247 additions and 416 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string,bool> _paramFixed ; ///< Parameter constant status at last time of use
Expand Down
6 changes: 3 additions & 3 deletions roofit/histfactory/src/HistFactoryImpl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void configureConstrainedGammas(RooArgList const &gammas, std::span<const double
// If the sigma value is less than a supplied threshold, set the variable to
// constant
if (sigmaRel < minSigma) {
oocxcoutW(static_cast<TObject *>(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);
Expand Down Expand Up @@ -102,15 +102,15 @@ CreateGammaConstraintsOutput createGammaConstraints(RooArgList const &paramSet,

RooRealVar &gamma = static_cast<RooRealVar &>(paramSet[i]);

oocxcoutI(static_cast<TObject *>(nullptr), HistFactory)
oocxcoutI(nullptr, HistFactory)
<< "Creating constraint for: " << gamma.GetName() << ". Type of constraint: " << type << std::endl;

const double sigmaRel = relSigmas[i];

// If the sigma is <= 0,
// do cont create the term
if (sigmaRel <= 0) {
oocxcoutI(static_cast<TObject *>(nullptr), HistFactory)
oocxcoutI(nullptr, HistFactory)
<< "Not creating constraint term for " << gamma.GetName() << " because sigma = " << sigmaRel
<< " (sigma<=0)"
<< " (bin number = " << i << ")" << std::endl;
Expand Down
14 changes: 7 additions & 7 deletions roofit/histfactory/src/HistoToWorkspaceFactoryFast.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ namespace HistFactory{
throw hf_exc();
}
if(!measurement.GetPOIList().empty()){
proto_config->GuessObsAndNuisance(*expData, RooMsgService::instance().isActive(static_cast<TObject*>(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
Expand Down Expand Up @@ -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<TObject*>(nullptr), RooFit::HistFactory, RooFit::DEBUG)) {
if (RooMsgService::instance().isActive(nullptr, RooFit::HistFactory, RooFit::DEBUG)) {
alphaOfBeta->Print("t");
gamma->Print("t");
}
Expand Down Expand Up @@ -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<TObject*>(nullptr), RooFit::HistFactory, RooFit::DEBUG))
if (RooMsgService::instance().isActive(nullptr, RooFit::HistFactory, RooFit::DEBUG))
alphaOfBeta->Print("t");
params.add(*alphaOfBeta);
}
Expand Down Expand Up @@ -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<TObject*>(nullptr), RooFit::HistFactory, RooFit::INFO)) asymcalcPrintLevel = 1;
if (RooMsgService::instance().isActive(static_cast<TObject*>(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<RooAbsData> asimov_dataset(AsymptoticCalculator::GenerateAsimovData(*model, observables));
proto.import(*asimov_dataset, RooFit::Rename("asimovData"));
Expand Down Expand Up @@ -1369,7 +1369,7 @@ RooArgList HistoToWorkspaceFactoryFast::createObservables(const TH1 *hist, RooWo

}

if (RooMsgService::instance().isActive(static_cast<TObject*>(nullptr), RooFit::HistFactory, RooFit::INFO)) {
if (RooMsgService::instance().isActive(nullptr, RooFit::HistFactory, RooFit::INFO)) {
proto.Print();
}

Expand Down Expand Up @@ -1529,7 +1529,7 @@ RooArgList HistoToWorkspaceFactoryFast::createObservables(const TH1 *hist, RooWo
}


if (RooMsgService::instance().isActive(static_cast<TObject*>(nullptr), RooFit::HistFactory, RooFit::INFO))
if (RooMsgService::instance().isActive(nullptr, RooFit::HistFactory, RooFit::INFO))
combined->Print();

cxcoutP(HistFactory) << "\n-----------------------------------------\n"
Expand Down
2 changes: 1 addition & 1 deletion roofit/histfactory/src/MakeModelAndMeasurementsFast.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<TObject*>(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,
Expand Down
7 changes: 2 additions & 5 deletions roofit/histfactory/src/RooBarlowBeestonLL.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions roofit/multiprocess/src/JobManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
20 changes: 10 additions & 10 deletions roofit/multiprocess/src/Messenger.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions roofit/roofit/inc/RooChi2MCSModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
} ;
Expand Down
20 changes: 8 additions & 12 deletions roofit/roofit/inc/RooFunctorBinding.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand All @@ -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:
Expand All @@ -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); }
Expand All @@ -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:
Expand Down
6 changes: 2 additions & 4 deletions roofit/roofit/inc/RooIntegralMorph.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 ;
Expand Down
19 changes: 10 additions & 9 deletions roofit/roofit/inc/RooKeysPdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, [email protected] *
* DK, David Kirkby, UC Irvine, [email protected] *
* WV, Wouter Verkerke, UC Santa Barbara, [email protected] *
* DK, David Kirkby, UC Irvine, [email protected] * WV, Wouter Verkerke, UC Santa Barbara, [email protected] *
* *
* Copyright (c) 2000-2005, Regents of the University of California *
* and Stanford University. All rights reserved. *
Expand Down Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions roofit/roofit/inc/RooTFnBinding.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) ;
Expand All @@ -31,7 +31,7 @@ class RooTFnBinding : public RooAbsReal {

RooListProxy _olist ;
RooListProxy _plist ;
TF1* _func ;
TF1* _func = nullptr;

double evaluate() const override ;

Expand Down
4 changes: 2 additions & 2 deletions roofit/roofit/inc/RooTFnPdfBinding.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand All @@ -25,7 +25,7 @@ class RooTFnPdfBinding : public RooAbsPdf {
protected:

RooListProxy _list ;
TF1* _func ;
TF1* _func = nullptr;

double evaluate() const override ;

Expand Down
14 changes: 2 additions & 12 deletions roofit/roofit/src/RooChi2MCSModule.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 36c8584

Please sign in to comment.