| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

InputCopyStream.cpp
Go to the documentation of this file.
1 // Framework include files
2 #include "GaudiKernel/IRegistry.h"
3 #include "GaudiKernel/IDataManagerSvc.h"
4 #include "GaudiKernel/IDataProviderSvc.h"
5 #include "GaudiKernel/IOpaqueAddress.h"
6 #include "GaudiKernel/DataStoreItem.h"
7 #include "GaudiKernel/DataObject.h"
8 #include "GaudiKernel/IDataStoreLeaves.h"
9 #include "GaudiKernel/MsgStream.h"
10 #include "InputCopyStream.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 {
19 m_doPreLoad = false;
20 m_doPreLoadOpt = false;
21 declareProperty( "TESVetoList", m_tesVetoList );
22 }
23
24 // Initialize the instance.
25 StatusCode InputCopyStream::initialize()
26 {
27 StatusCode sc = OutputStream::initialize();
28 if ( sc.isFailure() ) return sc;
29
30 sc = toolSvc()->retrieveTool("DataSvcFileEntriesTool", "InputCopyStreamTool",
31 m_leavesTool);
32 return sc;
33 }
34
35 // Finalize the instance.
36 StatusCode InputCopyStream::finalize()
37 {
38 toolSvc()->releaseTool(m_leavesTool).ignore();
39 m_leavesTool = nullptr;
40 return OutputStream::finalize();
41 }
42
44 StatusCode InputCopyStream::collectObjects()
45 {
46 // Get the objects in the same file as the root node
47 try
48 {
49 // Get all the leaves on the input stream
50 const IDataStoreLeaves::LeavesList & leaves = m_leavesTool->leaves();
51
52 // Do we need to veto anything ?
53 if ( UNLIKELY( !m_tesVetoList.empty() ) )
54 {
55 // Veto out locations
56 IDataStoreLeaves::LeavesList filteredLeaves;
57 filteredLeaves.reserve( leaves.size() );
58 std::copy_if( leaves.begin(), leaves.end(),
59 std::back_inserter(filteredLeaves),
60 [&](IDataStoreLeaves::LeavesList::const_reference i) {
61 return i && i->registry() &&
62 std::find( m_tesVetoList.begin(),
63 m_tesVetoList.end(),
64 i->registry()->identifier() ) == m_tesVetoList.end();
65
66 });
67 // save the veto'ed list
68 m_objects.assign( filteredLeaves.begin(), filteredLeaves.end() );
69
70 }
71 else
72 {
73 // no veto'ing, so save everything
74 m_objects.assign( leaves.begin(), leaves.end() );
75 }
76 }
77 catch ( const GaudiException & e )
78 {
79 error() << e.message() << endmsg;
80 return StatusCode::FAILURE;
81 }
82
83 // Collect the other objects from the transient store (mandatory and optional)
84 return OutputStream::collectObjects();
85 }
IDataStoreLeaves.h
GaudiException::message
virtual const std::string & message() const
error message to be printed
Definition: GaudiException.h:111
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:126
std::vector::empty
T empty(T...args)
InputCopyStream
Extension of OutputStream to copy the content of the main input file.
Definition: InputCopyStream.h:20
std::copy_if
T copy_if(T...args)
InputCopyStream::initialize
StatusCode initialize() override
Initialize the instance.
Definition: InputCopyStream.cpp:25
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
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:78
OutputStream::finalize
StatusCode finalize() override
Terminate OutputStream.
Definition: OutputStream.cpp:159
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
MsgStream.h
std
STL namespace.
std::vector::end
T end(T...args)
merge_files.sc
int sc
Definition: merge_files.py:167
InputCopyStream.h
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
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:145
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:36
OutputStream
A small to stream Data I/O.
Definition: OutputStream.h:29
Algorithm::toolSvc
SmartIF< IToolSvc > & toolSvc() const
The standard ToolSvc service, Return a pointer to the service if present.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
InputCopyStream::m_tesVetoList
std::vector< std::string > m_tesVetoList
Names of TES locations to Veto.
Definition: InputCopyStream.h:46
OutputStream::initialize
StatusCode initialize() override
Initialize OutputStream.
Definition: OutputStream.cpp:70
DataStoreItem.h
IDataManagerSvc.h
IDataProviderSvc.h
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
InputCopyStream::m_leavesTool
IDataStoreLeaves * m_leavesTool
Pointer to the (public) tool used to retrieve the objects in a file.
Definition: InputCopyStream.h:43
IRegistry.h
IOpaqueAddress.h
std::find
T find(T...args)
std::vector::size
T size(T...args)
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:36
IToolSvc::releaseTool
virtual StatusCode releaseTool(IAlgTool *tool)=0
Release the tool.
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:108
InputCopyStream::collectObjects
StatusCode collectObjects() override
Collect all objects to be written to the output stream.
Definition: InputCopyStream.cpp:44
ana.i
list i
Definition: ana.py:128
OutputStream::collectObjects
virtual StatusCode collectObjects()
Collect all objects to be written to the output stream.
Definition: OutputStream.cpp:292
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::vector::reserve
T reserve(T...args)
DataObject.h