From 46ab38a7e8594ff3565b4a97143121217590fb0b Mon Sep 17 00:00:00 2001 From: nshadskiy Date: Mon, 6 May 2024 16:50:46 +0200 Subject: [PATCH 1/5] implemention of electron energy uncertainties for MC --- .../2016postVFP_UL/EGM_ScaleUnc.json.gz | Bin 0 -> 1131 bytes .../2016preVFP_UL/EGM_ScaleUnc.json.gz | Bin 0 -> 1128 bytes .../2017_UL/EGM_ScaleUnc.json.gz | Bin 0 -> 1098 bytes .../2018_UL/EGM_ScaleUnc.json.gz | Bin 0 -> 1106 bytes include/physicsobjects.hxx | 5 ++ src/physicsobjects.cxx | 75 ++++++++++++++++++ 6 files changed, 80 insertions(+) create mode 100644 data/electron_energy_scale_patch/2016postVFP_UL/EGM_ScaleUnc.json.gz create mode 100644 data/electron_energy_scale_patch/2016preVFP_UL/EGM_ScaleUnc.json.gz create mode 100644 data/electron_energy_scale_patch/2017_UL/EGM_ScaleUnc.json.gz create mode 100644 data/electron_energy_scale_patch/2018_UL/EGM_ScaleUnc.json.gz diff --git a/data/electron_energy_scale_patch/2016postVFP_UL/EGM_ScaleUnc.json.gz b/data/electron_energy_scale_patch/2016postVFP_UL/EGM_ScaleUnc.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..bd04e94eedf6f68af3082c96ee50a2517bf52312 GIT binary patch literal 1131 zcmV-x1eE(9iwFp}w~k`~14TzoUsGdYY-Lq$V=iiQZ*BnXTFGwPIuzaaEAI2E1zcNB zn`T(NO`G-wXaEBlHV;9;%GVYVnN&&2u2JOQOAS$FTOK3|Eu7wiEM$rI+<~MH#qh@q zu;^$%z$yDOL#4SCopU(qW)DWFeZ?b_-R;~2s1cY#FabgoNFxPYe(1uGf5#AJXe2N( zg7?=KcW~{q5aA>9jZ_+53OVJ1gl~rJs*|m`9b!p z|CNjWjN`oj{_47a@#$)ql3jlI&yo*K_Dgs2e)6SK=qE{N+fV?jafu# z8*P*w9-CUNq@NJ>wU2@+F3$nKv#IUGELnv%*KTrs0%-is8sX!*j~(&fvG67dv&|H= zj-$TTNl!r=F`{9+;#0`NHe5{@7rT7fNnYV<>CXMi_>!@)1I!w)yDwbFYcpd#!;0rC zwV$yt#^lAdI%Sqaeq5b{cFJrBPmb^@2A>(6NVTYnBb`E9W`uod2!p~@PO=2mJ(HR~ z;38ozP52Fcl(tSwP?=1V#Hy3rK5dHjyK*jLd$+ z8Mf@+;JA6&5_|8&mEcd?yCyI={;eH9w%={((o`v_>c2D}Ygtq*W4EEP4!$E91d_q# zG$eyL0m)!}*s>4YB*0NY4%vJ_;+LcOM<9tGkoYyHA@R!zNc`%*B063KVpsn9L zW8vGo^?u`hH{Tvo+hCJA`R@a5Q~v^OQ_~Wq9%zYD1}#zQqLn3z*E>5qb@)n6?9Yx| z3I4RbYXYaVP5lJgrY0Gz1(LxsNCxYoH5qi107nHmXmb+39JEbM;#UhKer1sO)kRz4 zcj6=fr+=yS$ukzdXR=LQef+-CjCQFjUC}OenS)j+4QXhFk`vGhr9M2z!_=PZS!B=g zFmx;St_jd#>H@S&O)^*uB!gv;4AwyVzZZOyY;)v48NXdSNAU-e*%{1ckFFT008c4G4=oe literal 0 HcmV?d00001 diff --git a/data/electron_energy_scale_patch/2016preVFP_UL/EGM_ScaleUnc.json.gz b/data/electron_energy_scale_patch/2016preVFP_UL/EGM_ScaleUnc.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..21ca05d869ad856bbe26f0aefd84ef5a155ed2ee GIT binary patch literal 1128 zcmV-u1eg0CiwFp}w~k`~14TzoUsGdYY-Lq$V=iiQZ*BnXTFY+RI27IYEADvJ0p^0h@oCN(5w*C_Jur5;gaTYg9sS~znLvXCX-a~~viD26{@ zfkj9A0Z!Ss87j@C=$yk*H+wKb?JFLc>~7~KK#jl@f(a0!KpH9F@>3Uv{0D|GLnDES z5q!M9xPxn-g$SRSZ=}-jTF5CEEbKxYfmAS(bMXeo_UgzRe25g@eICMXXcU95IAQ(* zM$9mcrUw_y58#1YUO5JxvW_#>E{rh3NU5iZe-khRd<+X2E1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m8}QdNX4yEkfH zHD~ULqHNCKPFkOXD~B!Tte*6@}R zaMI=^e;Jy;0+Rdz$zO9ClD~|ANpM`3@&n-w~wuF6Le*Z?Gf zMUVv6MQ0M&QUXreoa8S99a5A0)dI<15hQIn!YW@C*h3`lXsms5)FEyhx z>QYy9MqT8f9ZEwQ+M#3wv_q*6uib~#Uds=WkHMZkq<#jSQIiDL0!d&IB!P9&nFO|! zfRi>S`O83O)FgkkK=M}v$zNS`C4Vi7=C%49`H!}y52>NUGwQu9c6%we+rGQb@auVc Q_3+~9Ck;;0eo{*S01eU_HUIzs literal 0 HcmV?d00001 diff --git a/data/electron_energy_scale_patch/2018_UL/EGM_ScaleUnc.json.gz b/data/electron_energy_scale_patch/2018_UL/EGM_ScaleUnc.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..951bb89288325fcabf6d3e3911c5f431f020fe5d GIT binary patch literal 1106 zcmV-Y1g-lYiwFp}w~k`~14TzoUsGdYY-Lq$V=iiQZ*BnXT3c_^Fcg00R~-5TQfada zShojWV8A3MRodkRO~|CDjkVMcw$oCf{der7%hEQz6^QjMM;`5!0V}Fj5KQF+d zrTqXW?8g+9=2EoIq1R3?3{m@vMn6TVT(*M=cR=q`vP7C(?01pia1B2(l(UyG2+_KR2gJy>NT?^yzX_NDK7zT7l}(X_b8U_6&wACCc4|u^ zA>iWxqMJo!Y|F_5zN}35aLDzw|-`-fpA4%8T z3V*?pHQUn0b`6(MH+(VpFS? zyd7az`zV;=@*MCto7moSS-y`H-hCdl-SH`)@mp(zkLx~m#DB-a8y9AiDQF!>U9DXg zK@%~eVY}i}$igOEjTslaeA&@m;A-j2{mT6%V`FbHYrO70a~-b@iS-N%uCLU7%EB1k zjI}yemP3AA9ej4kYzR*d@hJwM85~PBFNz}>LR&_Joh^hxVG0MCLvha}rVluG%xkL}@Rl#3!HN)$&s0?4fPtI3i{h59VnXSLcgm;Kb-8<>M zt6n!p;2pWWE#N=x_>p~5OV*@HNmYK*d@N;AuzuZ!$~yR-WDrOOtJ9DSE(k~l%frp$ zr!`gJn9WZ~0H09(L68IxNC2zTkN_?SNC3;jmc2&NtaXLi>maOq2P}Mhx8Co5-_5s& z)K=K2cCQ|2tNIzVRZUBja-bzj9<)R$i$<0xUgzwrU*{p+5u6>leV?AxGtgEw$zUmv z4CX;HSQd@RV4WAX&i0NCG+Nvf2ECmw4JV*e`qA3CF*OP!FweBCV@Eyojb@BK2 zg=Vxat("UL-EGM_ScaleUnc"); + auto electron_pt_correction_lambda = + [evaluator, era, variation](const ROOT::RVec &pt_values, + const ROOT::RVec &eta, const ROOT::RVec &gain, + const ROOT::RVec &ES_sigma_up, const ROOT::RVec &ES_sigma_down) { + ROOT::RVec corrected_pt_values(pt_values.size()); + for (int i = 0; i < pt_values.size(); i++) { + if (variation == "resolutionUp") { + auto dpt = ES_sigma_down.at(i) / std::cosh(eta.at(i)); + corrected_pt_values[i] = pt_values.at(i) + dpt; + Logger::get("eleEnergyCorrection") + ->debug("ele pt before {}, ele pt after {}, dpt {}", + pt_values.at(i), corrected_pt_values.at(i), dpt); + } else if (variation == "resolutionDown") { + auto dpt = ES_sigma_down.at(i) / std::cosh(eta.at(i)); + corrected_pt_values[i] = pt_values.at(i) + dpt; + Logger::get("eleEnergyCorrection") + ->debug("ele pt before {}, ele pt after {}, dpt {}", + pt_values.at(i), corrected_pt_values.at(i), dpt); + } else if (variation == "scaleUp") { + Logger::get("eleEnergyCorrection") + ->debug("inputs: era {}, eta {}, gain {}", + era, eta.at(i), static_cast(gain.at(i))); + auto sf = evaluator->evaluate({era, "scaleup", eta.at(i), static_cast(gain.at(i))}); + corrected_pt_values[i] = pt_values.at(i) * sf; + Logger::get("eleEnergyCorrection") + ->debug("ele pt before {}, ele pt after {}, sf {}", + pt_values.at(i), corrected_pt_values.at(i), sf); + } else if (variation == "scaleDown") { + Logger::get("eleEnergyCorrection") + ->debug("inputs: era {}, eta {}, gain {}", + era, eta.at(i), static_cast(gain.at(i))); + auto sf = evaluator->evaluate({era, "scaledown", eta.at(i), static_cast(gain.at(i))}); + corrected_pt_values[i] = pt_values.at(i) * sf; + Logger::get("eleEnergyCorrection") + ->debug("ele pt before {}, ele pt after {}, sf {}", + pt_values.at(i), corrected_pt_values.at(i), sf); + } else { + corrected_pt_values[i] = pt_values.at(i); + Logger::get("eleEnergyCorrection") + ->debug("ele pt before {}, ele pt after {}", + pt_values.at(i), corrected_pt_values.at(i)); + } + } + return corrected_pt_values; + }; + auto df1 = df.Define(corrected_pt, electron_pt_correction_lambda, {pt, eta, gain, ES_sigma_up, ES_sigma_down}); + return df1; +} /// Function to cut electrons based on the electron MVA ID /// /// \param[in] df the input dataframe From abb8a0f93fb8e098660d35df16e84b7f34200848 Mon Sep 17 00:00:00 2001 From: nshadskiy Date: Mon, 6 May 2024 17:47:04 +0200 Subject: [PATCH 2/5] incorporate comment --- src/physicsobjects.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/physicsobjects.cxx b/src/physicsobjects.cxx index 9c35e993..eeee3099 100644 --- a/src/physicsobjects.cxx +++ b/src/physicsobjects.cxx @@ -1048,7 +1048,7 @@ PtCorrection(ROOT::RDF::RNode df, const std::string &corrected_pt, /// \param[in] ES_sigma_down name of electron energy smearing value 1 sigma down shifted /// \param[in] era era of the electron measurement e.g. "2018" /// \param[in] variation name of the variation to be calculated (nominal correction is already applied) -/// \param[in] ES_patch_file name of the json file with the energy scale uncertainties +/// \param[in] ES_file name of the json file with the energy scale uncertainties /// /// \return a dataframe containing the new mask ROOT::RDF::RNode @@ -1056,9 +1056,9 @@ PtCorrectionMC(ROOT::RDF::RNode df, const std::string &corrected_pt, const std::string &pt, const std::string &eta, const std::string &gain, const std::string &ES_sigma_up, const std::string &ES_sigma_down, const std::string &era, - const std::string &variation, const std::string &ES_patch_file) { + const std::string &variation, const std::string &ES_file) { auto evaluator = - correction::CorrectionSet::from_file(ES_patch_file)->at("UL-EGM_ScaleUnc"); + correction::CorrectionSet::from_file(ES_file)->at("UL-EGM_ScaleUnc"); auto electron_pt_correction_lambda = [evaluator, era, variation](const ROOT::RVec &pt_values, const ROOT::RVec &eta, const ROOT::RVec &gain, From 872fbfd7d7d3ffb65f8ecf659ab172ad07fba757 Mon Sep 17 00:00:00 2001 From: nshadskiy Date: Mon, 6 May 2024 17:49:42 +0200 Subject: [PATCH 3/5] missed name change --- include/physicsobjects.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/physicsobjects.hxx b/include/physicsobjects.hxx index 7b48e923..24aa6eab 100644 --- a/include/physicsobjects.hxx +++ b/include/physicsobjects.hxx @@ -160,7 +160,7 @@ ROOT::RDF::RNode PtCorrectionMC(ROOT::RDF::RNode df, const std::string &correcte const std::string &pt, const std::string &eta, const std::string &gain, const std::string &ES_sigma_up, const std::string &ES_sigma_down, const std::string &era, - const std::string &variation, const std::string &ES_patch_file); + const std::string &variation, const std::string &ES_file); ROOT::RDF::RNode CutID(ROOT::RDF::RNode df, const std::string &maskname, const std::string &nameID); ROOT::RDF::RNode CutCBID(ROOT::RDF::RNode df, const std::string &maskname, From 7eadb1443d189fcf91c79c8ad4babeacae7d3707 Mon Sep 17 00:00:00 2001 From: nshadskiy Date: Mon, 6 May 2024 18:03:31 +0200 Subject: [PATCH 4/5] missed name change second try --- .../2016postVFP_UL/EGM_ScaleUnc.json.gz | Bin .../2016preVFP_UL/EGM_ScaleUnc.json.gz | Bin .../2017_UL/EGM_ScaleUnc.json.gz | Bin .../2018_UL/EGM_ScaleUnc.json.gz | Bin 4 files changed, 0 insertions(+), 0 deletions(-) rename data/{electron_energy_scale_patch => electron_energy_scale}/2016postVFP_UL/EGM_ScaleUnc.json.gz (100%) rename data/{electron_energy_scale_patch => electron_energy_scale}/2016preVFP_UL/EGM_ScaleUnc.json.gz (100%) rename data/{electron_energy_scale_patch => electron_energy_scale}/2017_UL/EGM_ScaleUnc.json.gz (100%) rename data/{electron_energy_scale_patch => electron_energy_scale}/2018_UL/EGM_ScaleUnc.json.gz (100%) diff --git a/data/electron_energy_scale_patch/2016postVFP_UL/EGM_ScaleUnc.json.gz b/data/electron_energy_scale/2016postVFP_UL/EGM_ScaleUnc.json.gz similarity index 100% rename from data/electron_energy_scale_patch/2016postVFP_UL/EGM_ScaleUnc.json.gz rename to data/electron_energy_scale/2016postVFP_UL/EGM_ScaleUnc.json.gz diff --git a/data/electron_energy_scale_patch/2016preVFP_UL/EGM_ScaleUnc.json.gz b/data/electron_energy_scale/2016preVFP_UL/EGM_ScaleUnc.json.gz similarity index 100% rename from data/electron_energy_scale_patch/2016preVFP_UL/EGM_ScaleUnc.json.gz rename to data/electron_energy_scale/2016preVFP_UL/EGM_ScaleUnc.json.gz diff --git a/data/electron_energy_scale_patch/2017_UL/EGM_ScaleUnc.json.gz b/data/electron_energy_scale/2017_UL/EGM_ScaleUnc.json.gz similarity index 100% rename from data/electron_energy_scale_patch/2017_UL/EGM_ScaleUnc.json.gz rename to data/electron_energy_scale/2017_UL/EGM_ScaleUnc.json.gz diff --git a/data/electron_energy_scale_patch/2018_UL/EGM_ScaleUnc.json.gz b/data/electron_energy_scale/2018_UL/EGM_ScaleUnc.json.gz similarity index 100% rename from data/electron_energy_scale_patch/2018_UL/EGM_ScaleUnc.json.gz rename to data/electron_energy_scale/2018_UL/EGM_ScaleUnc.json.gz From cf2dc31692eb53c65de711c50c5fc6fbadbca84b Mon Sep 17 00:00:00 2001 From: nshadskiy Date: Wed, 8 May 2024 10:23:29 +0200 Subject: [PATCH 5/5] fix electron ES resolution up variation --- src/physicsobjects.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/physicsobjects.cxx b/src/physicsobjects.cxx index eeee3099..79e8bd07 100644 --- a/src/physicsobjects.cxx +++ b/src/physicsobjects.cxx @@ -1066,7 +1066,7 @@ PtCorrectionMC(ROOT::RDF::RNode df, const std::string &corrected_pt, ROOT::RVec corrected_pt_values(pt_values.size()); for (int i = 0; i < pt_values.size(); i++) { if (variation == "resolutionUp") { - auto dpt = ES_sigma_down.at(i) / std::cosh(eta.at(i)); + auto dpt = ES_sigma_up.at(i) / std::cosh(eta.at(i)); corrected_pt_values[i] = pt_values.at(i) + dpt; Logger::get("eleEnergyCorrection") ->debug("ele pt before {}, ele pt after {}, dpt {}",