The Gaudi Framework  v30r4 (9b837755)
OutputStream Class Reference

A small to stream Data I/O. More...

#include <src/PersistencySvc/OutputStream.h>

Inheritance diagram for OutputStream:
Collaboration diagram for OutputStream:

Public Types

typedef std::vector< DataStoreItem * > Items
 
typedef std::vector< std::stringItemNames
 
typedef std::map< Algorithm *, ItemsAlgDependentItems
 
typedef std::map< std::string, ItemNamesAlgDependentItemNames
 
- Public Types inherited from Algorithm
using Factory = Gaudi::PluginService::Factory< IAlgorithm *(const std::string &, ISvcLocator *)>
 
- Public Types inherited from extends< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >, IDataHandleHolder >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 

Public Member Functions

StatusCode initialize () override
 Initialize OutputStream. More...
 
StatusCode finalize () override
 Terminate OutputStream. More...
 
StatusCode execute () override
 Working entry point. More...
 
virtual StatusCode connectConversionSvc ()
 
virtual bool collect (IRegistry *dir, int level)
 Store agent's classback. More...
 
virtual StatusCode collectObjects ()
 Collect all objects to be written to the output stream. More...
 
void clearSelection ()
 Clear list of selected objects. More...
 
- Public Member Functions inherited from Algorithm
 Algorithm (const std::string &name, ISvcLocator *svcloc, const std::string &version=PACKAGE_VERSION)
 Constructor. More...
 
StatusCode sysStart () override
 Reinitialization method invoked by the framework. More...
 
StatusCode sysInitialize () override
 Initialization method invoked by the framework. More...
 
StatusCode sysReinitialize () override
 Reinitialization method invoked by the framework. More...
 
StatusCode sysRestart () override
 Restart method invoked by the framework. More...
 
StatusCode sysExecute (const EventContext &ctx) override
 The actions to be performed by the algorithm on an event. More...
 
StatusCode sysStop () override
 System stop. More...
 
StatusCode sysFinalize () override
 System finalization. More...
 
StatusCode sysBeginRun () override
 beginRun method invoked by the framework. More...
 
StatusCode sysEndRun () override
 endRun method invoked by the framework. More...
 
const std::stringname () const override
 The identifying name of the algorithm object. More...
 
const Gaudi::StringKeynameKey () const override
 
const std::stringtype () const override
 The type of the algorithm object. More...
 
void setType (const std::string &type) override
 
const std::stringversion () const override
 
unsigned int index () const override
 
StatusCode configure () override
 Dummy implementation of IStateful::configure() method. More...
 
StatusCode terminate () override
 Dummy implementation of IStateful::terminate() method. More...
 
StatusCode initialize () override
 the default (empty) implementation of IStateful::initialize() method More...
 
StatusCode start () override
 the default (empty) implementation of IStateful::start() method More...
 
StatusCode stop () override
 the default (empty) implementation of IStateful::stop() method More...
 
StatusCode finalize () override
 the default (empty) implementation of IStateful::finalize() method More...
 
StatusCode reinitialize () override
 the default (empty) implementation of IStateful::reinitialize() method More...
 
StatusCode restart () override
 the default (empty) implementation of IStateful::restart() method More...
 
Gaudi::StateMachine::State FSMState () const override
 returns the current state of the algorithm More...
 
Gaudi::StateMachine::State targetFSMState () const override
 returns the state the algorithm will be in after the ongoing transition More...
 
bool isExecuted () const override
 Has this algorithm been executed since the last reset? More...
 
void setExecuted (bool state) const override
 Set the executed flag to the specified state. More...
 
void resetExecuted () override
 Reset the executed state of the Algorithm for the duration of the current event. More...
 
StatusCode beginRun () override
 Algorithm begin run. More...
 
StatusCode endRun () override
 Algorithm end run. This method is called at the end of the event loop. More...
 
bool isEnabled () const override
 Is this algorithm enabled or disabled? More...
 
bool isSequence () const override
 Are we a Sequence? More...
 
bool filterPassed () const override
 Did this algorithm pass or fail its filter criterion for the last event? More...
 
void setFilterPassed (bool state) const override
 Set the filter passed flag to the specified state. More...
 
unsigned int errorCount () const
 Get the number of failures of the algorithm. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
SmartIF< IServiceservice (const std::string &name, const bool createIf=true, const bool quiet=false) const
 Return a pointer to the service identified by name (or "type/name") More...
 
template<class T >
SmartIF< T > service (const std::string &name, bool createIf=true, bool quiet=false) const
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
SmartIF< IChronoStatSvc > & chronoSvc () const
 The standard Chrono & Stat service, Return a pointer to the service if present. More...
 
SmartIF< IChronoStatSvc > & chronoStatService () const
 
SmartIF< IDataProviderSvc > & detSvc () const
 The standard detector data service. More...
 
SmartIF< IDataProviderSvc > & detDataService () const
 
SmartIF< IConversionSvc > & detCnvSvc () const
 The standard detector data persistency conversion service. More...
 
SmartIF< IConversionSvc > & detDataCnvService () const
 
SmartIF< IDataProviderSvc > & eventSvc () const final override
 The standard event data service. More...
 
SmartIF< IDataProviderSvc > & evtSvc () const
 shortcut for method eventSvc More...
 
SmartIF< IDataProviderSvc > & eventDataService () const
 
SmartIF< IConversionSvc > & eventCnvSvc () const
 The standard event data persistency conversion service. More...
 
SmartIF< IConversionSvc > & eventDataCnvService () const
 
SmartIF< IHistogramSvc > & histoSvc () const
 The standard histogram service. More...
 
SmartIF< IHistogramSvc > & histogramDataService () const
 
SmartIF< INTupleSvc > & ntupleSvc () const
 The standard N tuple service. More...
 
SmartIF< INTupleSvc > & ntupleService () const
 
SmartIF< IRndmGenSvc > & randSvc () const
 The standard RandomGen service, Return a pointer to the service if present. More...
 
SmartIF< IToolSvc > & toolSvc () const
 The standard ToolSvc service, Return a pointer to the service if present. More...
 
SmartIF< IExceptionSvc > & exceptionSvc () const
 Get the exception Service. More...
 
SmartIF< IAlgContextSvc > & contextSvc () const
 get Algorithm Context Service More...
 
