ATLAS Offline Software
CaloIsolationDecorAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
6 #include <StoreGate/ReadHandle.h>
8 
9 //**********************************************************************
10 namespace DerivationFramework {
11 CaloIsolationDecorAlg::CaloIsolationDecorAlg(const std::string& name, ISvcLocator* pSvcLocator) :
12  AthReentrantAlgorithm(name, pSvcLocator) {}
13 //**********************************************************************
14 
16  ATH_CHECK(m_isoTool.retrieve());
17 
18  m_calo_corr.calobitset.set(static_cast<unsigned int>(xAOD::Iso::coreCone));
19  m_calo_corr.calobitset.set(static_cast<unsigned int>(xAOD::Iso::pileupCorrection));
20  // isolation types to run. The ptcones each also imply the respective ptvarcone.
21 
23  for (const std::string& decor : m_trkSel_Decors) m_trkSel_keys.emplace_back(m_trk_key, decor);
24  ATH_CHECK(m_trkSel_keys.initialize());
25  m_topocone20_key = std::string{"topoetcone20"} + (m_customName.empty() ? "" : "_") + m_customName;
26  m_topocone30_key = std::string{"topoetcone30"} + (m_customName.empty() ? "" : "_") + m_customName;
27  m_topocone40_key = std::string{"topoetcone40"} + (m_customName.empty() ? "" : "_") + m_customName;
28  m_corr_key = std::string{"etcore_correction"} + (m_customName.empty() ? "" : "_") + m_customName;
33  ATH_MSG_DEBUG("Decorate " << m_trk_key.fullKey() << " using '" << m_customName << "' as suffix.");
34  return StatusCode::SUCCESS;
35 }
36 
37 //**********************************************************************
38 
39 StatusCode CaloIsolationDecorAlg::execute(const EventContext& ctx) const {
41  if (!tracks.isValid()) {
42  ATH_MSG_FATAL("Failed to retrieve track collection " << m_trk_key.fullKey());
43  return StatusCode::FAILURE;
44  }
45 
46 
49 
50  std::vector<SelDecorator> selDecors;
52  selDecors.emplace_back(key, ctx);
53  }
54 
55  FloatDecor topocone40_dec{makeHandle<float>(ctx, m_topocone40_key, -Gaudi::Units::GeV)};
56  FloatDecor topocone30_dec{makeHandle<float>(ctx, m_topocone30_key, -Gaudi::Units::GeV)};
57  FloatDecor topocone20_dec{makeHandle<float>(ctx, m_topocone20_key, -Gaudi::Units::GeV)};
58  FloatDecor corr_dec{makeHandle<float>(ctx, m_corr_key)};
59 
60  for (const xAOD::TrackParticle* trk : *tracks) {
61  if (trk->pt() < m_pt_min) continue;
62  if (!selDecors.empty() && std::find_if(selDecors.begin(), selDecors.end(), [trk](const SelDecorator& dec){
63  return dec(*trk);
64  }) == selDecors.end()) continue;
65  ATH_MSG_DEBUG("Recomputing isolation by hand");
66  xAOD::CaloIsolation resultCalo;
67  if (!m_isoTool->caloTopoClusterIsolation(resultCalo, *trk, m_calo_isos, m_calo_corr)) {
68  ATH_MSG_ERROR("Failed to compute calorimeter isolation");
69  return StatusCode::FAILURE;
70  }
71  topocone40_dec(*trk) = resultCalo.etcones[0];
72  topocone30_dec(*trk) = resultCalo.etcones[1];
73  topocone20_dec(*trk) = resultCalo.etcones[2];
74  corr_dec(*trk) = resultCalo.coreCorrections[xAOD::Iso::coreCone][xAOD::Iso::coreEnergy];
75  }
76  return StatusCode::SUCCESS;
77 }
78 }
79 //**********************************************************************
DerivationFramework::CaloIsolationDecorAlg::m_isoTool
ToolHandle< xAOD::ICaloTopoClusterIsolationTool > m_isoTool
Athena configured tools.
Definition: CaloIsolationDecorAlg.h:31
DerivationFramework::CaloIsolationDecorAlg::m_calo_corr
xAOD::CaloCorrection m_calo_corr
Definition: CaloIsolationDecorAlg.h:32
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DerivationFramework::CaloIsolationDecorAlg::CaloIsolationDecorAlg
CaloIsolationDecorAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Definition: CaloIsolationDecorAlg.cxx:11
xAOD::Iso::coreEnergy
@ coreEnergy
energy stored for this correction
Definition: Event/xAOD/xAODPrimitives/xAODPrimitives/IsolationCorrection.h:93
Utils.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
DerivationFramework::CaloIsolationDecorAlg::m_topocone30_key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_topocone30_key
Definition: CaloIsolationDecorAlg.h:51
DerivationFramework::CaloIsolationDecorAlg::m_corr_key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_corr_key
Definition: CaloIsolationDecorAlg.h:55
DerivationFramework::CaloIsolationDecorAlg::initialize
StatusCode initialize() override
Athena algorithm's Hooks.
Definition: CaloIsolationDecorAlg.cxx:15
DerivationFramework::CaloIsolationDecorAlg::m_trk_key
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trk_key
track collection to decorate
Definition: CaloIsolationDecorAlg.h:35
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
xAOD::CaloIsolation
Definition: IsolationCommon.h:22
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition: StoreGate/StoreGate/ReadDecorHandle.h:94
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::CaloIsolation::coreCorrections
std::map< Iso::IsolationCaloCorrection, std::map< Iso::IsolationCorrectionParameter, float > > coreCorrections
Definition: IsolationCommon.h:26
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
WriteDecorHandle.h
Handle class for adding a decoration to an object.
DerivationFramework::CaloIsolationDecorAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition: CaloIsolationDecorAlg.cxx:39
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
CaloIsolationDecorAlg.h
DerivationFramework::CaloIsolationDecorAlg::m_trkSel_Decors
Gaudi::Property< std::vector< std::string > > m_trkSel_Decors
Optional list of decorators to select only the good tracks for the isolation decoration.
Definition: CaloIsolationDecorAlg.h:44
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
xAOD::CaloIsolation::etcones
std::vector< float > etcones
Definition: IsolationCommon.h:30
xAOD::Iso::coreCone
@ coreCone
core energy (in dR<0.1).
Definition: Event/xAOD/xAODPrimitives/xAODPrimitives/IsolationCorrection.h:29
DerivationFramework::CaloIsolationDecorAlg::m_topocone20_key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_topocone20_key
Definition: CaloIsolationDecorAlg.h:49
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
DerivationFramework::CaloIsolationDecorAlg::m_trkSel_keys
SG::ReadDecorHandleKeyArray< xAOD::TrackParticleContainer > m_trkSel_keys
Definition: CaloIsolationDecorAlg.h:46
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
ReadHandle.h
Handle class for reading from StoreGate.
SG::ReadDecorHandleKey
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Definition: StoreGate/StoreGate/ReadDecorHandleKey.h:85
DerivationFramework::CaloIsolationDecorAlg::m_topocone40_key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_topocone40_key
Definition: CaloIsolationDecorAlg.h:53
DerivationFramework::CaloIsolationDecorAlg::m_calo_isos
std::vector< xAOD::Iso::IsolationType > m_calo_isos
Definition: CaloIsolationDecorAlg.h:58
DerivationFramework::CaloIsolationDecorAlg::m_pt_min
Gaudi::Property< float > m_pt_min
pt threshold to apply
Definition: CaloIsolationDecorAlg.h:38
DerivationFramework::CaloIsolationDecorAlg::m_customName
Gaudi::Property< std::string > m_customName
Definition: CaloIsolationDecorAlg.h:40
xAOD::CaloCorrection::calobitset
Iso::IsolationCaloCorrectionBitset calobitset
Definition: IsolationCommon.h:15
xAOD::Iso::pileupCorrection
@ pileupCorrection
fully corrected
Definition: Event/xAOD/xAODPrimitives/xAODPrimitives/IsolationCorrection.h:35
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37