ATLAS Offline Software
Loading...
Searching...
No Matches
IDTrackCaloDepositsDecoratorAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
8#include "xAODMuon/Muon.h"
13
14namespace DerivationFramework {
15
16
18 ATH_CHECK(m_trkDepositInCalo.retrieve());
19
20 ATH_CHECK(m_partKey.initialize());
21 for (const std::string& decor : m_trkSelDecors) {
22 m_trkSelKeys.emplace_back(m_partKey, decor);
23 }
24 ATH_CHECK(m_trkSelKeys.initialize());
25 ATH_CHECK(m_depositKey.initialize());
26 ATH_CHECK(m_elossKey.initialize());
27 ATH_CHECK(m_typeKey.initialize());
28 return StatusCode::SUCCESS;
29}
30
31StatusCode IDTrackCaloDepositsDecoratorAlg::execute(const EventContext& ctx) const {
32
33 const xAOD::IParticleContainer* tracks{};
34 ATH_CHECK(SG::get(tracks, m_partKey, ctx));
35
39
41
42 std::vector<SelDecorator> selDecors;
44 selDecors.emplace_back(key, ctx);
45 }
46 for (const xAOD::IParticle* particle : *tracks) {
47 if (particle->pt() < m_ptMin) continue;
48 if (!selDecors.empty() && std::find_if(selDecors.begin(), selDecors.end(),
49 [particle](const SelDecorator& dec){
50 return dec(*particle);
51 }) == selDecors.end()) continue;
52 ATH_MSG_DEBUG("Recomputing calo deposition by hand");
53
54 const xAOD::TrackParticle* track_part = nullptr;
55 if (particle->type() == xAOD::Type::ObjectType::TrackParticle) {
56 track_part = static_cast<const xAOD::TrackParticle*>(particle);
57 } else if (particle->type() == xAOD::Type::ObjectType::Muon) {
58 const xAOD::Muon* muon = static_cast<const xAOD::Muon*>(particle);
59 track_part = muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle);
60 if (!track_part) {
61 ATH_MSG_VERBOSE("The muon does not have an associated ID track");
62 track_part = muon->trackParticle(xAOD::Muon::TrackParticleType::Primary);
63 }
64 }
65 if (!track_part) {
66 ATH_MSG_ERROR("Unable to retrieve xAOD::TrackParticle from probe object");
67 return StatusCode::FAILURE;
68 }
69
70 const CaloCellContainer* caloCellCont = nullptr;
71 std::vector<DepositInCalo> deposits = m_trkDepositInCalo->getDeposits(&(track_part->perigeeParameters()), caloCellCont);
72 std::vector<float>& dep_val{dec_deposit(*particle)};
73 std::vector<float>& eloss_val{dec_eloss(*particle)};
74 std::vector<uint16_t>& types{dec_type(*particle)};
75 dep_val.reserve(deposits.size());
76 eloss_val.reserve(deposits.size());
77 types.reserve(deposits.size());
78 for (const DepositInCalo& it : deposits) {
79 dep_val.push_back(it.energyDeposited());
80 eloss_val.push_back(it.muonEnergyLoss());
81 types.push_back(it.subCaloId());
82 }
83 }
84 return StatusCode::SUCCESS;
85}
86}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
static const std::vector< std::string > types
Handle class for reading a decoration on an object.
Handle class for adding a decoration to an object.
Container class for CaloCell.
class describing the measured energy loss associated to muons on the detector level,...
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_typeKey
SG::ReadHandleKey< xAOD::IParticleContainer > m_partKey
Particle container to decorate the Pivot plane coordinates to.
StatusCode execute(const EventContext &ctx) const override
Gaudi::Property< std::vector< std::string > > m_trkSelDecors
Optional list of decorators to select only the good tracks for the isolation decoration.
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_elossKey
SG::ReadDecorHandleKeyArray< xAOD::IParticleContainer > m_trkSelKeys
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_depositKey
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Handle class for reading a decoration on an object.
Auxiliary class to instantiate WriteDecorHandles.The handles can be created in an empty state.
Class providing the definition of the 4-vector interface.
const Trk::Perigee & perigeeParameters() const
Returns the Trk::MeasuredPerigee track parameters.
THE reconstruction tool.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
@ TrackParticle
The object is a charged track particle.
Definition ObjectType.h:43
@ Muon
The object is a muon.
Definition ObjectType.h:48
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Muon_v1 Muon
Reference the current persistent version:
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.