ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonPhaseII
MuonPatternRecognition
MuonTruthAlgsR4
src
MeasTruthAssocMapProvider.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
#include "
MeasTruthAssocMapProvider.h
"
5
6
#include "
MuonTruthHelpers/MuonSimHitHelpers.h
"
7
#include "
xAODTruth/xAODTruthHelpers.h
"
8
9
#include "
StoreGate/WriteHandle.h
"
10
#include "
StoreGate/ReadHandle.h
"
11
12
namespace
MuonR4
{
13
StatusCode
MeasTruthAssocMapProvider::initialize
() {
14
ATH_CHECK
(
m_readKey
.initialize());
15
ATH_CHECK
(
m_linkKey
.initialize());
16
ATH_CHECK
(
m_writeKey
.initialize());
17
ATH_CHECK
(
m_truthKey
.initialize());
18
ATH_CHECK
(
m_segLinkKey
.initialize());
19
ATH_CHECK
(
m_segLinkKey
.initialize());
20
return
StatusCode::SUCCESS;
21
}
22
StatusCode
MeasTruthAssocMapProvider::execute
(
const
EventContext& ctx)
const
{
23
const
xAOD::MuonMeasurementContainer
* measurements{};
24
ATH_CHECK
(
SG::get
(measurements,
m_readKey
, ctx));
25
auto
assocMap = std::make_unique<ActsTrk::MeasurementToTruthParticleAssociation>(measurements->
size
());
26
assocMap->setSourceContainer(*measurements, ctx);
27
for
(
const
xAOD::MuonMeasurement
* meas : *measurements) {
28
const
xAOD::MuonSimHit
* assocHit =
getTruthMatchedHit
(*meas);
29
if
(!assocHit) {
30
continue
;
31
}
32
const
xAOD::TruthParticle
* truthPart =
getTruthMatchedParticle
(*assocHit);
33
if
(!truthPart) {
34
continue
;
35
}
36
(*assocMap)[meas->index()]= {
xAOD::TruthHelpers::getTruthParticle
(*truthPart)};
37
}
38
SG::WriteHandle
writeHandle{
m_writeKey
, ctx};
39
ATH_CHECK
(writeHandle.
record
(std::move(assocMap)));
40
return
StatusCode::SUCCESS;
41
}
42
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
MeasTruthAssocMapProvider.h
MuonSimHitHelpers.h
ReadHandle.h
Handle class for reading from StoreGate.
WriteHandle.h
Handle class for recording to StoreGate.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
MuonR4::MeasTruthAssocMapProvider::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
MeasTruthAssocMapProvider.cxx:22
MuonR4::MeasTruthAssocMapProvider::initialize
virtual StatusCode initialize() override final
Definition
MeasTruthAssocMapProvider.cxx:13
MuonR4::MeasTruthAssocMapProvider::m_readKey
SG::ReadHandleKey< xAOD::MuonMeasurementContainer > m_readKey
Declare the container for which the Association map shall be built.
Definition
MeasTruthAssocMapProvider.h:31
MuonR4::MeasTruthAssocMapProvider::m_truthKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthKey
The dependency on the truth particle container.
Definition
MeasTruthAssocMapProvider.h:36
MuonR4::MeasTruthAssocMapProvider::m_linkKey
SG::ReadDecorHandleKey< xAOD::MuonMeasurementContainer > m_linkKey
Declare the dependency on the associated sim hit.
Definition
MeasTruthAssocMapProvider.h:33
MuonR4::MeasTruthAssocMapProvider::m_segLinkKey
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_segLinkKey
Dependency on the TruthSegment -> TruthParticle association.
Definition
MeasTruthAssocMapProvider.h:38
MuonR4::MeasTruthAssocMapProvider::m_writeKey
SG::WriteHandleKey< ActsTrk::MeasurementToTruthParticleAssociation > m_writeKey
Name of the written association map.
Definition
MeasTruthAssocMapProvider.h:41
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:71
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
MuonR4
This header ties the generic definitions in this package.
Definition
FastRecoUtils.h:12
MuonR4::getTruthMatchedParticle
const xAOD::TruthParticle * getTruthMatchedParticle(const xAOD::MuonSegment &segment)
Returns the particle truth-matched to the segment.
Definition
MuonSimHitHelpers.cxx:114
MuonR4::getTruthMatchedHit
const xAOD::MuonSimHit * getTruthMatchedHit(const xAOD::MuonMeasurement &prdHit)
Returns the MuonSimHit, if there's any, matched to the uncalibrated muon measurement.
Definition
MuonSimHitHelpers.cxx:27
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition
ReadCondHandle.h:281
xAOD::TruthHelpers::getTruthParticle
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any).
Definition
xAODTruthHelpers.cxx:25
xAOD::MuonMeasurement
MuonMeasurement_v1 MuonMeasurement
Definition
MuonMeasurementFwd.h:11
xAOD::MuonSimHit
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.
Definition
MuonSimHit.h:12
xAOD::TruthParticle
TruthParticle_v1 TruthParticle
Typedef to implementation.
Definition
Event/xAOD/xAODTruth/xAODTruth/TruthParticle.h:15
xAOD::MuonMeasurementContainer
MuonMeasurementContainer_v1 MuonMeasurementContainer
Definition
MuonMeasurementContainer.h:12
xAODTruthHelpers.h
Generated on
for ATLAS Offline Software by
1.17.0