ATLAS Offline Software
BJetCalibrationAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 //
9 // includes
10 //
11 
13 
14 //
15 // method implementations
16 //
17 
18 namespace CP
19 {
20 
22  initialize ()
23  {
30 
32 
33  if(!m_muonSelectionTool.empty()){
34  ANA_CHECK (m_muonSelectionTool.retrieve());
36  ATH_MSG_ERROR ("muonSelectionTool and muonPreselection should not be configured simultaneously");
37  return StatusCode::FAILURE;
38  }
39  }
40 
41  ANA_CHECK (m_muonInJetTool.retrieve());
42  if(!m_bJetTool.empty()) ANA_CHECK (m_bJetTool.retrieve());
43 
45  return StatusCode::SUCCESS;
46  }
47 
49  execute ()
50  {
51  for (const auto& sys : m_systematicsList.systematicsVector())
52  {
53  xAOD::JetContainer *jets = nullptr;
54  ANA_CHECK (m_jetHandle.getCopy (jets, sys));
55 
56  const xAOD::MuonContainer *muons = nullptr;
58 
59  std::vector<const xAOD::Muon*> muons_for_correction;
60  muons_for_correction.reserve(muons->size());
61  for(const xAOD::Muon* muon : *muons){
62  if(// For analysis frameworks
64  // For other frameworks
65  (!m_muonSelectionTool.empty() && m_muonSelectionTool->accept(*muon)))
66  muons_for_correction.emplace_back(muon);
67  }
68 
69  for(xAOD::Jet* jet : *jets) {
70 
71  jet->setJetP4("NoBJetCalibMomentum", jet->jetP4());
72  jet->setJetP4("MuonCorrMomentum", jet->jetP4());
73 
74  int nmuons = 0;
76  ANA_CHECK (m_muonInJetTool->applyMuonInJetCorrection(*jet, muons_for_correction, nmuons));
77  jet->setJetP4("MuonCorrMomentum", jet->jetP4());
78  if(!m_bJetTool.empty()){
79  ANA_CHECK (m_bJetTool->applyBJetCorrection(*jet, nmuons>0));
80  }
81  }
82  m_nmuons.set(*jet, nmuons, sys);
83 
84  }
85  }
86 
87  return StatusCode::SUCCESS;
88  }
89 }
CP::BJetCalibrationAlg::m_nmuons
SysWriteDecorHandle< int > m_nmuons
Definition: BJetCalibrationAlg.h:61
CP::SysWriteDecorHandle::set
void set(const SG::AuxElement &object, const T &value, const CP::SystematicSet &sys) const
set the object decoration for the given systematic
CP::BJetCalibrationAlg::m_muonPreselection
SysReadSelectionHandle m_muonPreselection
Definition: BJetCalibrationAlg.h:58
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
CP::BJetCalibrationAlg::m_bJetTool
ToolHandle< IBJetCorrectionTool > m_bJetTool
the b-jet pt correction tool
Definition: BJetCalibrationAlg.h:45
CP::BJetCalibrationAlg::m_muonSelectionTool
ToolHandle< CP::IMuonSelectionTool > m_muonSelectionTool
the muon-in-jet selection tool, unused if muonPreselection set
Definition: BJetCalibrationAlg.h:39
CP::BJetCalibrationAlg::m_jetHandle
SysCopyHandle< xAOD::JetContainer > m_jetHandle
Definition: BJetCalibrationAlg.h:49
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
CP::SysReadHandle::retrieve
::StatusCode retrieve(const T *&object, const CP::SystematicSet &sys) const
retrieve the object for the given name
CP::SysListHandle::systematicsVector
const std::vector< CP::SystematicSet > & systematicsVector() const
the list of systematics to loop over
Definition: SysListHandle.cxx:96
CP::BJetCalibrationAlg::m_muonInJetTool
ToolHandle< IMuonInJetCorrectionTool > m_muonInJetTool
the muon-in-jet correction tool
Definition: BJetCalibrationAlg.h:42
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
CP::BJetCalibrationAlg::m_jetPreselection
SysReadSelectionHandle m_jetPreselection
Definition: BJetCalibrationAlg.h:52
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
CP::SysReadHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle)
initialize this handle
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CP::SysListHandle::initialize
::StatusCode initialize()
intialize this property
Definition: SysListHandle.cxx:69
CP::SysReadSelectionHandle::getBool
bool getBool(const SG::AuxElement &element, const CP::SystematicSet &sys) const
get the selection as a bool
CP::BJetCalibrationAlg::initialize
StatusCode initialize() override
Definition: BJetCalibrationAlg.cxx:22
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::SysWriteDecorHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize this handle
CP::BJetCalibrationAlg::m_systematicsList
SysListHandle m_systematicsList
Definition: BJetCalibrationAlg.h:47
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
CP::BJetCalibrationAlg::execute
StatusCode execute() override
Definition: BJetCalibrationAlg.cxx:49
CP::BJetCalibrationAlg::m_muonHandle
SysReadHandle< xAOD::MuonContainer > m_muonHandle
Definition: BJetCalibrationAlg.h:55
CP::SysReadSelectionHandle::empty
virtual bool empty() const noexcept override
Definition: SysReadSelectionHandle.cxx:68
CP::SysReadSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysReadSelectionHandle.cxx:34
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
BJetCalibrationAlg.h