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 .
   ```

5. Replace `ClassDef` macros with `ClassDefOverride` to be consistent.
  • Loading branch information
guitargeek committed Apr 18, 2024
1 parent e7f355d commit fa36dd4
Show file tree
Hide file tree
Showing 83 changed files with 838 additions and 832 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: ''
...
8 changes: 4 additions & 4 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 All @@ -40,7 +40,7 @@ class AsymPow : public RooAbsReal {
// get the kappa for the appropriate x
Double_t logKappaForX(Double_t x) const ;

ClassDef(AsymPow,1) // Asymmetric power
ClassDefOverride(AsymPow,1) // Asymmetric power
};

#endif
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
54 changes: 27 additions & 27 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,9 +62,9 @@ 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
ClassDefOverride(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,17 +151,17 @@ 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
ClassDefOverride(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 @@ -251,7 +251,7 @@ class RooParamKeysPdf : public RooAbsPdf {
Double_t _lo, _hi, _binWidth;
Double_t _rho;

ClassDef(RooParamKeysPdf,4) // One-dimensional non-parametric kernel estimation p.d.f.
ClassDefOverride(RooParamKeysPdf,4) // One-dimensional non-parametric kernel estimation p.d.f.
};

#ifdef __CINT__
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 All @@ -379,7 +379,7 @@ class RooStarMomentMorph : public RooAbsPdf {

Bool_t _useHorizMorph;

ClassDef(RooStarMomentMorph,2) // Your description goes here...
ClassDefOverride(RooStarMomentMorph,2) // Your description goes here...
};

#endif
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
6 changes: 3 additions & 3 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,10 +36,10 @@ class CMSExternalMorph : public RooAbsReal {
RooRealProxy x_;
std::vector<double> edges_;

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

private:
ClassDef(CMSExternalMorph, 1)
ClassDefOverride(CMSExternalMorph, 1)
};

#endif // CMSExternalMorph_h
Loading

0 comments on commit fa36dd4

Please sign in to comment.