From a275836c8203f06f5e64b7d8693b2aa89382b90d Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Sun, 3 Dec 2023 13:40:32 +0100 Subject: [PATCH] Next chunk of changes --- interface/FastTemplateFunc.h | 5 +---- src/AsimovUtils.cc | 13 +++++-------- src/AsymptoticLimits.cc | 3 +-- src/FitterAlgoBase.cc | 6 ++---- src/HWWLVJRooPdfs.cxx | 1 - src/HZZ4L_RooSpinZeroPdf_phase.cc | 1 - src/MarkovChainMC.cc | 3 +-- src/ProfiledLikelihoodRatioTestStatExt.cc | 3 +-- src/SimplerLikelihoodRatioTestStatExt.cc | 6 ++---- src/TestProposal.cc | 1 - 10 files changed, 13 insertions(+), 29 deletions(-) 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/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/FitterAlgoBase.cc b/src/FitterAlgoBase.cc index 1c8dbe1d9d7..233644b71b9 100644 --- a/src/FitterAlgoBase.cc +++ b/src/FitterAlgoBase.cc @@ -676,8 +676,7 @@ double FitterAlgoBase::findCrossingNew(CascadeMinimizer &minim, RooAbsReal &nll, void FitterAlgoBase::optimizeBounds(const RooWorkspace *w, const RooStats::ModelConfig *mc) { if (runtimedef::get("UNBOUND_GAUSSIANS") && mc->GetNuisanceParameters() != 0) { - RooLinkedListIter iter = mc->GetNuisanceParameters()->iterator(); - for (RooAbsArg *a = (RooAbsArg *) iter.Next(); a != 0; a = (RooAbsArg *) iter.Next()) { + for (RooAbsArg *a : *mc->GetNuisanceParameters()) { RooRealVar *rrv = dynamic_cast(a); if (rrv != 0) { RooAbsPdf *pdf = w->pdf((std::string(a->GetName())+"_Pdf").c_str()); @@ -689,8 +688,7 @@ void FitterAlgoBase::optimizeBounds(const RooWorkspace *w, const RooStats::Model } } if (runtimedef::get("OPTIMIZE_BOUNDS") && mc->GetNuisanceParameters() != 0) { - RooLinkedListIter iter = mc->GetNuisanceParameters()->iterator(); - for (RooAbsArg *a = (RooAbsArg *) iter.Next(); a != 0; a = (RooAbsArg *) iter.Next()) { + for (RooAbsArg *a : *mc->GetNuisanceParameters()) { RooRealVar *rrv = dynamic_cast(a); //std::cout << (rrv ? "Var" : "Arg") << ": " << a->GetName() << ": " << a->getAttribute("optimizeBounds") << std::endl; if (rrv != 0 && rrv->getAttribute("optimizeBounds")) { 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/MarkovChainMC.cc b/src/MarkovChainMC.cc index 8397209ccd3..42e5caa87ea 100644 --- a/src/MarkovChainMC.cc +++ b/src/MarkovChainMC.cc @@ -262,8 +262,7 @@ int MarkovChainMC::runOnce(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStat if (verbose > 1) { std::cout << "\nDiscrete model point " << (i+1) << std::endl; discreteModelPointSets_[i].Print("V"); } } RooArgSet discretePOI; - RooLinkedListIter iter = poi.iterator(); - for (RooAbsArg *a = (RooAbsArg *) iter.Next(); a != 0; a = (RooAbsArg *) iter.Next()) { + for (RooAbsArg *a : poi) { if (discreteModelPointSets_[0].find(a->GetName())) discretePOI.add(*a); } if (verbose > 1) { std::cout << "Discrete POI: " ; discretePOI.Print(""); } diff --git a/src/ProfiledLikelihoodRatioTestStatExt.cc b/src/ProfiledLikelihoodRatioTestStatExt.cc index b3378f154b0..5651a0da40f 100644 --- a/src/ProfiledLikelihoodRatioTestStatExt.cc +++ b/src/ProfiledLikelihoodRatioTestStatExt.cc @@ -152,8 +152,7 @@ ProfiledLikelihoodTestStatOpt::ProfiledLikelihoodTestStatOpt( DBG(DBG_PLTestStat_ctor, (std::cout << "All params: " << std::endl)) DBG(DBG_PLTestStat_ctor, (params_->Print("V"))) DBG(DBG_PLTestStat_ctor, (std::cout << "Snapshot: " << std::endl)) DBG(DBG_PLTestStat_ctor, (snap_.Print("V"))) DBG(DBG_PLTestStat_ctor, (std::cout << "POI: " << std::endl)) DBG(DBG_PLTestStat_ctor, (poi_.Print("V"))) - RooLinkedListIter it = poi.iterator(); - for (RooAbsArg *a = (RooAbsArg*) it.Next(); a != 0; a = (RooAbsArg*) it.Next()) { + for (RooAbsArg *a : poi) { // search for this poi in the parameters and in the snapshot RooAbsArg *ps = snap_.find(a->GetName()); RooAbsArg *pp = params_->find(a->GetName()); 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