-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNewAnalysisHelpers.py
More file actions
52 lines (43 loc) · 1.99 KB
/
NewAnalysisHelpers.py
File metadata and controls
52 lines (43 loc) · 1.99 KB
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
import math
"""These helper functions implement three commonly used functionalities:
The Object Selection Helpers represent standard object selections that serve as a starting point for
self defined object selection strategies.
The selectAndSortContainer function can be used to do selecting and sorting in a one liner.
The StandardEventCuts function implements three standard cuts used in essentially all analyses.
"""
lep_num=25
# Object Selection Helpers
def isGoodLepton(Lepton):
if (abs(Lepton.pdgId()) == 11 and isGoodElectron(Lepton)): return True;
if (abs(Lepton.pdgId()) == 13 and isGoodMuon(Lepton)): return True;
return False;
def isGoodElectron(Lepton):
if not Lepton.isTight(): return False
if not Lepton.pt() > lep_num: return False
if not Lepton.isoetconerel20() < 0.15: return False
if not Lepton.isoptconerel30() < 0.15: return False
return True;
def isGoodMuon(Lepton):
if not Lepton.isTight(): return False
if not Lepton.pt() > lep_num: return False
if not Lepton.isoetconerel20() < 0.15: return False
if not Lepton.isoptconerel30() < 0.15: return False
return True;
def isGoodJet(jet):
if jet.pt() < 25: return False
if abs(jet.eta() > 2.5): return False
if jet.pt() < 50 and abs(jet.eta() < 2.4) and jet.jvf() < 0.5: return False
return True
# Utility function
def selectAndSortContainer(container, selectingFunction, sortingFunction):
selectedContainer = [particle for particle in container if selectingFunction(particle)]
return sorted(selectedContainer, key=sortingFunction, reverse=True)
# Event Selection Helpers
def StandardEventCuts(eventinfo):
if not (eventinfo.triggeredByElectron() or eventinfo.triggeredByMuon()): return False
if not eventinfo.passGRL(): return False
if not eventinfo.hasGoodVertex(): return False
return True;
# Variable Definitions:
def WTransverseMass(lepton, etmiss):
return math.sqrt(2*lepton.pt()*etmiss.et()*(1-math.cos(lepton.tlv().DeltaPhi(etmiss.tlv()))));