Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
EvtCollectionStream.cpp
Go to the documentation of this file.
1 // ====================================================================
2 // EvtCollectionStream.cpp
3 // --------------------------------------------------------------------
4 //
5 // Package : GaudiSvc/PersistencySvc
6 //
7 // Author : Markus Frank
8 //
9 // ====================================================================
10 #define GAUDISVC_PERSISTENCYSVC_EVTCOLLECTIONSTREAM_CPP
11 
12 // Framework include files
14 #include "GaudiKernel/INTupleSvc.h"
15 #include "GaudiKernel/MsgStream.h"
16 
17 #include "EvtCollectionStream.h"
19 
20 // Define the algorithm factory for the standard output data writer
22 
23 // initialize data writer
25  // Use the Job options service to set the Algorithm's parameters
26  setProperties();
27  // Get access to the DataManagerSvc
28  m_pTupleSvc = serviceLocator()->service( m_storeName );
29  if ( !m_pTupleSvc ) {
30  fatal() << "Unable to locate IDataManagerSvc interface" << endmsg;
31  return StatusCode::FAILURE;
32  }
33  // Clear the item list
34  clearItems();
35  // Take the new item list from the properties.
36  for ( const auto& i : m_itemNames ) addItem( i );
37  info() << "Data source: " << m_storeName.value() << endmsg;
38  return StatusCode::SUCCESS;
39 }
40 
41 // terminate data writer
43  m_pTupleSvc = nullptr; // release
44  clearItems();
45  return StatusCode::SUCCESS;
46 }
47 
48 // Work entry point
51  if ( status.isSuccess() ) {
52  for ( const auto& i : m_itemList ) {
53  StatusCode iret = m_pTupleSvc->writeRecord( i->path() );
54  if ( !iret.isSuccess() ) status = iret;
55  }
56  }
57  return status;
58 }
59 
60 // Remove all items from the output streamer list;
62 
63 // Add item to output streamer list
64 void EvtCollectionStream::addItem( const std::string& descriptor ) {
65  auto sep = descriptor.rfind( "#" );
66  int level = 0;
67  std::string obj_path = descriptor.substr( 0, sep );
68  if ( sep != std::string::npos ) {
69  std::string slevel = descriptor.substr( sep + 1 );
70  if ( slevel == "*" ) {
71  level = 9999999;
72  } else {
73  level = std::stoi( slevel );
74  }
75  }
76  m_itemList.emplace_back( new DataStoreItem( obj_path, level ) );
77  const auto& item = m_itemList.back();
78  info() << "Adding OutputStream item " << item->path() << " with " << item->depth() << " level(s)." << endmsg;
79 }
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
SmartIF< INTupleSvc > m_pTupleSvc
Reference to Tuple service for event collection (may or may not be NTuple service) ...
bool isSuccess() const
Definition: StatusCode.h:267
T rfind(T...args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
Description of the DataStoreItem class.
Definition: DataStoreItem.h:17
STL class.
#define DECLARE_COMPONENT(type)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
virtual StatusCode writeRecord(NTuple::Tuple *tuple)=0
Write single record to N tuple.
std::vector< std::unique_ptr< DataStoreItem > > m_itemList
Vector of items to be saved to this stream.
T clear(T...args)
void clearItems()
Clear item list.
void addItem(const std::string &descriptor)
Add item to output streamer list.
StatusCode finalize() override
Terminate EvtCollectionStream.
T back(T...args)
constexpr static const auto FAILURE
Definition: StatusCode.h:86
T substr(T...args)
StatusCode execute() override
Working entry point.
A small to stream Data I/O.
T stoi(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
T emplace_back(T...args)