Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ExampleAlg.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.
3  */
12 #include "ExampleAlg.h"
13 
14 
16 {
17  // This will check that the properties were initialized properly
18  // by job condifiguration.
21  return StatusCode::SUCCESS;
22 }
23 
24 
25 StatusCode ExampleAlg::execute (const EventContext& ctx) const
26 {
27  // Construct handles from the keys.
28  // Since this is a reentrant algorithm, we have an explicit event context,
29  // which we pass to the handles.
32 
33  // Now we can dereference the read handle to access input data.
34  int newval = h_read->val()+1;
35 
36  // We make a new object, held by a unique_ptr, and record it
37  // in the store using the record method of the handle.
38  ATH_CHECK( h_write.record (std::make_unique<MyDataObj> (newval)) );
39 
40  return StatusCode::SUCCESS;
41 }
ExampleAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: ExampleAlg.cxx:25
SG::ReadHandle< MyDataObj >
MyDataObj::val
void val(int i)
Definition: MyDataObj.h:24
ExampleAlg::m_writeKey
SG::WriteHandleKey< MyDataObj > m_writeKey
Definition: ExampleAlg.h:36
ExampleAlg.h
Example of using handles for data access.
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
ExampleAlg::initialize
virtual StatusCode initialize() override
Definition: ExampleAlg.cxx:15
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ExampleAlg::m_readKey
SG::ReadHandleKey< MyDataObj > m_readKey
Definition: ExampleAlg.h:35