ATLAS Offline Software
Loading...
Searching...
No Matches
ViewMergeAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 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// Public methods:
21
22// Constructors
24ViewMergeAlg::ViewMergeAlg( const std::string& name,
25 ISvcLocator* pSvcLocator ) :
26 ::AthAlgorithm( name, pSvcLocator ),
27 m_r_ints( "dflow_ints" )
28{
29}
30
31// Destructor
35
36// Athena Algorithm's Hooks
39{
40 ATH_MSG_INFO ("Initializing " << name() << "...");
41
42 CHECK( m_r_ints.initialize() );
43 CHECK( m_w_ints.initialize() );
44 CHECK( m_r_views.initialize() );
45
46 return StatusCode::SUCCESS;
47}
48
50{
51 ATH_MSG_INFO ("Finalizing " << name() << "...");
52
53 return StatusCode::SUCCESS;
54}
55
57{
58 ATH_MSG_DEBUG ("Executing " << name() << "...");
59
60 const EventContext& ctx = getContext();
61
62 //Merge results
63 std::vector< int > outputVector;
65 ViewHelper::ViewMerger merger( evtStore().get(), msg() );
66 CHECK( merger.mergeViewCollection( *inputViews, //Vector of views (inside ReadHandle)
67 m_r_ints, //ReadHandleKey to access the views
68 ctx, //The context of this algorithm
69 outputVector ) ); //Container to merge results into
70
71 //Output the merged data
72 SG::WriteHandle< std::vector< int > > outputHandle( m_w_ints, ctx );
73 CHECK( outputHandle.record( std::make_unique< std::vector< int > >( outputVector ) ) );
74 if ( !outputHandle.isValid() )
75 {
76 ATH_MSG_INFO( "Unable to load main event store for output" );
77 }
78
79 for ( int const test : outputVector )
80 {
81 ATH_MSG_INFO( test );
82 }
83
84 return StatusCode::SUCCESS;
85}
86
87} //> 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.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
MsgStream & msg() const
virtual StatusCode execute()
SG::ReadHandleKey< ViewContainer > m_r_views
virtual StatusCode finalize()
SG::WriteHandleKey< std::vector< int > > m_w_ints
virtual ~ViewMergeAlg()
Destructor:
SG::ReadHandleKey< std::vector< int > > m_r_ints
ViewMergeAlg()
Default constructor:
virtual StatusCode initialize()
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:130