The Gaudi Framework  v33r1 (b1225454)
OutputStream.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 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 "GaudiKernel/Algorithm.h"
18 #include "GaudiKernel/Property.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 initialize() override;
145  StatusCode finalize() override;
147  StatusCode execute() override;
148  // Connect to proper conversion service
151  virtual bool collect( IRegistry* dir, int level );
153  virtual StatusCode collectObjects();
155  void clearSelection();
156 
157 private:
159  void clearItems( Items& itms );
161  void addItem( Items& itms, const std::string& descriptor );
164 
166 };
167 
168 #endif // GAUDISVC_PERSISTENCYSVC_OUTPUTSTREAM_H
Gaudi::Property< std::vector< std::string > > m_acceptNames
Definition: OutputStream.h:69
void clearItems(Items &itms)
Clear item list.
Gaudi::Property< std::vector< std::string > > m_vetoNames
Definition: OutputStream.h:81
IDataSelector m_objects
Collection of objects being selected.
Definition: OutputStream.h:115
StatusCode finalize() override
Terminate OutputStream.
int m_events
Number of events written to this output stream.
Definition: OutputStream.h:117
Implementation of property with value of concrete type.
Definition: Property.h:370
std::map< std::string, ItemNames > AlgDependentItemNames
Definition: OutputStream.h:43
std::string m_outputType
Output type: NEW(NEW,CREATE,WRITE,RECREATE), UPDATE)
Definition: OutputStream.h:99
Gaudi::Property< bool > m_verifyItems
Definition: OutputStream.h:87
std::vector< Gaudi::Algorithm * > m_requireAlgs
Vector of Algorithms that this stream requires.
Definition: OutputStream.h:122
DataStoreItem * m_currentItem
Keep track of the current item.
Definition: OutputStream.h:107
Gaudi::Property< std::string > m_output
Definition: OutputStream.h:63
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition: Algorithm.h:102
Gaudi::Property< std::string > m_outputName
Definition: OutputStream.h:64
Gaudi::Property< ItemNames > m_optItemNames
Definition: OutputStream.h:51
IDataSelector * selectedObjects()
Return the list of selected objects.
Definition: OutputStream.h:163
SmartIF< IDataProviderSvc > m_pDataProvider
Keep reference to the data provider service.
Definition: OutputStream.h:101
Description of the DataStoreItem class.
Definition: DataStoreItem.h:27
Gaudi::Property< bool > m_doPreLoad
Definition: OutputStream.h:59
A small to stream Data I/O.
Definition: OutputStream.h:38
STL class.
virtual bool collect(IRegistry *dir, int level)
Store agent's classback.
DataStoreItem * findItem(const std::string &path)
Find single item identified by its path (exact match)
virtual bool hasInput() const
Tell if the instance has been configured with input items or not.
virtual StatusCode writeObjects()
Select the different objects and write them to file.
SmartIF< IConversionSvc > m_pConversionSvc
Keep reference to the data conversion service.
Definition: OutputStream.h:105
StatusCode initialize() override
Initialize OutputStream.
virtual StatusCode connectConversionSvc()
AlgDependentItems m_algDependentItems
Items to be saved for specific algorithms.
Definition: OutputStream.h:113
std::vector< DataStoreItem * > Items
Definition: OutputStream.h:40
std::vector< Gaudi::Algorithm * > m_vetoAlgs
Vector of Algorithms that this stream is vetoed by.
Definition: OutputStream.h:124
Gaudi::Property< std::vector< std::string > > m_requireNames
Definition: OutputStream.h:75
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
Items m_itemList
Vector of items to be saved to this stream.
Definition: OutputStream.h:109
void addItem(Items &itms, const std::string &descriptor)
Add item to output streamer list.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:32
Gaudi::Property< AlgDependentItemNames > m_algDependentItemList
Definition: OutputStream.h:53
SmartIF< IDataManagerSvc > m_pDataManager
Keep reference to the data manager service.
Definition: OutputStream.h:103
void clearSelection()
Clear list of selected objects.
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
Definition: OutputStream.h:96
StatusCode execute() override
Working entry point.
Alias for backward compatibility.
Definition: Algorithm.h:58
Gaudi::Property< std::string > m_storeName
Definition: OutputStream.h:65
std::vector< std::string > ItemNames
Definition: OutputStream.h:41
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:89
std::map< Gaudi::Algorithm *, Items > AlgDependentItems
Definition: OutputStream.h:42
Gaudi::Property< bool > m_doPreLoadOpt
Definition: OutputStream.h:61
bool isEventAccepted() const
Test whether this event should be output.
StatusCode collectFromSubTree(DataObject *)
void decodeAlgorithms(Gaudi::Property< std::vector< std::string >> &theNames, std::vector< Gaudi::Algorithm * > &theAlgs)
Decode specified list of Algorithms.
Gaudi::Property< std::string > m_persName
Definition: OutputStream.h:67
Gaudi::Algorithm * decodeAlgorithm(const std::string &theName)
Decode a single algorithm name.
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:40
Gaudi::Property< ItemNames > m_itemNames
Definition: OutputStream.h:50
virtual StatusCode collectObjects()
Collect all objects to be written to the output stream.
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:33
std::vector< Gaudi::Algorithm * > m_acceptAlgs
Vector of Algorithms that this stream accepts.
Definition: OutputStream.h:120
bool m_fireIncidents
should I fire incidents for writing opening/closing etc? in the baseclass, always fire the incidents ...
Definition: OutputStream.h:93
Items m_optItemList
Vector of optional items to be saved to this stream.
Definition: OutputStream.h:111