Skip to content

Commit

Permalink
Use override keyword were necessary
Browse files Browse the repository at this point in the history
To avoid future mistakes when overriding functions, this commit suggests
to use the `override` keyword as suggested by clang-tidy.

How this commit was produced:

1. Compile with CMake, exporting the compile commands as described here:
   https://stackoverflow.com/questions/20059670/how-to-use-cmake-export-compile-commands

2. Build

3. Run this in the build directory:
   ```
   run-clang-tidy -header-filter="interface/.*" -config-file=../.clang-tidy -export-fixes
 fixes.yaml . -j20
   ```

4. Copy the `fixes.yaml` back to the main repo and apply fixes with:
   ```
   clang-apply-replacements .
   ```
  • Loading branch information
guitargeek committed Apr 17, 2024
1 parent 81e8c76 commit 7e85616
Show file tree
Hide file tree
Showing 83 changed files with 695 additions and 689 deletions.
6 changes: 6 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
Checks: -*,
,modernize-use-override,
WarningsAsErrors: '*'
HeaderFilterRegex: ''
...
6 changes: 3 additions & 3 deletions interface/AsymPow.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ class AsymPow : public RooAbsReal {
AsymPow(const char *name, const char *title, RooAbsReal &kappaLow, RooAbsReal &kappaHigh, RooAbsReal &theta) ;
AsymPow(const AsymPow &other, const char *newname=0) ;

~AsymPow() ;
~AsymPow() override ;

TObject * clone(const char *newname) const ;
TObject * clone(const char *newname) const override ;

protected:
Double_t evaluate() const;
Double_t evaluate() const override;

private:
RooRealProxy kappaLow_, kappaHigh_;
Expand Down
8 changes: 4 additions & 4 deletions interface/AsymptoticLimits.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ class RooRealVar;
class AsymptoticLimits : public LimitAlgo {
public:
AsymptoticLimits() ;
virtual void applyOptions(const boost::program_options::variables_map &vm) ;
virtual void applyDefaultOptions() ;
void applyOptions(const boost::program_options::variables_map &vm) override ;
void applyDefaultOptions() override ;

virtual bool run(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint);
bool run(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint) override;
virtual bool runLimit(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint);
std::vector<std::pair<float,float> > runLimitExpected(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint) ;

float findExpectedLimitFromCrossing(RooAbsReal &nll, RooRealVar *r, double rMin, double rMax, double nll0, double quantile) ;

virtual const std::string& name() const { static std::string name_ = "AsymptoticLimits"; return name_; }
const std::string& name() const override { static std::string name_ = "AsymptoticLimits"; return name_; }
private:
static double rAbsAccuracy_, rRelAccuracy_;
static std::string what_;
Expand Down
46 changes: 23 additions & 23 deletions interface/AtlasPdfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ namespace HistFactory{
RooBSplineBases(const char *name, const char *title);
RooBSplineBases(const RooBSplineBases&, const char*);

virtual TObject* clone(const char* newname) const { return new RooBSplineBases(*this, newname); }
virtual ~RooBSplineBases() ;
TObject* clone(const char* newname) const override { return new RooBSplineBases(*this, newname); }
~RooBSplineBases() override ;

/* Double_t getCurvature() const; */

Expand All @@ -62,7 +62,7 @@ namespace HistFactory{
mutable std::vector<double> _t_ary;
mutable std::vector<std::vector<double> > _bin;

Double_t evaluate() const;
Double_t evaluate() const override;

ClassDef(RooStats::HistFactory::RooBSplineBases,1) // Uniform B-Spline
};
Expand Down Expand Up @@ -116,8 +116,8 @@ namespace HistFactory{
RooBSpline(const char *name, const char *title);
RooBSpline(const RooBSpline&, const char*);

virtual TObject* clone(const char* newname) const { return new RooBSpline(*this, newname); }
virtual ~RooBSpline() ;
TObject* clone(const char* newname) const override { return new RooBSpline(*this, newname); }
~RooBSpline() override ;

/* Double_t getCurvature() const; */

Expand All @@ -127,8 +127,8 @@ namespace HistFactory{
void setWeights(const RooArgList& weights);

Bool_t setBinIntegrator(RooArgSet& allVars) ;
Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& analVars, const RooArgSet* normSet,const char* rangeName=0) const ;
Double_t analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=0) const ;
Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& analVars, const RooArgSet* normSet,const char* rangeName=0) const override ;
Double_t analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=0) const override ;

const RooArgList& getControlPoints() const {return _controlPoints;}

Expand All @@ -151,15 +151,15 @@ namespace HistFactory{
// Cache the integrals
class CacheElem : public RooAbsCacheElement {
public:
virtual ~CacheElem();
~CacheElem() override;
// Payload
RooArgList _I ;
virtual RooArgList containedArgs(Action) ;
RooArgList containedArgs(Action) override ;
};
mutable RooObjCacheManager _cacheMgr ; // The cache manager


Double_t evaluate() const;
Double_t evaluate() const override;

ClassDef(RooStats::HistFactory::RooBSpline,2) // Uniform B-Spline
};
Expand Down Expand Up @@ -209,21 +209,21 @@ class RooParamKeysPdf : public RooAbsPdf {
RooDataSet& data, Mirror mirror= NoMirror, Double_t rho=1, Int_t nPoints=1000
);
RooParamKeysPdf(const RooParamKeysPdf& other, const char* name=0);
virtual TObject* clone(const char* newname) const {return new RooParamKeysPdf(*this,newname); }
virtual ~RooParamKeysPdf();
TObject* clone(const char* newname) const override {return new RooParamKeysPdf(*this,newname); }
~RooParamKeysPdf() override;

void LoadDataSet( RooDataSet& data);

Int_t getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* rangeName=0) const ;
Double_t analyticalIntegral(Int_t code, const char* rangeName=0) const ;
Int_t getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* rangeName=0) const override ;
Double_t analyticalIntegral(Int_t code, const char* rangeName=0) const override ;

