Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (d98a2936)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
OutputStream.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 #pragma once
12 
13 // Required for inheritance
14 #include <Gaudi/Property.h>
15 #include <GaudiKernel/Algorithm.h>
18 
19 // STL include files
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 // forward declarations
25 class IIncidentSvc;
26 class IRegistry;
27 class IConversionSvc;
28 struct IDataManagerSvc;
29 class OutputStreamAgent;
30 class DataStoreItem;
31 
37 class OutputStream : public Algorithm {
38 public:
39  typedef std::vector<DataStoreItem*> Items;
40  typedef std::vector<std::string> ItemNames;
41  typedef std::map<Gaudi::Algorithm*, Items> AlgDependentItems;
42  typedef std::map<std::string, ItemNames> AlgDependentItemNames;
43 
44 public:
47 
48 protected:
49  Gaudi::Property<ItemNames> m_itemNames{ this, "ItemList", {}, "vector of item names to be saved to this stream" };
51  this, "OptItemList", {}, "vector of optional item names to be saved to this stream" };
53  this,
54  "AlgDependentItemList",
55  {},
56  "mapping between algorithm names, and a list of items for which, if the "
57  "algorithm in question accepted the event, they should be also stored" };
58  Gaudi::Property<bool> m_doPreLoad{ this, "Preload", true,
59  "flag indicating whether data pre-loading should be performed" };
60  Gaudi::Property<bool> m_doPreLoadOpt{ this, "PreloadOptItems", false,
61  "flag indicating whether optional items should be preloaded" };
62  Gaudi::Property<std::string> m_output{ this, "Output", {}, "name of the output file specification" };
63  Gaudi::Property<std::string> m_outputName{ this, "OutputFile", {}, "name of the output file" };
64  Gaudi::Property<std::string> m_storeName{ this, "EvtDataSvc", "EventDataSvc",
65  "name of the service managing the data store" };
66  Gaudi::Property<std::string> m_persName{ this, "EvtConversionSvc", "EventPersistencySvc",
67  "name of the persistency service capable to write data from the store" };
69  this,
70  "AcceptAlgs",
71  {},
72  [this]( auto& ) { this->decodeAlgorithms( this->m_acceptNames, this->m_acceptAlgs ); },
73  "names of Algorithms that this stream accepts" };
75  this,
76  "RequireAlgs",
77  {},
78  [this]( auto& ) { this->decodeAlgorithms( this->m_requireNames, this->m_requireAlgs ); },
79  "names of Algorithms that this stream requires" };
81  this,
82  "VetoAlgs",
83  {},
84  [this]( auto& ) { this->decodeAlgorithms( this->m_vetoNames, this->m_vetoAlgs ); },
85  "names of Algorithms that this stream is vetoed by" };
86  Gaudi::Property<bool> m_verifyItems{ this, "VerifyItems", true,
87  "flag to indicate that item consistency should be checked" };
88 
92  bool m_fireIncidents = true;
93 
96 
98  std::string m_outputType = "UPDATE";
116  int m_events;
117 
119  std::vector<Gaudi::Algorithm*> m_acceptAlgs;
121  std::vector<Gaudi::Algorithm*> m_requireAlgs;
123  std::vector<Gaudi::Algorithm*> m_vetoAlgs;
124 
125 protected:
127  Gaudi::Algorithm* decodeAlgorithm( const std::string& theName );
129  void decodeAlgorithms( Gaudi::Property<std::vector<std::string>>& theNames, std::vector<Gaudi::Algorithm*>& theAlgs );
131  bool isEventAccepted() const;
133  DataStoreItem* findItem( const std::string& path );
135  virtual StatusCode writeObjects();
136 
138  virtual bool hasInput() const;
139 
140 public:
142  StatusCode start() override;
144  StatusCode initialize() override;
146  StatusCode finalize() override;
148  StatusCode execute() override;
149  // Connect to proper conversion service
152  virtual bool collect( IRegistry* dir, int level );
154  virtual StatusCode collectObjects();
156  void clearSelection();
157 
158 private:
160  void clearItems( Items& itms );
162  void addItem( Items& itms, const std::string& descriptor );
165 
167 };
OutputStream
A small to stream Data I/O.
Definition: OutputStream.h:37
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:86
IDataSelector
std::vector< DataObject * > IDataSelector
This is only a placeholder to allow me compiling until the responsible guy does his work!...
Definition: IDataSelector.h:15
OutputStream::m_requireAlgs
std::vector< Gaudi::Algorithm * > m_requireAlgs
Vector of Algorithms that this stream requires.
Definition: OutputStream.h:121
OutputStream::m_currentItem
DataStoreItem * m_currentItem
Keep track of the current item.
Definition: OutputStream.h:106
OutputStream::clearItems
void clearItems(Items &itms)
Clear item list.
Definition: OutputStream.cpp:325
OutputStream::m_vetoNames
Gaudi::Property< std::vector< std::string > > m_vetoNames
Definition: OutputStream.h:80
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:92
IDataManagerSvc
Definition: IDataManagerSvc.h:47
OutputStream::m_optItemList
Items m_optItemList
Vector of optional items to be saved to this stream.
Definition: OutputStream.h:110
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:98
OutputStream::m_events
int m_events
Number of events written to this output stream.
Definition: OutputStream.h:116
OutputStream::AlgDependentItemNames
std::map< std::string, ItemNames > AlgDependentItemNames
Definition: OutputStream.h:42
OutputStream::m_optItemNames
Gaudi::Property< ItemNames > m_optItemNames
Definition: OutputStream.h:50
OutputStream::m_output
Gaudi::Property< std::string > m_output
Definition: OutputStream.h:62
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:29
OutputStream::selectedObjects
IDataSelector * selectedObjects()
Return the list of selected objects.
Definition: OutputStream.h:164
OutputStream::m_doPreLoad
Gaudi::Property< bool > m_doPreLoad
Definition: OutputStream.h:58
OutputStream::m_pConversionSvc
SmartIF< IConversionSvc > m_pConversionSvc
Keep reference to the data conversion service.
Definition: OutputStream.h:104
OutputStream::m_outputName
Gaudi::Property< std::string > m_outputName
Definition: OutputStream.h:63
IIncidentSvc.h
OutputStream::m_vetoAlgs
std::vector< Gaudi::Algorithm * > m_vetoAlgs
Vector of Algorithms that this stream is vetoed by.
Definition: OutputStream.h:123
OutputStream::m_requireNames
Gaudi::Property< std::vector< std::string > > m_requireNames
Definition: OutputStream.h:74
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:100
StatusCode
Definition: StatusCode.h:64
OutputStream::m_algDependentItems
AlgDependentItems m_algDependentItems
Items to be saved for specific algorithms.
Definition: OutputStream.h:112
IDataSelector.h
DataStoreItem
Definition: DataStoreItem.h:25
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:87
OutputStream::Items
std::vector< DataStoreItem * > Items
Definition: OutputStream.h:39
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:52
OutputStream::m_pDataManager
SmartIF< IDataManagerSvc > m_pDataManager
Keep reference to the data manager service.
Definition: OutputStream.h:102
SmartIF< IIncidentSvc >
OutputStream::m_incidentSvc
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
Definition: OutputStream.h:95
OutputStream::start
StatusCode start() override
Start OutputStream.
Definition: OutputStream.cpp:45
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:108
OutputStream::m_storeName
Gaudi::Property< std::string > m_storeName
Definition: OutputStream.h:64
OutputStream::m_doPreLoadOpt
Gaudi::Property< bool > m_doPreLoadOpt
Definition: OutputStream.h:60
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:37
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:41
Gaudi::Algorithm::Algorithm
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition: Algorithm.h:98
OutputStream::ItemNames
std::vector< std::string > ItemNames
Definition: OutputStream.h:40
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:49
IIncidentSvc
Definition: IIncidentSvc.h:30
Gaudi::Property< ItemNames >
OutputStream::collectFromSubTree
StatusCode collectFromSubTree(DataObject *)
Definition: OutputStream.cpp:517
OutputStream::m_objects
IDataSelector m_objects
Collection of objects being selected.
Definition: OutputStream.h:114
Property.h
OutputStream::m_acceptAlgs
std::vector< Gaudi::Algorithm * > m_acceptAlgs
Vector of Algorithms that this stream accepts.
Definition: OutputStream.h:119
OutputStream::m_persName
Gaudi::Property< std::string > m_persName
Definition: OutputStream.h:66
OutputStream::m_acceptNames
Gaudi::Property< std::vector< std::string > > m_acceptNames
Definition: OutputStream.h:68
IConversionSvc
Definition: IConversionSvc.h:43