ATLAS Offline Software
Loading...
Searching...
No Matches
ViewMergeAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// AthExStoreGateExample includes
6#include "ViewMergeAlg.h"
8
9// STL includes
10
11// FrameWork includes
12#include "Gaudi/Property.h"
15
16namespace AthViews {
17
19{
20 ATH_MSG_INFO ("Initializing " << name() << "...");
21
22 CHECK( m_r_ints.initialize() );
23 CHECK( m_w_ints.initialize() );
24 CHECK( m_r_views.initialize() );
25
26 return StatusCode::SUCCESS;
27}
28
30{
31 ATH_MSG_INFO ("Finalizing " << name() << "...");
32
33 return StatusCode::SUCCESS;
34}
35
36StatusCode ViewMergeAlg::execute(const EventContext& ctx) const
37{
38 ATH_MSG_DEBUG ("Executing " << name() << "...");
39
40 //Merge results
41 std::vector< int > outputVector;
43 ViewHelper::ViewMerger merger( evtStore().get(), msg() );
44 CHECK( merger.mergeViewCollection( *inputViews, //Vector of views (inside ReadHandle)
45 m_r_ints, //ReadHandleKey to access the views
46 ctx, //The context of this algorithm
47 outputVector ) ); //Container to merge results into
48
49 //Output the merged data
50 SG::WriteHandle< std::vector< int > > outputHandle( m_w_ints, ctx );
51 CHECK( outputHandle.record( std::make_unique< std::vector< int > >( outputVector ) ) );
52 if ( !outputHandle.isValid() )
53 {
54 ATH_MSG_INFO( "Unable to load main event store for output" );
55 }
56
57 for ( int const test : outputVector )
58 {
59 ATH_MSG_INFO( test );
60 }
61
62 return StatusCode::SUCCESS;
63}
64
65} //> end namespace AthViews
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
SG::ReadHandleKey< ViewContainer > m_r_views
SG::WriteHandleKey< std::vector< int > > m_w_ints
SG::ReadHandleKey< std::vector< int > > m_r_ints
virtual StatusCode initialize() override
virtual StatusCode execute(const EventContext &ctx) const override
virtual StatusCode finalize() override
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?
StatusCode mergeViewCollection(ViewContainer const &viewVector, SG::ReadHandleKey< T > const &queryKey, EventContext const &sourceContext, T &outputData)
Definition ViewHelper.h:144
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:132