Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace old iterators in python script (ROOT 6.32 compatibility), fixing python scripts #977

Merged
merged 5 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions bin/PerfTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ int main(int argc, char *argv[]) {
}

RooWorkspace *w = (RooWorkspace*)gDirectory->Get(argv[2]);
// w->Print();
auto allfuncs = w->allFunctions();
auto it =allfuncs.fwdIterator();
for (RooAbsArg *a = it.next(); a != 0; a = it.next()) {
for (auto *a: allfuncs){
auto rrv = dynamic_cast<RooAbsReal*>(a);
if (rrv) {
rrv->getVal();
Expand Down
6 changes: 2 additions & 4 deletions python/ModelTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,9 @@ def doModel(self, justCheckPhysicsModel=False):
self.physics.doParametersOfInterest()

# set a group attribute on POI variables
poiIter = self.out.set("POI").createIterator()
poi = poiIter.Next()
while poi:
pois = self.out.set("POI")
for poi in pois:
self.out.var(poi.GetName()).setAttribute("group_POI", True)
poi = poiIter.Next()
self.physics.preProcessNuisances(self.DC.systs)
self.doNuisances()
self.doExtArgs()
Expand Down
18 changes: 7 additions & 11 deletions python/ShapeTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,7 @@ def doCombination(self):
self.out.safe_import(arg, ROOT.RooFit.RecycleConflictNodes())
if self.options.fixpars:
pars = self.out.pdf("model_s").getParameters(self.out.obs)
iter = pars.createIterator()
while True:
arg = iter.Next()
for arg in pars:
if arg == None:
break
if arg.InheritsFrom("RooRealVar") and arg.GetName() != "r":
Expand Down Expand Up @@ -1007,12 +1005,11 @@ def getPdf(self, channel, process, _cache={}):
pdfs.Add(self.shape2Pdf(shapeUp, channel, process))
pdfs.Add(self.shape2Pdf(shapeDown, channel, process))
histpdf = nominalPdf if nominalPdf.InheritsFrom("RooDataHist") else nominalPdf.dataHist()
varIter = histpdf.get().createIterator()
xvar = varIter.Next()
yvar = varIter.Next()
if varIter.Next():
if histpdf.get().getSize() > 2:
raise ValueError("No support for 3+ dimensional histpdfs")
elif yvar:
elif histpdf.get().getSize() > 1:
xvar = histpdf.get().first()
yvar = histpdf.get().second()
rhp = ROOT.FastVerticalInterpHistPdf2D2(
"shape%s_%s_%s_morph" % (postFix, channel, process),
"",
Expand All @@ -1025,6 +1022,7 @@ def getPdf(self, channel, process, _cache={}):
qalgo,
)
else:
xvar = histpdf.get().first()
rhp = ROOT.FastVerticalInterpHistPdf2(
"shape%s_%s_%s_morph" % (postFix, channel, process),
"",
Expand Down Expand Up @@ -1332,9 +1330,7 @@ def checkRooAddPdf(self, channel, process, pdf):

def argSetToString(self, argset):
names = []
it = argset.createIterator()
while True:
arg = it.Next()
for arg in argset:
if not arg:
break
names.append(arg.GetName())
Expand Down
2 changes: 1 addition & 1 deletion scripts/plot1DScan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
from __future__ import absolute_import
from __future__ import print_function
import ROOT
Expand Down
1 change: 1 addition & 0 deletions scripts/plotBSMxsBRLimit.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python3
from __future__ import absolute_import
from __future__ import print_function
import HiggsAnalysis.CombinedLimit.util.plotting as plot
Expand Down
2 changes: 1 addition & 1 deletion scripts/plotLimitGrid.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
from __future__ import absolute_import
from __future__ import print_function
import HiggsAnalysis.CombinedLimit.util.plotting as plot
Expand Down
Loading