The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
EvtCollectionStream.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11// ====================================================================
12// EvtCollectionStream.cpp
13// --------------------------------------------------------------------
14//
15// Package : GaudiSvc/PersistencySvc
16//
17// Author : Markus Frank
18//
19// ====================================================================
20#define GAUDISVC_PERSISTENCYSVC_EVTCOLLECTIONSTREAM_CPP
21
22// Framework include files
26
27#include "EvtCollectionStream.h"
29
30// Define the algorithm factory for the standard output data writer
32
33// initialize data writer
35 // Get access to the DataManagerSvc
37 if ( !m_pTupleSvc ) {
38 fatal() << "Unable to locate IDataManagerSvc interface" << endmsg;
40 }
41 // Clear the item list
42 clearItems();
43 // Take the new item list from the properties.
44 for ( const auto& i : m_itemNames ) addItem( i );
45 info() << "Data source: " << m_storeName.value() << endmsg;
47}
48
49// terminate data writer
51 m_pTupleSvc = nullptr; // release
52 clearItems();
54}
55
56// Work entry point
59 if ( status.isSuccess() ) {
60 for ( const auto& i : m_itemList ) {
61 StatusCode iret = m_pTupleSvc->writeRecord( i->path() );
62 if ( !iret.isSuccess() ) status = iret;
63 }
64 }
65 return status;
66}
67
68// Remove all items from the output streamer list;
70
71// Add item to output streamer list
72void EvtCollectionStream::addItem( const std::string& descriptor ) {
73 auto sep = descriptor.rfind( "#" );
74 int level = 0;
75 std::string obj_path = descriptor.substr( 0, sep );
76 if ( sep != std::string::npos ) {
77 std::string slevel = descriptor.substr( sep + 1 );
78 if ( slevel == "*" ) {
79 level = 9999999;
80 } else {
81 level = std::stoi( slevel );
82 }
83 }
84 m_itemList.emplace_back( new DataStoreItem( obj_path, level ) );
85 const auto& item = m_itemList.back();
86 info() << "Adding OutputStream item " << item->path() << " with " << item->depth() << " level(s)." << endmsg;
87}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
#define DECLARE_COMPONENT(type)
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Description of the DataStoreItem class.
A small to stream Data I/O.
std::vector< std::unique_ptr< DataStoreItem > > m_itemList
Vector of items to be saved to this stream.
StatusCode execute() override
Working entry point.
StatusCode finalize() override
Terminate EvtCollectionStream.
StatusCode initialize() override
Initialize EvtCollectionStream.
SmartIF< INTupleSvc > m_pTupleSvc
Reference to Tuple service for event collection (may or may not be NTuple service)
void addItem(const std::string &descriptor)
Add item to output streamer list.
Gaudi::Property< std::vector< std::string > > m_itemNames
Gaudi::Property< std::string > m_storeName
void clearItems()
Clear item list.
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
bool isSuccess() const
Definition StatusCode.h:314
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100