00001
00002 #ifndef muon_SF_EPS_h
00003 #define muon_SF_EPS_h
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <iostream>
00033 #include <math.h>
00034
00035
00036 double mu_trigger_SF(double eta, double phi, double pt);
00037 double mu_trigger_SF_err(double eta, double phi, double pt, bool isUp);
00038 double mu_trigger_eff(double eta, double phi, double pt);
00039 double mu_trigger_eff_err(double eta, double phi, double pt, bool isUp);
00040
00041 double mu_ID_SF();
00042 double mu_ID_SF_err();
00043 double mu_ID_SF_staterr();
00044 double mu_ID_SF_systerr();
00045 double check_phi_range(double phi);
00046 void printWarning();
00047
00048
00049 double mu_recoID_SF();
00050 double mu_recoID_SF_err();
00051 double mu_recoID_SF_staterr();
00052 double mu_recoID_SF_systerr();
00053
00054
00055
00056 double mu_trigger_SF(double eta, double phi, double pt)
00057 {
00058
00059 double mu_eta = eta;
00060 double mu_phi = check_phi_range(phi);
00061 double mu_pt = pt;
00062 int etaI=-1, phiI=-1;
00063
00064 const double pi = acos(-1.);
00065
00066 const double EC_eta = 1.05;
00067 const double etabins[7] = {-1.05,-0.75,-0.45,-0.15,0.15,0.45,0.75};
00068 const double phibins[3] = {-pi,0.,pi/2.};
00069
00070 const double EC_SF_pos = 1.0140;
00071 const double EC_SF_neg = 1.0097;
00072 const double trig_SFmatrix_lo[7][3] = {{1.0388,1.0660,1.0388},
00073 {1.0196,1.0660,1.0196},
00074 {0.9996,1.0660,0.9996},
00075 {1.0315,1.0315,1.0315},
00076 {1.0026,1.0026,1.0026},
00077 {0.9070,1.0369,1.0369},
00078 {0.9070,0.9946,0.9946}};
00079 const double trig_SFmatrix_mid[7][3] = {{1.0893,1.1525,1.0893},
00080 {1.0767,1.1525,1.0767},
00081 {1.0880,1.1525,1.0880},
00082 {1.1071,1.1071,1.1071},
00083 {1.0609,1.0609,1.0609},
00084 {0.9400,1.1205,1.1205},
00085 {0.9400,1.0684,1.0684}};
00086 const double trig_SFmatrix_hi[7][3] = {{1.3432,0.8027,1.3432},
00087 {1.1803,0.8027,1.1803},
00088 {0.9868,0.8027,0.9868},
00089 {1.2126,1.2126,1.2126},
00090 {0.8520,0.8520,0.8520},
00091 {1.5726,1.2885,1.2885},
00092 {1.5726,1.3099,1.3099}};
00093
00094 if ( mu_eta > EC_eta )
00095 return EC_SF_pos;
00096 else if ( mu_eta < -EC_eta)
00097 return EC_SF_neg;
00098 else {
00099
00100 for (int i=2; i>=0; i--){
00101 if ( mu_phi > phibins[i] ) {
00102 phiI = i;
00103 break;
00104 }
00105 }
00106 for (int i=6; i>=0; i--){
00107 if ( mu_eta > etabins[i] ) {
00108 etaI = i;
00109 break;
00110 }
00111 }
00112
00113 if (mu_pt < 60.)
00114 return trig_SFmatrix_lo[etaI][phiI];
00115 else if (mu_pt < 120.)
00116 return trig_SFmatrix_mid[etaI][phiI];
00117 else
00118 return trig_SFmatrix_hi[etaI][phiI];
00119
00120 }
00121
00122 return 0;
00123 }
00124
00125
00126 double mu_trigger_SF_err(double eta, double phi, double pt, bool isUp)
00127 {
00128
00129 double mu_eta = eta;
00130 double mu_phi = check_phi_range(phi);
00131 double mu_pt = pt;
00132 int etaI=-1, phiI=-1;
00133
00134 const double pi = acos(-1.);
00135
00136 const double EC_eta = 1.05;
00137 const double etabins[7] = {-1.05,-0.75,-0.45,-0.15,0.15,0.45,0.75};
00138 const double phibins[3] = {-pi,0.,pi/2.};
00139
00140 const double EC_SF_pos_up = 0.07000;
00141 const double EC_SF_pos_down = 0.07000;
00142 const double EC_SF_neg_up = 0.07000;
00143 const double EC_SF_neg_down = 0.07000;
00144
00145 const double trig_SFmatrix_up_lo[7][3] = {{0.00644,0.00543,0.00644},
00146 {0.00577,0.00543,0.00577},
00147 {0.07000,0.00543,0.07000},
00148 {0.00609,0.00609,0.00609},
00149 {0.00459,0.00459,0.00459},
00150 {0.07000,0.07000,0.07000},
00151 {0.07000,0.07000,0.07000}};
00152
00153 const double trig_SFmatrix_down_lo[7][3] = {{0.00640,0.00528,0.00640},
00154 {0.00609,0.00536,0.00609},
00155 {0.07000,0.00536,0.07000},
00156 {0.00615,0.00615,0.00615},
00157 {0.00473,0.00473,0.00473},
00158 {0.07000,0.07000,0.07000},
00159 {0.07000,0.07000,0.07000}};
00160
00161 const double trig_SFmatrix_up_mid[7][3] = {{0.03443,0.02918,0.03443},
00162 {0.03345,0.02918,0.03345},
00163 {0.03101,0.02918,0.03101},
00164 {0.03677,0.03677,0.03677},
00165 {0.07492,0.07492,0.07492},
00166 {0.03053,0.03296,0.03296},
00167 {0.03053,0.07998,0.07998}};
00168
00169 const double trig_SFmatrix_down_mid[7][3] = {{0.03426,0.03131,0.03426},
00170 {0.03308,0.03131,0.03308},
00171 {0.03456,0.03131,0.03456},
00172 {0.03503,0.03503,0.03503},
00173 {0.07483,0.07483,0.07483},
00174 {0.02877,0.03211,0.03211},
00175 {0.02877,0.08131,0.08131}};
00176
00177 const double trig_SFmatrix_up_hi[7][3] = {{0.1446,0.2084,0.1446},
00178 {0.1480,0.2084,0.1480},
00179 {0.1622,0.2084,0.1621},
00180 {0.1445,0.1445,0.1445},
00181 {0.1512,0.1512,0.1512},
00182 {0.1487,0.1704,0.1704},
00183 {0.1487,0.1763,0.1763}};
00184
00185 const double trig_SFmatrix_down_hi[7][3] = {{0.3481,0.1229,0.3481},
00186 {0.1426,0.1229,0.1426},
00187 {0.1677,0.1229,0.1677},
00188 {0.2142,0.2142,0.2142},
00189 {0.1490,0.1490,0.1490},
00190 {0.2493,0.2549,0.2549},
00191 {0.2493,0.1763,0.1763}};
00192
00193
00194 if ( mu_eta > EC_eta && isUp)
00195 return EC_SF_pos_up;
00196 else if ( mu_eta > EC_eta && !isUp)
00197 return EC_SF_pos_down;
00198 else if ( mu_eta < -EC_eta && isUp)
00199 return EC_SF_neg_up;
00200 else if ( mu_eta < -EC_eta && !isUp)
00201 return EC_SF_neg_down;
00202 else {
00203
00204 for (int i=2; i>=0; i--){
00205 if ( mu_phi > phibins[i] ) {
00206 phiI = i;
00207 break;
00208 }
00209 }
00210 for (int i=6; i>=0; i--){
00211 if ( mu_eta > etabins[i] ) {
00212 etaI = i;
00213 break;
00214 }
00215 }
00216
00217 if (mu_pt < 60.) {
00218 if (isUp)
00219 return trig_SFmatrix_up_lo[etaI][phiI];
00220 else
00221 return trig_SFmatrix_down_lo[etaI][phiI];
00222 } else if (mu_pt < 120.) {
00223 if (isUp)
00224 return trig_SFmatrix_up_mid[etaI][phiI];
00225 else
00226 return trig_SFmatrix_down_mid[etaI][phiI];
00227 } else {
00228 if (isUp)
00229 return trig_SFmatrix_up_hi[etaI][phiI];
00230 else
00231 return trig_SFmatrix_down_hi[etaI][phiI];
00232 }
00233
00234 }
00235
00236 return 0;
00237 }
00238
00239
00240 double mu_trigger_eff(double eta, double phi, double pt)
00241 {
00242
00243 double mu_eta = eta;
00244 double mu_phi = check_phi_range(phi);
00245 double mu_pt = pt;
00246 int etaI=-1, phiI=-1;
00247
00248 const double pi = acos(-1.);
00249
00250 const double EC_eta = 1.05;
00251 const double etabins[7] = {-1.05,-0.75,-0.45,-0.15,0.15,0.45,0.75};
00252 const double phibins[3] = {-pi,0.,pi/2.};
00253
00254 const double EC_eff_neg = 0.851779;
00255 const double EC_eff_pos = 0.859177;
00256 const double trig_effmatrix_lo[7][3] = { { 0.639896, 0.803655, 0.639896 },
00257 { 0.713710, 0.803655, 0.713710 },
00258 { 0.749295, 0.803655, 0.749295 },
00259 { 0.687885, 0.687885, 0.687885 },
00260 { 0.769332, 0.769332, 0.769332 },
00261 { 0.598131, 0.854731, 0.854731 },
00262 { 0.598131, 0.707926, 0.707926 } };
00263 const double trig_effmatrix_mid[7][3] = { { 0.642045, 0.826613, 0.642045 },
00264 { 0.707965, 0.826613, 0.707965 },
00265 { 0.776952, 0.826613, 0.776952 },
00266 { 0.720978, 0.720978, 0.720978 },
00267 { 0.789398, 0.789398, 0.789398 },
00268 { 0.579767, 0.887931, 0.887931 },
00269 { 0.579767, 0.721068, 0.721068 } };
00270 const double trig_effmatrix_hi[7][3] = { { 0.720000, 0.769231, 0.720000 },
00271 { 0.782609, 0.769231, 0.782609 },
00272 { 0.695652, 0.769231, 0.695652 },
00273 { 0.708333, 0.708333, 0.708333 },
00274 { 0.586207, 0.586207, 0.586207 },
00275 { 0.560000, 0.909091, 0.909091 },
00276 { 0.560000, 0.666667, 0.666667 } };
00277
00278 if ( mu_eta > EC_eta )
00279 return EC_eff_pos;
00280 else if ( mu_eta < -EC_eta)
00281 return EC_eff_neg;
00282 else {
00283
00284 for (int i=2; i>=0; i--){
00285 if ( mu_phi > phibins[i] ) {
00286 phiI = i;
00287 break;
00288 }
00289 }
00290 for (int i=6; i>=0; i--){
00291 if ( mu_eta > etabins[i] ) {
00292 etaI = i;
00293 break;
00294 }
00295 }
00296
00297 if (mu_pt < 60.)
00298 return trig_effmatrix_lo[etaI][phiI];
00299 else if (mu_pt < 120.)
00300 return trig_effmatrix_mid[etaI][phiI];
00301 else
00302 return trig_effmatrix_hi[etaI][phiI];
00303
00304 }
00305
00306 return 0;
00307 }
00308
00309
00310 double mu_trigger_eff_err(double eta, double phi, double pt, bool isUp)
00311 {
00312
00313 double mu_eta = eta;
00314 double mu_phi = check_phi_range(phi);
00315 double mu_pt = pt;
00316 int etaI=-1, phiI=-1;
00317
00318 const double pi = acos(-1.);
00319
00320 const double EC_eta = 1.05;
00321 const double etabins[7] = {-1.05,-0.75,-0.45,-0.15,0.15,0.45,0.75};
00322 const double phibins[3] = {-pi,0.,pi/2.};
00323
00324 const double EC_eff_pos_up = 0.00215;
00325 const double EC_eff_pos_down = 0.00206;
00326 const double EC_eff_neg_up = 0.00213;
00327 const double EC_eff_neg_down = 0.00208;
00328
00329 const double trig_effmatrix_up_lo[7][3] = {{0.00644,0.00543,0.00644},
00330 {0.00577,0.00543,0.00577},
00331 {0.00527,0.00543,0.00527},
00332 {0.00609,0.00609,0.00609},
00333 {0.00459,0.00459,0.00459},
00334 {0.00578,0.00613,0.00613},
00335 {0.00578,0.00726,0.00726}};
00336 const double trig_effmatrix_down_lo[7][3] = {{0.00640,0.00528,0.00640},
00337 {0.00609,0.00536,0.00609},
00338 {0.00533,0.00536,0.00533},
00339 {0.00615,0.00615,0.00615},
00340 {0.00473,0.00473,0.00473},
00341 {0.00524,0.00581,0.00581},
00342 {0.00524,0.00739,0.00739}};
00343
00344 const double trig_effmatrix_up_mid[7][3] = {{0.03443,0.02918,0.03443},
00345 {0.03345,0.02918,0.03345},
00346 {0.03101,0.02918,0.03101},
00347 {0.03677,0.03677,0.03677},
00348 {0.02670,0.02670,0.02670},
00349 {0.03053,0.03296,0.03296},
00350 {0.03053,0.03869,0.03869}};
00351 const double trig_effmatrix_down_mid[7][3] = {{0.03426,0.03131,0.03426},
00352 {0.03308,0.03131,0.03308},
00353 {0.03456,0.03131,0.03456},
00354 {0.03503,0.03503,0.03503},
00355 {0.02646,0.02646,0.02646},
00356 {0.02877,0.03211,0.03211},
00357 {0.02877,0.04138,0.04138}};
00358
00359 const double trig_effmatrix_up_hi[7][3] = {{0.1446,0.1963,0.1446},
00360 {0.1480,0.1963,0.1480},
00361 {0.1463,0.1963,0.1463},
00362 {0.1445,0.1445,0.1445},
00363 {0.1340,0.1340,0.1340},
00364 {0.1312,0.1704,0.1704},
00365 {0.1312,0.1763,0.1763}};
00366 const double trig_effmatrix_down_hi[7][3] = {{0.3481,0.1010,0.3481},
00367 {0.1426,0.1010,0.1426},
00368 {0.1524,0.1010,0.1524},
00369 {0.2142,0.2142,0.2142},
00370 {0.1315,0.1315,0.1315},
00371 {0.2393,0.2549,0.2549},
00372 {0.2393,0.1763,0.1763}};
00373
00374
00375 const Double_t fac = 10.0;
00376 if ( mu_eta > EC_eta && isUp)
00377 return fac * EC_eff_pos_up;
00378 else if ( mu_eta > EC_eta && !isUp)
00379 return fac * EC_eff_pos_down;
00380 else if ( mu_eta < -EC_eta && isUp)
00381 return fac * EC_eff_neg_up;
00382 else if ( mu_eta < -EC_eta && !isUp)
00383 return fac * EC_eff_neg_down;
00384 else {
00385
00386 for (int i=2; i>=0; i--){
00387 if ( mu_phi > phibins[i] ) {
00388 phiI = i;
00389 break;
00390 }
00391 }
00392 for (int i=6; i>=0; i--){
00393 if ( mu_eta > etabins[i] ) {
00394 etaI = i;
00395 break;
00396 }
00397 }
00398
00399 if (mu_pt < 60.) {
00400 if (isUp)
00401 return fac * trig_effmatrix_up_lo[etaI][phiI];
00402 else
00403 return fac * trig_effmatrix_down_lo[etaI][phiI];
00404 } else if (mu_pt < 120.) {
00405 if (isUp)
00406 return fac * trig_effmatrix_up_mid[etaI][phiI];
00407 else
00408 return fac * trig_effmatrix_down_mid[etaI][phiI];
00409 } else {
00410 if (isUp)
00411 return fac * trig_effmatrix_up_hi[etaI][phiI];
00412 else
00413 return fac * trig_effmatrix_down_hi[etaI][phiI];
00414 }
00415
00416 }
00417
00418 return 0;
00419 }
00420
00421
00422 double mu_recoID_SF()
00423 {
00424
00425 printWarning();
00426 return -99.;
00427
00428 }
00429
00430
00431 double mu_recoID_SF_err()
00432 {
00433
00434 printWarning();
00435 return -99.;
00436
00437 }
00438
00439
00440 double mu_recoID_SF_staterr()
00441 {
00442
00443 printWarning();
00444 return -99.;
00445
00446 }
00447
00448
00449 double mu_recoID_SF_systerr()
00450 {
00451
00452 printWarning();
00453 return -99.;
00454
00455 }
00456
00457
00458
00459
00460 double mu_ID_SF()
00461 {
00462
00463 const double ID_SF = 1.0008;
00464 return ID_SF;
00465
00466 }
00467
00468
00469 double mu_ID_SF_err()
00470 {
00471
00472 double staterr, systerr, toterr;
00473
00474 staterr = mu_ID_SF_staterr();
00475 systerr = mu_ID_SF_systerr();
00476
00477 toterr = sqrt(pow(staterr,2) + pow(systerr,2));
00478
00479 return toterr;
00480
00481 }
00482
00483
00484 double mu_ID_SF_staterr()
00485 {
00486
00487 const double SFerr = 0.0003;
00488 return SFerr;
00489
00490 }
00491
00492
00493 double mu_ID_SF_systerr()
00494 {
00495
00496 const double SFerr = 0.0003;
00497 return SFerr;
00498
00499 }
00500
00501
00502 double check_phi_range(double phi)
00503 {
00504
00505 double newphi = phi;
00506 const double pi = acos(-1.);
00507
00508 if (newphi > pi) {
00509 printf("<muon_SF>: WARNING: Muon phi %4.2f > pi! Using (phi-2*pi) \n", phi);
00510 newphi -= 2*pi;
00511 }
00512 if (newphi < -pi) {
00513 printf("<muon_SF>: WARNING: Muon phi %4.2f < -pi! Using (phi+2*pi) \n", phi);
00514 newphi += 2*pi;
00515 }
00516
00517 return newphi;
00518 }
00519
00520 void printWarning()
00521 {
00522
00523 printf("<muon_SF>: WARNING: Reco SFs no longer provided by this tool! Use MCP group tool instead.\n");
00524 printf("<muon_SF>: See https://twiki.cern.ch/twiki/bin/view/AtlasProtected/MCPAnalysisGuidelinesRel16\n");
00525 return;
00526
00527 }
00528
00529 #endif