ATLAS Offline Software
Loading...
Searching...
No Matches
BJetCorrectionTool.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5*/
6
7// JetCalibrationTool.cxx
8// Implementation file for class BJetCorrectionTool
10
13
14BJetCorrectionTool::BJetCorrectionTool(const std::string& name) : asg::AsgTool (name) { }
15
17 std::string filename = PathResolverFindCalibFile("BJetPtCorrection/" + m_calibFileName);
18 std::unique_ptr<TFile> calibFile = std::make_unique<TFile>(filename.c_str(), "READ");
19 if(!calibFile){
20 ANA_MSG_FATAL("Calibration file is not found " << filename );
21 return StatusCode::FAILURE;
22 }
23
24 m_Semi_Histo.reset(dynamic_cast<TH1F*>(calibFile->Get("Correction_SemiLeptonic_ttbar_mean")));
25 if (!m_Semi_Histo) {
26 ATH_MSG_FATAL("Cannot get Correction_SemiLeptonic_ttbar_mean from calib file");
27 return StatusCode::FAILURE;
28 }
29 m_Semi_Histo->SetDirectory(nullptr);
30 m_Had_Histo.reset(dynamic_cast<TH1F*>(calibFile->Get("Correction_Hadronic_ttbar_mean")));
31 if (!m_Had_Histo) {
32 ATH_MSG_FATAL("Cannot get Correction_Hadronic_ttbar_mean from calib file");
33 return StatusCode::FAILURE;
34 }
35 m_Had_Histo->SetDirectory(nullptr);
36 calibFile->Close();
37
38 return StatusCode::SUCCESS;
39}
40
41StatusCode BJetCorrectionTool::applyBJetCorrection(xAOD::Jet& jet, bool isSemiLep) const {
42 float calibFactor = (isSemiLep ? m_Semi_Histo : m_Had_Histo)->Interpolate(std::log(jet.pt() * 0.001));
43 TLorentzVector j = calibFactor * jet.p4();
44 xAOD::JetFourMom_t new_jet(j.Pt(),j.Eta(),j.Phi(),j.M());
45 jet.setJetP4(new_jet);
46 return StatusCode::SUCCESS;
47}
#define ATH_MSG_FATAL(x)
#define ANA_MSG_FATAL(xmsg)
Macro printing fatal messages.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
BJetCorrectionTool(const std::string &name)
Constructor with parameters:
virtual StatusCode applyBJetCorrection(xAOD::Jet &jet, bool isSemiLep) const override
std::unique_ptr< TH1F > m_Semi_Histo
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
std::unique_ptr< TH1F > m_Had_Histo
Gaudi::Property< std::string > m_calibFileName
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
Jet_v1 Jet
Definition of the current "jet version".
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition JetTypes.h:17