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

Ported to python3 using 2to3 script #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
20 changes: 10 additions & 10 deletions python/AnaliticAnomalousCouplingEFTNegativeExtended.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,21 @@ def __init__(self):
self.CompleteOperators = self.Operators + self.OperatorsDim8

self.numOperators = len(self.Operators)
print " Operators = ", self.Operators
print(" Operators = ", self.Operators)


def setPhysicsOptions(self,physOptions):
for po in physOptions:
if po.startswith("higgsMassRange="):
self.mHRange = po.replace("higgsMassRange=","").split(",")
if len(self.mHRange) != 2:
raise RuntimeError, "Higgs mass range definition requires two extrema"
raise RuntimeError("Higgs mass range definition requires two extrema")
elif float(self.mHRange[0]) >= float(self.mHRange[1]):
raise RuntimeError, "Extrema for Higgs mass range defined with inverterd order. Second must be larger the first"
raise RuntimeError("Extrema for Higgs mass range defined with inverterd order. Second must be larger the first")

if po.startswith("eftOperators="):
self.Operators = po.replace("eftOperators=","").split(",")
print " Operators = ", self.Operators
print(" Operators = ", self.Operators)
self.numOperators = len(self.Operators)

if po.startswith("eftAlternative"):
Expand Down Expand Up @@ -438,7 +438,7 @@ def doParametersOfInterest(self):
# Building PDF for EFT2Obs datacards only if specified by command line options
if self.UseEFT2Obs:

for an_ in self.json_map.keys():
for an_ in list(self.json_map.keys()):

# build the function
op_dict = {k: {"par": "k_" + k, "at": "@"+str(idx+1)} for idx, k in enumerate(self.Operators)}
Expand Down Expand Up @@ -468,13 +468,13 @@ def doParametersOfInterest(self):
if all(i in self.Operators for i in b[2:]):
func += " + {}*{}*{} ".format(b[0], op_dict[b[2]]["at"], op_dict[b[3]]["at"])

func += ")\",r,k_" + ",k_".join( it_[0] for it_ in sorted(op_dict.items(), key= lambda x: x[1] ) ) + ")"
func += ")\",r,k_" + ",k_".join( it_[0] for it_ in sorted(list(op_dict.items()), key= lambda x: x[1] ) ) + ")"
print(func)
self.modelBuilder.factory_(func)


print " parameters of interest = ", self.poiNames
print " self.numOperators = ", self.numOperators
print(" parameters of interest = ", self.poiNames)
print(" self.numOperators = ", self.numOperators)

self.modelBuilder.doSet("POI",self.poiNames)

Expand Down Expand Up @@ -514,9 +514,9 @@ def getYieldScale(self,bin,process):
return "func_quadratic_mixed_" + str(self.Operators[operator_sub]) + "_" + str(self.Operators[operator])

if self.UseEFT2Obs:
for an_ in self.json_map.keys():
for an_ in list(self.json_map.keys()):
if process in self.json_map[an_]["bin_labels"]:
print("---> Will scale " + process + " with " + "func_EFT2Obs_" + process)
print(("---> Will scale " + process + " with " + "func_EFT2Obs_" + process))
return "func_EFT2Obs_" + process


Expand Down
8 changes: 4 additions & 4 deletions python/AnomalousCoupling.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def setPhysicsOptions(self,physOptions):
if po.startswith("higgsMassRange="):
self.mHRange = po.replace("higgsMassRange=","").split(",")
if len(self.mHRange) != 2:
raise RuntimeError, "Higgs mass range definition requires two extrema"
raise RuntimeError("Higgs mass range definition requires two extrema")
elif float(self.mHRange[0]) >= float(self.mHRange[1]):
raise RuntimeError, "Extrema for Higgs mass range defined with inverterd order. Second must be larger the first"
raise RuntimeError("Extrema for Higgs mass range defined with inverterd order. Second must be larger the first")

if po.startswith("numOperators="):
self.numOperators = int ( po.replace("numOperators=","") )
Expand Down Expand Up @@ -75,8 +75,8 @@ def doParametersOfInterest(self):
self.modelBuilder.factory_("expr::quadratic_func_"+ str(operator) + "(\"@0*@1*@1\",r,k_my_" + str(operator) + ")")


