ATLAS Offline Software
Loading...
Searching...
No Matches
MuonCloseJetDecorationAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4// Local include(s):
7#include <cmath>
8
12namespace ADD_CMODE(CP) {
13 MuonCloseJetDecorationAlg::MuonCloseJetDecorationAlg(const std::string& name, ISvcLocator* svcLoc) :
14 AthAlgorithm(name, svcLoc),
15 m_muon_container("Muons"),
16 m_jet_container("AntiKt4EMTopoJets"),
17 m_jet_dr_decoration("dRJet"),
18 m_dummy_value(-1.),
19 m_jet_pt_cut(20.e3),
20 m_decorator(nullptr) {
21 declareProperty("MuonContainer", m_muon_container);
22 declareProperty("JetContainer", m_jet_container);
23 declareProperty("dRDecoration", m_jet_dr_decoration);
24 declareProperty("DefaultValue", m_dummy_value);
25 declareProperty("MinJetPt", m_jet_pt_cut);
26 }
27 StatusCode MuonCloseJetDecorationAlg::initialize() {
28 if (m_muon_container.empty()){
29 ATH_MSG_FATAL("Please provide a suitable muon container");
30 return StatusCode::FAILURE;
31 }
32 if (m_jet_container.empty()){
33 ATH_MSG_FATAL("Please provide a suitable jet container");
34 return StatusCode::FAILURE;
35 }
36 if (m_jet_dr_decoration.empty()){
37 ATH_MSG_FATAL("What's the decoration to apply to the muon");
38 return StatusCode::FAILURE;
39 }
40 m_decorator = std::make_unique<SG::Decorator<float>>(m_jet_dr_decoration);
41 ATH_MSG_INFO("Decorator the jet dR between "<<m_muon_container<<" and "<<m_jet_container<<" to "
42 <<m_jet_dr_decoration<<". If no jet is found the following dummy value is assigned: "<<m_dummy_value);
43 return StatusCode::SUCCESS;
44 }
45
46 StatusCode MuonCloseJetDecorationAlg::execute(const EventContext& /*ctx*/) {
47
48 const xAOD::MuonContainer* muons = nullptr;
49 ATH_CHECK(evtStore()->retrieve(muons, m_muon_container));
50
51 const xAOD::JetContainer* jets = nullptr;
52 ATH_CHECK(evtStore()->retrieve(jets, m_jet_container));
53 for ( const xAOD::Muon* mu : *muons){
54 const xAOD::Jet* closest_jet = nullptr;
55 for (const xAOD::Jet* jet: *jets){
56 if (jet->pt() < m_jet_pt_cut) continue;
57 if (closest_jet == nullptr || xAOD::P4Helpers::deltaR2(jet,mu) < xAOD::P4Helpers::deltaR2(closest_jet,mu)) closest_jet = jet;
58 }
59 (*m_decorator)(*mu) = closest_jet? xAOD::P4Helpers::deltaR(closest_jet,mu) : m_dummy_value;
60 }
61 return StatusCode::SUCCESS;
62 }
63
64} // namespace ADD_CMODE(CP)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(x,...)
Base class from which non-reentrant (not thread-safe) Athena algorithm classes should be derived.
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
double deltaR2(double rapidity1, double phi1, double rapidity2, double phi2)
from bare rapidity,phi
Jet_v1 Jet
Definition of the current "jet version".
Muon_v1 Muon
Reference the current persistent version:
Definition Muon.h:13
JetContainer_v1 JetContainer
Definition of the current "jet container version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".