ATLAS Offline Software
Loading...
Searching...
No Matches
MissingMassProb.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Class handling the probability calculation of the MissingMassCalculator
6// author Michael Huebner <michael.huebner@no.spam.cern.ch>
7
8// Local include(s):
11#include <cmath>
12
14
15namespace {
16 constexpr double GEV = 1000.0;
17}
18
19using namespace DiTauMassTools;
20using ROOT::Math::PtEtaPhiMVector;
21using ROOT::Math::VectorUtil::Phi_mpi_pi;
22
23// The wrapper functions make use of the ignore template defined in HelperFunctions.h.
24// This is to avoid warnings during compilation.
25// All wrapper functions need to have the same structure such that they can be
26// handled within the probList vectors and the "user" from the Calculator only
27// has to call Prob->apply() to have a common handling of all probability calculations.
28
29double MissingMassProb::MetProbabilityWrapper( MissingMassProb* prob, MissingMassInput& preparedInput, const int & tau_type1, const int & tau_type2, const PtEtaPhiMVector & tauvec1, const PtEtaPhiMVector & tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector & nuvec2 ){
30 ignore(tau_type1);
31 ignore(tau_type2);
32 ignore(tauvec1);
33 ignore(tauvec2);
34 ignore(nuvec1);
35 ignore(nuvec2);
36 return prob->MetProbability(preparedInput, 1.,1.,1.,1.);
37}
38
39double MissingMassProb::mEtAndTauProbabilityWrapper( MissingMassProb* prob, MissingMassInput& preparedInput, const int & tau_type1, const int & tau_type2, const PtEtaPhiMVector & tauvec1, const PtEtaPhiMVector & tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector & nuvec2 ){
40 ignore(tau_type1);
41 ignore(tau_type2);
42 ignore(tauvec1);
43 ignore(tauvec2);
44 ignore(nuvec1);
45 ignore(nuvec2);
46 return prob->mEtAndTauProbability(preparedInput);
47}
48
49double MissingMassProb::dTheta3d_probabilityFastWrapper( MissingMassProb* prob, MissingMassInput& preparedInput, const int & tau_type1, const int & tau_type2, const PtEtaPhiMVector & tauvec1, const PtEtaPhiMVector & tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector & nuvec2 ){
50 double Prob = 1.;
51 if (tau_type1>=0) {
52 PtEtaPhiMVector totalTau1;
53 totalTau1+=tauvec1;
54 totalTau1+=nuvec1;
55 const double tau1_tmpp = totalTau1.P();
56 const double angle1 = Angle(nuvec1,tauvec1);
57 Prob*=prob->dTheta3d_probabilityFast(preparedInput, tau_type1, angle1, tau1_tmpp);
58 }
59 if (tau_type2>=0) {
60 PtEtaPhiMVector totalTau2;
61 totalTau2+=tauvec2;
62 totalTau2+=nuvec2;
63 const double tau2_tmpp = totalTau2.P();
64 const double angle2 = Angle(nuvec2,tauvec2);
65 Prob*=prob->dTheta3d_probabilityFast(preparedInput, tau_type2, angle2, tau2_tmpp);
66 }
67 return Prob;
68}
69
70double MissingMassProb::TauProbabilityWrapper( MissingMassProb* prob, MissingMassInput& preparedInput, const int & tau_type1, const int & tau_type2, const PtEtaPhiMVector & tauvec1, const PtEtaPhiMVector & tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector & nuvec2 ){
71 if( prob->GetUseHT() || (preparedInput.m_tauTypes==TauTypes::hh) ) {
72 return prob->TauProbability(preparedInput, tau_type1, tauvec1, nuvec1, tau_type2, tauvec2, nuvec2, preparedInput.m_MetVec.R()); // customized prob for Njet25=0
73 } else {
74 return prob->TauProbability(preparedInput, tau_type1, tauvec1, nuvec1, tau_type2, tauvec2, nuvec2);
75 }
76}
77
78double MissingMassProb::MnuProbabilityWrapper( MissingMassProb* prob, MissingMassInput& preparedInput, const int & tau_type1, const int & tau_type2, const PtEtaPhiMVector & tauvec1, const PtEtaPhiMVector & tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector & nuvec2 ){
79 ignore(tauvec1);
80 ignore(tauvec2);
81 if(prob->GetUseMnuProbability()==1){
82 if(preparedInput.m_tauTypes==TauTypes::ll) return prob->MnuProbability(preparedInput, nuvec1.M())*prob->MnuProbability(preparedInput, nuvec2.M()); // lep-lep
83 else if(tau_type1==8 && (tau_type2>=0 && tau_type2<=5)) return prob->MnuProbability(preparedInput, nuvec1.M()); // lep-had: tau1==lepton
84 else if((tau_type1>=0 && tau_type1<=5) && tau_type2==8) return prob->MnuProbability(preparedInput, nuvec2.M()); // lep-had: tau2==lepton
85 else {
86 Warning("DiTauMassTools", "something went really wrong in MNuProb...");
87 return 1.;
88 }
89 } else {
90 return 1.;
91 }
92}
93
94double MissingMassProb::dTheta3d_probabilityNewWrapper( MissingMassProb* prob, MissingMassInput& preparedInput, const int & tau_type1, const int & tau_type2, const PtEtaPhiMVector & tauvec1, const PtEtaPhiMVector & tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector & nuvec2 ){
95 ignore(preparedInput);
96 double Prob = 1.;
97 if (tau_type1>=0) {
98 PtEtaPhiMVector totalTau1;
99 totalTau1+=tauvec1;
100 totalTau1+=nuvec1;
101 const double angle1 = Angle(nuvec1,tauvec1);
102 double prob_tmp = 1e-10;
103 if (angle1!=0.) prob_tmp=prob->GetFormulaAngle1()->Eval(angle1);
104 if (prob_tmp<=0.) prob_tmp=1e-10;
105 Prob*=prob_tmp;
106 }
107 if (tau_type2>=0) {
108 PtEtaPhiMVector totalTau2;
109 totalTau2+=tauvec2;
110 totalTau2+=nuvec2;
111 const double angle2 = Angle(nuvec2,tauvec2);
112 double prob_tmp = 1e-10;
113 if (angle2!=0.) prob_tmp=prob->GetFormulaAngle2()->Eval(angle2);
114 if (prob_tmp<=0.) prob_tmp=1e-10;
115 Prob*=prob_tmp;
116 }
117 // very rare cases where parametrisation flips
118 if (std::isnan(Prob)) Prob = 0.;
119 return Prob;
120}
121
122double MissingMassProb::TauProbabilityNewWrapper( MissingMassProb* prob, MissingMassInput& preparedInput, const int & tau_type1, const int & tau_type2, const PtEtaPhiMVector & tauvec1, const PtEtaPhiMVector & tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector & nuvec2 ){
123 ignore(preparedInput);
124 ignore(tau_type1);
125 ignore(tau_type2);
126 double Prob = 1.;
127 double R1 = nuvec1.P()/tauvec1.P();
128 double R2 = nuvec2.P()/tauvec2.P();
129 Prob*=prob->GetFormulaRatio1()->Eval(R1);
130 Prob*=prob->GetFormulaRatio2()->Eval(R2);
131 // not observed, just a protection
132 if (std::isnan(Prob)) Prob = 0.;
133 return Prob;
134}
135
136double MissingMassProb::MnuProbabilityNewWrapper( MissingMassProb* prob, MissingMassInput& preparedInput, const int & tau_type1, const int & tau_type2, const PtEtaPhiMVector & tauvec1, const PtEtaPhiMVector & tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector & nuvec2 ){
137 ignore(tauvec1);
138 ignore(tauvec2);
139 double Prob = 1.;
140 if(prob->GetUseMnuProbability()==1){
141 if(preparedInput.m_tauTypes==TauTypes::ll) Prob*=(prob->GetFormulaNuMass()->Eval(nuvec1.M())*prob->GetFormulaNuMass()->Eval(nuvec2.M()));
142 else if(tau_type1==8 && (tau_type2>=0 && tau_type2<=5)) Prob*=prob->GetFormulaNuMass()->Eval(nuvec1.M());
143 else if((tau_type1>=0 && tau_type1<=5) && tau_type2==8) Prob*=prob->GetFormulaNuMass()->Eval(nuvec2.M());
144 else {
145 Warning("DiTauMassTools", "something went really wrong in MNuProb...");
146 }
147 }
148 // not observed, just a protection
149 if (std::isnan(Prob)) Prob = 0.;
150 return Prob;
151}
152
154 if (m_paramVectorNuMass.size() > 0){
155 for(int i=0; i<m_formulaNuMass->GetNpar(); i++){
156 m_formulaNuMass->SetParameter(i, m_paramVectorNuMass[0]->GetParameter(i));
157 }
158 }
159}
160
161void MissingMassProb::setParamAngle(const PtEtaPhiMVector& tauvec, int tau, int tautype) {
162 double Pt_tau = tauvec.Pt();
163 int type = tautype;
164 if (tautype > 4 && tautype < 8) type = 4;
165 if (tautype <= 5){
166 if (m_paramVectorAngle.size() > 0){
167 for(int i=0; i<=3; i++){
168 double par = m_paramVectorAngle[i+(type)*4]->Eval(Pt_tau);
169 if (tau==1){
170 m_formulaAngle1->SetParameter(i, par);
171 } else {
172 m_formulaAngle2->SetParameter(i, par);
173 }
174 }
175 }
176 } else {
177 if (m_paramVectorAngleLep.size() > 0){
178 for(int i=0; i<=3; i++){
179 double par = m_paramVectorAngleLep[i]->Eval(Pt_tau);
180 if (tau==1){
181 m_formulaAngle1->SetParameter(i, par);
182 } else {
183 m_formulaAngle2->SetParameter(i, par);
184 }
185 }
186 }
187 }
188}
189
190void MissingMassProb::setParamRatio(int tau, int tautype) {
191 int type = tautype;
192 if(tautype > 4 && tautype < 8) type = 4;
193 if (tautype <= 5){
194 if(tau==1){
196 for(int i=0; i<m_formulaRatio1->GetNpar(); i++){
197 m_formulaRatio1->SetParameter(i, m_paramVectorRatio[5*(tau-1)+type]->GetParameter(i));
198 }
199 } else {
201 for(int i=0; i<m_formulaRatio2->GetNpar(); i++){
202 m_formulaRatio2->SetParameter(i, m_paramVectorRatio[5*(tau-1)+type]->GetParameter(i));
203 }
204 }
205 } else {
206 if(tau==1){
208 for(int i=0; i<m_formulaRatio1->GetNpar(); i++){
209 m_formulaRatio1->SetParameter(i, m_paramVectorRatioLep[0]->GetParameter(i));
210 }
211 } else {
213 for(int i=0; i<m_formulaRatio2->GetNpar(); i++){
214 m_formulaRatio2->SetParameter(i, m_paramVectorRatioLep[0]->GetParameter(i));
215 }
216 }
217 }
218}
219
220// Default Constructor
221MissingMassProb::MissingMassProb(MMCCalibrationSet::e aset, const std::string& paramFilePath) {
222 m_mmcCalibrationSet = aset;
223 m_allowUseHT = false;
224 m_UseHT = false;
225
226 m_fParams = NULL;
227 if (!paramFilePath.empty()){
228 std::string total_path = "DiTauMassTools/"+paramFilePath;
229 m_fParams = TFile::Open( (const char*) PathResolverFindCalibFile(total_path).c_str() ,"READ");
230 }
232 m_probListConstant.push_back( std::bind(&mEtAndTauProbabilityWrapper, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7) );
233 m_probListOneTau.push_back( std::bind(&dTheta3d_probabilityNewWrapper, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7) );
234 m_probListTwoTau.push_back( std::bind(&TauProbabilityNewWrapper, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7) );
235 m_probListTwoTau.push_back( std::bind(&MnuProbabilityNewWrapper, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7) );
236 if (m_fParams){
238 }
239 }
240 else {
241 m_probListConstant.push_back( std::bind(&mEtAndTauProbabilityWrapper, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7) );
242 m_probListOneTau.push_back( std::bind(&dTheta3d_probabilityFastWrapper, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7) );
243 m_probListTwoTau.push_back( std::bind(&TauProbabilityWrapper, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7) );
244 m_probListTwoTau.push_back( std::bind(&MnuProbabilityWrapper, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7) );
245 }
246
247 if (m_fParams) if (m_fParams->IsOpen()) m_fParams->Close();
248
250 // [tau_type][parLG][par]
251 // leptonic tau
252 //-par[0]
253 s_fit_param[0][0][0][0]=-9.82013E-1;
254 s_fit_param[0][0][0][1]=9.09874E-1;
255 s_fit_param[0][0][0][2]=0.0;
256 s_fit_param[0][0][0][3]=0.0;
257 //-par[1]
258 s_fit_param[0][0][1][0]=9.96303E1;
259 s_fit_param[0][0][1][1]=1.68873E1;
260 s_fit_param[0][0][1][2]=3.23798E-2;
261 s_fit_param[0][0][1][3]=0.0;
262 //-par[2]
263 s_fit_param[0][0][2][0]=0.0;
264 s_fit_param[0][0][2][1]=0.0;
265 s_fit_param[0][0][2][2]=0.0;
266 s_fit_param[0][0][2][3]=0.3; // fit value is 2.8898E-1, I use 0.3
267 //-par[3]
268 s_fit_param[0][0][3][0]=9.70055E1;
269 s_fit_param[0][0][3][1]=6.46175E1;
270 s_fit_param[0][0][3][2]=3.20679E-2;
271 s_fit_param[0][0][3][3]=0.0;
272 //-par[4]
273 s_fit_param[0][0][4][0]=1.56865;
274 s_fit_param[0][0][4][1]=2.28336E-1;
275 s_fit_param[0][0][4][2]=1.09396E-1;
276 s_fit_param[0][0][4][3]=1.99975E-3;
277 //-par[5]
278 s_fit_param[0][0][5][0]=0.0;
279 s_fit_param[0][0][5][1]=0.0;
280 s_fit_param[0][0][5][2]=0.0;
281 s_fit_param[0][0][5][3]=0.66;
282 //-----------------------------------------------------------------
283 // 1-prong hadronic tau
284 //-par[0]
285 s_fit_param[0][1][0][0]=-2.42674;
286 s_fit_param[0][1][0][1]=7.69124E-1;
287 s_fit_param[0][1][0][2]=0.0;
288 s_fit_param[0][1][0][3]=0.0;
289 //-par[1]
290 s_fit_param[0][1][1][0]=9.52747E1;
291 s_fit_param[0][1][1][1]=1.26319E1;
292 s_fit_param[0][1][1][2]=3.09643E-2;
293 s_fit_param[0][1][1][3]=0.0;
294 //-par[2]
295 s_fit_param[0][1][2][0]=1.71302E1;
296 s_fit_param[0][1][2][1]=3.00455E1;
297 s_fit_param[0][1][2][2]=7.49445E-2;
298 s_fit_param[0][1][2][3]=0.0;
299 //-par[3]
300 s_fit_param[0][1][3][0]=1.06137E2;
301 s_fit_param[0][1][3][1]=6.01548E1;
302 s_fit_param[0][1][3][2]=3.50867E-2;
303 s_fit_param[0][1][3][3]=0.0;
304 //-par[4]
305 s_fit_param[0][1][4][0]=4.26079E-1;
306 s_fit_param[0][1][4][1]=1.76978E-1;
307 s_fit_param[0][1][4][2]=1.43419;
308 s_fit_param[0][1][4][3]=0.0;
309 //-par[5]
310 s_fit_param[0][1][5][0]=0.0;
311 s_fit_param[0][1][5][1]=0.0;
312 s_fit_param[0][1][5][2]=0.0;
313 s_fit_param[0][1][5][3]=0.4;
314 //-----------------------------------------------------------------
315 // 3-prong hadronic tau
316 //-par[0]
317 s_fit_param[0][2][0][0]=-2.43533;
318 s_fit_param[0][2][0][1]=6.12947E-1;
319 s_fit_param[0][2][0][2]=0.0;
320 s_fit_param[0][2][0][3]=0.0;
321 //-par[1]
322 s_fit_param[0][2][1][0]=9.54202;
323 s_fit_param[0][2][1][1]=2.80011E-1;
324 s_fit_param[0][2][1][2]=2.49782E-1;
325 s_fit_param[0][2][1][3]=0.0;
326 //-par[2]
327 s_fit_param[0][2][2][0]=1.61325E1;
328 s_fit_param[0][2][2][1]=1.74892E1;
329 s_fit_param[0][2][2][2]=7.05797E-2;
330 s_fit_param[0][2][2][3]=0.0;
331 //-par[3]
332 s_fit_param[0][2][3][0]=1.17093E2;
333 s_fit_param[0][2][3][1]=4.70000E1;
334 s_fit_param[0][2][3][2]=3.87085E-2;
335 s_fit_param[0][2][3][3]=0.0;
336 //-par[4]
337 s_fit_param[0][2][4][0]=4.16557E-1;
338 s_fit_param[0][2][4][1]=1.58902E-1;
339 s_fit_param[0][2][4][2]=1.53516;
340 s_fit_param[0][2][4][3]=0.0;
341 //-par[5]
342 s_fit_param[0][2][5][0]=0.0;
343 s_fit_param[0][2][5][1]=0.0;
344 s_fit_param[0][2][5][2]=0.0;
345 s_fit_param[0][2][5][3]=0.95;
346
347
349 // [tau_type][parLG][par]
350 // leptonic tau
351 //-par[0]
352 s_fit_param[1][0][0][0]=-9.82013E-1;
353 s_fit_param[1][0][0][1]=9.09874E-1;
354 s_fit_param[1][0][0][2]=0.0;
355 s_fit_param[1][0][0][3]=0.0;
356 s_fit_param[1][0][0][4]=0.0;
357 //-par[1]
358 s_fit_param[1][0][1][0]=9.96303E1;
359 s_fit_param[1][0][1][1]=1.68873E1;
360 s_fit_param[1][0][1][2]=3.23798E-2;
361 s_fit_param[1][0][1][3]=0.0;
362 s_fit_param[1][0][1][4]=0.0;
363 //-par[2]
364 s_fit_param[1][0][2][0]=0.0;
365 s_fit_param[1][0][2][1]=0.0;
366 s_fit_param[1][0][2][2]=0.0;
367 s_fit_param[1][0][2][3]=0.3; // fit value is 2.8898E-1, I use 0.3
368 s_fit_param[1][0][2][4]=0.0;
369 //-par[3]
370 s_fit_param[1][0][3][0]=9.70055E1;
371 s_fit_param[1][0][3][1]=6.46175E1;
372 s_fit_param[1][0][3][2]=3.20679E-2;
373 s_fit_param[1][0][3][3]=0.0;
374 s_fit_param[1][0][3][4]=0.0;
375 //-par[4]
376 s_fit_param[1][0][4][0]=1.56865;
377 s_fit_param[1][0][4][1]=2.28336E-1;
378 s_fit_param[1][0][4][2]=1.09396E-1;
379 s_fit_param[1][0][4][3]=1.99975E-3;
380 s_fit_param[1][0][4][4]=0.0;
381 //-par[5]
382 s_fit_param[1][0][5][0]=0.0;
383 s_fit_param[1][0][5][1]=0.0;
384 s_fit_param[1][0][5][2]=0.0;
385 s_fit_param[1][0][5][3]=0.66;
386 s_fit_param[1][0][5][4]=0.0;
387 //-----------------------------------------------------------------
388 //-----------------------
389 // Only hadronic tau's were re-parametrized in MC12. The parameterization now
390 // goes to P(tau)=1 TeV.
391 //-----------------------------------------------------------------
392 // 1-prong hadronic tau
393 //---par[0]
394 s_fit_param[1][1][0][0]=0.7568;
395 s_fit_param[1][1][0][1]=-0.0001469;
396 s_fit_param[1][1][0][2]=5.413E-7;
397 s_fit_param[1][1][0][3]=-6.754E-10;
398 s_fit_param[1][1][0][4]=2.269E-13;
399 //---par[1]
400 s_fit_param[1][1][1][0]=-0.0288208;
401 s_fit_param[1][1][1][1]=0.134174;
402 s_fit_param[1][1][1][2]=-142.588;
403 s_fit_param[1][1][1][3]=-0.00035606;
404 s_fit_param[1][1][1][4]=-6.94567E-20;
405 //---par[2]
406 s_fit_param[1][1][2][0]=-0.00468927;
407 s_fit_param[1][1][2][1]=0.0378737;
408 s_fit_param[1][1][2][2]=-260.284;
409 s_fit_param[1][1][2][3]=0.00241158;
410 s_fit_param[1][1][2][4]=-6.01766E-7;
411 //---par[3]
412 s_fit_param[1][1][3][0]=-0.170424;
413 s_fit_param[1][1][3][1]=0.135764;
414 s_fit_param[1][1][3][2]=-50.2361;
415 s_fit_param[1][1][3][3]=0.00735544;
416 s_fit_param[1][1][3][4]=-7.34073E-6;
417 //---par[4]
418 s_fit_param[1][1][4][0]=-0.0081364;
419 s_fit_param[1][1][4][1]=0.0391428;
420 s_fit_param[1][1][4][2]=-141.936;
421 s_fit_param[1][1][4][3]=0.0035034;
422 s_fit_param[1][1][4][4]=-1.21956E-6;
423 //-par[5]
424 s_fit_param[1][1][5][0]=0.0;
425 s_fit_param[1][1][5][1]=0.0;
426 s_fit_param[1][1][5][2]=0.0;
427 s_fit_param[1][1][5][3]=0.624*0.00125; // multiplied by a bin size
428 s_fit_param[1][1][5][4]=0.0;
429 //-----------------------------------------------------------------
430 // 3-prong hadronic tau
431 //---par[0]
432 s_fit_param[1][2][0][0]=0.7562;
433 s_fit_param[1][2][0][1]=-1.168E-5;
434 s_fit_param[1][2][0][2]=0.0;
435 s_fit_param[1][2][0][3]=0.0;
436 s_fit_param[1][2][0][4]=0.0;
437 //---par[1]
438 s_fit_param[1][2][1][0]=-0.0420458;
439 s_fit_param[1][2][1][1]=0.15917;
440 s_fit_param[1][2][1][2]=-80.3259;
441 s_fit_param[1][2][1][3]=0.000125729;
442 s_fit_param[1][2][1][4]=-2.43945E-18;
443 //---par[2]
444 s_fit_param[1][2][2][0]=-0.0216898;
445 s_fit_param[1][2][2][1]=0.0243497;
446 s_fit_param[1][2][2][2]=-63.8273;
447 s_fit_param[1][2][2][3]=0.0148339;
448 s_fit_param[1][2][2][4]=-4.45351E-6;
449 //---par[3]
450 s_fit_param[1][2][3][0]=-0.0879411;
451 s_fit_param[1][2][3][1]=0.110092;
452 s_fit_param[1][2][3][2]=-75.4901;
453 s_fit_param[1][2][3][3]=0.0116915;
454 s_fit_param[1][2][3][4]=-1E-5;
455 //---par[4]
456 s_fit_param[1][2][4][0]=-0.0118324;
457 s_fit_param[1][2][4][1]=0.0280538;
458 s_fit_param[1][2][4][2]=-85.127;
459 s_fit_param[1][2][4][3]=0.00724948;
460 s_fit_param[1][2][4][4]=-2.38792E-6;
461 //-par[5]
462 s_fit_param[1][2][5][0]=0.0;
463 s_fit_param[1][2][5][1]=0.0;
464 s_fit_param[1][2][5][2]=0.0;
465 s_fit_param[1][2][5][3]=0.6167*0.00125; // multiplied by a bin size
466 s_fit_param[1][2][5][4]=0.0;
467
468}
469
470// Default Destructor
473
474double MissingMassProb::apply(MissingMassInput& preparedInput, const int & tau_type1, const int & tau_type2, const PtEtaPhiMVector & tauvec1, const PtEtaPhiMVector & tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector & nuvec2, bool constant, bool oneTau, bool twoTau) {
475 double prob = 1.;
476 if (constant == true) {
477 for (auto& f: m_probListConstant) {
478 prob*=f(preparedInput, tau_type1, tau_type2, tauvec1, tauvec2, nuvec1, nuvec2);
479 }
480 } else if (oneTau == true) {
481 for (auto& f: m_probListOneTau) {
482 prob*=f(preparedInput, tau_type1, tau_type2, tauvec1, tauvec2, nuvec1, nuvec2);
483 }
484 } else if (twoTau == true) {
485 for (auto& f: m_probListTwoTau) {
486 prob*=f(preparedInput, tau_type1, tau_type2, tauvec1, tauvec2, nuvec1, nuvec2);
487 }
488 }
489 return prob;
490}
491
492
493double MissingMassProb::MetProbability(MissingMassInput& preparedInput, const double & met1,const double & met2,const double & MetSigma1,const double & MetSigma2) {
494
495
496 double metprob;
497 if(MetSigma1>1.0 && MetSigma2>1.0) // it doesn't make sense if MET resolution sigma is <1 GeV
498 {
499 //SpeedUp
500 metprob=exp(-0.5*(met1*met1/(MetSigma1*MetSigma1)+met2*met2/(MetSigma2*MetSigma2)))/(MetSigma1*MetSigma2*2*TMath::Pi());
501 }
502 else
503 {
504 if(preparedInput.m_fUseVerbose==1) Warning("DiTauMassTools", "MissingMassCalculator::MetProbability: either MetSigma1 or MetSigma2 are <1 GeV--- too low, returning prob=1");
505 metprob=1.;
506 }
507
508
509 return metprob;
510
511
512}
513
515{
516 double proba=1.;
517 double metprob;
518
519 // deltaMEt is the difference between the neutrino sum and the MEt (or -HT if useHT),
520 //corrected possibly from tau E scanning
521
522 double deltaMetX=preparedInput.m_metVec.X()-preparedInput.m_inputMEtX;
523 double deltaMetY=preparedInput.m_metVec.Y()-preparedInput.m_inputMEtY;
524
525 // possibly correct for subtract tau scanning here
526 // const double met_smearL=(deltaMetVec.X()*m_metCovPhiCos+deltaMetVec.Y()*m_metCovPhiSin;
527 // const double met_smearP=-deltaMetVec.X()*m_metCovPhiSin+deltaMetVec.Y()*m_metCovPhiCos;
528
529 // rotate into error ellipse axis
530 const double met_smearL=deltaMetX*cos(preparedInput.m_METcovphi)+deltaMetY*sin(preparedInput.m_METcovphi);
531 const double met_smearP=-deltaMetX*sin(preparedInput.m_METcovphi)+deltaMetY*cos(preparedInput.m_METcovphi);
532
533
534 if (m_UseHT)
535 {
536 if ( preparedInput.m_tauTypes==TauTypes::hh ) {
537
538 metprob=MHtProbabilityHH(preparedInput, met_smearL,met_smearP,preparedInput.m_inputMEtT,preparedInput.m_MEtT,preparedInput.m_htOffset); // for had-had
539 }
540 else {
541 metprob=MHtProbability(preparedInput, met_smearL,met_smearP,preparedInput.m_inputMEtT,preparedInput.m_MEtT,preparedInput.m_htOffset); // for lep-had Winter 2012 analysis
542 }
543 }
544 else {
545 metprob=MetProbability(preparedInput, met_smearL,met_smearP,preparedInput.m_METsigmaL,preparedInput.m_METsigmaP);
546 }
547
548 proba=metprob;
549
550 return proba;
551}
552
553//------------------- simple TauProbability for LFV
554double MissingMassProb::TauProbabilityLFV(MissingMassInput& preparedInput, const int & type1, const PtEtaPhiMVector & vis1, const PtEtaPhiMVector & nu1)
555{
556 double prob=1.0;
557 if(m_fUseTauProbability==0) return prob; // don't apply TauProbability
558 double prob1=1.0;
559 const double mtau=ParticleConstants::tauMassInMeV / GEV;
560 const double R1=nu1.E()/vis1.E();
561 //--- dealing with 1st tau
562 double m1=nu1.M();
563 double m2=vis1.M();
564 double E1=0.5*(mtau*mtau+m1*m1-m2*m2)/mtau;
565 double E2=mtau-E1;
566 if(E1<=m1 || E1>=mtau)
567 {
568 if(preparedInput.m_fUseVerbose==1) Warning("DiTauMassTools", "Warning in MissingMassCalculator::TauProbability: bad E1, returning 0 ");
569 return 0.0;
570 }
571 if(E2<=m2 || E2>=mtau)
572 {
573 if(preparedInput.m_fUseVerbose==1) Warning("DiTauMassTools", "Warning in MissingMassCalculator::TauProbability: bad E2, returning 0 ");
574 return 0.0;
575 }
576 preparedInput.m_tlv_tmp.SetPxPyPzE(0.,0.,0.,0.);
577 preparedInput.m_tlv_tmp+=nu1;
578 preparedInput.m_tlv_tmp+=vis1;
579 // double p=(nu1+vis1).P();
580 double p=preparedInput.m_tlv_tmp.P();
581 double V=p/sqrt(p*p+mtau*mtau);
582 double p0;
583 if(type1==8) p0=sqrt(E2*E2-m2*m2); // leptonic tau
584 else p0=E1; // hadronic tau
585 prob1=0.5*mtau/(p0*V*pow(R1+1.0,2));
586 // avoid too large values
587 prob=std::min(prob1,1.);
588 return prob;
589}
590
591double MissingMassProb::TauProbability(MissingMassInput& preparedInput, const int & type1, const PtEtaPhiMVector & vis1, const PtEtaPhiMVector & nu1,
592 const int & type2, const PtEtaPhiMVector & vis2, const PtEtaPhiMVector & nu2)
593{
594 double prob=1.0;
595 if(m_fUseTauProbability==0) return prob; // don't apply TauProbability
596 double prob1=1.0;
597 double prob2=1.0;
598 const double mtau=ParticleConstants::tauMassInMeV / GEV;
599 const double R1=nu1.E()/vis1.E();
600 const double R2=nu2.E()/vis2.E();
601 //--- dealing with 1st tau
602 double m1=nu1.M();
603 double m2=vis1.M();
604 double E1=0.5*(mtau*mtau+m1*m1-m2*m2)/mtau;
605 double E2=mtau-E1;
606 if(E1<=m1 || E1>=mtau)
607 {
608 if(preparedInput.m_fUseVerbose==1) Warning("DiTauMassTools", "Warning in MissingMassCalculator::TauProbability: bad E1, returning 0 ");
609 return 0.0;
610 }
611 if(E2<=m2 || E2>=mtau)
612 {
613 if(preparedInput.m_fUseVerbose==1) Warning("DiTauMassTools", "Warning in MissingMassCalculator::TauProbability: bad E2, returning 0 ");
614 return 0.0;
615 }
616 preparedInput.m_tlv_tmp.SetPxPyPzE(0.,0.,0.,0.);
617 preparedInput.m_tlv_tmp+=nu1;
618 preparedInput.m_tlv_tmp+=vis1;
619 // double p=(nu1+vis1).P();
620 double p=preparedInput.m_tlv_tmp.P();
621 double V=p/sqrt(p*p+mtau*mtau);
622 double p0;
623 if(type1==8) p0=sqrt(E2*E2-m2*m2); // leptonic tau
624 else p0=E1; // hadronic tau
625 prob1=0.5*mtau/(p0*V*pow(R1+1.0,2));
626 // avoid too large values
627 prob1=std::min(prob1,1.);
628
629
630 //--- dealing with 2nd tau
631 m1=nu2.M();
632 m2=vis2.M();
633 E1=0.5*(mtau*mtau+m1*m1-m2*m2)/mtau;
634 E2=mtau-E1;
635 if(E1<=m1 || E1>=mtau)
636 {
637 if(preparedInput.m_fUseVerbose==1) Warning("DiTauMassTools", "Warning in MissingMassCalculator::TauProbability: bad E1, returning 0 ");
638 return 0.0;
639 }
640 if(E2<=m2 || E2>=mtau)
641 {
642 if(preparedInput.m_fUseVerbose==1) Warning("DiTauMassTools", "Warning in MissingMassCalculator::TauProbability: bad E2, returning 0 ");
643 return 0.0;
644 }
645 preparedInput.m_tlv_tmp.SetPxPyPzE(0.,0.,0.,0.);
646 preparedInput.m_tlv_tmp+=nu2;
647 preparedInput.m_tlv_tmp+=vis2;
648 // p=(nu2+vis2).P();
649 p=preparedInput.m_tlv_tmp.P();
650
651
652 V=p/sqrt(p*p+mtau*mtau);
653 if(type2==8) p0=sqrt(E2*E2-m2*m2); // leptonic tau
654 else p0=E1; // hadronic tau
655 prob2=0.5*mtau/(p0*V*pow(R2+1.0,2));
656 // avoid too large values
657 prob2=std::min(prob2,1.);
658 prob=prob1*prob2;
659 return prob;
660}
661
662
663// --------- Updated version of TauProbability for lep-had events with Njet25=0, takes into account Winter-2012 analysis cuts
664double MissingMassProb::TauProbability(MissingMassInput& preparedInput, const int & type1, const PtEtaPhiMVector & vis1, const PtEtaPhiMVector & nu1,
665 const int & type2, const PtEtaPhiMVector & vis2, const PtEtaPhiMVector & nu2, const double & detmet) {
666 double prob=1.0;
667
668 if(m_fUseTauProbability==0) return prob; // don't apply TauProbability
669
670 if(m_UseHT)
671 {
672 if(detmet<20.0) // low MET Njet=0 category
673 {
674 const double R1=nu1.P()/vis1.P();
675 const double R2=nu2.P()/vis2.P();
676 const double lep_p1[4]={0.417,0.64,0.52,0.678};
677 const double lep_p2[4]={0.23,0.17,0.315,0.319};
678 const double lep_p3[4]={0.18,0.33,0.41,0.299};
679 const double lep_p4[4]={0.033,0.109,0.129,0.096};
680 const double lep_p5[4]={0.145,0.107,0.259,0.304};
681 int ind=3;
682 int indT=3;
683 const double n_1pr[4]={-0.15,-0.13,-0.25,-0.114};
684 const double s_1pr[4]={0.40,0.54,0.62,0.57};
685 const double n_3pr[4]={-1.08,-1.57,-0.46,-0.39};
686 const double s_3pr[4]={0.53,0.85,0.61,0.53};
687 double Ptau=0.0;
688 double Plep=0.0;
689 if(type1>=0 && type1<=5)
690 {
691 Ptau=(nu1+vis1).P();
692 Plep=(nu2+vis2).P();
693 }
694 if(type2>=0 && type2<=5)
695 {
696 Ptau=(nu2+vis2).P();
697 Plep=(nu1+vis1).P();
698 }
699 if(Plep<50.0 && Plep>=45.0) ind=2;
700 if(Plep<45.0 && Plep>=40.0) ind=1;
701 if(Plep<40.0) ind=0;
702 if(Ptau<50.0 && Ptau>=45.0) indT=2;
703 if(Ptau<45.0 && Ptau>=40.0) indT=1;
704 if(Ptau<40.0) indT=0;
705 if(type1==8) prob=prob*(lep_p5[ind]*TMath::Gaus(R1,lep_p1[ind],lep_p2[ind])+TMath::Landau(R1,lep_p3[ind],lep_p4[ind]))/(1+lep_p5[ind]);
706 if(type2==8) prob=prob*(lep_p5[ind]*TMath::Gaus(R2,lep_p1[ind],lep_p2[ind])+TMath::Landau(R2,lep_p3[ind],lep_p4[ind]))/(1+lep_p5[ind]);
707
708 if(type1>=0 && type1<=2) prob=prob*TMath::Gaus(R1,n_1pr[indT],s_1pr[indT]);
709 if(type2>=0 && type2<=2) prob=prob*TMath::Gaus(R2,n_1pr[indT],s_1pr[indT]);
710 if(type1>=3 && type1<=5) prob=prob*TMath::Gaus(R1,n_3pr[indT],s_3pr[indT]);
711 if(type2>=3 && type2<=5) prob=prob*TMath::Gaus(R2,n_3pr[indT],s_3pr[indT]);
712
713 }
714 else // high MET Njet=0 category
715 {
716 const double R1=nu1.P()/vis1.P();
717 const double R2=nu2.P()/vis2.P();
718 const double lep_p1[4]={0.441,0.64,0.79,0.8692};
719 const double lep_p2[4]={0.218,0.28,0.29,0.3304};
720 const double lep_p3[4]={0.256,0.33,0.395,0.4105};
721 const double lep_p4[4]={0.048,0.072,0.148,0.1335};
722 const double lep_p5[4]={0.25,0.68,0.10,0.2872};
723 int ind=3;
724 const double p_1prong=-3.706;
725 const double p_3prong=-5.845;
726 double Ptau=0.0;
727 double Plep=0.0;
728 if(type1>=0 && type1<=5)
729 {
730 Ptau=(nu1+vis1).P();
731 Plep=(nu2+vis2).P();
732 }
733 if(type2>=0 && type2<=5)
734 {
735 Ptau=(nu2+vis2).P();
736 Plep=(nu1+vis1).P();
737 }
738 if(Plep<50.0 && Plep>=45.0) ind=2;
739 if(Plep<45.0 && Plep>=40.0) ind=1;
740 if(Plep<40.0) ind=0;
741 const double scale1prong=Ptau>45.0 ? 1.0 : -1.019/((Ptau*0.0074-0.059)*p_1prong);
742 const double scale3prong=Ptau>40.0 ? 1.0 : -1.24/((Ptau*0.0062-0.033)*p_3prong);
743 if(type1==8) prob=prob*(lep_p5[ind]*TMath::Gaus(R1,lep_p1[ind],lep_p2[ind])+TMath::Landau(R1,lep_p3[ind],lep_p4[ind]))/(1+lep_p5[ind]);
744 if(type2==8) prob=prob*(lep_p5[ind]*TMath::Gaus(R2,lep_p1[ind],lep_p2[ind])+TMath::Landau(R2,lep_p3[ind],lep_p4[ind]))/(1+lep_p5[ind]);
745
746 if(type1>=0 && type1<=2) prob=prob*exp(p_1prong*R1*scale1prong)*std::abs(p_1prong*scale1prong)*0.02; // introduced normalization to account for sharpening of probability at low E(tau)
747 if(type2>=0 && type2<=2) prob=prob*exp(p_1prong*R2*scale1prong)*std::abs(p_1prong*scale1prong)*0.02;
748 if(type1>=3 && type1<=5) prob=prob*exp(p_3prong*R1*scale3prong)*std::abs(p_3prong*scale3prong)*0.02;
749 if(type2>=3 && type2<=5) prob=prob*exp(p_3prong*R2*scale3prong)*std::abs(p_3prong*scale3prong)*0.02;
750 }
751 }
752 //----------------- had-had channel ---------------------------------------
753 if( preparedInput.m_tauTypes==TauTypes::hh )
754 {
755
756 if(m_UseHT) // Events with no jets
757 {
758
759 const double R[2]={nu1.P()/vis1.P(),nu2.P()/vis2.P()};
760 const double E[2]={(nu1+vis1).E(),(nu2+vis2).E()};
761 const int tau_type[2]={type1,type2};
762 int order1= vis1.Pt()>vis2.Pt() ? 0 : 1;
763 int order2= vis1.Pt()>vis2.Pt() ? 1 : 0;
764
765 double par_1p[2][6]; // P(tau)-scaling; lead, sub-lead
766 double par_3p[2][6]; // P(tau)-scaling; lead, sub-lead
767
768 par_1p[0][0]=0.1273; par_1p[0][1]=-0.2479; par_1p[0][2]=1.0; par_1p[0][3]=-43.16; par_1p[0][4]=0.0; par_1p[0][5]=0.0;
769 par_1p[1][0]=0.3736; par_1p[1][1]=-1.441; par_1p[1][2]=1.0; par_1p[1][3]=-29.82; par_1p[1][4]=0.0; par_1p[1][5]=0.0;
770 par_3p[0][0]=0.1167; par_3p[0][1]=-0.1388; par_3p[0][2]=1.0; par_3p[0][3]=-44.77; par_3p[0][4]=0.0; par_3p[0][5]=0.0;
771 par_3p[1][0]=0.3056; par_3p[1][1]=-2.18; par_3p[1][2]=1.0; par_3p[1][3]=-19.09; par_3p[1][4]=0.0; par_3p[1][5]=0.0;
772 // parameters for sub-leading tau
773 const double C1p=0.062;
774 const double C3p=0.052;
775 const double G1p=1.055;
776 const double G3p=1.093;
777 // Probability for leading tau
778
779 if( tau_type[order1]>=0 && tau_type[order1]<=2 ) // 1-prong
780 {
781 //double x=std::min(300.,std::max(E[order1],45.0));
782 // 50 to be safe. TO be finalised.
783 // double x=std::min(300.,std::max(E[order1],50.0));
784 double x=std::min(E[order1],300.0);
785 const double slope=par_1p[0][0]+par_1p[0][1]/(par_1p[0][2]*x+par_1p[0][3])+par_1p[0][4]*x > 0.01 ?
786 par_1p[0][0]+par_1p[0][1]/(par_1p[0][2]*x+par_1p[0][3])+par_1p[0][4]*x : 0.01;
787 prob=prob*exp(-R[order1]/slope)*0.04/std::abs(slope);
788 }
789 if( tau_type[order1]>=3 && tau_type[order1]<=5 ) // 3-prong
790 {
791 //double x=std::min(300.,std::max(E[order1],45.0));
792 // double x=std::min(300.,std::max(E[order1],50.0));
793 double x=std::min(E[order1],300.0);
794 const double slope=par_3p[0][0]+par_3p[0][1]/(par_3p[0][2]*x+par_3p[0][3])+par_3p[0][4]*x > 0.01 ?
795 par_3p[0][0]+par_3p[0][1]/(par_3p[0][2]*x+par_3p[0][3])+par_3p[0][4]*x : 0.01;
796 prob=prob*exp(-R[order1]/slope)*0.04/std::abs(slope);
797 }
798 // Probability for sub-leading tau
799 if( tau_type[order2]>=0 && tau_type[order2]<=2 ) // 1-prong
800 {
801 const double par[4]={0.1147,-0.09675,-35.0,3.711E-11};
802 double x=std::min(300.,std::max(E[order2],30.0));
803 // double x=std::min(300.,std::max(E[order2],50.0));
804 const double sigma=G1p*(par_1p[1][0]+par_1p[1][1]/(par_1p[1][2]*x+par_1p[1][3])+par_1p[1][4]*x+par_1p[1][5]*x*x) > 0.01 ?
805 G1p*(par_1p[1][0]+par_1p[1][1]/(par_1p[1][2]*x+par_1p[1][3])+par_1p[1][4]*x+par_1p[1][5]*x*x) : 0.01;
806 if(x<36.0) x=36.0;
807 const double mean=par[0]+par[1]/(x+par[2])+par[3]*pow(x,4);
808 prob=prob*C1p*TMath::Gaus(R[order2],mean,sigma);
809 }
810 if( tau_type[order2]>=3 && tau_type[order2]<=5 ) // 3-prong
811 {
812 double x=std::min(300.,std::max(E[order2],20.0));
813 // double x=std::min(300.,std::max(E[order2],50.0));
814 const double sigma=G3p*(par_3p[1][0]+par_3p[1][1]/(par_3p[1][2]*x+par_3p[1][3])+par_3p[1][4]*x+par_3p[1][5]*x*x) > 0.01 ?
815 G3p*(par_3p[1][0]+par_3p[1][1]/(par_3p[1][2]*x+par_3p[1][3])+par_3p[1][4]*x+par_3p[1][5]*x*x) : 0.01;
816 const double par[4]={0.2302,-2.012,-36.08,-0.000373};
817 if(x<37.0) x=37.0;
818 const double mean=par[0]+par[1]/(x+par[2])+par[3]*x;
819 prob=prob*C3p*TMath::Gaus(R[order2],mean,sigma);
820 }
821 }
822 if(!m_UseHT) // Events with jets
823 {
824 const double R1=nu1.P()/vis1.P();
825 const double R2=nu2.P()/vis2.P();
826 const double E1=(nu1+vis1).E();
827 const double E2=(nu2+vis2).E();
828 int order1= vis1.Pt()>vis2.Pt() ? 0 : 1;
829 int order2= vis1.Pt()>vis2.Pt() ? 1 : 0;
830 const double slope_1p[2]={-3.185,-2.052}; // lead, sub-lead
831 const double slope_3p[2]={-3.876,-2.853}; // lead, sub-lead
832 double par_1p[2][3]; // scaling below 100 GeV; lead, sub-lead
833 double par_3p[2][3]; // scaling below 100 GeV; lead, sub-lead
834 par_1p[0][0]=-0.3745; par_1p[0][1]=0.01417; par_1p[0][2]=-7.285E-5; // [0][i] is always adjusted to match slope at 100 GeV
835 par_1p[1][0]=-0.3683; par_1p[1][1]=0.01807; par_1p[1][2]=-9.514E-5;
836 par_3p[0][0]=-0.3055; par_3p[0][1]=0.01149; par_3p[0][2]=-5.855E-5;
837 par_3p[1][0]=-0.3410; par_3p[1][1]=0.01638; par_3p[1][2]=-9.465E-5;
838 double scale1;
839 double scale2;
840 if(type1>=0 && type1<=2) // 1-prong
841 {
842 scale1=E1>100.0 ? 1.0 : 1.0/std::abs((par_1p[order1][0]+par_1p[order1][1]*E1+par_1p[order1][2]*E1*E1)*slope_1p[order1]);
843 if(scale1<1.0) scale1=1.0;
844 if(scale1>100.0) scale1=100.0;
845 prob=prob*std::abs(slope_1p[order1])*scale1*exp(slope_1p[order1]*scale1*R1)*0.04;
846 }
847 if(type1>=3 && type1<=5) // 3-prong
848 {
849 scale1=E1>100.0 ? 1.0 : 1.0/std::abs((par_3p[order1][0]+par_3p[order1][1]*E1+par_3p[order1][2]*E1*E1)*slope_3p[order1]);
850 if(scale1<1.0) scale1=1.0;
851 if(scale1>100.0) scale1=100.0;
852 prob=prob*std::abs(slope_3p[order1])*scale1*exp(slope_3p[order1]*scale1*R1)*0.04;
853 }
854 if(type2>=0 && type2<=2) // 1-prong
855 {
856 scale2=E2>100.0 ? 1.0 : 1.0/std::abs((par_1p[order2][0]+par_1p[order2][1]*E2+par_1p[order2][2]*E2*E2)*slope_1p[order2]);
857 if(scale2<1.0) scale2=1.0;
858 if(scale2>100.0) scale2=100.0;
859 prob=prob*std::abs(slope_1p[order2])*scale2*exp(slope_1p[order2]*scale2*R2)*0.04;
860 }
861 if(type2>=3 && type2<=5) // 3-prong
862 {
863 scale2=E2>100.0 ? 1.0 : 1.0/std::abs((par_3p[order2][0]+par_3p[order2][1]*E2+par_3p[order2][2]*E2*E2)*slope_3p[order2]);
864 if(scale2<1.0) scale2=1.0;
865 if(scale2>100.0) scale2=100.0;
866 prob=prob*std::abs(slope_3p[order2])*scale2*exp(slope_3p[order2]*scale2*R2)*0.04;
867
868 }
869 }
870
871 }
872 // prob=std::min(prob,1.); // Sasha commented out this line, it was introduced by David. Have to ask about its purpose.
873
874 return prob;
875}
876
877
878// returns Mnu probability according pol6 parameterization
879double MissingMassProb::MnuProbability(MissingMassInput& preparedInput, double mnu, double binsize)
880{
881 double prob=1.0;
882 double norm=4851900.0;
883 double p[7];
884 p[0]=-288.6/norm; p[1]=6.217E4/(2.0*norm); p[2]=2.122E4/(3.0*norm); p[3]=-9.067E4/(4.0*norm);
885 p[4]=1.433E5/(5.0*norm); p[5]=-1.229E5/(6.0*norm); p[6]=3.434E4/(7.0*norm);
886 double int1=0.0;
887 double int2=0.0;
888 double x1= mnu+0.5*binsize < 1.777-0.113 ? mnu+0.5*binsize : 1.777-0.113;
889 double x2= mnu-0.5*binsize > 0.0 ? mnu-0.5*binsize : 0.0;
890 for(int i=0; i<7; i++)
891 {
892 int1=p[i]*pow(x1,i+1)+int1;
893 int2=p[i]*pow(x2,i+1)+int2;
894 }
895 prob=int1-int2;
896 if(prob<0.0)
897 {
898 if(preparedInput.m_fUseVerbose==1) Warning("DiTauMassTools", "Warning in MissingMassCalculator::MnuProbability: negative probability!!! ");
899 return 0.0;
900 }
901 if(prob>1.0)
902 {
903 if(preparedInput.m_fUseVerbose==1) Warning("DiTauMassTools", "Warning in MissingMassCalculator::MnuProbability: probability > 1!!! ");
904 return 1.0;
905 }
906 return prob;
907}
908
909// returns Mnu probability according pol6 parameterization
910double MissingMassProb::MnuProbability(MissingMassInput& preparedInput, double mnu)
911{
912 if(m_fUseMnuProbability==0) return 1.0;
913 double prob=1.0;
914 const double norm=4851900.0;
915 double p[7];
916 p[0]=-288.6; p[1]=6.217E4; p[2]=2.122E4; p[3]=-9.067E4;
917 p[4]=1.433E5; p[5]=-1.229E5; p[6]=3.434E4;
918 double int1=0.0;
919 for(int i=0; i<7; i++)
920 {
921 int1+=p[i]*pow(mnu,i);
922 }
923 prob=int1/norm;
924 if(prob<0.0)
925 {
926 if(preparedInput.m_fUseVerbose==1) Warning("DiTauMassTools", "Warning in MissingMassCalculator::MnuProbability: negative probability!!! ");
927 return 0.0;
928 }
929 if(prob>1.0)
930 {
931 if(preparedInput.m_fUseVerbose==1) Warning("DiTauMassTools", "Warning in MissingMassCalculator::MnuProbability: probability > 1!!! ");
932 return 1.0;
933 }
934 return prob;
935}
936
937double MissingMassProb::MHtProbability(MissingMassInput& preparedInput, const double & d_mhtX, const double & d_mhtY, const double & mht,
938 const double & trueMetGuess, const double & mht_offset) {
939 // all param except trueMetguess unchanged in one event. So can cache agaisnt this one.
940 //disable cache if (trueMetGuess==trueMetGuesscache) return mhtprobcache;
941 double mhtprob;
942 // if(MHtSigma1>0.0 && MHtSigma2>0.0 && MHtGaussFr>0.0)
943
944 // if RANDOMNONUNIF MET already follow the double gaussian parameterisation. So weight should not include it to avoid double counting
945 // formula to be checked IMHO the two gaussian should be correlated
946 mhtprob=exp(-0.5*pow(d_mhtX/preparedInput.m_MHtSigma1,2))+preparedInput.m_MHtGaussFr*exp(-0.5*pow(d_mhtX/preparedInput.m_MHtSigma2,2));
947 mhtprob*=(exp(-0.5*pow(d_mhtY/preparedInput.m_MHtSigma1,2))+preparedInput.m_MHtGaussFr*exp(-0.5*pow(d_mhtY/preparedInput.m_MHtSigma2,2)));
948
949 const double n_arg=(mht-trueMetGuess-mht_offset)/preparedInput.m_MHtSigma1;
950 mhtprob*=exp(-0.25*pow(n_arg,2)); // assuming sqrt(2)*sigma
951 return mhtprob;
952}
953
954double MissingMassProb::MHtProbabilityHH(MissingMassInput& preparedInput, const double & d_mhtX, const double & d_mhtY, const double & mht,
955 const double & trueMetGuess, const double & mht_offset) {
956 double prob=1.0;
957
958 // updated for final cuts, May 21 2012
959 // should be merged
960 prob=prob*(0.0256*TMath::Gaus(d_mhtX,0.0,preparedInput.m_MHtSigma1)+0.01754*TMath::Gaus(d_mhtX,0.0,preparedInput.m_MHtSigma2));
961 prob=prob*(0.0256*TMath::Gaus(d_mhtY,0.0,preparedInput.m_MHtSigma1)+0.01754*TMath::Gaus(d_mhtY,0.0,preparedInput.m_MHtSigma2));
962 const double n_arg=(mht-trueMetGuess-mht_offset)/5.7; // this sigma is different from MHtSigma1; actually it depends on dPhi
963 prob=prob*exp(-0.5*pow(n_arg,2))/(5.7*sqrt(2.0*TMath::Pi())); // assuming sigma from above line
964
965 return prob;
966}
967
968//SpeedUp static instantation
969// first index is the calibration set : 0: MMC2011, 1:MMC2012
970// second index is the decay 0 : lepton, 1 : 1 prong, 2 3 prong
971thread_local double MissingMassProb::s_fit_param[2][3][6][5];
972
973// returns dTheta3D probability based on ATLAS parameterization
974double MissingMassProb::dTheta3d_probabilityFast(MissingMassInput& preparedInput, const int & tau_type,const double & dTheta3d,const double & P_tau) {
975 double prob=1.0E-10;
976 int tau_code; // 0: l, 1:1-prong, 2:3-prong
977 if(tau_type==8) tau_code = 0;
978 else if(tau_type>=0 && tau_type<=2) tau_code = 1;
979 else if(tau_type>=3 && tau_type<=5) tau_code = 2;
980 else if(tau_type==6) return prob;
981 else
982 {
983 Warning("DiTauMassTools", "---- WARNING in MissingMassCalculator::dTheta3d_probabilityFast() ----");
984 Warning("DiTauMassTools", "%s", ("..... wrong tau_type="+std::to_string(tau_type)).c_str());
985 Warning("DiTauMassTools", "%s", ("..... returning prob="+std::to_string(prob)).c_str());
986 Warning("DiTauMassTools", "____________________________________________________________");
987 return prob;
988 }
989
990
991 double myDelThetaParam[6];
992
993 for (int i=0;i<6;++i)
994 {
998 myDelThetaParam[i]=dTheta3Dparam(i,tau_code,P_tau,s_fit_param[1][tau_code][i]);
999 }
1000 double dTheta3dVal=dTheta3d;
1001
1002 if (tau_type==8) prob=myDelThetaLepFunc(&dTheta3dVal, myDelThetaParam);
1003 else prob=myDelThetaHadFunc(&dTheta3dVal, myDelThetaParam);
1004
1005 if (false)
1006 {
1007
1008 if( preparedInput.m_fUseVerbose==1 && (prob>1.0 || prob<0.0))
1009 {
1010 Warning("DiTauMassTools", "---- WARNING in MissingMassCalculator::dTheta3d_probabilityFast() ----");
1011 Warning("DiTauMassTools", "%s", ("..... wrong probability="+std::to_string(prob)).c_str());
1012 Warning("DiTauMassTools", "%s", ("..... debugging: tau_type="+std::to_string(tau_type)+"dTheta3d="+std::to_string(dTheta3d)+" P_tau="+std::to_string(P_tau)).c_str());
1013 Warning("DiTauMassTools", "____________________________________________________________");
1014 prob=1.0E-10;
1015 }
1016 }
1017
1018 return prob;
1019}
1020
1021// dTheta probability density function for hadronic taus
1022double MissingMassProb::myDelThetaHadFunc(double *x, double *par)
1023{
1024 double fitval=1.0E-10;
1025 if(x[0]>TMath::Pi() || x[0]<0.0) return fitval;
1026 const double arg=x[0];
1027 const double arg_L=arg;
1028 const double mean=par[1];
1029 const double sigmaG=par[2];
1030 const double mpv=par[3];
1031 const double sigmaL=par[4];
1032
1036 const double norm=sqrt(2.0*TMath::Pi());
1037 const double g1=TMath::Gaus(arg,mean,sigmaG)/norm;
1038 const double g2=TMath::Landau(arg_L,mpv,sigmaL)/norm;
1039 fitval=par[0]*g1/sigmaG+par[5]*g2/sigmaL;
1040 }
1041
1042 if(fitval<0.0) return 0.0;
1043 return fitval;
1044}
1045
1046// dTheta probability density function for leptonic taus
1047double MissingMassProb::myDelThetaLepFunc(double *x, double *par)
1048{
1049 double fitval=1.0E-10;
1050 if(x[0]>TMath::Pi() || x[0]<0.0) return fitval;
1051 double arg=x[0]/par[1];
1052
1053 double normL=par[5];
1054 if(normL<0.0) normL=0.0;
1055
1056 if(arg<1) arg=sqrt(std::abs(arg));
1057 else arg=arg*arg;
1058 const double arg_L=x[0];
1059 const double mean=1.0;
1060 const double sigmaG=par[2];
1061 const double mpv=par[3];
1062 const double sigmaL=par[4];
1063 const double g1=normL*TMath::Gaus(arg,mean,sigmaG);
1064 const double g2=TMath::Landau(arg_L,mpv,sigmaL);
1065 fitval=par[0]*(g1+g2)/(1.0+normL);
1066 if(fitval<0.0) return 0.0;
1067 return fitval;
1068}
1069
1070// returns parameters for dTheta3D pdf
1071double MissingMassProb::dTheta3Dparam(const int & parInd, const int & tau_type, const double & P_tau, const double *par) {
1072 //tau_type 0: l, 1:1-prong, 3:3-prong
1073 if(P_tau<0.0) return 0.0;
1074
1075
1076 if(parInd==0) {
1080 return (par[0]+par[1]*P_tau+par[2]*pow(P_tau,2)+par[3]*pow(P_tau,3)+par[4]*pow(P_tau,4))*0.00125;
1081 }
1082 }
1083 else { // parInd==0
1087 if(tau_type==0) return par[0]*(exp(-par[1]*P_tau)+par[2]/P_tau)+par[3]+par[4]*P_tau;
1088 else return par[0]*(exp(-par[1]*sqrt(P_tau))+par[2]/P_tau)+par[3]+par[4]*P_tau;
1089 }
1090 }
1091 return 0.;
1092}
1093
1095 // compute MET resolution (eventually use HT)
1096 if(preparedInput.m_METsigmaP<0.1 || preparedInput.m_METsigmaL<0.1)
1097 {
1099 {
1100 if(preparedInput.m_fUseVerbose==1) { Info("DiTauMassTools", "Attempting to set LFV MMC settings"); }
1101 double mT1 = mT(preparedInput.m_vistau1,preparedInput.m_MetVec);
1102 double mT2 = mT(preparedInput.m_vistau2,preparedInput.m_MetVec);
1103 int sr_switch = 0;
1104 if(preparedInput.m_vistau1.M()<0.12 && preparedInput.m_vistau2.M()<0.12) // lep-lep case
1105 {
1106 if(preparedInput.m_LFVmode==0) // e+tau(->mu) case
1107 {
1108 if(preparedInput.m_vistau1.M()<0.05 && preparedInput.m_vistau2.M()>0.05)
1109 {
1110 if(mT1>mT2) sr_switch = 0; // SR1
1111 else sr_switch = 1; // SR2
1112 }
1113 else
1114 {
1115 if(mT1>mT2) sr_switch = 1; // SR2
1116 else sr_switch = 0; // SR1
1117 }
1118 }
1119 if(preparedInput.m_LFVmode==1) // mu+tau(->e) case
1120 {
1121 if(preparedInput.m_vistau1.M()>0.05 && preparedInput.m_vistau2.M()<0.05)
1122 {
1123 if(mT1>mT2) sr_switch = 0; // SR1
1124 else sr_switch = 1; // SR2
1125 }
1126 else
1127 {
1128 if(mT1>mT2) sr_switch = 1; // SR2
1129 else sr_switch = 0; // SR1
1130 }
1131 }
1132 }
1133 if((preparedInput.m_vistau1.M()<0.12 && preparedInput.m_vistau2.M()>0.12) || (preparedInput.m_vistau2.M()<0.12 && preparedInput.m_vistau1.M()>0.12)) // lep-had case
1134 {
1135 if(preparedInput.m_vistau1.M()<0.12 && preparedInput.m_vistau2.M()>0.12)
1136 {
1137 if(mT1>mT2) sr_switch = 0; // SR1
1138 else sr_switch = 1; // SR2
1139 }
1140 else
1141 {
1142 if(mT1>mT2) sr_switch = 1; // SR2
1143 else sr_switch = 0; // SR1
1144 }
1145 }
1146
1147 m_UseHT = false;
1148 if(preparedInput.m_Njet25==0) // 0-jet
1149 {
1150 double sigmaSyst = 0.10; // 10% systematics for now (be conservative)
1151 double METresScale;
1152 double METoffset;
1153 if(sr_switch==0)
1154 {
1155 METresScale = 0.41*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1156 METoffset = 7.36*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1157 }
1158 else
1159 {
1160 METresScale = 0.34*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1161 METoffset = 6.61*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1162 }
1163 if(preparedInput.m_fUseVerbose==1) {
1164 Info("DiTauMassTools", "%s", ("SumEt = "+std::to_string(preparedInput.m_SumEt)).c_str());
1165 Info("DiTauMassTools", "%s", ("METoffset = "+std::to_string(METoffset)).c_str());
1166 Info("DiTauMassTools", "%s", ("METresScale = "+std::to_string(METresScale)).c_str());
1167 }
1168
1169 double sigma = preparedInput.m_SumEt>0.0 ? METoffset+METresScale*sqrt(preparedInput.m_SumEt) : METoffset;
1170 preparedInput.m_METsigmaP = sigma;
1171 preparedInput.m_METsigmaL = sigma;
1172 if(preparedInput.m_fUseVerbose==1) {
1173 Info("DiTauMassTools", "%s", ("=> METsigmaP = "+std::to_string(preparedInput.m_METsigmaP)).c_str());
1174 Info("DiTauMassTools", "%s", ("=> METsigmaL = "+std::to_string(preparedInput.m_METsigmaL)).c_str());
1175 }
1176 }
1177 if(preparedInput.m_Njet25>0) // Inclusive 1-jet
1178 {
1179 double sigmaSyst = 0.10; // 10% systematics for now (be conservative)
1180 double sigma = 0.;
1181 double METresScale;
1182 double METoffset;
1183 if(sr_switch==0)
1184 {
1185 METresScale = 0.38*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1186 METoffset = 7.96*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1187 }
1188 else
1189 {
1190 METresScale = 0.39*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1191 METoffset = 6.61*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1192 }
1193
1194 // MET resolution can't be perfect in presence of other objects (i.e., electrons, jets, taus), so assume minSumEt = 5.0 for now
1195 sigma = preparedInput.m_SumEt>0.0 ? METoffset+METresScale*sqrt(preparedInput.m_SumEt) : METoffset;
1196 preparedInput.m_METsigmaP = sigma;
1197 preparedInput.m_METsigmaL = sigma;
1198 } // Njet25>0
1199 }
1200 else //LFV
1201 {
1202 //DRDRMERGE end addition
1203
1204 if(preparedInput.m_METScanScheme==1) // default for Winter 2012 and further
1205 {
1206 //LEP-HAD
1207 if ( preparedInput.m_tauTypes==TauTypes::lh ) // lephad case
1208 {
1209 //0-jet
1210 if(preparedInput.m_Njet25==0)//0-jet
1211 {
1212 // placeholder for 2019 tune
1215 if(preparedInput.m_MetVec.R()<20.0) // 0-jet low MET case
1216 {
1217 if(std::abs(preparedInput.m_DelPhiTT)>2.95 && m_allowUseHT) // use mHt only if dPhi(lep-tau)>2.95
1218 {
1219 m_UseHT = true;
1220 // giving priority to external settings
1221 if(preparedInput.m_MHtSigma1<0.0) preparedInput.m_MHtSigma1 = 4.822;
1222 if(preparedInput.m_MHtSigma2<0.0) preparedInput.m_MHtSigma2 = 10.31;
1223 if(preparedInput.m_MHtGaussFr<0.0) preparedInput.m_MHtGaussFr = 6.34E-5;
1224 }
1225 else
1226 {
1227 m_UseHT = false;
1228 double sigmaSyst = 0.10; // 10% systematics for now (be conservative)
1229 double METresScale = 0.32*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1230 double METoffset = 5.38*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1231 double sigma = preparedInput.m_SumEt>0.0 ? METoffset+METresScale*sqrt(preparedInput.m_SumEt) : METoffset;
1232 preparedInput.m_METsigmaP = sigma;
1233 preparedInput.m_METsigmaL = sigma;
1234 }
1235 }
1236 else // 0-jet high MET case
1237 {
1238 if(std::abs(preparedInput.m_DelPhiTT)>2.8 && m_allowUseHT) // use mHt only if dPhi(lep-tau)>2.8
1239 {
1240 m_UseHT = true;
1241 // giving priority to external settings
1242 if(preparedInput.m_MHtSigma1<0.0) preparedInput.m_MHtSigma1 = 7.5;
1243 if(preparedInput.m_MHtSigma2<0.0) preparedInput.m_MHtSigma2 = 13.51;
1244 if(preparedInput.m_MHtGaussFr<0.0) preparedInput.m_MHtGaussFr = 6.81E-4;
1245 preparedInput.m_METsigmaP = preparedInput.m_MHtSigma2; // sigma of 2nd Gaussian for missing Ht resolution
1246 preparedInput.m_METsigmaL = preparedInput.m_MHtSigma2;
1247 }
1248 else
1249 {
1250 m_UseHT = false;
1251 double sigmaSyst = 0.10; // 10% systematics for now (be conservative)
1252 double METresScale = 0.87*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1253 double METoffset = 4.16*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1254 double sigma = preparedInput.m_SumEt>0.0 ? METoffset+METresScale*sqrt(preparedInput.m_SumEt) : METoffset;
1255 preparedInput.m_METsigmaP = sigma;
1256 preparedInput.m_METsigmaL = sigma;
1257 }
1258 } // high MET
1259 } // MMC2019
1260 // 2015 high-mass tune; avergare MET resolution for Mh=600,1000 mass points
1262 {
1263 m_UseHT = false;
1264 double sigmaSyst = 0.10; // 10% systematics for now (be conservative)
1265 double METresScale = 0.65*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1266 double METoffset = 5.0*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1267 double sigma = preparedInput.m_SumEt>0.0 ? METoffset+METresScale*sqrt(preparedInput.m_SumEt) : METoffset;
1268 preparedInput.m_METsigmaP = sigma;
1269 preparedInput.m_METsigmaL = sigma;
1270 } // MMC2015HIGHMASS
1271 } // 0 jet
1272 //1-jet
1273 else if(preparedInput.m_Njet25>0) // Inclusive 1-jet and VBF lep-had categories for Winter 2012
1274 {
1275 double sigmaSyst=0.10; // 10% systematics for now (be conservative)
1276 double sigma=0.;
1277 // 2015 high-mass tune; average MET resolution for Mh=400,600 mass points (they look consistent);
1279 {
1280 double METresScale=0.86*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1281 double METoffset=3.0*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1282 // MET resolution can't be perfect in presence of other objects (i.e., electrons, jets, taus), so assume minSumEt=5.0 for now
1283 sigma= preparedInput.m_SumEt>0.0 ? METoffset+METresScale*sqrt(preparedInput.m_SumEt) : METoffset;
1284 }
1285 //2019
1288 {
1289 double x = preparedInput.m_DelPhiTT;
1290 double dphi_scale = x > 0.3 ? 0.9429 - 0.059*x + 0.054*x*x : 0.728;
1291 double METoffset = 1.875*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1292 double METresScale1 = 8.914*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1293 double METresScale2 = -8.53*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1294
1295
1296 sigma = preparedInput.m_SumEt > 80.0 ? METoffset + METresScale1*TMath::Log(sqrt(preparedInput.m_SumEt)+METresScale2) : 5.0;
1297 sigma = sigma * dphi_scale;
1298 }
1299 //
1300
1301 preparedInput.m_METsigmaP=sigma;
1302 preparedInput.m_METsigmaL=sigma;
1303 } // Njet25>0
1304
1305 } // lep-had
1306
1307 //HAD-HAD
1308 else if(preparedInput.m_tauTypes==TauTypes::hh) // had-had events
1309 {
1310 if(preparedInput.m_Njet25==0 && m_mmcCalibrationSet==MMCCalibrationSet::MMC2015HIGHMASS) //0-jet high mass hadhad
1311 {
1312 // 2015 high-mass tune; average of all mass points
1313 // double METresScale=-1.;
1314 // double METoffset=-1.;
1315 double sigmaSyst=0.10; // 10% systematics for now (be conservative)
1316
1317 double METresScale=0.9*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1318 double METoffset=-1.8*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1319 double sigma= preparedInput.m_SumEt>0.0 ? METoffset+METresScale*sqrt(preparedInput.m_SumEt) : std::abs(METoffset);
1320 preparedInput.m_METsigmaP=sigma;
1321 preparedInput.m_METsigmaL=sigma;
1322
1323 }
1324 else if(preparedInput.m_Njet25==0 &&
1327 {
1328 double sigmaSyst=0.10; // 10% systematics for now (be conservative)
1329 double x = preparedInput.m_DelPhiTT;
1330 double dphi_scale = x > 2.5 ? 11.0796 - 4.61236*x + 0.423617*x*x : 2.;
1331 double METoffset = -8.51013*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1332 double METresScale1 = 8.54378*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1333 double METresScale2 = -3.97146*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1334 double sigma= preparedInput.m_SumEt>80.0 ? METoffset+METresScale1*TMath::Log(sqrt(preparedInput.m_SumEt)+METresScale2) : 5.;
1335 sigma = sigma*dphi_scale;
1336
1337 preparedInput.m_METsigmaP=sigma;
1338 preparedInput.m_METsigmaL=sigma;
1339
1340 }
1341 else if(preparedInput.m_Njet25==0 && m_allowUseHT) // 0-jet high MET had-had category for Winter 2012
1342 {
1343
1344 m_UseHT=true; // uncomment this line to enable HT also for HH (crucial)
1345 // updated for final cuts, may 21 2012
1346 if(preparedInput.m_MHtSigma1<0.0) preparedInput.m_MHtSigma1=5.972;
1347 if(preparedInput.m_MHtSigma2<0.0) preparedInput.m_MHtSigma2=13.85;
1348 // if(MHtGaussFr<0.0) MHtGaussFr=0.4767; // don't directly use 2nd fraction
1349 }
1350 //1-jet
1351 else // Inclusive 1-jet and VBF categories
1352 {
1353 double METresScale=-1.;
1354 double METoffset=-1.;
1355 double sigmaSyst=0.10; // 10% systematics for now (be conservative)
1356
1357 // previous value in trunk
1359 // 2015 high-mass tune; average of all mass points
1360 METresScale = 1.1*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1361 METoffset = -5.0*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1362 }
1363 // MET resolution can't be perfect in presence of other objects (i.e., electrons, jets, taus), so assume minSumEt=5.0 for now
1364 double sigma = preparedInput.m_SumEt>0.0 ? METoffset+METresScale*sqrt(preparedInput.m_SumEt) : std::abs(METoffset);
1365
1368 double x = preparedInput.m_DelPhiTT;
1369 double dphi_scale = x > 0.6 ? 1.42047 - 0.666644*x + 0.199986*x*x : 1.02;
1370 METoffset = 1.19769*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1371 double METresScale1 = 5.61687*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1372 double METresScale2 = -4.2076*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1373 sigma= preparedInput.m_SumEt>115.0 ? METoffset+METresScale1*TMath::Log(sqrt(preparedInput.m_SumEt)+METresScale2) : 12.1;
1374 sigma = sigma*dphi_scale;
1375 } //for hh 2016 mc15c
1376
1377 preparedInput.m_METsigmaP = sigma;
1378 preparedInput.m_METsigmaL = sigma;
1379
1380 }// 1 jet
1381 } // had-had
1382 //LEP-LEP
1383 else if(preparedInput.m_tauTypes==TauTypes::ll) // setup for LEP-LEP channel
1384 {
1385 if(m_mmcCalibrationSet==MMCCalibrationSet::MMC2015HIGHMASS) // placeholder for 2015 high-mass tune; for now it is the same as 2012
1386 {
1387 m_UseHT = false;
1388 double sigmaSyst = 0.10; // 10% systematics for now (be conservative)
1389 double METresScale = -1.0;
1390 double METoffset = -1.0;
1391 double sigma = 5.0;
1392 // tune is based on cuts for Run-1 paper analysis
1393 if(preparedInput.m_Njet25==0)
1394 {
1395 // use tune for emebedding
1396 METresScale=-0.4307*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1397 METoffset=7.06*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1398 double METresScale2=0.07693*(1.0+preparedInput.m_METresSyst*sigmaSyst); // quadratic term
1399 // this is a tune for Higgs125
1400 // METresScale=-0.5355*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1401 // METoffset=11.5*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1402 // double METresScale2=0.07196*(1.0+preparedInput.m_METresSyst*sigmaSyst); // quadratic term
1403 sigma= preparedInput.m_SumEt>0.0 ? METoffset+METresScale*sqrt(preparedInput.m_SumEt)+METresScale2*preparedInput.m_SumEt : METoffset;
1404 }
1405 if(preparedInput.m_Njet25>0)
1406 {
1407 // use tune for embedding
1408 METresScale=0.8149*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1409 METoffset=5.343*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1410 // this is a tune for Higgs125
1411 // METresScale=0.599*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1412 // METoffset=8.223*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1413 sigma= preparedInput.m_SumEt>0.0 ? METoffset+METresScale*sqrt(preparedInput.m_SumEt) : METoffset;
1414 }
1415 preparedInput.m_METsigmaP = sigma;
1416 preparedInput.m_METsigmaL = sigma;
1417 } // end of MMC2015HIGHMASS
1418
1421 // 2019 leplep
1422 {
1423 m_UseHT=false;
1424 double sigmaSyst=0.10; // 10% systematics for now (be conservative)
1425 double METresScale=-1.0;
1426 double METoffset=-1.0;
1427 double sigma=5.0;
1428 double min_sigma = 2.0;
1429 // tune is based on cuts for Run-1 paper analysis
1430 if(preparedInput.m_Njet25==0)
1431 {
1432 // Madgraph Ztautau MET param
1433 METoffset = 4.22581*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1434 METresScale = 0.03818*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1435 double METresScale2= 0.12623;
1436 sigma= preparedInput.m_SumEt>0.0 ? METoffset+METresScale*sqrt(preparedInput.m_SumEt)+METresScale2*preparedInput.m_SumEt : min_sigma;
1437 if (m_fUseDphiLL) {
1438 double p0 = 2.60131;
1439 double p1const = 1.22427;
1440 double p2quad = -1.71261;
1441 double DphiLL = std::abs(Phi_mpi_pi(preparedInput.m_vistau1.Phi()-preparedInput.m_vistau2.Phi()));
1442 sigma *= (DphiLL < p0) ? p1const : p1const+
1443 p2quad*p0*p0 - 2*p2quad*p0*DphiLL+p2quad*DphiLL*DphiLL;
1444 }
1445 if (sigma < min_sigma) sigma = min_sigma;
1446 }
1447 if(preparedInput.m_Njet25>0)
1448 {
1449 // Madgraph Ztautau MET param
1450 METoffset = 5.42506*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1451 METresScale = 5.36760*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1452 double METoffset2 = -4.86808*(1.0+preparedInput.m_METresSyst*sigmaSyst);
1453 if (preparedInput.m_SumEt > 0.0) {
1454 double x = sqrt(preparedInput.m_SumEt);
1455 sigma = (x+METoffset2 > 1) ? METoffset+METresScale*log(x+METoffset2) : METoffset;
1456 } else {
1457 sigma = METoffset;
1458 }
1459 if (m_fUseDphiLL) {
1460 double p0 = 2.24786;
1461 double p1const = 0.908597;
1462 double p2quad = 0.544577;
1463 double DphiLL = std::abs(Phi_mpi_pi(preparedInput.m_vistau1.Phi()-preparedInput.m_vistau2.Phi()));
1464 sigma *= (DphiLL < p0) ? p1const : p1const+
1465 p2quad*p0*p0 - 2*p2quad*p0*DphiLL+p2quad*DphiLL*DphiLL;
1466 }
1467 if (sigma < min_sigma) sigma = min_sigma;
1468 }
1469 preparedInput.m_METsigmaP=sigma;
1470 preparedInput.m_METsigmaL=sigma;
1471 }//2016 mc15c
1472
1473 } // lep-lep
1474
1475 } //preparedInput.METScanScheme
1476
1477 if(preparedInput.m_METScanScheme==0) // old scheme with JER
1478 {
1479 if(preparedInput.m_dataType==0 || preparedInput.m_dataType==1) preparedInput.SetMetScanParamsUE(preparedInput.m_SumEt,preparedInput.m_METcovphi,preparedInput.m_dataType);
1480 else preparedInput.SetMetScanParamsUE(preparedInput.m_SumEt,preparedInput.m_METcovphi,0);
1481 }
1482 }
1483 } // end else LFV
1484
1485 return;
1486}
__HOSTDEV__ double Phi_mpi_pi(double)
Definition GeoRegion.cxx:10
#define scale2
#define scale1
static Double_t P(Double_t *tt, Double_t *par)
A number of constexpr particle constants to avoid hardcoding them directly in various places.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
#define GEV
#define x
void SetMetScanParamsUE(double sumEt, double phi_scan=0.0, int data_code=0)
std::vector< TF1 * > m_paramVectorRatioLep
double TauProbabilityLFV(MissingMassInput &preparedInput, const int &type1, const PtEtaPhiMVector &vis1, const PtEtaPhiMVector &nu1)
static double dTheta3d_probabilityFastWrapper(MissingMassProb *prob, MissingMassInput &preparedInput, const int &tau_type1, const int &tau_type2, const PtEtaPhiMVector &tauvec1, const PtEtaPhiMVector &tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector &nuvec2)
double MHtProbabilityHH(MissingMassInput &preparedInput, const double &d_mhtX, const double &d_mhtY, const double &mht, const double &trueMetGuess, const double &mht_offset)
std::vector< TF1 * > m_paramVectorNuMass
double MHtProbability(MissingMassInput &preparedInput, const double &d_mhtX, const double &d_mhtY, const double &mht, const double &trueMetGuess, const double &mht_offset)
MissingMassProb(MMCCalibrationSet::e aset, const std::string &paramFilePath)
void MET(MissingMassInput &preparedInput)
double dTheta3d_probabilityFast(MissingMassInput &preparedInput, const int &tau_type, const double &dTheta3d, const double &P_tau)
std::list< std::function< double(MissingMassInput &preparedInput, const int &tau_type1, const int &tau_type2, const PtEtaPhiMVector &tauvec1, const PtEtaPhiMVector &tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector &nuvec2)> > m_probListConstant
double myDelThetaLepFunc(double *x, double *par)
double dTheta3Dparam(const int &parInd, const int &tau_type, const double &P_tau, const double *par)
void setParamRatio(int tau, int tautype)
double TauProbability(MissingMassInput &preparedInput, const int &type1, const PtEtaPhiMVector &vis1, const PtEtaPhiMVector &nu1, const int &type2, const PtEtaPhiMVector &vis2, const PtEtaPhiMVector &nu2)
std::vector< TF1 * > m_paramVectorAngle
static double TauProbabilityWrapper(MissingMassProb *prob, MissingMassInput &preparedInput, const int &tau_type1, const int &tau_type2, const PtEtaPhiMVector &tauvec1, const PtEtaPhiMVector &tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector &nuvec2)
double MetProbability(MissingMassInput &preparedInput, const double &met1, const double &met2, const double &MetSigma1, const double &MetSigma2)
static thread_local double s_fit_param[2][3][6][5]
static double MnuProbabilityNewWrapper(MissingMassProb *prob, MissingMassInput &preparedInput, const int &tau_type1, const int &tau_type2, const PtEtaPhiMVector &tauvec1, const PtEtaPhiMVector &tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector &nuvec2)
static double mEtAndTauProbabilityWrapper(MissingMassProb *prob, MissingMassInput &preparedInput, const int &tau_type1, const int &tau_type2, const PtEtaPhiMVector &tauvec1, const PtEtaPhiMVector &tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector &nuvec2)
static double MetProbabilityWrapper(MissingMassProb *prob, MissingMassInput &preparedInput, const int &tau_type1, const int &tau_type2, const PtEtaPhiMVector &tauvec1, const PtEtaPhiMVector &tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector &nuvec2)
static double dTheta3d_probabilityNewWrapper(MissingMassProb *prob, MissingMassInput &preparedInput, const int &tau_type1, const int &tau_type2, const PtEtaPhiMVector &tauvec1, const PtEtaPhiMVector &tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector &nuvec2)
std::vector< TF1 * > m_paramVectorRatio
static double MnuProbabilityWrapper(MissingMassProb *prob, MissingMassInput &preparedInput, const int &tau_type1, const int &tau_type2, const PtEtaPhiMVector &tauvec1, const PtEtaPhiMVector &tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector &nuvec2)
double mEtAndTauProbability(MissingMassInput &preparedInput)
double MnuProbability(MissingMassInput &preparedInput, double mnu, double binsize)
void setParamAngle(const PtEtaPhiMVector &tauvec, int tau, int tautype)
std::vector< TF1 * > m_paramVectorAngleLep
MMCCalibrationSet::e m_mmcCalibrationSet
double apply(MissingMassInput &preparedInput, const int &tau_type1, const int &tau_type2, const PtEtaPhiMVector &tauvec1, const PtEtaPhiMVector &tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector &nuvec2, bool constant=false, bool oneTau=false, bool twoTau=false)
static double TauProbabilityNewWrapper(MissingMassProb *prob, MissingMassInput &preparedInput, const int &tau_type1, const int &tau_type2, const PtEtaPhiMVector &tauvec1, const PtEtaPhiMVector &tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector &nuvec2)
std::list< std::function< double(MissingMassInput &preparedInput, const int &tau_type1, const int &tau_type2, const PtEtaPhiMVector &tauvec1, const PtEtaPhiMVector &tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector &nuvec2)> > m_probListOneTau
std::list< std::function< double(MissingMassInput &preparedInput, const int &tau_type1, const int &tau_type2, const PtEtaPhiMVector &tauvec1, const PtEtaPhiMVector &tauvec2, const PtEtaPhiMVector nuvec1, const PtEtaPhiMVector &nuvec2)> > m_probListTwoTau
double myDelThetaHadFunc(double *x, double *par)
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
double Angle(const VectorType1 &vec1, const VectorType2 &vec2)
double mT(const VectorType &vec, const XYVector &met_vec)
void readInParams(TDirectory *dir, MMCCalibrationSet::e aset, std::vector< TF1 * > &lep_numass, std::vector< TF1 * > &lep_angle, std::vector< TF1 * > &lep_ratio, std::vector< TF1 * > &had_angle, std::vector< TF1 * > &had_ratio)
constexpr double tauMassInMeV
the mass of the tau (in MeV)