Skip to content

Commit

Permalink
Merge pull request #977 from cms-analysis/rootv632_rtcompat
Browse files Browse the repository at this point in the history
Replace old iterators in python script (ROOT 6.32 compatibility), fixing python scripts
  • Loading branch information
anigamova authored Jun 24, 2024
2 parents 61d6dba + 0d6fc50 commit 732b132
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 20 deletions.
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

0 comments on commit 732b132

Please sign in to comment.