ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthViews
src_dflow
ViewSubgraphAlg.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
#include "
ViewSubgraphAlg.h
"
6
#include "
AthViews/ViewHelper.h
"
7
#include "Gaudi/Property.h"
8
#include "
StoreGate/WriteHandle.h
"
9
10
namespace
AthViews
{
11
12
StatusCode
ViewSubgraphAlg::initialize
()
13
{
14
ATH_MSG_INFO
(
"Initializing {}..."
, name());
15
16
renounce
(
m_w_int
);
// To test ViewDataVerifier
17
CHECK
(
m_w_int
.initialize() );
18
CHECK
(
m_w_views
.initialize() );
19
CHECK
(
m_r_views
.initialize(
SG::AllowEmpty
) );
20
CHECK
(
m_scheduler
.retrieve() );
21
22
return
StatusCode::SUCCESS;
23
}
24
25
StatusCode
ViewSubgraphAlg::finalize
()
26
{
27
ATH_MSG_INFO
(
"Finalizing {}..."
, name());
28
29
return
StatusCode::SUCCESS;
30
}
31
32
StatusCode
ViewSubgraphAlg::execute
(
const
EventContext& ctx)
const
33
{
34
ATH_MSG_DEBUG
(
"Executing {}..."
, name());
35
36
//Start scheduler profiling
37
auto
profileCallback = [
this
, slot=ctx.slot()]( IScheduler::OccupancySnapshot snap ) ->
void
{
38
std::string states =
""
;
39
for
(
int
const
stateTotal : snap.states[slot] ) {
40
states += std::to_string( stateTotal ) +
" "
;
41
}
42
ATH_MSG_INFO
(
"Slot {} snapshot time {} states: "
,
43
slot, snap.time.time_since_epoch().count(), states );
44
};
45
m_scheduler
->recordOccupancy( 0, std::move( profileCallback ) );
46
47
//Make a vector of dummy data to initialise the views
48
std::vector<int> viewData;
49
auto
viewVector = std::make_unique<ViewContainer>();
50
for
(
int
viewIndex = 0; viewIndex <
m_viewNumber
; ++viewIndex )
51
{
52
viewData.push_back( ( viewIndex * 10 ) + 10 + ctx.evt() );
53
}
54
55
//Create the views and populate them
56
CHECK
(
ViewHelper::makeAndPopulate
(
m_viewBaseName
,
//Base name for all views to use
57
viewVector.get(),
//Vector to store views
58
m_w_int
,
//A writehandlekey to use to access the views
59
ctx,
//The context of this algorithm
60
viewData ) );
//Data to initialise each view - one view will be made per entry
61
62
//Attach parent views to existing views
63
if
(
m_r_views
.key() !=
""
)
64
{
65
SG::ReadHandle< ViewContainer >
parentViewHandle(
m_r_views
, ctx );
66
if
( parentViewHandle->size() == viewVector->size() )
67
{
68
for
(
unsigned
int
viewIndex = 0; viewIndex < parentViewHandle->size(); ++viewIndex )
69
{
70
ATH_MSG_INFO
(
"Linking view {} to parent {}"
,
71
viewVector->at( viewIndex )->name(),
72
parentViewHandle->at( viewIndex )->name() );
73
viewVector->at( viewIndex )->linkParent( parentViewHandle->at( viewIndex ) );
74
}
75
}
76
}
77
78
//Schedule the algorithms in views
79
CHECK
(
ViewHelper::scheduleViews
( viewVector.get(),
//View vector
80
m_viewNodeName
,
//Name of node to attach views to
81
ctx,
//Context to attach the views to
82
m_scheduler
.get() ) );
//ServiceHandle for the scheduler
83
84
//Store the collection of views
85
SG::WriteHandle< ViewContainer >
outputViewHandle(
m_w_views
, ctx );
86
CHECK
( outputViewHandle.
record
( std::move( viewVector ) ) );
87
88
return
StatusCode::SUCCESS;
89
}
90
91
}
//> end namespace AthViews
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
WriteHandle.h
Handle class for recording to StoreGate.
ViewHelper.h
ViewSubgraphAlg.h
AthCommonAlgorithm< Gaudi::Algorithm >::renounce
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)
Definition
AthCommonDataStore.h:368
AthViews::ViewSubgraphAlg::m_viewNumber
Gaudi::Property< int > m_viewNumber
Definition
ViewSubgraphAlg.h:37
AthViews::ViewSubgraphAlg::initialize
virtual StatusCode initialize() override
Definition
ViewSubgraphAlg.cxx:12
AthViews::ViewSubgraphAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
ViewSubgraphAlg.cxx:32
AthViews::ViewSubgraphAlg::m_w_views
SG::WriteHandleKey< ViewContainer > m_w_views
Definition
ViewSubgraphAlg.h:32
AthViews::ViewSubgraphAlg::m_r_views
SG::ReadHandleKey< ViewContainer > m_r_views
Definition
ViewSubgraphAlg.h:33
AthViews::ViewSubgraphAlg::m_viewBaseName
Gaudi::Property< std::string > m_viewBaseName
Definition
ViewSubgraphAlg.h:35
AthViews::ViewSubgraphAlg::m_viewNodeName
Gaudi::Property< std::string > m_viewNodeName
Definition
ViewSubgraphAlg.h:36
AthViews::ViewSubgraphAlg::finalize
virtual StatusCode finalize() override
Definition
ViewSubgraphAlg.cxx:25
AthViews::ViewSubgraphAlg::m_scheduler
ServiceHandle< IScheduler > m_scheduler
Definition
ViewSubgraphAlg.h:31
AthViews::ViewSubgraphAlg::m_w_int
SG::WriteHandleKey< int > m_w_int
Definition
ViewSubgraphAlg.h:34
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:66
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:71
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
AthViews
Definition
ViewDataVerifier.cxx:19
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:29
ViewHelper::scheduleViews
StatusCode scheduleViews(ViewContainer *viewVector, std::string const &nodeName, EventContext const &sourceContext, SmartIF< IScheduler > scheduler, bool reverseOrder=false)
Definition
ViewHelper.h:85
ViewHelper::makeAndPopulate
StatusCode makeAndPopulate(std::string const &viewNameRoot, ViewContainer *viewVector, SG::WriteHandleKey< T > const &populateKey, EventContext const &sourceContext, std::vector< T > const &inputData, bool const allowFallThrough=true)
Definition
ViewHelper.h:25
Generated on
for ATLAS Offline Software by
1.17.0