ATLAS Offline Software
Loading...
Searching...
No Matches
ExampleAlg.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.
3 */
10
11
12#include "ExampleAlg.h"
13
14
16{
17 // This will check that the properties were initialized properly
18 // by job condifiguration.
19 ATH_CHECK( m_readKey.initialize() );
20 ATH_CHECK( m_writeKey.initialize() );
21 return StatusCode::SUCCESS;
22}
23
24
25StatusCode 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}
#define ATH_CHECK
Evaluate an expression and check for errors.
Example of using handles for data access.
SG::WriteHandleKey< MyDataObj > m_writeKey
Definition ExampleAlg.h:36
virtual StatusCode initialize() override
virtual StatusCode execute(const EventContext &ctx) const override
SG::ReadHandleKey< MyDataObj > m_readKey
Definition ExampleAlg.h:35
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.