The Gaudi Framework  master (37c0b60a)
InputCopyStream.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 "InputCopyStream.h"
13 #include <GaudiKernel/DataObject.h>
19 #include <GaudiKernel/IRegistry.h>
20 #include <GaudiKernel/MsgStream.h>
21 
22 // Define the algorithm factory for the standard output data writer
24 
25 // Standard Constructor
26 InputCopyStream::InputCopyStream( const std::string& name, ISvcLocator* pSvcLocator )
27  : OutputStream( name, pSvcLocator ) {
28  m_doPreLoad = false;
29  m_doPreLoadOpt = false;
30 }
31 
32 // Initialize the instance.
35  if ( sc.isFailure() ) return sc;
36 
37  sc = toolSvc()->retrieveTool( "DataSvcFileEntriesTool", "InputCopyStreamTool", m_leavesTool );
38  return sc;
39 }
40 
41 // Finalize the instance.
43  toolSvc()->releaseTool( m_leavesTool ).ignore();
44  m_leavesTool = nullptr;
45  return OutputStream::finalize();
46 }
47 
50  // Get the objects in the same file as the root node
51  try {
52  // Get all the leaves on the input stream
54 
55  // Do we need to veto anything ?
56  if ( !m_tesVetoList.empty() ) {
57  // Veto out locations
58  IDataStoreLeaves::LeavesList filteredLeaves;
59  filteredLeaves.reserve( leaves.size() );
60  std::copy_if( leaves.begin(), leaves.end(), std::back_inserter( filteredLeaves ),
61  [&]( IDataStoreLeaves::LeavesList::const_reference i ) {
62  return i && i->registry() &&
63  std::find( m_tesVetoList.begin(), m_tesVetoList.end(), i->registry()->identifier() ) ==
64  m_tesVetoList.end();
65  } );
66  // save the veto'ed list
67  m_objects.assign( filteredLeaves.begin(), filteredLeaves.end() );
68 
69  } else {
70  // no veto'ing, so save everything
71  m_objects.assign( leaves.begin(), leaves.end() );
72  }
73  } catch ( const GaudiException& e ) {
74  error() << e.message() << endmsg;
75  return StatusCode::FAILURE;
76  }
77 
78  // Collect the other objects from the transient store (mandatory and optional)
80 }
IDataStoreLeaves.h
OutputStream
A small to stream Data I/O.
Definition: OutputStream.h:38
OutputStream::collectObjects
virtual StatusCode collectObjects()
Collect all objects to be written to the output stream.
Definition: OutputStream.cpp:251
DataStoreItem.h
Gaudi::Algorithm::toolSvc
SmartIF< IToolSvc > & toolSvc() const
The standard ToolSvc service, Return a pointer to the service if present.
Definition: Algorithm.cpp:564
std::vector::reserve
T reserve(T... args)
std::vector< DataObject * >
std::vector::size
T size(T... args)
ISvcLocator
Definition: ISvcLocator.h:46
std::back_inserter
T back_inserter(T... args)
GaudiException
Definition: GaudiException.h:31
OutputStream::finalize
StatusCode finalize() override
Terminate OutputStream.
Definition: OutputStream.cpp:148
IDataProviderSvc.h
InputCopyStream::collectObjects
StatusCode collectObjects() override
Collect all objects to be written to the output stream.
Definition: InputCopyStream.cpp:49
GaudiException::message
virtual const std::string & message() const
error message to be printed
Definition: GaudiException.h:68
InputCopyStream::m_leavesTool
IDataStoreLeaves * m_leavesTool
Pointer to the (public) tool used to retrieve the objects in a file.
Definition: InputCopyStream.h:46
OutputStream::initialize
StatusCode initialize() override
Initialize OutputStream.
Definition: OutputStream.cpp:53
StatusCode
Definition: StatusCode.h:65
IOpaqueAddress.h
InputCopyStream::m_tesVetoList
Gaudi::Property< std::vector< std::string > > m_tesVetoList
Definition: InputCopyStream.h:48
InputCopyStream.h
InputCopyStream::initialize
StatusCode initialize() override
Initialize the instance.
Definition: InputCopyStream.cpp:33
std::copy_if
T copy_if(T... args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
IRegistry.h
InputCopyStream::finalize
StatusCode finalize() override
Finalize the instance.
Definition: InputCopyStream.cpp:42
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
DataObject.h
std::vector::begin
T begin(T... args)
std
STL namespace.
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
std::vector::assign
T assign(T... args)
IDataStoreLeaves::leaves
virtual const LeavesList & leaves() const =0
Return the list of leaves.
std::vector::end
T end(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
InputCopyStream
Extension of OutputStream to copy the content of the main input file.
Definition: InputCopyStream.h:29
IDataManagerSvc.h
OutputStream::m_objects
IDataSelector m_objects
Collection of objects being selected.
Definition: OutputStream.h:115
MsgStream.h