Gaudi Framework, version v25r0

Home   Generated: Mon Feb 17 2014
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
OutputStream Class Reference

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

#include <OutputStream.h>

Inheritance diagram for OutputStream:
Inheritance graph
[legend]
Collaboration diagram for OutputStream:
Collaboration graph
[legend]

Public Types

typedef std::vector
< DataStoreItem * > 
Items
 
typedef std::vector< std::stringItemNames
 
- Public Types inherited from Algorithm
typedef
Gaudi::PluginService::Factory2
< IAlgorithm *, const
std::string &, ISvcLocator * > 
Factory
 
- Public Types inherited from implements3< IAlgorithm, IProperty, IStateful >
typedef implements3 base_class
 Typedef to this class.
 
typedef extend_interfaces3
< IAlgorithm, IProperty,
IStateful
extend_interfaces_base
 Typedef to the base of this class.
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces.
 
- Public Types inherited from extend_interfaces3< I1, I2, I3 >
typedef mpl::fold< typename
I1::iid::iids::type, typename
mpl::fold< typename
I2::iid::iids::type, typename
I3::iid::iids::type,
mpl::insert< mpl::_1, mpl::_2 >
>::type, mpl::insert< mpl::_1,
mpl::_2 > >::type 
ext_iids
 MPL set of interfaces extended by this one.
 

Public Member Functions

 OutputStream (const std::string &name, ISvcLocator *pSvcLocator)
 Standard algorithm Constructor.
 
virtual ~OutputStream ()
 Standard Destructor.
 
virtual StatusCode initialize ()
 Initialize OutputStream.
 
virtual StatusCode finalize ()
 Terminate OutputStream.
 
virtual StatusCode execute ()
 Working entry point.
 
virtual StatusCode connectConversionSvc ()
 
virtual bool collect (IRegistry *dir, int level)
 Store agent's classback.
 
virtual StatusCode collectObjects ()
 Collect all objects to be written to the output stream.
 
void clearItems (Items &itms)
 Clear item list.
 
void addItem (Items &itms, const std::string &descriptor)
 Add item to output streamer list.
 
void clearSelection ()
 Clear list of selected objects.
 
IDataSelectorselectedObjects ()
 Return the list of selected objects.
 
- Public Member Functions inherited from Algorithm
 Algorithm (const std::string &name, ISvcLocator *svcloc, const std::string &version=PACKAGE_VERSION)
 Constructor.
 
virtual ~Algorithm ()
 Destructor.
 
virtual StatusCode sysStart ()
 Reinitialization method invoked by the framework.
 
virtual StatusCode sysInitialize ()
 Initialization method invoked by the framework.
 
virtual StatusCode sysReinitialize ()
 Reinitialization method invoked by the framework.
 
virtual StatusCode sysRestart ()
 Restart method invoked by the framework.
 
virtual StatusCode sysExecute ()
 The actions to be performed by the algorithm on an event.
 
virtual StatusCode sysStop ()
 System stop.
 
virtual StatusCode sysFinalize ()
 System finalization.
 
virtual StatusCode sysBeginRun ()
 beginRun method invoked by the framework.
 
virtual StatusCode sysEndRun ()
 endRun method invoked by the framework.
 
virtual const std::stringname () const
 The identifying name of the algorithm object.
 
virtual const std::stringversion () const
 
virtual StatusCode configure ()
 Dummy implementation of IStateful::configure() method.
 
virtual StatusCode terminate ()
 Dummy implementation of IStateful::terminate() method.
 
virtual StatusCode start ()
 the default (empty) implementation of IStateful::start() method
 
virtual StatusCode stop ()
 the default (empty) implementation of IStateful::stop() method
 
virtual StatusCode reinitialize ()
 the default (empty) implementation of IStateful::reinitialize() method
 
virtual StatusCode restart ()
 the default (empty) implementation of IStateful::restart() method
 
virtual bool isExecuted () const
 Has this algorithm been executed since the last reset?
 
virtual void setExecuted (bool state)
 Set the executed flag to the specified state.
 
virtual void resetExecuted ()
 Reset the executed state of the Algorithm for the duration of the current event.
 
virtual StatusCode beginRun ()
 Algorithm begin run.
 
virtual StatusCode endRun ()
 Algorithm end run. This method is called at the end of the event loop.
 
