ATLAS Offline Software
Loading...
Searching...
No Matches
BeamSpotFixerAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6
11
12#include "BeamSpotFixerAlg.h"
13
14namespace Simulation
15{
16
17 BeamSpotFixerAlg::BeamSpotFixerAlg( const std::string& name, ISvcLocator* pSvcLocator )
18 : AthReentrantAlgorithm( name, pSvcLocator )
19 {
20 }
21
24 {
25 ATH_CHECK(m_beamSpotKey.initialize());
26
27 ATH_CHECK( m_inputKey.initialize() );
28 ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_inputKey);
29 ATH_CHECK( m_outputKey.initialize() );
30 ATH_MSG_VERBOSE("Initialized WriteHandleKey: " << m_outputKey);
31
32 return StatusCode::SUCCESS;
33 }
34
35 StatusCode BeamSpotFixerAlg::execute(const EventContext& ctx) const
36 {
38 if (!beamSpotHandle.isValid()) {
39 ATH_MSG_ERROR("Beam spot information not valid");
40 return StatusCode::FAILURE;
41 }
42
44 if (!inputEventInfo.isValid()) {
45 ATH_MSG_ERROR("Could not get input xAOD::EventInfo " << inputEventInfo.name() << " from store " << inputEventInfo.store());
46 return StatusCode::FAILURE;
47 }
48 ATH_MSG_DEBUG("Found input xAOD::EventInfo " << inputEventInfo.name() << " in store " << inputEventInfo.store());
49
51 ATH_CHECK(eventInfo.record(std::make_unique<xAOD::EventInfo>(), std::make_unique<xAOD::EventAuxInfo>()));
52 if (!eventInfo.isValid()) {
53 ATH_MSG_ERROR("Could not record output xAOD::EventInfo " << eventInfo.name() << " to store " << eventInfo.store());
54 return StatusCode::FAILURE;
55 }
56 ATH_MSG_DEBUG("Recorded output xAOD::EventInfo " << eventInfo.name() << " in store " << eventInfo.store());
57
58 // Copy the eventInfo data
59 *eventInfo = *inputEventInfo;
60
61 // Copy the beamspot info
62 eventInfo->setBeamPos( beamSpotHandle->beamPos()[ Amg::x ],
63 beamSpotHandle->beamPos()[ Amg::y ],
64 beamSpotHandle->beamPos()[ Amg::z ] );
65 eventInfo->setBeamPosSigma( beamSpotHandle->beamSigma( 0 ),
66 beamSpotHandle->beamSigma( 1 ),
67 beamSpotHandle->beamSigma( 2 ) );
68 eventInfo->setBeamPosSigmaXY( beamSpotHandle->beamSigmaXY() );
69 eventInfo->setBeamTiltXZ( beamSpotHandle->beamTilt( 0 ) );
70 eventInfo->setBeamTiltYZ( beamSpotHandle->beamTilt( 1 ) );
71 eventInfo->setBeamStatus( beamSpotHandle->beamStatus() );
72
73 return StatusCode::SUCCESS;
74 }
75
76} // namespace Simulation
#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)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
An algorithm that can be simultaneously executed in multiple threads.
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.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual StatusCode execute(const EventContext &ctx) const override final
Athena algorithm's interface method execute()
SG::ReadHandleKey< xAOD::EventInfo > m_inputKey
BeamSpotFixerAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
SG::WriteHandleKey< xAOD::EventInfo > m_outputKey
virtual StatusCode initialize() override final
Athena algorithm's interface method initialize()