SmartIF< ITimelineSvc > & timelineSvc () const
 
SmartIF< ISvcLocator > & serviceLocator () const override
 The standard service locator. More...
 
SmartIF< ISvcLocator > & svcLoc () const
 shortcut for method serviceLocator More...
 
SmartIF< IHiveWhiteBoard > & whiteboard () const
 
SmartIF< IAlgExecStateSvc > & algExecStateSvc () const
 
bool registerContext () const
 register for Algorithm Context Service? More...
 
StatusCode createSubAlgorithm (const std::string &type, const std::string &name, Algorithm *&pSubAlg)
 Create a sub algorithm. More...
 
const std::vector< Algorithm * > * subAlgorithms () const
 List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms. More...
 
std::vector< Algorithm * > * subAlgorithms ()
 List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms. More...
 
StatusCode setProperties ()
 Set the algorithm's properties. More...
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
SmartIF< IMonitorSvc > & monitorSvc () const
 Access the monitor service. More...
 
template<class T >
void declareInfo (const std::string &name, const T &var, const std::string &desc) const
 Declare monitoring information. More...
 
void declareInfo (const std::string &name, const std::string &format, const void *var, int size, const std::string &desc) const
 Declare monitoring information (special case) More...
 
const EventContextgetContext () const override
 get the context More...
 
void registerTool (IAlgTool *tool) const
 
void deregisterTool (IAlgTool *tool) const
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 
template<class T >
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
bool isIOBound () const
 
void setIOBound (bool value)
 
unsigned int cardinality () const override
 Return the cardinality. More...
 
const std::vector< std::string > & neededResources () const override
 
std::ostreamtoControlFlowExpression (std::ostream &os) const override
 Produce string represention of the control flow expression. More...
 
- Public Member Functions inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >
 DataHandleHolderBase (Args &&...args)
 NOTE: Cannot use "using Super::Super;" due to a GCC 6 bug. More...
 
void registerDataHandle (Gaudi::v2::DataHandle &handle) final override
 Register a data handle of this algorithm/tool. More...
 
void addDataDependency (const DataObjID &key, AccessMode access) final override
 Add a data dependency, even after initialization. More...
 
const DataObjIDColldataDependencies (AccessMode access) const final override
 Tell which whiteboard keys the algorithm will be reading or writing. More...
 
void declare (Gaudi::v1::DataHandle &handle) override
 Declare ownership of a legacy DataHandle. More...
 
void renounce (Gaudi::v1::DataHandle &handle) override
 Discard ownership of a legacy DataHandle. More...
 
const DataObjIDCollallDataDependencies () const final override
 
- Public Member Functions inherited from extends< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >, IDataHandleHolder >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const
 Backward compatibility function for getting the output level. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 

Protected Member Functions

AlgorithmdecodeAlgorithm (const std::string &theName)
 Decode a single algorithm name. More...
 
void decodeAlgorithms (Gaudi::Property< std::vector< std::string >> &theNames, std::vector< Algorithm * > &theAlgs)
 Decode specified list of Algorithms. More...
 
bool isEventAccepted () const
 Test whether this event should be output. More...
 
DataStoreItemfindItem (const std::string &path)
 Find single item identified by its path (exact match) More...
 
virtual StatusCode writeObjects ()
 Select the different objects and write them to file. More...
 
virtual bool hasInput () const
 Tell if the instance has been configured with input items or not. More...
 
- Protected Member Functions inherited from Algorithm
std::vector< IAlgTool * > & tools ()
 
bool isInitialized () const override
 Has the Algorithm already been initialized? More...
 
bool isFinalized () const override
 Has the Algorithm already been finalized? More...
 
void setIndex (const unsigned int &idx) override
 set instantiation index of Alg More...
 
AlgExecStateexecState (const EventContext &ctx) const
 reference to AlgExecState of Alg More...
 
- Protected Member Functions inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >
void updateDataDependencies (const DataObjIDMapping &keyMap)
 Update the key of each registered data dependency, using a user-defined mapping from the old to the new key. More...
 
void collectExplicitDataDependencies ()
 Collect all explicit data dependencies in a single place. More...
 
StatusCode handleCircularDataDependencies (CircularDepHandler &&circularDepHandler)
 Look for circular dependencies and let a user-specified handler deal with each of them. More...
 
void collectImplicitDataDependencies (const IDataHandleHolder *child)
 Add the dependencies of another DataHandleHolder to our dependency list. More...
 
const DataObjIDCollignoredDataDependencies (AccessMode access) const
 Tell which data dependencies have been ignored due to an empty key. More...
 
void initializeDataHandleHolder ()
 Initialize the DataHandles. More...
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Protected Attributes

Gaudi::Property< ItemNamesm_itemNames {this, "ItemList", {}, "vector of item names to be saved to this stream"}
 
Gaudi::Property< ItemNamesm_optItemNames
 
Gaudi::Property< AlgDependentItemNamesm_algDependentItemList
 
Gaudi::Property< bool > m_doPreLoad
 
Gaudi::Property< bool > m_doPreLoadOpt
 
Gaudi::Property< std::stringm_output {this, "Output", {}, "name of the output file specification"}
 
Gaudi::Property< std::stringm_outputName {this, "OutputFile", {}, "name of the output file"}
 
Gaudi::Property< std::stringm_storeName
 
Gaudi::Property< std::stringm_persName
 
Gaudi::Property< std::vector< std::string > > m_acceptNames
 
Gaudi::Property< std::vector< std::string > > m_requireNames
 
Gaudi::Property< std::vector< std::string > > m_vetoNames
 
Gaudi::Property< bool > m_verifyItems
 
bool m_fireIncidents = true
 should I fire incidents for writing opening/closing etc? in the baseclass, always fire the incidents by default in e.g. More...
 
SmartIF< IIncidentSvcm_incidentSvc
 Reference to the incident service. More...
 
std::string m_outputType = "UPDATE"
 Output type: NEW(NEW,CREATE,WRITE,RECREATE), UPDATE) More...
 
SmartIF< IDataProviderSvcm_pDataProvider
 Keep reference to the data provider service. More...
 
SmartIF< IDataManagerSvcm_pDataManager
 Keep reference to the data manager service. More...
 
SmartIF< IConversionSvcm_pConversionSvc
 Keep reference to the data conversion service. More...
 
