ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthViews
src
ViewDataVerifier.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
// ViewDataVerifier.cxx
6
// Implementation file for class ViewDataVerifier
7
// Author: B. Wynne <bwynne@cern.ch>
9
10
#include "
ViewDataVerifier.h
"
11
12
// STL includes
13
14
// FrameWork includes
15
#include "
AthenaKernel/ExtendedEventContext.h
"
16
#include "
AthViews/View.h
"
17
#include <print>
18
19
namespace
AthViews
{
20
21
ViewDataVerifier::ViewDataVerifier
(
const
std::string& name,
22
ISvcLocator* pSvcLocator ) :
23
::
AthReentrantAlgorithm
( name, pSvcLocator )
24
{
25
}
26
27
ViewDataVerifier::~ViewDataVerifier
()
28
{}
29
30
StatusCode
ViewDataVerifier::initialize
()
31
{
32
StatusCode
sc
= StatusCode::SUCCESS;
33
34
// Debug message indicating what containers will be loaded
35
// Code copied from SGInputLoader
36
if
(
m_load
.value().size() > 0 ) {
37
std::ostringstream
str
;
38
std::print (
str
,
"Will explicitly preload the following DataObjects:"
);;
39
for
(
auto
&obj :
m_load
.value() ) {
40
str
<<
"\n + "
<< obj;
41
if
( obj.key() .empty() ) {
42
sc
= StatusCode::FAILURE;
43
std::print (
str
,
" ERROR: empty key is not allowed!"
);
44
}
45
}
46
ATH_MSG_INFO
(
str
.str() );
47
}
48
49
// Inform the scheduler that these containers will be available
50
if
( !
setProperty
(
"ExtraOutputs"
,
m_load
.toString() ).isSuccess() ) {
51
ATH_MSG_WARNING
(
"Failed setting property ExtraOutputs"
);
52
}
53
54
return
sc
;
55
}
56
57
StatusCode
ViewDataVerifier::execute
(
const
EventContext& ctx)
const
58
{
59
// Don't actually test for data presence in normal running
60
// The VDV will just tell the scheduler that the data is available
61
// Downstream algs can then fail if this is incorrect
62
if
( !this->
msgLvl
( MSG::DEBUG ) ) [[
likely
]] {
63
return
StatusCode::SUCCESS;
64
}
65
66
// Retrieve the current view from the EventContext
67
auto
viewProxy =
Atlas::getExtendedEventContext
(ctx).proxy();
68
69
ATH_MSG_DEBUG
(
"Executing {} running with store {}"
,
70
name(), viewProxy->name() );
71
StatusCode
sc
= StatusCode::SUCCESS;
72
73
// Test each container
74
for
(
auto
&obj :
m_load
.value() ) {
75
76
// Create a VarHandleKey (code copied from SGInputLoader)
77
SG::VarHandleKey
vhk( obj.clid(), obj.key(), Gaudi::DataHandle::Writer );
78
79
// Create a test proxy
80
SG::DataProxy
* dp = viewProxy->proxy( obj.clid(), vhk.
key
() );
81
82
// Test if the proxy is valid
83
if
( dp )
84
{
85
ATH_MSG_DEBUG
(
"Found {} in {}"
, obj.key(), viewProxy->name() );
86
}
87
else
if
( obj.key().rfind(
"DetectorStore"
, 0 ) != std::string::npos )
88
{
89
ATH_MSG_DEBUG
(
"Ignoring DetectorStore data {}"
, obj.key() );
90
}
91
else
if
( obj.className() ==
"SG::AuxElement"
)
92
{
93
// For decorations, look for the parent container
94
const
auto
split
= obj.key().rfind(
'.'
);
95
if
(
split
== std::string::npos) {
96
ATH_MSG_ERROR
(
"Aux data specified, but key does not contain '.': {}"
, obj.key() );
97
sc
= StatusCode::FAILURE;
98
}
99
100
// Is parent container present?
101
const
auto
parentKey = obj.key().substr( 0,
split
);
102
SG::VarHandleKey
parentVhk( obj.clid(), parentKey, Gaudi::DataHandle::Writer );
103
dp = viewProxy->proxy( obj.clid(), parentVhk.
key
() );
104
if
( dp ) {
105
ATH_MSG_DEBUG
(
"Found {} in {} (need aux data {})"
,
106
parentKey, viewProxy->name(), obj.key() );
107
}
else
{
108
ATH_MSG_ERROR
(
"Did not find {} in {} (need aux data {})"
,
109
parentKey, viewProxy->name(), obj.key() );
110
sc
= StatusCode::FAILURE;
111
}
112
}
113
else
114
{
115
// Examine the current view
116
ATH_MSG_ERROR
(
"Did not find {} in {}"
, obj.key(), viewProxy->name() );
117
const
SG::View
* view =
dynamic_cast<
const
SG::View
*
>
( viewProxy );
118
if
( view != 0 ) {
119
ATH_MSG_DEBUG
(
"Available content is: {}"
, view->dump() );
120
}
else
{
121
ATH_MSG_DEBUG
(
"Not a View"
);
122
}
123
sc
= StatusCode::FAILURE;
124
}
125
}
126
127
return
sc
;
128
}
129
130
}
//> end namespace AthViews
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x,...)
Definition
AthMsgStreamMacros.h:46
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
ExtendedEventContext.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
setProperty
void setProperty(columnar::PythonToolHandle &self, const std::string &key, nb::object value)
Definition
NanobindBindings.cxx:75
ViewDataVerifier.h
View.h
AthCommonAlgorithm< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition
AthCommonMsg.h:30
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
AthViews::ViewDataVerifier::~ViewDataVerifier
virtual ~ViewDataVerifier()
Destructor:
Definition
ViewDataVerifier.cxx:27
AthViews::ViewDataVerifier::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
ViewDataVerifier.cxx:57
AthViews::ViewDataVerifier::ViewDataVerifier
ViewDataVerifier()
Default constructor:
AthViews::ViewDataVerifier::initialize
virtual StatusCode initialize() override
Definition
ViewDataVerifier.cxx:30
AthViews::ViewDataVerifier::m_load
Gaudi::Property< DataObjIDColl > m_load
Containers to verify.
Definition
ViewDataVerifier.h:51
SG::DataProxy
Definition
DataProxy.h:45
SG::VarHandleKey
A property holding a SG store/key/clid from which a VarHandle is made.
Definition
StoreGate/StoreGate/VarHandleKey.h:61
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition
AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::View
A "view" of the event store (IProxyDict).
Definition
View.h:46
split
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition
hcg.cxx:179
AthViews
Definition
ViewDataVerifier.cxx:19
Atlas::getExtendedEventContext
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
Definition
ExtendedEventContext.cxx:32
str
Definition
BTagTrackIpAccessor.cxx:11
likely
#define likely(x)
Definition
pythonic_coracool.cxx:8
Generated on
for ATLAS Offline Software by
1.17.0