diff --git a/TTHAnalysis/macros/prepareEventVariablesFriendTree.py b/TTHAnalysis/macros/prepareEventVariablesFriendTree.py index ab3f094ce2fa..fb5c077c4e60 100755 --- a/TTHAnalysis/macros/prepareEventVariablesFriendTree.py +++ b/TTHAnalysis/macros/prepareEventVariablesFriendTree.py @@ -11,11 +11,14 @@ ROOT.PyConfig.IgnoreCommandLineOptions = True MODULES = [] +from CMGTools.TTHAnalysis.tools.multilepFriendTreeProducersToCleanup import MODULES as multiModules +MODULES += multiModules class VariableProducer(Module): def __init__(self,name,booker,modules): Module.__init__(self,name,booker) self._modules = [ (n,m() if type(m) == types.FunctionType else m) for (n,m) in modules ] + print self._modules def init(self,tree): for n,m in self._modules: if hasattr(m, 'init'): m.init(tree) @@ -182,6 +185,7 @@ def analyze(self,event): runner = "" super = "" + theoutput= args[1].replace('/pool/ciencias/','/pool/cienciasrw/') if options.env == "cern": runner = "lxbatch_runner.sh" super = "bsub -q {queue}".format(queue = options.queue) @@ -193,7 +197,6 @@ def analyze(self,event): options.queue = "batch" super = "qsub -q {queue} -N happyTreeFriend".format(queue = options.queue) runner = "lxbatch_runner.sh" - theoutput= args[1].replace('/pool/ciencias/','/pool/cienciasrw/') else: raise RuntimeError, "I do not know what to do. Where am I? Please set the [env] option" @@ -295,6 +298,7 @@ def _runIt(myargs): if re.match(pat,m): toRun[m] = True modulesToRun = [ (m,v) for (m,v) in MODULES if m in toRun ] + print 'looooping ###############' el = EventLoop([ VariableProducer(options.treeDir,booker,modulesToRun), ]) el.loop([tb], eventRange=range) booker.done() diff --git a/TTHAnalysis/macros/submit.py b/TTHAnalysis/macros/submit.py new file mode 100644 index 000000000000..c9d5dbae9be2 --- /dev/null +++ b/TTHAnalysis/macros/submit.py @@ -0,0 +1,250 @@ +import os +from multiprocessing import Pool + +## this script creates a sub-directory in the tree path for a given module +## and runs the friend tree producer for this module + +batch = True +queue = "batch" #"batch" for Oviedo, "8nh" or others for lxplus +path = "/pool/ciencias/HeppyTrees/ttH/" +#path = "trees/" +force = True # if the friend tree already exists, module is not run; set to True to still run it +print 'here' +## first: module to run, second: list of modules (comma separated) that are required to run +modules = [ +# ["leptonJetReCleanerTTH", ""] +# ["ttH2lss","leptonJetReCleanerTTH"], + ["kinMVA_2D_2lss_3l","leptonJetReCleanerTTH,ttH2lss"] + +# ["ttHLepMEMFriend", ""], +# ["eventBTagWeight","leptonJetReCleanerTTH"] + #["fastCombinedObjectRecleaner", ""] + #["leptonJetReCleanerSusyEWK2L" , "" ], + # ["leptonJetReCleanerSusyEWK3L" , "" ], + #["WZCRvars" , "leptonJetReCleanerSusyEWK2L" ], + #["leptonBuilderEWK" , "leptonJetReCleanerSusyEWK3L" ], + #["leptonJetReCleanerSusyRA7" , "" ], + #["leptonBuilderRA7" , "leptonJetReCleanerSusyRA7" ], + #["leptonJetReCleanerWZSM" , "" ], + #["leptonBuilderWZSM" , "leptonJetReCleanerWZSM" ], + ] + +## in case you want to run only specific samples +accept = ['SingleElectron_Run2016B_23Sep2016_v3_runs_273150_275376_part8' +#'MuonEG_Run2016H-PromptReco-v2_runs_281613_284035' + #'TTTT', + #"WZTo3LNu", + #"WGToLNuG", + #"DoubleEG_Run2016G_23Sep2016_v1_runs_271036_284044_part1", + # + #"DoubleEG_Run2016G_23Sep2016_v1_runs_271036_284044_part2", + # + #"DoubleMuon_Run2016F_23Sep2016_v1_runs_271036_284044_part2", + # + #"DoubleMuon_Run2016G_23Sep2016_v1_runs_271036_284044_part5", + #@@"DoubleEG_Run2016G_23Sep2016_v1_runs_271036_284044_part2", + #@@"DoubleEG_Run2016G_23Sep2016_v1_runs_271036_284044_part3", + #@@"DoubleEG_Run2016G_23Sep2016_v1_runs_271036_284044_part4", + #@@"DoubleEG_Run2016G_23Sep2016_v1_runs_271036_284044_part5", + #@@"DoubleMuon_Run2016F_23Sep2016_v1_runs_271036_284044_part2", + #@@"DoubleMuon_Run2016G_23Sep2016_v1_runs_271036_284044_part3", + ##"DoubleEG_Run2016G_23Sep2016_v1_runs_271036_284044_part2", + #"DoubleEG_Run2016G_23Sep2016_v1_runs_271036_284044_part3", + # + #"DoubleEG_Run2016G_23Sep2016_v1_runs_271036_284044_part4", + # + # + #"DoubleEG_Run2016G_23Sep2016_v1_runs_271036_284044_part5", + # + #"DoubleMuon_Run2016G_23Sep2016_v1_runs_271036_284044_part3", + #"DoubleEG_Run2016G_23Sep2016_v1_runs_271036_284044_part5", + ###"JetHT_Run2016B_23Sep2016_v3_runs_273150_275376_part1", + ###"MET_Run2016H-PromptReco-v3_runs_284036_284044", + ###"SingleMuon_Run2016H-PromptReco-v3_runs_284036_284044", + #"DoubleMuon_Run2016G_23Sep2016_v1_runs_271036_284044_part2", + #"DoubleMuon_Run2016G_23Sep2016_v1_runs_271036_284044_part5", + #"DoubleMuon_Run2016G_23Sep2016_v1_runs_271036_284044_part7", + #"DoubleMuon_Run2016G_23Sep2016_v1_runs_271036_284044_part7", + # + #"DoubleEG_Run2016B_23Sep2016_v3_runs_273150_275376_skimmed_part1", + #"DoubleEG_Run2016D_23Sep2016_v1_runs_271036_284044_part4", + #"DoubleEG_Run2016E_23Sep2016_v1_runs_271036_284044_part2", + #"DoubleEG_Run2016H-PromptReco-v2_runs_281613_284035_part4", + #"DoubleMuon_Run2016B_23Sep2016_v3_runs_273150_275376_skimmed_part1", + #"DoubleMuon_Run2016B_23Sep2016_v3_runs_273150_275376_skimmed_part3", + #"DoubleMuon_Run2016B_23Sep2016_v3_runs_273150_275376_skimmed_part6", + #"DoubleMuon_Run2016H-PromptReco-v2_runs_281613_284035_part10", + #"TTJets_SingleLeptonFromTbar_part2", + #"TTJets_SingleLeptonFromTbar_part3", + #"Run2016G", + #"Run2016F", + #"DoubleEG_Run2016E_23Sep2016_v1_runs_271036_284044_part2" + #"DYJetsToLL_M50_LO_part2", + #"TTJets_SingleLeptonFromT_part3", + #"TTJets_SingleLeptonFromTbar_part1", + #"SingleLeptonFromTbar_part2", + #"SingleLeptonFromTbar_part3", + #"DoubleEG_Run2016B_23Sep2016_v3_runs_273150_275376_part1", + #"DoubleEG_Run2016B_23Sep2016_v3_runs_273150_275376_part3", + #"DoubleEG_Run2016B_23Sep2016_v3_runs_273150_275376_part4", + #"DoubleEG_Run2016C_23Sep2016_v1_runs_271036_284044_part1", + #"DoubleEG_Run2016D_23Sep2016_v1_runs_271036_284044_part2", + #"DoubleEG_Run2016D_23Sep2016_v1_runs_271036_284044_part4", + #"DoubleEG_Run2016E_23Sep2016_v1_runs_271036_284044_part1", + #"DoubleEG_Run2016E_23Sep2016_v1_runs_271036_284044_part2", + #"DoubleEG_Run2016H-PromptReco-v2_runs_281613_284035_part4", + #"DoubleEG_Run2016H-PromptReco-v2_runs_281613_284035_part5", + #"SingleElectron_Run2016E_23Sep2016_v1_runs_271036_284044", + #"DoubleEG_Run2016B_23Sep2016_v3_runs_273150_275376_part1", + #"DoubleEG_Run2016B_23Sep2016_v3_runs_273150_275376_part3", + #"DoubleEG_Run2016B_23Sep2016_v3_runs_273150_275376_part4", + #"DoubleEG_Run2016C_23Sep2016_v1_runs_271036_284044_part1", + #"DoubleEG_Run2016D_23Sep2016_v1_runs_271036_284044_part2", + #"DoubleEG_Run2016D_23Sep2016_v1_runs_271036_284044_part4", + #"DoubleEG_Run2016E_23Sep2016_v1_runs_271036_284044_part1", + #"DoubleEG_Run2016E_23Sep2016_v1_runs_271036_284044_part2", + #"DoubleEG_Run2016H-PromptReco-v2_runs_281613_284035_part4", + #"DoubleEG_Run2016H-PromptReco-v2_runs_281613_284035_part5", + #"DoubleMuon_Run2016B_23Sep2016_v3_runs_273150_275376_part10", + #"DoubleMuon_Run2016B_23Sep2016_v3_runs_273150_275376_part9", + #"DoubleMuon_Run2016C_23Sep2016_v1_runs_271036_284044_part2", + #"DoubleMuon_Run2016C_23Sep2016_v1_runs_271036_284044_part1", + #"DoubleMuon_Run2016D_23Sep2016_v1_runs_271036_284044_part1", + #"DoubleMuon_Run2016D_23Sep2016_v1_runs_271036_284044_part6", + #"DoubleMuon_Run2016E_23Sep2016_v1_runs_271036_284044_part1", + #"MuonEG_Run2016H-PromptReco-v2_runs_281613_284035", + #"SingleElectron_Run2016E_23Sep2016_v1_runs_271036_284044", + #"SingleMuon_Run2016H-PromptReco-v3_runs_284036_284044", + #"WWZ" + #"TChiNeuSlepSneu_mCh450_mChi300", + #"TChiNeuSlepSneu_mCh300_mChi270", + #"TChiNeuSlepSneu_mCh750_mChi100" + #"TChiNeuWZ_mCh150_mChi120", + #"TChiNeuWZ_mCh200_mChi100", + #"TChiNeuWZ_mCh350_mChi100", + #"TChiNeuWZ_mCh350_mChi20" + # "TChiNeuWZ_mCh350_mChi20" + # "T6ttWW_mG_1000_mN_100", + #"T6ttWW_mG_1200_mN_100", + #"T1tttt_mG_1200_mN_900", + #"T1tttt_mG_1300_mN_1000", + #"T1tttt_mG_1400_mN_1100", + #"T1tttt_mG_1500_mN_1200", + #"T1tttt_mG_1600_mN_1300", + #"1250_mN_950", + #"800_mN_700", + #"DYJets" + #"TGJets", + #"TTGJets", + #"TTJets_Di", + #"TTJets_Single", + #"TTLL", + #"TTW", + #"TTZ", + #"TTW", + #"TTWTo", + #"TTZTo", + #"TTH", + #"TBar", + #"TTHnobb_pow", + #"tZq", + #"VH", + #"WG", + #"ZG", + #"WWZ", + #"WZZ", + #"ZZZ", + #"ZZTo4L", + #"WWTo2L2Nu", + #"TTTT", + #"FromTbar", + #"romT", + #"WZTo3LNu", + #"T5qqqqVV_noDM_mG_1000_mN_100", + #"MuonEG_Run2016B", + #"GGHZZ", + #"Run", + #"DYJetsToLL_M10to50_LO", + #"DYJetsToLL_M50_LO", + #"DoubleMuon_Run2016B_PromptReco_v2_runs_275126_275783", + #"T1tttt", + #"T5qqqq", + #"T6ttWW", + ] + +#annot open file evVarFriend_SingleMuon_Run2016D_PromptReco_v2_runs_276284_276811.chunk68.root cannot open file evVarFriend_DoubleEG_Run2016D_PromptReco_v2_runs_276284_276811.chunk14.root + +## in case you want to exclude specific samples +exclude = [#"_SS", + #"_OS", + #"_TD", + #"_LO", + #"Tau", + #"TChi", + #"WZTo3LNu", + #"DoubleEG", + #"DoubleMuon", + #"MuonEG", + #"ZToMuMu", + #"QCD", + #"50to", + #"amcatnlo", + #"Run", + #"runs_273150_275125", + #"TTW","TTZ", + #"WZTo3LNu" + #"amcatnlo", + ] + +## --------------- do not touch beyond this line --------------- + +def cmd(cmd): + print cmd + os.system(cmd) + +def mkdir(path): + if os.path.isdir(path): return + cmd("mkdir " + path) + +def submit(sample, module): + print 'meh' + global batch, queue, path + super = "python prepareEventVariablesFriendTree.py " + path + " " + path + "/" + module[0] + " -d " + sample + " --tra2 --tree treeProducerSusyMultilepton -m " + module[0] + if not module[1].strip() == "": + sm = module[1].strip().split(",") + for f in sm: super += " -F sf/t " + path + "/" + f + "/evVarFriend_" + sample + ".root" + if batch: + #super += " --env cern -q " + queue + " -N 50000 --log " + path + "/" + module[0] + "/log" + super += " -q " + queue + " -N 5000000 --env oviedo" + cmd(super) + + +path = path.rstrip("/") +listdir = os.listdir(path) + +def parallelSubmission(module_d): + module = module_d[0] + d = module_d[1] + + if not os.path.isdir(path + "/" + d): return None + if not ( os.path.exists(path + "/" + d + "/treeProducerSusyMultilepton/tree.root") or os.path.exists(path + "/" + d + "/treeProducerSusyMultilepton/tree.root.url") ): return None + if not force and os.path.exists(path + "/" + module[0] + "/evVarFriend_" + d + ".root"): return None + if accept != [] and all([d.find(a) == -1 for a in accept ]): return None + if exclude != [] and any([d.find(e) > -1 for e in exclude]): return None + submit(d, module) + +for module in modules: + mkdir( module[0]) + listJobs = [] + pool = Pool(1) + for d in listdir: + listJobs.append( [module, d] ) + pool.map(parallelSubmission, listJobs) + # for d in listdir: + # if not os.path.isdir(path + "/" + d): continue + # if not ( os.path.exists(path + "/" + d + "/treeProducerSusyMultilepton/tree.root") or os.path.exists(path + "/" + d + "/treeProducerSusyMultilepton/tree.root.url") ): continue + # if not force and os.path.exists(path + "/" + module[0] + "/evVarFriend_" + d + ".root"): continue + # if accept != [] and all([d.find(a) == -1 for a in accept ]): continue + # if exclude != [] and any([d.find(e) > -1 for e in exclude]): continue + # submit(d, module) + diff --git a/TTHAnalysis/python/plotter/ttH-multilepton/mca-2lss-mc.txt b/TTHAnalysis/python/plotter/ttH-multilepton/mca-2lss-mc.txt index 9fc0f8fea918..a235af245370 100644 --- a/TTHAnalysis/python/plotter/ttH-multilepton/mca-2lss-mc.txt +++ b/TTHAnalysis/python/plotter/ttH-multilepton/mca-2lss-mc.txt @@ -1,18 +1,18 @@ -ttH+ : TTHnobb_mWCutfix_ch0 : 0.5071*0.418 : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge; FillColor=ROOT.kOrange+10 +#ttH+ : TTHnobb_mWCutfix_ch0 : 0.5071*0.418 : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge; FillColor=ROOT.kOrange+10 TTW : TTWToLNu : 0.196 : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; FillColor=ROOT.kGreen-5 TTZ : TTZToLLNuNu : 0.2526 : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; FillColor=ROOT.kSpring+2 TTZ : TTLLJets_m1to10 : xsec : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; FillColor=ROOT.kSpring+2 -TTZ : TTJets_DiLepton : xsec : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; FillColor=ROOT.kSpring+2 -TTZ : TTJets_SingleLeptonFromT+TTJets_SingleLeptonFromT_ext : xsec : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; FillColor=ROOT.kSpring+2 -TTZ : TTJets_SingleLeptonFromTbar+TTJets_SingleLeptonFromTbar_ext : xsec : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; FillColor=ROOT.kSpring+2 +#TTZ : TTJets_DiLepton : xsec : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; FillColor=ROOT.kSpring+2 +#TTZ : TTJets_SingleLeptonFromT+TTJets_SingleLeptonFromT_ext : xsec : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; FillColor=ROOT.kSpring+2 +#TTZ : TTJets_SingleLeptonFromTbar+TTJets_SingleLeptonFromTbar_ext : xsec : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; FillColor=ROOT.kSpring+2 WZ : WZTo3LNu : 1.1*xsec : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; FillColor=ROOT.kViolet-4 WZ : WJetsToLNu_LO : xsec : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; FillColor=ROOT.kViolet-4 Rares : ZZTo4L : xsec : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; FillColor=ROOT.kAzure-9 -Gstar : DYJetsToLL_M10to50: xsec : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; FillColor=ROOT.kCyan+1 -Gstar : DYJetsToLL_M50: xsec : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; FillColor=ROOT.kCyan+1 +#Gstar : DYJetsToLL_M10to50: xsec : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; FillColor=ROOT.kCyan+1 +#Gstar : DYJetsToLL_M50: xsec : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; FillColor=ROOT.kCyan+1 WWss: WpWpJJ : xsec : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; FillColor=ROOT.kOrange-3 @@ -23,30 +23,30 @@ Rares: ZZZ : xsec : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; Rares: TTTT : xsec : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; FillColor=ROOT.kMagenta-7 Rares: tZq_ll : xsec : LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge ; FillColor=ROOT.kMagenta-7 -Convs : TTGJets : xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==1) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==1)) ; FillColor=ROOT.kOrange +#Convs : TTGJets : xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==1) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==1)) ; FillColor=ROOT.kOrange Convs : WGToLNuG : xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==1) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==1)) ; FillColor=ROOT.kOrange Convs : ZGTo2LG : xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==1) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==1)) ; FillColor=ROOT.kOrange Convs : TGJets : xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==1) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==1)) ; FillColor=ROOT.kOrange -TT : TTJets_DiLepton : xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==0) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==0)) ; FillColor=ROOT.kGray -TT : TTJets_SingleLeptonFromT+TTJets_SingleLeptonFromT_ext : xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==0) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==0)) ; FillColor=ROOT.kGray -TT : TTJets_SingleLeptonFromTbar+TTJets_SingleLeptonFromTbar_ext : xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==0) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==0)) ; FillColor=ROOT.kGray -DY : DYJetsToLL_M10to50: xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==0) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==0)) ; FillColor=ROOT.kCyan -DY : DYJetsToLL_M50: xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==0) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==0)) ; FillColor=ROOT.kCyan +#TT : TTJets_DiLepton : xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==0) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==0)) ; FillColor=ROOT.kGray +#TT : TTJets_SingleLeptonFromT+TTJets_SingleLeptonFromT_ext : xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==0) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==0)) ; FillColor=ROOT.kGray +#TT : TTJets_SingleLeptonFromTbar+TTJets_SingleLeptonFromTbar_ext : xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==0) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==0)) ; FillColor=ROOT.kGray +#DY : DYJetsToLL_M10to50: xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==0) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==0)) ; FillColor=ROOT.kCyan +#DY : DYJetsToLL_M50: xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==0) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==0)) ; FillColor=ROOT.kCyan WJets : WJetsToLNu_LO : xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==0) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==0)) ; FillColor=ROOT.kCyan+2 SingleTop: TToLeptons_tch_powheg: xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==0) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==0)) ; FillColor=ROOT.kGray+2, Label="Single T" SingleTop: TBarToLeptons_tch_powheg: xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==0) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==0)) ; FillColor=ROOT.kGray+2, Label="Single T" SingleTop: TToLeptons_sch: xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==0) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==0)) ; FillColor=ROOT.kGray+2, Label="Single T" SingleTop: T_tWch: xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==0) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==0)) ; FillColor=ROOT.kGray+2, Label="Single T" SingleTop: TBar_tWch: xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==0) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==0)) ; FillColor=ROOT.kGray+2, Label="Single T" -WW: WWTo2L2Nu: xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==0) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==0)) ; FillColor=ROOT.kGray+1 +#WW: WWTo2L2Nu: xsec : ((LepGood1_mcMatchId==0 && LepGood1_mcPromptGamma==0) || (LepGood2_mcMatchId==0 && LepGood2_mcPromptGamma==0)) ; FillColor=ROOT.kGray+1 -Flips : TTJets_DiLepton : xsec : (LepGood1_mcMatchId!=0 && LepGood2_mcMatchId!=0 && !(LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge)) ; Label="Flips", FillColor=ROOT.kCyan-10 -Flips : DYJetsToLL_M10to50 : xsec : (LepGood1_mcMatchId!=0 && LepGood2_mcMatchId!=0 && !(LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge)) ; Label="Flips", FillColor=ROOT.kCyan-10 -Flips : DYJetsToLL_M50 : xsec : (LepGood1_mcMatchId!=0 && LepGood2_mcMatchId!=0 && !(LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge)) ; Label="Flips", FillColor=ROOT.kCyan-10 +#Flips : TTJets_DiLepton : xsec : (LepGood1_mcMatchId!=0 && LepGood2_mcMatchId!=0 && !(LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge)) ; Label="Flips", FillColor=ROOT.kCyan-10 +#Flips : DYJetsToLL_M10to50 : xsec : (LepGood1_mcMatchId!=0 && LepGood2_mcMatchId!=0 && !(LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge)) ; Label="Flips", FillColor=ROOT.kCyan-10 +#Flips : DYJetsToLL_M50 : xsec : (LepGood1_mcMatchId!=0 && LepGood2_mcMatchId!=0 && !(LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge)) ; Label="Flips", FillColor=ROOT.kCyan-10 Flips : T_tWch : xsec : (LepGood1_mcMatchId!=0 && LepGood2_mcMatchId!=0 && !(LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge)) ; Label="Flips", FillColor=ROOT.kCyan-10 Flips : TBar_tWch : xsec : (LepGood1_mcMatchId!=0 && LepGood2_mcMatchId!=0 && !(LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge)) ; Label="Flips", FillColor=ROOT.kCyan-10 -Flips : WWTo2L2Nu : xsec : (LepGood1_mcMatchId!=0 && LepGood2_mcMatchId!=0 && !(LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge)) ; Label="Flips", FillColor=ROOT.kCyan-10 +#Flips : WWTo2L2Nu : xsec : (LepGood1_mcMatchId!=0 && LepGood2_mcMatchId!=0 && !(LepGood1_isMatchRightCharge && LepGood2_isMatchRightCharge)) ; Label="Flips", FillColor=ROOT.kCyan-10 diff --git a/TTHAnalysis/python/plotter/ttH-multilepton/ttH_plots.py b/TTHAnalysis/python/plotter/ttH-multilepton/ttH_plots.py index 130bc7b05384..39949fac7978 100644 --- a/TTHAnalysis/python/plotter/ttH-multilepton/ttH_plots.py +++ b/TTHAnalysis/python/plotter/ttH-multilepton/ttH_plots.py @@ -11,17 +11,19 @@ def base(selection): - CORE="--Fs {P}/2_recleaner_v5_b1E2 --Fs {P}/4_kinMVA_without_MEM_v5 --Fs {P}/8_bTagSF_12fb_v45" + #CORE="--Fs {P}/2_recleaner_v5_b1E2 --Fs {P}/4_kinMVA_without_MEM_v5 --Fs {P}/8_bTagSF_12fb_v45" + CORE="--Fs {P}/leptonJetReCleanerTTH" CORE+=" -f -j 8 -l 12.9 --s2v -L ttH-multilepton/functionsTTH.cc --tree treeProducerSusyMultilepton --mcc ttH-multilepton/lepchoice-ttH-FO.txt --mcc ttH-multilepton/ttH_2lss3l_triggerdefs.txt"# --neg" if dowhat == "plots": CORE+=" --lspam '#bf{CMS} #it{Preliminary}' --legendWidth 0.20 --legendFontSize 0.035 --showRatio --maxRatioRange 0 2 --fixRatioRange --showMCError --rebin 4 --xP 'nT_.*' --xP 'debug_.*'" if selection=='2lss': - GO="%s -P /data1/peruzzi/mixture_jecv6prompt_datafull_jul20_skimOnlyMC ttH-multilepton/mca-2lss-mc.txt ttH-multilepton/2lss_tight.txt "%CORE - GO="%s -W 'puw2016_nTrueInt_13fb(nTrueInt)*leptonSF_ttH(LepGood_pdgId[iF_Recl[0]],LepGood_pt[iF_Recl[0]],LepGood_eta[iF_Recl[0]],2)*leptonSF_ttH(LepGood_pdgId[iF_Recl[1]],LepGood_pt[iF_Recl[1]],LepGood_eta[iF_Recl[1]],2)*triggerSF_ttH(LepGood_pdgId[iF_Recl[0]],LepGood_pt[iF_Recl[0]],LepGood_pdgId[iF_Recl[1]],LepGood_pt[iF_Recl[1]],2)*eventBTagSF'"%GO + GO="%s -P /nfs/fanae/user/sscruz/TTH/samples/ ttH-multilepton/mca-2lss-mc.txt ttH-multilepton/2lss_tight.txt "%CORE + #GO="%s -W 'puw2016_nTrueInt_13fb(nTrueInt)*leptonSF_ttH(LepGood_pdgId[iF_Recl[0]],LepGood_pt[iF_Recl[0]],LepGood_eta[iF_Recl[0]],2)*leptonSF_ttH(LepGood_pdgId[iF_Recl[1]],LepGood_pt[iF_Recl[1]],LepGood_eta[iF_Recl[1]],2)*triggerSF_ttH(LepGood_pdgId[iF_Recl[0]],LepGood_pt[iF_Recl[0]],LepGood_pdgId[iF_Recl[1]],LepGood_pt[iF_Recl[1]],2)*eventBTagSF'"%GO + GO="%s -W 'puw2016_nTrueInt_13fb(nTrueInt)*leptonSF_ttH(LepGood_pdgId[iF_Recl[0]],LepGood_pt[iF_Recl[0]],LepGood_eta[iF_Recl[0]],2)*leptonSF_ttH(LepGood_pdgId[iF_Recl[1]],LepGood_pt[iF_Recl[1]],LepGood_eta[iF_Recl[1]],2)*triggerSF_ttH(LepGood_pdgId[iF_Recl[0]],LepGood_pt[iF_Recl[0]],LepGood_pdgId[iF_Recl[1]],LepGood_pt[iF_Recl[1]],2)'"%GO if dowhat == "plots": GO+=" ttH-multilepton/2lss_3l_plots.txt --xP '^lep(3|4)_.*' --xP '^(3|4)lep_.*' --xP 'kinMVA_3l_.*' " elif selection=='3l': - GO="%s -P /data1/peruzzi/mixture_jecv6prompt_datafull_jul20_skimOnlyMC ttH-multilepton/mca-3l-mc.txt ttH-multilepton/3l_tight.txt "%CORE + GO="%s -P /nfs/fanae/user/sscruz/TTH/samples/leptonJetReCleanerTTH/ ttH-multilepton/mca-3l-mc.txt ttH-multilepton/3l_tight.txt "%CORE GO="%s -W 'puw2016_nTrueInt_13fb(nTrueInt)*leptonSF_ttH(LepGood_pdgId[iF_Recl[0]],LepGood_pt[iF_Recl[0]],LepGood_eta[iF_Recl[0]],3)*leptonSF_ttH(LepGood_pdgId[iF_Recl[1]],LepGood_pt[iF_Recl[1]],LepGood_eta[iF_Recl[1]],3)*leptonSF_ttH(LepGood_pdgId[iF_Recl[2]],LepGood_pt[iF_Recl[2]],LepGood_eta[iF_Recl[2]],3)*triggerSF_ttH(LepGood_pdgId[iF_Recl[0]],LepGood_pt[iF_Recl[0]],LepGood_pdgId[iF_Recl[1]],LepGood_pt[iF_Recl[1]],3)*eventBTagSF'"%GO if dowhat == "plots": GO+=" ttH-multilepton/2lss_3l_plots.txt --xP '^(2|4)lep_.*' --xP '^lep4_.*' --xP 'kinMVA_2lss_.*' " else: @@ -59,7 +61,6 @@ def doprescale3l(x): torun = sys.argv[2] if (not allow_unblinding) and '_data' in torun and (not any([re.match(x.strip()+'$',torun) for x in ['.*_appl.*','cr_.*']])): raise RuntimeError, 'You are trying to unblind!' - if '2lss_' in torun: x = base('2lss') if '_appl' in torun: x = add(x,'-I ^TT ') @@ -249,3 +250,5 @@ def doprescale3l(x): runIt(x,'%s'%torun,plots) x = add(x,"-E ^4j ") runIt(x,'%s_4j'%torun,plots) + + print torun diff --git a/TTHAnalysis/python/tools/conept.py b/TTHAnalysis/python/tools/conept.py index a0cb06fadca4..65b2de06ce40 100644 --- a/TTHAnalysis/python/tools/conept.py +++ b/TTHAnalysis/python/tools/conept.py @@ -73,7 +73,7 @@ def conept_SSDL_for3l(lep): def conept_TTH(lep): if (abs(lep.pdgId)!=11 and abs(lep.pdgId)!=13): return lep.pt - if (abs(lep.pdgId)!=13 or lep.ICHEPmediumMuonId>0) and lep.mvaTTH > 0.75: return lep.pt + if (abs(lep.pdgId)!=13 or lep.mediumMuonId>0) and lep.mvaTTH > 0.75: return lep.pt else: return 0.85 * lep.pt / lep.jetPtRatiov2 from CMGTools.TTHAnalysis.analyzers.ntupleTypes import jetLepAwareJEC diff --git a/TTHAnalysis/python/tools/eventVars_2lss.py b/TTHAnalysis/python/tools/eventVars_2lss.py index 7b3f7c01c044..e44e4122b649 100644 --- a/TTHAnalysis/python/tools/eventVars_2lss.py +++ b/TTHAnalysis/python/tools/eventVars_2lss.py @@ -14,14 +14,12 @@ def __init__(self, label="", recllabel='Recl'): def listBranches(self): return self.branches[:] def __call__(self,event): - allret = {} all_leps = [l for l in Collection(event,"LepGood","nLepGood")] nFO = getattr(event,"nLepFO"+self.inputlabel) chosen = getattr(event,"iF"+self.inputlabel) leps = [all_leps[chosen[i]] for i in xrange(nFO)] - for var in self.systsJEC: _var = var if not hasattr(event,"nJet"+self.systsJEC[var]): _var = 0 @@ -30,7 +28,6 @@ def __call__(self,event): _ijets_list = getattr(event,"iJSel"+self.inputlabel+self.systsJEC[_var]) _ijets = [ij for ij in _ijets_list] jets = [ (jetsc[ij] if ij>=0 else jetsd[-ij-1]) for ij in _ijets] - met = getattr(event,"met"+self.systsJEC[_var]+"_pt") metphi = getattr(event,"met"+self.systsJEC[_var]+"_phi") njet = len(jets); nlep = len(leps) @@ -65,7 +62,6 @@ def __call__(self,event): for br in self.namebranches: allret[br+self.label+self.systsJEC[var]] = ret[br] - return allret diff --git a/TTHAnalysis/python/tools/kinMVA_2D_2lss_3l.py b/TTHAnalysis/python/tools/kinMVA_2D_2lss_3l.py index 13baa2bc9170..61a1d1b0268a 100644 --- a/TTHAnalysis/python/tools/kinMVA_2D_2lss_3l.py +++ b/TTHAnalysis/python/tools/kinMVA_2D_2lss_3l.py @@ -171,12 +171,17 @@ def put_minus_99(self,event): def listBranches(self): return self._MVAs.keys() def __call__(self,event): + print 'event', type(event) out = {} for name, mva in self._MVAs.iteritems(): _mva = mva for i,j in self.systsJEC.iteritems(): if j in name and not hasattr(event,"nJet"+j): _mva = self._MVAs[name.replace(j,"")] - if '2lss' in name: out[name] = _mva(event) if event.nLepFO_Recl>=2 else -99 + if '2lss' in name: + if event.nLepFO_Recl>=2: + print 'calling mva' + out[name] = _mva(event) if event.nLepFO_Recl>=2 else -99 + print 'out',out[name] elif '3l' in name: out[name] = _mva(event) if event.nLepFO_Recl>=3 else -99 return out diff --git a/TTHAnalysis/python/tools/leptonJetReCleaner.py b/TTHAnalysis/python/tools/leptonJetReCleaner.py index 4b9fd3fa4c58..d30dee3de083 100644 --- a/TTHAnalysis/python/tools/leptonJetReCleaner.py +++ b/TTHAnalysis/python/tools/leptonJetReCleaner.py @@ -76,7 +76,8 @@ def listBranches(self): for key in self.systsJEC: biglist.extend([ - ("nJetSel"+label+self.systsJEC[key], "I"), ("iJSel"+label+self.systsJEC[key],"I",20,"nJetSel"+label+self.systsJEC[key]), # index >= 0 if in Jet; -1-index (<0) if in DiscJet + ("nJetSel"+label+self.systsJEC[key], "I"), + ("iJSel"+label+self.systsJEC[key],"I",20,"nJetSel"+label+self.systsJEC[key]), # index >= 0 if in Jet; -1-index (<0) if in DiscJet ("nDiscJetSel"+label+self.systsJEC[key], "I"), ("iDiscJSel"+label+self.systsJEC[key],"I",20,"nDiscJetSel"+label+self.systsJEC[key]), # index >= 0 if in Jet; -1-index (<0) if in DiscJet ("nJet"+self.strJetPt+label+self.systsJEC[key], "I"), "htJet"+self.strJetPt + "j"+label+self.systsJEC[key], "mhtJet"+self.strJetPt + label+self.systsJEC[key], ("nBJetLoose"+self.strJetPt+label+self.systsJEC[key], "I"), ("nBJetMedium"+self.strJetPt+label+self.systsJEC[key], "I"), @@ -281,6 +282,7 @@ def __call__(self,event): ### attach labels and return fullret["nLepGood"]=len(leps) fullret["LepGood_conePt"] = [lep.conept for lep in leps] + for k,v in ret.iteritems(): fullret[k+self.label] = v fullret.update(retwlabel) @@ -289,6 +291,7 @@ def __call__(self,event): fullret["TauSel%s_%s" % (self.label,k)] = v for k,v in jetret.iteritems(): fullret["JetSel%s_%s" % (self.label,k)] = v + return fullret diff --git a/TTHAnalysis/python/tools/multilepFriendTreeProducersToCleanup.py b/TTHAnalysis/python/tools/multilepFriendTreeProducersToCleanup.py index 89f46cf22151..23256c8209b2 100644 --- a/TTHAnalysis/python/tools/multilepFriendTreeProducersToCleanup.py +++ b/TTHAnalysis/python/tools/multilepFriendTreeProducersToCleanup.py @@ -21,9 +21,9 @@ #--- Recleaner instances from CMGTools.TTHAnalysis.tools.leptonChoiceRA5 import _susy2lss_lepId_CBloose,_susy2lss_lepId_loosestFO,_susy2lss_lepId_IPcuts,_susy2lss_lepConePt1015,_susy2lss_lepId_tighterFO,_susy2lss_multiIso,_susy2lss_lepId_CB,_susy2lss_idIsoEmu_cuts from CMGTools.TTHAnalysis.tools.leptonChoiceRA7 import _susy3l_lepId_CBloose, _susy3l_lepId_loosestFO,_susy3l_lepId_loosestFO,_susy3l_multiIso,_susy3l_lepId_CB -from CMGTools.TTHAnalysis.tools.leptonBuilderEWK import _susyEWK_lepId_CBloose, _susyEWK_lepId_IPcuts, _susyEWK_lepId_MVAFO, _susyEWK_lepId_MVAmedium, _susyEWK_tauId_CBloose, _susyEWK_tauId_CBtight +#from CMGTools.TTHAnalysis.tools.leptonBuilderEWK import _susyEWK_lepId_CBloose, _susyEWK_lepId_IPcuts, _susyEWK_lepId_MVAFO, _susyEWK_lepId_MVAmedium, _susyEWK_tauId_CBloose, _susyEWK_tauId_CBtight from CMGTools.TTHAnalysis.tools.functionsTTH import _ttH_idEmu_cuts_E2 -from CMGTools.TTHAnalysis.tools.functionsEWKino import _ewkino_idEmu_cuts_E2, _ewkino_2lss_lepId_CBloose, _ewkino_2lss_lepId_FO, _ewkino_2lss_lepId_num,_ewkino_3l_lepId_FO, _ewkino_3l_lepId_num, _ewkino_2lss_lepId_IPcuts, _ewkino_leptonMVA_VT, _ewkino_leptonMVA_M +#from CMGTools.TTHAnalysis.tools.functionsEWKino import _ewkino_idEmu_cuts_E2, _ewkino_2lss_lepId_CBloose, _ewkino_2lss_lepId_FO, _ewkino_2lss_lepId_num,_ewkino_3l_lepId_FO, _ewkino_3l_lepId_num, _ewkino_2lss_lepId_IPcuts, _ewkino_leptonMVA_VT, _ewkino_leptonMVA_M from CMGTools.TTHAnalysis.tools.conept import conept_RA5, conept_RA7, conept_EWK, conept_TTH, conept_SSDL, conept_SSDL_for3l MODULES.append( ('leptonJetReCleanerSusyRA5', lambda : LeptonJetReCleaner("Mini", @@ -65,67 +65,67 @@ # MVA (upper limits and combination) -MODULES.append( ('leptonJetReCleanerSusyEWK3L', lambda : LeptonJetReCleaner("Mini", - lambda lep : lep.miniRelIso < 0.4 and _susyEWK_lepId_CBloose(lep) and _susyEWK_lepId_IPcuts(lep), - lambda lep : lep.pt>10 and lep.conept>10 and (_susyEWK_lepId_MVAmedium(lep) or _susyEWK_lepId_MVAFO(lep)), - lambda lep,ht : lep.pt>10 and lep.conept>10 and (_susyEWK_lepId_MVAmedium(lep) or _susyEWK_lepId_MVAFO(lep)), # cuts applied on top of loose - lambda lep,ht : lep.pt>10 and lep.conept>10 and _susyEWK_lepId_MVAmedium(lep), # medium WP - cleanJet = lambda lep,jet,dr : dr<0.4, - selectJet = lambda jet: abs(jet.eta)<2.4, - cleanTau = lambda lep,tau,dr: dr<0.4, - looseTau = lambda tau: _susyEWK_tauId_CBloose(tau), # used in cleaning - tightTau = lambda tau: _susyEWK_tauId_CBtight(tau), # on top of loose - cleanJetsWithTaus = True, - cleanTausWithLoose = True, - doVetoZ = False, - doVetoLMf = False, - doVetoLMt = True, - jetPt = 30, - bJetPt = 25, - coneptdef = lambda lep: conept_EWK(lep, 2), - ) )) - -# All jets, needed for tau fakes study -MODULES.append( ('leptonJetReCleanerNoCleanTausSusyEWK3L', lambda : LeptonJetReCleaner("Mini", - lambda lep : lep.miniRelIso < 0.4 and _susyEWK_lepId_CBloose(lep) and _susyEWK_lepId_IPcuts(lep), - lambda lep : lep.pt>10 and lep.conept>10 and (_susyEWK_lepId_MVAmedium(lep) or _susyEWK_lepId_MVAFO(lep)), - lambda lep,ht : lep.pt>10 and lep.conept>10 and (_susyEWK_lepId_MVAmedium(lep) or _susyEWK_lepId_MVAFO(lep)), # cuts applied on top of loose - lambda lep,ht : lep.pt>10 and lep.conept>10 and _susyEWK_lepId_MVAmedium(lep), # medium WP - cleanJet = lambda lep,jet,dr : dr<0.4, - selectJet = lambda jet: abs(jet.eta)<2.4, - cleanTau = lambda lep,tau,dr: dr<0.4, - looseTau = lambda tau: _susyEWK_tauId_CBloose(tau), # used in cleaning - tightTau = lambda tau: _susyEWK_tauId_CBtight(tau), # on top of loose - cleanJetsWithTaus = False, - cleanTausWithLoose = True, - doVetoZ = False, - doVetoLMf = False, - doVetoLMt = True, - jetPt = 20, - bJetPt = 25, - coneptdef = lambda lep: conept_EWK(lep, 2), - ) )) - -MODULES.append( ('leptonJetReCleanerSusyEWK2L', lambda : LeptonJetReCleaner("Recl", - looseLeptonSel = lambda lep : lep.miniRelIso < 0.4 and _ewkino_2lss_lepId_IPcuts(lep) and _ewkino_2lss_lepId_CBloose(lep), - cleaningLeptonSel = lambda lep : lep.pt>10 and lep.conept>10 and (_ewkino_2lss_lepId_num(lep) or _ewkino_2lss_lepId_FO(lep)), # cuts on top of loose - FOLeptonSel = lambda lep,ht : lep.pt>10 and lep.conept>10 and (_ewkino_2lss_lepId_num(lep) or _ewkino_2lss_lepId_FO(lep)), # cuts on top of loose - tightLeptonSel = lambda lep,ht : lep.pt>10 and lep.conept>10 and _ewkino_2lss_lepId_num(lep), # on top of loose - cleanJet = lambda lep,jet,dr : dr<0.4, - selectJet = lambda jet: abs(jet.eta)<2.4, - cleanTau = lambda lep,tau,dr: dr<0.4, - looseTau = lambda tau: _susyEWK_tauId_CBloose(tau), # used in cleaning - tightTau = lambda tau: _susyEWK_tauId_CBtight(tau), # on top of loose - cleanJetsWithTaus = True, - doVetoZ = True, - doVetoLMf = True, - doVetoLMt = True, - jetPt = 40, - bJetPt = 25, - coneptdef = lambda lep: conept_SSDL(lep) - ) )) - -MODULES.append( ('MediumMuonID2016', lambda : ObjTagger(label='ICHEPmediumMuonId', coll='LepGood', +# MODULES.append( ('leptonJetReCleanerSusyEWK3L', lambda : LeptonJetReCleaner("Mini", +# lambda lep : lep.miniRelIso < 0.4 and _susyEWK_lepId_CBloose(lep) and _susyEWK_lepId_IPcuts(lep), +# lambda lep : lep.pt>10 and lep.conept>10 and (_susyEWK_lepId_MVAmedium(lep) or _susyEWK_lepId_MVAFO(lep)), +# lambda lep,ht : lep.pt>10 and lep.conept>10 and (_susyEWK_lepId_MVAmedium(lep) or _susyEWK_lepId_MVAFO(lep)), # cuts applied on top of loose +# lambda lep,ht : lep.pt>10 and lep.conept>10 and _susyEWK_lepId_MVAmedium(lep), # medium WP +# cleanJet = lambda lep,jet,dr : dr<0.4, +# selectJet = lambda jet: abs(jet.eta)<2.4, +# cleanTau = lambda lep,tau,dr: dr<0.4, +# looseTau = lambda tau: _susyEWK_tauId_CBloose(tau), # used in cleaning +# tightTau = lambda tau: _susyEWK_tauId_CBtight(tau), # on top of loose +# cleanJetsWithTaus = True, +# cleanTausWithLoose = True, +# doVetoZ = False, +# doVetoLMf = False, +# doVetoLMt = True, +# jetPt = 30, +# bJetPt = 25, +# coneptdef = lambda lep: conept_EWK(lep, 2), +# ) )) + +# # All jets, needed for tau fakes study +# MODULES.append( ('leptonJetReCleanerNoCleanTausSusyEWK3L', lambda : LeptonJetReCleaner("Mini", +# lambda lep : lep.miniRelIso < 0.4 and _susyEWK_lepId_CBloose(lep) and _susyEWK_lepId_IPcuts(lep), +# lambda lep : lep.pt>10 and lep.conept>10 and (_susyEWK_lepId_MVAmedium(lep) or _susyEWK_lepId_MVAFO(lep)), +# lambda lep,ht : lep.pt>10 and lep.conept>10 and (_susyEWK_lepId_MVAmedium(lep) or _susyEWK_lepId_MVAFO(lep)), # cuts applied on top of loose +# lambda lep,ht : lep.pt>10 and lep.conept>10 and _susyEWK_lepId_MVAmedium(lep), # medium WP +# cleanJet = lambda lep,jet,dr : dr<0.4, +# selectJet = lambda jet: abs(jet.eta)<2.4, +# cleanTau = lambda lep,tau,dr: dr<0.4, +# looseTau = lambda tau: _susyEWK_tauId_CBloose(tau), # used in cleaning +# tightTau = lambda tau: _susyEWK_tauId_CBtight(tau), # on top of loose +# cleanJetsWithTaus = False, +# cleanTausWithLoose = True, +# doVetoZ = False, +# doVetoLMf = False, +# doVetoLMt = True, +# jetPt = 20, +# bJetPt = 25, +# coneptdef = lambda lep: conept_EWK(lep, 2), +# ) )) + +# MODULES.append( ('leptonJetReCleanerSusyEWK2L', lambda : LeptonJetReCleaner("Recl", +# looseLeptonSel = lambda lep : lep.miniRelIso < 0.4 and _ewkino_2lss_lepId_IPcuts(lep) and _ewkino_2lss_lepId_CBloose(lep), +# cleaningLeptonSel = lambda lep : lep.pt>10 and lep.conept>10 and (_ewkino_2lss_lepId_num(lep) or _ewkino_2lss_lepId_FO(lep)), # cuts on top of loose +# FOLeptonSel = lambda lep,ht : lep.pt>10 and lep.conept>10 and (_ewkino_2lss_lepId_num(lep) or _ewkino_2lss_lepId_FO(lep)), # cuts on top of loose +# tightLeptonSel = lambda lep,ht : lep.pt>10 and lep.conept>10 and _ewkino_2lss_lepId_num(lep), # on top of loose +# cleanJet = lambda lep,jet,dr : dr<0.4, +# selectJet = lambda jet: abs(jet.eta)<2.4, +# cleanTau = lambda lep,tau,dr: dr<0.4, +# looseTau = lambda tau: _susyEWK_tauId_CBloose(tau), # used in cleaning +# tightTau = lambda tau: _susyEWK_tauId_CBtight(tau), # on top of loose +# cleanJetsWithTaus = True, +# doVetoZ = True, +# doVetoLMf = True, +# doVetoLMt = True, +# jetPt = 40, +# bJetPt = 25, +# coneptdef = lambda lep: conept_SSDL(lep) +# ) )) + +MODULES.append( ('MediumMuonID2016', lambda : ObjTagger(label='mediumMuonId', coll='LepGood', sel = [lambda x : abs(x.pdgId)==13, lambda x : x.isGlobalMuon or x.isTrackerMuon, lambda x : x.innerTrackValidHitFraction>0.49, @@ -136,12 +136,12 @@ looseLeptonSel = lambda lep : lep.miniRelIso < 0.4 and lep.sip3d < 8, cleaningLeptonSel = lambda lep : lep.conept>10 and lep.jetBTagCSV<0.80 and (abs(lep.pdgId)!=11 or lep.conept<30 or _ttH_idEmu_cuts_E2(lep)) and ((lep.jetPtRatiov2>0.3 and lep.jetBTagCSV<0.46) or lep.mvaTTH>0.75), # cuts applied on top of loose FOLeptonSel = lambda lep,ht : lep.conept>10 and lep.jetBTagCSV<0.80 and (abs(lep.pdgId)!=11 or lep.conept<30 or _ttH_idEmu_cuts_E2(lep)) and ((lep.jetPtRatiov2>0.3 and lep.jetBTagCSV<0.46) or lep.mvaTTH>0.75), # cuts applied on top of loose - tightLeptonSel = lambda lep,ht : lep.conept>10 and lep.jetBTagCSV<0.80 and (abs(lep.pdgId)!=11 or lep.conept<30 or _ttH_idEmu_cuts_E2(lep)) and ((lep.jetPtRatiov2>0.3 and lep.jetBTagCSV<0.46) or lep.mvaTTH>0.75) and (abs(lep.pdgId)!=13 or lep.ICHEPmediumMuonId>0) and lep.mvaTTH > 0.75, # cuts applied on top of loose + tightLeptonSel = lambda lep,ht : lep.conept>10 and lep.jetBTagCSV<0.80 and (abs(lep.pdgId)!=11 or lep.conept<30 or _ttH_idEmu_cuts_E2(lep)) and ((lep.jetPtRatiov2>0.3 and lep.jetBTagCSV<0.46) or lep.mvaTTH>0.75) and (abs(lep.pdgId)!=13 or lep.mediumMuonId>0) and lep.mvaTTH > 0.75, # cuts applied on top of loose cleanJet = lambda lep,jet,dr : dr<0.4, # called on cleaning leptons and loose taus - selectJet = lambda jet: abs(jet.eta)<2.4, + selectJet = lambda jet: abs(jet.eta)<2.4 and jet.pt > 25., cleanTau = lambda lep,tau,dr: dr<0.4, - looseTau = lambda tau: tau.pt > 20 and abs(tau.eta)<2.3 and abs(tau.dxy) < 1000 and abs(tau.dz) < 0.2 and tau.idMVAOldDMRun2dR03 >= 1 and tau.idDecayMode, # used in cleaning - tightTau = lambda tau: tau.idMVAOldDMRun2dR03 >= 2, # cuts applied on top of loose + looseTau = lambda tau: tau.pt > 20 and abs(tau.eta)<2.3 and abs(tau.dxy) < 1000 and abs(tau.dz) < 0.2 and tau.idMVAdR03 >= 2 and tau.idDecayMode, # used in cleaning + tightTau = lambda tau: tau.idMVAdR03 >= 3, # cuts applied on top of loose cleanJetsWithTaus = True, cleanTausWithLoose = True, # cleaning taus with cleaningLeptonSel == loose doVetoZ = True, @@ -153,10 +153,10 @@ #--- Lepton builder instances -from CMGTools.TTHAnalysis.tools.leptonBuilderEWK import LeptonBuilderEWK +#from CMGTools.TTHAnalysis.tools.leptonBuilderEWK import LeptonBuilderEWK -MODULES.append( ('leptonBuilderEWK', lambda : LeptonBuilderEWK("Mini"))) -MODULES.append( ('leptonBuilderWZCR_EWK', lambda : LeptonBuilderEWK("Recl"))) +#MODULES.append( ('leptonBuilderEWK', lambda : LeptonBuilderEWK("Mini"))) +#MODULES.append( ('leptonBuilderWZCR_EWK', lambda : LeptonBuilderEWK("Recl"))) #--- Tau builder instances from CMGTools.TTHAnalysis.tools.TauFakesBuilder import TauFakesBuilder diff --git a/TTHAnalysis/python/tools/mvaTool.py b/TTHAnalysis/python/tools/mvaTool.py index aa4ad3465275..eea914fd88c5 100644 --- a/TTHAnalysis/python/tools/mvaTool.py +++ b/TTHAnalysis/python/tools/mvaTool.py @@ -4,19 +4,22 @@ class MVAVar: def __init__(self,name,type='f',func=None): self.name = name + print self.name if func != None: self.func = func else: if ":=" in self.name: self.expr = self.name.split(":=")[1] + print self.name, self.expr self.func = lambda ev : ev.eval(self.expr) else: self.func = lambda ev : ev[self.name] self.type = type self.var = array('f',[0.]) #TMVA wants ints as floats! #array(type,[0 if type == 'i' else 0.]) def set(self,ev): + print 'setting', self.func self.var[0] = self.func(ev) - + print 'now its set' class MVATool: def __init__(self,name,xml,vars,rarity=False,specs=[],nClasses=1): self.name = name @@ -31,7 +34,11 @@ def __init__(self,name,xml,vars,rarity=False,specs=[],nClasses=1): self.rarity = rarity if self.rarity and self.nClasses!=1: raise RuntimeError, 'not implemented' def __call__(self,ev): - for s in self.vars: s.set(ev) + print 'setting variables' + for s in self.vars: + print 'here',s.name, ev.nLepGood, ev.iF_Recl[0], ev.iF_Recl[1] + s.set(ev) + print 'variables set' for s in self.specs: s.set(ev) return (self.reader.EvaluateMVA(self.name) if self.nClasses==1 else self.reader.EvaluateMulticlass(self.name)) if not self.rarity else self.reader.GetRarity(self.name)