Gaudi Framework, version v25r2
Home
Generated: Wed Jun 4 2014
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
.cern.ch
sw
Gaudi
releases
GAUDI
GAUDI_v25r2
GaudiCommonSvc
src
PersistencySvc
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
"
15
#include "
GaudiKernel/IDataProviderSvc.h
"
16
17
#include "
GaudiKernel/DataStoreItem.h
"
18
#include "
EvtCollectionStream.h
"
19
20
// Define the algorithm factory for the standard output data writer
21
DECLARE_COMPONENT
(
EvtCollectionStream
)
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
33
EvtCollectionStream::~EvtCollectionStream
() {
34
}
35
36
// initialize data writer
37
StatusCode
EvtCollectionStream::initialize
() {
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
42
m_pTupleSvc
=
serviceLocator
()->service(
m_storeName
);
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
58
StatusCode
EvtCollectionStream::finalize
() {
59
m_pTupleSvc
= 0;
// release
60
clearItems
();
61
return
StatusCode::SUCCESS
;
62
}
63
64
// Work entry point
65
StatusCode
EvtCollectionStream::execute
() {
66
StatusCode
status = (
m_pTupleSvc
) ?
StatusCode::SUCCESS
:
StatusCode::FAILURE
;
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;
79
void
EvtCollectionStream::clearItems
() {
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
}
Generated at Wed Jun 4 2014 14:48:56 for Gaudi Framework, version v25r2 by
Doxygen
version 1.8.2 written by
Dimitri van Heesch
, © 1997-2004