virtual Gaudi::StateMachine::State FSMState () const
 returns the current state of the algorithm
 
virtual Gaudi::StateMachine::State targetFSMState () const
 returns the state the algorithm will be in after the ongoing transition
 
virtual bool isEnabled () const
 Is this algorithm enabled or disabled?
 
virtual bool filterPassed () const
 Did this algorithm pass or fail its filter criterion for the last event?
 
virtual void setFilterPassed (bool state)
 Set the filter passed flag to the specified state.
 
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.
 
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.
 
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")
 
void setOutputLevel (int level)
 Set the output level for current algorithm.
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
 
SmartIF< IChronoStatSvc > & chronoSvc () const
 The standard Chrono & Stat service, Return a pointer to the service if present.
 
SmartIF< IChronoStatSvc > & chronoStatService () const
 Obsoleted name, kept due to the backwards compatibility.
 
SmartIF< IDataProviderSvc > & detSvc () const
 The standard detector data service.
 
SmartIF< IDataProviderSvc > & detDataService () const
 Obsoleted name, kept due to the backwards compatibility.
 
SmartIF< IConversionSvc > & detCnvSvc () const
 The standard detector data persistency conversion service.
 
SmartIF< IConversionSvc > & detDataCnvService () const
 Obsoleted name, kept due to the backwards compatibility.
 
SmartIF< IDataProviderSvc > & eventSvc () const
 The standard event data service.
 
SmartIF< IDataProviderSvc > & evtSvc () const
 shortcut for method eventSvc
 
SmartIF< IDataProviderSvc > & eventDataService () const
 Obsoleted name, kept due to the backwards compatibility.
 
SmartIF< IConversionSvc > & eventCnvSvc () const
 The standard event data persistency conversion service.
 
SmartIF< IConversionSvc > & eventDataCnvService () const
 Obsoleted name, kept due to the backwards compatibility.
 
SmartIF< IHistogramSvc > & histoSvc () const
 The standard histogram service.
 
SmartIF< IHistogramSvc > & histogramDataService () const
 Obsoleted name, kept due to the backwards compatibility.
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
SmartIF< IMessageSvc > & messageService () const
 Obsoleted name, kept due to the backwards compatibility.
 
SmartIF< INTupleSvc > & ntupleSvc () const
 The standard N tuple service.
 
SmartIF< INTupleSvc > & ntupleService () const
 Obsoleted name, kept due to the backwards compatibility.
 
SmartIF< IRndmGenSvc > & randSvc () const
 AIDA-based NTuple service Returns a pointer to the AIDATuple service if present.
 
SmartIF< IToolSvc > & toolSvc () const
 The standard ToolSvc service, Return a pointer to the service if present.
 
SmartIF< IExceptionSvc > & exceptionSvc () const
 Get the exception Service.
 
SmartIF< IAlgContextSvc > & contextSvc () const
 get Algorithm Context Service
 
SmartIF< ISvcLocator > & serviceLocator () const
 The standard service locator.
 
SmartIF< ISvcLocator > & svcLoc () const
 shortcut for method serviceLocator
 
bool registerContext () const
 register for Algorithm Context Service?
 
StatusCode createSubAlgorithm (const std::string &type, const std::string &name, Algorithm *&pSubAlg)
 Create a sub algorithm.
 
std::vector< Algorithm * > * subAlgorithms () const
 List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms.
 
virtual StatusCode setProperty (const Property &p)
 Implementation of IProperty::setProperty.
 
virtual StatusCode setProperty (const std::string &s)
 Implementation of IProperty::setProperty.
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 Implementation of IProperty::setProperty.
 
virtual StatusCode getProperty (Property *p) const
 Implementation of IProperty::getProperty.
 
virtual const PropertygetProperty (const std::string &name) const
 Implementation of IProperty::getProperty.
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 Implementation of IProperty::getProperty.
 
virtual const std::vector
< Property * > & 
getProperties () const
 Implementation of IProperty::getProperties.
 
StatusCode setProperties ()
 Set the algorithm's properties.
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property.
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties.
 
SmartIF< IMonitorSvc > & monitorSvc () const
 Access the monitor service.
 
template<class T >
void declareInfo (const std::string &name, const T &var, const std::string &desc) const
 Declare monitoring information.
 
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)
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 

