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
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.
26 {
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.
37 {
39  m_leavesTool = nullptr;
40  return OutputStream::finalize();
41 }
42 
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
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  MsgStream log(msgSvc(), name());
80  log << MSG::ERROR << e.message() << endmsg;
81  return StatusCode::FAILURE;
82  }
83 
84  // Collect the other objects from the transient store (mandatory and optional)
86 }
virtual const std::string & message() const
error message to be printed
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Extension of OutputStream to copy the content of the main input file.
StatusCode initialize() override
Initialize the instance.
Define general base for Gaudi exception.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
IDataSelector m_objects
Collection of objects being selected.
Definition: OutputStream.h:78
StatusCode finalize() override
Terminate OutputStream.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
STL namespace.
std::vector< DataObject * > LeavesList
Returned type.
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
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
A small to stream Data I/O.
Definition: OutputStream.h:29
SmartIF< IToolSvc > & toolSvc() const
The standard ToolSvc service, Return a pointer to the service if present.
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:919
std::vector< std::string > m_tesVetoList
Names of TES locations to Veto.
StatusCode initialize() override
Initialize OutputStream.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
IDataStoreLeaves * m_leavesTool
Pointer to the (public) tool used to retrieve the objects in a file.
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:36
virtual const LeavesList & leaves() const =0
Return the list of leaves.
StatusCode finalize() override
Finalize the instance.
#define UNLIKELY(x)
Definition: Kernel.h:126
virtual StatusCode releaseTool(IAlgTool *tool)=0
Release the tool.
void ignore() const
Definition: StatusCode.h:108
StatusCode collectObjects() override
Collect all objects to be written to the output stream.
list i
Definition: ana.py:128
virtual StatusCode collectObjects()
Collect all objects to be written to the output stream.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Algorithm.cpp:1001