diff --git a/interface/AsymQuad.h b/interface/AsymQuad.h index 6c4de6d860e..153f6d5c0fb 100644 --- a/interface/AsymQuad.h +++ b/interface/AsymQuad.h @@ -3,7 +3,6 @@ #include "RooFit.h" #include "Riostream.h" -#include "TIterator.h" #include "TList.h" #include #include "RooRealVar.h" diff --git a/interface/FastTemplateFunc.h b/interface/FastTemplateFunc.h index b7cf2bad56a..e8120a64067 100644 --- a/interface/FastTemplateFunc.h +++ b/interface/FastTemplateFunc.h @@ -19,15 +19,12 @@ template class FastTemplateFunc_t : public RooAbsReal{ virtual inline ~FastTemplateFunc_t(){} void setProxyList(RooListProxy& proxyList, RooArgList& varList){ - TIterator* varIter = varList.createIterator(); - RooAbsArg* var; - while ((var = (RooAbsArg*)varIter->Next())) { + for (RooAbsArg *var : varList) { if (!dynamic_cast(var)) { assert(0); } proxyList.add(*var); } - delete varIter; } virtual TObject* clone(const char* newname) const = 0; diff --git a/interface/ProcessNormalization.h b/interface/ProcessNormalization.h index d99aec236e3..dd09d64525e 100644 --- a/interface/ProcessNormalization.h +++ b/interface/ProcessNormalization.h @@ -1,7 +1,6 @@ #ifndef HiggsAnalysis_CombinedLimit_ProcessNormalization_h #define HiggsAnalysis_CombinedLimit_ProcessNormalization_h -#include #include #include "RooListProxy.h" diff --git a/interface/RooMultiPdf.h b/interface/RooMultiPdf.h index bb7f4176e49..6b196e0245a 100644 --- a/interface/RooMultiPdf.h +++ b/interface/RooMultiPdf.h @@ -17,7 +17,6 @@ #include "RooConstVar.h" -#include "TIterator.h" #include "RooListProxy.h" #include diff --git a/interface/RooRealFlooredSumPdf.h b/interface/RooRealFlooredSumPdf.h index 660fa784c01..882e6fe444c 100755 --- a/interface/RooRealFlooredSumPdf.h +++ b/interface/RooRealFlooredSumPdf.h @@ -80,8 +80,6 @@ class RooRealFlooredSumPdf : public RooAbsPdf { RooListProxy _funcList; // List of component FUNCs RooListProxy _coefList; // List of coefficients - TIterator* _funcIter; //! Iterator over FUNC list - TIterator* _coefIter; //! Iterator over coefficient list Bool_t _extended; // Allow use as extended p.d.f. Bool_t _doFloor; Double_t _floorVal; diff --git a/interface/SimpleCacheSentry.h b/interface/SimpleCacheSentry.h index 28d895298df..4a90b4ba1bc 100644 --- a/interface/SimpleCacheSentry.h +++ b/interface/SimpleCacheSentry.h @@ -3,7 +3,6 @@ #include "RooRealVar.h" #include "RooSetProxy.h" -#include "TIterator.h" class SimpleCacheSentry : public RooAbsArg { public: diff --git a/src/AsimovUtils.cc b/src/AsimovUtils.cc index 3e3a9db1036..8a63df3244d 100644 --- a/src/AsimovUtils.cc +++ b/src/AsimovUtils.cc @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -89,8 +88,7 @@ RooAbsData *asimovutils::asimovDatasetWithFit(RooStats::ModelConfig *mc, RooAbsD std::unique_ptr nuispdf(utils::makeNuisancePdf(*mc)); RooProdPdf *prod = dynamic_cast(nuispdf.get()); if (prod == 0) throw std::runtime_error("AsimovUtils: the nuisance pdf is not a RooProdPdf!"); - std::unique_ptr iter(prod->pdfList().createIterator()); - for (RooAbsArg *a = (RooAbsArg *) iter->Next(); a != 0; a = (RooAbsArg *) iter->Next()) { + for (RooAbsArg *a : prod->pdfList()) { RooAbsPdf *cterm = dynamic_cast(a); if (!cterm) throw std::logic_error("AsimovUtils: a factor of the nuisance pdf is not a Pdf!"); if (!cterm->dependsOn(nuis)) continue; // dummy constraints @@ -106,8 +104,7 @@ RooAbsData *asimovutils::asimovDatasetWithFit(RooStats::ModelConfig *mc, RooAbsD if (cpars->getSize() == 1) { match = dynamic_cast(cpars->first()); } else { - std::unique_ptr iter2(cpars->createIterator()); - for (RooAbsArg *a2 = (RooAbsArg *) iter2->Next(); a2 != 0; a2 = (RooAbsArg *) iter2->Next()) { + for (RooAbsArg *a2 : *cpars) { RooRealVar *rrv2 = dynamic_cast(a2); if (rrv2 != 0 && !rrv2->isConstant()) { if (match != 0) throw std::runtime_error(Form("AsimovUtils: constraint term %s has multiple floating params", cterm->GetName())); @@ -135,10 +132,10 @@ RooAbsData *asimovutils::asimovDatasetWithFit(RooStats::ModelConfig *mc, RooAbsD // we want to set the global obs to a value for which the current value // of the nuisance is the best fit one. // best fit x = (k-1)*theta ----> k = x/theta + 1 - RooArgList leaves; cterm->leafNodeServerList(&leaves); - std::unique_ptr iter2(leaves.createIterator()); + RooArgList leaves; + cterm->leafNodeServerList(&leaves); RooAbsReal *match2 = 0; - for (RooAbsArg *a2 = (RooAbsArg *) iter2->Next(); a2 != 0; a2 = (RooAbsArg *) iter2->Next()) { + for (RooAbsArg *a2 : leaves) { RooAbsReal *rar = dynamic_cast(a2); if (rar == 0 || rar == match || rar == &rrv) continue; if (!rar->isConstant()) throw std::runtime_error(Form("AsimovUtils: extra floating parameter %s of RooGamma %s.", rar->GetName(), cterm->GetName())); diff --git a/src/AsymptoticLimits.cc b/src/AsymptoticLimits.cc index 00971c9af09..2aca5a9073b 100644 --- a/src/AsymptoticLimits.cc +++ b/src/AsymptoticLimits.cc @@ -163,8 +163,7 @@ bool AsymptoticLimits::runLimit(RooWorkspace *w, RooStats::ModelConfig *mc_s, Ro if (params_.get() == 0) params_.reset(mc_s->GetPdf()->getParameters(data)); hasFloatParams_ = false; - std::unique_ptr itparam(params_->createIterator()); - for (RooAbsArg *a = (RooAbsArg *) itparam->Next(); a != 0; a = (RooAbsArg *) itparam->Next()) { + for (RooAbsArg *a : *params_) { RooRealVar *rrv = dynamic_cast(a); if ( rrv != 0 && rrv != r && rrv->isConstant() == false ) { hasFloatParams_ = true; break; } } diff --git a/src/CachingNLL.cc b/src/CachingNLL.cc index f699a3ec5bc..638c78d1cf6 100644 --- a/src/CachingNLL.cc +++ b/src/CachingNLL.cc @@ -580,9 +580,8 @@ cacheutils::CachingAddNLL::setup_() throw std::invalid_argument(errmsg); } - std::unique_ptr params(pdf_->getParameters(*data_)); - std::unique_ptr iter(params->createIterator()); - for (RooAbsArg *a = (RooAbsArg *) iter->Next(); a != 0; a = (RooAbsArg *) iter->Next()) { + ; + for (RooAbsArg *a : *std::unique_ptr{pdf_->getParameters(*data_)}) { if (dynamic_cast(a)) params_.add(*a); else if (dynamic_cast(a)) catParams_.add(*a); } diff --git a/src/Combine.cc b/src/Combine.cc index 3d80b7b6944..d0532569059 100644 --- a/src/Combine.cc +++ b/src/Combine.cc @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -974,8 +973,7 @@ void Combine::run(TString hlfFile, const std::string &dataset, double &limit, do // print the values of the parameters used to generate the toy if (verbose > 2) { Logger::instance().log(std::string(Form("Combine.cc: %d -- Generate Asimov toy from parameter values ... ",__LINE__)),Logger::kLogLevelInfo,__func__); - std::unique_ptr iter(genPdf->getParameters((const RooArgSet*)0)->createIterator()); - for (RooAbsArg *a = (RooAbsArg *) iter->Next(); a != 0; a = (RooAbsArg *) iter->Next()) { + for (RooAbsArg *a : *std::unique_ptr{genPdf->getParameters((const RooArgSet*)0)}) { TString varstring = utils::printRooArgAsString(a); Logger::instance().log(std::string(Form("Combine.cc: %d -- %s",__LINE__,varstring.Data())),Logger::kLogLevelInfo,__func__); } @@ -1073,8 +1071,7 @@ void Combine::run(TString hlfFile, const std::string &dataset, double &limit, do std::cout << "Generate toy " << iToy << "/" << nToys << std::endl; if (verbose > 2) { Logger::instance().log(std::string(Form("Combine.cc: %d -- Generating toy %d/%d, from parameter values ... ",__LINE__,iToy,nToys)),Logger::kLogLevelInfo,__func__); - std::unique_ptr iter(genPdf->getParameters((const RooArgSet*)0)->createIterator()); - for (RooAbsArg *a = (RooAbsArg *) iter->Next(); a != 0; a = (RooAbsArg *) iter->Next()) { + for (RooAbsArg *a : *std::unique_ptr{genPdf->getParameters((const RooArgSet*)0)}) { TString varstring = utils::printRooArgAsString(a); Logger::instance().log(std::string(Form("Combine.cc: %d -- %s",__LINE__,varstring.Data())),Logger::kLogLevelInfo,__func__); } diff --git a/src/HWWLVJRooPdfs.cxx b/src/HWWLVJRooPdfs.cxx index 80bbab4b86d..dc45009be41 100755 --- a/src/HWWLVJRooPdfs.cxx +++ b/src/HWWLVJRooPdfs.cxx @@ -25,7 +25,6 @@ #include "TString.h" #include "TRandom3.h" #include "TCanvas.h" -#include "TIterator.h" #include "RooHist.h" #include "RooRealVar.h" #include "RooFitResult.h" diff --git a/src/HZZ4L_RooSpinZeroPdf_phase.cc b/src/HZZ4L_RooSpinZeroPdf_phase.cc index 8c421a6bf60..2853ed3f801 100755 --- a/src/HZZ4L_RooSpinZeroPdf_phase.cc +++ b/src/HZZ4L_RooSpinZeroPdf_phase.cc @@ -57,7 +57,6 @@ ClassImp(HZZ4L_RooSpinZeroPdf_phase) Integral_T2 = other.Integral_T2; Integral_T4 = other.Integral_T4; Integral_T5 = other.Integral_T5; - // _coefIter = _coefList.createIterator() ; } diff --git a/src/HybridNew.cc b/src/HybridNew.cc index e7ac6dbc470..b9ba2186da6 100644 --- a/src/HybridNew.cc +++ b/src/HybridNew.cc @@ -807,8 +807,7 @@ std::unique_ptr HybridNew::create(RooWorkspace *w, R // print the values of the parameters used to generate the toy if (verbose > 2) { Logger::instance().log(std::string(Form("HybridNew.cc: %d -- Using the following (post-fit) parameters for No signal hypothesis ",__LINE__)),Logger::kLogLevelInfo,__func__); - std::unique_ptr iter(paramsToFit->createIterator()); - for (RooAbsArg *a = (RooAbsArg *) iter->Next(); a != 0; a = (RooAbsArg *) iter->Next()) { + for (RooAbsArg *a : *paramsToFit) { TString varstring = utils::printRooArgAsString(a); Logger::instance().log(std::string(Form("HybridNew.cc: %d -- %s",__LINE__,varstring.Data())),Logger::kLogLevelInfo,__func__); } @@ -835,8 +834,7 @@ std::unique_ptr HybridNew::create(RooWorkspace *w, R Logger::instance().log(std::string(Form("HybridNew.cc: %d -- Using the following (post-fit) parameters for S+B hypothesis ",__LINE__)),Logger::kLogLevelInfo,__func__); RooArgSet reportParams; reportParams.add(*paramsToFit); reportParams.add(poi); - std::unique_ptr iter(reportParams.createIterator()); - for (RooAbsArg *a = (RooAbsArg *) iter->Next(); a != 0; a = (RooAbsArg *) iter->Next()) { + for (RooAbsArg *a : reportParams) { TString varstring = utils::printRooArgAsString(a); Logger::instance().log(std::string(Form("HybridNew.cc: %d -- %s",__LINE__,varstring.Data())),Logger::kLogLevelInfo,__func__); } diff --git a/src/RooMorphingPdf.cc b/src/RooMorphingPdf.cc index 4c87c9df038..14ba9873667 100644 --- a/src/RooMorphingPdf.cc +++ b/src/RooMorphingPdf.cc @@ -48,11 +48,7 @@ RooMorphingPdf::RooMorphingPdf(const char* name, const char* title, mh_lo_(0.), mh_hi_(0.) { SetAxisInfo(); - TIterator* pdf_iter = pdfs.createIterator(); - RooAbsArg* pdf; - while ((pdf = reinterpret_cast(pdf_iter->Next()))) - pdfs_.add(*pdf); - delete pdf_iter; + pdfs_.add(pdfs); } RooMorphingPdf::RooMorphingPdf(const RooMorphingPdf& other, const char* name) diff --git a/src/RooNCSplineCore.cc b/src/RooNCSplineCore.cc index e75dda0a264..2b638ccd043 100644 --- a/src/RooNCSplineCore.cc +++ b/src/RooNCSplineCore.cc @@ -1,7 +1,6 @@ #include "../interface/RooNCSplineCore.h" #include #include "TMath.h" -#include "TIterator.h" #include "Riostream.h" using namespace TMath; diff --git a/src/RooParametricHist.cxx b/src/RooParametricHist.cxx index aba709360b2..0efb3453448 100644 --- a/src/RooParametricHist.cxx +++ b/src/RooParametricHist.cxx @@ -17,9 +17,6 @@ #include "RooFit.h" #include "TFile.h" -#include "TIterator.h" - -//using namespace RooFit ; ClassImp(RooParametricHist) @@ -96,11 +93,8 @@ RooArgList & RooParametricHist::getAllBinVars() const { double RooParametricHist::getFullSum() const { double sum=0; - TIterator *varIter=pars.createIterator(); - RooAbsReal *fVar; - int i=0; - while ( (fVar = (RooAbsReal*) varIter->Next()) ){ - double thisVal = fVar->getVal(); + for (int i = 0; i < pars.getSize(); ++i) { + double thisVal = static_cast(pars[i]).getVal(); if (_hasMorphs) thisVal*=evaluateMorphFunction(i); sum+=thisVal; i++; diff --git a/src/RooPiecewisePolynomial.cc b/src/RooPiecewisePolynomial.cc index d3b9557dd05..f1218e6e94f 100644 --- a/src/RooPiecewisePolynomial.cc +++ b/src/RooPiecewisePolynomial.cc @@ -4,7 +4,6 @@ #include #include "TVectorD.h" #include "TMatrixD.h" -#include "TIterator.h" using namespace std; @@ -43,16 +42,13 @@ RooPiecewisePolynomial::RooPiecewisePolynomial(const char* name, const char* tit { assert((nfcn>2 && polyndof>=2) || (nfcn==2 && polyndof>=1) || (nfcn==1 && polyndof>=0)); - TIterator* coefIter = parList_.createIterator(); - RooAbsArg* func; - while ((func = (RooAbsArg*) coefIter->Next())) { + for (RooAbsArg *func : parList_) { if (!dynamic_cast(func)) { cerr << "RooPiecewisePolynomial::RooPiecewisePolynomial(" << GetName() << ") funcficient " << func->GetName() << " is not of type RooAbsReal" << endl; assert(0); } parList.add(*func); } - delete coefIter; } RooPiecewisePolynomial::RooPiecewisePolynomial(RooPiecewisePolynomial const& other, const char* name) : RooAbsReal(other, name), diff --git a/src/RooRealFlooredSumPdf.cc b/src/RooRealFlooredSumPdf.cc index 58e2defaad8..6ff54153b35 100755 --- a/src/RooRealFlooredSumPdf.cc +++ b/src/RooRealFlooredSumPdf.cc @@ -3,7 +3,6 @@ #include "../interface/RooRealFlooredSumPdf.h" #include "RooAbsReal.h" #include "RooAbsCategory.h" -#include "TIterator.h" #include "TList.h" #include "RooRealProxy.h" #include "RooPlot.h" @@ -35,8 +34,6 @@ RooRealFlooredSumPdf::RooRealFlooredSumPdf() { // Default constructor // coverity[UNINIT_CTOR] - _funcIter = _funcList.createIterator() ; - _coefIter = _coefList.createIterator() ; _extended = kFALSE ; _doFloor = kTRUE ; _floorVal = 1e-100 ; @@ -56,8 +53,6 @@ RooRealFlooredSumPdf::RooRealFlooredSumPdf(const char *name, const char *title) _floorVal(1e-100) { // Constructor with name and title - _funcIter = _funcList.createIterator() ; - _coefIter = _coefList.createIterator() ; } @@ -66,7 +61,7 @@ RooRealFlooredSumPdf::RooRealFlooredSumPdf(const char *name, const char *title) RooRealFlooredSumPdf::RooRealFlooredSumPdf(const char *name, const char *title, const RooArgList& inFuncList, const RooArgList& inCoefList, Bool_t extended) : RooAbsPdf(name, title), _normIntMgr(this, 10), -_haveLastCoef(kFALSE), +_haveLastCoef(inCoefList.size() == inFuncList.size()), _funcList("!funcList", "List of functions", this), _coefList("!coefList", "List of coefficients", this), _extended(extended), @@ -85,17 +80,11 @@ _floorVal(1e-100) assert(0); } - _funcIter = _funcList.createIterator(); - _coefIter = _coefList.createIterator(); // Constructor with N functions and N or N-1 coefs - TIterator* funcIter = inFuncList.createIterator(); - TIterator* coefIter = inCoefList.createIterator(); - RooAbsArg* func; - RooAbsArg* coef; - - while ((coef = (RooAbsArg*)coefIter->Next())) { - func = (RooAbsArg*)funcIter->Next(); + for (int iCoef = 0; iCoef <= inCoefList.getSize(); ++iCoef) { + RooAbsArg *coef = &inCoefList[iCoef]; + RooAbsArg *func = &inFuncList[iCoef]; if (!dynamic_cast(coef)) { coutW(InputArguments) << "RooRealFlooredSumPdf::RooRealFlooredSumPdf(" << GetName() << ") coefficient " << coef->GetName() << " is not of type RooAbsReal, ignored" << endl; @@ -109,19 +98,14 @@ _floorVal(1e-100) _coefList.add(*coef); } - func = (RooAbsReal*)funcIter->Next(); - if (func) { + if (!_haveLastCoef) { + RooAbsArg *func = &_funcList[_coefList.size()]; if (!dynamic_cast(func)) { coutE(InputArguments) << "RooRealFlooredSumPdf::RooRealFlooredSumPdf(" << GetName() << ") last func " << func->GetName() << " is not of type RooAbsReal, fatal error" << endl; assert(0); } _funcList.add(*func); } - else _haveLastCoef = kTRUE; - - - delete funcIter; - delete coefIter; } @@ -139,9 +123,6 @@ _doFloor(other._doFloor), _floorVal(other._floorVal) { // Copy constructor - - _funcIter = _funcList.createIterator(); - _coefIter = _coefList.createIterator(); } @@ -154,15 +135,7 @@ void RooRealFlooredSumPdf::setFloor(Double_t val) //_____________________________________________________________________________ -RooRealFlooredSumPdf::~RooRealFlooredSumPdf() -{ - // Destructor - delete _funcIter; - delete _coefIter; -} - - - +RooRealFlooredSumPdf::~RooRealFlooredSumPdf() = default; //_____________________________________________________________________________ @@ -182,15 +155,12 @@ Double_t RooRealFlooredSumPdf::evaluate() const Double_t value(0); // Do running sum of coef/func pairs, calculate lastCoef. - RooFIter funcIter = _funcList.fwdIterator(); - RooFIter coefIter = _coefList.fwdIterator(); - RooAbsReal* coef; - RooAbsReal* func; // N funcs, N-1 coefficients Double_t lastCoef(1); - while ((coef = (RooAbsReal*)coefIter.next())) { - func = (RooAbsReal*)funcIter.next(); + for (int iCoef = 0; iCoef < _coefList.getSize(); ++iCoef) { + RooAbsReal *coef = &static_cast(_coefList[iCoef]); + RooAbsReal *func = &static_cast(_funcList[iCoef]); Double_t coefVal = coef->getVal(); if (coefVal) { cxcoutD(Eval) << "RooRealFlooredSumPdf::eval(" << GetName() << ") coefVal = " << coefVal << " funcVal = " << func->ClassName() << "::" << func->GetName() << " = " << func->getVal() << endl; @@ -201,7 +171,7 @@ Double_t RooRealFlooredSumPdf::evaluate() const if (!_haveLastCoef) { // Add last func with correct coefficient - func = (RooAbsReal*)funcIter.next(); + RooAbsReal *func = &static_cast(_funcList[_coefList.getSize()]); value += func->getVal()*lastCoef; cxcoutD(Eval) << "RooRealFlooredSumPdf::eval(" << GetName() << ") lastCoef = " << lastCoef << " funcVal = " << func->getVal() << endl; @@ -235,12 +205,9 @@ Bool_t RooRealFlooredSumPdf::checkObservables(const RooArgSet* nset) const Bool_t ret(kFALSE); - _funcIter->Reset(); - _coefIter->Reset(); - RooAbsReal* coef; - RooAbsReal* func; - while ((coef = (RooAbsReal*)_coefIter->Next())) { - func = (RooAbsReal*)_funcIter->Next(); + for (int iCoef = 0; iCoef < _coefList.getSize(); ++iCoef) { + RooAbsReal *coef = &static_cast(_coefList[iCoef]); + RooAbsReal *func = &static_cast(_funcList[iCoef]); if (func->observableOverlaps(nset, *coef)) { coutE(InputArguments) << "RooRealFlooredSumPdf::checkObservables(" << GetName() << "): ERROR: coefficient " << coef->GetName() << " and FUNC " << func->GetName() << " have one or more observables in common" << endl; @@ -252,6 +219,9 @@ Bool_t RooRealFlooredSumPdf::checkObservables(const RooArgSet* nset) const ret = kTRUE; } } + + // guitargeek: should the last function not be checked as well, in case + // there is one less coef than functions? return ret; } @@ -286,9 +256,8 @@ Int_t RooRealFlooredSumPdf::getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSe cache = new CacheElem; // Make list of function projection and normalization integrals - _funcIter->Reset(); - RooAbsReal *func; - while ((func = (RooAbsReal*)_funcIter->Next())) { + for (RooAbsArg *funcAbsArg : _funcList) { + RooAbsReal *func = static_cast(funcAbsArg); RooAbsReal* funcInt = func->createIntegral(analVars, rangeName); cache->_funcIntList.addOwned(*funcInt); if (normSet && normSet->getSize() > 0) { @@ -475,10 +444,8 @@ Bool_t RooRealFlooredSumPdf::isBinnedDistribution(const RooArgSet& obs) const { // If all components that depend on obs are binned that so is the product - RooFIter iter = _funcList.fwdIterator(); - RooAbsReal* func; - while ((func = (RooAbsReal*)iter.next())) { - if (func->dependsOn(obs) && !func->isBinnedDistribution(obs)) { + for (RooAbsArg *func : _funcList) { + if (func->dependsOn(obs) && !static_cast(func)->isBinnedDistribution(obs)) { return kFALSE; } } @@ -544,31 +511,29 @@ void RooRealFlooredSumPdf::printMetaArgs(ostream& os) const // Customized printing of arguments of a RooRealFlooredSumPdf to more intuitively reflect the contents of the // product operator construction - _funcIter->Reset(); - _coefIter->Reset(); - Bool_t first(kTRUE); RooAbsArg* coef, *func; if (_coefList.getSize() != 0) { - while ((coef = (RooAbsArg*)_coefIter->Next())) { + for (int iCoef = 0; iCoef <= _coefList.getSize(); ++iCoef) { + RooAbsArg *coef = &_coefList[iCoef]; + RooAbsArg *func = &_funcList[iCoef]; if (!first) { os << " + "; } else { first = kFALSE; } - func = (RooAbsArg*)_funcIter->Next(); os << coef->GetName() << " * " << func->GetName(); } - func = (RooAbsArg*)_funcIter->Next(); - if (func) { + if (_funcList.size() > _coefList.size()) { + RooAbsArg *func = &_funcList[_coefList.size()]; os << " + [%] * " << func->GetName(); } } else { - while ((func = (RooAbsArg*)_funcIter->Next())) { + for (RooAbsArg *func : _funcList) { if (!first) { os << " + "; } diff --git a/src/SimplerLikelihoodRatioTestStatExt.cc b/src/SimplerLikelihoodRatioTestStatExt.cc index f62e441c72e..8e38d0d4379 100644 --- a/src/SimplerLikelihoodRatioTestStatExt.cc +++ b/src/SimplerLikelihoodRatioTestStatExt.cc @@ -56,11 +56,10 @@ SimplerLikelihoodRatioTestStatOpt::Evaluate(RooAbsData& data, RooArgSet& nullPOI if (paramsAlt_.get() == 0) paramsAlt_.reset(pdfAlt_->getParameters(data)); // if the dataset is not empty, redirect pdf nodes to the dataset - std::unique_ptr iterDepObs(pdfDepObs_.createIterator()); bool nonEmpty = data.numEntries() > 0; if (nonEmpty) { const RooArgSet *entry = data.get(0); - for (RooAbsArg *a = (RooAbsArg *) iterDepObs->Next(); a != 0; a = (RooAbsArg *) iterDepObs->Next()) { + for (RooAbsArg *a : pdfDepObs_) { a->redirectServers(*entry); } } @@ -76,8 +75,7 @@ SimplerLikelihoodRatioTestStatOpt::Evaluate(RooAbsData& data, RooArgSet& nullPOI // put back links in pdf nodes, otherwise if the dataset goes out of scope they have dangling pointers if (nonEmpty) { - iterDepObs->Reset(); - for (RooAbsArg *a = (RooAbsArg *) iterDepObs->Next(); a != 0; a = (RooAbsArg *) iterDepObs->Next()) { + for (RooAbsArg *a : pdfDepObs_) { a->redirectServers(*obs_); } } diff --git a/src/TestProposal.cc b/src/TestProposal.cc index f6df0e363b3..1685688fa15 100644 --- a/src/TestProposal.cc +++ b/src/TestProposal.cc @@ -3,7 +3,6 @@ #include #include #include -#include #include #include diff --git a/src/ToyMCSamplerOpt.cc b/src/ToyMCSamplerOpt.cc index eb8ca7ebb3c..a4a00956187 100644 --- a/src/ToyMCSamplerOpt.cc +++ b/src/ToyMCSamplerOpt.cc @@ -145,8 +145,7 @@ toymcoptutils::SinglePdfGenInfo::generateAsimov(RooRealVar *&weightVar, double w if (boostAPA>0) { // trigger adaptive PA (setting boostAPA=1 will just use internal logic) if ( verbose > 0 ) Logger::instance().log(std::string(Form("ToyMCSamplerOpt.cc: %d -- Using internal logic for binned/unbinned Asimov dataset generation",__LINE__)),Logger::kLogLevelInfo,__func__); int nbins = 1; - RooLinkedListIter iter = observables_.iterator(); - for (RooAbsArg *a = (RooAbsArg *) iter.Next(); a != 0; a = (RooAbsArg *) iter.Next()) { + for (RooAbsArg *a : observables_) { RooRealVar *rrv = dynamic_cast(a); int mybins = rrv->getBins(); nbins *= (mybins ? mybins : 100); @@ -289,8 +288,7 @@ toymcoptutils::SinglePdfGenInfo::generateCountingAsimov() void toymcoptutils::SinglePdfGenInfo::setToExpected(RooProdPdf &prod, RooArgSet &obs) { - std::unique_ptr iter(prod.pdfList().createIterator()); - for (RooAbsArg *a = (RooAbsArg *) iter->Next(); a != 0; a = (RooAbsArg *) iter->Next()) { + for (RooAbsArg *a : prod.pdfList()) { if (!a->dependsOn(obs)) continue; RooPoisson *pois = 0; if ((pois = dynamic_cast(a)) != 0) { @@ -308,8 +306,7 @@ toymcoptutils::SinglePdfGenInfo::setToExpected(RooPoisson &pois, RooArgSet &obs) { RooRealVar *myobs = 0; RooAbsReal *myexp = 0; - std::unique_ptr iter(pois.serverIterator()); - for (RooAbsArg *a = (RooAbsArg *) iter->Next(); a != 0; a = (RooAbsArg *) iter->Next()) { + for (RooAbsArg *a : pois.servers()) { if (obs.contains(*a)) { assert(myobs == 0 && "SinglePdfGenInfo::setToExpected(RooPoisson): Two observables??"); myobs = dynamic_cast(a); diff --git a/src/VBFHZZ4L_RooSpinZeroPdf.cc b/src/VBFHZZ4L_RooSpinZeroPdf.cc index 156d658057d..d1846a5f8e8 100755 --- a/src/VBFHZZ4L_RooSpinZeroPdf.cc +++ b/src/VBFHZZ4L_RooSpinZeroPdf.cc @@ -34,23 +34,19 @@ ClassImp(VBFHZZ4L_RooSpinZeroPdf) ai("ai","ai",this,_ai), _coefList("coefList","List of funcficients",this) { - TIterator* coefIter = inCoefList.createIterator() ; - RooAbsArg* func; - while((func = (RooAbsArg*)coefIter->Next())) { + for (RooAbsArg *func : inCoefList) { if (!dynamic_cast(func)) { coutE(InputArguments) << "ERROR: :VBFHZZ4L_RooSpinZeroPdf(" << GetName() << ") funcficient " << func->GetName() << " is not of type RooAbsReal" << std::endl; assert(0); } _coefList.add(*func) ; } - delete coefIter; Integral_T1 = dynamic_cast(_coefList.at(0))-> analyticalIntegral(1000); Integral_T2 = dynamic_cast(_coefList.at(1))-> analyticalIntegral(1000); Integral_T3 = dynamic_cast(_coefList.at(2))-> analyticalIntegral(1000); Integral_T4 = dynamic_cast(_coefList.at(3))-> analyticalIntegral(1000); Integral_T5 = dynamic_cast(_coefList.at(4))-> analyticalIntegral(1000); -// _coefIter = _coefList.createIterator() ; } diff --git a/src/VBFHZZ4L_RooSpinZeroPdf_fast.cc b/src/VBFHZZ4L_RooSpinZeroPdf_fast.cc index 1688a1e5884..ca8b8c02333 100755 --- a/src/VBFHZZ4L_RooSpinZeroPdf_fast.cc +++ b/src/VBFHZZ4L_RooSpinZeroPdf_fast.cc @@ -31,27 +31,21 @@ VBFHZZ4L_RooSpinZeroPdf_fast::VBFHZZ4L_RooSpinZeroPdf_fast( obsList("obsList", "List of pdf observables", this), coefList("coefList", "List of pdf components", this) { - TIterator* coefIter = inObsList.createIterator(); - RooAbsArg* coef; - while ((coef = (RooAbsArg*)coefIter->Next())){ + for (RooAbsArg *coef : inObsList) { if (!dynamic_cast(coef)){ coutE(InputArguments) << "VBFHZZ4L_RooSpinZeroPdf_fast(" << GetName() << ") observable " << coef->GetName() << " is not of type RooAbsReal" << endl; assert(0); } obsList.add(*coef); } - delete coefIter; - coefIter = inCoefList.createIterator(); - coef=0; - while ((coef = (RooAbsArg*)coefIter->Next())){ + for (RooAbsArg *coef : inCoefList) { if (dynamic_cast(coef)==0 && dynamic_cast(coef)==0){ coutE(InputArguments) << "VBFHZZ4L_RooSpinZeroPdf_fast(" << GetName() << ") component " << coef->GetName() << " is not of type FastTemplateFunc_f" << endl; assert(0); } coefList.add(*coef); } - delete coefIter; } diff --git a/src/VVHZZ4L_RooSpinZeroPdf_1D_fast.cc b/src/VVHZZ4L_RooSpinZeroPdf_1D_fast.cc index 2118760435b..01a12dbd42a 100755 --- a/src/VVHZZ4L_RooSpinZeroPdf_1D_fast.cc +++ b/src/VVHZZ4L_RooSpinZeroPdf_1D_fast.cc @@ -28,27 +28,21 @@ VVHZZ4L_RooSpinZeroPdf_1D_fast::VVHZZ4L_RooSpinZeroPdf_1D_fast( obsList("obsList", "List of pdf observables", this), coefList("coefList", "List of pdf components", this) { - TIterator* coefIter = inObsList.createIterator(); - RooAbsArg* coef; - while ((coef = (RooAbsArg*)coefIter->Next())){ + for (RooAbsArg *coef : inObsList) { if (!dynamic_cast(coef)){ coutE(InputArguments) << "VVHZZ4L_RooSpinZeroPdf_1D_fast(" << GetName() << ") observable " << coef->GetName() << " is not of type RooAbsReal" << endl; assert(0); } obsList.add(*coef); } - delete coefIter; - coefIter = inCoefList.createIterator(); - coef=0; - while ((coef = (RooAbsArg*)coefIter->Next())){ + for (RooAbsArg *coef : inCoefList) { if (dynamic_cast(coef)==0 && dynamic_cast(coef)==0){ coutE(InputArguments) << "VVHZZ4L_RooSpinZeroPdf_1D_fast(" << GetName() << ") component " << coef->GetName() << " is not of type FastTemplateFunc_f" << endl; assert(0); } coefList.add(*coef); } - delete coefIter; } diff --git a/src/VerticalInterpHistPdf.cc b/src/VerticalInterpHistPdf.cc index cade9329b25..c354cc43867 100644 --- a/src/VerticalInterpHistPdf.cc +++ b/src/VerticalInterpHistPdf.cc @@ -6,7 +6,6 @@ #include "RooFit.h" #include "Riostream.h" -#include "TIterator.h" #include "RooRealVar.h" #include "RooMsgService.h" #include "RooAbsData.h" diff --git a/src/VerticalInterpPdf.cc b/src/VerticalInterpPdf.cc index a8abd9ee918..b68ee45bdab 100644 --- a/src/VerticalInterpPdf.cc +++ b/src/VerticalInterpPdf.cc @@ -4,7 +4,6 @@ #include "RooFit.h" #include "Riostream.h" -#include "TIterator.h" #include "TList.h" #include "RooRealProxy.h" #include "RooPlot.h" diff --git a/src/utils.cc b/src/utils.cc index 243a5764487..00b21350b10 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -13,7 +13,6 @@ #include #include -#include #include #include @@ -410,8 +409,7 @@ bool utils::checkModel(const RooStats::ModelConfig &model, bool throwOnFail) { ok = false; errors << "ERROR: have nuisance parameters, but can't factorize the pdf\n"; } std::unique_ptr obsParams(factorizedPdf->getParameters(*model.GetObservables())); - iter.reset(model.GetNuisanceParameters()->createIterator()); - for (RooAbsArg *a = (RooAbsArg *) iter->Next(); a != 0; a = (RooAbsArg *) iter->Next()) { + for (RooAbsArg *a : *model.GetNuisanceParameters()) { if (!obsParams->contains(*a)) { errors << "WARNING: model pdf does not depend on nuisace parameter " << a->GetName() << "\n"; } @@ -586,14 +584,7 @@ utils::makePlots(const RooAbsPdf &pdf, const RooAbsData &data, const char *signa RooAbsPdf *pdfi = sim->getPdf(ds->GetName()); std::unique_ptr obs(pdfi->getObservables(ds)); if (obs->getSize() == 0) break; - TIterator *obs_iter = obs->createIterator(); - //std::cout << " PDF CHECKING " << std::endl; - //pdfi->Print("v"); - //ds->Print("v"); - //std::cout << " ------------ " << std::endl; - - //for (int iobs=0;iobsgetSize();iobs++){ - for (RooAbsArg *a = 0; (a = (RooAbsArg *)obs_iter->Next()) != 0; ) { + for (RooAbsArg *a : *obs) { RooRealVar *x = dynamic_cast(a); if (x == 0) continue; int nbins = x->numBins(); if (nbins == 0) nbins = 100; @@ -617,9 +608,7 @@ utils::makePlots(const RooAbsPdf &pdf, const RooAbsData &data, const char *signa } else if (pdf.canBeExtended()) { std::unique_ptr obs(pdf.getObservables(&data)); - //for (int iobs=0;iobsgetSize();iobs++){ - TIterator *obs_iter = obs->createIterator(); - for (RooAbsArg *a = 0; (a = (RooAbsArg *)obs_iter->Next()) != 0; ) { + for (RooAbsArg *a : *obs) { RooRealVar *x = dynamic_cast(a); if (x != 0) { ret.push_back(x->frame()); @@ -739,8 +728,7 @@ void utils::setModelParameters( const std::string & setPhysicsModelParameterExpr std::cout<<"interpreting "< iter(params.createIterator()); - for (RooAbsArg *tmp = (RooAbsArg*) iter->Next(); tmp != 0; tmp = (RooAbsArg*) iter->Next()) { + for (RooAbsArg *tmp : params) { bool isrvar = tmp->IsA()->InheritsFrom(RooRealVar::Class()); // check its type @@ -861,8 +849,7 @@ void utils::setModelParameterRanges( const std::string & setPhysicsModelParamete std::cout<<"interpreting "< iter(params.createIterator()); - for (RooAbsArg *a = (RooAbsArg*) iter->Next(); a != 0; a = (RooAbsArg*) iter->Next()) { + for (RooAbsArg *a : params) { RooRealVar *tmpParameter = dynamic_cast(a); const std::string &target = tmpParameter->GetName(); std::smatch match;