ATLAS Offline Software
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 
14 namespace DerivationFramework {
17  }
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 
33 StatusCode 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;
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 }
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DerivationFramework::IDTrackCaloDepositsDecoratorAlg::m_partKey
SG::ReadHandleKey< xAOD::IParticleContainer > m_partKey
Particle container to decorate the Pivot plane coordinates to.
Definition: IDTrackCaloDepositsDecoratorAlg.h:37
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
Utils.h
IDTrackCaloDepositsDecoratorAlg.h
Muon.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
DerivationFramework::IDTrackCaloDepositsDecoratorAlg::m_trkSelKeys
SG::ReadDecorHandleKeyArray< xAOD::IParticleContainer > m_trkSelKeys
Definition: IDTrackCaloDepositsDecoratorAlg.h:46
DerivationFramework::IDTrackCaloDepositsDecoratorAlg::m_elossKey
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_elossKey
Definition: IDTrackCaloDepositsDecoratorAlg.h:51
skel.it
it
Definition: skel.GENtoEVGEN.py:423
DerivationFramework::IDTrackCaloDepositsDecoratorAlg::m_typeKey
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_typeKey
Definition: IDTrackCaloDepositsDecoratorAlg.h:53
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
DerivationFramework::IDTrackCaloDepositsDecoratorAlg::initialize
StatusCode initialize() override
Definition: IDTrackCaloDepositsDecoratorAlg.cxx:19
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition: Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
InDet::ExclusiveOrigin::Primary
@ Primary
Definition: InDetTrackTruthOriginDefs.h:163
xAOD::TrackParticle_v1::perigeeParameters
const Trk::Perigee & perigeeParameters() const
Returns the Trk::MeasuredPerigee track parameters.
Definition: TrackParticle_v1.cxx:485
DerivationFramework::IDTrackCaloDepositsDecoratorAlg::IDTrackCaloDepositsDecoratorAlg
IDTrackCaloDepositsDecoratorAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: IDTrackCaloDepositsDecoratorAlg.cxx:15
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
DerivationFramework::IDTrackCaloDepositsDecoratorAlg::m_ptMin
Gaudi::Property< float > m_ptMin
Definition: IDTrackCaloDepositsDecoratorAlg.h:39
beamspotman.n
n
Definition: beamspotman.py:731
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
WriteDecorHandle.h
Handle class for adding a decoration to an object.
DepositInCalo.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
DepositInCalo
class describing the measured energy loss associated to muons on the detector level,...
Definition: DepositInCalo.h:23
DerivationFramework::IDTrackCaloDepositsDecoratorAlg::m_trkSelDecors
Gaudi::Property< std::vector< std::string > > m_trkSelDecors
Optional list of decorators to select only the good tracks for the isolation decoration.
Definition: IDTrackCaloDepositsDecoratorAlg.h:44
DerivationFramework::IDTrackCaloDepositsDecoratorAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition: IDTrackCaloDepositsDecoratorAlg.cxx:33
CaloCellContainer.h
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
Muon
struct TBPatternUnitContext Muon
TrackParticle.h
DerivationFramework::IDTrackCaloDepositsDecoratorAlg::m_trkDepositInCalo
ToolHandle< ITrackDepositInCaloTool > m_trkDepositInCalo
Definition: IDTrackCaloDepositsDecoratorAlg.h:34
DerivationFramework::IDTrackCaloDepositsDecoratorAlg::m_depositKey
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_depositKey
Definition: IDTrackCaloDepositsDecoratorAlg.h:49
ReadDecorHandle.h
Handle class for reading a decoration on an object.
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
SG::ReadDecorHandleKey
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Definition: StoreGate/StoreGate/ReadDecorHandleKey.h:85
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37