ATLAS Offline Software
PflowIsolationDecorAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
6 
7 #include <StoreGate/ReadHandle.h>
9 
10 //**********************************************************************
11 namespace DerivationFramework {
12 PflowIsolationDecorAlg::PflowIsolationDecorAlg(const std::string& name, ISvcLocator* pSvcLocator) :
13  AthReentrantAlgorithm(name, pSvcLocator) {}
14 //**********************************************************************
15 
17  ATH_CHECK(m_isoTool.retrieve());
18 
19  m_calo_corr.calobitset.set(static_cast<unsigned int>(xAOD::Iso::coreCone));
20  m_calo_corr.calobitset.set(static_cast<unsigned int>(xAOD::Iso::pileupCorrection));
21  // isolation types to run. The ptcones each also imply the respective ptvarcone.
22 
24  for (const std::string& decor : m_trkSel_Decors) m_trkSel_keys.emplace_back(m_trk_key, decor);
25  ATH_CHECK(m_trkSel_keys.initialize());
26  m_neflowCone20_key = std::string{"neflowisol20"} + (m_customName.empty() ? "" : "_") + m_customName;
27  m_neflowCone30_key = std::string{"neflowisol30"} + (m_customName.empty() ? "" : "_") + m_customName;
28  m_neflowCone40_key = std::string{"neflowisol40"} + (m_customName.empty() ? "" : "_") + m_customName;
32 
33  ATH_MSG_DEBUG("Decorate " << m_trk_key.fullKey() << " using '" << m_customName << "' as suffix.");
34  return StatusCode::SUCCESS;
35 }
36 
37 //**********************************************************************
38 
39 StatusCode PflowIsolationDecorAlg::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  FloatDecor neflowCone40_dec{makeHandle<float>(ctx,m_neflowCone40_key, -Gaudi::Units::GeV)};
55  FloatDecor neflowCone30_dec{makeHandle<float>(ctx,m_neflowCone30_key, -Gaudi::Units::GeV)};
56  FloatDecor neflowCone20_dec{makeHandle<float>(ctx,m_neflowCone20_key, -Gaudi::Units::GeV)};
57 
58 
59  for (const xAOD::TrackParticle* trk : *tracks) {
60  if (trk->pt() < m_pt_min) continue;
61  if (!selDecors.empty() && std::find_if(selDecors.begin(), selDecors.end(), [trk](const SelDecorator& dec){
62  return dec(*trk);
63  }) == selDecors.end()) continue;
64  ATH_MSG_DEBUG("Recomputing isolation by hand");
65  xAOD::CaloIsolation resultCalo;
66  if (!m_isoTool->neutralEflowIsolation(resultCalo, *trk, m_pflow_isos, m_calo_corr)) {
67  ATH_MSG_ERROR("Failed to compute calorimeter isolation");
68  return StatusCode::FAILURE;
69  }
70  neflowCone40_dec(*trk) = resultCalo.etcones[0];
71  neflowCone30_dec(*trk) = resultCalo.etcones[1];
72  neflowCone20_dec(*trk) = resultCalo.etcones[2];
73  }
74  return StatusCode::SUCCESS;
75 }
76 }
77 //**********************************************************************
DerivationFramework::PflowIsolationDecorAlg::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: PflowIsolationDecorAlg.h:45
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
Utils.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
DerivationFramework::PflowIsolationDecorAlg::m_neflowCone30_key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_neflowCone30_key
Definition: PflowIsolationDecorAlg.h:52
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
DerivationFramework::PflowIsolationDecorAlg::PflowIsolationDecorAlg
PflowIsolationDecorAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Definition: PflowIsolationDecorAlg.cxx:12
xAOD::CaloIsolation
Definition: IsolationCommon.h:22
DerivationFramework::PflowIsolationDecorAlg::m_pflow_isos
std::vector< xAOD::Iso::IsolationType > m_pflow_isos
Definition: PflowIsolationDecorAlg.h:57
DerivationFramework::PflowIsolationDecorAlg::m_neflowCone20_key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_neflowCone20_key
Definition: PflowIsolationDecorAlg.h:50
DerivationFramework::PflowIsolationDecorAlg::m_trkSel_keys
SG::ReadDecorHandleKeyArray< xAOD::TrackParticleContainer > m_trkSel_keys
Definition: PflowIsolationDecorAlg.h:47
PflowIsolationDecorAlg.h
DerivationFramework::PflowIsolationDecorAlg::m_neflowCone40_key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_neflowCone40_key
Definition: PflowIsolationDecorAlg.h:54
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
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:99
WriteDecorHandle.h
Handle class for adding a decoration to an object.
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
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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::PflowIsolationDecorAlg::m_isoTool
ToolHandle< xAOD::INeutralEFlowIsolationTool > m_isoTool
Athena configured tools.
Definition: PflowIsolationDecorAlg.h:32
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::PflowIsolationDecorAlg::m_trk_key
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trk_key
track collection to decorate
Definition: PflowIsolationDecorAlg.h:36
DerivationFramework::PflowIsolationDecorAlg::m_pt_min
Gaudi::Property< float > m_pt_min
pt threshold to apply
Definition: PflowIsolationDecorAlg.h:39
DerivationFramework::PflowIsolationDecorAlg::initialize
StatusCode initialize() override
Athena algorithm's Hooks.
Definition: PflowIsolationDecorAlg.cxx:16
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::PflowIsolationDecorAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition: PflowIsolationDecorAlg.cxx:39
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
DerivationFramework::PflowIsolationDecorAlg::m_customName
Gaudi::Property< std::string > m_customName
Definition: PflowIsolationDecorAlg.h:41
DerivationFramework::PflowIsolationDecorAlg::m_calo_corr
xAOD::CaloCorrection m_calo_corr
Definition: PflowIsolationDecorAlg.h:33
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