The Gaudi Framework
master (6507eef1)
Toggle main menu visibility
Loading...
Searching...
No Matches
MIReadAlg.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
// Framework include files
12
#include <
GaudiKernel/IDataManagerSvc.h
>
13
#include <
GaudiKernel/MsgStream.h
>
14
#include <
GaudiKernel/SmartDataPtr.h
>
15
16
// Example related include files
17
#include "
MIHelpers.h
"
18
#include "
MIReadAlg.h
"
19
20
// Event Model related classes
21
#include <
GaudiTestSuite/Event.h
>
22
#include <
GaudiTestSuite/MyTrack.h
>
23
24
#include <
GaudiKernel/System.h
>
25
26
#include <fstream>
27
28
using namespace
Gaudi::TestSuite::MultiInput
;
29
30
DECLARE_COMPONENT
(
ReadAlg
)
31
32
//--------------------------------------------------------------------
33
// Initialize
34
//--------------------------------------------------------------------
35
StatusCode
ReadAlg::initialize
() {
36
StatusCode sc =
Algorithm::initialize
();
37
if
( sc.
isFailure
() )
return
sc;
38
39
if
(
msgLevel
(
MSG::DEBUG
) )
debug
() <<
"Reading "
<<
m_addressfile
.value() <<
endmsg
;
40
m_addresses
.clear();
41
std::ifstream input{
m_addressfile
};
42
while
( input.good() ) {
43
RootAddressArgs
addr;
44
input >> addr;
45
if
( input.eof() )
break
;
46
m_addresses
.push_back( addr );
47
}
48
if
(
msgLevel
(
MSG::DEBUG
) )
debug
() <<
"Read "
<<
m_addresses
.size() <<
" addresses"
<<
endmsg
;
49
50
m_count
= 0;
51
52
return
StatusCode::SUCCESS
;
53
}
54
55
//--------------------------------------------------------------------
56
// Execute
57
//--------------------------------------------------------------------
58
StatusCode
ReadAlg::execute
() {
59
60
if
(
m_count
<
m_addresses
.size() ) {
61
// register the entry "Extra/Tracks" in the TES so that it is loaded
62
// from the other file
63
StatusCode sc =
eventSvc
()->
registerObject
(
"Extra"
,
new
DataObject );
64
if
( sc.
isFailure
() ) {
65
error
() <<
"Cannot add entry 'Extra' to the TES"
<<
endmsg
;
66
return
sc;
67
}
68
sc =
69
SmartIF<IDataManagerSvc>(
eventSvc
() )->registerAddress(
"Extra/Tracks"
,
make_address
(
m_addresses
[
m_count
] ) );
70
if
( sc.
isFailure
() ) {
71
error
() <<
"Failed to register the address to the extra data"
<<
endmsg
;
72
return
sc;
73
}
74
++
m_count
;
75
}
76
77
SmartDataPtr<MyTrackVector> trks1(
eventSvc
(),
"Tracks"
);
78
SmartDataPtr<MyTrackVector> trks2(
eventSvc
(),
"Extra/Tracks"
);
79
80
if
( trks1 )
81
info
() <<
"Base event tracks: "
<< trks1->size() <<
endmsg
;
82
else
83
warning
() <<
"No tracks container in base event"
<<
endmsg
;
84
if
( trks2 )
85
info
() <<
"Extra event tracks: "
<< trks2->size() <<
endmsg
;
86
else
87
warning
() <<
"No tracks container in extra event"
<<
endmsg
;
88
89
return
StatusCode::SUCCESS
;
90
}
Event.h
IDataManagerSvc.h
MIHelpers.h
MIReadAlg.h
MsgStream.h
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition
MsgStream.h:198
MyTrack.h
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition
PluginServiceV1.h:45
SmartDataPtr.h
System.h
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition
CommonMessaging.h:109
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition
CommonMessaging.h:112
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition
CommonMessaging.h:118
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition
CommonMessaging.h:115
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition
CommonMessaging.h:127
Gaudi::Algorithm::eventSvc
SmartIF< IDataProviderSvc > & eventSvc() const
The standard event data service.
Definition
Algorithm.cpp:551
Gaudi::Algorithm::initialize
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition
Algorithm.h:175
Gaudi::TestSuite::MultiInput::ReadAlg::m_count
size_t m_count
Definition
MIReadAlg.h:37
Gaudi::TestSuite::MultiInput::ReadAlg::m_addressfile
Gaudi::Property< std::string > m_addressfile
Definition
MIReadAlg.h:33
Gaudi::TestSuite::MultiInput::ReadAlg::m_addresses
std::vector< RootAddressArgs > m_addresses
Address details for the data to be added to the main event.
Definition
MIReadAlg.h:36
IDataProviderSvc::registerObject
StatusCode registerObject(std::string_view fullPath, DataObject *pObject)
Register object with the data store.
Definition
IDataProviderSvc.h:67
ReadAlg
ReadAlg class for the RootIOExample.
Definition
ReadAlg.h:29
ReadAlg::execute
StatusCode execute() override
Event callback.
Definition
ReadAlg.cpp:121
ReadAlg::initialize
StatusCode initialize() override
Initialize.
Definition
ReadAlg.cpp:50
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
Gaudi::TestSuite::MultiInput
Definition
DumpAddress.cpp:26
Gaudi::TestSuite::MultiInput::make_address
Gaudi::RootAddress * make_address(RootAddressArgs args)
Definition
MIHelpers.h:36
Gaudi::TestSuite::MultiInput::RootAddressArgs
std::tuple< long, CLID, std::string, std::string, unsigned long, unsigned long > RootAddressArgs
Definition
MIHelpers.h:26
MSG::DEBUG
@ DEBUG
Definition
IMessageSvc.h:22
GaudiTestSuite
src
MultiInput
MIReadAlg.cpp
Generated on
for The Gaudi Framework by
1.17.0