def __init__( self, file="/afs/cern.ch/work/e/emanuele/public/monox/leptonsf/leptonTrigsfs.root" ): tfile = ROOT.TFile(file) self.hm = tfile.Get("hltmu20_SF").Clone( "LepTriggerSF_SingleMuonTriggerSF") self.he = tfile.Get("hltel27_SF").Clone( "LepTriggerSF_SingleEleTriggerSF") self.hm.SetDirectory(None) self.he.SetDirectory(None) tfile.Close() self.evtSel = EventVarsMonojet()
def __init__(self): self.f_el = ROOT.TFile("/afs/cern.ch/work/e/emanuele/public/monox/leptonsf/eff_electron.root") self.f_mu = ROOT.TFile("/afs/cern.ch/work/e/emanuele/public/monox/leptonsf/eff_muon.root") self.evtSel = EventVarsMonojet() self.sf_TightLoose = Lep_SF_Event(self.evtSel,self.f_el,self.f_mu,"LepTightSF1","LepLooseSF1") self.sf_Tight = Lep_SF_Event(self.evtSel,self.f_el,self.f_mu,"LepTightSF1") self.f_el.Close() self.f_mu.Close()
class LepTriggerSF_Event: def __init__( self, file="/afs/cern.ch/work/e/emanuele/public/monox/leptonsf/leptonTrigsfs.root" ): tfile = ROOT.TFile(file) self.hm = tfile.Get("hltmu20_SF").Clone( "LepTriggerSF_SingleMuonTriggerSF") self.he = tfile.Get("hltel27_SF").Clone( "LepTriggerSF_SingleEleTriggerSF") self.hm.SetDirectory(None) self.he.SetDirectory(None) tfile.Close() self.evtSel = EventVarsMonojet() def __call__(self, event): leps = Collection(event, "LepGood", "nLepGood", 2) # single-lepton triggers have tight ID tightLeps = [l for l in leps if self.evtSel.lepIdTight(l)] if len(tightLeps) < 1: return 1.0 id1 = abs(leps[0].pdgId) h = self.hm if id1 == 13 else self.he return h.GetBinContent(h.FindBin(leps[0].pt, abs(leps[0].eta)))
def __init__(self): self.f_el = [ ROOT.TFile( "/afs/cern.ch/work/e/emanuele/public/monox/leptonsf/eff_eleID_CutsID_Medium_ICHEP16.root" ), ROOT.TFile( "/afs/cern.ch/work/e/emanuele/public/monox/leptonsf/eff_eleID_CutsID_Veto_ICHEP16.root" ) ] self.f_mu = [ ROOT.TFile( "/afs/cern.ch/work/e/emanuele/public/monox/leptonsf/eff_muID_medium_ICHEP16.root" ), ROOT.TFile( "/afs/cern.ch/work/e/emanuele/public/monox/leptonsf/eff_muID_loose_ICHEP16.root" ) ] self.evtSel = EventVarsMonojet() self.sf_TightLoose = Lep_SF_Event(self.evtSel, self.f_el, self.f_mu, 2) self.sf_Tight = Lep_SF_Event(self.evtSel, self.f_el, self.f_mu, 1) files = self.f_el + self.f_mu for f in files: f.Close()
#!/usr/bin/env python from CMGTools.TTHAnalysis.treeReAnalyzer import * from glob import glob import os.path, re, pickle MODULES = [] from CMGTools.MonoXAnalysis.tools.eventVars_monojet import EventVarsMonojet MODULES.append( ('vars_mj', EventVarsMonojet()) ) class VariableProducer(Module): def __init__(self,name,booker,sample_nevt,modules): Module.__init__(self,name,booker) self._modules = modules self._sample_nevt = sample_nevt def beginJob(self): self.t = PyTree(self.book("TTree","t","t")) self.branches = {} for name,mod in self._modules: mod.initSampleNormalization(self._sample_nevt) for B in mod.listBranches(): # don't add the same branch twice if B in self.branches: print "Will not add branch %s twice" % (B,) continue self.branches[B] = True if type(B) == tuple: if len(B) == 2: self.t.branch(B[0],B[1]) elif len(B) == 4: self.t.branch(B[0],B[1],n=B[2],lenVar=B[3])