Protected Member Functions

StatusCode decodeAcceptAlgs ()
 Decode list of Algorithms that this stream accepts.
 
void acceptAlgsHandler (Property &theProp)
 Handler for AcceptAlgs Property.
 
StatusCode decodeRequireAlgs ()
 Decode list of Algorithms that this stream requires.
 
void requireAlgsHandler (Property &theProp)
 Handler for RequireAlgs Property.
 
StatusCode decodeVetoAlgs ()
 Decode list of Algorithms that this stream is vetoed by.
 
void vetoAlgsHandler (Property &theProp)
 Handler for VetoAlgs Property.
 
StatusCode decodeAlgorithms (StringArrayProperty &theNames, std::vector< Algorithm * > *theAlgs)
 Decode specified list of Algorithms.
 
bool isEventAccepted () const
 Test whether this event should be output.
 
DataStoreItemfindItem (const std::string &path)
 Find single item identified by its path (exact match)
 
virtual StatusCode writeObjects ()
 Select the different objects and write them to file.
 
virtual bool hasInput () const
 Tell if the instance has been configured with input items or not.
 
- Protected Member Functions inherited from Algorithm
bool isInitialized () const
 Has the Algorithm already been initialized?
 
bool isFinalized () const
 Has the Algorithm already been finalized?
 
int outputLevel () const
 retrieve the Algorithm output level
 
IntegerPropertyoutputLevelProperty ()
 Accessor for the Message level property.
 
void initOutputLevel (Property &prop)
 callback for output level property
 

Protected Attributes

SmartIF< IIncidentSvcm_incidentSvc
 Reference to the incident service.
 
bool m_doPreLoad
 Flag indicating whether data pre-loading should be performed.
 
bool m_doPreLoadOpt
 Flag indicating whether optional items should be preloaded.
 
bool m_verifyItems
 Flag to indicate that item consistency should be checked.
 
std::string m_storeName
 Name of the service managing the data store.
 
std::string m_persName
 Name of the persistency service capable to write data from the store.
 
std::string m_output
 Name of the output file specification.
 
std::string m_outputName
 Name of the output file.
 
std::string m_outputType
 Output type: NEW(NEW,CREATE,WRITE,RECREATE), UPDATE)
 
OutputStreamAgentm_agent
 Keep reference of agent.
 
SmartIF< IDataProviderSvcm_pDataProvider
 Keep reference to the data provider service.
 
SmartIF< IDataManagerSvcm_pDataManager
 Keep reference to the data manager service.
 
SmartIF< IConversionSvcm_pConversionSvc
 Keep reference to the data conversion service.
 
DataStoreItemm_currentItem
 Keep track of the current item.
 
ItemNames m_itemNames
 Vector of item names.
 
Items m_itemList
 Vector of items to be saved to this stream.
 
ItemNames m_optItemNames
 Vector of item names.
 
Items m_optItemList
 Vector of optional items to be saved to this stream.
 
IDataSelector m_objects
 Collection of objects being selected.
 
int m_events
 Number of events written to this output stream.
 
StringArrayProperty m_acceptNames
 Vector of names of Algorithms that this stream accepts.
 
StringArrayProperty m_requireNames
 Vector of names of Algorithms that this stream requires.
 
StringArrayProperty m_vetoNames
 Vector of names of Algorithms that this stream is vetoed by.
 
std::vector< Algorithm * > * m_acceptAlgs
 Vector of Algorithms that this stream accepts.
 
std::vector< Algorithm * > * m_requireAlgs
 Vector of Algorithms that this stream requires.
 
std::vector< Algorithm * > * m_vetoAlgs
 Vector of Algorithms that this stream is vetoed by.
 
bool m_fireIncidents
 should I fire incidents for writing opening/closing etc?
 

Detailed Description

A small to stream Data I/O.

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

Definition at line 27 of file OutputStream.h.

Member Typedef Documentation

Definition at line 30 of file OutputStream.h.

Definition at line 29 of file OutputStream.h.

Constructor & Destructor Documentation

OutputStream::OutputStream ( const std::string name,
ISvcLocator pSvcLocator 
)

Standard algorithm Constructor.

in the baseclass, always fire the incidents by default in e.g. RecordStream this will be set to false, and configurable

