ATLAS Offline Software
Loading...
Searching...
No Matches
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
16#include "AthViews/View.h"
17
18namespace AthViews {
19
20ViewDataVerifier::ViewDataVerifier( const std::string& name,
21 ISvcLocator* pSvcLocator ) :
22 ::AthReentrantAlgorithm( name, pSvcLocator )
23{
24}
25
28
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
56StatusCode 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
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define ATH_LIKELY(x)
static Double_t sc
void setProperty(columnar::PythonToolHandle &self, const std::string &key, nb::object value)
bool msgLvl(const MSG::Level lvl) const
An algorithm that can be simultaneously executed in multiple threads.
virtual ~ViewDataVerifier()
Destructor:
virtual StatusCode execute(const EventContext &ctx) const override
ViewDataVerifier()
Default constructor:
virtual StatusCode initialize() override
Gaudi::Property< DataObjIDColl > m_load
Containers to verify.
A property holding a SG store/key/clid from which a VarHandle is made.
const std::string & key() const
Return the StoreGate ID for the referenced object.
A "view" of the event store (IProxyDict).
Definition View.h:46
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.