print " parameters of interesst = "
print self.poiNames
print(" parameters of interesst = ")
print(self.poiNames)
self.modelBuilder.doSet("POI",self.poiNames)


Expand Down
8 changes: 4 additions & 4 deletions python/AnomalousCouplingEFT.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ def setPhysicsOptions(self,physOptions):
if po.startswith("higgsMassRange="):
self.mHRange = po.replace("higgsMassRange=","").split(",")
if len(self.mHRange) != 2:
raise RuntimeError, "Higgs mass range definition requires two extrema"
raise RuntimeError("Higgs mass range definition requires two extrema")
elif float(self.mHRange[0]) >= float(self.mHRange[1]):
raise RuntimeError, "Extrema for Higgs mass range defined with inverterd order. Second must be larger the first"
raise RuntimeError("Extrema for Higgs mass range defined with inverterd order. Second must be larger the first")
if po.startswith("eftOperators="):
self.Operators = po.replace("eftOperators=","").split(",")
print " Operators = ", self.Operators
print(" Operators = ", self.Operators)
self.numOperators = len(self.Operators)


Expand Down Expand Up @@ -180,7 +180,7 @@ def doParametersOfInterest(self):
self.modelBuilder.factory_("expr::linear_func_mixed_" + str(self.Operators[operator]) + "_" + str(self.Operators[operator_sub]) +"(\"@0*@1*@2\",r,k_" + str(self.Operators[operator]) + ",k_" + str(self.Operators[operator_sub]) + ")")
#print "expr::linear_func_mixed_" + str(self.Operators[operator]) + "_" + str(self.Operators[operator_sub]) +"(\"@0*@1*@2\",r,k_" + str(self.Operators[operator]) + ",k_" + str(self.Operators[operator_sub]) + ")"

print " parameters of interest = ", self.poiNames
print(" parameters of interest = ", self.poiNames)
self.modelBuilder.doSet("POI",self.poiNames)


Expand Down
18 changes: 9 additions & 9 deletions python/AnomalousCouplingEFTNegative.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,21 @@ def __init__(self):
self.CompleteOperators = self.Operators + self.OperatorsDim8

self.numOperators = len(self.Operators)
print " Operators = ", self.Operators
print(" Operators = ", self.Operators)


def setPhysicsOptions(self,physOptions):
for po in physOptions:
if po.startswith("higgsMassRange="):
self.mHRange = po.replace("higgsMassRange=","").split(",")
if len(self.mHRange) != 2:
raise RuntimeError, "Higgs mass range definition requires two extrema"
raise RuntimeError("Higgs mass range definition requires two extrema")
elif float(self.mHRange[0]) >= float(self.mHRange[1]):
raise RuntimeError, "Extrema for Higgs mass range defined with inverterd order. Second must be larger the first"
raise RuntimeError("Extrema for Higgs mass range defined with inverterd order. Second must be larger the first")

if po.startswith("eftOperators="):
self.Operators = po.replace("eftOperators=","").split(",")
print " Operators = ", self.Operators
print(" Operators = ", self.Operators)
self.numOperators = len(self.Operators)

if po.startswith("eftAlternative"):
Expand All @@ -167,18 +167,18 @@ def setPhysicsOptions(self,physOptions):
#
if po.startswith("defineCompleteOperators="):
self.CompleteOperators = po.replace("defineCompleteOperators=","").split(",")
print " CompleteOperators = ", self.CompleteOperators
print(" CompleteOperators = ", self.CompleteOperators)

if po.startswith("addToCompleteOperators="):
toAddOperators = po.replace("addToCompleteOperators=","").split(",")
self.CompleteOperators.extend ( toAddOperators )
print " CompleteOperators = ", self.CompleteOperators
print(" CompleteOperators = ", self.CompleteOperators)

if po.startswith("removeFromCompleteOperators="):
toRemoveOperators = po.replace("removeFromCompleteOperators=","").split(",")
newlist = [i for i in self.CompleteOperators if i not in toRemoveOperators]
self.CompleteOperators = newlist
print " CompleteOperators = ", self.CompleteOperators
print(" CompleteOperators = ", self.CompleteOperators)


#
Expand Down Expand Up @@ -435,8 +435,8 @@ def doParametersOfInterest(self):



