ATLAS Offline Software
Loading...
Searching...
No Matches
RPC_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
6
7
8RPC_HitsTruthRelink::RPC_HitsTruthRelink(const std::string &name, ISvcLocator *pSvcLocator)
9 : HitsTruthRelinkBase(name, pSvcLocator)
10{
11}
12
13
15{
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
27StatusCode RPC_HitsTruthRelink::execute(const EventContext &ctx) const
28{
29 ATH_MSG_DEBUG("Doing truth relinking");
30
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
39 ATH_CHECK(outputCollection.record(std::make_unique<RPCSimHitCollection>()));
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 RPCSimHit & hit : *inputCollection) {
51 HepMcParticleLink particleLink = updatedLink(ctx, hit.particleLink(), referenceId);
52 int id = hit.RPCid();
53 double time = hit.globalTime();
54 Amg::Vector3D prePos = hit.preLocalPosition();
55 Amg::Vector3D postPos = hit.postLocalPosition();
56 double energyDeposit = hit.energyDeposit();
57 int pdgID = hit.particleEncoding();
58 double kineticEnergy = hit.kineticEnergy();
59 double stepLength = hit.stepLength();
60
61 outputCollection->Emplace(id, time, prePos, particleLink, postPos, energyDeposit, stepLength, pdgID, kineticEnergy);
62 }
63
64 return StatusCode::SUCCESS;
65}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
virtual StatusCode initialize() override
virtual HepMcParticleLink updatedLink(const EventContext &ctx, const HepMcParticleLink &oldLink, int referenceId, int pdgID=0) const
StatusCode getReferenceId(const EventContext &ctx, int *id) const
HitsTruthRelinkBase(const std::string &name, ISvcLocator *pSvcLocator)
virtual bool isValid() override final
Can the handle be successfully dereferenced?
std::string store() const
Return the name of the store holding the object we are proxying.
const std::string & name() const
Return the StoreGate ID for the referenced object.
Eigen::Matrix< double, 3, 1 > Vector3D