| The Gaudi Framework v32r1 (f65d50dc)

InputCopyStream.cpp
Go to the documentation of this file.
1 // Framework include files
2 #include "InputCopyStream.h"
3 #include "GaudiKernel/DataObject.h"
4 #include "GaudiKernel/DataStoreItem.h"
5 #include "GaudiKernel/IDataManagerSvc.h"
6 #include "GaudiKernel/IDataProviderSvc.h"
7 #include "GaudiKernel/IDataStoreLeaves.h"
8 #include "GaudiKernel/IOpaqueAddress.h"
9 #include "GaudiKernel/IRegistry.h"
10 #include "GaudiKernel/MsgStream.h"
11
12 // Define the algorithm factory for the standard output data writer
13 DECLARE_COMPONENT( InputCopyStream )
14
15 // Standard Constructor
16 InputCopyStream::InputCopyStream( const std::string& name, ISvcLocator* pSvcLocator )
17 : OutputStream( name, pSvcLocator ) {
18 m_doPreLoad = false;
19 m_doPreLoadOpt = false;
20 }
21
22 // Initialize the instance.
23 StatusCode InputCopyStream::initialize() {
24 StatusCode sc = OutputStream::initialize();
25 if ( sc.isFailure() ) return sc;
26
27 sc = toolSvc()->retrieveTool( "DataSvcFileEntriesTool", "InputCopyStreamTool", m_leavesTool );
28 return sc;
29 }
30
31 // Finalize the instance.
32 StatusCode InputCopyStream::finalize() {
33 toolSvc()->releaseTool( m_leavesTool ).ignore();
34 m_leavesTool = nullptr;
35 return OutputStream::finalize();
36 }
37
39 StatusCode InputCopyStream::collectObjects() {
40 // Get the objects in the same file as the root node
41 try {
42 // Get all the leaves on the input stream
43 const IDataStoreLeaves::LeavesList& leaves = m_leavesTool->leaves();
44
45 // Do we need to veto anything ?
46 if ( UNLIKELY( !m_tesVetoList.empty() ) ) {
47 // Veto out locations
48 IDataStoreLeaves::LeavesList filteredLeaves;
49 filteredLeaves.reserve( leaves.size() );
50 std::copy_if( leaves.begin(), leaves.end(), std::back_inserter( filteredLeaves ),
51 [&]( IDataStoreLeaves::LeavesList::const_reference i ) {
52 return i && i->registry() &&
53 std::find( m_tesVetoList.begin(), m_tesVetoList.end(), i->registry()->identifier() ) ==
54 m_tesVetoList.end();
55 } );
56 // save the veto'ed list
57 m_objects.assign( filteredLeaves.begin(), filteredLeaves.end() );
58
59 } else {
60 // no veto'ing, so save everything
61 m_objects.assign( leaves.begin(), leaves.end() );
62 }
63 } catch ( const GaudiException& e ) {
64 error() << e.message() << endmsg;
65 return StatusCode::FAILURE;
66 }
67
68 // Collect the other objects from the transient store (mandatory and optional)
69 return OutputStream::collectObjects();
70 }
IDataStoreLeaves.h
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:96
InputCopyStream
Extension of OutputStream to copy the content of the main input file.
Definition: InputCopyStream.h:19
std::copy_if
T copy_if(T... args)
InputCopyStream::initialize
StatusCode initialize() override
Initialize the instance.
Definition: InputCopyStream.cpp:23
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:21
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
OutputStream::m_objects
IDataSelector m_objects
Collection of objects being selected.
Definition: OutputStream.h:105
OutputStream::finalize
StatusCode finalize() override
Terminate OutputStream.
Definition: OutputStream.cpp:123
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
MsgStream.h
GaudiException::message
virtual const std::string & message() const
error message to be printed
Definition: GaudiException.h:58
std
STL namespace.
Gaudi::Algorithm::toolSvc
SmartIF< IToolSvc > & toolSvc() const
The standard ToolSvc service, Return a pointer to the service if present.
Definition: Algorithm.cpp:683
std::vector::end
T end(T... args)
InputCopyStream.h
IToolSvc::retrieveTool
StatusCode retrieveTool(const std::string &type, T *&tool, const IInterface *parent=nullptr, bool createIf=true)
Retrieve specified tool sub-type with tool dependent part of the name automatically assigned.
Definition: IToolSvc.h:138
OutputStream
A small to stream Data I/O.
Definition: OutputStream.h:28
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
OutputStream::initialize
StatusCode initialize() override
Initialize OutputStream.
Definition: OutputStream.cpp:36
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:98
DataStoreItem.h
IDataManagerSvc.h
IDataProviderSvc.h
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
InputCopyStream::m_leavesTool
IDataStoreLeaves * m_leavesTool
Pointer to the (public) tool used to retrieve the objects in a file.
Definition: InputCopyStream.h:36
IRegistry.h
InputCopyStream::m_tesVetoList
Gaudi::Property< std::vector< std::string > > m_tesVetoList
Definition: InputCopyStream.h:38
IOpaqueAddress.h
std::find
T find(T... args)
std::vector::size
T size(T... args)
StatusCode::ignore
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
std::vector::assign
T assign(T... args)
std::vector< DataObject * >
IDataStoreLeaves::leaves
virtual const LeavesList & leaves() const =0
Return the list of leaves.
std::vector::begin
T begin(T... args)
std::back_inserter
T back_inserter(T... args)
InputCopyStream::finalize
StatusCode finalize() override
Finalize the instance.
Definition: InputCopyStream.cpp:32
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
IToolSvc::releaseTool
virtual StatusCode releaseTool(IAlgTool *tool)=0
Release the tool.
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:130
InputCopyStream::collectObjects
StatusCode collectObjects() override
Collect all objects to be written to the output stream.
Definition: InputCopyStream.cpp:39
OutputStream::collectObjects
virtual StatusCode collectObjects()
Collect all objects to be written to the output stream.
Definition: OutputStream.cpp:226
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
std::vector::reserve
T reserve(T... args)
DataObject.h