The Gaudi Framework
master (57817a18)
Toggle main menu visibility
Loading...
Searching...
No Matches
DumpAddress.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
#include <
GaudiKernel/Algorithm.h
>
12
13
#include <
GaudiKernel/DataObject.h
>
14
#include <
GaudiKernel/IDataManagerSvc.h
>
15
#include <
GaudiKernel/IRegistry.h
>
16
#include <
GaudiKernel/SmartDataPtr.h
>
17
#include <
RootCnv/RootAddress.h
>
18
19
#include <fstream>
20
#include <memory>
21
22
#include "
MIHelpers.h
"
23
24
namespace
Gaudi
{
25
namespace
TestSuite
{
26
namespace
MultiInput
{
27
29
class
DumpAddress
:
public
::Algorithm
{
30
public
:
31
using
Algorithm::Algorithm
;
32
33
StatusCode
initialize
()
override
{
34
StatusCode
sc =
Algorithm::initialize
();
35
if
( sc.
isFailure
() )
return
sc;
36
m_outputFile
.open(
m_output
.value().c_str() );
37
m_count
= 0;
38
return
sc;
39
}
40
41
StatusCode
execute
()
override
{
42
MsgStream
log(
msgSvc
() );
43
SmartDataPtr<DataObject>
obj(
eventSvc
(),
m_path
);
44
if
( obj ) {
45
Gaudi::RootAddress
* addr =
dynamic_cast<
Gaudi::RootAddress
*
>
( obj->registry()->address() );
46
if
( addr ) {
47
m_outputFile
<< *addr << std::endl;
48
}
else
{
49
log <<
MSG::ERROR
<<
"Event "
<<
m_count
<<
" does not have a Gaudi::RootAddress"
<<
endmsg
;
50
return
StatusCode::FAILURE
;
51
}
52
}
else
{
53
log <<
MSG::ERROR
<<
"No data at "
<<
m_path
.value() <<
endmsg
;
54
return
StatusCode::FAILURE
;
55
}
56
++
m_count
;
57
return
StatusCode::SUCCESS
;
58
}
59
60
StatusCode
finalize
()
override
{
61
m_outputFile
.close();
62
return
Algorithm::finalize
();
63
}
64
65
private
:
66
Gaudi::Property<std::string>
m_output
{
this
,
"OutputFile"
, {},
"Name of the output file"
};
67
Gaudi::Property<std::string>
m_path
{
this
,
"ObjectPath"
, {},
"Path to the object in the transient store"
};
68
std::ofstream
m_outputFile
;
69
long
m_count
= 0;
70
};
71
DECLARE_COMPONENT
(
DumpAddress
)
72
}
// namespace MultiInput
73
}
// namespace TestSuite
74
}
// namespace Gaudi
DataObject.h
Algorithm.h
IDataManagerSvc.h
IRegistry.h
MIHelpers.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
RootAddress.h
SmartDataPtr.h
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition
CommonMessaging.h:79
Gaudi::Algorithm::eventSvc
SmartIF< IDataProviderSvc > & eventSvc() const
The standard event data service.
Definition
Algorithm.cpp:551
Gaudi::Algorithm::Algorithm
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition
Algorithm.h:98
Gaudi::Algorithm::initialize
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition
Algorithm.h:175
Gaudi::Algorithm::finalize
StatusCode finalize() override
the default (empty) implementation of IStateful::finalize() method
Definition
Algorithm.h:181
Gaudi::Property
Implementation of property with value of concrete type.
Definition
Property.h:35
Gaudi::RootAddress
Description:
Definition
RootAddress.h:42
Gaudi::TestSuite::MultiInput::DumpAddress
Write the content of the RootAddress of a data object.
Definition
DumpAddress.cpp:29
Gaudi::TestSuite::MultiInput::DumpAddress::m_count
long m_count
Definition
DumpAddress.cpp:69
Gaudi::TestSuite::MultiInput::DumpAddress::Algorithm
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition
Algorithm.h:98
Gaudi::TestSuite::MultiInput::DumpAddress::m_outputFile
std::ofstream m_outputFile
Definition
DumpAddress.cpp:68
Gaudi::TestSuite::MultiInput::DumpAddress::finalize
StatusCode finalize() override
Definition
DumpAddress.cpp:60
Gaudi::TestSuite::MultiInput::DumpAddress::m_output
Gaudi::Property< std::string > m_output
Definition
DumpAddress.cpp:66
Gaudi::TestSuite::MultiInput::DumpAddress::execute
StatusCode execute() override
Definition
DumpAddress.cpp:41
Gaudi::TestSuite::MultiInput::DumpAddress::m_path
Gaudi::Property< std::string > m_path
Definition
DumpAddress.cpp:67
Gaudi::TestSuite::MultiInput::DumpAddress::initialize
StatusCode initialize() override
Definition
DumpAddress.cpp:33
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition
MsgStream.h:29
SmartDataPtr
A small class used to access easily (and efficiently) data items residing in data stores.
Definition
SmartDataPtr.h:44
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
StatusCode::isFailure
bool isFailure() const
Definition
StatusCode.h:118
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition
StatusCode.h:99
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition
StatusCode.h:100
Gaudi::TestSuite::MultiInput
Definition
DumpAddress.cpp:26
Gaudi::TestSuite
Definition
ConditionAccessorHolder.h:21
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition
__init__.py:1
MSG::ERROR
@ ERROR
Definition
IMessageSvc.h:22
GaudiTestSuite
src
MultiInput
DumpAddress.cpp
Generated on
for The Gaudi Framework by
1.17.0