The Gaudi Framework  v33r0 (d5ea422b)
ReplayOutputStream Class Reference

#include <component/ReplayOutputStream.h>

Inheritance diagram for ReplayOutputStream:
Collaboration diagram for ReplayOutputStream:

Classes

class  OutStreamAdder
 Helper class to fill the internal map of OutputStreams. More...
 

Public Types

typedef GaudiUtils::HashMap< std::string, SmartIF< IAlgorithm > > OutStreamsMapType
 Class used to hold the OutputStream instances. More...
 

Public Member Functions

StatusCode initialize () override
 Algorithm initialization. More...
 
StatusCode start () override
 Algorithm initialization. More...
 
StatusCode execute () override
 Algorithm execution. More...
 
StatusCode stop () override
 Algorithm finalization. More...
 
StatusCode finalize () override
 Algorithm finalization. More...
 
 GaudiAlgorithm (const std::string &name, ISvcLocator *pSvcLocator)
 Inherited constructor. More...
 
 GaudiAlgorithm (const GaudiAlgorithm &)=delete
 Inherited constructor. More...
 
- Public Member Functions inherited from GaudiAlgorithm
StatusCode initialize () override
 standard initialization method More...
 
StatusCode execute () override
 standard execution method More...
 
StatusCode finalize () override
 standard finalization method More...
 
StatusCode sysExecute (const EventContext &ctx) override
 the generic actions for the execution. More...
 
void put (IDataProviderSvc *svc, DataObject *object, const std::string &address, const bool useRootInTES=true) const
 Register a data object or container into Gaudi Event Transient Store. More...
 
void put (IDataProviderSvc *svc, std::unique_ptr< DataObject > object, const std::string &address, const bool useRootInTES=true) const
 
const DataObjectput (DataObject *object, const std::string &address, const bool useRootInTES=true) const
 Register a data object or container into Gaudi Event Transient Store. More...
 
