ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
Tools
McEventCollectionFilter
src
SiliconHitsTruthRelink.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 "
SiliconHitsTruthRelink.h
"
6
7
8
SiliconHitsTruthRelink::SiliconHitsTruthRelink
(
const
std::string &name, ISvcLocator *pSvcLocator)
9
:
HitsTruthRelinkBase
(name, pSvcLocator)
10
{
11
}
12
13
14
StatusCode
SiliconHitsTruthRelink::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
SiliconHitsTruthRelink::execute
(
const
EventContext &ctx)
const
28
{
29
ATH_MSG_DEBUG
(
"Doing truth relinking"
);
30
31
SG::ReadHandle<SiHitCollection>
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<SiHitCollection>
outputCollection(
m_outputHitsKey
, ctx);
39
ATH_CHECK
(outputCollection.record(std::make_unique<SiHitCollection>()));
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
SiHit
&
hit
: *inputCollection) {
51
HepMcParticleLink
particleLink =
updatedLink
(ctx,
hit
.particleLink(), referenceId);
52
HepGeom::Point3D<double> lP1 =
hit
.localStartPosition();
53
HepGeom::Point3D<double> lP2 =
hit
.localEndPosition();
54
double
energyLoss =
hit
.energyLoss();
55
double
meanTime =
hit
.meanTime();
56
unsigned
int
id
=
hit
.identify();
57
outputCollection->Emplace(lP1, lP2, energyLoss, meanTime, particleLink,
id
);
58
}
59
60
return
StatusCode::SUCCESS;
61
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
SiliconHitsTruthRelink.h
HepMcParticleLink
a link optimized in size for a GenParticle in a McEventCollection
Definition
HepMcParticleLink.h:72
HitsTruthRelinkBase::initialize
virtual StatusCode initialize() override
Definition
HitsTruthRelinkBase.cxx:14
HitsTruthRelinkBase::updatedLink
virtual HepMcParticleLink updatedLink(const EventContext &ctx, const HepMcParticleLink &oldLink, int referenceId, int pdgID=0) const
Definition
HitsTruthRelinkBase.cxx:85
HitsTruthRelinkBase::getReferenceId
StatusCode getReferenceId(const EventContext &ctx, int *id) const
Definition
HitsTruthRelinkBase.cxx:53
HitsTruthRelinkBase::HitsTruthRelinkBase
HitsTruthRelinkBase(const std::string &name, ISvcLocator *pSvcLocator)
Definition
HitsTruthRelinkBase.cxx:8
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::VarHandleBase::store
std::string store() const
Return the name of the store holding the object we are proxying.
Definition
StoreGate/src/VarHandleBase.cxx:382
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition
AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SiHit
Definition
SiHit.h:19
SiliconHitsTruthRelink::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
SiliconHitsTruthRelink.cxx:27
SiliconHitsTruthRelink::m_inputHitsKey
SG::ReadHandleKey< SiHitCollection > m_inputHitsKey
Definition
SiliconHitsTruthRelink.h:23
SiliconHitsTruthRelink::initialize
virtual StatusCode initialize() override
Definition
SiliconHitsTruthRelink.cxx:14
SiliconHitsTruthRelink::SiliconHitsTruthRelink
SiliconHitsTruthRelink(const std::string &name, ISvcLocator *pSvcLocator)
Definition
SiliconHitsTruthRelink.cxx:8
SiliconHitsTruthRelink::m_outputHitsKey
SG::WriteHandleKey< SiHitCollection > m_outputHitsKey
Definition
SiliconHitsTruthRelink.h:24
Generated on
for ATLAS Offline Software by
1.17.0