-
Notifications
You must be signed in to change notification settings - Fork 14
/
wvAnalysisModule.py
68 lines (57 loc) · 2.45 KB
/
wvAnalysisModule.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import ROOT
ROOT.PyConfig.IgnoreCommandLineOptions = True
from PhysicsTools.NanoAODTools.postprocessing.framework.datamodel import Collection
from PhysicsTools.NanoAODTools.postprocessing.framework.eventloop import Module
class wvAnalysisProducer(Module):
def __init__(self):
pass
def beginJob(self):
pass
def endJob(self):
pass
def beginFile(self, inputFile, outputFile, inputTree, wrappedOutputTree):
self.out = wrappedOutputTree
#self.out.branch("EventMass", "F");
"""process event, return True (go to next module) or False (fail, go to next event)"""
#pass
def endFile(self, inputFile, outputFile, inputTree, wrappedOutputTree):
pass
def analyze(self, event):
"""nanoAOD skimming is done considering the final events selection
for the vv semileptonic final state.
For the vv semileptonic final state we should be either one or two
tight leptons, either one Fat jet and two small radius jet or four
small radius jets.
Arguments:
event {instance of event} -- instance of event
Returns:
boolean -- if the event passes skimming then it returns true and
go to the next module else returns false and go to
the next event.
"""
electrons = Collection(event, "Electron")
muons = Collection(event, "Muon")
jets = Collection(event, "Jet")
fatJets = Collection(event, "FatJet")
keepIt = True
eventElectrons = 0
eventMuons = 0
eventJets = 0
eventFatJets = 0
for lep in muons :
if lep.tightId and lep.pt > 10 :
eventMuons += 1
for lep in electrons :
if lep.cutBased >= 2 and lep.pt > 10 :
eventElectrons += 1
for jet in jets :
if jet.pt > 20:
eventJets += 1
for fatjet in fatJets :
if fatjet.pt > 20:
eventFatJets += 1
if not ( ((eventElectrons >= 1 or eventMuons >=1)) and ( (eventJets >= 2 and eventFatJets >= 1) or (eventJets >= 4 and eventFatJets == 0) ) ):
keepIt = False
return keepIt
# define modules using the syntax 'name = lambda : constructor' to avoid having them loaded when not needed
wvAnalysisModule = lambda : wvAnalysisProducer() #(jetSelection= lambda j : j.pt > 30)