8 #include "TGraphAsymmErrors.h"
28 const float GeV(1000);
39 m_corr_ddshift_file(
""),
40 m_corr_ddsmearing_file(
""),
44 m_correct_etcone(false),
45 m_trouble_categories(false),
46 m_useLogLogFit(false),
49 m_previousYear(
"2000")
52 for (
int i = 0;
i < 3;
i++) {
54 for (
int j = 0; j < 2; j++)
75 return StatusCode::SUCCESS;
85 return corrected_isolation;
108 float isolation_ptcorrection = 0;
112 if (
input.caloCluster() ==
nullptr) {
113 ATH_MSG_WARNING(
"The associated cluster of the object does not exist ! Maybe the thinning was too agressive... No leakage correction computed.");
117 energy =
input.caloCluster()->energyBE(1) +
input.caloCluster()->energyBE(2) +
input.caloCluster()->energyBE(3);
123 bool convFlag =
false;
125 float etaS2 =
input.caloCluster()->etaBE(2);
126 float etaS1 =
input.caloCluster()->etaBE(1);
127 float etaCluster =
input.caloCluster()->eta();
128 float phiCluster =
input.caloCluster()->phi();
133 if(fabs(etaS1) > 2.5)
return 0.;
134 if(fabs(phiCluster) >
float(
M_PI))
return 0.;
139 int convFlag_int = 0;
140 float conv_radius = 0.;
141 float conv_ratio = 0.;
147 if(convFlag_int == 3 ) convFlag_int = 2;
148 else if(convFlag_int != 0) convFlag_int = 1;
150 if(convFlag_int != 0) convFlag =
true;
153 if(convFlag_int == 2){
161 float pt1conv, pt2conv;
163 pt1conv = accPt1(*phVertex);
164 pt2conv = accPt2(*phVertex);
170 if(pt1conv > pt2conv) conv_ratio = pt2conv/pt1conv;
171 else conv_ratio = pt1conv/pt2conv;
186 if (!etaPointing.has_value())
return 0.;
217 return isolation_ptcorrection;
223 for (
unsigned int i = 0;
i <
tp->numberOfParameters(); ++
i)
225 return hypot(
tp->parameterPX(
i),
tp->parameterPY(
i));
233 ATH_MSG_WARNING(
"IsolationCorrection::GetDDCorrection " <<
year <<
", unknown correction file name.\nNo correction is applied.\n");
234 return StatusCode::FAILURE;
237 int ii =
year ==
"2017" ? 2 : (
year ==
"2015_2016" ? 1 : 0);
241 return StatusCode::SUCCESS;
246 if (
year ==
"2015") {
253 }
else if (
year ==
"2015_2016") {
260 }
else if (
year ==
"2017") {
268 ATH_MSG_WARNING(
"Year " <<
year <<
" is not known in IsolationCorrection ! Check your input ! No correction is applied");
269 return StatusCode::FAILURE;
276 std::unique_ptr< TFile > file_ptleakagecorr( TFile::Open(
m_corr_ddshift_file.c_str(),
"READ" ) );
277 if (!file_ptleakagecorr) {
279 return StatusCode::FAILURE;
282 TVector *veta = (TVector*)file_ptleakagecorr->Get(baseN+
"/etaBinning");
284 for (
int ieta = 0; ieta < veta->GetNrows(); ieta++)
m_feta_bins_dd->at(ieta) = (*veta)[ieta];
285 TTree *tbinLabel = (TTree*)file_ptleakagecorr->Get(baseN+
"tbinLabel");
286 TBranch *bbinLabel(
nullptr);
287 TString *binLabel(
nullptr); tbinLabel->SetBranchAddress(
"binLabel",&binLabel,&bbinLabel);
288 for (
unsigned int ieta = 0; ieta <
m_feta_bins_dd->size()-2; ieta++) {
289 tbinLabel->GetEntry(ieta);
290 TString gN =
"topoETcone40_DataDriven_unconverted_photon_eta_";
293 gN =
"topoETcone40_DataDriven_converted_photon_eta_";
296 gN =
"topoETcone20_DataDriven_unconverted_photon_eta_";
299 gN =
"topoETcone20_DataDriven_converted_photon_eta_";
312 return StatusCode::SUCCESS;
331 float etaS2 =
input.eta();
334 double feta = fabs(etaS2);
345 ATH_MSG_WARNING(
"Strange cluster S2 eta for photon isolation DD correction ! eta = " << etaS2 <<
". No correction");
351 <<
" eta: " << etaS2 <<
" etabin: " <<
eta_bin);
353 float pt_gev =
input.pt()*0.001;
354 if (pt_gev > 999.) pt_gev = 999. ;
356 float isolation_ddcorrection = 0;
359 isolation_ddcorrection = 1
e3*(*m_graph_dd_cone40_unconv_photon_shift)[
eta_bin]->Eval(pt_gev);
361 isolation_ddcorrection = 1
e3*(*m_graph_dd_cone40_conv_photon_shift)[
eta_bin]->Eval(pt_gev);
364 isolation_ddcorrection = 1
e3*(*m_graph_dd_cone20_unconv_photon_shift)[
eta_bin]->Eval(pt_gev);
366 isolation_ddcorrection = 1
e3*(*m_graph_dd_cone20_conv_photon_shift)[
eta_bin]->Eval(pt_gev);
369 return isolation_ddcorrection;
373 if (
input->caloCluster() ==
nullptr) {
374 ATH_MSG_WARNING(
"The associated cluster of the object does not exist ! Maybe the thinning was too agressive... use object eta for eta (instead of etaS2 or pointing).");
377 float etaS1 =
input->caloCluster()->etaBE(1);
378 float etaS2 =
input->caloCluster()->etaBE(2);
379 float phiCluster =
input->caloCluster()->phi();
384 if(fabs(etaS1) > 2.5)
return 0.;
385 if(fabs(phiCluster) > 3.2)
return 0.;
389 return etaPointing.value_or(0.);
423 m_eta_bins_fine = {0.0, 0.10, 0.60, 0.80, 1.15, 1.37, 1.52, 1.81, 2.01, 2.37, 2.47};
492 ATH_MSG_WARNING(
"Correction file for 2017 data/mc not specified, tool not initialized for 2017 corrections\n");
497 std::unique_ptr<TFile> file_ptleakagecorr(TFile::Open(
m_corr_file.c_str(),
"READ"));
498 if(!file_ptleakagecorr){
499 ATH_MSG_WARNING(
"Correction file for 2012 data/mc not found, tool not initialized for 2012 corrections\n");
525 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin0_extrap") );
526 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin1_extrap") );
527 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin2_extrap") );
528 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin3_extrap") );
529 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin4_extrap") );
530 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin5_extrap") );
531 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin6_extrap") );
532 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin7_extrap") );
533 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin8_extrap") );
534 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin9_extrap") );
558 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin0_extrap") );
559 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin1_extrap") );
560 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin2_extrap") );
561 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin3_extrap") );
562 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin4_extrap") );
563 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin5_extrap") );
564 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin6_extrap") );
565 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin7_extrap") );
566 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin8_extrap") );
567 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin9_extrap") );
591 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin0_extrap") );
592 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin1_extrap") );
593 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin2_extrap") );
594 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin3_extrap") );
595 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin4_extrap") );
596 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin5_extrap") );
597 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin6_extrap") );
598 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin7_extrap") );
599 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin8_extrap") );
600 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin9_extrap") );
608 ATH_MSG_WARNING(
"Correction file for 2015 data/mc not specified, tool not initialized for 2015 corrections\n");
613 std::unique_ptr<TFile> file_ptleakagecorr(TFile::Open(
m_corr_file.c_str(),
"READ"));
614 if(!file_ptleakagecorr){
615 ATH_MSG_WARNING(
"Correction file for 2015 data/mc not found, "<<
m_corr_file<<
". tool not initialized for 2015 corrections\n");
618 if(!file_ptleakagecorr->GetListOfKeys()->Contains(
"mean_f_topoetcone40_eta_1.15_1.37_converted_ok")){
619 ATH_MSG_ERROR(
"Correction file for 2015 data/mc is not right, "<<
m_corr_file<<
". Tool not initialized for 2015 corrections\n");
627 static const int nEta = 10;
628 static const TString etaLab[
nEta] = {
"0.0_0.1",
"0.1_0.6",
"0.6_0.8",
"0.8_1.15",
"1.15_1.37",
"1.37_1.52",
"1.52_1.81",
"1.81_2.01",
"2.01_2.37",
"2.37_2.47" };
629 static const TString pLab[5] = {
"_unconverted",
"_converted_ok",
"_converted_trouble",
"_author_1_electron",
"_author_16_electron" };
630 static const TString dRLab[3] = {
"20",
"30",
"40" };
659 for (
int iPart = 0; iPart < 5; iPart++) {
664 if (iPart < 3 && (
iEta == 5 ||
iEta == 9))
667 for (
int idR = 0; idR < 3; idR++) {
669 TString fN = (
m_useLogLogFit && iPart < 2) ?
"mean_flog_histo_topoetcone" :
"mean_f_topoetcone";
670 fN += dRLab[idR]; fN +=
"_eta_"; fN += etaLab[
iEta]; fN += pLab[iPart];
675 gN =
"mean_g_histo_topoetcone"; gN += dRLab[idR]; gN +=
"_eta_"; gN += etaLab[
iEta]; gN += pLab[iPart];
681 }
else if (iPart == 1) {
684 }
else if (iPart == 2) {
691 }
else if (iPart == 3) {
694 }
else if (iPart == 4) {
703 }
else if (idR == 1) {
707 }
else if (iPart == 1) {
710 }
else if (iPart == 2) {
717 }
else if (iPart == 3) {
720 }
else if (iPart == 4) {
733 }
else if (iPart == 1) {
736 }
else if (iPart == 2) {
743 }
else if (iPart == 3) {
746 }
else if (iPart == 4) {
770 ATH_MSG_WARNING(
"Data-driven correction files not specified, tool not initialized for data-driven corrections\n");
775 std::unique_ptr< TFile > file_ddshift_corr( TFile::Open(
m_corr_ddshift_file.c_str(),
"READ" ) );
778 if(!file_ddshift_corr || !file_ddsmearingcorr){
779 ATH_MSG_WARNING(
"Correction file for data-driven corrections not found, tool not initialized for data-driven corrections\n");
790 std::vector< std::shared_ptr<TGraphAsymmErrors> > graph_shift;
792 std::vector< std::shared_ptr<TGraphAsymmErrors> > graph_smearing;
793 for (
int ig = 0; ig <= 13; ig++) {
794 graph_shift.emplace_back(
dynamic_cast<TGraphAsymmErrors*
>(file_ddshift_corr->Get(Form(
"graph_%i",ig))) );
795 graph_smearing.emplace_back(
dynamic_cast<TGraphAsymmErrors*
>(file_ddsmearingcorr->Get(Form(
"graph_%i",ig))) );
797 for (
int ig = 0; ig <= 13; ig++) {
805 for (
const auto&
gr : graph_shift) {
807 ATH_MSG_ERROR(
"Null pointer for one of the DD correction graphs");
809 for (
const auto&
gr : graph_smearing) {
811 ATH_MSG_ERROR(
"Null pointer for one of the smearing graphs");
819 it != cntr.end(); ++
it ) {
967 return Etcone_value - pt_correction;
987 return Etcone_value - pt_correction;
1003 float etaS2,
float etaPointing,
float etaCluster,
1009 std::vector<float> mc_correction_slopes_ptr;
1010 std::vector<float> mc_correction_offsets_ptr;
1011 std::vector<float> data_correction_slopes_ptr;
1017 if (parttype ==
PHOTON) {
1035 if (parttype ==
PHOTON) {
1053 if (parttype ==
PHOTON) {
1071 ATH_MSG_WARNING(
"Unable to retrieve leakage correction for topoIso cone with radius = " <<
radius <<
".\n--- Radii must be one of {.20, .30, .40} OR {20, 30, 40}.\n");
1075 float scale_factor =
GetPtCorrectionFactor(etaS2, mc_correction_slopes_ptr, data_correction_slopes_ptr);
1080 if(is_mc) is_mc =
true;
1091 float etaS2,
float etaPointing,
float etaCluster,
1095 int convFlag_int,
int author,
float conv_radius,
float conv_ratio)
const {
1096 double correction_value = 0.;
1103 return correction_value;
1127 float fabs_eta = fabs(eta);
1145 float fabs_eta = fabs(eta);
1161 const std::vector<float>& mc_leakage_corrections_ptr,
1162 const std::vector<float>& data_leakage_corrections_ptr)
const {
1163 if(mc_leakage_corrections_ptr.empty() && data_leakage_corrections_ptr.empty())
1170 if (!mc_leakage_corrections_ptr.empty() && (eta_bin_fine >= 0))
correction += mc_leakage_corrections_ptr[eta_bin_fine];
1171 if (!data_leakage_corrections_ptr.empty() && (eta_bin_coarse >= 0))
correction += data_leakage_corrections_ptr[eta_bin_coarse];
1182 double etaForPt = ((fabs(etaPointing - etaCluster) < 0.15) ? etaPointing : etaCluster);
1183 double et = (fabs(etaForPt)<99.) ?
energy/cosh(etaForPt) : 0.;
1185 return scale_factor *
et;
1197 double etaForPt = ((fabs(etaPointing - etaCluster) < 0.15) ? etaPointing : etaCluster);
1198 double et = (fabs(etaForPt)<99.) ?
energy/cosh(etaForPt) : 0.;
1201 ATH_MSG_WARNING(
"IsolationCorrection::GetPtCorrection_FromGraph: the file containing the isolation leakage corrections is not initialized.\nNo correction is applied.\n");
1204 if (etabin < 0)
return 0;
1206 if( (etabin == 9 || etabin == 5) && parttype ==
PHOTON ){
1210 double correction_value_mev = -1e6;
1234 ATH_MSG_WARNING(
"Unable to retrieve leakage correction for topoIso cone with radius = " <<
radius <<
".\n--- Radii must be one of {.20, .30, .40} OR {20, 30, 40}.\n");
1237 return correction_value_mev;
1248 if(conversion_flag == 0)
return 0;
1250 if( (conversion_flag == 1) || ((conversion_flag == 2 && conv_ratio > 0.3) || (conversion_flag == 2 && conv_ratio < 0.3 && conv_radius > 140.)) )
return 1;
1252 if(conversion_flag == 2 && conv_radius < 140.)
return 2;
1258 double etaForPt = etaS2;
1262 int conversion_type = 0;
1266 if (
m_forcePartType && parttype ==
PHOTON) conversion_type = conv_radius > 800 ? 0 : (conv_radius > 140 ? 1 : 2);
1269 ATH_MSG_WARNING(
"In IsolationCorrection::GetPtCorrection_FromGraph_2015: the file containing the isolation leakage corrections is not initialized.\nNo correction is applied.\n");
1273 if (etabin < 0)
return 0;
1274 if(parttype ==
PHOTON)
if( (etabin == 9 || etabin == 5) )
return 0;
1276 double correction_value_mev = 0;
1278 float pt_threshold = 250000.;
1294 if(conversion_type == 2){
1310 if(conversion_type == 2){
1326 if(conversion_type == 2){
1333 ATH_MSG_WARNING(
"Unable to retrieve leakage correction for topoIso cone with radius = " <<
radius <<
".\n--- Radii must be one of {.20, .30, .40} OR {20, 30, 40}.\n");
1338 ATH_MSG_VERBOSE(
"Electron ? " << (parttype ==
ELECTRON) <<
" author / conversion type = " << (parttype ==
ELECTRON ?
author : conversion_type) <<
" et = " <<
et <<
" eta = " << etaS2 <<
" etabin = " << etabin <<
" correction: "<< correction_value_mev);
1339 return correction_value_mev;
1343 ATH_MSG_INFO(
"Print properties of the parametrisation");