Skip to content

Commit cdc4ab4

Browse files
committed
[RF] Code modernization of RooRealIntegral
* replace `getSize()` with `size()` and `empty()` * use smart pointers * rely less on `include namespace std` * move data member initialization to header file * use `operator->` for function proxy instead of `arg()`
1 parent 59a0ecc commit cdc4ab4

File tree

2 files changed

+101
-146
lines changed

2 files changed

+101
-146
lines changed

roofit/roofitcore/inc/RooRealIntegral.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class RooRealIntegral : public RooAbsReal {
5555

5656
RooArgSet intVars() const { RooArgSet tmp(_sumList) ; tmp.add(_intList) ; tmp.add(_anaList) ; tmp.add(_facList) ; return tmp ; }
5757
const char* intRange() { return _rangeName ? _rangeName->GetName() : 0 ; }
58-
const RooAbsReal& integrand() const { return _function.arg() ; }
58+
const RooAbsReal& integrand() const { return *_function; }
5959

6060
void setCacheNumeric(bool flag) {
6161
// If true, value of this integral is cached if it is (partially numeric)
@@ -73,7 +73,7 @@ class RooRealIntegral : public RooAbsReal {
7373

7474
std::list<double>* plotSamplingHint(RooAbsRealLValue& obs, double xlo, double xhi) const override {
7575
// Forward plot sampling hint of integrand
76-
return _function.arg().plotSamplingHint(obs,xlo,xhi) ;
76+
return _function->plotSamplingHint(obs,xlo,xhi) ;
7777
}
7878

7979
RooAbsReal* createIntegral(const RooArgSet& iset, const RooArgSet* nset=nullptr, const RooNumIntConfig* cfg=nullptr, const char* rangeName=nullptr) const override ;
@@ -83,8 +83,8 @@ class RooRealIntegral : public RooAbsReal {
8383

8484
protected:
8585

86-
mutable bool _valid;
87-
bool _respectCompSelect;
86+
mutable bool _valid = false;
87+
bool _respectCompSelect = true;
8888

8989
const RooArgSet& parameters() const ;
9090

@@ -116,27 +116,27 @@ class RooRealIntegral : public RooAbsReal {
116116

117117
mutable RooArgSet _facListOwned ; ///< Owned components in _facList
118118
RooRealProxy _function ; ///<Function being integration
119-
RooArgSet* _funcNormSet ; ///< Optional normalization set passed to function
119+
RooArgSet* _funcNormSet = nullptr; ///< Optional normalization set passed to function
120120

121121
mutable RooArgSet _saveInt ; ///<! do not persist
122122
mutable RooArgSet _saveSum ; ///<! do not persist
123123

124-
RooNumIntConfig* _iconfig ;
124+
RooNumIntConfig* _iconfig = nullptr;
125125

126126
mutable RooListProxy _sumCat ; ///<! do not persist
127127

128-
Int_t _mode ;
129-
IntOperMode _intOperMode ; ///< integration operation mode
128+
Int_t _mode = 0;
129+
IntOperMode _intOperMode = Hybrid; ///< integration operation mode
130130

131-
mutable bool _restartNumIntEngine ; ///<! do not persist
132-
mutable RooAbsIntegrator* _numIntEngine ; ///<! do not persist
133-
mutable RooAbsFunc *_numIntegrand; ///<! do not persist
131+
mutable bool _restartNumIntEngine = false; ///<! do not persist
132+
mutable std::unique_ptr<RooAbsIntegrator> _numIntEngine; ///<! do not persist
133+
mutable std::unique_ptr<RooAbsFunc> _numIntegrand; ///<! do not persist
134134

135-
TNamed* _rangeName ;
135+
TNamed* _rangeName = nullptr;
136136

137-
mutable RooArgSet* _params ; ///<! cache for set of parameters
137+
mutable std::unique_ptr<RooArgSet> _params; ///<! cache for set of parameters
138138

139-
bool _cacheNum ; ///< Cache integral if numeric
139+
bool _cacheNum = false; ///< Cache integral if numeric
140140
static Int_t _cacheAllNDim ; ///<! Cache all integrals with given numeric dimension
141141

142142
ClassDefOverride(RooRealIntegral,3) // Real-valued function representing an integral over a RooAbsReal object

0 commit comments

Comments
 (0)