diff --git a/roofit/roofitcore/inc/LinkDef.h b/roofit/roofitcore/inc/LinkDef.h index 2994cd50a82a6..88aef868da7be 100644 --- a/roofit/roofitcore/inc/LinkDef.h +++ b/roofit/roofitcore/inc/LinkDef.h @@ -48,8 +48,8 @@ #pragma link C++ class RooAbsCollection+ ; #pragma read sourceClass="RooAbsCollection" targetClass="RooAbsCollection" version="[1]" source="" target="_allRRV" code="{ _allRRV=kFALSE ; }" #pragma read sourceClass="RooAbsCollection" targetClass="RooAbsCollection" version="[2]"\ - source="RooLinkedList _list" target="_list" code="{ RooFIter iter = onfile._list.fwdIterator(); RooAbsArg * theArg;\ - while ((theArg = iter.next())) {_list.push_back(theArg);} }" + source="RooLinkedList _list" target="_list" code="{ \ + for (RooAbsArg * theArg : static_range_cast(onfile._list)) {_list.push_back(theArg);} }" #pragma link C++ class RooAbsData- ; #pragma link C++ class RooAbsFunc+ ; #pragma link C++ class RooAbsGenContext+ ; @@ -202,8 +202,8 @@ #pragma read sourceClass="RooRealVarSharedProperties" targetClass="RooRealVarSharedProperties" version="[1]" \ include="RooLinkedList.h" \ source="RooLinkedList _altBinning" target="_altBinning" \ - code="{ RooFIter iter = onfile._altBinning.fwdIterator(); TObject* binning;\ - while ( (binning = iter.next()) ) { _altBinning[binning->GetName()] = static_cast(binning); } \ + code="{ \ + for (TObject * binning : onfile._altBinning) { _altBinning[binning->GetName()] = static_cast(binning); } \ }" #pragma link C++ class RooRefCountList+ ; #pragma link C++ class RooScaledFunc+ ; diff --git a/roofit/roofitcore/src/RooAbsCollection.cxx b/roofit/roofitcore/src/RooAbsCollection.cxx index 0b1b2881bb680..bcb69c1edbd9c 100644 --- a/roofit/roofitcore/src/RooAbsCollection.cxx +++ b/roofit/roofitcore/src/RooAbsCollection.cxx @@ -1360,18 +1360,15 @@ void RooAbsCollection::printLatex(ostream& ofs, Int_t ncol, const char* option, // Make list of lists ; RooLinkedList listList ; listList.Add((RooAbsArg*)this) ; - RooFIter sIter = siblingList.fwdIterator() ; - RooAbsCollection* col ; - while((col=(RooAbsCollection*)sIter.next())) { + for(auto * col : static_range_cast(siblingList)) { listList.Add(col) ; } RooLinkedList listListRRV ; // Make list of RRV-only components - RooFIter lIter = listList.fwdIterator() ; RooArgList* prevList = 0 ; - while((col=(RooAbsCollection*)lIter.next())) { + for(auto * col : static_range_cast(listList)) { RooArgList* list = new RooArgList ; RooFIter iter = col->fwdIterator() ; RooAbsArg* arg ; diff --git a/roofit/roofitcore/src/RooAbsReal.cxx b/roofit/roofitcore/src/RooAbsReal.cxx index 684fab53672e0..2dbcd837c0850 100644 --- a/roofit/roofitcore/src/RooAbsReal.cxx +++ b/roofit/roofitcore/src/RooAbsReal.cxx @@ -1852,15 +1852,15 @@ RooPlot* RooAbsReal::plotOn(RooPlot* frame, RooLinkedList& argList) const // Loop over all categories provided by (multiple) Slice() arguments auto catTokens = ROOT::Split(sliceCatState, ","); - std::unique_ptr iter( sliceCatList.MakeIterator() ); + auto iter = sliceCatList.begin(); for (unsigned int i=0; i < catTokens.size(); ++i) { - auto scat = static_cast(iter->Next()); - if (scat) { + if (auto scat = static_cast(*iter)) { // Set the slice position to the value indicate by slabel scat->setLabel(catTokens[i]) ; // Add the slice category to the master slice set sliceSet->add(*scat,kFALSE) ; } + ++iter; } } @@ -2823,9 +2823,7 @@ RooPlot* RooAbsReal::plotOnWithErrorBand(RooPlot* frame,const RooFitResult& fr, // Strip any 'internal normalization' arguments from list RooLinkedList plotArgList ; - RooFIter iter = plotArgListTmp.fwdIterator() ; - RooCmdArg* cmd ; - while ((cmd=(RooCmdArg*)iter.next())) { + for (auto * cmd : static_range_cast(plotArgListTmp)) { if (std::string("Normalization")==cmd->GetName()) { if (((RooCmdArg*)cmd)->getInt(1)!=0) { } else { diff --git a/roofit/roofitcore/src/RooAbsStudy.cxx b/roofit/roofitcore/src/RooAbsStudy.cxx index 7276d39971ae4..710a9d84653fe 100644 --- a/roofit/roofitcore/src/RooAbsStudy.cxx +++ b/roofit/roofitcore/src/RooAbsStudy.cxx @@ -148,15 +148,9 @@ void RooAbsStudy::aggregateSummaryOutput(TList* chunkList) } } - RooLinkedList* dlist = dynamic_cast(obj) ; - if (dlist) { + if (auto dlist = dynamic_cast(obj)) { if (TString(dlist->GetName()).BeginsWith(Form("%s_detailed_data",GetName()))) { - //cout << "RooAbsStudy::aggregateSummaryOutput(" << GetName() << ") found detail block " <GetName() << " with " << dlist->GetSize() << " entries" << endl ; - TIter diter = dlist->MakeIterator() ; - TNamed* dobj ; - while((dobj=(TNamed*)diter.Next())) { - storeDetailedOutput(*dobj) ; - } + for(auto * dobj : static_range_cast(*dlist)) storeDetailedOutput(*dobj) ; } } } diff --git a/roofit/roofitcore/src/RooCategory.cxx b/roofit/roofitcore/src/RooCategory.cxx index daff8177e309a..b96c1ae13343e 100644 --- a/roofit/roofitcore/src/RooCategory.cxx +++ b/roofit/roofitcore/src/RooCategory.cxx @@ -492,8 +492,7 @@ void RooCategory::installLegacySharedProp(const RooCategorySharedProperties* pro auto& rangesMap = *_ranges; // Copy the data: - std::unique_ptr iter(props->_altRanges.MakeIterator()); - while (TList* olist = (TList*)iter->Next()) { + for (auto * olist : static_range_cast(props->_altRanges)) { std::vector& vec = rangesMap[olist->GetName()]; diff --git a/roofit/roofitcore/src/RooErrorVar.cxx b/roofit/roofitcore/src/RooErrorVar.cxx index 72a4527d519c5..fb948c2a1b159 100644 --- a/roofit/roofitcore/src/RooErrorVar.cxx +++ b/roofit/roofitcore/src/RooErrorVar.cxx @@ -61,13 +61,7 @@ RooErrorVar::RooErrorVar(const RooErrorVar& other, const char* name) : _binning = other._binning->clone() ; // Copy constructor - - TIterator* iter = other._altBinning.MakeIterator() ; - RooAbsBinning* binning ; - while((binning=(RooAbsBinning*)iter->Next())) { - _altBinning.Add(binning->clone()) ; - } - delete iter ; + for(auto * binning : static_range_cast(other._altBinning)) _altBinning.Add(binning->clone()); } @@ -153,9 +147,7 @@ std::list RooErrorVar::getBinningNames() const { std::list binningNames(1, ""); - RooFIter iter = _altBinning.fwdIterator(); - const RooAbsArg* binning = 0; - while((binning = iter.next())) { + for(auto * binning : static_range_cast(_altBinning)) { const char* name = binning->GetName(); binningNames.push_back(name); } diff --git a/roofit/roofitcore/src/RooNumGenConfig.cxx b/roofit/roofitcore/src/RooNumGenConfig.cxx index 211f9c8b6ed22..229e7601795f3 100644 --- a/roofit/roofitcore/src/RooNumGenConfig.cxx +++ b/roofit/roofitcore/src/RooNumGenConfig.cxx @@ -119,14 +119,11 @@ RooNumGenConfig::RooNumGenConfig(const RooNumGenConfig& other) : _methodNDCondCat(other._methodNDCondCat) { // Clone all configuration dat - TIterator* iter = other._configSets.MakeIterator() ; - RooArgSet* set ; - while((set=(RooArgSet*)iter->Next())) { + for (auto * set : static_range_cast(other._configSets)) { RooArgSet* setCopy = (RooArgSet*) set->snapshot() ; setCopy->setName(set->GetName()) ; _configSets.Add(setCopy); } - delete iter ; } @@ -160,14 +157,11 @@ RooNumGenConfig& RooNumGenConfig::operator=(const RooNumGenConfig& other) _configSets.Delete() ; // Copy new integrator-specific data - TIterator* iter = other._configSets.MakeIterator() ; - RooArgSet* set ; - while((set=(RooArgSet*)iter->Next())) { + for(auto * set : static_range_cast(other._configSets)) { RooArgSet* setCopy = (RooArgSet*) set->snapshot() ; setCopy->setName(set->GetName()) ; _configSets.Add(setCopy); } - delete iter ; return *this ; } @@ -368,9 +362,7 @@ void RooNumGenConfig::printMultiline(ostream &os, Int_t /*content*/, Bool_t verb if (verbose) { os << endl << "Available sampling methods:" << endl << endl ; - TIterator* cIter = _configSets.MakeIterator() ; - RooArgSet* configSet ; - while ((configSet=(RooArgSet*)cIter->Next())) { + for(auto * configSet : static_range_cast(_configSets)) { os << indent << "*** " << configSet->GetName() << " ***" << endl ; os << indent << "Capabilities: " ; @@ -384,7 +376,5 @@ void RooNumGenConfig::printMultiline(ostream &os, Int_t /*content*/, Bool_t verb os << endl ; } - - delete cIter ; } } diff --git a/roofit/roofitcore/src/RooNumIntConfig.cxx b/roofit/roofitcore/src/RooNumIntConfig.cxx index a2513026e3861..4a4661e5eb2b2 100644 --- a/roofit/roofitcore/src/RooNumIntConfig.cxx +++ b/roofit/roofitcore/src/RooNumIntConfig.cxx @@ -117,14 +117,11 @@ RooNumIntConfig::RooNumIntConfig(const RooNumIntConfig& other) : _methodNDOpen(other._methodNDOpen) { // Clone all configuration dat - TIterator* iter = other._configSets.MakeIterator() ; - RooArgSet* set ; - while((set=(RooArgSet*)iter->Next())) { + for(auto * set : static_range_cast(other._configSets)) { RooArgSet* setCopy = (RooArgSet*) set->snapshot() ; setCopy->setName(set->GetName()) ; _configSets.Add(setCopy); } - delete iter ; } @@ -152,14 +149,11 @@ RooNumIntConfig& RooNumIntConfig::operator=(const RooNumIntConfig& other) _configSets.Delete() ; // Copy new integrator-specific data - TIterator* iter = other._configSets.MakeIterator() ; - RooArgSet* set ; - while((set=(RooArgSet*)iter->Next())) { + for(auto * set : static_range_cast(other._configSets)) { RooArgSet* setCopy = (RooArgSet*) set->snapshot() ; setCopy->setName(set->GetName()) ; _configSets.Add(setCopy); } - delete iter ; return *this ; } @@ -308,9 +302,7 @@ void RooNumIntConfig::printMultiline(ostream &os, Int_t /*content*/, Bool_t verb if (verbose) { os << endl << "Available integration methods:" << endl << endl ; - TIterator* cIter = _configSets.MakeIterator() ; - RooArgSet* configSet ; - while ((configSet=(RooArgSet*)cIter->Next())) { + for(auto * configSet : static_range_cast(_configSets)) { os << indent << "*** " << configSet->GetName() << " ***" << endl ; os << indent << "Capabilities: " ; @@ -332,7 +324,5 @@ void RooNumIntConfig::printMultiline(ostream &os, Int_t /*content*/, Bool_t verb os << endl ; } - - delete cIter ; } } diff --git a/roofit/roofitcore/src/RooProdPdf.cxx b/roofit/roofitcore/src/RooProdPdf.cxx index 7e62fde2b8429..f08bd5792f87c 100644 --- a/roofit/roofitcore/src/RooProdPdf.cxx +++ b/roofit/roofitcore/src/RooProdPdf.cxx @@ -357,9 +357,7 @@ RooProdPdf::RooProdPdf(const RooProdPdf& other, const char* name) : _defNormSet(other._defNormSet) { // Clone contents of normalizarion set list - RooFIter iter = other._pdfNSetList.fwdIterator(); - RooArgSet* nset ; - while((nset=(RooArgSet*)iter.next())) { + for(auto * nset : static_range_cast(other._pdfNSetList)) { RooArgSet* tmp = (RooArgSet*) nset->snapshot() ; tmp->setName(nset->GetName()) ; _pdfNSetList.Add(tmp) ; @@ -586,12 +584,13 @@ void RooProdPdf::factorizeProduct(const RooArgSet& normSet, const RooArgSet& int std::vector pdfAllDeps; // All dependents of this PDF // Loop over the PDFs - RooAbsPdf* pdf; - RooArgSet* pdfNSetOrig; - for (RooLinkedListIter pdfIter = _pdfList.iterator(), - nIter = _pdfNSetList.iterator(); - (pdfNSetOrig = static_cast(nIter.Next()), - pdf = static_cast(pdfIter.Next())); ) { + auto pdfIter = _pdfList.begin(); + auto nIter = _pdfNSetList.begin(); + for (;pdfIter != _pdfList.end(); (++pdfIter, ++nIter)) { + + auto pdf = static_cast(*pdfIter); + auto pdfNSetOrig = static_cast(*nIter); + pdfNSet.clear(); pdfCSet.clear(); @@ -662,10 +661,11 @@ void RooProdPdf::factorizeProduct(const RooArgSet& normSet, const RooArgSet& int // Check if this PDF has dependents overlapping with one of the existing terms bool done = false; int j = 0; - for (RooLinkedListIter lIter = termList.iterator(), - ldIter = normList.iterator(); - (termNormDeps = static_cast(ldIter.Next()), - term = static_cast(lIter.Next())); ++j) { + auto lIter = termList.begin(); + auto ldIter = normList.begin(); + for(;lIter != termList.end(); (++lIter, ++ldIter, ++j)) { + termNormDeps = static_cast(*ldIter); + term = static_cast(*lIter); // PDF should be added to existing term if // 1) It has overlapping normalization dependents with any other PDF in existing term // 2) It has overlapping dependents of any class for which integration is requested @@ -718,10 +718,11 @@ void RooProdPdf::factorizeProduct(const RooArgSet& normSet, const RooArgSet& int // Loop over list of terms again to determine 'imported' observables int i = 0; RooArgSet *normDeps; - for (RooLinkedListIter lIter = termList.iterator(), - ldIter = normList.iterator(); - (normDeps = static_cast(ldIter.Next()), - term= static_cast(lIter.Next())); ++i) { + auto lIter = termList.begin(); + auto ldIter = normList.begin(); + for(;lIter != termList.end(); (++lIter, ++ldIter, ++i)) { + normDeps = static_cast(*ldIter); + term = static_cast(*lIter); // Make list of wholly imported dependents RooArgSet impDeps(depAllList[i]); impDeps.remove(*normDeps, kTRUE, kTRUE); diff --git a/roofit/roofitcore/src/RooSimultaneous.cxx b/roofit/roofitcore/src/RooSimultaneous.cxx index d25f4144a5a34..fa85e4bb58c62 100644 --- a/roofit/roofitcore/src/RooSimultaneous.cxx +++ b/roofit/roofitcore/src/RooSimultaneous.cxx @@ -640,10 +640,8 @@ RooPlot* RooSimultaneous::plotOn(RooPlot *frame, RooLinkedList& cmdList) const auto catTokens = ROOT::Split(sliceCatState, ","); // Loop over all categories provided by (multiple) Slice() arguments - TIterator* iter = sliceCatList.MakeIterator() ; - RooCategory* scat ; unsigned int tokenIndex = 0; - while((scat=(RooCategory*)iter->Next())) { + for(auto * scat : static_range_cast(sliceCatList)) { const char* slabel = tokenIndex >= catTokens.size() ? nullptr : catTokens[tokenIndex++].c_str(); if (slabel) { @@ -653,7 +651,6 @@ RooPlot* RooSimultaneous::plotOn(RooPlot *frame, RooLinkedList& cmdList) const sliceSet->add(*scat,kFALSE) ; } } - delete iter ; } // Check if we have a projection dataset diff --git a/roofit/roostats/src/ToyMCStudy.cxx b/roofit/roostats/src/ToyMCStudy.cxx index 2c9214eb65599..41ce1e4077715 100644 --- a/roofit/roostats/src/ToyMCStudy.cxx +++ b/roofit/roostats/src/ToyMCStudy.cxx @@ -107,10 +107,8 @@ RooDataSet* ToyMCStudy::merge() { return NULL; } - RooLinkedListIter iter = detailedData()->iterator(); - TObject *o = NULL; int i = 0; - while((o = iter.Next())) { + for (auto * o : static_range_cast(*detailedData())) { ToyMCPayload *oneWorker = dynamic_cast< ToyMCPayload* >(o); if(!oneWorker) { coutW(Generation) << "Merging Results problem: not correct type" << endl;