print " parameters of interest = ", self.poiNames
print " self.numOperators = ", self.numOperators
print(" parameters of interest = ", self.poiNames)
print(" self.numOperators = ", self.numOperators)

self.modelBuilder.doSet("POI",self.poiNames)

Expand Down
14 changes: 7 additions & 7 deletions python/AnomalousCouplingLinearEFTNegative.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def __init__(self):

self.numOperators = len(self.Operators)

print " Operators = ", self.Operators
print(" Operators = ", self.Operators)



Expand All @@ -152,13 +152,13 @@ def setPhysicsOptions(self,physOptions):
if po.startswith("higgsMassRange="):
self.mHRange = po.replace("higgsMassRange=","").split(",")
if len(self.mHRange) != 2:
raise RuntimeError, "Higgs mass range definition requires two extrema"
raise RuntimeError("Higgs mass range definition requires two extrema")
elif float(self.mHRange[0]) >= float(self.mHRange[1]):
raise RuntimeError, "Extrema for Higgs mass range defined with inverterd order. Second must be larger the first"
raise RuntimeError("Extrema for Higgs mass range defined with inverterd order. Second must be larger the first")

if po.startswith("eftOperators="):
self.Operators = po.replace("eftOperators=","").split(",")
print " Operators = ", self.Operators
print(" Operators = ", self.Operators)
self.numOperators = len(self.Operators)

if po.startswith("addDim8"):
Expand All @@ -167,7 +167,7 @@ def setPhysicsOptions(self,physOptions):

if po.startswith("reuseCompleteDatacards"):
self.reuseCompleteDatacards = True
print " reuseCompleteDatacards = ", self.reuseCompleteDatacards
print(" reuseCompleteDatacards = ", self.reuseCompleteDatacards)


#
Expand Down Expand Up @@ -276,8 +276,8 @@ def doParametersOfInterest(self):
"(\"-@0*@1\",r," + "k_" + str(self.Operators[operator]) + ")"
)

print " parameters of interest = ", self.poiNames
print " self.numOperators = ", self.numOperators
print(" parameters of interest = ", self.poiNames)
print(" self.numOperators = ", self.numOperators)

self.modelBuilder.doSet("POI",self.poiNames)

Expand Down
6 changes: 3 additions & 3 deletions python/AnomalousCouplingOneOp.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def setPhysicsOptions(self,physOptions):
if po.startswith("higgsMassRange="):
self.mHRange = po.replace("higgsMassRange=","").split(",")
if len(self.mHRange) != 2:
raise RuntimeError, "Higgs mass range definition requires two extrema"
raise RuntimeError("Higgs mass range definition requires two extrema")
elif float(self.mHRange[0]) >= float(self.mHRange[1]):
raise RuntimeError, "Extrema for Higgs mass range defined with inverterd order. Second must be larger the first"
raise RuntimeError("Extrema for Higgs mass range defined with inverterd order. Second must be larger the first")

#
# standard, not touched (end)
Expand Down Expand Up @@ -53,7 +53,7 @@ def doParametersOfInterest(self):
self.modelBuilder.factory_("expr::linear_func(\"@0*@1\",r,k_my)")
self.modelBuilder.factory_("expr::quadratic_func(\"@0*@1*@1\",r,k_my)")

print self.poiNames
print(self.poiNames)
self.modelBuilder.doSet("POI",self.poiNames)


Expand Down
6 changes: 3 additions & 3 deletions python/AnomalousCouplingTwoOp.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def setPhysicsOptions(self,physOptions):
if po.startswith("higgsMassRange="):
self.mHRange = po.replace("higgsMassRange=","").split(",")
if len(self.mHRange) != 2:
raise RuntimeError, "Higgs mass range definition requires two extrema"
raise RuntimeError("Higgs mass range definition requires two extrema")
elif float(self.mHRange[0]) >= float(self.mHRange[1]):
raise RuntimeError, "Extrema for Higgs mass range defined with inverterd order. Second must be larger the first"
raise RuntimeError("Extrema for Higgs mass range defined with inverterd order. Second must be larger the first")

#
# standard, not touched (end)
Expand Down Expand Up @@ -63,7 +63,7 @@ def doParametersOfInterest(self):
self.modelBuilder.factory_("expr::quadratic_func_1(\"@0*@1*@1\",r,k_my_1)")
self.modelBuilder.factory_("expr::quadratic_func_2(\"@0*@1*@1\",r,k_my_2)")

