ATLAS Offline Software
Simulation
Tools
McEventCollectionFilter
src
MDT_HitsTruthRelink.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
MDT_HitsTruthRelink.h
"
6
7
8
MDT_HitsTruthRelink::MDT_HitsTruthRelink
(
const
std::string &
name
, ISvcLocator *pSvcLocator)
9
:
HitsTruthRelinkBase
(
name
, pSvcLocator)
10
{
11
}
12
13
14
StatusCode
MDT_HitsTruthRelink::initialize
()
15
{
16
ATH_CHECK
(
HitsTruthRelinkBase::initialize
());
17
18
// Check and initialize keys
19
ATH_CHECK
(
m_inputHitsKey
.initialize() );
20
ATH_MSG_VERBOSE
(
"Initialized ReadHandleKey: "
<<
m_inputHitsKey
);
21
ATH_CHECK
(
m_outputHitsKey
.initialize() );
22
ATH_MSG_VERBOSE
(
"Initialized WriteHandleKey: "
<<
m_outputHitsKey
);
23
return
StatusCode::SUCCESS;
24
}
25
26
27
StatusCode
MDT_HitsTruthRelink::execute
(
const
EventContext &ctx)
const
28
{
29
ATH_MSG_DEBUG
(
"Doing truth relinking"
);
30
31
SG::ReadHandle<MDTSimHitCollection>
inputCollection(
m_inputHitsKey
, ctx);
32
if
(!inputCollection.
isValid
()) {
33
ATH_MSG_ERROR
(
"Could not get input hits collection "
<< inputCollection.
name
() <<
" from store "
<< inputCollection.
store
());
34
return
StatusCode::FAILURE;
35
}
36
ATH_MSG_DEBUG
(
"Found input hits collection "
<< inputCollection.
name
() <<
" in store "
<< inputCollection.
store
());
37
38
SG::WriteHandle<MDTSimHitCollection>
outputCollection
(
m_outputHitsKey
, ctx);
39
ATH_CHECK
(
outputCollection
.record(std::make_unique<MDTSimHitCollection>()));
40
if
(!
outputCollection
.isValid()) {
41
ATH_MSG_ERROR
(
"Could not record output hits collection "
<<
outputCollection
.name() <<
" to store "
<<
outputCollection
.store());
42
return
StatusCode::FAILURE;
43
}
44
ATH_MSG_DEBUG
(
"Recorded output hits collection "
<<
outputCollection
.name() <<
" in store "
<<
outputCollection
.store());
45
46
// Do relinking
47
int
referenceId{};
48
ATH_CHECK
(
getReferenceId
(ctx, &referenceId));
49
50
for
(
const
MDTSimHit
&hit : *inputCollection) {
51
HepMcParticleLink
particleLink =
updatedLink
(ctx, hit.particleLink(), referenceId);
52
int
id
= hit.MDTid();
53
double
time
= hit.globalTime();
54
double
radius
= hit.driftRadius();
55
Amg::Vector3D
position = hit.localPosition();
56
double
stepLength = hit.stepLength();
57
double
energyDeposit
= hit.energyDeposit();
58
int
pdgID = hit.particleEncoding();
59
double
kineticEnergy = hit.kineticEnergy();
60
61
outputCollection
->Emplace(
id
,
time
,
radius
, position, particleLink, stepLength,
energyDeposit
, pdgID, kineticEnergy);
62
}
63
64
return
StatusCode::SUCCESS;
65
}
MDT_HitsTruthRelink::MDT_HitsTruthRelink
MDT_HitsTruthRelink(const std::string &name, ISvcLocator *pSvcLocator)
Definition:
MDT_HitsTruthRelink.cxx:8
SG::ReadHandle
Definition:
StoreGate/StoreGate/ReadHandle.h:70
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition:
AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
MDTSimHit
Definition:
MDTSimHit.h:21
HitsTruthRelinkBase::getReferenceId
StatusCode getReferenceId(const EventContext &ctx, int *id) const
Definition:
HitsTruthRelinkBase.cxx:64
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition:
AthMsgStreamMacros.h:28
Trk::energyDeposit
@ energyDeposit
Definition:
MeasurementType.h:32
HitsTruthRelinkBase::initialize
virtual StatusCode initialize() override
Definition:
HitsTruthRelinkBase.cxx:14
HepMcParticleLink
a link optimized in size for a GenParticle in a McEventCollection
Definition:
HepMcParticleLink.h:72
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition:
AthMsgStreamMacros.h:33
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
MDT_HitsTruthRelink.h
SG::VarHandleBase::store
std::string store() const
Return the name of the store holding the object we are proxying.
Definition:
StoreGate/src/VarHandleBase.cxx:376
ATH_CHECK
#define ATH_CHECK
Definition:
AthCheckMacros.h:40
HitsTruthRelinkBase::updatedLink
virtual HepMcParticleLink updatedLink(const EventContext &ctx, const HepMcParticleLink &oldLink, int referenceId, int pdgID=0) const
Definition:
HitsTruthRelinkBase.cxx:107
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
postInclude.outputCollection
outputCollection
Definition:
postInclude.SortInput.py:27
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:221
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition:
GeoPrimitives.h:47
ParticleGun_SamplingFraction.radius
radius
Definition:
ParticleGun_SamplingFraction.py:96
MDT_HitsTruthRelink::m_inputHitsKey
SG::ReadHandleKey< MDTSimHitCollection > m_inputHitsKey
Definition:
MDT_HitsTruthRelink.h:23
SG::WriteHandle
Definition:
StoreGate/StoreGate/WriteHandle.h:76
MDT_HitsTruthRelink::m_outputHitsKey
SG::WriteHandleKey< MDTSimHitCollection > m_outputHitsKey
Definition:
MDT_HitsTruthRelink.h:24
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition:
CaloSwCorrections.py:242
MDT_HitsTruthRelink::initialize
virtual StatusCode initialize() override
Definition:
MDT_HitsTruthRelink.cxx:14
HitsTruthRelinkBase
Definition:
HitsTruthRelinkBase.h:15
MDT_HitsTruthRelink::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition:
MDT_HitsTruthRelink.cxx:27
Generated on Thu Nov 7 2024 21:20:35 for ATLAS Offline Software by
1.8.18