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-2019 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
18
namespace
AthViews
{
19
20
ViewDataVerifier::ViewDataVerifier
(
const
std::string& name,
21
ISvcLocator* pSvcLocator ) :
22
::
AthReentrantAlgorithm
( name, pSvcLocator )
23
{
24
}
25
26
ViewDataVerifier::~ViewDataVerifier
()
27
{}
28
29
StatusCode
ViewDataVerifier::initialize
()
30
{
31
StatusCode
sc
= StatusCode::SUCCESS;
32
33
// Debug message indicating what containers will be loaded
34
// Code copied from SGInputLoader
35
if
(
m_load
.value().size() > 0 ) {
36
std::ostringstream
str
;
37
str
<<
"Will explicitly preload the following DataObjects:"
;
38
for
(
auto
&obj :
m_load
.value() ) {
39
str
<<
"\n + "
<< obj;
40
if
( obj.key() .empty() ) {
41
sc
= StatusCode::FAILURE;
42
str
<<
" ERROR: empty key is not allowed!"
;
43
}
44
}
45
ATH_MSG_INFO
(
str
.str() );
46
}
47
48
// Inform the scheduler that these containers will be available
49
if
( !
setProperty
(
"ExtraOutputs"
,
m_load
.toString() ).isSuccess() ) {
50
ATH_MSG_WARNING
(
"Failed setting property ExtraOutputs"
);
51
}
52
53
return
sc
;
54
}
55
56
StatusCode
ViewDataVerifier::execute
(
const
EventContext& ctx)
const
57
{
58
// Don't actually test for data presence in normal running
59
// The VDV will just tell the scheduler that the data is available
60
// Downstream algs can then fail if this is incorrect
61
if
(
ATH_LIKELY
( !this->
msgLvl
( MSG::DEBUG ) ) ) {
62
return
StatusCode::SUCCESS;
63
}
64
65
// Retrieve the current view from the EventContext
66
auto
viewProxy =
Atlas::getExtendedEventContext
(ctx).proxy();
67
68
ATH_MSG_DEBUG
(
"Executing "
<< name() <<
" running with store "
<< viewProxy->name() );
69
StatusCode
sc
= StatusCode::SUCCESS;
70
71
// Test each container
72
for
(
auto
&obj :
m_load
.value() ) {
73
74
// Create a VarHandleKey (code copied from SGInputLoader)
75
SG::VarHandleKey
vhk( obj.clid(), obj.key(), Gaudi::DataHandle::Writer );
76
77
// Create a test proxy
78
SG::DataProxy
* dp = viewProxy->proxy( obj.clid(), vhk.
key
() );
79
80
// Test if the proxy is valid
81
if
( dp )
82
{
83
ATH_MSG_DEBUG
(
"Found "
<< obj.key() <<
" in "
<< viewProxy->name() );
84
}
85
else
if
( obj.key().rfind(
"DetectorStore"
, 0 ) != std::string::npos )
86
{
87
ATH_MSG_DEBUG
(
"Ignoring DetectorStore data "
<< obj.key() );
88
}
89
else
if
( obj.className() ==
"SG::AuxElement"
)
90
{
91
// For decorations, look for the parent container
92
const
auto
split
= obj.key().rfind(
'.'
);
93
if
(
split
== std::string::npos) {
94
ATH_MSG_ERROR
(
"Aux data specified, but key does not contain '.': "
<< obj.key() );
95
sc
= StatusCode::FAILURE;
96
}
97
98
// Is parent container present?
99
const
auto
parentKey = obj.key().substr( 0,
split
);
100
SG::VarHandleKey
parentVhk( obj.clid(), parentKey, Gaudi::DataHandle::Writer );
101
dp = viewProxy->proxy( obj.clid(), parentVhk.
key
() );
102
if
( dp ) {
103
ATH_MSG_DEBUG
(
"Found "
<< parentKey <<
" in "
<< viewProxy->name() <<
" (need aux data "
<< obj.key() <<
")"
);
104
}
else
{
105
ATH_MSG_ERROR
(
"Did not find "
<< parentKey <<
" in "
<< viewProxy->name() <<
" (need aux data "
<< obj.key() <<
")"
);
106
sc
= StatusCode::FAILURE;
107
}
108
}
109
else
110
{
111
// Examine the current view
112
ATH_MSG_ERROR
(
"Did not find "
<< obj.key() <<
" in "
<< viewProxy->name() );
113
const
SG::View
* view =
dynamic_cast<
const
SG::View
*
>
( viewProxy );
114
if
( view != 0 ) {
115
ATH_MSG_DEBUG
(
"Available content is: "
<< view->dump() );
116
}
else
{
117
ATH_MSG_DEBUG
(
"Not a View"
);
118
}
119
sc
= StatusCode::FAILURE;
120
}
121
}
122
123
return
sc
;
124
}
125
126
}
//> end namespace AthViews
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ATH_LIKELY
#define ATH_LIKELY(x)
Definition
AthUnlikelyMacros.h:16
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:26
AthViews::ViewDataVerifier::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
ViewDataVerifier.cxx:56
AthViews::ViewDataVerifier::ViewDataVerifier
ViewDataVerifier()
Default constructor:
AthViews::ViewDataVerifier::initialize
virtual StatusCode initialize() override
Definition
ViewDataVerifier.cxx:29
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:59
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:18
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
Generated on
for ATLAS Offline Software by
1.17.0