ATLAS Offline Software
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 
18 namespace AthViews {
19 
21  ISvcLocator* pSvcLocator ) :
22  ::AthReentrantAlgorithm( name, pSvcLocator )
23 {
24 }
25 
27 {}
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 
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
TileDCSDataPlotter.dp
dp
Definition: TileDCSDataPlotter.py:840
AthViews::ViewDataVerifier::~ViewDataVerifier
virtual ~ViewDataVerifier()
Destructor:
Definition: ViewDataVerifier.cxx:26
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ExtendedEventContext.h
AthViews::ViewDataVerifier::m_load
Gaudi::Property< DataObjIDColl > m_load
Containers to verify.
Definition: ViewDataVerifier.h:51
AthCommonMsg< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
Atlas::getExtendedEventContext
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
Definition: ExtendedEventContext.cxx:32
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AthViews::ViewDataVerifier::ViewDataVerifier
ViewDataVerifier()
Default constructor:
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
AthViews
Definition: ViewDataVerifier.cxx:18
ViewDataVerifier.h
AthViews::ViewDataVerifier::initialize
virtual StatusCode initialize() override
Definition: ViewDataVerifier.cxx:29
SG::VarHandleKey
A property holding a SG store/key/clid from which a VarHandle is made.
Definition: StoreGate/StoreGate/VarHandleKey.h:62
ATH_LIKELY
#define ATH_LIKELY(x)
Definition: AthUnlikelyMacros.h:16
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DEBUG
#define DEBUG
Definition: page_access.h:11
AthViews::ViewDataVerifier::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: ViewDataVerifier.cxx:56
str
Definition: BTagTrackIpAccessor.cxx:11
LHEF::Writer
Pythia8::Writer Writer
Definition: Prophecy4fMerger.cxx:12
View.h
SG::View
Definition: View.h:25
python.PyAthena.obj
obj
Definition: PyAthena.py:135
SG::DataProxy
Definition: DataProxy.h:44
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
drawFromPickle.view
view
Definition: drawFromPickle.py:294