34 , m_calibArea(
"CalibArea-08")
56 return StatusCode::FAILURE;
64 return StatusCode::FAILURE;
69 return StatusCode::FAILURE;
81 if (settings.ReadFile( configFilePath.Data(),kEnvGlobal))
83 ATH_MSG_ERROR(
"Cannot read config file: " << configFilePath.Data());
84 return StatusCode::FAILURE;
87 ATH_MSG_INFO(
"================================================");
93 m_release = settings.GetValue(
"UncertaintyRelease",
"UNKNOWN");
100 ATH_MSG_ERROR(
"Cannot find the truth jet collection to use in config");
101 return StatusCode::FAILURE;
108 ATH_MSG_ERROR(
"Cannot find the TruthLabelAccessor to use in config");
109 return StatusCode::FAILURE;
116 ATH_MSG_ERROR(
"Cannot find the EtaRange parameter in the config file");
117 return StatusCode::FAILURE;
121 m_MaxMass = settings.GetValue(
"MaxMass",0);
124 ATH_MSG_ERROR(
"Cannot find the MaxMass parameter in the config file");
125 return StatusCode::FAILURE;
129 m_MaxPt = settings.GetValue(
"MaxPt",0);
132 ATH_MSG_ERROR(
"Cannot find the MaxPt parameter in the config file");
133 return StatusCode::FAILURE;
141 ATH_MSG_ERROR(
"Cannot find uncertainty histogram file in the config file");
142 return StatusCode::FAILURE;
154 if(
registry.registerSystematics(*
this) != StatusCode::SUCCESS){
156 return StatusCode::FAILURE;
163 return StatusCode::SUCCESS;
177 return sys.find(systematic) !=
sys.end();
195 if ((*ci).basename().find(
"CALO_")!=std::string::npos)
196 filteredSysts.
insert(*ci);
198 return filteredSysts;
202 if ((*ci).basename().find(
"TA_") !=std::string::npos)
203 filteredSysts.
insert(*ci);
205 return filteredSysts;
209 if ((*ci).basename().find(
"COMB_")!=std::string::npos){
210 filteredSysts.
insert(*ci);
213 return filteredSysts;
236 filterForAffectingSystematics(
systematics, affectingSysts, filteredSysts) !=
237 StatusCode::SUCCESS )
240 return StatusCode::FAILURE;
247 if(filteredSysts.
size() > 1){
248 ATH_MSG_ERROR(
"No support for more than one JMS/JMR sys at a time: " <<
249 filteredSysts.
name());
250 return StatusCode::FAILURE;
267 return StatusCode::SUCCESS;
279 if(!data_file || data_file->IsZombie()){
281 return StatusCode::FAILURE;
287 TString CaloResponseMap_path = settings.GetValue(
"CaloResponseMap",
"");
289 if(CaloResponseMap_path.IsNull())
291 ATH_MSG_ERROR(
"Cannot find the CaloResponseMap in the config file");
292 return StatusCode::FAILURE;
295 m_CALO_ResponseMap = std::unique_ptr<TH2>(
dynamic_cast<TH2*
>(data_file->Get( CaloResponseMap_path )));
300 TString TAResponseMap_path = settings.GetValue(
"TAResponseMap",
"");
302 if(TAResponseMap_path.IsNull())
304 ATH_MSG_ERROR(
"Cannot find the TAResponseMap in the config file");
305 return StatusCode::FAILURE;
308 m_TA_ResponseMap = std::unique_ptr<TH2>(
dynamic_cast<TH2*
>(data_file->Get( TAResponseMap_path )));
315 for (
size_t iComp = 0; iComp < 999; ++iComp)
317 const TString
prefix = Form(
"JMSComponent.%zu.",iComp);
319 std::string Syst_Name = settings.GetValue(
prefix+
"Name",
"");
321 if( !Syst_Name.empty()){
340 for (
size_t iComp = 0; iComp < 999; ++iComp)
342 const TString
prefix = Form(
"JMRComponent.%zu.",iComp);
344 std::string Syst_Name = settings.GetValue(
prefix+
"Name",
"");
346 if( !Syst_Name.empty()){
371 TString Calo_TA_weight_file_name = settings.GetValue(
"JetUncertainties_UncertaintyRootFile",
"");
374 if (Calo_TA_weight_file_path.IsNull())
376 ATH_MSG_ERROR(
"Cannot find the file with the Calo and TA weights");
377 return StatusCode::FAILURE;
380 TString Calo_weight_hist_name = settings.GetValue(
"CombMassWeightCaloHist",
"");
381 if (Calo_weight_hist_name.IsNull())
383 ATH_MSG_ERROR(
"Cannot find the histogram name that contains the Calo weights in the config file");
384 return StatusCode::FAILURE;
387 TString TA_weight_hist_name = settings.GetValue(
"CombMassWeightTAHist",
"");
388 if (TA_weight_hist_name.IsNull())
390 ATH_MSG_ERROR(
"Cannot find the histogram name that contains the TA weights in the config file");
391 return StatusCode::FAILURE;
394 ATH_MSG_INFO(Form(
" Calo weights hist: \"%s\"",Calo_weight_hist_name.Data()));
395 ATH_MSG_INFO(Form(
" TA weights hist: \"%s\"",TA_weight_hist_name.Data()));
396 ATH_MSG_INFO(Form(
" Location: %s",Calo_TA_weight_file_path.Data()));
399 std::unique_ptr<TFile> Calo_TA_weight_file ( TFile::Open(Calo_TA_weight_file_path));
400 if(!Calo_TA_weight_file || Calo_TA_weight_file->IsZombie()){
401 ATH_MSG_FATAL(
"Could not open the first input file: " << Calo_TA_weight_file_path );
402 return StatusCode::FAILURE;
405 m_caloMassWeight = std::unique_ptr<TH3F>(
dynamic_cast<TH3F*
>(Calo_TA_weight_file->Get(Calo_weight_hist_name)));
406 m_TAMassWeight = std::unique_ptr<TH3F>(
dynamic_cast<TH3F*
>(Calo_TA_weight_file->Get(TA_weight_hist_name)));
412 Calo_TA_weight_file->Close();
414 return StatusCode::SUCCESS;
433 double dRmax_truthJet = 0.75;
438 for (
const auto *
const jet_truth : *jets_truth) {
439 float dR_Test = jet_reco.
p4().DeltaR(jet_truth->p4());
440 if ( dR_Test < dRmax_truthJet){
442 close_jet = jet_truth;
447 if(dRmin > 999){
return StatusCode::FAILURE;}
450 return StatusCode::SUCCESS;
464 ATH_MSG_ERROR(
"Unable to retrieve the FatjetTruthLabel from the jet. Please call the BoostedJetTaggers decorateTruthLabel() function before calling this function.");
465 return StatusCode::FAILURE;
493 jetTopology=
"no_match";
494 ATH_MSG_DEBUG(
"No truth jet match with this reco jet. The jet will not be smeared.");
497 else jetTopology=
"QCD";
499 ATH_MSG_VERBOSE(
"The topology of this jet correspond to a " << jetTopology <<
" large-R jet");
501 return StatusCode::SUCCESS;
524 else{
return StatusCode::SUCCESS;}
528 return StatusCode::SUCCESS;
545 if(MassDef_of_syst==calo)
547 else if(MassDef_of_syst==ta)
564 if(MassDef_of_syst==calo)
566 else if(MassDef_of_syst==ta)
578 return StatusCode::SUCCESS;
589 ATH_MSG_VERBOSE(
"//---------------------------------------------------------------//");
590 ATH_MSG_VERBOSE(
"Reco Jet to Smear: pt = " << jet_reco.
pt() <<
", mass = " << jet_reco.
m() <<
", eta = " << jet_reco.
eta());
601 ATH_MSG_DEBUG(
"This jet exceeds the maximum pt that the tool allows jet_pt <" <<
m_MaxPt <<
" MeV)");
610 ATH_MSG_VERBOSE(
"No truth jet match with this reco jet. The jet will not be smeared.");
614 ATH_MSG_VERBOSE(
"Matched truth Jet: pt = " << jet_truth_matched.
pt() <<
", mass = " << jet_truth_matched.
m() <<
", eta = " << jet_truth_matched.
eta());
617 std::string jetTopology;
623 if(jetTopology ==
"no_match"){
630 double jet_mass_CALO = 0;
631 double jet_mass_TA = 0;
632 double calo_mass_weight=1;
634 float JetTrackAssistedMassCalibrated_from_JetCalibTools;
650 jet_mass_CALO = jet_reco_CALO.mass();
651 jet_mass_TA = jet_reco_TA.mass();
652 jet_reco.
getAttribute<
float>(
"JetTrackAssistedMassCalibrated", JetTrackAssistedMassCalibrated_from_JetCalibTools);
655 jet_mass_CALO = jet_reco.
m();
656 calo_mass_weight = 1;
659 jet_mass_TA = jet_reco.
m();
660 jet_reco.
getAttribute<
float>(
"JetTrackAssistedMassCalibrated", JetTrackAssistedMassCalibrated_from_JetCalibTools);
661 calo_mass_weight = 0;
669 double avg_response_CALO=1;
670 double avg_response_TA=1;
675 if(avg_response_CALO==0) avg_response_CALO=1;
681 if(avg_response_TA==0) avg_response_TA = 1;
687 double JMS (1), JMS_err(0), JMR(1), JMR_err(0);
691 double smeared_CALO_mass = jet_mass_CALO;
692 double smeared_TA_mass = jet_mass_TA;
694 bool is_CALO_mass_smeared =
false;
695 bool is_TA_mass_smeared =
false;
703 scale = JMS + JMS_err;
707 is_CALO_mass_smeared =
true;
709 ATH_MSG_VERBOSE(
"Forward Folding CALO procedure will use scale=" <<
scale <<
", resolution=" <<
resolution <<
" and average respose=" << avg_response_CALO);
712 smeared_CALO_mass = jet_mass_CALO *
scale + (jet_mass_CALO - avg_response_CALO*jet_truth_matched.
m())*(
resolution-
scale);
722 scale = JMS + JMS_err;
727 is_TA_mass_smeared =
true;
729 ATH_MSG_VERBOSE(
"Forward Folding TA procedure will use scale=" <<
scale <<
", resolution=" <<
resolution <<
" and average respose=" << avg_response_TA);
732 smeared_TA_mass = jet_mass_TA *
scale + (jet_mass_TA - avg_response_TA*jet_truth_matched.
m())*(
resolution-
scale);
737 if(!is_CALO_mass_smeared && !is_TA_mass_smeared){
739 ATH_MSG_VERBOSE(
"This jet is not affected by the systematic. The jet won't be modified");
740 ATH_MSG_VERBOSE(
"//---------------------------------------------------------------//");
766 p4_aux =
xAOD::JetFourMom_t(jet_reco_CALO.pt(),jet_reco_CALO.eta(),jet_reco_CALO.phi(),smeared_CALO_mass);
767 jet_reco_CALO = p4_aux;
769 p4_aux =
xAOD::JetFourMom_t(jet_reco_TA.pt(),jet_reco_TA.eta(),jet_reco_TA.phi(),smeared_TA_mass);
770 jet_reco_TA = p4_aux;
786 if (caloRes == 0 ) { caloFactor = 0; TAFactor = 1;}
787 else if( TARes == 0) { caloFactor = 1; TAFactor = 0;}
789 caloFactor = 1./(caloRes*caloRes);
790 TAFactor = 1./(TARes*TARes);
793 calo_mass_weight = caloFactor /(caloFactor + TAFactor);
798 else if(JetTrackAssistedMassCalibrated_from_JetCalibTools == 0){calo_mass_weight = 1;}
799 else if(jet_mass_CALO == 0){calo_mass_weight = 0;}
801 double smeared_mass = calo_mass_weight*smeared_CALO_mass + (1 - calo_mass_weight)*smeared_TA_mass;
812 ATH_MSG_VERBOSE(
"Smeared Reco Jet: pt = " << jet_reco.
pt() <<
", mass = " << jet_reco.
m() <<
", eta = " << jet_reco.
eta());
814 ATH_MSG_VERBOSE(
"//---------------------------------------------------------------//");
841 for (
size_t iJet = 0; iJet <
inputs.size(); ++iJet)
867 double xMax =
histo->GetXaxis()->GetBinLowEdge(
histo->GetNbinsX()+1);
868 double xMin =
histo->GetXaxis()->GetBinLowEdge(1);
869 double yMax =
histo->GetYaxis()->GetBinLowEdge(
histo->GetNbinsY()+1);
870 double yMin =
histo->GetYaxis()->GetBinLowEdge(1);
871 double zMax =
histo->GetZaxis()->GetBinLowEdge(
histo->GetNbinsZ()+1);
872 double zMin =
histo->GetZaxis()->GetBinLowEdge(1);
874 if(
x >= xMax) aux_x = xMax-1
e-6 ;
875 if(
x <= xMin) aux_x = xMin+1
e-6 ;
876 if ( std::isnan(
y))
return 0;
877 if(
y >= yMax) aux_y = yMax-1
e-6 ;
878 if(
y <= yMin) aux_y = yMin+1
e-6 ;
879 if(
z >= zMax) aux_z = zMax-1
e-6 ;
880 if(
z <= zMin) aux_z = zMin+1
e-6 ;
892 ATH_MSG_ERROR(
"Histogram pointer is null in FFJetSmearingTool::Interpolate2D");
895 Int_t bin_x =
histo->GetXaxis()->FindFixBin(
x);
896 Int_t bin_y =
histo->GetYaxis()->FindFixBin(
y);
897 if(bin_x<1 || bin_x>
histo->GetNbinsX() || bin_y<1 || bin_y>
histo->GetNbinsY()) {
903 return interpolated_value;