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

Make python3 compatible #36

Merged
merged 55 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
0dd42d1
make python3 compatible
May 28, 2023
cd1eb85
make python3 compatible (common)
May 28, 2023
3b7cbd6
remove unneeded list()
May 28, 2023
1ad317b
make python3 compatible (batch)
May 28, 2023
25f7b21
make python3 compatible (pico)
May 28, 2023
57fcc85
fix typo
May 28, 2023
d156ce8
make python3 compatible (storage)
May 28, 2023
308d48f
make python3 compatible (tool)
May 28, 2023
5e659f2
make python3 compatible (analysis fix)
May 28, 2023
833e6e7
fix parentheses typo
May 28, 2023
7f8e34e
make python3 compatible (processors)
May 28, 2023
ec45db8
make python3 compatible (corrections)
May 28, 2023
db2bb4d
fix parentheses typo
May 28, 2023
e2c8253
fix parentheses typo
May 28, 2023
ed4ea59
make python3 compatible (Plotter, except JetToTauFR)
May 28, 2023
9368629
make python3 compatible (Plotter/JetToTauFR)
May 28, 2023
50da437
make python3 compatible (Fitter)
May 28, 2023
f92f7e7
fix typos (common/tools)
May 28, 2023
1988e1e
rename fillCommonCorrBraches -> fillCommonCorrBranches (since we're a…
May 30, 2023
f8f1669
add instructions
May 30, 2023
f9c322d
update instruction for correctionlib/JSONs
May 30, 2023
5950a6a
update instructions
May 30, 2023
59de432
fix typos
May 30, 2023
e12c4a8
import unicode from past; fix keys() -> list(keys())
May 30, 2023
b86ecc3
replace exec() with eval()
May 31, 2023
b60f882
remove unneeded import that does not work in python3
May 31, 2023
40f04ee
change default
May 31, 2023
a570634
add 'validate' argument for CMSSW_12_X
May 31, 2023
9107eb0
add python2 version
May 31, 2023
8d52a9a
make python2 compatible with 'from __future__ import print_function'
May 31, 2023
2049a80
make python2 compatible with 'from __future__ import print_function'
May 31, 2023
aa77a52
remove unneeded TauPOG.TauIDSFs import
May 31, 2023
53693ff
fix bug
May 31, 2023
1867a62
fix bug
May 31, 2023
319a85d
make python2-python3 compatible: command line (buffsize=1 -> 0); long
May 31, 2023
f77603e
change relative import to absolute: .TreeProducer -> TauFW.PicoProduc…
Jun 7, 2023
360fdda
debug
Jun 7, 2023
e0be74d
add comments; improve error handling
Jun 7, 2023
a51833b
add haddcmd option for haddnano.py
Jun 7, 2023
510f23f
debug
Jun 7, 2023
bce39ac
raw_input -> input; split HTCondor batch systems; guess functions
Jun 8, 2023
e975444
make python3 compatible (test/, missed 'print' statements without arg…
Jun 8, 2023
2e32d99
debugging; removing redundant parentheses
Jun 8, 2023
c6c6571
debug
Jun 8, 2023
cbbb401
debug: move _cfgdefaults initiation to help function to protect imports
Jun 9, 2023
0df4dff
improve print out
Jun 9, 2023
489dcbb
print() -> print('')
Jun 9, 2023
89bd349
make python3 compatible; remove hardcoded genweight fix for deprecate…
Jun 12, 2023
3e67aa9
improve instructions
Jun 12, 2023
995e3b7
update CMSSW 10 -> 11 for python2
Jun 12, 2023
168256d
improve instructions
Jun 12, 2023
fe15a53
add table of content
Jun 12, 2023
d8005c9
maxtau<-1 -> maxtau!=None
Jun 12, 2023
b990042
disable DeepTau2018v2p5
Jun 12, 2023
590347a
tweaks documentation
Jun 14, 2023
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.pyc
*.bak
*.d
*.so
*.pcm
Expand Down
8 changes: 4 additions & 4 deletions Fitter/HighPT/DatacardsWToMuNu.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def PlotWToMuNu(h_data_input,h_bkg_input,h_sig_input,era,var):
canvas.cd()
canvas.SetSelected(canvas)
canvas.Update()
print
print()
print('Creating control plot')
canvas.Print(utils.figuresFolderWMuNu+"/wmunu_"+era+".png")

Expand Down Expand Up @@ -176,22 +176,22 @@ def CreateCardsWToMuNu(fileName,h_data,h_bkg,h_sig,uncs):
basefolder = utils.picoFolder
var = args.variable

print
print()
print('initializing SingleMuon samples >>>')
singlemuSamples = {} # data samples dictionary
singlemuNames = utils.singlemu[args.era]
for singlemuName in singlemuNames:
singlemuSamples[singlemuName] = utils.sampleHighPt(basefolder,args.era,
"munu",singlemuName,True)

print
print()
print('initializing background samples >>>')
bkgSamples = {} # MC bkg samples dictionary
for bkgSampleName in bkgSampleNames:
bkgSamples[bkgSampleName] = utils.sampleHighPt(basefolder,args.era,
"munu",bkgSampleName,False)

print
print()
print('initializing signal samples >>>')
sigSamples = {} # MC signal samples dictionary
for sigSampleName in sigSampleNames:
Expand Down
22 changes: 11 additions & 11 deletions Fitter/HighPT/DatacardsWToTauNu.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def FitConst(x,par):
def ComputeFake(h_wjets,h_dijets,h_fraction,name):
nbins = h_wjets.GetNbinsX()
hist = h_wjets.Clone(name)
print
print()
print('Computing fake histogram ->',name)
for i in range(1,nbins+1):
x_wjets = h_wjets.GetBinContent(i)
Expand Down Expand Up @@ -53,7 +53,7 @@ def ComputeFake(h_wjets,h_dijets,h_fraction,name):
##################################
def ComputeEWKFraction(h_data,h_mc):

print
print()
print('Computing EWK fraction')
nbins = h_data.GetNbinsX()
h_fraction = h_data.Clone('fraction')
Expand Down Expand Up @@ -85,7 +85,7 @@ def ComputeEWKFraction(h_data,h_mc):
############################
def PlotClosure(h_data,h_models,wp,era,var):

print
print()
print("Plotting closure")
h_model = h_models["bkg_fake_mc_wjets"]

Expand Down Expand Up @@ -305,7 +305,7 @@ def PlotWToTauNu(h_data_input,h_fake_input,h_bkg_input,h_sig_input,wp,era,var):
canvas.cd()
canvas.SetSelected(canvas)
canvas.Update()
print
print()
print('Creating control plot')
canvas.Print(utils.figuresFolderWTauNu+"/wtaunu_"+wp+"_"+era+".png")

Expand Down Expand Up @@ -382,7 +382,7 @@ def CreateCardsWToTauNu(fileName,h_data,h_fake,h_bkg,h_sig,uncs_fake,uncs_sig):
uncert_names = ["JES","Unclustered","taues_1pr","taues_1pr1pi0","taues_3pr","taues_3pr1pi0"]
# uncert_names = ["JES","Unclustered","taues"]

print
print()
print('initializing data samples >>>')
metSamples = {} # data samples dictionary
metNames = utils.met[args.era]
Expand All @@ -391,15 +391,15 @@ def CreateCardsWToTauNu(fileName,h_data,h_fake,h_bkg,h_sig,uncs_fake,uncs_sig):
"taunu",metName,True)
metSamples[metName].SetTauNuConfig(fakeFactor,args.wp,wtaunuCuts)

print
print()
print('initializing background samples >>>')
bkgSamples = {} # MC bkg samples dictionary
for bkgSampleName in bkgSampleNames:
bkgSamples[bkgSampleName] = utils.sampleHighPt(basefolder,args.era,
"taunu",bkgSampleName,False)
bkgSamples[bkgSampleName].SetTauNuConfig(fakeFactor,args.wp,wtaunuCuts)

print
print()
print('initializing signal samples >>>')
sigSamples = {} # MC signal samples dictionary
for sigSampleName in sigSampleNames:
Expand All @@ -411,7 +411,7 @@ def CreateCardsWToTauNu(fileName,h_data,h_fake,h_bkg,h_sig,uncs_fake,uncs_sig):
hists_sig_notFake = utils.RunSamplesTauNu(sigSamples,var,"",xbins,"_notFake","sig")

# running on signal samples (central template and unceertainties)
print
print()
print('Running on signal samples >>>')
hists_sig_shape = {}
commonCut = "metfilter>0.5&&mettrigger>0.5&&extraelec_veto<0.5&&extramuon_veto<0.5&&extratau_veto<0.5&&njets==0&&idDeepTau2017v2p1VSmu_1>=1&&idDeepTau2017v2p1VSe_1>=4&&genmatch_1==5&&idDeepTau2017v2p1VSjet_1>=" + utils.tauWPs[args.wp]
Expand Down Expand Up @@ -450,12 +450,12 @@ def CreateCardsWToTauNu(fileName,h_data,h_fake,h_bkg,h_sig,uncs_fake,uncs_sig):


# running selection on data
print
print()
print('Running on data samples >>>')
hists_data = utils.RunSamplesTauNu(metSamples,var,"",xbins,"","data")

# running selection on bkgd samples
print
print()
print('Running on background samples >>>')
hists_bkg_fake = utils.RunSamplesTauNu(bkgSamples,var,"",xbins,"_fake","bkg")
hists_bkg_notFake = utils.RunSamplesTauNu(bkgSamples,var,"",xbins,"_notFake","bkg")
Expand Down Expand Up @@ -524,7 +524,7 @@ def CreateCardsWToTauNu(fileName,h_data,h_fake,h_bkg,h_sig,uncs_fake,uncs_sig):

# saving histograms to datacard file datacards
outputFileName = utils.datacardsFolder + "/taunu_" + args.wp + "_" + args.era
print
print()
print("Saving histograms to RooT file",outputFileName+".root")
fileOutput = ROOT.TFile(outputFileName+".root","recreate")
fileOutput.mkdir("taunu")
Expand Down
18 changes: 9 additions & 9 deletions Fitter/HighPT/FakeFactorHighPt.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def FitMass(x,par):
###########################
def DrawFF(hist,era,channel,label,WP,**kwargs):

print
print()
print('fitting FF histo >>>',era,channel,label)

isdata = kwargs.get('isdata',True)
Expand Down Expand Up @@ -139,16 +139,16 @@ def main(outputfile,dataSamples,mcSamples,sigSamples,**kwargs):
channel = kwargs.get("channel","wjets")
mode = kwargs.get("mode",0)

print
print()
print("+++++++++++++++++++++++++++++++++++++++++++")
print
print()
if mode==0:
print('Computing FF as a function of tau pT in bins of pt_tau/pt_jet',era,wp,channel)
elif mode==1:
print('Computing FF as a function of tau mass in bins of DM',era,wp,channel)
else:
print('Computing FF as a function of tau pT in bins of (pt_tau/pt_jet,DM)',era,wp,channel)
print
print()

cutTauDen = "idDeepTau2017v2p1VSjet_2<4"
cutTauNum = "idDeepTau2017v2p1VSjet_2>=" + utils.tauWPs[wp]
Expand Down Expand Up @@ -179,10 +179,10 @@ def main(outputfile,dataSamples,mcSamples,sigSamples,**kwargs):
histssig = {}
for label in binCuts:
xbins = []
print
print()
print('***************************')
print('Running over',label)
print
print()

if mode==0: xbins=utils.xbinsPt
elif mode==1: xbins=utils.xbinsMass[label]
Expand Down Expand Up @@ -256,15 +256,15 @@ def main(outputfile,dataSamples,mcSamples,sigSamples,**kwargs):
singlemuSamples[singlemuName] = utils.sampleHighPt(basefolder,args.era,
"wjets",singlemuName,True)

print
print()
print('initializing JetHT samples >>>')
jethtSamples = {} # data samples disctionary
jethtNames = utils.jetht[args.era]
for jethtName in jethtNames:
jethtSamples[jethtName] = utils.sampleHighPt(basefolder,args.era,
"dijets",jethtName,True)

print
print()
print('initializing MC samples >>>')
mcSamples = {} # mc samples dictionary
for mcSampleName in mcSampleNames:
Expand All @@ -274,7 +274,7 @@ def main(outputfile,dataSamples,mcSamples,sigSamples,**kwargs):
else:
mcSamples[mcSampleName] = utils.sampleHighPt(basefolder,args.era,"wjets",mcSampleName,
False)
print
print()
print('initializing W+Jets samples >>>')
sigSamples = {} # wjets samples dictionary
for sigSampleName in sigSampleNames:
Expand Down
6 changes: 3 additions & 3 deletions Fitter/HighPT/MetTrigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def DrawEfficiency(histdata,histmc,era,legend):
def main(args):

era = args.era
print
print()

channel = "munu"
basefolder = utils.picoFolder
Expand All @@ -71,7 +71,7 @@ def main(args):
dataSamples[dataSampleName] = utils.sampleHighPt(basefolder,era,channel,
dataSampleName,True)

print
print()
mcSamples = {} # mc samples dictionary
print('Initializing W+Jets MC samples>>>')
for mcSampleName in mcSampleNames:
Expand All @@ -81,7 +81,7 @@ def main(args):
else:
mcSamples[mcSampleName] = utils.sampleHighPt(basefolder,era,channel,
mcSampleName,False)
print
print()
histsdata = {} # data histo dictionary
histsmc = {} # mc histo dictionary

Expand Down
2 changes: 1 addition & 1 deletion Fitter/HighPT/PlotWToMuNu.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def Plot(h_data_input,h_tot_input,h_bkg_input,h_sig_input,era,var,postFit):
canvas.cd()
canvas.SetSelected(canvas)
canvas.Update()
print
print()
print('Creating control plot')
if postFit:
canvas.Print(utils.figuresFolderWMuNu+"/wmunu_"+era+"_postFit.png")
Expand Down
2 changes: 1 addition & 1 deletion Fitter/HighPT/PlotWToTauNu.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def Plot(h_data_input,h_tot_input,h_fake_input,h_bkg_input,h_sig_input,wp,era,va
canvas.cd()
canvas.SetSelected(canvas)
canvas.Update()
print
print()
print('Creating control plot')
if postFit:
canvas.Print(utils.figuresFolderWTauNu+"/wtaunu_"+wp+"_"+era+"_postFit.png")
Expand Down
2 changes: 1 addition & 1 deletion Fitter/TauES/correctionlib/tau_tes.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,5 +366,5 @@ def main():

if __name__ == '__main__':
main()
print()
print('')

2 changes: 1 addition & 1 deletion Fitter/paper/writecards.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def main():


if __name__ == '__main__':
print
print('')
main()
print ">>>\n>>> Done harvesting\n"

6 changes: 3 additions & 3 deletions Fitter/python/HighPT/utilsHighPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def extractBinLabels(pt,ptratio):

# Run over set of samples and create histogram
def RunSamples(samples,var,weight,cut,xbins,name):
print
print('')
print("Running",name,var,weight,cut)
nbins = len(xbins)-1
hist = ROOT.TH1D(name,"",nbins,array('d',list(xbins)))
Expand All @@ -289,7 +289,7 @@ def RunSamples(samples,var,weight,cut,xbins,name):
# Run over set of samples and create histograms for W*->tau+v channel
# for each sample loop over Tree entries is performed
def RunSamplesTauNu(samples,var,unc,xbins,selection,name):
print
print('')
print("Running",name,var,unc,selection)
nbins = len(xbins)-1
hists = {} # discionary of histograms
Expand Down Expand Up @@ -418,7 +418,7 @@ def __init__(self,**kwargs):
class FakeFactorHighPt:

def __init__(self,filename):
print
print('')
print('Loading fake factors from file',filename," >>>>>")
self.fileName = filename
self.fileFF = ROOT.TFile(self.fileName,"READ")
Expand Down
10 changes: 5 additions & 5 deletions Fitter/python/models/TagAndProbeModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ def doParametersOfInterest(self):
elif self.passbin in bin:
exp_pass += self.DC.exp[bin][param]
if self.verbose>=3:
print ">>> Expected number of %s events in %s bin: %9.1f"%(param,bin,self.DC.exp[bin][param])
print(">>> Expected number of %s events in %s bin: %9.1f"%(param,bin,self.DC.exp[bin][param]))
if self.verbose>=2:
print ">>> Expected number of signal events in pass region: %9.1f"%(exp_pass)
print ">>> Expected number of signal events in fail region: %9.1f"%(exp_fail)
print ">>> SF_fail = (%.2f+(1.-SF)*%.2f)/%.2f"%(exp_fail,exp_pass,exp_fail)
print(">>> Expected number of signal events in pass region: %9.1f"%(exp_pass))
print(">>> Expected number of signal events in fail region: %9.1f"%(exp_fail))
print(">>> SF_fail = (%.2f+(1.-SF)*%.2f)/%.2f"%(exp_fail,exp_pass,exp_fail))
assert exp_fail, "Fail region has no signal events!"

# DEFINE PARAMETERS
Expand All @@ -88,7 +88,7 @@ def getYieldScale(self,bin,process):
elif self.passbin in bin:
scale = 'SF'
if self.verbose>=1:
print ">>> Scaling %3s in %s bin by '%s'"%(process,bin,scale)
print(">>> Scaling %3s in %s bin by '%s'"%(process,bin,scale))
return scale
return 1

Expand Down
Loading