| The Gaudi Framework v32r1 (f65d50dc)

OutputStream.h
Go to the documentation of this file.
1 #ifndef GAUDISVC_PERSISTENCYSVC_OUTPUTSTREAM_H
2 #define GAUDISVC_PERSISTENCYSVC_OUTPUTSTREAM_H
3
4 // Required for inheritance
5 #include "GaudiKernel/Algorithm.h"
6 #include "GaudiKernel/IDataSelector.h"
7 #include "GaudiKernel/IIncidentSvc.h"
8 #include "GaudiKernel/Property.h"
9
10 // STL include files
11 #include <memory>
12 #include <string>
13 #include <vector>
14
15 // forward declarations
16 class IIncidentSvc;
17 class IRegistry;
18 class IConversionSvc;
19 struct IDataManagerSvc;
20 class OutputStreamAgent;
21 class DataStoreItem;
22
28 class OutputStream : public Algorithm {
29 public:
30 typedef std::vector<DataStoreItem*> Items;
31 typedef std::vector<std::string> ItemNames;
32 typedef std::map<Gaudi::Algorithm*, Items> AlgDependentItems;
33 typedef std::map<std::string, ItemNames> AlgDependentItemNames;
34
35 public:
37 using Algorithm::Algorithm;
38
39 protected:
40 Gaudi::Property<ItemNames> m_itemNames{this, "ItemList", {}, "vector of item names to be saved to this stream"};
41 Gaudi::Property<ItemNames> m_optItemNames{
42 this, "OptItemList", {}, "vector of optional item names to be saved to this stream"};
43 Gaudi::Property<AlgDependentItemNames> m_algDependentItemList{
44 this,
45 "AlgDependentItemList",
46 {},
47 "mapping between algorithm names, and a list of items for which, if the "
48 "algorithm in question accepted the event, they should be also stored"};
49 Gaudi::Property<bool> m_doPreLoad{this, "Preload", true,
50 "flag indicating whether data pre-loading should be performed"};
51 Gaudi::Property<bool> m_doPreLoadOpt{this, "PreloadOptItems", false,
52 "flag indicating whether optional items should be preloaded"};
53 Gaudi::Property<std::string> m_output{this, "Output", {}, "name of the output file specification"};
54 Gaudi::Property<std::string> m_outputName{this, "OutputFile", {}, "name of the output file"};
55 Gaudi::Property<std::string> m_storeName{this, "EvtDataSvc", "EventDataSvc",
56 "name of the service managing the data store"};
57 Gaudi::Property<std::string> m_persName{this, "EvtConversionSvc", "EventPersistencySvc",
58 "name of the persistency service capable to write data from the store"};
59 Gaudi::Property<std::vector<std::string>> m_acceptNames{
60 this,
61 "AcceptAlgs",
62 {},
63 [this]( auto& ) { this->decodeAlgorithms( this->m_acceptNames, this->m_acceptAlgs ); },
64 "names of Algorithms that this stream accepts"};
65 Gaudi::Property<std::vector<std::string>> m_requireNames{
66 this,
67 "RequireAlgs",
68 {},
69 [this]( auto& ) { this->decodeAlgorithms( this->m_requireNames, this->m_requireAlgs ); },
70 "names of Algorithms that this stream requires"};
71 Gaudi::Property<std::vector<std::string>> m_vetoNames{
72 this,
73 "VetoAlgs",
74 {},
75 [this]( auto& ) { this->decodeAlgorithms( this->m_vetoNames, this->m_vetoAlgs ); },
76 "names of Algorithms that this stream is vetoed by"};
77 Gaudi::Property<bool> m_verifyItems{this, "VerifyItems", true,
78 "flag to indicate that item consistency should be checked"};
79
83 bool m_fireIncidents = true;
84
86 SmartIF<IIncidentSvc> m_incidentSvc;
87
89 std::string m_outputType = "UPDATE";
91 SmartIF<IDataProviderSvc> m_pDataProvider;
93 SmartIF<IDataManagerSvc> m_pDataManager;
95 SmartIF<IConversionSvc> m_pConversionSvc;
97 DataStoreItem* m_currentItem;
99 Items m_itemList;
101 Items m_optItemList;
103 AlgDependentItems m_algDependentItems;
105 IDataSelector m_objects;
107 int m_events;
108
110 std::vector<Gaudi::Algorithm*> m_acceptAlgs;
112 std::vector<Gaudi::Algorithm*> m_requireAlgs;
114 std::vector<Gaudi::Algorithm*> m_vetoAlgs;
115
116 protected:
118 Gaudi::Algorithm* decodeAlgorithm( const std::string& theName );
120 void decodeAlgorithms( Gaudi::Property<std::vector<std::string>>& theNames, std::vector<Gaudi::Algorithm*>& theAlgs );
122 bool isEventAccepted() const;
124 DataStoreItem* findItem( const std::string& path );
126 virtual StatusCode writeObjects();
127
129 virtual bool hasInput() const;
130
131 public:
133 StatusCode initialize() override;
135 StatusCode finalize() override;
137 StatusCode execute() override;
138 // Connect to proper conversion service
139 virtual StatusCode connectConversionSvc();
141 virtual bool collect( IRegistry* dir, int level );
143 virtual StatusCode collectObjects();
145 void clearSelection();
146
147 private:
149 void clearItems( Items& itms );
151 void addItem( Items& itms, const std::string& descriptor );
153 IDataSelector* selectedObjects() { return &m_objects; }
154
155 StatusCode collectFromSubTree( DataObject* );
156 };
157
158 #endif // GAUDISVC_PERSISTENCYSVC_OUTPUTSTREAM_H
OutputStream::m_acceptNames
Gaudi::Property< std::vector< std::string > > m_acceptNames
Definition: OutputStream.h:59
IDataSelector.h
OutputStream::clearItems
void clearItems(Items &itms)
Clear item list.
Definition: OutputStream.cpp:300
Algorithm.h
SmartIF< IIncidentSvc >
OutputStream::m_vetoNames
Gaudi::Property< std::vector< std::string > > m_vetoNames
Definition: OutputStream.h:71
OutputStream::m_objects
IDataSelector m_objects
Collection of objects being selected.
Definition: OutputStream.h:105
OutputStream::finalize
StatusCode finalize() override
Terminate OutputStream.
Definition: OutputStream.cpp:123
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:932
IConversionSvc
Definition: IConversionSvc.h:37
OutputStream::m_events
int m_events
Number of events written to this output stream.
Definition: OutputStream.h:107
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:352
OutputStream::AlgDependentItemNames
std::map< std::string, ItemNames > AlgDependentItemNames
Definition: OutputStream.h:33
OutputStream::m_outputType
std::string m_outputType
Output type: NEW(NEW,CREATE,WRITE,RECREATE), UPDATE)
Definition: OutputStream.h:89
OutputStream::m_verifyItems
Gaudi::Property< bool > m_verifyItems
Definition: OutputStream.h:77
IDataManagerSvc
Definition: IDataManagerSvc.h:45
OutputStream::m_requireAlgs
std::vector< Gaudi::Algorithm * > m_requireAlgs
Vector of Algorithms that this stream requires.
Definition: OutputStream.h:112
OutputStream::m_currentItem
DataStoreItem * m_currentItem
Keep track of the current item.
Definition: OutputStream.h:97
OutputStream::m_output
Gaudi::Property< std::string > m_output
Definition: OutputStream.h:53
Gaudi::Algorithm::Algorithm
Algorithm(const std::string &name, ISvcLocator *svcloc, const std::string &version=PACKAGE_VERSION)
Constructor.
Definition: Algorithm.cpp:48
OutputStream::m_outputName
Gaudi::Property< std::string > m_outputName
Definition: OutputStream.h:54
OutputStream::m_optItemNames
Gaudi::Property< ItemNames > m_optItemNames
Definition: OutputStream.h:41
OutputStream::selectedObjects
IDataSelector * selectedObjects()
Return the list of selected objects.
Definition: OutputStream.h:153
OutputStream::m_pDataProvider
SmartIF< IDataProviderSvc > m_pDataProvider
Keep reference to the data provider service.
Definition: OutputStream.h:91
DataStoreItem
Description of the DataStoreItem class.
Definition: DataStoreItem.h:17
OutputStream::m_doPreLoad
Gaudi::Property< bool > m_doPreLoad
Definition: OutputStream.h:49
std::map< Gaudi::Algorithm *, Items >
OutputStream
A small to stream Data I/O.
Definition: OutputStream.h:28
std::string
STL class.
OutputStream::collect
virtual bool collect(IRegistry *dir, int level)
Store agent's classback.
Definition: OutputStream.cpp:208
OutputStream::findItem
DataStoreItem * findItem(const std::string &path)
Find single item identified by its path (exact match)
Definition: OutputStream.cpp:306
OutputStream::hasInput
virtual bool hasInput() const
Tell if the instance has been configured with input items or not.
Definition: OutputStream.cpp:488
OutputStream::writeObjects
virtual StatusCode writeObjects()
Select the different objects and write them to file.
Definition: OutputStream.cpp:155
OutputStream::m_pConversionSvc
SmartIF< IConversionSvc > m_pConversionSvc
Keep reference to the data conversion service.
Definition: OutputStream.h:95
OutputStream::initialize
StatusCode initialize() override
Initialize OutputStream.
Definition: OutputStream.cpp:36
OutputStream::connectConversionSvc
virtual StatusCode connectConversionSvc()
Definition: OutputStream.cpp:340
OutputStream::m_algDependentItems
AlgDependentItems m_algDependentItems
Items to be saved for specific algorithms.
Definition: OutputStream.h:103
OutputStream::Items
std::vector< DataStoreItem * > Items
Definition: OutputStream.h:30
OutputStream::m_vetoAlgs
std::vector< Gaudi::Algorithm * > m_vetoAlgs
Vector of Algorithms that this stream is vetoed by.
Definition: OutputStream.h:114
IIncidentSvc.h
OutputStream::m_requireNames
Gaudi::Property< std::vector< std::string > > m_requireNames
Definition: OutputStream.h:65
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
OutputStream::m_itemList
Items m_itemList
Vector of items to be saved to this stream.
Definition: OutputStream.h:99
OutputStream::addItem
void addItem(Items &itms, const std::string &descriptor)
Add item to output streamer list.
Definition: OutputStream.cpp:317
IRegistry
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
OutputStream::m_algDependentItemList
Gaudi::Property< AlgDependentItemNames > m_algDependentItemList
Definition: OutputStream.h:43
OutputStream::m_pDataManager
SmartIF< IDataManagerSvc > m_pDataManager
Keep reference to the data manager service.
Definition: OutputStream.h:93
OutputStream::clearSelection
void clearSelection()
Clear list of selected objects.
Definition: OutputStream.cpp:297
OutputStream::m_incidentSvc
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
Definition: OutputStream.h:86
OutputStream::execute
StatusCode execute() override
Working entry point.
Definition: OutputStream.cpp:136
Algorithm
Alias for backward compatibility.
Definition: Algorithm.h:56
OutputStream::m_storeName
Gaudi::Property< std::string > m_storeName
Definition: OutputStream.h:55
std::vector< DataStoreItem * >
OutputStream::ItemNames
std::vector< std::string > ItemNames
Definition: OutputStream.h:31
Property.h
Gaudi::Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
OutputStream::AlgDependentItems
std::map< Gaudi::Algorithm *, Items > AlgDependentItems
Definition: OutputStream.h:32
OutputStream::m_doPreLoadOpt
Gaudi::Property< bool > m_doPreLoadOpt
Definition: OutputStream.h:51
OutputStream::isEventAccepted
bool isEventAccepted() const
Test whether this event should be output.
Definition: OutputStream.cpp:463
gaudirun.level
level
Definition: gaudirun.py:334
OutputStream::collectFromSubTree
StatusCode collectFromSubTree(DataObject *)
Definition: OutputStream.cpp:492
OutputStream::decodeAlgorithms
void decodeAlgorithms(Gaudi::Property< std::vector< std::string >> &theNames, std::vector< Gaudi::Algorithm * > &theAlgs)
Decode specified list of Algorithms.
Definition: OutputStream.cpp:442
OutputStream::m_persName
Gaudi::Property< std::string > m_persName
Definition: OutputStream.h:57
OutputStream::decodeAlgorithm
Gaudi::Algorithm * decodeAlgorithm(const std::string &theName)
Decode a single algorithm name.
Definition: OutputStream.cpp:418
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
OutputStream::m_itemNames
Gaudi::Property< ItemNames > m_itemNames
Definition: OutputStream.h:40
OutputStream::collectObjects
virtual StatusCode collectObjects()
Collect all objects to be written to the output stream.
Definition: OutputStream.cpp:226
IIncidentSvc
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:23
OutputStream::m_acceptAlgs
std::vector< Gaudi::Algorithm * > m_acceptAlgs
Vector of Algorithms that this stream accepts.
Definition: OutputStream.h:110
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:83
OutputStream::m_optItemList
Items m_optItemList
Vector of optional items to be saved to this stream.
Definition: OutputStream.h:101