-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTauEffZMM.py
134 lines (113 loc) · 5.74 KB
/
TauEffZMM.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
'''
Make plots of Z->tau tau -> mu tau events.
Author: Mauro Verzetti, UniZh
'''
import MuMuTree
from TauEffBase import TauEffBase
from FinalStateAnalysis.PlotTools.decorators import memo
import mcCorrectors
import baseSelections as selections
import glob
import os
import ROOT
@memo
def getHist(dire , name):
return '/'.join([dire,name])
################################################################################
#### MC-DATA and PU corrections ################################################
################################################################################
class TauEffZMM(TauEffBase):
tree = 'mm/final/Ntuple'
def __init__(self, tree, outfile, **kwargs):
super(TauEffZMM, self).__init__(tree, outfile,MuMuTree.MuMuTree, **kwargs)
self.pucorrector = mcCorrectors.make_puCorrector('singlemu')
self.objId = [
'h2Tau',
]
self.id_functions = {
'h2Tau' : lambda row: selections.mu_idIso(row, 'm2'),
'sign_cut' : self.sign_cut,
}
self.id_functions_with_sys = {
}
self.hfunc['MET_Z_perp'] = lambda row, weight: (row.type1_pfMetEt*ROOT.TMath.Cos(row.m1_m2_ToMETDPhi_Ty1), weight)
self.hfunc['MET_Z_para'] = lambda row, weight: (row.type1_pfMetEt*ROOT.TMath.Sin(row.m1_m2_ToMETDPhi_Ty1), weight)
def build_folder_structure(self):
flag_map = {}
for obj_id_name in self.objId:
for sign in ['ss', 'os']:
flag_map['/'.join((obj_id_name, sign))] = {
'h2Tau' : True,
'sign_cut' : (sign == 'os'),
}
return flag_map
def book_histos(self, directory):
self.book(directory, "weight", "Event weight", 100, 0, 5)
self.book(directory, "rho", "Fastjet #rho", 100, 0, 25)
self.book(directory, "nvtx", "Number of vertices", 31, -0.5, 30.5)
#self.book(directory, "prescale", "HLT prescale", 21, -0.5, 20.5)
self.book(directory, "m1Pt", "Muon 1 Pt", 100, 0, 100)
self.book(directory, "m2Pt", "Muon 2 Pt", 100, 0, 100)
self.book(directory, "m1AbsEta", "Muon 1 eta", 100, 0, 5)
self.book(directory, "m2AbsEta", "Muon 2 eta", 100, 0, 5)
self.book(directory, "m1_m2_Mass", "Muon 1-2 Mass", 300, 0, 300)
#MET "certification"
self.book(directory, "pfMetEt" , "type1_pfMetEt" , 200, 0, 200)
self.book(directory, "pfMetEt_mes" , "type1_pfMetEt" , 200, 0, 200)
self.book(directory, "pfMetEt_tes" , "type1_pfMetEt" , 200, 0, 200)
self.book(directory, "pfMetEt_jes" , "type1_pfMetEt" , 200, 0, 200)
self.book(directory, "pfMetEt_ues" , "type1_pfMetEt" , 200, 0, 200)
self.book(directory, "pfMetPhi", "type1_pfMetPhi", 100, -7, 7)
self.book(directory, "pfMetPhi_mes" , "type1_pfMetPhi", 100, -7, 7)
self.book(directory, "pfMetPhi_tes" , "type1_pfMetPhi", 100, -7, 7)
self.book(directory, "pfMetPhi_jes" , "type1_pfMetPhi", 100, -7, 7)
self.book(directory, "pfMetPhi_ues" , "type1_pfMetPhi", 100, -7, 7)
self.book(directory, "m1MtToPfMET" , "Muon 1 MT", 120, 0, 120)
self.book(directory, "m1MtToPfMET_mes", "Muon 1 MT", 120, 0, 120)
self.book(directory, "m1MtToPfMET_tes", "Muon 1 MT", 120, 0, 120)
self.book(directory, "m1MtToPfMET_jes", "Muon 1 MT", 120, 0, 120)
self.book(directory, "m1MtToPfMET_ues", "Muon 1 MT", 120, 0, 120)
self.book(directory, "m1MtToPfMET_ees", "Muon 1 MT", 120, 0, 120)
self.book(directory, "MET_Z_perp", "MET_Z_perp", 200, 0, 200)
self.book(directory, "MET_Z_para", "MET_Z_para", 200, 0, 200)
# Vetoes
self.book(directory, 'bjetVeto', 'Number of b-jets', 5, -0.5, 4.5)
self.book(directory, 'bjetCSVVeto', 'Number of b-jets', 5, -0.5, 4.5)
self.book(directory, 'muVetoPt5', 'Number of extra muons', 5, -0.5, 4.5)
self.book(directory, 'tauVetoPt20Loose3HitsVtx', 'Number of extra taus', 5, -0.5, 4.5)
self.book(directory, 'eVetoCicTightIso', 'Number of extra CiC tight electrons', 5, -0.5, 4.5)
def event_weight(self, row):
if row.run > 2:
return 1.
trigger_weight = 1.
trigger_weight *= mcCorrectors.muon_pog_IsoMu24eta2p1(row.m1Pt, row.m1Eta) \
if row.m1MatchesIsoMu24eta2p1 else \
1.
trigger_weight *= mcCorrectors.muon_pog_IsoMu24eta2p1(row.m2Pt, row.m2Eta) \
if row.m2MatchesIsoMu24eta2p1 else \
1.
return self.pucorrector(row.nTruePU)*\
mcCorrectors.muon_pog_PFTight(row.m1Pt, row.m1Eta) * \
mcCorrectors.muon_pog_Iso(row.m1Pt, row.m1Eta) * \
mcCorrectors.muon_pog_PFTight(row.m2Pt, row.m2Eta) * \
mcCorrectors.muon_pog_Iso(row.m2Pt, row.m2Eta) * \
trigger_weight
def sign_cut(self, row):
return not row.m1_m2_SS
def is_MT_Low(self, row):
return True #row.m1MtToMET < 20 #This cut is not used in this channel
def preselection(self, row):
''' Preselection applied to events.
Excludes FR object IDs and sign cut.
'''
if not row.isoMu24eta2p1Pass : return False
if not selections.muSelection(row, 'm1', 10): return False
if not selections.muSelection(row, 'm2', 10): return False
m1matches = row.m1MatchesIsoMu24eta2p1 and \
(row.m1Pt > 25) and (row.m1AbsEta < 2.1)
m2matches = row.m2MatchesIsoMu24eta2p1 and \
(row.m2Pt > 25) and (row.m2AbsEta < 2.1)
if not (m1matches or m2matches): return False
if not selections.mu_idIso(row, 'm1'): return False
if not selections.vetos(row): return False
return True