-
Notifications
You must be signed in to change notification settings - Fork 0
/
ptools.py
222 lines (209 loc) · 8.62 KB
/
ptools.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/usr/bin/env python
#Finn Rebassoo, LLNL 02-03-2017
import math as m
def calcAco(phi1,phi2):
result = phi1-phi2
if result > m.pi : result = result-2*m.pi
if result < m.pi : result = result+2*m.pi
aco=1-result/m.pi
return aco
def ModifyHisto(h,sample):
#h.Scale(2.)
#luminosity_fb=37.2
#luminosity_fb=4.39
#luminosity_fb=12.19
#luminosity_fb=7.8
#Runs BCG
#luminosity_fb=15.9
#Full run
#luminosity_fb=35.8
#Runs BCG
#luminosity_fb=15.9
luminosity_fb=9.4
#Runs BG
#luminosity_fb=13.8
#luminosity_fb=13
#This is luminosity without runD
#luminosity_fb=32.8
print sample
#https://twiki.cern.ch/twiki/bin/viewauth/CMS/SummaryTable1G25ns#Diboson
cross_section_pb=0
numevents=0
linecolor=0
if sample =="ExclusiveWWNonElastic":
#This cross section is from Doug's notes 92.83+/-0.10 for Madgraph 5.2.4.2. But this sample is only leptons so smaller cross section. Used %10.61 from Doug's notes. Should be 10.71% from 2014 PDG.
#numevents=5000
numevents=50000
#0.0098903 is value calculated in Madgraph and is in the file unweighted_events.lhe
#This does no include elastic
cross_section_pb=3.11*0.0098903
#cross_section_pb=0.0098903
#linecolor=8
linecolor=429
if sample =="ExclusiveWW":
#This cross section is from Doug's notes 92.83+/-0.10 for Madgraph 5.2.4.2. But this sample is only leptons so smaller cross section. Used %10.61 from Doug's notes. Should be 10.71% from 2014 PDG.
#numevents=5000
numevents=50000
#0.0098903 is value calculated in Madgraph and is in the file unweighted_events.lhe
#cross_section_pb=4.1*0.0098903
cross_section_pb=0.0098903
linecolor=7
if sample =="ExclusiveWW-FPMC":
numevents=199132
cross_section_pb=0.036744*0.7
linecolor=7
if sample =="ExclusiveWW-a0w-5e-6":
numevents=199132
cross_section_pb=2.228*0.7
linecolor=8
if sample =="ExclusiveWW-a0w-5e-6-withXiCut":
numevents=200000
cross_section_pb=0.1352*0.7
linecolor=9
if sample =="ExclusiveWW-a0w-2e-5-withXiCut":
numevents=200000
cross_section_pb=1.610*0.7
linecolor=10
if sample =="ExclusiveWW-a0w-5e-5-withXiCut":
numevents=200000
cross_section_pb=9.859*0.7
linecolor=11
if sample =="WWTo2L2Nu_13TeV-powheg":
#numevents=1999000
#numevents=1236906
#numevents=1162658
#numevents=1206070
numevents=1999000.0
#From website above
cross_section_pb=12.178
linecolor=5
if sample =="TTJets_DiLept_TuneCUETP8M1_13TeV-madgraphMLM-pythia8":
numevents=6105137.
#numevents=5865278
#numevents=5997301
#numevents=6055403
#numevents=5967259.0
#From UCSB table (3*0.108)^2*815.96
cross_section_pb=85.66
linecolor=4
if sample =="DYJetsToLL_M-50_TuneCUETP8M1_13TeV-madgraphMLM-pythia8":
#Differs slightly from https://twiki.cern.ch/twiki/bin/viewauth/CMS/SummaryTable1G25ns#DY_Z. Where is 1.23 factor from that is in UCSB table?
#numevents=47943922
#numevents=49748967
numevents=49582723.0
#numevents=49620546.0
cross_section_pb=4895*1.23
linecolor=2
if sample =="DYJetsToLL_M-10to50_TuneCUETP8M1_13TeV-madgraphMLM-pythia8":
#Differs slightly from https://twiki.cern.ch/twiki/bin/viewauth/CMS/SummaryTable1G25ns#DY_Z. Where is 1.23 factor from?
#numevents=35293682
numevents=35167868
cross_section_pb=18610*1.23
linecolor=2
#From UCBS table, NNLO from Lesya's summary table
if sample=="WJetsToLNu_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8":
#numevents=24120319
#numevents=24083399.0
#numevents=23183722
numevents=2317615.0
cross_section_pb=61526.7
linecolor=6
if sample=="WW_DoubleScattering_13TeV-pythia8":
numevents=10000
cross_section_pb=1.64
linecolor=7
if sample=="WpWpJJ_EWK-QCD_TuneCUETP8M1_13TeV-madgraph-pythia8":
numevents=149681.
cross_section_pb=0.03711
linecolor=14
if sample=="ZZTo4L_13TeV_powheg_pythia8":
numevents=6669988.
cross_section_pb=1.256
linecolor=8
if sample=="WGToLNuG_TuneCUETP8M1_13TeV-madgraphMLM-pythia8":
numevents=6103817
cross_section_pb=405.271
linecolor=9
if sample=="ZGTo2LG_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8":
#This samples is for M>30
numevents=2307158.0
cross_section_pb=117.864
linecolor=11
if sample=="WZ_TuneCUETP8M1_13TeV-pythia8":
numevents=1000000.0
cross_section_pb=47.13
linecolor=12
if sample=="ZZ_TuneCUETP8M1_13TeV-pythia8":
numevents=990064.0
cross_section_pb=16.523
linecolor=13
print sample
print luminosity_fb
print cross_section_pb
print numevents
h.Scale((luminosity_fb*cross_section_pb*1000.)/numevents)
h.SetFillColor(linecolor)
h.SetLineColor(linecolor)
def legend_name(sample):
name="No legend name yet"
if sample=="WJetsToLNu_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8":name="W+Jets"
if sample=="TTJets_DiLept_TuneCUETP8M1_13TeV-madgraphMLM-pythia8":name="t#bar{t}"
if sample=="WWTo2L2Nu_13TeV-powheg":name="inclusive WW"
if sample=="DYJetsToLL_M-10to50_TuneCUETP8M1_13TeV-madgraphMLM-pythia8": name="Drell-Yan 10-50 GeV"
if sample=="DYJetsToLL_M-50_TuneCUETP8M1_13TeV-madgraphMLM-pythia8": name="Drell-Yan 50+ GeV"
if sample=="ExclusiveWW": name="Elastic SM Exclusive WW"
if sample=="ExclusiveWW-a0w-5e-6": name="Elastic SM Exclusive WW a0w = 5e-6"
if sample=="ExclusiveWW-a0w-5e-6-withXiCut": name="Elastic SM Exclusive WW a0w = 5e-6"
if sample=="ExclusiveWW-a0w-2e-6-withXiCut": name="Elastic SM Exclusive WW a0w = 2e-6"
if sample=="ExclusiveWW-a0w-5e-5-withXiCut": name="Elastic SM Exclusive WW a0w = 5e-5"
if sample=="ExclusiveWWNonElastic": name="Non-Elastic SM Exclusive WW"
if sample=="WW_DoubleScattering_13TeV-pythia8": name="WW_DoubleScattering"
if sample=="WpWpJJ_EWK-QCD_TuneCUETP8M1_13TeV-madgraph-pythia8": name="WpWpJJ_EWK-QCD"
if sample=="ZZTo4L_13TeV_powheg_pythia8": name="ZZTo4L"
if sample=="ZGTo2LG_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8": name="ZGTo2LG"
if sample=="WGToLNuG_TuneCUETP8M1_13TeV-madgraphMLM-pythia8": name="WGToLNuG"
if sample=="ZZ_TuneCUETP8M1_13TeV-pythia8": name="ZZ"
if sample=="WZ_TuneCUETP8M1_13TeV-pythia8": name="WZ"
return name
def passPPS(xi):
left=False
right=False
passesPPS=False
ii=0
for detId_rp in e.rp_tracks_detId:
#print detId_rp
if detId_rp == 2:
left=True
#if lessthan6: print "DetId 2, Xi: {0}".format(e.rp_tracks_xi[i])
xi["2"].append(e.rp_tracks_xi[ii])
if detId_rp == 3:
left=True
#if lessthan6: print "DetId 3, Xi: {0}".format(e.rp_tracks_xi[i])
xi["3"].append(e.rp_tracks_xi[ii])
if detId_rp == 102:
right=True
#xi_right.append(float(e.rp_tracks_xi))
#if lessthan6: print "DetId 102, Xi: {0}".format(e.rp_tracks_xi[i])
xi["102"].append(e.rp_tracks_xi[ii])
if detId_rp == 103:
right=True
#xi_right.append(float(e.rp_tracks_xi))
#if lessthan6: print "DetId 103, Xi: {0}".format(e.rp_tracks_xi[i])
xi["103"].append(e.rp_tracks_xi[ii])
ii=ii+1
if (left == True) and (right == True):
passesPPS=True
if fvertex_numtracks < 6 and ptemu > 30:
print "Run: {0}, Lumi: {1}, Event: {2}".format(run,e.lumiblock,event)
print "Num extra tracks: {0}, ptemu: {1}".format(fvertex_numtracks,ptemu)
print "Xi_2:",xi["2"],"Xi_3:",xi["3"],"Xi_102:",xi["102"],"Xi_103:",xi["103"]
print "Chi2_ndof: {0}".format(e.fvertex_chi2ndof)
print "Closest track: {0}".format(closest_track)
print "My vertex fit position x, y, z: {0},{1},{2}".format(e.fvertex_x,e.fvertex_y,e.fvertex_z)
print "Primary vertex fit position x, y, z: {0},{1},{2}".format(e.vertex_x,e.vertex_y,e.vertex_z)
print "Primary vertex extra tracks: {0}".format(e.vertex_ntracks-2)
if len(xi["2"]) > 1 or len(xi["3"]) > 1 or len(xi["102"]) > 1 or len(xi["103"]) > 1:
print "This event has multiple tracks in a single pot"
print "Xi_2:",xi["2"],"Xi_3:",xi["3"],"Xi_102:",xi["102"],"Xi_103:",xi["103"]
passesPPS=False
return passesPPS