diff --git a/CMGTools/TTHAnalysis/macros/prepareEventVariablesFriendTree.py b/CMGTools/TTHAnalysis/macros/prepareEventVariablesFriendTree.py index a511e89878869..07a1bc2ed20ae 100644 --- a/CMGTools/TTHAnalysis/macros/prepareEventVariablesFriendTree.py +++ b/CMGTools/TTHAnalysis/macros/prepareEventVariablesFriendTree.py @@ -47,9 +47,10 @@ def analyze(self,event): parser.add_option("-N", "--events", dest="chunkSize", type="int", default=500000, help="Default chunk size when splitting trees"); parser.add_option("-j", "--jobs", dest="jobs", type="int", default=1, help="Use N threads"); parser.add_option("-p", "--pretend", dest="pretend", action="store_true", default=False, help="Don't run anything"); -parser.add_option("-t", "--tree-dir", dest="treeDir", type="string", default="sf", help="Directory of the friend tree in the file (default: 'sf')"); +parser.add_option("-T", "--tree-dir", dest="treeDir", type="string", default="sf", help="Directory of the friend tree in the file (default: 'sf')"); parser.add_option("-q", "--queue", dest="queue", type="string", default=None, help="Run jobs on lxbatch instead of locally"); -parser.add_option("-V", "--vector", dest="vectorTree", action="store_true", default=False, help="Input tree is a vector") +parser.add_option("-t", "--tree", dest="tree", default='ttHLepTreeProducerTTH', help="Pattern for tree name"); +parser.add_option("-V", "--vector", dest="vectorTree", action="store_true", default=True, help="Input tree is a vector"); parser.add_option("-F", "--add-friend", dest="friendTrees", action="append", default=[], nargs=2, help="Add a friend tree (treename, filename). Can use {name}, {cname} patterns in the treename") parser.add_option("--FMC", "--add-friend-mc", dest="friendTreesMC", action="append", default=[], nargs=2, help="Add a friend tree (treename, filename) to MC only. Can use {name}, {cname} patterns in the treename") parser.add_option("--FD", "--add-friend-data", dest="friendTreesData", action="append", default=[], nargs=2, help="Add a friend tree (treename, filename) to data trees only. Can use {name}, {cname} patterns in the treename") @@ -64,17 +65,14 @@ def analyze(self,event): jobs = [] for D in glob(args[0]+"/*"): - if options.vectorTree: - fname = D+"/ttHLepTreeProducerNew/ttHLepTreeProducerNew_tree.root" - else: - fname = D+"/ttHLepTreeProducerBase/ttHLepTreeProducerBase_tree.root" + fname = D+"/"+options.tree+"/"+options.tree+"_tree.root" if os.path.exists(fname): short = os.path.basename(D) if options.datasets != []: if short not in options.datasets: continue data = ("DoubleMu" in short or "MuEG" in short or "DoubleElectron" in short or "SingleMu" in short) f = ROOT.TFile.Open(fname); - t = f.Get("ttHLepTreeProducerNew" if options.vectorTree else "ttHLepTreeProducerBase") + t = f.Get(options.tree) entries = t.GetEntries() f.Close() chunk = options.chunkSize @@ -94,9 +92,9 @@ def analyze(self,event): if options.queue: import os, sys - basecmd = "bsub -q {queue} {dir}/lxbatch_runner.sh {dir} {cmssw} python {self} -N {chunkSize} -t '{tdir}' {data} {output}".format( + basecmd = "bsub -q {queue} {dir}/lxbatch_runner.sh {dir} {cmssw} python {self} -N {chunkSize} -T '{tdir}' -t {tree} {data} {output}".format( queue = options.queue, dir = os.getcwd(), cmssw = os.environ['CMSSW_BASE'], - self=sys.argv[0], chunkSize=options.chunkSize, tdir=options.treeDir, data=args[0], output=args[1] + self=sys.argv[0], chunkSize=options.chunkSize, tdir=options.treeDir, tree=options.tree, data=args[0], output=args[1] ) if options.vectorTree: basecmd += " --vector " friendPost = "".join([" -F %s %s " % (fn,ft) for fn,ft in options.friendTrees]) @@ -115,11 +113,10 @@ def _runIt(myargs): (name,fin,fout,data,range,chunk) = myargs timer = ROOT.TStopwatch() fb = ROOT.TFile(fin) + tb = fb.Get(options.tree) if options.vectorTree: - tb = fb.Get("ttHLepTreeProducerNew") tb.vectorTree = True else: - tb = fb.Get("ttHLepTreeProducerBase") tb.vectorTree = False friends = options.friendTrees[:] friends += (options.friendTreesData if data else options.friendTreesMC) diff --git a/CMGTools/TTHAnalysis/macros/prepareScaleFactorsFriendTree.py b/CMGTools/TTHAnalysis/macros/prepareScaleFactorsFriendTree.py index 138bc1b17f4b0..d7f7005ee8179 100644 --- a/CMGTools/TTHAnalysis/macros/prepareScaleFactorsFriendTree.py +++ b/CMGTools/TTHAnalysis/macros/prepareScaleFactorsFriendTree.py @@ -6,13 +6,13 @@ MODULES = [] from CMGTools.TTHAnalysis.tools.btagSFs_POG import bTagSFEvent3WPErrs as btagSFEvent -MODULES += [ ('btag', btagSFEvent) ] +#MODULES += [ ('btag', btagSFEvent) ] from CMGTools.TTHAnalysis.tools.lepMVA_SF import AllLepSFs MODULES += [ ('lep',AllLepSFs()) ] from CMGTools.TTHAnalysis.tools.lepTrigger_SF import LepTriggerSF_Event -MODULES += [ ('trig2l', LepTriggerSF_Event()) ] +#MODULES += [ ('trig2l', LepTriggerSF_Event()) ] from CMGTools.TTHAnalysis.tools.metLD_reshape import MetLDReshaper #MODULES += [ ('metLD', MetLDReshaper()) ] @@ -60,7 +60,8 @@ def analyze(self,event): parser.add_option("-j", "--jobs", dest="jobs", type="int", default=1, help="Use N threads"); parser.add_option("-p", "--pretend", dest="pretend", action="store_true", default=False, help="Don't run anything"); parser.add_option("-q", "--queue", dest="queue", type="string", default=None, help="Run jobs on lxbatch instead of locally"); -parser.add_option("-V", "--vector", dest="vectorTree", action="store_true", default=False, help="Input tree is a vector") +parser.add_option("-t", "--tree", dest="tree", default='ttHLepTreeProducerTTH', help="Pattern for tree name"); +parser.add_option("-V", "--vector", dest="vectorTree",action="store_true", default=True, help="Input tree is a vector") (options, args) = parser.parse_args() if len(args) != 2 or not os.path.isdir(args[0]) or not os.path.isdir(args[1]): @@ -72,10 +73,7 @@ def analyze(self,event): jobs = [] for D in glob(args[0]+"/*"): - if options.vectorTree: - fname = D+"/ttHLepTreeProducerNew/ttHLepTreeProducerNew_tree.root" - else: - fname = D+"/ttHLepTreeProducerBase/ttHLepTreeProducerBase_tree.root" + fname = D+"/"+options.tree+"/"+options.tree+"_tree.root" if os.path.exists(fname): short = os.path.basename(D) if options.datasets != []: @@ -83,7 +81,8 @@ def analyze(self,event): data = ("DoubleMu" in short or "MuEG" in short or "DoubleElectron" in short or "SingleMu" in short) if data: continue f = ROOT.TFile.Open(fname); - t = f.Get("ttHLepTreeProducerNew" if options.vectorTree else "ttHLepTreeProducerBase") + #t = f.Get("ttHLepTreeProducerTTH" if options.vectorTree else "ttHLepTreeProducerBase") + t = f.Get(options.tree) entries = t.GetEntries() f.Close() chunk = options.chunkSize @@ -103,9 +102,9 @@ def analyze(self,event): if options.queue: import os, sys - basecmd = "bsub -q {queue} {dir}/lxbatch_runner.sh {dir} {cmssw} python {self} -N {chunkSize} {data} {output}".format( + basecmd = "bsub -q {queue} {dir}/lxbatch_runner.sh {dir} {cmssw} python {self} -N {chunkSize} -t {tree} {data} {output}".format( queue = options.queue, dir = os.getcwd(), cmssw = os.environ['CMSSW_BASE'], - self=sys.argv[0], chunkSize=options.chunkSize, data=args[0], output=args[1] + self=sys.argv[0], chunkSize=options.chunkSize, tree=options.tree, data=args[0], output=args[1] ) if options.vectorTree: basecmd += " --vector " # specify what to do @@ -121,11 +120,10 @@ def _runIt(myargs): (name,fin,fout,data,range,chunk) = myargs timer = ROOT.TStopwatch() fb = ROOT.TFile(fin) + tb = fb.Get(options.tree) if options.vectorTree: - tb = fb.Get("ttHLepTreeProducerNew") tb.vectorTree = True else: - tb = fb.Get("ttHLepTreeProducerBase") tb.vectorTree = False nev = tb.GetEntries() if options.pretend: