ATLAS Offline Software
Loading...
Searching...
No Matches
IDTrackCaloDepositsDecoratorAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
9#include "xAODMuon/Muon.h"
13
14namespace DerivationFramework {
18
20 ATH_CHECK(m_trkDepositInCalo.retrieve());
21
22 ATH_CHECK(m_partKey.initialize());
23 for (const std::string& decor : m_trkSelDecors) {
24 m_trkSelKeys.emplace_back(m_partKey, decor);
25 }
26 ATH_CHECK(m_trkSelKeys.initialize());
27 ATH_CHECK(m_depositKey.initialize());
28 ATH_CHECK(m_elossKey.initialize());
29 ATH_CHECK(m_typeKey.initialize());
30 return StatusCode::SUCCESS;
31}
32
33StatusCode IDTrackCaloDepositsDecoratorAlg::execute(const EventContext& ctx) const {
34
36 if (!tracks.isPresent()) {
37 ATH_MSG_FATAL("Failed to retrieve "<< m_partKey.fullKey());
38 return StatusCode::FAILURE;
39 }
40 auto dec_deposit = makeHandle<std::vector<float>>(ctx, m_depositKey);
41 auto dec_eloss = makeHandle<std::vector<float>>(ctx, m_elossKey);
42 auto dec_type = makeHandle<std::vector<uint16_t>>(ctx, m_typeKey);
43
45
46 std::vector<SelDecorator> selDecors;
48 selDecors.emplace_back(key, ctx);
49 }
50 for (const xAOD::IParticle* particle : *tracks) {
51 if (particle->pt() < m_ptMin) continue;
52 if (!selDecors.empty() && std::find_if(selDecors.begin(), selDecors.end(),
53 [particle](const SelDecorator& dec){
54 return dec(*particle);
55 }) == selDecors.end()) continue;
56 ATH_MSG_DEBUG("Recomputing calo deposition by hand");
57
58 const xAOD::TrackParticle* track_part = nullptr;
59 if (particle->type() == xAOD::Type::ObjectType::TrackParticle) {
60 track_part = static_cast<const xAOD::TrackParticle*>(particle);
61 } else if (particle->type() == xAOD::Type::ObjectType::Muon) {
62 const xAOD::Muon* muon = static_cast<const xAOD::Muon*>(particle);
63 track_part = muon->trackParticle(xAOD::Muon::InnerDetectorTrackParticle);
64 if (!track_part) {
65 ATH_MSG_VERBOSE("The muon does not have an associated ID track");
66 track_part = muon->trackParticle(xAOD::Muon::Primary);
67 }
68 }
69 if (!track_part) {
70 ATH_MSG_ERROR("Unable to retrieve xAOD::TrackParticle from probe object");
71 return StatusCode::FAILURE;
72 }
73
74 const CaloCellContainer* caloCellCont = nullptr;
75 std::vector<DepositInCalo> deposits = m_trkDepositInCalo->getDeposits(&(track_part->perigeeParameters()), caloCellCont);
76 std::vector<float>& dep_val{dec_deposit(*particle)};
77 std::vector<float>& eloss_val{dec_eloss(*particle)};
78 std::vector<uint16_t>& types{dec_type(*particle)};
79 dep_val.reserve(deposits.size());
80 eloss_val.reserve(deposits.size());
81 types.reserve(deposits.size());
82 for (const DepositInCalo& it : deposits) {
83 dep_val.push_back(it.energyDeposited());
84 eloss_val.push_back(it.muonEnergyLoss());
85 types.push_back(it.subCaloId());
86 }
87 }
88 return StatusCode::SUCCESS;
89}
90}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(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.
An algorithm that can be simultaneously executed in multiple threads.
Container class for CaloCell.
class describing the measured energy loss associated to muons on the detector level,...
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_typeKey
IDTrackCaloDepositsDecoratorAlg(const std::string &name, ISvcLocator *pSvcLocator)
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.
bool isPresent() const
Is the referenced object present in SG?
Class providing the definition of the 4-vector interface.
const Trk::Perigee & perigeeParameters() const
Returns the Trk::MeasuredPerigee track parameters.
THE reconstruction tool.
SG::WriteDecorHandle< ContType, dType > makeHandle(const EventContext &ctx, const SG::WriteDecorHandleKey< ContType > &key, const dType &defValue=dType{})
@ 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: