All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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
13 #include "GaudiKernel/MsgStream.h"
14 #include "GaudiKernel/INTupleSvc.h"
16 
18 #include "EvtCollectionStream.h"
19 
20 // Define the algorithm factory for the standard output data writer
22 
23 // Standard Constructor
24 EvtCollectionStream::EvtCollectionStream(const std::string& name, ISvcLocator* pSvcLocator)
25 : Algorithm(name, pSvcLocator)
26 {
27  m_storeName = "TagCollectionSvc";
28  declareProperty("ItemList", m_itemNames);
29  declareProperty("EvtDataSvc", m_storeName);
30 }
31 
32 // Standard Destructor
34 }
35 
36 // initialize data writer
38  MsgStream log(msgSvc(), name());
39  // Use the Job options service to set the Algorithm's parameters
40  setProperties();
41  // Get access to the DataManagerSvc
43  if( !m_pTupleSvc.isValid() ) {
44  log << MSG::FATAL << "Unable to locate IDataManagerSvc interface" << endmsg;
45  return StatusCode::FAILURE;
46  }
47  // Clear the item list
48  clearItems();
49  // Take the new item list from the properties.
50  for(ItemNames::iterator i = m_itemNames.begin(); i != m_itemNames.end(); i++) {
51  addItem( *i );
52  }
53  log << MSG::INFO << "Data source: " << m_storeName << endmsg;
54  return StatusCode::SUCCESS;
55 }
56 
57 // terminate data writer
59  m_pTupleSvc = 0; // release
60  clearItems();
61  return StatusCode::SUCCESS;
62 }
63 
64 // Work entry point
67  if ( status.isSuccess() ) {
68  for ( Items::iterator i = m_itemList.begin(); i != m_itemList.end(); i++ ) {
69  StatusCode iret = m_pTupleSvc->writeRecord((*i)->path());
70  if ( !iret.isSuccess() ) {
71  status = iret;
72  }
73  }
74  }
75  return status;
76 }
77 
78 // Remove all items from the output streamer list;
80  for ( Items::iterator i = m_itemList.begin(); i != m_itemList.end(); i++ ) {
81  delete (*i);
82  }
83  m_itemList.erase(m_itemList.begin(), m_itemList.end());
84 }
85 
86 // Add item to output streamer list
87 void EvtCollectionStream::addItem(const std::string& descriptor) {
88  MsgStream log(msgSvc(), name());
89  int sep = descriptor.rfind("#");
90  int level = 0;
91  std::string obj_path (descriptor,0,sep);
92  std::string slevel (descriptor,sep+1,descriptor.length());
93  if ( slevel == "*" ) {
94  level = 9999999;
95  }
96  else {
97  level = ::atoi(slevel.c_str());
98  }
99  DataStoreItem* item = new DataStoreItem(obj_path, level);
100  log << MSG::INFO << "Adding OutputStream item " << item->path()
101  << " with " << item->depth()
102  << " level(s)." << endmsg;
103  m_itemList.push_back( item );
104 }
virtual StatusCode finalize()
Terminate EvtCollectionStream.
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:26
int depth() const
Accessor: Retrieve load depth.
Definition: DataStoreItem.h:70
SmartIF< ISvcLocator > & serviceLocator() const
The standard service locator.
Definition: Algorithm.cpp:1091
virtual ~EvtCollectionStream()
Standard Destructor.
SmartIF< INTupleSvc > m_pTupleSvc
Reference to Tuple service for event collection (may or may not be NTuple service) ...
StatusCode setProperties()
Set the algorithm's properties.
Definition: Algorithm.cpp:1096
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
virtual StatusCode initialize()
Initialize EvtCollectionStream.
Description of the DataStoreItem class.
Definition: DataStoreItem.h:18
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:36
const std::string & path() const
Accessor: Retrieve load path.
Definition: DataStoreItem.h:66
virtual StatusCode execute()
Working entry point.
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:51
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual const std::string & name() const
The identifying name of the algorithm object.
Definition: Algorithm.cpp:837
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Algorithm.cpp:896
ItemNames m_itemNames
Vector of item names.
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:61
std::string m_storeName
Name of the service managing the data store.
void clearItems()
Clear item list.
void addItem(const std::string &descriptor)
Add item to output streamer list.
tuple item
print s1,s2
Definition: ana.py:146
Items m_itemList
Vector of items to be saved to this stream.
A small to stream Data I/O.
list i
Definition: ana.py:128
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244