ATLAS Offline Software
Loading...
Searching...
No Matches
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
16#include "AthViews/View.h"
17#include <print>
18
19namespace AthViews {
20
21ViewDataVerifier::ViewDataVerifier( const std::string& name,
22 ISvcLocator* pSvcLocator ) :
23 ::AthReentrantAlgorithm( name, pSvcLocator )
24{
25}
26
29
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
57StatusCode 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
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(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:179
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
#define likely(x)