in the baseclass, always fire the incidents by default in RecordStream this will be set to false, and configurable

Definition at line 27 of file OutputStream.cpp.

: Algorithm(name, pSvcLocator)
{
m_doPreLoad = true;
m_doPreLoadOpt = false;
m_verifyItems = true;
m_output = "";
m_outputType = "UPDATE";
m_storeName = "EventDataSvc";
m_persName = "EventPersistencySvc";
declareProperty("PreloadOptItems", m_doPreLoadOpt);
declareProperty("OutputFile", m_outputName);
declareProperty("EvtDataSvc", m_storeName);
declareProperty("EvtConversionSvc", m_persName);
declareProperty("VerifyItems", m_verifyItems);
// Associate action handlers with the AcceptAlgs, RequireAlgs & VetoAlgs properties
}
OutputStream::~OutputStream ( )
virtual

Standard Destructor.

Definition at line 67 of file OutputStream.cpp.

{
delete m_agent;
delete m_acceptAlgs;
delete m_requireAlgs;
delete m_vetoAlgs;
}

Member Function Documentation

void OutputStream::acceptAlgsHandler ( Property theProp)
protected

Handler for AcceptAlgs Property.

Definition at line 488 of file OutputStream.cpp.

{
if (sc.isFailure()) {
throw GaudiException("Failure in OutputStream::decodeAlgorithms",
"OutputStream::acceptAlgsHandler",sc);
}
}
void OutputStream::addItem ( Items itms,
const std::string descriptor 
)

Add item to output streamer list.

Definition at line 374 of file OutputStream.cpp.

{
int level = 0;
size_t sep = descriptor.rfind("#");
std::string obj_path (descriptor,0,sep);
std::string slevel (descriptor,sep+1,descriptor.length());
if ( slevel == "*" ) {
level = 9999999;
}
else {
level = atoi(slevel.c_str());
}
if ( m_verifyItems ) {
size_t idx = obj_path.find("/",1);
while(idx != std::string::npos) {
std::string sub_item = obj_path.substr(0,idx);
if ( 0 == findItem(sub_item) ) {
addItem(itms, sub_item+"#1");
}
idx = obj_path.find("/",idx+1);
}
}
DataStoreItem* item = new DataStoreItem(obj_path, level);
if(log.level() <= MSG::DEBUG )
log << MSG::DEBUG << "Adding OutputStream item " << item->path()
<< " with " << item->depth()
<< " level(s)." << endmsg;
itms.push_back( item );
}
void OutputStream::clearItems ( Items itms)

Clear item list.

Definition at line 354 of file OutputStream.cpp.

{
for ( Items::iterator i = itms.begin(); i != itms.end(); i++ ) {
delete (*i);
}
itms.erase(itms.begin(), itms.end());
}
void OutputStream::clearSelection ( )

Clear list of selected objects.

Definition at line 349 of file OutputStream.cpp.

bool OutputStream::collect ( IRegistry dir,
int  level 
)
virtual

Store agent's classback.

Definition at line 276 of file OutputStream.cpp.

{
if ( level < m_currentItem->depth() ) {
if ( dir->object() != 0 ) {
/*
std::cout << "Analysing ("
<< dir->name()
<< ") Object:"
<< ((dir->object()==0) ? "UNLOADED" : "LOADED")
<< std::endl;
*/
return true;
}
}
return false;
}
StatusCode OutputStream::collectObjects ( )
virtual

Collect all objects to be written to the output stream.

Reimplemented in InputCopyStream.

Definition at line 294 of file OutputStream.cpp.

