ATLAS Offline Software
Loading...
Searching...
No Matches
TruthPVzRelativeToBeamspotAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Header file
7
8// Read and write handles
12
13#include <cmath>
14#include <limits>
15
16
17namespace FlavorTagDiscriminants {
18
20 const std::string& name, ISvcLocator* loc)
21 : AthReentrantAlgorithm(name, loc) {}
22
23
25 ATH_MSG_DEBUG("Initializing " << name());
26
27 ATH_CHECK(m_jetCollectionKey.initialize());
28 ATH_CHECK(m_truthPVzKey.initialize());
29 ATH_CHECK(m_outputKey.initialize());
30 ATH_CHECK(m_eventInfoKey.initialize());
31
32 return StatusCode::SUCCESS;
33 }
34
35
36 StatusCode TruthPVzRelativeToBeamspotAlg::execute(const EventContext& ctx) const {
37 ATH_MSG_DEBUG("Executing " << name());
38
39 // Read out jets
41 if(!jets.isValid()) {
42 ATH_MSG_ERROR("Failed to retrieve jet container with key " << m_jetCollectionKey.key());
43 return StatusCode::FAILURE;
44 }
45
46 // Read out the beamspot position
48 if(!eventInfo.isValid()) {
49 ATH_MSG_ERROR("Failed to retrieve EventInfo with key " << m_eventInfoKey.key());
50 return StatusCode::FAILURE;
51 }
52 const double beamPosZ = eventInfo->beamPosZ();
53
56
57 for(const xAOD::IParticle* jet : *jets) {
58 const double zed = truthPVz(*jet);
59 relToBeamspot(*jet) = std::isfinite(zed)
60 ? static_cast<float>(zed - beamPosZ)
61 : std::numeric_limits<float>::quiet_NaN();
62 }
63
64 return StatusCode::SUCCESS;
65 }
66}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading a decoration on an object.
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
An algorithm that can be simultaneously executed in multiple threads.
SG::ReadHandleKey< xAOD::IParticleContainer > m_jetCollectionKey
TruthPVzRelativeToBeamspotAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode execute(const EventContext &ctx) const override
SG::ReadDecorHandleKey< xAOD::IParticleContainer > m_truthPVzKey
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_outputKey
Handle class for reading a decoration on an object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.
Class providing the definition of the 4-vector interface.