ATLAS Offline Software
Loading...
Searching...
No Matches
PflowIsolationDecorAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
6
9
10//**********************************************************************
11namespace DerivationFramework {
12PflowIsolationDecorAlg::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
23 ATH_CHECK(m_trk_key.initialize());
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;
29 ATH_CHECK(m_neflowCone20_key.initialize());
30 ATH_CHECK(m_neflowCone30_key.initialize());
31 ATH_CHECK(m_neflowCone40_key.initialize());
32
33 ATH_MSG_DEBUG("Decorate " << m_trk_key.fullKey() << " using '" << m_customName << "' as suffix.");
34 return StatusCode::SUCCESS;
35}
36
37//**********************************************************************
38
39StatusCode 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//**********************************************************************
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
An algorithm that can be simultaneously executed in multiple threads.
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_neflowCone30_key
Gaudi::Property< float > m_pt_min
pt threshold to apply
std::vector< xAOD::Iso::IsolationType > m_pflow_isos
PflowIsolationDecorAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
ToolHandle< xAOD::INeutralEFlowIsolationTool > m_isoTool
Athena configured tools.
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_neflowCone40_key
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trk_key
track collection to decorate
SG::ReadDecorHandleKeyArray< xAOD::TrackParticleContainer > m_trkSel_keys
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_neflowCone20_key
StatusCode initialize() override
Athena algorithm's Hooks.
Gaudi::Property< std::vector< std::string > > m_trkSel_Decors
Optional list of decorators to select only the good tracks for the isolation decoration.
StatusCode execute(const EventContext &ctx) const override
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Handle class for reading a decoration on an object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.
THE reconstruction tool.
SG::WriteDecorHandle< ContType, dType > makeHandle(const EventContext &ctx, const SG::WriteDecorHandleKey< ContType > &key, const dType &defValue=dType{})
TrackParticle_v1 TrackParticle
Reference the current persistent version:
std::vector< float > etcones