{
// Traverse the tree and collect the requested objects
for ( i = m_itemList.begin(); i != m_itemList.end(); i++ ) {
DataObject* obj = 0;
m_currentItem = (*i);
StatusCode iret = m_pDataProvider->retrieveObject(m_currentItem->path(), obj);
if ( iret.isSuccess() ) {
iret = m_pDataManager->traverseSubTree(obj, m_agent);
if ( !iret.isSuccess() ) {
status = iret;
}
}
else {
log << MSG::ERROR << "Cannot write mandatory object(s) (Not found) "
status = iret;
}
}
// Traverse the tree and collect the requested objects (tolerate missing items here)
for ( i = m_optItemList.begin(); i != m_optItemList.end(); i++ ) {
DataObject* obj = 0;
m_currentItem = (*i);
StatusCode iret = m_pDataProvider->retrieveObject(m_currentItem->path(), obj);
if ( iret.isSuccess() ) {
iret = m_pDataManager->traverseSubTree(obj, m_agent);
}
if ( !iret.isSuccess() ) {
if(log.level() <= MSG::DEBUG )
log << MSG::DEBUG << "Ignore request to write non-mandatory object(s) "
}
}
if (status.isSuccess()){
// Remove duplicates from the list of objects, preserving the order in the list
std::vector<DataObject*> tmp; // temporary vector with the reduced list
if (!unique.count(*o)) {
// if the pointer is not in the set, add it to both the set and the temporary vector
unique.insert(*o);
tmp.push_back(*o);
}
}
m_objects.swap(tmp); // swap the data of the two vectors
}
return status;
}
StatusCode OutputStream::connectConversionSvc ( )
virtual

Definition at line 405 of file OutputStream.cpp.

{
// Get output file from input
std::string dbType, svc, shr;
Tokenizer tok(true);
tok.analyse(m_output, " ", "", "", "=", "'", "'");
for(Tokenizer::Items::iterator i = tok.items().begin(); i != tok.items().end(); ++i) {
const std::string& tag = (*i).tag();
const std::string& val = (*i).value();
switch( ::toupper(tag[0]) ) {
case 'D':
m_outputName = val;
break;
case 'T':
dbType = val;
break;
case 'S':
switch( ::toupper(tag[1]) ) {
case 'V': svc = val; break;
case 'H': shr = "YES"; break;
}
break;
case 'O': // OPT='<NEW<CREATE,WRITE,RECREATE>, UPDATE>'
switch( ::toupper(val[0]) ) {
case 'R':
if ( ::strncasecmp(val.c_str(),"RECREATE",3)==0 )
m_outputType = "RECREATE";
else if ( ::strncasecmp(val.c_str(),"READ",3)==0 )
m_outputType = "READ";
break;
case 'C':
case 'N':
case 'W':
m_outputType = "NEW";
break;
case 'U':
m_outputType = "UPDATE";
break;
default:
m_outputType = "???";
break;
}
break;
default:
break;
}
}
if ( !shr.empty() ) m_outputType += "|SHARED";
// Get access to the default Persistency service
// The default service is the same for input as for output.
// If this is not desired, then a specialized OutputStream must overwrite
// this value.
if ( dbType.length() > 0 || svc.length() > 0 ) {
std::string typ = dbType.length()>0 ? dbType : svc;
if( !ipers.isValid() ) {
log << MSG::FATAL << "Unable to locate IPersistencySvc interface of " << m_persName << endmsg;
}
IConversionSvc *cnvSvc = 0;
status = ipers->getService(typ, cnvSvc);
if( !status.isSuccess() ) {
log << MSG::FATAL << "Unable to locate IConversionSvc interface of database type " << typ << endmsg;
return status;
}
// Increase reference count and keep service.
m_pConversionSvc = cnvSvc;
}
else {
<< "Unable to locate IConversionSvc interface (Unknown technology) " << endmsg
<< "You either have to specify a technology name or a service name!" << endmsg
<< "Please correct the job option \"" << name() << ".Output\" !" << endmsg;
}
}
StatusCode OutputStream::decodeAcceptAlgs ( )
protected

Decode list of Algorithms that this stream accepts.

Definition at line 484 of file OutputStream.cpp.

StatusCode OutputStream::decodeAlgorithms ( StringArrayProperty theNames,
std::vector< Algorithm * > *  theAlgs 
)
protected

Decode specified list of Algorithms.

Definition at line 520 of file OutputStream.cpp.

