Skip to content

Commit

Permalink
Merge pull request #23858 from davidlange6/printMig_180718T4_ElectroW…
Browse files Browse the repository at this point in the history
…eakAnalysis_ZMuMu

Print function migration for ElectroWeakAnalysis_ZMuMu
  • Loading branch information
cmsbuild committed Jul 19, 2018
2 parents 20f6e7b + a90dd6a commit 9e16c92
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 49 deletions.
3 changes: 2 additions & 1 deletion ElectroWeakAnalysis/ZMuMu/test/EWKSystUnc.py
@@ -1,3 +1,4 @@
from __future__ import print_function
import FWCore.ParameterSet.Config as cms
import copy

Expand Down Expand Up @@ -90,7 +91,7 @@



print "sequence", seq
print("sequence", seq)

process.options = cms.untracked.PSet(
wantSummary = cms.untracked.bool(True)
Expand Down
47 changes: 24 additions & 23 deletions ElectroWeakAnalysis/ZMuMu/test/EvalPdfUnc.py
@@ -1,3 +1,4 @@
from __future__ import print_function
import os, sys, re
import string
import math
Expand All @@ -6,14 +7,14 @@
usage = "usage: %s python EvalPdfUnc.py infile outfile" % os.path.basename(sys.argv[0])

if len(sys.argv) < 3:
print usage
print(usage)
sys.exit(2)
else:
argv = sys.argv
print argv
print(argv)
infile = argv[1]
outfile = argv[2]
print argv[1]
print(argv[1])
f = open(infile, 'read')
## outfile in append mode
ff = open(outfile,'a')
Expand Down Expand Up @@ -45,14 +46,14 @@ def mean ( v):
return ( mean / n )

avg_acc = mean (acc)
print "mean acc: ", avg_acc
print("mean acc: ", avg_acc)
avg_acc_rew = mean (acc_rew)
print "mean acc_rew: ", avg_acc_rew
print("mean acc_rew: ", avg_acc_rew)
diff_acc= (avg_acc_rew - avg_acc) / ( avg_acc )
avg_nevt = mean (nevt)
print "mean nevt: ", avg_nevt
print("mean nevt: ", avg_nevt)
avg_nevt_rew = mean (nevt_rew)
print "mean nevt_rew: ", avg_nevt_rew
print("mean nevt_rew: ", avg_nevt_rew)
diff_evt = (avg_nevt_rew - avg_nevt) / ( avg_nevt )


Expand All @@ -79,16 +80,16 @@ def eval_asym_sys(eff):
tmp = d1
d1 = -d2
d2 = -tmp
print idx/2, ' ' , x0, '[+', d1, ' -', d2, ']'
print(idx/2, ' ' , x0, '[+', d1, ' -', d2, ']')
m1 = max(d1, 0.)
s1 += m1*m1
m2 = max(d2, 0.)
s2 += m2*m2
s1 = sqrt(s1)
s2 = sqrt(s2)
print >> ff, infile, 'asym error'
print >> ff , ' x = ', x0, '[+', s1, ' -', s2, ']'
print >> ff, 'err = +', s1/x0*100, ' -', s2/x0*100
print(infile, 'asym error', file=ff)
print(' x = ', x0, '[+', s1, ' -', s2, ']', file=ff)
print('err = +', s1/x0*100, ' -', s2/x0*100, file=ff)



Expand All @@ -114,13 +115,13 @@ def eval_max_asym_sys(eff):
tmp = d1
d1 = -d2
d2 = -tmp
print idx/2, ' ' , x0, '[+', d1, ' -', d2, ']'
print(idx/2, ' ' , x0, '[+', d1, ' -', d2, ']')
m = max(abs(d1), abs(d2))
s1 += m*m
s1 = sqrt(s1)
print >> ff, infile, 'sym error taking the max between asym errors'
print >> ff , ' x = ', x0, '[+', s1, ' -', s1, ']'
print >> ff, 'err = +', s1/x0*100, ' -', s1/x0*100
print(infile, 'sym error taking the max between asym errors', file=ff)
print(' x = ', x0, '[+', s1, ' -', s1, ']', file=ff)
print('err = +', s1/x0*100, ' -', s1/x0*100, file=ff)



Expand All @@ -147,13 +148,13 @@ def eval_mean_asym_sys(eff):
tmp = d1
d1 = -d2
d2 = -tmp
print idx/2, ' ' , x0, '[+', d1, ' -', d2, ']'
print(idx/2, ' ' , x0, '[+', d1, ' -', d2, ']')
m = 0.5 * ( abs(d1) + abs(d2))
s1 += m*m
s1 = sqrt(s1)
print >> ff, infile, 'sym error taking the mean between asym errors'
print >> ff , ' x = ', x0, '[+', s1, ' -', s1, ']'
print >> ff, 'err = +', s1/x0*100, ' -', s1/x0*100
print(infile, 'sym error taking the mean between asym errors', file=ff)
print(' x = ', x0, '[+', s1, ' -', s1, ']', file=ff)
print('err = +', s1/x0*100, ' -', s1/x0*100, file=ff)



Expand All @@ -179,13 +180,13 @@ def eval_quadsum_asym_sys(eff):
tmp = d1
d1 = -d2
d2 = -tmp
print idx/2, ' ' , x0, '[+', d1, ' -', d2, ']'
print(idx/2, ' ' , x0, '[+', d1, ' -', d2, ']')
m = sqrt( 0.5 *( abs(d1)* abs(d1) + abs(d2)*abs(d2)) )
s1 += m*m
s1 = sqrt(s1)
print >> ff, infile, 'sym error taking the qaudratic sum between asym errors'
print >> ff , ' x = ', x0, '[+', s1, ' -', s1, ']'
print >> ff, 'err = +', s1/x0*100, ' -', s1/x0*100
print(infile, 'sym error taking the qaudratic sum between asym errors', file=ff)
print(' x = ', x0, '[+', s1, ' -', s1, ']', file=ff)
print('err = +', s1/x0*100, ' -', s1/x0*100, file=ff)


sys_acc_asym = eval_asym_sys(acc_rew)
Expand Down
3 changes: 2 additions & 1 deletion ElectroWeakAnalysis/ZMuMu/test/mcAcceptanceForDistMuons.py
@@ -1,3 +1,4 @@
from __future__ import print_function
import FWCore.ParameterSet.Config as cms

process = cms.Process("MCAcceptance")
Expand All @@ -22,7 +23,7 @@
basenamelist = os.listdir(dirname + "/")
for basename in basenamelist:
process.source.fileNames.append("file:" + dirname + "/" + basename)
print "Number of files to process is %s" % (len(process.source.fileNames))
print("Number of files to process is %s" % (len(process.source.fileNames)))



Expand Down
@@ -1,3 +1,4 @@
from __future__ import print_function
#analysis code.
#It produces plot for Fit study
#author Luca Lista
Expand Down Expand Up @@ -229,7 +230,7 @@
etaBounds = [-2, 2.0]

def addModulesFromTemplate(sequence, moduleLabel, src, probeSelection):
print "selection for: ", moduleLabel
print("selection for: ", moduleLabel)
for i in range(len(etaBounds)-1):
etaMin = etaBounds[i]
etaMax = etaBounds[i+1]
Expand All @@ -238,7 +239,7 @@ def addModulesFromTemplate(sequence, moduleLabel, src, probeSelection):
cut = "%5.3f < daughter(1).eta < %5.3f" %(etaMin, etaMax)
elif probeSelection == "double":
cut = "%5.3f < daughter(0).eta < %5.3f | %5.3f < daughter(1).eta < %5.3f" %(etaMin, etaMax, etaMin, etaMax)
print i, ") cut = ", cut
print(i, ") cut = ", cut)
setattr(module, "cut", cut)
setattr(module, "src", cms.InputTag(src))
copyModuleLabel = moduleLabel + str(i)
Expand Down
5 changes: 3 additions & 2 deletions ElectroWeakAnalysis/ZMuMu/test/old/zToMuMuAnalysis_zmm.py
@@ -1,3 +1,4 @@
from __future__ import print_function
#analysis code.
#It produces plot for Fit study
#author Luca Lista
Expand Down Expand Up @@ -206,7 +207,7 @@
etaBounds = [-2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2.0]

def addModulesFromTemplate(sequence, moduleLabel, src, probeSelection):
print "selection for: ", moduleLabel
print("selection for: ", moduleLabel)
for i in range(len(etaBounds)-1):
etaMin = etaBounds[i]
etaMax = etaBounds[i+1]
Expand All @@ -215,7 +216,7 @@ def addModulesFromTemplate(sequence, moduleLabel, src, probeSelection):
cut = "%5.3f < daughter(1).eta < %5.3f" %(etaMin, etaMax)
elif probeSelection == "double":
cut = "%5.3f < daughter(0).eta < %5.3f | %5.3f < daughter(1).eta < %5.3f" %(etaMin, etaMax, etaMin, etaMax)
print i, ") cut = ", cut
print(i, ") cut = ", cut)
setattr(module, "cut", cut)
setattr(module, "src", cms.InputTag(src))
copyModuleLabel = moduleLabel + str(i)
Expand Down
@@ -1,3 +1,4 @@
from __future__ import print_function
import FWCore.ParameterSet.Config as cms
import copy

Expand Down Expand Up @@ -131,7 +132,7 @@
etaBounds = [-2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2.0]

def addModulesFromTemplate(sequence, moduleLabel, src, probeSelection):
print "selection for: ", moduleLabel
print("selection for: ", moduleLabel)
for i in range(len(etaBounds)-1):
etaMin = etaBounds[i]
etaMax = etaBounds[i+1]
Expand All @@ -140,7 +141,7 @@ def addModulesFromTemplate(sequence, moduleLabel, src, probeSelection):
cut = "%5.3f < daughter(1).eta < %5.3f" %(etaMin, etaMax)
elif probeSelection == "double":
cut = "%5.3f < daughter(0).eta < %5.3f | %5.3f < daughter(1).eta < %5.3f" %(etaMin, etaMax, etaMin, etaMax)
print i, ") cut = ", cut
print(i, ") cut = ", cut)
setattr(module, "cut", cut)
setattr(module, "src", cms.InputTag(src))
copyModuleLabel = moduleLabel + str(i)
Expand Down
13 changes: 7 additions & 6 deletions ElectroWeakAnalysis/ZMuMu/test/zMuMuIsolationAnalysis.py
@@ -1,3 +1,4 @@
from __future__ import print_function
import FWCore.ParameterSet.Config as cms
import copy

Expand Down Expand Up @@ -54,7 +55,7 @@

for i in range(len(cut)):
ptThreshold = cut[i]
print i, ") cut = ", ptThreshold
print(i, ") cut = ", ptThreshold)

plotModuleLabel = "isoPlots_ptTkr_" + str(i);
module = copy.deepcopy(process.zmumuNewIsolation)
Expand All @@ -70,7 +71,7 @@

for i in range(len(ecal_cut)):
etEcalThreshold = ecal_cut[i]
print i, ") cut = ", etEcalThreshold
print(i, ") cut = ", etEcalThreshold)

plotModuleLabel = "isoPlots_etEcal_" + str(i);
module = copy.deepcopy(process.zmumuNewIsolation)
Expand All @@ -86,7 +87,7 @@

for i in range(len(hcal_cut)):
etHcalThreshold = hcal_cut[i]
print i, ") cut = ", etHcalThreshold
print(i, ") cut = ", etHcalThreshold)

plotModuleLabel = "isoPlots_etHcal_" + str(i);
module = copy.deepcopy(process.zmumuNewIsolation)
Expand All @@ -105,7 +106,7 @@
deltaREcal = deltaR_[i]
deltaRHcal = deltaR_[i]

print i, ") deltaR = ", deltaRTrk
print(i, ") deltaR = ", deltaRTrk)

plotModuleLabel = "isoPlots_DR_" + str(i);
module = copy.deepcopy(process.zmumuNewIsolation)
Expand All @@ -124,11 +125,11 @@

for i in range(len(alpha_array)):
alpha = alpha_array[i]
print i, ") alpha = ", alpha
print(i, ") alpha = ", alpha)

for j in range(len(beta_array)):
beta = beta_array[j]
print i,".", j, ") beta = ", beta
print(i,".", j, ") beta = ", beta)

plotModuleLabel = "isoPlots_LinearComb_" + str(i)+"_" + str(j);
module = copy.deepcopy(process.zmumuNewIsolation)
Expand Down
3 changes: 2 additions & 1 deletion ElectroWeakAnalysis/ZMuMu/test/zPdfUnc.py
@@ -1,3 +1,4 @@
from __future__ import print_function
import FWCore.ParameterSet.Config as cms
import copy

Expand Down Expand Up @@ -110,7 +111,7 @@



print "sequence", seq
print("sequence", seq)

process.options = cms.untracked.PSet(
wantSummary = cms.untracked.bool(True)
Expand Down
5 changes: 3 additions & 2 deletions ElectroWeakAnalysis/ZMuMu/test/zToMuMuAnalysis.py
@@ -1,3 +1,4 @@
from __future__ import print_function
#analysis code.
#It produces plot for Fit study
#author Luca Lista
Expand Down Expand Up @@ -610,7 +611,7 @@
##### etaBounds = [-2.1, -1.2, -0.8, 0.8, 1.2, 2.1]

def addModulesFromTemplate(sequence, moduleLabel, src, probeSelection):
print "selection for: ", moduleLabel
print("selection for: ", moduleLabel)
for i in range(len(etaBounds)-1):
etaMin = etaBounds[i]
etaMax = etaBounds[i+1]
Expand All @@ -619,7 +620,7 @@ def addModulesFromTemplate(sequence, moduleLabel, src, probeSelection):
cut = "%5.3f < daughter(1).eta < %5.3f" %(etaMin, etaMax)
elif probeSelection == "double":
cut = "%5.3f < daughter(0).eta < %5.3f | %5.3f < daughter(1).eta < %5.3f" %(etaMin, etaMax, etaMin, etaMax)
print i, ") cut = ", cut
print(i, ") cut = ", cut)
setattr(module, "cut", cut)
setattr(module, "src", cms.InputTag(src))
copyModuleLabel = moduleLabel + str(i)
Expand Down
7 changes: 4 additions & 3 deletions ElectroWeakAnalysis/ZMuMu/test/zToMuMuAnalysis_EtaRegions.py
@@ -1,3 +1,4 @@
from __future__ import print_function
#analysis code.
#It produces plot for Fit study
#author Luca Lista
Expand Down Expand Up @@ -52,13 +53,13 @@


def addModuleEtaRegions(moduleToModify, region, src="", cut =""):
print "selection for: ", moduleToModify.label()+region
print("selection for: ", moduleToModify.label()+region)
etaMin = dict[region][0]
etaMax = dict[region][1]
module = copy.deepcopy(moduleToModify)
if cut=="":
cut = "mass>20 & charge = 0 & daughter(0).pt > 20 & daughter(1).pt > 20 & ( abs(daughter(0).eta) > %5.3f & abs( daughter(0).eta )< %5.3f) & ( abs(daughter(1).eta) > %5.3f & abs( daughter(1).eta )< %5.3f) " %(etaMin, etaMax, etaMin, etaMax)
print region, ") cut = ", cut
print(region, ") cut = ", cut)
if 'cut' in module.parameters_():
setattr(module, "cut", cut)
if 'src' in module.parameters_():
Expand All @@ -69,7 +70,7 @@ def addModuleEtaRegions(moduleToModify, region, src="", cut =""):


def addPlotModuleEtaRegions(plotModuleToModify, region, src=""):
print "selection for: ", plotModuleToModify.label()
print("selection for: ", plotModuleToModify.label())
etaMin = dict[region][0]
etaMax = dict[region][1]
plotModule = copy.deepcopy(plotModuleToModify)
Expand Down
5 changes: 3 additions & 2 deletions ElectroWeakAnalysis/ZMuMu/test/zToMuMuAnalysis_ntuple.py
@@ -1,3 +1,4 @@
from __future__ import print_function
#analysis code.
#It produces plot for Fit study
#author Luca Lista
Expand Down Expand Up @@ -547,7 +548,7 @@
##### etaBounds = [-2.1, -1.2, -0.8, 0.8, 1.2, 2.1]

def addModulesFromTemplate(sequence, moduleLabel, src, probeSelection):
print "selection for: ", moduleLabel
print("selection for: ", moduleLabel)
for i in range(len(etaBounds)-1):
etaMin = etaBounds[i]
etaMax = etaBounds[i+1]
Expand All @@ -556,7 +557,7 @@ def addModulesFromTemplate(sequence, moduleLabel, src, probeSelection):
cut = "%5.3f < daughter(1).eta < %5.3f" %(etaMin, etaMax)
elif probeSelection == "double":
cut = "%5.3f < daughter(0).eta < %5.3f | %5.3f < daughter(1).eta < %5.3f" %(etaMin, etaMax, etaMin, etaMax)
print i, ") cut = ", cut
print(i, ") cut = ", cut)
setattr(module, "cut", cut)
setattr(module, "src", cms.InputTag(src))
copyModuleLabel = moduleLabel + str(i)
Expand Down
5 changes: 3 additions & 2 deletions ElectroWeakAnalysis/ZMuMu/test/zToMuMuAnalysis_vtx.py
@@ -1,3 +1,4 @@
from __future__ import print_function
#analysis code.
#It produces plot for Fit study
#author Luca Lista
Expand Down Expand Up @@ -804,7 +805,7 @@
##### etaBounds = [-2.1, -1.2, -0.8, 0.8, 1.2, 2.1]

def addModulesFromTemplate(sequence, moduleLabel, src, probeSelection):
print "selection for: ", moduleLabel
print("selection for: ", moduleLabel)
for i in range(len(etaBounds)-1):
etaMin = etaBounds[i]
etaMax = etaBounds[i+1]
Expand All @@ -813,7 +814,7 @@ def addModulesFromTemplate(sequence, moduleLabel, src, probeSelection):
cut = "%5.3f < daughter(1).eta < %5.3f" %(etaMin, etaMax)
elif probeSelection == "double":
cut = "%5.3f < daughter(0).eta < %5.3f | %5.3f < daughter(1).eta < %5.3f" %(etaMin, etaMax, etaMin, etaMax)
print i, ") cut = ", cut
print(i, ") cut = ", cut)
setattr(module, "cut", cut)
setattr(module, "src", cms.InputTag(src))
copyModuleLabel = moduleLabel + str(i)
Expand Down

0 comments on commit 9e16c92

Please sign in to comment.