The Gaudi Framework
master (bdbe7744)
Toggle main menu visibility
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
23
#include <
GaudiKernel/IDataProviderSvc.h
>
24
#include <
GaudiKernel/INTupleSvc.h
>
25
#include <
GaudiKernel/MsgStream.h
>
26
27
#include "
EvtCollectionStream.h
"
28
#include <
GaudiKernel/DataStoreItem.h
>
29
30
// Define the algorithm factory for the standard output data writer
31
DECLARE_COMPONENT
(
EvtCollectionStream
)
32
33
// initialize data writer
34
StatusCode
EvtCollectionStream
::
initialize
() {
35
// Get access to the DataManagerSvc
36
m_pTupleSvc
=
serviceLocator
()->service(
m_storeName
);
37
if
( !
m_pTupleSvc
) {
38
fatal
() <<
"Unable to locate IDataManagerSvc interface"
<<
endmsg
;
39
return
StatusCode::FAILURE
;
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
;
46
return
StatusCode::SUCCESS
;
47
}
48
49
// terminate data writer
50
StatusCode
EvtCollectionStream::finalize
() {
51
m_pTupleSvc
=
nullptr
;
// release
52
clearItems
();
53
return
StatusCode::SUCCESS
;
54
}
55
56
// Work entry point
57
StatusCode
EvtCollectionStream::execute
() {
58
StatusCode
status = (
m_pTupleSvc
) ?
StatusCode::SUCCESS
:
StatusCode::FAILURE
;
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;
69
void
EvtCollectionStream::clearItems
() {
m_itemList
.clear(); }
70
71
// Add item to output streamer list
72
void
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
}
DataStoreItem.h
EvtCollectionStream.h
IDataProviderSvc.h
INTupleSvc.h
MsgStream.h
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition
MsgStream.h:198
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition
PluginServiceV1.h:45
CommonMessagingBase::fatal
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
Definition
CommonMessaging.h:103
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition
CommonMessaging.h:115
DataStoreItem
Description of the DataStoreItem class.
Definition
DataStoreItem.h:25
EvtCollectionStream
A small to stream Data I/O.
Definition
EvtCollectionStream.h:34
EvtCollectionStream::m_itemList
std::vector< std::unique_ptr< DataStoreItem > > m_itemList
Vector of items to be saved to this stream.
Definition
EvtCollectionStream.h:43
EvtCollectionStream::execute
StatusCode execute() override
Working entry point.
Definition
EvtCollectionStream.cpp:57
EvtCollectionStream::finalize
StatusCode finalize() override
Terminate EvtCollectionStream.
Definition
EvtCollectionStream.cpp:50
EvtCollectionStream::initialize
StatusCode initialize() override
Initialize EvtCollectionStream.
Definition
EvtCollectionStream.cpp:34
EvtCollectionStream::m_pTupleSvc
SmartIF< INTupleSvc > m_pTupleSvc
Reference to Tuple service for event collection (may or may not be NTuple service).
Definition
EvtCollectionStream.h:41
EvtCollectionStream::addItem
void addItem(const std::string &descriptor)
Add item to output streamer list.
Definition
EvtCollectionStream.cpp:72
EvtCollectionStream::m_itemNames
Gaudi::Property< std::vector< std::string > > m_itemNames
Definition
EvtCollectionStream.h:36
EvtCollectionStream::m_storeName
Gaudi::Property< std::string > m_storeName
Definition
EvtCollectionStream.h:37
EvtCollectionStream::clearItems
void clearItems()
Clear item list.
Definition
EvtCollectionStream.cpp:69
Gaudi::Algorithm::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition
Algorithm.cpp:562
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
StatusCode::isSuccess
bool isSuccess() const
Definition
StatusCode.h:302
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition
StatusCode.h:99
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition
StatusCode.h:100
GaudiCommonSvc
src
PersistencySvc
EvtCollectionStream.cpp
Generated on
for The Gaudi Framework by
1.17.0