ATLAS Offline Software
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 
10 #include "xAODJet/JetContainer.h"
12 namespace 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  }
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::AuxElement::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 
47 
48  const xAOD::MuonContainer* muons = nullptr;
50 
51  const xAOD::JetContainer* jets = nullptr;
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 CP
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
CP::MuonCloseJetDecorationAlg::execute
StatusCode execute() override
Function executing the algorithm.
Definition: MuonCloseJetDecorationAlg.cxx:46
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAODP4Helpers.h
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
MuonCloseJetDecorationAlg.h
xAOD::P4Helpers::deltaR2
double deltaR2(double rapidity1, double phi1, double rapidity2, double phi2)
from bare rapidity,phi
Definition: xAODP4Helpers.h:111
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
CP::MuonCloseJetDecorationAlg::m_jet_dr_decoration
std::string m_jet_dr_decoration
name of the decoration
Definition: MuonCloseJetDecorationAlg.h:34
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
CP::MuonCloseJetDecorationAlg::m_muon_container
std::string m_muon_container
muon container
Definition: MuonCloseJetDecorationAlg.h:30
CP::MuonCloseJetDecorationAlg::m_decorator
std::unique_ptr< SG::AuxElement::Decorator< float > > m_decorator
Definition: MuonCloseJetDecorationAlg.h:39
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
CheckAppliedSFs.e3
e3
Definition: CheckAppliedSFs.py:264
xAOD::P4Helpers::deltaR
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
Definition: xAODP4Helpers.h:150
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CP::MuonCloseJetDecorationAlg::m_jet_container
std::string m_jet_container
jet container
Definition: MuonCloseJetDecorationAlg.h:32
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
AthAlgorithm
Definition: AthAlgorithm.h:47
SystematicsTool.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CP::MuonCloseJetDecorationAlg::m_dummy_value
float m_dummy_value
value to be assigned if no jet is in the event
Definition: MuonCloseJetDecorationAlg.h:36
MuonContainer.h
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
JetContainer.h
CP::MuonCloseJetDecorationAlg::MuonCloseJetDecorationAlg
MuonCloseJetDecorationAlg(const std::string &name, ISvcLocator *svcLoc)
Regular Algorithm constructor.
Definition: MuonCloseJetDecorationAlg.cxx:13
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
CP::MuonCloseJetDecorationAlg::m_jet_pt_cut
float m_jet_pt_cut
Minimum pt on the jet.
Definition: MuonCloseJetDecorationAlg.h:38
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
CP::MuonCloseJetDecorationAlg::initialize
StatusCode initialize() override
Function initialising the algorithm.
Definition: MuonCloseJetDecorationAlg.cxx:27