{
// Reset the list of Algorithms
theAlgs->clear( );
MsgStream log( msgSvc( ), name( ) );
if ( theAlgMgr.isValid() ) {
// Build the list of Algorithms from the names list
const std::vector<std::string> nameList = theNames.value( );
for (it = nameList.begin(); it != itend; ++it) {
// Check whether the supplied name corresponds to an existing
// Algorithm object.
const std::string &theName = (*it);
SmartIF<IAlgorithm> &theIAlg = theAlgMgr->algorithm(theName);
Algorithm* theAlgorithm;
if ( theIAlg.isValid() ) {
try{
theAlgorithm = dynamic_cast<Algorithm*>(theIAlg.get());
} catch(...){
}
}
if ( result.isSuccess( ) ) {
// Check that the specified algorithm doesn't already exist in the list
std::vector<Algorithm*>::iterator itaend = theAlgs->end( );
for (ita = theAlgs->begin(); ita != itaend; ++ita) {
Algorithm* existAlgorithm = (*ita);
if ( theAlgorithm == existAlgorithm ) {
break;
}
}
if ( result.isSuccess( ) ) {
theAlgorithm->addRef();
theAlgs->push_back( theAlgorithm );
}
}
else {
log << MSG::INFO << theName << " doesn't exist - ignored" << endmsg;
}
}
}
else {
log << MSG::FATAL << "Can't locate ApplicationMgr!!!" << endmsg;
}
return result;
}
StatusCode OutputStream::decodeRequireAlgs ( )
protected

Decode list of Algorithms that this stream requires.

Definition at line 496 of file OutputStream.cpp.

StatusCode OutputStream::decodeVetoAlgs ( )
protected

Decode list of Algorithms that this stream is vetoed by.

Definition at line 508 of file OutputStream.cpp.

StatusCode OutputStream::execute ( )
virtual

Working entry point.

Reimplemented in SequentialOutputStream, RecordStream, and RunRecordStream.

Definition at line 170 of file OutputStream.cpp.

{
// Clear any previously existing item list
// Test whether this event should be output
if ( isEventAccepted() )
{
if ( sc.isSuccess() && m_fireIncidents )
{
}
else if ( m_fireIncidents )
{
}
return sc;
}
}
StatusCode OutputStream::finalize ( )
virtual
DataStoreItem * OutputStream::findItem ( const std::string path)
protected

Find single item identified by its path (exact match)

Definition at line 363 of file OutputStream.cpp.

{
if ( (*i)->path() == path ) return (*i);
}
if ( (*j)->path() == path ) return (*j);
}
return 0;
}
bool OutputStream::hasInput ( ) const
protectedvirtual

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

Reimplemented in InputCopyStream.

Definition at line 624 of file OutputStream.cpp.

{
}
StatusCode OutputStream::initialize ( )
virtual

Initialize OutputStream.

Reimplemented from Algorithm.

Reimplemented in TagCollectionStream, and InputCopyStream.

Definition at line 75 of file OutputStream.cpp.

{
// Reset the number of events written
m_events = 0;
// Get access to the DataManagerSvc
log << MSG::FATAL << "Unable to locate IDataManagerSvc interface" << endmsg;
}
// Get access to the IncidentService
m_incidentSvc = serviceLocator()->service("IncidentSvc");
log << MSG::WARNING << "Error retrieving IncidentSvc." << endmsg;
}
// Get access to the assigned data service
log << MSG::FATAL << "Unable to locate IDataProviderSvc interface of " << m_storeName << endmsg;
}
if ( hasInput() ) {
if( !status.isSuccess() ) {
log << MSG::FATAL << "Unable to connect to conversion service." << endmsg;
return status;
}
}
// Clear the list with optional items
// Clear the item list
// Take the new item list from the properties.
for(i = m_itemNames.begin(); i != m_itemNames.end(); i++) {
}
// Take the new item list from the properties.
for(i = m_optItemNames.begin(); i != m_optItemNames.end(); i++) {
}
// Take the item list to the data service preload list.
if ( m_doPreLoad ) {
for(Items::iterator j = m_itemList.begin(); j != m_itemList.end(); j++) {
m_pDataProvider->addPreLoadItem( *(*j) ).ignore();
}
// Not working: bad reference counting! pdataSvc->release();
}
if ( m_doPreLoadOpt ) {
m_pDataProvider->addPreLoadItem( *(*j) );
}
}
log << MSG::INFO << "Data source: " << m_storeName << " output: " << m_output << endmsg;
// Decode the accept, required and veto Algorithms. The logic is the following:
// a. The event is accepted if all lists are empty.
// b. The event is provisionally accepted if any Algorithm in the accept list
// has been executed and has indicated that its filter is passed. This
// provisional acceptance can be overridden by the other lists.
// c. The event is rejected unless all Algorithms in the required list have
// been executed and have indicated that their filter passed.
// d. The event is rejected if any Algorithm in the veto list has been
// executed and has indicated that its filter has passed.
}
bool OutputStream::isEventAccepted ( ) const
protected