DataStoreItemm_currentItem
 Keep track of the current item. More...
 
Items m_itemList
 Vector of items to be saved to this stream. More...
 
Items m_optItemList
 Vector of optional items to be saved to this stream. More...
 
AlgDependentItems m_algDependentItems
 Items to be saved for specific algorithms. More...
 
IDataSelector m_objects
 Collection of objects being selected. More...
 
int m_events
 Number of events written to this output stream. More...
 
std::vector< Algorithm * > m_acceptAlgs
 Vector of Algorithms that this stream accepts. More...
 
std::vector< Algorithm * > m_requireAlgs
 Vector of Algorithms that this stream requires. More...
 
std::vector< Algorithm * > m_vetoAlgs
 Vector of Algorithms that this stream is vetoed by. More...
 
- Protected Attributes inherited from Algorithm
DataObjIDMapping m_updateDependencies
 Hook for for derived classes to alter the DataObjID of dependencies. More...
 

Private Member Functions

void clearItems (Items &itms)
 Clear item list. More...
 
void addItem (Items &itms, const std::string &descriptor)
 Add item to output streamer list. More...
 
IDataSelectorselectedObjects ()
 Return the list of selected objects. More...
 
StatusCode collectFromSubTree (DataObject *)
 

Additional Inherited Members

- Public Attributes inherited from Algorithm
friend AlgorithmManager
 
- Protected Types inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >
enum  CircularDepAction
 A circular dependency handling action. More...
 
using DataObjIDMapping = std::function< boost::optional< DataObjID >(const DataObjID &)>
 DataObjID mapping function, with optimized identity mapping case. More...
 
