ATLAS Offline Software
Loading...
Searching...
No Matches
HitDecoratorAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6// Header file
8
9// Read and write handles
12
13
14
15namespace FlavorTagDiscriminants {
16
18 const std::string& name, ISvcLocator* loc )
19 : AthReentrantAlgorithm(name, loc) {}
20
21
23 ATH_MSG_INFO( "Initializing " << name());
24
25 // Initialize reader
26 ATH_CHECK( m_eventInfoKey.initialize() );
27 ATH_CHECK( m_HitContainerKey.initialize() );
28
29 // Initialize decorator
30 ATH_CHECK( m_OutputHitXKey.initialize() );
31 ATH_CHECK( m_OutputHitYKey.initialize() );
32 ATH_CHECK( m_OutputHitZKey.initialize() );
33
34 return StatusCode::SUCCESS;
35 }
36
37
38 StatusCode HitDecoratorAlg::execute(const EventContext& ctx) const {
39 ATH_MSG_DEBUG( "Executing " << name());
40 // Read out event info
42 if ( !event_info.isValid() ) {
43 ATH_MSG_ERROR("Failed to retrieve event info container with key " << m_eventInfoKey.key() );
44 return StatusCode::FAILURE;
45 }
46
47 // Read out hits
49 if ( !hits.isValid() ) {
50 ATH_MSG_ERROR("Failed to retrieve hit container with key " << m_HitContainerKey.key() );
51 return StatusCode::FAILURE;
52 }
53
54 // Set up decorator
58
59 // Construct beamspot vector
60 const xAOD::EventInfo& ei = *event_info;
61
62 // Calculate relative hit position to beamsport and decorate it to hits container
63 for (const auto *hit: *hits) {
64 float localX = hit->globalX() - ei.beamPosX();
65 float localY = hit->globalY() - ei.beamPosY();
66 float localZ = hit->globalZ() - ei.beamPosZ();
67
68 correctedHitX(*hit) = localX;
69 correctedHitY(*hit) = localY;
70 correctedHitZ(*hit) = localZ;
71
72 }
73
74 return StatusCode::SUCCESS;
75 }
76
77
79 return StatusCode::SUCCESS;
80 }
81}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading a decoration on an object.
Handle class for adding a decoration to an object.
An algorithm that can be simultaneously executed in multiple threads.
HitDecoratorAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::TrackMeasurementValidationContainer > m_HitContainerKey
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_OutputHitXKey
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_OutputHitZKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_OutputHitYKey
virtual StatusCode execute(const EventContext &) const override
virtual StatusCode finalize() override
virtual StatusCode initialize() override
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.
float beamPosX() const
X coordinate of the beam spot position.
float beamPosZ() const
Z coordinate of the beam spot position.
float beamPosY() const
Y coordinate of the beam spot position.
EventInfo_v1 EventInfo
Definition of the latest event info version.