Test whether this event should be output.

Definition at line 578 of file OutputStream.cpp.

{
bool result = true;
// Loop over all Algorithms in the accept list to see
// whether any have been executed and have their filter
// passed flag set. Any match causes the event to be
// provisionally accepted.
if ( ! m_acceptAlgs->empty() ) {
result = false;
for(AlgIter i=m_acceptAlgs->begin(),end=m_acceptAlgs->end(); i != end; ++i) {
if ( (*i)->isExecuted() && (*i)->filterPassed() ) {
result = true;
break;
}
}
}
// Loop over all Algorithms in the required list to see
// whether all have been executed and have their filter
// passed flag set. Any mismatch causes the event to be
// rejected.
if ( result && ! m_requireAlgs->empty() ) {
for(AlgIter i=m_requireAlgs->begin(),end=m_requireAlgs->end(); i != end; ++i) {
if ( !(*i)->isExecuted() || !(*i)->filterPassed() ) {
result = false;
break;
}
}
}
// Loop over all Algorithms in the veto list to see
// whether any have been executed and have their filter
// passed flag set. Any match causes the event to be
// rejected.
if ( result && ! m_vetoAlgs->empty() ) {
for(AlgIter i=m_vetoAlgs->begin(),end=m_vetoAlgs->end(); i != end; ++i) {
if ( (*i)->isExecuted() && (*i)->filterPassed() ) {
result = false;
break;
}
}
}
return result;
}
void OutputStream::requireAlgsHandler ( Property theProp)
protected

Handler for RequireAlgs Property.

Definition at line 500 of file OutputStream.cpp.

{
if (sc.isFailure()) {
throw GaudiException("Failure in OutputStream::decodeAlgorithms",
"OutputStream::requireAlgsHandler",sc);
}
}
IDataSelector* OutputStream::selectedObjects ( )
inline

Return the list of selected objects.

Definition at line 139 of file OutputStream.h.

{ return &m_objects; }
void OutputStream::vetoAlgsHandler ( Property theProp)
protected

Handler for VetoAlgs Property.

Definition at line 512 of file OutputStream.cpp.

{
if (sc.isFailure()) {
throw GaudiException("Failure in OutputStream::decodeAlgorithms",
"OutputStream::vetoAlgsHandler",sc);
}
}
StatusCode OutputStream::writeObjects ( )
protectedvirtual

Select the different objects and write them to file.

Reimplemented in TagCollectionStream, and SequentialOutputStream.

Definition at line 196 of file OutputStream.cpp.

{
// Connect the output file to the service
if ( status.isSuccess() )
{
if ( sel->begin() != sel->end() )
{
status = m_pConversionSvc->connectOutput(m_outputName, m_outputType);
if ( status.isSuccess() )
{
// Now pass the collection to the persistency service
IOpaqueAddress* pAddress = NULL;
for ( IDataSelector::iterator j = sel->begin(); j != sel->end(); ++j )
{
try
{
const StatusCode iret = m_pConversionSvc->createRep( *j, pAddress );
if ( !iret.isSuccess() )
{
status = iret;
continue;
}
IRegistry* pReg = (*j)->registry();
pReg->setAddress(pAddress);
}
catch ( const std::exception & excpt )
{
const std::string loc = ( (*j)->registry() ?
(*j)->registry()->identifier() : "UnRegistered" );
<< "std::exception during createRep for '" << loc << "' "
<< System::typeinfoName( typeid(**j) )
<< endmsg;
log << MSG::FATAL << excpt.what() << endmsg;
throw;
}
}
for ( IDataSelector::iterator j = sel->begin(); j != sel->end(); ++j )
{
try
{
IRegistry* pReg = (*j)->registry();
const StatusCode iret = m_pConversionSvc->fillRepRefs( pReg->address(), *j );
if ( !iret.isSuccess() )
{
status = iret;
}
}
catch ( const std::exception & excpt )
{
const std::string loc = ( (*j)->registry() ?
(*j)->registry()->identifier() : "UnRegistered" );
<< "std::exception during fillRepRefs for '" << loc << "'"
<< System::typeinfoName( typeid(**j) )
<< endmsg;
log << MSG::FATAL << excpt.what() << endmsg;
throw;
}
}
// Commit the data if there was no error; otherwise possibly discard
if ( status.isSuccess() )
{
status = m_pConversionSvc->commitOutput(m_outputName, true);
}
else
{
m_pConversionSvc->commitOutput(m_outputName, false).ignore();
}
}
}
}
return status;
}