const DataObjectput (std::unique_ptr< DataObject > object, const std::string &address, const bool useRootInTES=true) const
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type get (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Templated access to the data in Gaudi Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type getIfExists (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Templated access to the data in Gaudi Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type get (const std::string &location, const bool useRootInTES=true) const
 Templated access to the data from Gaudi Event Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type getIfExists (const std::string &location, const bool useRootInTES=true) const
 Templated access to the data in Gaudi Transient Store. More...
 
template<class TYPE >
TYPE * getDet (IDataProviderSvc *svc, const std::string &location) const
 Templated access to the detector data from the Gaudi Detector Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type getDetIfExists (IDataProviderSvc *svc, const std::string &location) const
 Templated access to the detector data from the Gaudi Detector Transient Store. More...
 
template<class TYPE >
TYPE * getDet (const std::string &location) const
 Templated access to the detector data from the Gaudi Detector Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type getDetIfExists (const std::string &location) const
 Templated access to the detector data from the Gaudi Detector Transient Store. More...
 
template<class TYPE >
bool exist (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Check the existence of a data object or container in the Gaudi Transient Event Store. More...
 
template<class TYPE >
bool exist (const std::string &location, const bool useRootInTES=true) const
 Check the existence of a data object or container in the Gaudi Transient Event Store. More...
 
template<class TYPE >
bool existDet (IDataProviderSvc *svc, const std::string &location) const
 Check the existence of detector objects in the Gaudi Transient Detector Store. More...
 
template<class TYPE >
bool existDet (const std::string &location) const
 Check the existence of detector objects in the Gaudi Transient Detector Store. More...
 
template<class TYPE , class TYPE2 >
Gaudi::Utils::GetData< TYPE >::return_type getOrCreate (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Get the existing data object from Gaudi Event Transient store. More...
 
template<class TYPE , class TYPE2 >
Gaudi::Utils::GetData< TYPE >::return_type getOrCreate (const std::string &location, const bool useRootInTES=true) const
 Get the existing data object from Gaudi Event Transient store. More...
 
 GaudiAlgorithm (const std::string &name, ISvcLocator *pSvcLocator)
 Standard constructor. More...
 
 GaudiAlgorithm (const GaudiAlgorithm &)=delete
 
GaudiAlgorithmoperator= (const GaudiAlgorithm &)=delete
 
SmartIF< INTupleSvc > & evtColSvc () const
 Access the standard event collection service. More...
 
- Public Member Functions inherited from GaudiCommon< Algorithm >
Gaudi::Utils::GetData< TYPE >::return_type get (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Templated access to the data in Gaudi Transient Store. More...
 
Gaudi::Utils::GetData< TYPE >::return_type getIfExists (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Quicker version of the get function which bypasses the check on the retrieved data. More...
 
bool exist (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Check the existence of a data object or container in the Gaudi Transient Event Store. More...
 
Gaudi::Utils::GetData< TYPE >::return_type getOrCreate (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Get the existing data object from Gaudi Event Transient store. More...
 
DataObjectput (IDataProviderSvc *svc, std::unique_ptr< DataObject > object, const std::string &location, const bool useRootInTES=true) const
 Register a data object or container into Gaudi Event Transient Store. More...
 
DataObjectput (IDataProviderSvc *svc, DataObject *object, const std::string &location, const bool useRootInTES=true) const
 
TOOL * tool (const std::string &type, const std::string &name, const IInterface *parent=0, bool create=true) const
 Useful method for the easy location of tools. More...
 
TOOL * tool (const std::string &type, const IInterface *parent=0, bool create=true) const
 A useful method for the easy location of tools. More...
 
SmartIF< SERVICE > svc (const std::string &name, const bool create=true) const
 A useful method for the easy location of services. More...
 
IUpdateManagerSvcupdMgrSvc () const
 Short-cut to locate the Update Manager Service. More...
 
WARN_UNUSED StatusCode Error (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
 Print the error message and return with the given StatusCode. More...
 
WARN_UNUSED StatusCode Warning (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
 Print the warning message and return with the given StatusCode. More...
 
WARN_UNUSED StatusCode Info (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const size_t mx=10) const
 Print the info message and return with the given StatusCode. More...
 
WARN_UNUSED StatusCode Print (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const
 Print the message and return with the given StatusCode. More...
 
void Assert (const bool ok, const std::string &message="", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Assertion - throw exception if the given condition is not fulfilled. More...
 
void Assert (const bool ok, const char *message, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Assertion - throw exception if the given condition is not fulfilled. More...
 
void Exception (const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and (re)-throw a given GaudiException. More...
 
void Exception (const std::string &msg, const std::exception &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and (re)-throw a given exception. More...
 
void Exception (const std::string &msg="no message", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and throw an exception with the given message. More...
 
StatEntitycounter (const std::string &tag) const
 accessor to certain counter by name More...
 
StatEntitycounter (const std::string &tag)
 
bool typePrint () const
 Insert the actual C++ type of the algorithm/tool in the messages ? More...
 
bool propsPrint () const
 Print properties at initialization ? More...
 
bool statPrint () const
 Print statistical counters at finalization ? More...
 
bool errorsPrint () const
 Print error counters at finalization ? More...
 
long printStat (const MSG::Level level=MSG::ALWAYS) const
 perform the actual printout of statistical counters More...
 
long printErrors (const MSG::Level level=MSG::ALWAYS) const
 perform the actual printout of error counters More...
 
long printProps (const MSG::Level level=MSG::ALWAYS) const
 perform the actual printout of properties More...
 
void registerCondition (const std::string &condition, StatusCode(CallerClass::*mf)()=nullptr)
 register the current instance to the UpdateManagerSvc as a consumer for a condition. More...
 
void registerCondition (const std::string &condition, CondType *&condPtrDest, StatusCode(CallerClass::*mf)()=NULL)
 register the current instance to the UpdateManagerSvc as a consumer for a condition. More...
 
void registerCondition (char *condition, StatusCode(CallerClass::*mf)()=NULL)
 just to avoid conflicts with the version using a pointer to a template class. More...
 
void registerCondition (TargetClass *condition, StatusCode(CallerClass::*mf)()=NULL)
 register the current instance to the UpdateManagerSvc as a consumer for a condition. More...
 
StatusCode runUpdate ()
 asks the UpdateManagerSvc to perform an update of the instance (if needed) without waiting the next BeginEvent incident. More...
 
 GaudiCommon (const std::string &name, ISvcLocator *pSvcLocator)
 Algorithm constructor - the SFINAE constraint below ensures that this is constructor is only defined if PBASE derives from Algorithm. More...
 
 GaudiCommon (const std::string &type, const std::string &name, const IInterface *ancestor)
 Tool constructor - SFINAE-ed to insure this constructor is only defined if PBASE derives from AlgTool. More...
 
StatusCode initialize () override
 standard initialization method More...
 
StatusCode finalize () override
 standard finalization method More...
 
StatusCode release (const IInterface *interface) const
 Manual forced (and 'safe') release of the active tool or service. More...
 
const Servicesservices () const
 get the list of aquired services More...
 
const std::stringcontext () const
 Returns the "context" string. Used to identify different processing states. More...
 
- Public Member Functions inherited from FixTESPath< BASE >
template<typename U = BASE, typename = std::enable_if_t<std::is_base_of_v<Gaudi::Algorithm, BASE>, U>>
 FixTESPath (const std::string &name, ISvcLocator *pSvcLocator)
 Algorithm constructor - the SFINAE constraint below ensures that this is constructor is only defined if BASE derives from Algorithm. More...
 
template<typename U = BASE, typename = std::enable_if_t<std::is_base_of_v<AlgTool, BASE>, U>>
 FixTESPath (const std::string &type, const std::string &name, const IInterface *ancestor)
 Tool constructor - SFINAE-ed to insure this constructor is only defined if BASE derives from AlgTool. More...
 
StatusCode initialize () override
 
const std::stringrootInTES () const
 Returns the "rootInTES" string. More...
 
std::string fullTESLocation (std::string_view location, bool useRootInTES) const
 Returns the full correct event location given the rootInTes settings. More...
 

Private Member Functions

void i_addOutputStream (const Gaudi::Utils::TypeNameString &outStream)
 Add a new algorithm to the list of OutputStreams. More...
 
template<Gaudi::StateMachine::Transition TR>
StatusCode i_outStreamTransition ()
 Helper function to call the transition on the contained OutputStreams. More...
 

Private Attributes

Gaudi::Property< std::vector< std::string > > m_outputStreamNames
 
OutStreamsMapType m_outputStreams
 Internal storage for the OutputStreams to call. More...
 
SmartIF< IAlgManagerm_algMgr
 
SmartIF< IDataManagerSvcm_evtMgr
 

Additional Inherited Members

- Protected Types inherited from GaudiCommon< Algorithm >
using base_class = FixTESPath< Algorithm >
 
typedef std::map< std::string, StatEntityStatisticsOwn
 the actual type of general counters More...
 
typedef std::map< std::string, std::reference_wrapper< Gaudi::Accumulators::PrintableCounter > > Statistics
 
typedef std::map< std::string, unsigned int > Counter
 the actual type error/warning counter More...
 
typedef std::vector< IAlgTool * > AlgTools
 storage for active tools More...
 
typedef std::vector< SmartIF< IService > > Services
 storage for active services More...
 
- Protected Member Functions inherited from GaudiCommon< Algorithm >
StatusCode releaseTool (const IAlgTool *tool) const
 manual forced (and 'safe') release of the tool More...
 
StatusCode releaseSvc (const IInterface *svc) const
 manual forced (and 'safe') release of the service More...
 
- Protected Attributes inherited from GaudiCommon< Algorithm >
SmartIF< ICounterSummarySvcm_counterSummarySvc
 a pointer to the CounterSummarySvc More...
 
- Static Protected Attributes inherited from GaudiCommon< Algorithm >
static const bool IgnoreRootInTES
 Simple definition to be used with the new useRootInTES argument get<TYPE> and put methods. More...
 
static const bool UseRootInTES
 Simple definition to be used with the new useRootInTES argument get<TYPE> and put methods. More...
 

Detailed Description

Author
Marco Clemencic
Date
30/08/2013

Definition at line 29 of file ReplayOutputStream.h.

Member Typedef Documentation

◆ OutStreamsMapType

Class used to hold the OutputStream instances.

Definition at line 41 of file ReplayOutputStream.h.

Member Function Documentation

◆ execute()

StatusCode ReplayOutputStream::execute ( )
override

Algorithm execution.

Definition at line 122 of file ReplayOutputStream.cpp.

122  {
123  if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Execute" << endmsg;
124 
126  m_evtMgr->traverseSubTree( RecordOutputStream::locationRoot(), [&names]( IRegistry* pReg, int lvl ) {
127  if ( lvl > 0 ) names.push_back( pReg->name() );
128  return true;
129  } );
130 
131  std::for_each( names.begin(), names.end(), [this]( const std::string& name ) {
133  if ( alg ) {
134  const auto& ctx = Gaudi::Hive::currentContext();
135  if ( alg->execState( ctx ).state() != AlgExecState::State::Done ) {
136  alg->sysExecute( ctx );
137  } else {
138  this->warning() << name << " already executed for the current event" << endmsg;
139  }
140  } else {
141  this->warning() << "invalid OuputStream " << name << endmsg;
142  }
143  } );
144 
145  return StatusCode::SUCCESS;
146 }
OutStreamsMapType m_outputStreams
Internal storage for the OutputStreams to call.
virtual StatusCode traverseSubTree(std::string_view sub_tree_path, IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects below the sub tree identified by its full path name.
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
virtual const name_type & name() const =0
Name of the directory (or key)
T end(T... args)
STL class.
T push_back(T... args)
GAUDI_API const EventContext & currentContext()
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:32
T begin(T... args)
SmartIF< IDataManagerSvc > m_evtMgr
T for_each(T... args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
static const std::string locationRoot()
Return the path in the Transient Store used to record the triggered instances.

◆ finalize()

StatusCode ReplayOutputStream::finalize ( )
override

Algorithm finalization.

Definition at line 151 of file ReplayOutputStream.cpp.

151  {
152  if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Finalize" << endmsg;
153 
154  StatusCode sc = i_outStreamTransition<Gaudi::StateMachine::FINALIZE>();
155 
156  // release interfaces
158  m_algMgr.reset();
159  m_evtMgr.reset();
160 
161  StatusCode fsc = GaudiAlgorithm::finalize(); // must be called after all other actions
162  if ( sc.isSuccess() ) sc = fsc;
163  return sc;
164 }
OutStreamsMapType m_outputStreams
Internal storage for the OutputStreams to call.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
StatusCode finalize() override
standard finalization method
bool isSuccess() const
Definition: StatusCode.h:361
void clear()
Definition: Map.h:195
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:96
SmartIF< IDataManagerSvc > m_evtMgr
SmartIF< IAlgManager > m_algMgr
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ GaudiAlgorithm() [1/2]

GaudiAlgorithm::GaudiAlgorithm
delete

Inherited constructor.

◆ GaudiAlgorithm() [2/2]

GaudiAlgorithm::GaudiAlgorithm

Inherited constructor.

Definition at line 45 of file GaudiAlgorithm.cpp.

46  : GaudiCommon<Algorithm>( name, pSvcLocator ) {
47  setProperty( "RegisterForContextService", true ).ignore();
48 }
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
Definition: Bootstrap.cpp:243

◆ i_addOutputStream()

void ReplayOutputStream::i_addOutputStream ( const Gaudi::Utils::TypeNameString outStream)
private

Add a new algorithm to the list of OutputStreams.

Definition at line 176 of file ReplayOutputStream.cpp.

176  {
177  // we prepend '/' to the name of the algorithm to simplify the handling in
178  // OutputStreamsCollector
179  const std::string algId = "/" + outStream.name();
180  if ( m_outputStreams.find( algId ) == m_outputStreams.end() ) {
181  m_outputStreams[algId] = m_algMgr->algorithm( outStream );
182  if ( !m_outputStreams[algId] ) {
183  throw GaudiException( name(), "Could not get algorithm " + outStream.name(), StatusCode::FAILURE );
184  }
185  } else {
186  warning() << "OutputStream instance " << outStream.name() << " already added, ignoring " << outStream << endmsg;
187  }
188 }
virtual SmartIF< IAlgorithm > & algorithm(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
Define general base for Gaudi exception.
OutStreamsMapType m_outputStreams
Internal storage for the OutputStreams to call.
STL class.
iterator end()
Definition: Map.h:140
const std::string & name() const
iterator find(const key_type &key)
Definition: Map.h:157
constexpr static const auto FAILURE
Definition: StatusCode.h:97
SmartIF< IAlgManager > m_algMgr
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ i_outStreamTransition()

template<Gaudi::StateMachine::Transition TR>
StatusCode ReplayOutputStream::i_outStreamTransition ( )
private

Helper function to call the transition on the contained OutputStreams.

Returns StatusCode::FAILURE if any of the OutputStreams returned a failure.

Definition at line 84 of file ReplayOutputStream.cpp.

84  {
85  OutStreamTransition<TR> trans( msg() );
87  return trans.result();
88 }
OutStreamsMapType m_outputStreams
Internal storage for the OutputStreams to call.
iterator end()
Definition: Map.h:140
iterator begin()
Definition: Map.h:139
T for_each(T... args)

◆ initialize()

StatusCode ReplayOutputStream::initialize ( )
override

Algorithm initialization.

Definition at line 93 of file ReplayOutputStream.cpp.

93  {
94  StatusCode sc = GaudiAlgorithm::initialize(); // must be executed first
95  if ( sc.isFailure() ) return sc; // error printed already by GaudiAlgorithm
96 
97  if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Initialize" << endmsg;
98 
99  m_algMgr = service( "ApplicationMgr" );
100  if ( UNLIKELY( !m_algMgr ) ) return Error( "cannot retrieve IAlgManager" );
101 
102  m_evtMgr = evtSvc();
103  if ( UNLIKELY( !m_evtMgr ) ) return Error( "cannot retrieve IDataManagerSvc " );
104 
105  std::for_each( m_outputStreamNames.begin(), m_outputStreamNames.end(), OutStreamAdder( this ) );
106 
107  return i_outStreamTransition<Gaudi::StateMachine::INITIALIZE>();
108 }
#define UNLIKELY(x)
Definition: Kernel.h:106
StatusCode initialize() override
standard initialization method
WARN_UNUSED StatusCode Error(const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
Print the error message and return with the given StatusCode.
Gaudi::Property< std::vector< std::string > > m_outputStreamNames
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
bool isFailure() const
Definition: StatusCode.h:141
SmartIF< IDataManagerSvc > m_evtMgr
T for_each(T... args)
SmartIF< IAlgManager > m_algMgr
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ start()

StatusCode ReplayOutputStream::start ( )
override

Algorithm initialization.

Definition at line 110 of file ReplayOutputStream.cpp.

110  {
111  StatusCode sc = GaudiAlgorithm::start(); // must be executed first
112  if ( sc.isFailure() ) return sc; // error printed already by GaudiAlgorithm
113 
114  if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Start" << endmsg;
115 
116  return i_outStreamTransition<Gaudi::StateMachine::START>();
117 }
def start
Definition: IOTest.py:108
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
bool isFailure() const
Definition: StatusCode.h:141
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ stop()

StatusCode ReplayOutputStream::stop ( )
override

Algorithm finalization.

Definition at line 166 of file ReplayOutputStream.cpp.

166  {
167  if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Stop" << endmsg;
168 
169  StatusCode sc = i_outStreamTransition<Gaudi::StateMachine::STOP>();
170 
171  StatusCode ssc = GaudiAlgorithm::stop(); // must be called after all other actions
172  if ( sc.isSuccess() ) sc = ssc;
173  return sc;
174 }
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
bool isSuccess() const
Definition: StatusCode.h:361
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

Member Data Documentation

◆ m_algMgr

SmartIF<IAlgManager> ReplayOutputStream::m_algMgr
private

Definition at line 68 of file ReplayOutputStream.h.

◆ m_evtMgr

SmartIF<IDataManagerSvc> ReplayOutputStream::m_evtMgr
private

Definition at line 69 of file ReplayOutputStream.h.

◆ m_outputStreamNames

Gaudi::Property<std::vector<std::string> > ReplayOutputStream::m_outputStreamNames
private
Initial value:
{
this, "OutputStreams", {}, "OutputStream instances that can be called."}

Definition at line 62 of file ReplayOutputStream.h.

◆ m_outputStreams

OutStreamsMapType ReplayOutputStream::m_outputStreams
private

Internal storage for the OutputStreams to call.

Definition at line 66 of file ReplayOutputStream.h.


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