protected:

RooRealProxy _x ;
RooRealProxy _deltax ;
double _centralValue;
RooRealProxy _multiplicativeShift;
Double_t evaluate() const;
Double_t evaluate() const override;

private:

Expand Down Expand Up @@ -304,15 +304,15 @@ class RooStarMomentMorph : public RooAbsPdf {

RooStarMomentMorph(const RooStarMomentMorph& other, const char* name=0) ;

virtual TObject* clone(const char* newname) const { return new RooStarMomentMorph(*this,newname); }
TObject* clone(const char* newname) const override { return new RooStarMomentMorph(*this,newname); }

virtual ~RooStarMomentMorph();
~RooStarMomentMorph() override;

void setMode(const Setting& setting) { _setting = setting; }

int nnuisSize() { return _nnuis.size(); }

virtual Bool_t selfNormalized() const {
Bool_t selfNormalized() const override {
// P.d.f is self normalized
return kTRUE ;
}
Expand All @@ -325,7 +325,7 @@ class RooStarMomentMorph : public RooAbsPdf {

#if ROOT_VERSION_CODE>=ROOT_VERSION(5,34,15)
void fixCache() { _cacheMgr.setClearOnRedirect(kFALSE) ; }
virtual CacheMode canNodeBeCached() const { return RooAbsArg::NotAdvised ; } ;
CacheMode canNodeBeCached() const override { return RooAbsArg::NotAdvised ; } ;
#endif


Expand All @@ -336,9 +336,9 @@ class RooStarMomentMorph : public RooAbsPdf {
CacheElem(RooAbsPdf& sumPdf, RooChangeTracker& tracker, const RooArgList& flist) : _sumPdf(&sumPdf), _tracker(&tracker), _fractionsCalculated(false) {
_frac.add(flist) ;
} ;
void operModeHook(RooAbsArg::OperMode) {};
virtual ~CacheElem() ;
virtual RooArgList containedArgs(Action) ;
void operModeHook(RooAbsArg::OperMode) override {};
~CacheElem() override ;
RooArgList containedArgs(Action) override ;
RooAbsPdf* _sumPdf ;
RooChangeTracker* _tracker ;
RooArgList _frac ;
Expand All @@ -353,7 +353,7 @@ class RooStarMomentMorph : public RooAbsPdf {

friend class CacheElem ; // Cache needs to be able to clear _norm pointer

Double_t evaluate() const ;
Double_t evaluate() const override ;

void initialize();
CacheElem* getCache(const RooArgSet* nset) const ;
Expand Down
4 changes: 2 additions & 2 deletions interface/BayesianFlatPrior.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
class BayesianFlatPrior : public LimitAlgo {
public:
BayesianFlatPrior() ;
virtual bool run(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint);
virtual const std::string & name() const {
bool run(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint) override;
const std::string & name() const override {
static const std::string name("BayesianSimple");
return name;
}
Expand Down
6 changes: 3 additions & 3 deletions interface/BayesianToyMC.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class RooArgSet;
class BayesianToyMC : public LimitAlgo {
public:
BayesianToyMC() ;
virtual bool run(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint);
bool run(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint) override;
virtual bool runBayesFactor(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint);
virtual void applyOptions(const boost::program_options::variables_map &vm) ;
virtual const std::string & name() const {
void applyOptions(const boost::program_options::variables_map &vm) override ;
const std::string & name() const override {
static const std::string name("BayesianToyMC");
return name;
}
Expand Down
4 changes: 2 additions & 2 deletions interface/BestFitSigmaTestStat.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class BestFitSigmaTestStat : public RooStats::TestStatistic {
const RooArgSet *nuisances,
const RooArgSet & params, int verbosity=0) ;

virtual Double_t Evaluate(RooAbsData& data, RooArgSet& nullPOI) ;
Double_t Evaluate(RooAbsData& data, RooArgSet& nullPOI) override ;

virtual const TString GetVarName() const { return "mu-hat`"; }
const TString GetVarName() const override { return "mu-hat`"; }

// Verbosity (default: 0)
void setPrintLevel(Int_t level) { verbosity_ = level; }
Expand Down
4 changes: 2 additions & 2 deletions interface/CMSExternalMorph.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CMSExternalMorph : public RooAbsReal {
const std::vector<double>& edges
);
CMSExternalMorph(CMSExternalMorph const& other, const char* name = 0);
virtual ~CMSExternalMorph();
~CMSExternalMorph() override;

/* Batch accessor for CMSHistFunc / CMSHistSum, to be overriden by concrete
* implementations. hasChanged() should indicate whether or not
Expand All @@ -36,7 +36,7 @@ class CMSExternalMorph : public RooAbsReal {
RooRealProxy x_;
std::vector<double> edges_;

double evaluate() const;
double evaluate() const override;

private:
ClassDef(CMSExternalMorph, 1)
Expand Down
42 changes: 21 additions & 21 deletions interface/CMSHggFormula.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class CMSHggFormulaA1 : public RooAbsReal {
RooAbsReal & p2, RooAbsReal & p3, RooArgList const& terms,
std::vector<double> const& coeffs);
CMSHggFormulaA1(const CMSHggFormulaA1& other, const char* name = 0);
virtual ~CMSHggFormulaA1() {}
virtual TObject* clone(const char* newname) const { return new CMSHggFormulaA1(*this, newname); }
~CMSHggFormulaA1() override {}
TObject* clone(const char* newname) const override { return new CMSHggFormulaA1(*this, newname); }

protected:
RooRealProxy p0_;
Expand All @@ -23,7 +23,7 @@ class CMSHggFormulaA1 : public RooAbsReal {
RooListProxy terms_;
std::vector<double> coeffs_;
mutable std::vector<RooAbsReal*> vterms_; //! not to be serialized
virtual Double_t evaluate() const;
Double_t evaluate() const override;

private:
ClassDef(CMSHggFormulaA1,1)
Expand All @@ -37,8 +37,8 @@ class CMSHggFormulaA2 : public RooAbsReal {
RooAbsReal & p2, RooAbsReal & p3, RooArgList const& terms,
std::vector<double> const& coeffs);
CMSHggFormulaA2(const CMSHggFormulaA2& other, const char* name = 0);
virtual ~CMSHggFormulaA2() {}
virtual TObject* clone(const char* newname) const { return new CMSHggFormulaA2(*this, newname); }
~CMSHggFormulaA2() override {}
TObject* clone(const char* newname) const override { return new CMSHggFormulaA2(*this, newname); }

protected:
RooRealProxy p0_;
Expand All @@ -48,7 +48,7 @@ class CMSHggFormulaA2 : public RooAbsReal {
RooListProxy terms_;
std::vector<double> coeffs_;
mutable std::vector<RooAbsReal*> vterms_; //! not to be serialized
virtual Double_t evaluate() const;
Double_t evaluate() const override;

private:
ClassDef(CMSHggFormulaA2,1)
Expand All @@ -61,15 +61,15 @@ class CMSHggFormulaB1 : public RooAbsReal {
CMSHggFormulaB1(const char* name, const char* title, RooAbsReal & p0, RooArgList const& terms,
std::vector<double> const& coeffs);
CMSHggFormulaB1(const CMSHggFormulaB1& other, const char* name = 0);
virtual ~CMSHggFormulaB1() {}
virtual TObject* clone(const char* newname) const { return new CMSHggFormulaB1(*this, newname); }
~CMSHggFormulaB1() override {}
TObject* clone(const char* newname) const override { return new CMSHggFormulaB1(*this, newname); }

protected:
RooRealProxy p0_;
RooListProxy terms_;
std::vector<double> coeffs_;
mutable std::vector<RooAbsReal*> vterms_; //! not to be serialized
virtual Double_t evaluate() const;
Double_t evaluate() const override;

private:
ClassDef(CMSHggFormulaB1,1)
Expand All @@ -82,15 +82,15 @@ class CMSHggFormulaB2 : public RooAbsReal {
CMSHggFormulaB2(const char* name, const char* title, double const& p0, RooArgList const& terms,
std::vector<double> const& coeffs);
CMSHggFormulaB2(const CMSHggFormulaB2& other, const char* name = 0);
virtual ~CMSHggFormulaB2() {}
virtual TObject* clone(const char* newname) const { return new CMSHggFormulaB2(*this, newname); }
~CMSHggFormulaB2() override {}
TObject* clone(const char* newname) const override { return new CMSHggFormulaB2(*this, newname); }

protected:
double p0_;
RooListProxy terms_;
std::vector<double> coeffs_;
mutable std::vector<RooAbsReal*> vterms_; //! not to be serialized
virtual Double_t evaluate() const;
Double_t evaluate() const override;

private:
ClassDef(CMSHggFormulaB2,1)
Expand All @@ -103,14 +103,14 @@ class CMSHggFormulaC1 : public RooAbsReal {
CMSHggFormulaC1(const char* name, const char* title, RooArgList const& terms,
std::vector<double> const& coeffs);
CMSHggFormulaC1(const CMSHggFormulaC1& other, const char* name = 0);
virtual ~CMSHggFormulaC1() {}
virtual TObject* clone(const char* newname) const { return new CMSHggFormulaC1(*this, newname); }
~CMSHggFormulaC1() override {}
TObject* clone(const char* newname) const override { return new CMSHggFormulaC1(*this, newname); }

protected:
RooListProxy terms_;
std::vector<double> coeffs_;
mutable std::vector<RooAbsReal*> vterms_; //! not to be serialized
virtual Double_t evaluate() const;
Double_t evaluate() const override;

private:
ClassDef(CMSHggFormulaC1,1)
Expand All @@ -122,13 +122,13 @@ class CMSHggFormulaD1 : public RooAbsReal {
CMSHggFormulaD1() {}
CMSHggFormulaD1(const char* name, const char* title, RooAbsReal & p0, RooAbsReal & p1);
CMSHggFormulaD1(const CMSHggFormulaD1& other, const char* name = 0);
virtual ~CMSHggFormulaD1() {}
virtual TObject* clone(const char* newname) const { return new CMSHggFormulaD1(*this, newname); }
~CMSHggFormulaD1() override {}
TObject* clone(const char* newname) const override { return new CMSHggFormulaD1(*this, newname); }

protected:
RooRealProxy p0_;
RooRealProxy p1_;
virtual Double_t evaluate() const;
Double_t evaluate() const override;

private:
ClassDef(CMSHggFormulaD1,1)
Expand All @@ -140,13 +140,13 @@ class CMSHggFormulaD2 : public RooAbsReal {
CMSHggFormulaD2() {}
CMSHggFormulaD2(const char* name, const char* title, RooAbsReal & p0, double const& p1);
CMSHggFormulaD2(const CMSHggFormulaD2& other, const char* name = 0);
virtual ~CMSHggFormulaD2() {}
virtual TObject* clone(const char* newname) const { return new CMSHggFormulaD2(*this, newname); }
~CMSHggFormulaD2() override {}
TObject* clone(const char* newname) const override { return new CMSHggFormulaD2(*this, newname); }

protected:
RooRealProxy p0_;
double p1_;
virtual Double_t evaluate() const;
Double_t evaluate() const override;

private:
ClassDef(CMSHggFormulaD2,1)
Expand Down
Loading

0 comments on commit 7e85616

Please sign in to comment.