Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
HitDecoratorAlg.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 
6 // Header file
8 
9 // Read and write handles
12 
13 
14 
15 namespace 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
27  ATH_CHECK( m_HitContainerKey.initialize() );
28 
29  // Initialize decorator
31  CHECK( m_OutputHitXKey.initialize() );
33  CHECK( m_OutputHitYKey.initialize() );
35  CHECK( m_OutputHitZKey.initialize() );
36 
37  return StatusCode::SUCCESS;
38  }
39 
40 
41  StatusCode HitDecoratorAlg::execute(const EventContext& ctx) const {
42  ATH_MSG_DEBUG( "Executing " << name());
43  // Read out event info
45  if ( !event_info.isValid() ) {
46  ATH_MSG_ERROR("Failed to retrieve event info container with key " << m_eventInfoKey.key() );
47  return StatusCode::FAILURE;
48  }
49 
50  // Read out hits
52  if ( !hits.isValid() ) {
53  ATH_MSG_ERROR("Failed to retrieve hit container with key " << m_HitContainerKey.key() );
54  return StatusCode::FAILURE;
55  }
56 
57  // Set up decorator
61 
62  // Construct beamspot vector
63  const xAOD::EventInfo& ei = *event_info;
64 
65  // Calculate relative hit position to beamsport and decorate it to hits container
66  for (const auto *hit: *hits) {
67  float localX = hit->globalX() - ei.beamPosX();
68  float localY = hit->globalY() - ei.beamPosY();
69  float localZ = hit->globalZ() - ei.beamPosZ();
70 
71  correctedHitX(*hit) = localX;
72  correctedHitY(*hit) = localY;
73  correctedHitZ(*hit) = localZ;
74 
75  }
76 
77  return StatusCode::SUCCESS;
78  }
79 
80 
82  return StatusCode::SUCCESS;
83  }
84 }
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
FlavorTagDiscriminants::HitDecoratorAlg::m_HitContainerKey
SG::ReadHandleKey< xAOD::TrackMeasurementValidationContainer > m_HitContainerKey
Definition: HitDecoratorAlg.h:38
FlavorTagDiscriminants::HitDecoratorAlg::m_OutputHitZKey
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_OutputHitZKey
Definition: HitDecoratorAlg.h:50
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FlavorTagDiscriminants
This file contains "getter" functions used for accessing tagger inputs from the EDM.
Definition: AssociationEnums.h:11
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
FlavorTagDiscriminants::HitDecoratorAlg::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: HitDecoratorAlg.h:41
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
FlavorTagDiscriminants::HitDecoratorAlg::m_OutputHitYKey
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_OutputHitYKey
Definition: HitDecoratorAlg.h:47
xAOD::EventInfo_v1::beamPosX
float beamPosX() const
X coordinate of the beam spot position.
FlavorTagDiscriminants::HitDecoratorAlg::m_OutputHitXKey
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_OutputHitXKey
Definition: HitDecoratorAlg.h:44
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
FlavorTagDiscriminants::HitDecoratorAlg::HitDecoratorAlg
HitDecoratorAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: HitDecoratorAlg.cxx:17
xAOD::EventInfo_v1::beamPosY
float beamPosY() const
Y coordinate of the beam spot position.
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
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
WriteDecorHandle.h
Handle class for adding a decoration to an object.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
xAOD::EventInfo_v1::beamPosZ
float beamPosZ() const
Z coordinate of the beam spot position.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
FlavorTagDiscriminants::HitDecoratorAlg::finalize
virtual StatusCode finalize() override
Definition: HitDecoratorAlg.cxx:81
FlavorTagDiscriminants::HitDecoratorAlg::initialize
virtual StatusCode initialize() override
Definition: HitDecoratorAlg.cxx:22
ReadDecorHandle.h
Handle class for reading a decoration on an object.
FlavorTagDiscriminants::HitDecoratorAlg::execute
virtual StatusCode execute(const EventContext &) const override
Definition: HitDecoratorAlg.cxx:41
HitDecoratorAlg.h