The Gaudi Framework  master (37c0b60a)
OutputStream.h
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 #ifndef GAUDISVC_PERSISTENCYSVC_OUTPUTSTREAM_H
12 #define GAUDISVC_PERSISTENCYSVC_OUTPUTSTREAM_H
13 
14 // Required for inheritance
15 #include <Gaudi/Property.h>
16 #include <GaudiKernel/Algorithm.h>
19 
20 // STL include files
21 #include <memory>
22 #include <string>
23 #include <vector>
24 
25 // forward declarations
26 class IIncidentSvc;
27 class IRegistry;
28 class IConversionSvc;
29 struct IDataManagerSvc;
30 class OutputStreamAgent;
31 class DataStoreItem;
32 
38 class OutputStream : public Algorithm {
39 public:
44 
45 public:
48 
49 protected:
50  Gaudi::Property<ItemNames> m_itemNames{ this, "ItemList", {}, "vector of item names to be saved to this stream" };
52  this, "OptItemList", {}, "vector of optional item names to be saved to this stream" };
54  this,
55  "AlgDependentItemList",
56  {},
57  "mapping between algorithm names, and a list of items for which, if the "
58  "algorithm in question accepted the event, they should be also stored" };
59  Gaudi::Property<bool> m_doPreLoad{ this, "Preload", true,
60  "flag indicating whether data pre-loading should be performed" };
61  Gaudi::Property<bool> m_doPreLoadOpt{ this, "PreloadOptItems", false,
62  "flag indicating whether optional items should be preloaded" };
63  Gaudi::Property<std::string> m_output{ this, "Output", {}, "name of the output file specification" };
64  Gaudi::Property<std::string> m_outputName{ this, "OutputFile", {}, "name of the output file" };
65  Gaudi::Property<std::string> m_storeName{ this, "EvtDataSvc", "EventDataSvc",
66  "name of the service managing the data store" };
67  Gaudi::Property<std::string> m_persName{ this, "EvtConversionSvc", "EventPersistencySvc",
68  "name of the persistency service capable to write data from the store" };
70  this,
71  "AcceptAlgs",
72  {},
73  [this]( auto& ) { this->decodeAlgorithms( this->m_acceptNames, this->m_acceptAlgs ); },
74  "names of Algorithms that this stream accepts" };
76  this,
77  "RequireAlgs",
78  {},
79  [this]( auto& ) { this->decodeAlgorithms( this->m_requireNames, this->m_requireAlgs ); },
80  "names of Algorithms that this stream requires" };
82  this,
83  "VetoAlgs",
84  {},
85  [this]( auto& ) { this->decodeAlgorithms( this->m_vetoNames, this->m_vetoAlgs ); },
86  "names of Algorithms that this stream is vetoed by" };
87  Gaudi::Property<bool> m_verifyItems{ this, "VerifyItems", true,
88  "flag to indicate that item consistency should be checked" };
89 
93  bool m_fireIncidents = true;
94 
97 
117  int m_events;
118 
125 
126 protected:
128  Gaudi::Algorithm* decodeAlgorithm( const std::string& theName );
132  bool isEventAccepted() const;
136  virtual StatusCode writeObjects();
137 
139  virtual bool hasInput() const;
140 
141 public:
143  StatusCode start() override;
145  StatusCode initialize() override;
147  StatusCode finalize() override;
149  StatusCode execute() override;
150  // Connect to proper conversion service
153  virtual bool collect( IRegistry* dir, int level );
155  virtual StatusCode collectObjects();
157  void clearSelection();
158 
159 private:
161  void clearItems( Items& itms );
163  void addItem( Items& itms, const std::string& descriptor );
166 
168 };
169 
170 #endif // GAUDISVC_PERSISTENCYSVC_OUTPUTSTREAM_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
OutputStream::m_verifyItems
Gaudi::Property< bool > m_verifyItems
Definition: OutputStream.h:87
OutputStream::m_requireAlgs
std::vector< Gaudi::Algorithm * > m_requireAlgs
Vector of Algorithms that this stream requires.
Definition: OutputStream.h:122
OutputStream::m_currentItem
DataStoreItem * m_currentItem
Keep track of the current item.
Definition: OutputStream.h:107
OutputStream::clearItems
void clearItems(Items &itms)
Clear item list.
Definition: OutputStream.cpp:325
std::string
STL class.
OutputStream::m_vetoNames
Gaudi::Property< std::vector< std::string > > m_vetoNames
Definition: OutputStream.h:81
OutputStream::m_fireIncidents
bool m_fireIncidents
should I fire incidents for writing opening/closing etc? in the baseclass, always fire the incidents ...
Definition: OutputStream.h:93
IDataManagerSvc
Definition: IDataManagerSvc.h:55
OutputStream::m_optItemList
Items m_optItemList
Vector of optional items to be saved to this stream.
Definition: OutputStream.h:111
AtlasMCRecoFullPrecedenceDump.path
path
Definition: AtlasMCRecoFullPrecedenceDump.py:49
OutputStream::m_outputType
std::string m_outputType
Output type: NEW(NEW,CREATE,WRITE,RECREATE), UPDATE)
Definition: OutputStream.h:99
OutputStream::m_events
int m_events
Number of events written to this output stream.
Definition: OutputStream.h:117
OutputStream::AlgDependentItemNames
std::map< std::string, ItemNames > AlgDependentItemNames
Definition: OutputStream.h:43
OutputStream::m_optItemNames
Gaudi::Property< ItemNames > m_optItemNames
Definition: OutputStream.h:51
std::vector< DataStoreItem * >
OutputStream::m_output
Gaudi::Property< std::string > m_output
Definition: OutputStream.h:63
Algorithm
Alias for backward compatibility.
Definition: Algorithm.h:58
OutputStream::finalize
StatusCode finalize() override
Terminate OutputStream.
Definition: OutputStream.cpp:148
Algorithm.h
IRegistry
Definition: IRegistry.h:32
OutputStream::selectedObjects
IDataSelector * selectedObjects()
Return the list of selected objects.
Definition: OutputStream.h:165
OutputStream::m_doPreLoad
Gaudi::Property< bool > m_doPreLoad
Definition: OutputStream.h:59
OutputStream::m_pConversionSvc
SmartIF< IConversionSvc > m_pConversionSvc
Keep reference to the data conversion service.
Definition: OutputStream.h:105
OutputStream::m_outputName
Gaudi::Property< std::string > m_outputName
Definition: OutputStream.h:64
IIncidentSvc.h
OutputStream::m_vetoAlgs
std::vector< Gaudi::Algorithm * > m_vetoAlgs
Vector of Algorithms that this stream is vetoed by.
Definition: OutputStream.h:124
OutputStream::m_requireNames
Gaudi::Property< std::vector< std::string > > m_requireNames
Definition: OutputStream.h:75
OutputStream::initialize
StatusCode initialize() override
Initialize OutputStream.
Definition: OutputStream.cpp:53
OutputStream::collect
virtual bool collect(IRegistry *dir, int level)
Store agent's classback.
Definition: OutputStream.cpp:233
OutputStream::findItem
DataStoreItem * findItem(const std::string &path)
Find single item identified by its path (exact match)
Definition: OutputStream.cpp:331
OutputStream::connectConversionSvc
virtual StatusCode connectConversionSvc()
Definition: OutputStream.cpp:365
OutputStream::m_pDataProvider
SmartIF< IDataProviderSvc > m_pDataProvider
Keep reference to the data provider service.
Definition: OutputStream.h:101
StatusCode
Definition: StatusCode.h:65
OutputStream::m_algDependentItems
AlgDependentItems m_algDependentItems
Items to be saved for specific algorithms.
Definition: OutputStream.h:113
IDataSelector.h
DataStoreItem
Definition: DataStoreItem.h:27
OutputStream::clearSelection
void clearSelection()
Clear list of selected objects.
Definition: OutputStream.cpp:322
Gaudi::Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:90
OutputStream::Items
std::vector< DataStoreItem * > Items
Definition: OutputStream.h:40
OutputStream::addItem
void addItem(Items &itms, const std::string &descriptor)
Add item to output streamer list.
Definition: OutputStream.cpp:342
OutputStream::hasInput
virtual bool hasInput() const
Tell if the instance has been configured with input items or not.
Definition: OutputStream.cpp:513
OutputStream::writeObjects
virtual StatusCode writeObjects()
Select the different objects and write them to file.
Definition: OutputStream.cpp:180
OutputStream::m_algDependentItemList
Gaudi::Property< AlgDependentItemNames > m_algDependentItemList
Definition: OutputStream.h:53
OutputStream::m_pDataManager
SmartIF< IDataManagerSvc > m_pDataManager
Keep reference to the data manager service.
Definition: OutputStream.h:103
SmartIF< IIncidentSvc >
OutputStream::m_incidentSvc
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
Definition: OutputStream.h:96
OutputStream::start
StatusCode start() override
Start OutputStream.
Definition: OutputStream.cpp:45
std::map< Gaudi::Algorithm *, Items >
gaudirun.level
level
Definition: gaudirun.py:364
OutputStream::m_itemList
Items m_itemList
Vector of items to be saved to this stream.
Definition: OutputStream.h:109
OutputStream::m_storeName
Gaudi::Property< std::string > m_storeName
Definition: OutputStream.h:65
OutputStream::m_doPreLoadOpt
Gaudi::Property< bool > m_doPreLoadOpt
Definition: OutputStream.h:61
OutputStream::execute
StatusCode execute() override
Working entry point.
Definition: OutputStream.cpp:161
OutputStream::decodeAlgorithm
Gaudi::Algorithm * decodeAlgorithm(const std::string &theName)
Decode a single algorithm name.
Definition: OutputStream.cpp:443
DataObject
Definition: DataObject.h:36
OutputStream::isEventAccepted
bool isEventAccepted() const
Test whether this event should be output.
Definition: OutputStream.cpp:488
OutputStream::AlgDependentItems
std::map< Gaudi::Algorithm *, Items > AlgDependentItems
Definition: OutputStream.h:42
Gaudi::Algorithm::Algorithm
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition: Algorithm.h:101
OutputStream::ItemNames
std::vector< std::string > ItemNames
Definition: OutputStream.h:41
OutputStream::decodeAlgorithms
void decodeAlgorithms(Gaudi::Property< std::vector< std::string >> &theNames, std::vector< Gaudi::Algorithm * > &theAlgs)
Decode specified list of Algorithms.
Definition: OutputStream.cpp:467
OutputStream::m_itemNames
Gaudi::Property< ItemNames > m_itemNames
Definition: OutputStream.h:50
IIncidentSvc
Definition: IIncidentSvc.h:33
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:37
OutputStream::collectFromSubTree
StatusCode collectFromSubTree(DataObject *)
Definition: OutputStream.cpp:517
OutputStream::m_objects
IDataSelector m_objects
Collection of objects being selected.
Definition: OutputStream.h:115
Property.h
OutputStream::m_acceptAlgs
std::vector< Gaudi::Algorithm * > m_acceptAlgs
Vector of Algorithms that this stream accepts.
Definition: OutputStream.h:120
OutputStream::m_persName
Gaudi::Property< std::string > m_persName
Definition: OutputStream.h:67
OutputStream::m_acceptNames
Gaudi::Property< std::vector< std::string > > m_acceptNames
Definition: OutputStream.h:69
IConversionSvc
Definition: IConversionSvc.h:47