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++)
73 return StatusCode::SUCCESS;
82 float corrected_isolation = input.isolationValue(isol) -
GetPtCorrection(input, isol);
83 return corrected_isolation;
106 float isolation_ptcorrection = 0;
110 if (input.caloCluster() ==
nullptr) {
111 ATH_MSG_WARNING(
"The associated cluster of the object does not exist ! Maybe the thinning was too agressive... No leakage correction computed.");
115 energy = input.caloCluster()->energyBE(1) + input.caloCluster()->energyBE(2) + input.caloCluster()->energyBE(3);
117 energy = input.caloCluster()->e();
121 bool convFlag =
false;
123 float etaS2 = input.caloCluster()->etaBE(2);
124 float etaS1 = input.caloCluster()->etaBE(1);
125 float etaCluster = input.caloCluster()->eta();
126 float phiCluster = input.caloCluster()->phi();
131 if(fabs(etaS1) > 2.5)
return 0.;
132 if(fabs(phiCluster) >
float(
M_PI))
return 0.;
137 int convFlag_int = 0;
138 float conv_radius = 0.;
139 float conv_ratio = 0.;
145 if(convFlag_int == 3 ) convFlag_int = 2;
146 else if(convFlag_int != 0) convFlag_int = 1;
148 if(convFlag_int != 0) convFlag =
true;
151 if(convFlag_int == 2){
159 float pt1conv, pt2conv;
161 pt1conv = accPt1(*phVertex);
162 pt2conv = accPt2(*phVertex);
168 if(pt1conv > pt2conv) conv_ratio = pt2conv/pt1conv;
169 else conv_ratio = pt1conv/pt2conv;
172 int author = input.author();
184 if (!etaPointing.has_value())
return 0.;
215 return isolation_ptcorrection;
221 for (
unsigned int i = 0;
i <
tp->numberOfParameters(); ++
i)
223 return hypot(
tp->parameterPX(
i),
tp->parameterPY(
i));
231 ATH_MSG_WARNING(
"IsolationCorrection::GetDDCorrection " <<
year <<
", unknown correction file name.\nNo correction is applied.\n");
232 return StatusCode::FAILURE;
235 int ii =
year ==
"2017" ? 2 : (
year ==
"2015_2016" ? 1 : 0);
239 return StatusCode::SUCCESS;
244 if (
year ==
"2015") {
251 }
else if (
year ==
"2015_2016") {
258 }
else if (
year ==
"2017") {
266 ATH_MSG_WARNING(
"Year " <<
year <<
" is not known in IsolationCorrection ! Check your input ! No correction is applied");
267 return StatusCode::FAILURE;
274 std::unique_ptr< TFile > file_ptleakagecorr( TFile::Open(
m_corr_ddshift_file.c_str(),
"READ" ) );
275 if (!file_ptleakagecorr) {
277 return StatusCode::FAILURE;
280 TVector *veta = (TVector*)file_ptleakagecorr->Get(baseN+
"/etaBinning");
282 for (
int ieta = 0; ieta < veta->GetNrows(); ieta++)
m_feta_bins_dd->at(ieta) = (*veta)[ieta];
283 TTree *tbinLabel = (TTree*)file_ptleakagecorr->Get(baseN+
"tbinLabel");
284 TBranch *bbinLabel(
nullptr);
285 TString *binLabel(
nullptr); tbinLabel->SetBranchAddress(
"binLabel",&binLabel,&bbinLabel);
286 for (
unsigned int ieta = 0; ieta <
m_feta_bins_dd->size()-2; ieta++) {
287 tbinLabel->GetEntry(ieta);
288 TString gN =
"topoETcone40_DataDriven_unconverted_photon_eta_";
291 gN =
"topoETcone40_DataDriven_converted_photon_eta_";
294 gN =
"topoETcone20_DataDriven_unconverted_photon_eta_";
297 gN =
"topoETcone20_DataDriven_converted_photon_eta_";
310 return StatusCode::SUCCESS;
329 float etaS2 = input.eta();
332 double feta = fabs(etaS2);
343 ATH_MSG_WARNING(
"Strange cluster S2 eta for photon isolation DD correction ! eta = " << etaS2 <<
". No correction");
347 if (input.pt() > 25
e3)
349 <<
" eta: " << etaS2 <<
" etabin: " <<
eta_bin);
351 float pt_gev = input.pt()*0.001;
352 if (pt_gev > 999.) pt_gev = 999. ;
354 float isolation_ddcorrection = 0;
357 isolation_ddcorrection = 1
e3*(*m_graph_dd_cone40_unconv_photon_shift)[
eta_bin]->Eval(pt_gev);
359 isolation_ddcorrection = 1
e3*(*m_graph_dd_cone40_conv_photon_shift)[
eta_bin]->Eval(pt_gev);
362 isolation_ddcorrection = 1
e3*(*m_graph_dd_cone20_unconv_photon_shift)[
eta_bin]->Eval(pt_gev);
364 isolation_ddcorrection = 1
e3*(*m_graph_dd_cone20_conv_photon_shift)[
eta_bin]->Eval(pt_gev);
367 return isolation_ddcorrection;
371 if (input->caloCluster() ==
nullptr) {
372 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).");
375 float etaS1 = input->caloCluster()->etaBE(1);
376 float etaS2 = input->caloCluster()->etaBE(2);
377 float phiCluster = input->caloCluster()->phi();
382 if(fabs(etaS1) > 2.5)
return 0.;
383 if(fabs(phiCluster) > 3.2)
return 0.;
387 return etaPointing.value_or(0.);
421 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};
490 ATH_MSG_WARNING(
"Correction file for 2017 data/mc not specified, tool not initialized for 2017 corrections\n");
495 std::unique_ptr<TFile> file_ptleakagecorr(TFile::Open(
m_corr_file.c_str(),
"READ"));
496 if(!file_ptleakagecorr){
497 ATH_MSG_WARNING(
"Correction file for 2012 data/mc not found, tool not initialized for 2012 corrections\n");
523 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin0_extrap") );
524 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin1_extrap") );
525 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin2_extrap") );
526 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin3_extrap") );
527 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin4_extrap") );
528 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin5_extrap") );
529 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin6_extrap") );
530 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin7_extrap") );
531 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin8_extrap") );
532 m_graph_cone40_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone40_electron_etabin9_extrap") );
556 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin0_extrap") );
557 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin1_extrap") );
558 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin2_extrap") );
559 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin3_extrap") );
560 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin4_extrap") );
561 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin5_extrap") );
562 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin6_extrap") );
563 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin7_extrap") );
564 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin8_extrap") );
565 m_graph_cone30_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone30_electron_etabin9_extrap") );
589 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin0_extrap") );
590 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin1_extrap") );
591 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin2_extrap") );
592 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin3_extrap") );
593 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin4_extrap") );
594 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin5_extrap") );
595 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin6_extrap") );
596 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin7_extrap") );
597 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin8_extrap") );
598 m_graph_cone20_electron.push_back( (TGraph*) file_ptleakagecorr->Get(
"graph_cone20_electron_etabin9_extrap") );
606 ATH_MSG_WARNING(
"Correction file for 2015 data/mc not specified, tool not initialized for 2015 corrections\n");
611 std::unique_ptr<TFile> file_ptleakagecorr(TFile::Open(
m_corr_file.c_str(),
"READ"));
612 if(!file_ptleakagecorr){
613 ATH_MSG_WARNING(
"Correction file for 2015 data/mc not found, "<<
m_corr_file<<
". tool not initialized for 2015 corrections\n");
616 if(!file_ptleakagecorr->GetListOfKeys()->Contains(
"mean_f_topoetcone40_eta_1.15_1.37_converted_ok")){
617 ATH_MSG_ERROR(
"Correction file for 2015 data/mc is not right, "<<
m_corr_file<<
". Tool not initialized for 2015 corrections\n");
625 static const int nEta = 10;
626 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" };
627 static const TString pLab[5] = {
"_unconverted",
"_converted_ok",
"_converted_trouble",
"_author_1_electron",
"_author_16_electron" };
628 static const TString dRLab[3] = {
"20",
"30",
"40" };
657 for (
int iPart = 0; iPart < 5; iPart++) {
662 if (iPart < 3 && (
iEta == 5 ||
iEta == 9))
665 for (
int idR = 0; idR < 3; idR++) {
667 TString fN = (
m_useLogLogFit && iPart < 2) ?
"mean_flog_histo_topoetcone" :
"mean_f_topoetcone";
668 fN += dRLab[idR]; fN +=
"_eta_"; fN += etaLab[
iEta]; fN += pLab[iPart];
673 gN =
"mean_g_histo_topoetcone"; gN += dRLab[idR]; gN +=
"_eta_"; gN += etaLab[
iEta]; gN += pLab[iPart];
679 }
else if (iPart == 1) {
682 }
else if (iPart == 2) {
689 }
else if (iPart == 3) {
692 }
else if (iPart == 4) {
701 }
else if (idR == 1) {
705 }
else if (iPart == 1) {
708 }
else if (iPart == 2) {
715 }
else if (iPart == 3) {
718 }
else if (iPart == 4) {
731 }
else if (iPart == 1) {
734 }
else if (iPart == 2) {
741 }
else if (iPart == 3) {
744 }
else if (iPart == 4) {
768 ATH_MSG_WARNING(
"Data-driven correction files not specified, tool not initialized for data-driven corrections\n");
773 std::unique_ptr< TFile > file_ddshift_corr( TFile::Open(
m_corr_ddshift_file.c_str(),
"READ" ) );
776 if(!file_ddshift_corr || !file_ddsmearingcorr){
777 ATH_MSG_WARNING(
"Correction file for data-driven corrections not found, tool not initialized for data-driven corrections\n");
788 std::vector< std::shared_ptr<TGraphAsymmErrors> > graph_shift;
790 std::vector< std::shared_ptr<TGraphAsymmErrors> > graph_smearing;
791 for (
int ig = 0; ig <= 13; ig++) {
792 graph_shift.emplace_back(
dynamic_cast<TGraphAsymmErrors*
>(file_ddshift_corr->Get(Form(
"graph_%i",ig))) );
793 graph_smearing.emplace_back(
dynamic_cast<TGraphAsymmErrors*
>(file_ddsmearingcorr->Get(Form(
"graph_%i",ig))) );
795 for (
int ig = 0; ig <= 13; ig++) {
803 for (
const auto&
gr : graph_shift) {
805 ATH_MSG_ERROR(
"Null pointer for one of the DD correction graphs");
807 for (
const auto&
gr : graph_smearing) {
809 ATH_MSG_ERROR(
"Null pointer for one of the smearing graphs");
817 it != cntr.end(); ++
it ) {
965 return Etcone_value - pt_correction;
985 return Etcone_value - pt_correction;
1001 float etaS2,
float etaPointing,
float etaCluster,
1007 std::vector<float> mc_correction_slopes_ptr;
1008 std::vector<float> mc_correction_offsets_ptr;
1009 std::vector<float> data_correction_slopes_ptr;
1015 if (parttype ==
PHOTON) {
1033 if (parttype ==
PHOTON) {
1051 if (parttype ==
PHOTON) {
1069 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");
1073 float scale_factor =
GetPtCorrectionFactor(etaS2, mc_correction_slopes_ptr, data_correction_slopes_ptr);
1078 if(is_mc) is_mc =
true;
1089 float etaS2,
float etaPointing,
float etaCluster,
1093 int convFlag_int,
int author,
float conv_radius,
float conv_ratio)
const {
1094 double correction_value = 0.;
1101 return correction_value;
1125 float fabs_eta = fabs(
eta);
1143 float fabs_eta = fabs(
eta);
1159 const std::vector<float>& mc_leakage_corrections_ptr,
1160 const std::vector<float>& data_leakage_corrections_ptr)
const {
1161 if(mc_leakage_corrections_ptr.empty() && data_leakage_corrections_ptr.empty())
1168 if (!mc_leakage_corrections_ptr.empty() && (eta_bin_fine >= 0))
correction += mc_leakage_corrections_ptr[eta_bin_fine];
1169 if (!data_leakage_corrections_ptr.empty() && (eta_bin_coarse >= 0))
correction += data_leakage_corrections_ptr[eta_bin_coarse];
1180 double etaForPt = ((fabs(etaPointing - etaCluster) < 0.15) ? etaPointing : etaCluster);
1181 double et = (fabs(etaForPt)<99.) ?
energy/cosh(etaForPt) : 0.;
1183 return scale_factor *
et;
1195 double etaForPt = ((fabs(etaPointing - etaCluster) < 0.15) ? etaPointing : etaCluster);
1196 double et = (fabs(etaForPt)<99.) ?
energy/cosh(etaForPt) : 0.;
1199 ATH_MSG_WARNING(
"IsolationCorrection::GetPtCorrection_FromGraph: the file containing the isolation leakage corrections is not initialized.\nNo correction is applied.\n");
1202 if (etabin < 0)
return 0;
1204 if( (etabin == 9 || etabin == 5) && parttype ==
PHOTON ){
1208 double correction_value_mev = -1e6;
1232 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");
1235 return correction_value_mev;
1246 if(conversion_flag == 0)
return 0;
1248 if( (conversion_flag == 1) || ((conversion_flag == 2 && conv_ratio > 0.3) || (conversion_flag == 2 && conv_ratio < 0.3 && conv_radius > 140.)) )
return 1;
1250 if(conversion_flag == 2 && conv_radius < 140.)
return 2;
1256 double etaForPt = etaS2;
1260 int conversion_type = 0;
1264 if (
m_forcePartType && parttype ==
PHOTON) conversion_type = conv_radius > 800 ? 0 : (conv_radius > 140 ? 1 : 2);
1267 ATH_MSG_WARNING(
"In IsolationCorrection::GetPtCorrection_FromGraph_2015: the file containing the isolation leakage corrections is not initialized.\nNo correction is applied.\n");
1271 if (etabin < 0)
return 0;
1272 if(parttype ==
PHOTON)
if( (etabin == 9 || etabin == 5) )
return 0;
1274 double correction_value_mev = 0;
1276 float pt_threshold = 250000.;
1292 if(conversion_type == 2){
1308 if(conversion_type == 2){
1324 if(conversion_type == 2){
1331 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");
1336 ATH_MSG_VERBOSE(
"Electron ? " << (parttype ==
ELECTRON) <<
" author / conversion type = " << (parttype ==
ELECTRON ?
author : conversion_type) <<
" et = " <<
et <<
" eta = " << etaS2 <<
" etabin = " << etabin <<
" correction: "<< correction_value_mev);
1337 return correction_value_mev;
1341 ATH_MSG_INFO(
"Print properties of the parametrisation");