using CircularDepHandler = std::function< CircularDepAction(const DataObjID &)>
 A circular dependency handler, which can take any user-specified step (e.g. More...
 

Detailed Description

A small to stream Data I/O.

Author: M.Frank author R. Lambert Version: 1.0

Definition at line 28 of file OutputStream.h.

Member Typedef Documentation

Definition at line 33 of file OutputStream.h.

Definition at line 32 of file OutputStream.h.

Definition at line 31 of file OutputStream.h.

Member Function Documentation

void OutputStream::addItem ( Items itms,
const std::string descriptor 
)
private

Add item to output streamer list.

Definition at line 318 of file OutputStream.cpp.

319 {
320  int level = 0;
321  auto sep = descriptor.rfind( "#" );
322  std::string obj_path = descriptor.substr( 0, sep );
323  if ( sep != std::string::npos ) {
324  std::string slevel = descriptor.substr( sep + 1 );
325  level = ( slevel == "*" ) ? 9999999 : std::stoi( slevel );
326  }
327  if ( m_verifyItems ) {
328  size_t idx = obj_path.find( "/", 1 );
329  while ( idx != std::string::npos ) {
330  std::string sub_item = obj_path.substr( 0, idx );
331  if ( !findItem( sub_item ) ) addItem( itms, sub_item + "#1" );
332  idx = obj_path.find( "/", idx + 1 );
333  }
334  }
335  itms.push_back( new DataStoreItem( obj_path, level ) );
336  const auto& item = itms.back();
337  ON_DEBUG
338  debug() << "Adding OutputStream item " << item->path() << " with " << item->depth() << " level(s)." << endmsg;
339 }
Gaudi::Property< bool > m_verifyItems
Definition: OutputStream.h:78
T rfind(T...args)
Description of the DataStoreItem class.
Definition: DataStoreItem.h:17
STL class.
DataStoreItem * findItem(const std::string &path)
Find single item identified by its path (exact match)
void addItem(Items &itms, const std::string &descriptor)
Add item to output streamer list.
T find(T...args)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
#define ON_DEBUG
T substr(T...args)
T stoi(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
void OutputStream::clearItems ( Items itms)
private

Clear item list.

Definition at line 299 of file OutputStream.cpp.

300 {
301  for ( auto& i : itms ) delete i;
302  itms.clear();
303 }
void OutputStream::clearSelection ( )

Clear list of selected objects.

Definition at line 296 of file OutputStream.cpp.

296 { m_objects.clear(); }
IDataSelector m_objects
Collection of objects being selected.
Definition: OutputStream.h:106
T clear(T...args)
bool OutputStream::collect ( IRegistry dir,
int  level 
)
virtual

Store agent's classback.

Definition at line 205 of file OutputStream.cpp.

206 {
207  if ( level < m_currentItem->depth() ) {
208  if ( dir->object() ) {
209  /*
210  std::cout << "Analysing ("
211  << dir->name()
212  << ") Object:"
213  << ((dir->object()==0) ? "UNLOADED" : "LOADED")
214  << std::endl;
215  */
216  m_objects.push_back( dir->object() );
217  return true;
218  }
219  }
220  return false;
221 }
IDataSelector m_objects
Collection of objects being selected.
Definition: OutputStream.h:106
T push_back(T...args)
virtual DataObject * object() const =0
Retrieve object behind the link.
StatusCode OutputStream::collectFromSubTree ( DataObject pObj)
private

Definition at line 503 of file OutputStream.cpp.

504 {
505  return m_pDataManager->traverseSubTree( pObj,
506  [this]( IRegistry* r, int level ) { return this->collect( r, level ); } );
507 }
virtual StatusCode traverseSubTree(boost::string_ref sub_tree_path, IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects below the sub tree identified by its full path name...
virtual bool collect(IRegistry *dir, int level)
Store agent&#39;s classback.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
SmartIF< IDataManagerSvc > m_pDataManager
Keep reference to the data manager service.
Definition: OutputStream.h:94
StatusCode OutputStream::collectObjects ( )
virtual

Collect all objects to be written to the output stream.

Reimplemented in InputCopyStream.

Definition at line 224 of file OutputStream.cpp.

225 {
227 
228  // Traverse the tree and collect the requested objects
229  for ( auto& i : m_itemList ) {
230  DataObject* obj = nullptr;
231  m_currentItem = i;
233  if ( iret.isSuccess() ) {
234  iret = collectFromSubTree( obj );
235  if ( !iret.isSuccess() ) status = iret;
236  } else {
237  error() << "Cannot write mandatory object(s) (Not found) " << m_currentItem->path() << endmsg;
238  status = iret;
239  }
240  }
241 
242  // Traverse the tree and collect the requested objects (tolerate missing items here)
243  for ( auto& i : m_optItemList ) {
244  DataObject* obj = nullptr;
245  m_currentItem = i;
247  if ( iret.isSuccess() ) iret = collectFromSubTree( obj );
248  if ( !iret.isSuccess() ) {
249  ON_DEBUG
250  debug() << "Ignore request to write non-mandatory object(s) " << m_currentItem->path() << endmsg;
251  }
252  }
253 
254  // Collect objects dependent on particular algorithms
255  for ( const auto& iAlgItems : m_algDependentItems ) {
256  Algorithm* alg = iAlgItems.first;
257  const Items& items = iAlgItems.second;
258  if ( alg->isExecuted() && alg->filterPassed() ) {
259  ON_DEBUG
260  debug() << "Algorithm '" << alg->name() << "' fired. Adding " << items << endmsg;
261  for ( const auto& i : items ) {
262  DataObject* obj = nullptr;
263  m_currentItem = i;
265  if ( iret.isSuccess() ) {
266  iret = collectFromSubTree( obj );
267  if ( !iret.isSuccess() ) status = iret;
268  } else {
269  error() << "Cannot write mandatory (algorithm dependent) object(s) (Not found) " << m_currentItem->path()
270  << endmsg;
271  status = iret;
272  }
273  }
274  }
275  }
276 
277  if ( status.isSuccess() ) {
278  // Remove duplicates from the list of objects, preserving the order in the list
280  std::vector<DataObject*> tmp; // temporary vector with the reduced list
281  tmp.reserve( m_objects.size() );
282  for ( auto& o : m_objects ) {
283  if ( !unique.count( o ) ) {
284  // if the pointer is not in the set, add it to both the set and the temporary vector
285  unique.insert( o );
286  tmp.push_back( o );
287  }
288  }
289  m_objects.swap( tmp ); // swap the data of the two vectors
290  }
291 
292  return status;
293 }
IDataSelector m_objects
Collection of objects being selected.
Definition: OutputStream.h:106
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:747
bool isExecuted() const override
Has this algorithm been executed since the last reset?
Definition: Algorithm.cpp:757
DataStoreItem * m_currentItem
Keep track of the current item.
Definition: OutputStream.h:98
bool isSuccess() const
Definition: StatusCode.h:287
SmartIF< IDataProviderSvc > m_pDataProvider
Keep reference to the data provider service.
Definition: OutputStream.h:92
T unique(T...args)
const std::string & path() const
Accessor: Retrieve load path.
Definition: DataStoreItem.h:58
T push_back(T...args)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
AlgDependentItems m_algDependentItems
Items to be saved for specific algorithms.
Definition: OutputStream.h:104
std::vector< DataStoreItem * > Items
Definition: OutputStream.h:31
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
Items m_itemList
Vector of items to be saved to this stream.
Definition: OutputStream.h:100
virtual StatusCode retrieveObject(IRegistry *pDirectory, boost::string_ref path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
T count(T...args)
T insert(T...args)
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
T size(T...args)
STL class.
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
bool filterPassed() const override
Did this algorithm pass or fail its filter criterion for the last event?
Definition: Algorithm.cpp:771
#define ON_DEBUG
StatusCode collectFromSubTree(DataObject *)
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
T reserve(T...args)
Items m_optItemList
Vector of optional items to be saved to this stream.
Definition: OutputStream.h:102
StatusCode OutputStream::connectConversionSvc ( )
virtual

Definition at line 342 of file OutputStream.cpp.

343 {
344  StatusCode status = StatusCode( StatusCode::FAILURE, true );
345  // Get output file from input
346  std::string dbType, svc, shr;
347  for ( auto attrib : Gaudi::Utils::AttribStringParser( m_output ) ) {
348  const std::string& tag = attrib.tag;
349  const std::string& val = attrib.value;
350  switch (::toupper( tag[0] ) ) {
351  case 'D':
352  m_outputName = val;
353  break;
354  case 'T':
355  dbType = val;
356  break;
357  case 'S':
358  switch (::toupper( tag[1] ) ) {
359  case 'V':
360  svc = val;
361  break;
362  case 'H':
363  shr = "YES";
364  break;
365  }
366  break;
367  case 'O': // OPT='<NEW<CREATE,WRITE,RECREATE>, UPDATE>'
368  switch (::toupper( val[0] ) ) {
369  case 'R':
370  if (::strncasecmp( val.c_str(), "RECREATE", 3 ) == 0 )
371  m_outputType = "RECREATE";
372  else if (::strncasecmp( val.c_str(), "READ", 3 ) == 0 )
373  m_outputType = "READ";
374  break;
375  case 'C':
376  case 'N':
377  case 'W':
378  m_outputType = "NEW";
379  break;
380  case 'U':
381  m_outputType = "UPDATE";
382  break;
383  default:
384  m_outputType = "???";
385  break;
386  }
387  break;
388  default:
389  break;
390  }
391  }
392  if ( !shr.empty() ) m_outputType += "|SHARED";
393  // Get access to the default Persistency service
394  // The default service is the same for input as for output.
395  // If this is not desired, then a specialized OutputStream must overwrite
396  // this value.
397  if ( !dbType.empty() || !svc.empty() ) {
398  std::string typ = !dbType.empty() ? dbType : svc;
399  auto ipers = serviceLocator()->service<IPersistencySvc>( m_persName );
400  if ( !ipers ) {
401  fatal() << "Unable to locate IPersistencySvc interface of " << m_persName << endmsg;
402  return StatusCode::FAILURE;
403  }
404  IConversionSvc* cnvSvc = nullptr;
405  status = ipers->getService( typ, cnvSvc );
406  if ( !status.isSuccess() ) {
407  fatal() << "Unable to locate IConversionSvc interface of database type " << typ << endmsg;
408  return status;
409  }
410  // Increase reference count and keep service.
411  m_pConversionSvc = cnvSvc;
412  } else {
413  fatal() << "Unable to locate IConversionSvc interface (Unknown technology) " << endmsg
414  << "You either have to specify a technology name or a service name!" << endmsg
415  << "Please correct the job option \"" << name() << ".Output\" !" << endmsg;
416  return StatusCode::FAILURE;
417  }
418  return StatusCode::SUCCESS;
419 }
Parse attribute strings allowing iteration over the various attributes.
constexpr static const auto FAILURE
Definition: StatusCode.h:88
T empty(T...args)
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:747
std::string m_outputType
Output type: NEW(NEW,CREATE,WRITE,RECREATE), UPDATE)
Definition: OutputStream.h:90
bool isSuccess() const
Definition: StatusCode.h:287
Gaudi::Property< std::string > m_output
Definition: OutputStream.h:54
Gaudi::Property< std::string > m_outputName
Definition: OutputStream.h:55
STL class.
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
SmartIF< IConversionSvc > m_pConversionSvc
Keep reference to the data conversion service.
Definition: OutputStream.h:96
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Algorithm.cpp:816
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
T c_str(T...args)
Data persistency service interface.
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
Gaudi::Property< std::string > m_persName
Definition: OutputStream.h:58
void toupper(std::string &s)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Algorithm * OutputStream::decodeAlgorithm ( const std::string theName)
protected

Decode a single algorithm name.

Definition at line 421 of file OutputStream.cpp.

422 {
423  Algorithm* theAlgorithm = nullptr;
424 
425  auto theAlgMgr = serviceLocator()->as<IAlgManager>();
426  if ( theAlgMgr ) {
427  // Check whether the supplied name corresponds to an existing
428  // Algorithm object.
429  SmartIF<IAlgorithm>& theIAlg = theAlgMgr->algorithm( theName );
430  if ( theIAlg ) {
431  try {
432  theAlgorithm = dynamic_cast<Algorithm*>( theIAlg.get() );
433  } catch ( ... ) {
434  // do nothing
435  }
436  }
437  } else {
438  fatal() << "Can't locate ApplicationMgr!!!" << endmsg;
439  }
440 
441  if ( !theAlgorithm ) {
442  warning() << "Failed to decode Algorithm name " << theName << endmsg;
443  }
444 
445  return theAlgorithm;
446 }
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition: IAlgManager.h:27
SmartIF< IFace > as()
Definition: ISvcLocator.h:109
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:82
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Algorithm.cpp:816
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
void OutputStream::decodeAlgorithms ( Gaudi::Property< std::vector< std::string >> &  theNames,
std::vector< Algorithm * > &  theAlgs 
)
protected

Decode specified list of Algorithms.

Definition at line 448 of file OutputStream.cpp.

450 {
451  // Reset the list of Algorithms
452  theAlgs.clear();
453 
454  // Build the list of Algorithms from the names list
455  for ( const auto& it : theNames.value() ) {
456 
457  Algorithm* theAlgorithm = decodeAlgorithm( it );
458  if ( theAlgorithm ) {
459  // Check that the specified algorithm doesn't already exist in the list
460  if ( std::find( std::begin( theAlgs ), std::end( theAlgs ), theAlgorithm ) == std::end( theAlgs ) ) {
461  theAlgorithm->addRef();
462  theAlgs.push_back( theAlgorithm );
463  }
464  } else {
465  info() << it << " doesn't exist - ignored" << endmsg;
466  }
467  }
468 }
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
T end(T...args)
T push_back(T...args)
T clear(T...args)
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
T find(T...args)
T begin(T...args)
Algorithm * decodeAlgorithm(const std::string &theName)
Decode a single algorithm name.
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:587
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode OutputStream::execute ( )
override

Working entry point.

Definition at line 131 of file OutputStream.cpp.

132 {
133  // Clear any previously existing item list
134  clearSelection();
135  // Test whether this event should be output
136  if ( isEventAccepted() ) {
137  const StatusCode sc = writeObjects();
138  clearSelection();
139  ++m_events;
140  if ( sc.isSuccess() && m_fireIncidents ) {
141  m_incidentSvc->fireIncident( Incident( m_outputName, IncidentType::WroteToOutputFile ) );
142  } else if ( m_fireIncidents ) {
143  m_incidentSvc->fireIncident( Incident( m_outputName, IncidentType::FailOutputFile ) );
144  }
145  return sc;
146  }
147  return StatusCode::SUCCESS;
148 }
bool isEventAccepted() const
Test whether this event should be output.
int m_events
Number of events written to this output stream.
Definition: OutputStream.h:108
bool isSuccess() const
Definition: StatusCode.h:287
Gaudi::Property< std::string > m_outputName
Definition: OutputStream.h:55
virtual StatusCode writeObjects()
Select the different objects and write them to file.
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
void clearSelection()
Clear list of selected objects.
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
Definition: OutputStream.h:87
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
Base class for all Incidents (computing events).
Definition: Incident.h:17
bool m_fireIncidents
should I fire incidents for writing opening/closing etc? in the baseclass, always fire the incidents ...
Definition: OutputStream.h:84
StatusCode OutputStream::finalize ( )
override

Terminate OutputStream.

Definition at line 117 of file OutputStream.cpp.

118 {
119  info() << "Events output: " << m_events << endmsg;
120  if ( m_fireIncidents ) m_incidentSvc->fireIncident( Incident( m_outputName, IncidentType::EndOutputFile ) );
127  return StatusCode::SUCCESS;
128 }
void clearItems(Items &itms)
Clear item list.
int m_events
Number of events written to this output stream.
Definition: OutputStream.h:108
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Gaudi::Property< std::string > m_outputName
Definition: OutputStream.h:55
SmartIF< IDataProviderSvc > m_pDataProvider
Keep reference to the data provider service.
Definition: OutputStream.h:92
SmartIF< IConversionSvc > m_pConversionSvc
Keep reference to the data conversion service.
Definition: OutputStream.h:96
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
Items m_itemList
Vector of items to be saved to this stream.
Definition: OutputStream.h:100
SmartIF< IDataManagerSvc > m_pDataManager
Keep reference to the data manager service.
Definition: OutputStream.h:94
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
Definition: OutputStream.h:87
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
Base class for all Incidents (computing events).
Definition: Incident.h:17
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:92
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
bool m_fireIncidents
should I fire incidents for writing opening/closing etc? in the baseclass, always fire the incidents ...
Definition: OutputStream.h:84
Items m_optItemList
Vector of optional items to be saved to this stream.
Definition: OutputStream.h:102
DataStoreItem * OutputStream::findItem ( const std::string path)
protected

Find single item identified by its path (exact match)

Definition at line 306 of file OutputStream.cpp.

307 {
308  auto matchPath = [&]( const DataStoreItem* i ) { return i->path() == path; };
309  auto i = std::find_if( m_itemList.begin(), m_itemList.end(), matchPath );
310  if ( i == m_itemList.end() ) {
311  i = std::find_if( m_optItemList.begin(), m_optItemList.end(), matchPath );
312  if ( i == m_optItemList.end() ) return nullptr;
313  }
314  return *i;
315 }
T end(T...args)
Description of the DataStoreItem class.
Definition: DataStoreItem.h:17
Items m_itemList
Vector of items to be saved to this stream.
Definition: OutputStream.h:100
T find_if(T...args)
T begin(T...args)
Items m_optItemList
Vector of optional items to be saved to this stream.
Definition: OutputStream.h:102
bool OutputStream::hasInput ( ) const
protectedvirtual

Tell if the instance has been configured with input items or not.

Reimplemented in InputCopyStream.

Definition at line 498 of file OutputStream.cpp.

499 {
500  return !( m_itemNames.empty() && m_optItemNames.empty() && m_algDependentItemList.empty() );
501 }
Gaudi::Property< ItemNames > m_optItemNames
Definition: OutputStream.h:42
Gaudi::Property< AlgDependentItemNames > m_algDependentItemList
Definition: OutputStream.h:44
Gaudi::Property< ItemNames > m_itemNames
Definition: OutputStream.h:41
StatusCode OutputStream::initialize ( )
override

Initialize OutputStream.

Definition at line 29 of file OutputStream.cpp.

30 {
31 
32  // Reset the number of events written
33  m_events = 0;
34  // Get access to the DataManagerSvc
36  if ( !m_pDataManager ) {
37  fatal() << "Unable to locate IDataManagerSvc interface" << endmsg;
38  return StatusCode::FAILURE;
39  }
40  // Get access to the IncidentService
41  m_incidentSvc = serviceLocator()->service( "IncidentSvc" );
42  if ( !m_incidentSvc ) {
43  warning() << "Error retrieving IncidentSvc." << endmsg;
44  return StatusCode::FAILURE;
45  }
46  // Get access to the assigned data service
48  if ( !m_pDataProvider ) {
49  fatal() << "Unable to locate IDataProviderSvc interface of " << m_storeName << endmsg;
50  return StatusCode::FAILURE;
51  }
52  if ( hasInput() ) {
54  if ( !status.isSuccess() ) {
55  fatal() << "Unable to connect to conversion service." << endmsg;
56  if ( m_outputName != "" && m_fireIncidents )
57  m_incidentSvc->fireIncident( Incident( m_outputName, IncidentType::FailOutputFile ) );
58  return status;
59  }
60  }
61 
62  // Clear the list with optional items
64  // Clear the item list
66 
67  // Take the new item list from the properties.
68  ON_DEBUG debug() << "ItemList : " << m_itemNames.value() << endmsg;
69  for ( const auto& i : m_itemNames ) addItem( m_itemList, i );
70 
71  // Take the new item list from the properties.
72  ON_DEBUG debug() << "OptItemList : " << m_optItemNames.value() << endmsg;
73  for ( const auto& i : m_optItemNames ) addItem( m_optItemList, i );
74 
75  // prepare the algorithm selected dependent locations
76  ON_DEBUG debug() << "AlgDependentItemList : " << m_algDependentItemList.value() << endmsg;
77  for ( const auto& a : m_algDependentItemList ) {
78  // Get the algorithm pointer
79  Algorithm* theAlgorithm = decodeAlgorithm( a.first );
80  if ( theAlgorithm ) {
81  // Get the item list for this alg
82  auto& items = m_algDependentItems[theAlgorithm];
83  // Clear the list for this alg
84  clearItems( items );
85  // fill the list again
86  for ( const auto& i : a.second ) addItem( items, i );
87  }
88  }
89 
90  // Take the item list to the data service preload list.
91  if ( m_doPreLoad ) {
92  for ( auto& j : m_itemList ) m_pDataProvider->addPreLoadItem( *j ).ignore();
93  // Not working: bad reference counting! pdataSvc->release();
94  }
95 
96  if ( m_doPreLoadOpt ) {
97  for ( auto& j : m_optItemList ) m_pDataProvider->addPreLoadItem( *j ).ignore();
98  }
99  info() << "Data source: " << m_storeName.value() << " output: " << m_output.value() << endmsg;
100 
101  // Decode the accept, required and veto Algorithms. The logic is the following:
102  // a. The event is accepted if all lists are empty.
103  // b. The event is provisionally accepted if any Algorithm in the accept list
104  // has been executed and has indicated that its filter is passed. This
105  // provisional acceptance can be overridden by the other lists.
106  // c. The event is rejected unless all Algorithms in the required list have
107  // been executed and have indicated that their filter passed.
108  // d. The event is rejected if any Algorithm in the veto list has been
109  // executed and has indicated that its filter has passed.
110  m_acceptNames.useUpdateHandler();
111  m_requireNames.useUpdateHandler();
112  m_vetoNames.useUpdateHandler();
113  return StatusCode::SUCCESS;
114 }
Gaudi::Property< std::vector< std::string > > m_acceptNames
Definition: OutputStream.h:60
constexpr static const auto FAILURE
Definition: StatusCode.h:88
void clearItems(Items &itms)
Clear item list.
virtual bool hasInput() const
Tell if the instance has been configured with input items or not.
Gaudi::Property< std::vector< std::string > > m_vetoNames
Definition: OutputStream.h:72
int m_events
Number of events written to this output stream.
Definition: OutputStream.h:108
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
virtual StatusCode addPreLoadItem(const DataStoreItem &item)=0
Add an item to the preload list.
bool isSuccess() const
Definition: StatusCode.h:287
Gaudi::Property< std::string > m_output
Definition: OutputStream.h:54
Gaudi::Property< std::string > m_outputName
Definition: OutputStream.h:55
Gaudi::Property< ItemNames > m_optItemNames
Definition: OutputStream.h:42
SmartIF< IDataProviderSvc > m_pDataProvider
Keep reference to the data provider service.
Definition: OutputStream.h:92
Gaudi::Property< bool > m_doPreLoad
Definition: OutputStream.h:50
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
virtual StatusCode connectConversionSvc()
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
AlgDependentItems m_algDependentItems
Items to be saved for specific algorithms.
Definition: OutputStream.h:104
Gaudi::Property< std::vector< std::string > > m_requireNames
Definition: OutputStream.h:66
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
Items m_itemList
Vector of items to be saved to this stream.
Definition: OutputStream.h:100
void addItem(Items &itms, const std::string &descriptor)
Add item to output streamer list.
Gaudi::Property< AlgDependentItemNames > m_algDependentItemList
Definition: OutputStream.h:44
SmartIF< IDataManagerSvc > m_pDataManager
Keep reference to the data manager service.
Definition: OutputStream.h:94
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
Definition: OutputStream.h:87
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Algorithm.cpp:816
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
Gaudi::Property< std::string > m_storeName
Definition: OutputStream.h:56
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:165
Base class for all Incidents (computing events).
Definition: Incident.h:17
Gaudi::Property< bool > m_doPreLoadOpt
Definition: OutputStream.h:52
#define ON_DEBUG
Algorithm * decodeAlgorithm(const std::string &theName)
Decode a single algorithm name.
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
Gaudi::Property< ItemNames > m_itemNames
Definition: OutputStream.h:41
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
bool m_fireIncidents
should I fire incidents for writing opening/closing etc? in the baseclass, always fire the incidents ...
Definition: OutputStream.h:84
Items m_optItemList
Vector of optional items to be saved to this stream.
Definition: OutputStream.h:102
bool OutputStream::isEventAccepted ( ) const
protected

Test whether this event should be output.

Definition at line 470 of file OutputStream.cpp.

471 {
472  auto passed = []( const Algorithm* alg ) { return alg->isExecuted() && alg->filterPassed(); };
473 
474  // Loop over all Algorithms in the accept list to see
475  // whether any have been executed and have their filter
476  // passed flag set. Any match causes the event to be
477  // provisionally accepted.
478  bool result = m_acceptAlgs.empty() || std::any_of( std::begin( m_acceptAlgs ), std::end( m_acceptAlgs ), passed );
479 
480  // Loop over all Algorithms in the required list to see
481  // whether all have been executed and have their filter
482  // passed flag set. Any mismatch causes the event to be
483  // rejected.
484  if ( result && !m_requireAlgs.empty() ) {
485  result = std::all_of( std::begin( m_requireAlgs ), std::end( m_requireAlgs ), passed );
486  }
487 
488  // Loop over all Algorithms in the veto list to see
489  // whether any have been executed and have their filter
490  // passed flag set. Any match causes the event to be
491  // rejected.
492  if ( result && !m_vetoAlgs.empty() ) {
493  result = std::none_of( std::begin( m_vetoAlgs ), std::end( m_vetoAlgs ), passed );
494  }
495  return result;
496 }
T empty(T...args)
T end(T...args)
std::vector< Algorithm * > m_requireAlgs
Vector of Algorithms that this stream requires.
Definition: OutputStream.h:113
std::vector< Algorithm * > m_acceptAlgs
Vector of Algorithms that this stream accepts.
Definition: OutputStream.h:111
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
T begin(T...args)
T any_of(T...args)
std::vector< Algorithm * > m_vetoAlgs
Vector of Algorithms that this stream is vetoed by.
Definition: OutputStream.h:115
IDataSelector* OutputStream::selectedObjects ( )
inlineprivate

Return the list of selected objects.

Definition at line 154 of file OutputStream.h.

154 { return &m_objects; }
IDataSelector m_objects
Collection of objects being selected.
Definition: OutputStream.h:106
StatusCode OutputStream::writeObjects ( )
protectedvirtual

Select the different objects and write them to file.

Reimplemented in TagCollectionStream, and SequentialOutputStream.

Definition at line 151 of file OutputStream.cpp.

152 {
153  // Connect the output file to the service
154  StatusCode status = collectObjects();
155  if ( status.isSuccess() ) {
157  if ( sel->begin() != sel->end() ) {
159  if ( status.isSuccess() ) {
160  // Now pass the collection to the persistency service
161  IOpaqueAddress* pAddress = nullptr;
162  for ( auto& j : *sel ) {
163  try {
164  const StatusCode iret = m_pConversionSvc->createRep( j, pAddress );
165  if ( !iret.isSuccess() ) {
166  status = iret;
167  continue;
168  }
169  IRegistry* pReg = j->registry();
170  pReg->setAddress( pAddress );
171  } catch ( const std::exception& excpt ) {
172  const std::string loc = ( j->registry() ? j->registry()->identifier() : "UnRegistered" );
173  fatal() << "std::exception during createRep for '" << loc << "' " << System::typeinfoName( typeid( *j ) )
174  << endmsg;
175  fatal() << excpt.what() << endmsg;
176  throw;
177  }
178  }
179  for ( auto& j : *sel ) {
180  try {
181  IRegistry* pReg = j->registry();
182  const StatusCode iret = m_pConversionSvc->fillRepRefs( pReg->address(), j );
183  if ( !iret.isSuccess() ) status = iret;
184  } catch ( const std::exception& excpt ) {
185  const std::string loc = ( j->registry() ? j->registry()->identifier() : "UnRegistered" );
186  fatal() << "std::exception during fillRepRefs for '" << loc << "'" << System::typeinfoName( typeid( *j ) )
187  << endmsg;
188  fatal() << excpt.what() << endmsg;
189  throw;
190  }
191  }
192  // Commit the data if there was no error; otherwise possibly discard
193  if ( status.isSuccess() ) {
194  status = m_pConversionSvc->commitOutput( m_outputName, true );
195  } else {
197  }
198  }
199  }
200  }
201  return status;
202 }
std::string m_outputType
Output type: NEW(NEW,CREATE,WRITE,RECREATE), UPDATE)
Definition: OutputStream.h:90
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:332
bool isSuccess() const
Definition: StatusCode.h:287
Gaudi::Property< std::string > m_outputName
Definition: OutputStream.h:55
sel
Definition: IOTest.py:95
T end(T...args)
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)=0
Convert the transient object to the requested representation.
IDataSelector * selectedObjects()
Return the list of selected objects.
Definition: OutputStream.h:154
STL class.
SmartIF< IConversionSvc > m_pConversionSvc
Keep reference to the data conversion service.
Definition: OutputStream.h:96
virtual StatusCode connectOutput(const std::string &outputFile)=0
Connect the output file to the service.
virtual StatusCode commitOutput(const std::string &outputFile, bool do_commit)=0
Commit pending output.
T what(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
STL class.
T begin(T...args)
virtual void setAddress(IOpaqueAddress *pAddress)=0
Set/Update Opaque storage address.
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:165
Opaque address interface definition.
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
virtual StatusCode collectObjects()
Collect all objects to be written to the output stream.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the converted object.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

Member Data Documentation

std::vector<Algorithm*> OutputStream::m_acceptAlgs
protected

Vector of Algorithms that this stream accepts.

Definition at line 111 of file OutputStream.h.

Gaudi::Property<std::vector<std::string> > OutputStream::m_acceptNames
protected
Initial value:
{
this,
"AcceptAlgs",
{},
[this]( auto& ) { this->decodeAlgorithms( this->m_acceptNames, this->m_acceptAlgs ); },
"names of Algorithms that this stream accepts"}

Definition at line 60 of file OutputStream.h.

Gaudi::Property<AlgDependentItemNames> OutputStream::m_algDependentItemList
protected
Initial value:
{
this,
"AlgDependentItemList",
{},
"mapping between algorithm names, and a list of items for which, if the "
"algorithm in question accepted the event, they should be also stored"}

Definition at line 44 of file OutputStream.h.

AlgDependentItems OutputStream::m_algDependentItems
protected

Items to be saved for specific algorithms.

Definition at line 104 of file OutputStream.h.

DataStoreItem* OutputStream::m_currentItem
protected

Keep track of the current item.

Definition at line 98 of file OutputStream.h.

Gaudi::Property<bool> OutputStream::m_doPreLoad
protected
Initial value:
{this, "Preload", true,
"flag indicating whether data pre-loading should be performed"}

Definition at line 50 of file OutputStream.h.

Gaudi::Property<bool> OutputStream::m_doPreLoadOpt
protected
Initial value:
{this, "PreloadOptItems", false,
"flag indicating whether optional items should be preloaded"}

Definition at line 52 of file OutputStream.h.

int OutputStream::m_events
protected

Number of events written to this output stream.

Definition at line 108 of file OutputStream.h.

bool OutputStream::m_fireIncidents = true
protected

should I fire incidents for writing opening/closing etc? in the baseclass, always fire the incidents by default in e.g.

RecordStream this will be set to false, and configurable

Definition at line 84 of file OutputStream.h.

SmartIF<IIncidentSvc> OutputStream::m_incidentSvc
protected

Reference to the incident service.

Definition at line 87 of file OutputStream.h.

Items OutputStream::m_itemList
protected

Vector of items to be saved to this stream.

Definition at line 100 of file OutputStream.h.

Gaudi::Property<ItemNames> OutputStream::m_itemNames {this, "ItemList", {}, "vector of item names to be saved to this stream"}
protected

Definition at line 41 of file OutputStream.h.

IDataSelector OutputStream::m_objects
protected

Collection of objects being selected.

Definition at line 106 of file OutputStream.h.

Items OutputStream::m_optItemList
protected

Vector of optional items to be saved to this stream.

Definition at line 102 of file OutputStream.h.

Gaudi::Property<ItemNames> OutputStream::m_optItemNames
protected
Initial value:
{
this, "OptItemList", {}, "vector of optional item names to be saved to this stream"}

Definition at line 42 of file OutputStream.h.

Gaudi::Property<std::string> OutputStream::m_output {this, "Output", {}, "name of the output file specification"}
protected

Definition at line 54 of file OutputStream.h.

Gaudi::Property<std::string> OutputStream::m_outputName {this, "OutputFile", {}, "name of the output file"}
protected

Definition at line 55 of file OutputStream.h.

std::string OutputStream::m_outputType = "UPDATE"
protected

Output type: NEW(NEW,CREATE,WRITE,RECREATE), UPDATE)

Definition at line 90 of file OutputStream.h.

SmartIF<IConversionSvc> OutputStream::m_pConversionSvc
protected

Keep reference to the data conversion service.

Definition at line 96 of file OutputStream.h.

SmartIF<IDataManagerSvc> OutputStream::m_pDataManager
protected

Keep reference to the data manager service.

Definition at line 94 of file OutputStream.h.

SmartIF<IDataProviderSvc> OutputStream::m_pDataProvider
protected

Keep reference to the data provider service.

Definition at line 92 of file OutputStream.h.

Gaudi::Property<std::string> OutputStream::m_persName
protected
Initial value:
{this, "EvtConversionSvc", "EventPersistencySvc",
"name of the persistency service capable to write data from the store"}

Definition at line 58 of file OutputStream.h.

std::vector<Algorithm*> OutputStream::m_requireAlgs
protected

Vector of Algorithms that this stream requires.

Definition at line 113 of file OutputStream.h.

Gaudi::Property<std::vector<std::string> > OutputStream::m_requireNames
protected
Initial value:
{
this,
"RequireAlgs",
{},
[this]( auto& ) { this->decodeAlgorithms( this->m_requireNames, this->m_requireAlgs ); },
"names of Algorithms that this stream requires"}

Definition at line 66 of file OutputStream.h.

Gaudi::Property<std::string> OutputStream::m_storeName
protected
Initial value:
{this, "EvtDataSvc", "EventDataSvc",
"name of the service managing the data store"}

Definition at line 56 of file OutputStream.h.

Gaudi::Property<bool> OutputStream::m_verifyItems
protected
Initial value:
{this, "VerifyItems", true,
"flag to indicate that item consistency should be checked"}

Definition at line 78 of file OutputStream.h.

std::vector<Algorithm*> OutputStream::m_vetoAlgs
protected

Vector of Algorithms that this stream is vetoed by.

Definition at line 115 of file OutputStream.h.

Gaudi::Property<std::vector<std::string> > OutputStream::m_vetoNames
protected
Initial value:
{
this,
"VetoAlgs",
{},
[this]( auto& ) { this->decodeAlgorithms( this->m_vetoNames, this->m_vetoAlgs ); },
"names of Algorithms that this stream is vetoed by"}

Definition at line 72 of file OutputStream.h.


The documentation for this class was generated from the following files: