The Gaudi Framework  master (37c0b60a)
CopyInputStream.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 "OutputStream.h"
13 #include <GaudiKernel/DataObject.h>
20 #include <GaudiKernel/IRegistry.h>
21 #include <GaudiKernel/MsgStream.h>
22 
23 class CopyInputStream : public OutputStream {
24 
25 public:
27  CopyInputStream( const std::string& name, ISvcLocator* pSvcLocator );
28 
30  StatusCode collectObjects() override;
31 
32 private:
33  Gaudi::Property<std::vector<std::string>> m_tesVetoList{ this, "TESVetoList", {}, "names of TES locations to Veto" };
34 
36  "/Event/InputFileLeaves" };
37 
38 protected:
40  bool hasInput() const override { return true; }
41 };
42 
43 // implementation
44 
45 // Standard Constructor
47  : OutputStream( name, pSvcLocator ) {
48  setProperty( "Preload", false ).ignore();
49  setProperty( "PreloadOptItems", false ).ignore();
50 }
51 
54  // Get the objects in the same file as the root node
55  try {
56  // Get all the leaves on the input stream
57  const auto& leaves = *m_inputFileLeaves.get();
58 
59  // Do we need to veto anything ?
60  if ( !m_tesVetoList.empty() ) {
61  // Veto out locations
62  IDataStoreLeaves::LeavesList filteredLeaves;
63  filteredLeaves.reserve( leaves.size() );
64  std::copy_if( leaves.begin(), leaves.end(), std::back_inserter( filteredLeaves ),
65  [&]( IDataStoreLeaves::LeavesList::const_reference i ) {
66  return i && i->registry() &&
67  std::find( m_tesVetoList.begin(), m_tesVetoList.end(), i->registry()->identifier() ) ==
68  m_tesVetoList.end();
69  } );
70  // save the veto'ed list
71  m_objects.assign( filteredLeaves.begin(), filteredLeaves.end() );
72 
73  } else {
74  // no veto'ing, so save everything
75  m_objects.assign( leaves.begin(), leaves.end() );
76  }
77  } catch ( const GaudiException& e ) {
78  error() << e.message() << endmsg;
79  return StatusCode::FAILURE;
80  }
81 
82  // Collect the other objects from the transient store (mandatory and optional)
84 }
85 
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
CopyInputStream::m_tesVetoList
Gaudi::Property< std::vector< std::string > > m_tesVetoList
Definition: CopyInputStream.cpp:33
std::string
STL class.
DataStoreItem.h
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:526
std::vector::reserve
T reserve(T... args)
CopyInputStream::CopyInputStream
CopyInputStream(const std::string &name, ISvcLocator *pSvcLocator)
Standard algorithm Constructor.
Definition: CopyInputStream.cpp:46
std::vector< DataObject * >
CopyInputStream::collectObjects
StatusCode collectObjects() override
Collect all objects to be written to the output stream.
Definition: CopyInputStream.cpp:53
PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >::setProperty
StatusCode setProperty(const Gaudi::Details::PropertyBase &p)
Set the property from a property.
Definition: IProperty.h:39
ISvcLocator
Definition: ISvcLocator.h:46
std::back_inserter
T back_inserter(T... args)
GaudiException
Definition: GaudiException.h:31
IDataProviderSvc.h
GaudiException::message
virtual const std::string & message() const
error message to be printed
Definition: GaudiException.h:68
StatusCode
Definition: StatusCode.h:65
CopyInputStream
Definition: CopyInputStream.cpp:23
IOpaqueAddress.h
DataObjectReadHandle
Definition: DataObjectHandle.h:452
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
StatusCode::ignore
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition: StatusCode.h:139
CopyInputStream::m_inputFileLeaves
DataObjectReadHandle< IDataStoreLeaves::LeavesList > m_inputFileLeaves
Definition: CopyInputStream.cpp:35
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
DataObject.h
std::vector::begin
T begin(T... args)
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
CopyInputStream::hasInput
bool hasInput() const override
Overridden from the base class (CopyInputStream has always input).
Definition: CopyInputStream.cpp:40
std::vector::assign
T assign(T... args)
OutputStream.h
std::vector::end
T end(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
DataObjectHandle.h
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:37
IDataManagerSvc.h
OutputStream::m_objects
IDataSelector m_objects
Collection of objects being selected.
Definition: OutputStream.h:115
MsgStream.h