print self.poiNames
print(self.poiNames)
self.modelBuilder.doSet("POI",self.poiNames)


Expand Down
22 changes: 11 additions & 11 deletions scripts/HistoRy.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def setScan(self, file, tree):


c = dict.fromkeys(self.pois)
self.pois = c.keys()
self.pois = list(c.keys())

self.ppois = list(combinations(self.pois, 2))

Expand Down Expand Up @@ -155,7 +155,7 @@ def compute(self, poiInterest):
print("#####################")
print(poiInterest)
print("#####################")
print(self.minimPoisValue)
print((self.minimPoisValue))
print("#####################")

self.historySingleHistos[poiInterest] = {}
Expand All @@ -176,7 +176,7 @@ def compute(self, poiInterest):
fact += poiPair_sum
fact *= self.minimPoisValue["r"]

print("--> SM fact " + str(fact))
print(("--> SM fact " + str(fact)))

bench.Scale(fact)
self.historySingleHistos[poiInterest]["SM"] = deepcopy(bench)
Expand All @@ -193,7 +193,7 @@ def compute(self, poiInterest):

fact*=self.minimPoisValue["r"]

print("--> Sm li qu {} fact ".format(poi) + str(fact))
print(("--> Sm li qu {} fact ".format(poi) + str(fact)))

h.Scale(fact)
self.historySingleHistos[poiInterest]["sm_lin_quad_"+ poi.strip("k_")] = h
Expand All @@ -202,7 +202,7 @@ def compute(self, poiInterest):
#qu
for poi in self.pois:
h = deepcopy(self.shapes["histo_quad_" + poi.strip("k_")])
print("--> qu {} fact ".format(poi) + str(self.minimPoisValue["r"]*(self.minimPoisValue[poi]*self.minimPoisValue[poi] - self.minimPoisValue[poi])))
print(("--> qu {} fact ".format(poi) + str(self.minimPoisValue["r"]*(self.minimPoisValue[poi]*self.minimPoisValue[poi] - self.minimPoisValue[poi]))))
h.Scale( self.minimPoisValue["r"]*(self.minimPoisValue[poi]*self.minimPoisValue[poi] - self.minimPoisValue[poi]) )
self.historySingleHistos[poiInterest]["quad_"+ poi.strip("k_")] = h

Expand All @@ -213,17 +213,17 @@ def compute(self, poiInterest):

name = "histo_sm_lin_quad_mixed_" + ppair[0].strip("k_") + "_" + ppair[1].strip("k_")

if name not in self.shapes.keys():
if name not in list(self.shapes.keys()):
name = "histo_sm_lin_quad_mixed_" + ppair[1].strip("k_") + "_" + ppair[0].strip("k_")

if name not in self.shapes.keys():
print ("No shape for {} {}".format(ppair[0], ppair[1]))
if name not in list(self.shapes.keys()):
print(("No shape for {} {}".format(ppair[0], ppair[1])))
continue

h = deepcopy(self.shapes[name])
fact = self.minimPoisValue["r"] * self.minimPoisValue[ppair[0]] * self.minimPoisValue[ppair[1]]

print("--> mixed {} {} fact ".format(ppair[0], ppair[1]) + str(fact))
print(("--> mixed {} {} fact ".format(ppair[0], ppair[1]) + str(fact)))

h.Scale(fact)
self.historySingleHistos[poiInterest][name.split("histo_")[1]] = h
Expand All @@ -233,7 +233,7 @@ def compute(self, poiInterest):

#print(bench.Integral(), self.shapes["histo_sm"].Integral())
if bench.GetMinimum() < 0:
print ("foundBin < 0" + str(bench.GetMinimum()) )
print(("foundBin < 0" + str(bench.GetMinimum()) ))

return bench

Expand All @@ -247,7 +247,7 @@ def runHistoryEFTNeg(self):
for event in t:
for poi in self.pois:
self.minimPoisValue[poi] = getattr(event, poi)
for key in self.rateParam.keys():
for key in list(self.rateParam.keys()):
self.rateParam[key].append(getattr(event, key))

self.minimPoisValue["r"] = 1 if not self.has_r_SignalStrength else getattr(event, "r")
Expand Down
Loading