Member Data Documentation

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

Vector of Algorithms that this stream accepts.

Definition at line 79 of file OutputStream.h.

StringArrayProperty OutputStream::m_acceptNames
protected

Vector of names of Algorithms that this stream accepts.

Definition at line 73 of file OutputStream.h.

OutputStreamAgent* OutputStream::m_agent
protected

Keep reference of agent.

Definition at line 51 of file OutputStream.h.

DataStoreItem* OutputStream::m_currentItem
protected

Keep track of the current item.

Definition at line 59 of file OutputStream.h.

bool OutputStream::m_doPreLoad
protected

Flag indicating whether data pre-loading should be performed.

Definition at line 35 of file OutputStream.h.

bool OutputStream::m_doPreLoadOpt
protected

Flag indicating whether optional items should be preloaded.

Definition at line 37 of file OutputStream.h.

int OutputStream::m_events
protected

Number of events written to this output stream.

Definition at line 71 of file OutputStream.h.

bool OutputStream::m_fireIncidents
protected

should I fire incidents for writing opening/closing etc?

Definition at line 114 of file OutputStream.h.

SmartIF<IIncidentSvc> OutputStream::m_incidentSvc
protected

Reference to the incident service.

Definition at line 33 of file OutputStream.h.

Items OutputStream::m_itemList
protected

Vector of items to be saved to this stream.

Definition at line 63 of file OutputStream.h.

ItemNames OutputStream::m_itemNames
protected

Vector of item names.

Definition at line 61 of file OutputStream.h.

IDataSelector OutputStream::m_objects
protected

Collection of objects being selected.

Definition at line 69 of file OutputStream.h.

Items OutputStream::m_optItemList
protected

Vector of optional items to be saved to this stream.

Definition at line 67 of file OutputStream.h.

ItemNames OutputStream::m_optItemNames
protected

Vector of item names.

Definition at line 65 of file OutputStream.h.

std::string OutputStream::m_output
protected

Name of the output file specification.

Definition at line 45 of file OutputStream.h.

std::string OutputStream::m_outputName
protected

Name of the output file.

Definition at line 47 of file OutputStream.h.

std::string OutputStream::m_outputType
protected

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

Definition at line 49 of file OutputStream.h.

SmartIF<IConversionSvc> OutputStream::m_pConversionSvc
protected

Keep reference to the data conversion service.

Definition at line 57 of file OutputStream.h.

SmartIF<IDataManagerSvc> OutputStream::m_pDataManager
protected

Keep reference to the data manager service.

Definition at line 55 of file OutputStream.h.

SmartIF<IDataProviderSvc> OutputStream::m_pDataProvider
protected

Keep reference to the data provider service.

Definition at line 53 of file OutputStream.h.

std::string OutputStream::m_persName
protected

Name of the persistency service capable to write data from the store.

Definition at line 43 of file OutputStream.h.

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

Vector of Algorithms that this stream requires.

Definition at line 81 of file OutputStream.h.

StringArrayProperty OutputStream::m_requireNames
protected

Vector of names of Algorithms that this stream requires.

Definition at line 75 of file OutputStream.h.

std::string OutputStream::m_storeName
protected

Name of the service managing the data store.

Definition at line 41 of file OutputStream.h.

bool OutputStream::m_verifyItems
protected

Flag to indicate that item consistency should be checked.

Definition at line 39 of file OutputStream.h.

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

Vector of Algorithms that this stream is vetoed by.

Definition at line 83 of file OutputStream.h.

StringArrayProperty OutputStream::m_vetoNames
protected

Vector of names of Algorithms that this stream is vetoed by.

Definition at line 77 of file OutputStream.h.


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

Generated at Mon Feb 17 2014 14:38:08 for Gaudi Framework, version v25r0 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004