Skip to content

Commit

Permalink
Next chunk of changes
Browse files Browse the repository at this point in the history
  • Loading branch information
guitargeek committed Dec 3, 2023
1 parent d53d98d commit a275836
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 29 deletions.
5 changes: 1 addition & 4 deletions interface/FastTemplateFunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@ template <typename T> 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<RooAbsReal*>(var)) {
assert(0);
}
proxyList.add(*var);
}
delete varIter;
}

virtual TObject* clone(const char* newname) const = 0;
Expand Down
13 changes: 5 additions & 8 deletions src/AsimovUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <memory>
#include <stdexcept>
#include <TIterator.h>
#include <RooAbsData.h>
#include <RooArgSet.h>
#include <RooProdPdf.h>
Expand Down Expand Up @@ -89,8 +88,7 @@ RooAbsData *asimovutils::asimovDatasetWithFit(RooStats::ModelConfig *mc, RooAbsD
std::unique_ptr<RooAbsPdf> nuispdf(utils::makeNuisancePdf(*mc));
RooProdPdf *prod = dynamic_cast<RooProdPdf *>(nuispdf.get());
if (prod == 0) throw std::runtime_error("AsimovUtils: the nuisance pdf is not a RooProdPdf!");
std::unique_ptr<TIterator> 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<RooAbsPdf *>(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
Expand All @@ -106,8 +104,7 @@ RooAbsData *asimovutils::asimovDatasetWithFit(RooStats::ModelConfig *mc, RooAbsD
if (cpars->getSize() == 1) {
match = dynamic_cast<RooAbsReal *>(cpars->first());
} else {
std::unique_ptr<TIterator> iter2(cpars->createIterator());
for (RooAbsArg *a2 = (RooAbsArg *) iter2->Next(); a2 != 0; a2 = (RooAbsArg *) iter2->Next()) {
for (RooAbsArg *a2 : *cpars) {
RooRealVar *rrv2 = dynamic_cast<RooRealVar *>(a2);
if (rrv2 != 0 && !rrv2->isConstant()) {
if (match != 0) throw std::runtime_error(Form("AsimovUtils: constraint term %s has multiple floating params", cterm->GetName()));
Expand Down Expand Up @@ -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<TIterator> 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<RooAbsReal *>(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()));
Expand Down
3 changes: 1 addition & 2 deletions src/AsymptoticLimits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<TIterator> itparam(params_->createIterator());
for (RooAbsArg *a = (RooAbsArg *) itparam->Next(); a != 0; a = (RooAbsArg *) itparam->Next()) {
for (RooAbsArg *a : *params_) {
RooRealVar *rrv = dynamic_cast<RooRealVar *>(a);
if ( rrv != 0 && rrv != r && rrv->isConstant() == false ) { hasFloatParams_ = true; break; }
}
Expand Down
6 changes: 2 additions & 4 deletions src/FitterAlgoBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<RooRealVar *>(a);
if (rrv != 0) {
RooAbsPdf *pdf = w->pdf((std::string(a->GetName())+"_Pdf").c_str());
Expand All @@ -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<RooRealVar *>(a);
//std::cout << (rrv ? "Var" : "Arg") << ": " << a->GetName() << ": " << a->getAttribute("optimizeBounds") << std::endl;
if (rrv != 0 && rrv->getAttribute("optimizeBounds")) {
Expand Down
1 change: 0 additions & 1 deletion src/HWWLVJRooPdfs.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/HZZ4L_RooSpinZeroPdf_phase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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() ;
}


Expand Down
3 changes: 1 addition & 2 deletions src/MarkovChainMC.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(""); }
Expand Down
3 changes: 1 addition & 2 deletions src/ProfiledLikelihoodRatioTestStatExt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
6 changes: 2 additions & 4 deletions src/SimplerLikelihoodRatioTestStatExt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<TIterator> 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);
}
}
Expand All @@ -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_);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/TestProposal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <iostream>
#include <memory>
#include <stdexcept>
#include <TIterator.h>
#include <RooRandom.h>
#include <RooStats/RooStatsUtils.h>

Expand Down

0 comments on commit a275836

Please sign in to comment.