forked from h2gglobe/h2gglobe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MassResolution.cc
323 lines (249 loc) · 12 KB
/
MassResolution.cc
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
#include "MassResolution.h"
//----------------------------------------------------------//
// Project: MassResolution
// Author: Matt Kenzie ([email protected])
// Modified: 25/08/2011
// Admins: Matth Kenzie ([email protected])
//---------------------------------------------------------//
/*
See MassResolution.h for instructions
*/
MassResolution::MassResolution(){}
void MassResolution::Setup(LoopAll &l, PhotonReducedInfo *leadInfo, PhotonReducedInfo *subleadInfo,int vtx_index,EnergySmearer::energySmearingParameters eSmearPars, int nR9Categories, int nEtaCategories, double beamspotSigma_in, bool usethisvtx) {
beamspotSigma= beamspotSigma_in;
leadPhoton= leadInfo;
subleadPhoton= subleadInfo;
vertex = (TVector3*)l.vtx_std_xyz->At(vtx_index);
vtx_dxdydz = (TVector3*)l.vtx_std_dxdydz->At(vtx_index);
//lead_sc_pos = leadPhoton->caloPosition();
//sublead_sc_pos = subleadPhoton->caloPosition();
lead_Eres = leadPhoton->corrEnergyErr();
sublead_Eres = subleadPhoton->corrEnergyErr();
lead_r9 = leadPhoton->r9();
sublead_r9 = subleadPhoton->r9();
lead_iDet = leadPhoton->iDet();
sublead_iDet = subleadPhoton->iDet();
TLorentzVector lead_p4=leadPhoton->p4(vertex->X(),vertex->Y(),vertex->Z());
TLorentzVector sublead_p4=subleadPhoton->p4(vertex->X(),vertex->Y(),vertex->Z());
higgsMass=(lead_p4+sublead_p4).M();
_eSmearPars=eSmearPars;
/* std::cout << "Inside the mmassreso calc -- E1 - " <<leadPhoton->energy() <<std::endl;
std::cout << "Inside the mmassreso calc -- E2 - " <<subleadPhoton->energy() <<std::endl;
std::cout << "Inside the mmassreso calc -- r91 - " <<lead_r9 <<std::endl;
std::cout << "Inside the mmassreso calc -- r92 - " <<sublead_r9 <<std::endl;
std::cout << "Inside the mmassreso calc -- mass - " <<higgsMass <<std::endl;
std::cout << "Inside the mmassreso calc -- calopos Eta1 - " <<leadPhoton->caloPosition().Eta() <<std::endl;
std::cout << "Inside the mmassreso calc -- calopos Eta2 - " <<subleadPhoton->caloPosition().Eta() <<std::endl;
*/
}
void MassResolution::Setup(LoopAll &l, PhotonReducedInfo *leadInfo, PhotonReducedInfo *subleadInfo,int diphoton_index,EnergySmearer::energySmearingParameters eSmearPars, int nR9Categories, int nEtaCategories, double beamspotSigma_in)
{
Setup(l, leadInfo, subleadInfo, l.dipho_vtxind[diphoton_index], eSmearPars, nR9Categories, nEtaCategories, beamspotSigma_in, true);
}
// return the mass resolution given correct vertex
double MassResolution::massResolutionCorrVtx(){
TLorentzVector lead_p4=leadPhoton->p4(vertex->X(),vertex->Y(),vertex->Z());
TLorentzVector sublead_p4=subleadPhoton->p4(vertex->X(),vertex->Y(),vertex->Z());
double lead_E = lead_p4.E();
double sublead_E = sublead_p4.E();
double alpha = lead_p4.Angle(sublead_p4.Vect());
double lead_sig = leadPhotonResolution();
double sublead_sig = subleadPhotonResolution();
double alpha_sig = angleResolutionCorrVtx();
return 0.5*higgsMass*TMath::Sqrt(((lead_sig*lead_sig)/(lead_E*lead_E))+((sublead_sig*sublead_sig)/(sublead_E*sublead_E))+((alpha_sig*alpha_sig)*(TMath::Sin(alpha)/(1.-TMath::Cos(alpha)))*(TMath::Sin(alpha)/(1.-TMath::Cos(alpha)))));
}
double MassResolution::massResolutionCorrVtxNoSmear(){
TLorentzVector lead_p4=leadPhoton->p4(vertex->X(),vertex->Y(),vertex->Z());
TLorentzVector sublead_p4=subleadPhoton->p4(vertex->X(),vertex->Y(),vertex->Z());
double lead_E = lead_p4.E();
double sublead_E = sublead_p4.E();
double alpha = lead_p4.Angle(sublead_p4.Vect());
double lead_sig = leadPhotonResolutionNoSmear();
double sublead_sig = subleadPhotonResolutionNoSmear();
double alpha_sig = angleResolutionCorrVtx();
return 0.5*higgsMass*TMath::Sqrt(((lead_sig*lead_sig)/(lead_E*lead_E))+((sublead_sig*sublead_sig)/(sublead_E*sublead_E))+((alpha_sig*alpha_sig)*(TMath::Sin(alpha)/(1.-TMath::Cos(alpha)))*(TMath::Sin(alpha)/(1.-TMath::Cos(alpha)))));
}
// return the mass resolution wrong vertex
double MassResolution::massResolutionWrongVtx(){
// TLorentzVector lead_p4=leadPhoton->p4(vertex->X(),vertex->Y(),vertex->Z());
// TLorentzVector sublead_p4=subleadPhoton->p4(vertex->X(),vertex->Y(),vertex->Z());
// double lead_E = lead_p4.E();
// double sublead_E = sublead_p4.E();
// double alpha = lead_p4.Angle(sublead_p4.Vect());
// double lead_sig = leadPhotonResolution();
// double sublead_sig = subleadPhotonResolution();
double alpha_sig = higgsMass*0.5*angleResolutionWrongVtx();
double sigmaM = massResolutionEonly();
// return 0.5*higgsMass*TMath::Sqrt(((lead_sig*lead_sig)/(lead_E*lead_E))+((sublead_sig*sublead_sig)/(sublead_E*sublead_E))+((alpha_sig*alpha_sig)));
return TMath::Sqrt((sigmaM*sigmaM)+(alpha_sig*alpha_sig));
}
double MassResolution::massResolutionWrongVtxNoSmear(){
double alpha_sig = higgsMass*0.5*angleResolutionWrongVtx();
double sigmaM = massResolutionEonlyNoSmear();
// return 0.5*higgsMass*TMath::Sqrt(((lead_sig*lead_sig)/(lead_E*lead_E))+((sublead_sig*sublead_sig)/(sublead_E*sublead_E))+((alpha_sig*alpha_sig)));
return TMath::Sqrt((sigmaM*sigmaM)+(alpha_sig*alpha_sig));
}
// return energy contribution to mass resolution only
double MassResolution::massResolutionEonly() {
double lead_E = leadPhoton->energy();
double sublead_E = subleadPhoton->energy();
double lead_sig = leadPhotonResolution();
double sublead_sig = subleadPhotonResolution();
return 0.5*higgsMass*TMath::Sqrt((lead_sig*lead_sig)/(lead_E*lead_E)+(sublead_sig*sublead_sig)/(sublead_E*sublead_E));
}
double MassResolution::massResolutionEonlyNoSmear(){
double lead_E = leadPhoton->energy();
double sublead_E = subleadPhoton->energy();
double lead_sig = leadPhotonResolutionNoSmear();
double sublead_sig = subleadPhotonResolutionNoSmear();
return 0.5*higgsMass*TMath::Sqrt((lead_sig*lead_sig)/(lead_E*lead_E)+(sublead_sig*sublead_sig)/(sublead_E*sublead_E));
}
double MassResolution::massResolutionAonly(){
double aRes = angleResolution();
return 0.5*higgsMass*aRes;
}
// return angle resolution given the vertex choice is correct
double MassResolution::angleResolutionCorrVtx() {
return propagateDz(dzResolutionCorrVtx());
}
// return angle resolution given the vertex choice is wrong
double MassResolution::angleResolutionWrongVtx() {
return propagateDz(dzResolutionWrongVtx());
}
// return angle resolution given a convolution of correct/wrong vertex as func of higgsPt
double MassResolution::angleResolution() {
return propagateDz(dzResolution());
}
// return lead photon resolution without smearing
double MassResolution::leadPhotonResolutionNoSmear() {
return lead_Eres;
}
// return sublead photon resolution without smearing
double MassResolution::subleadPhotonResolutionNoSmear() {
return sublead_Eres;
}
// return lead photon resolution
double MassResolution::leadPhotonResolution() {
TLorentzVector lead_p4=leadPhoton->p4(vertex->X(),vertex->Y(),vertex->Z());
bool sphericalLeadPhoton_=leadPhoton->isSphericalPhoton();
// std::cout << " MassResolution -- Lead special ? " << sphericalLeadPhoton_ <<std::endl;
return getPhotonResolution(lead_p4.E(),lead_Eres,lead_r9, leadPhoton->caloPosition().Eta(),lead_iDet,sphericalLeadPhoton_);
}
// return sublead photon resolution
double MassResolution::subleadPhotonResolution() {
TLorentzVector sublead_p4=subleadPhoton->p4(vertex->X(),vertex->Y(),vertex->Z());
bool sphericalSubleadPhoton_=subleadPhoton->isSphericalPhoton();
// std::cout << " MassResolution -- SubLead special ? " << sphericalSubleadPhoton_ <<std::endl;
return getPhotonResolution(sublead_p4.E(),sublead_Eres,sublead_r9,subleadPhoton->caloPosition().Eta(),sublead_iDet,sphericalSubleadPhoton_);
}
// Actually compute resolution given a photon
double MassResolution::getPhotonResolution(double photonEnergy, double photonResolution, double r9, double scEta, bool iDet, bool ispherical) {
// Get the photon-category sigma
std::string myCategory="";
if (_eSmearPars.categoryType=="Automagic")
{
EnergySmearer::energySmearingParameters::phoCatVectorConstIt vit = find(_eSmearPars.photon_categories.begin(), _eSmearPars.photon_categories.end(),
std::make_pair(ispherical, std::make_pair( fabs((float)scEta), (float)r9 ) ) );
if( vit == _eSmearPars.photon_categories.end() ) {
//cout << "PhotonCheck " << r9 << " " << phoCat << " " << scEta << " " << iDet << " " << endl;
std::cerr << "Could not find energy scale correction for this photon " << (float)scEta << " " << (float)r9 << std::endl;
assert( 0 );
}
myCategory = vit->name;
}
else if (_eSmearPars.categoryType=="2CatR9_EBEE")
{
if (iDet)
myCategory+="EB";
else
myCategory+="EE";
if (r9>=0.94)
myCategory+="HighR9";
else
myCategory+="LowR9";
}
else if (_eSmearPars.categoryType=="2CatR9_EBEBm4EE")
{
if (iDet && fabs(scEta) < 1.)
myCategory+="EB";
else if (iDet && fabs(scEta) > 1.)
myCategory+="EBm4";
else
myCategory+="EE";
if (r9>=0.94)
myCategory+="HighR9";
else
myCategory+="LowR9";
}
else if (_eSmearPars.categoryType=="EBEE")
{
if (iDet)
myCategory+="EB";
else
myCategory+="EE";
}
else
{
std::cout << "Unknown categorization. No category name is returned" << std::endl;
}
/// Moved to config file PM 4/4/12
/// double categoryResolution = ispherical ? 0.0067*photonEnergy : _eSmearPars.smearing_sigma[myCategory]*photonEnergy;
double categoryResolution = _eSmearPars.smearing_sigma[myCategory]*photonEnergy;
return TMath::Sqrt(categoryResolution*categoryResolution + photonResolution*photonResolution);
}
//return dz resolution given correct vertex (used 10mm)
double MassResolution::dzResolutionCorrVtx() {
return 0.1;
}
//return dz resolution given wrong vertex (using sqrt(2)*5.8cm)
double MassResolution::dzResolutionWrongVtx() {
return TMath::Sqrt(2.)*beamspotSigma;
}
//return dz resolution from dz wrong and dz right (stored in TGraph as func of higgsPt)
double MassResolution::dzResolution() {
return dz;
}
// propagate error on z to error on angle
double MassResolution::propagateDz(double dz){
// TLorentzVector lead_p4=leadPhoton->p4(vertex->X(),vertex->Y(),vertex->Z());
// TLorentzVector sublead_p4=subleadPhoton->p4(vertex->X(),vertex->Y(),vertex->Z());
// double alpha = //lead_p4.Angle(sublead_p4.Vect());
// if (alpha!= sublead_p4.Angle(lead_p4.Vect())) std::cout << "Error: Angle between photons not consistent" << std::endl;
TVector3 LeadPosition = (leadPhoton->caloPosition()) - *vertex;
TVector3 SubLeadPosition = (subleadPhoton->caloPosition()) - *vertex;
/*
double x1 = leadPhoton->caloPosition().X();
double y1 = leadPhoton->caloPosition().Y();
double z1 = leadPhoton->caloPosition().Z();
double x2 = subleadPhoton->caloPosition().X();
double y2 = subleadPhoton->caloPosition().Y();
double z2 = subleadPhoton->caloPosition().Z();
*/
double x1 = leadPhoton->caloPosition().X()-vertex->X();
double y1 = leadPhoton->caloPosition().Y()-vertex->Y();
double z1 = leadPhoton->caloPosition().Z()-vertex->Z();
double x2 = subleadPhoton->caloPosition().X()-vertex->X();
double y2 = subleadPhoton->caloPosition().Y()-vertex->Y();
double z2 = subleadPhoton->caloPosition().Z()-vertex->Z();
double r1 = TMath::Sqrt(x1*x1+y1*y1+z1*z1);
double r2 = TMath::Sqrt(x2*x2+y2*y2+z2*z2);
double cos_term = TMath::Cos(LeadPosition.Phi()-SubLeadPosition.Phi());
double sech1 = SecH(LeadPosition.Eta());
double sech2 = SecH(SubLeadPosition.Eta());
double tanh1 = TanH(LeadPosition.Eta());
double tanh2 = TanH(SubLeadPosition.Eta());
double numerator1 = sech1*(sech1*tanh2-tanh1*sech2*cos_term);
double numerator2 = sech2*(sech2*tanh1-tanh2*sech1*cos_term);
double denominator = 1. - tanh1*tanh2 - sech1*sech2*cos_term;
double ResTerm = (-1.*dz/denominator)*(numerator1/r1 + numerator2/r2);
//double angleResolution = ResTerm*(1.-TMath::Cos(alpha))/TMath::Sin(alpha);
double angleResolution = ResTerm;
return angleResolution;
}
// utility functions
double MassResolution::SecH(double x){
return 1.0/TMath::CosH(x);
}
double MassResolution::TanH(double x){
return TMath::TanH(x);
}