Gaudi Framework, version v24r2

Home   Generated: Wed Dec 4 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Member Functions | Protected Attributes | List of all members
EventCollectionSelector Class Reference

Definition of class EventCollectionSelector. More...

#include <EventCollectionSelector.h>

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

Classes

class  MyContextType
 

Public Member Functions

virtual StatusCode initialize ()
 Service override: Initialize service.
 
virtual StatusCode finalize ()
 Service override: Finalize Service.
 
virtual StatusCode createContext (Context *&refpCtxt) const
 Create a new event loop context.
 
virtual StatusCode next (Context &refCtxt) const
 Get next iteration item from the event loop context.
 
virtual StatusCode next (Context &refCtxt, int jump) const
 Get next iteration item from the event loop context, but skip jump elements.
 
virtual StatusCode previous (Context &refCtxt) const
 Get previous iteration item from the event loop context.
 
virtual StatusCode previous (Context &refCtxt, int jump) const
 Get previous iteration item from the event loop context, but skip jump elements.
 
virtual StatusCode rewind (Context &refCtxt) const
 Rewind the dataset.
 
virtual StatusCode createAddress (const Context &refCtxt, IOpaqueAddress *&refpAddr) const
 Create new Opaque address corresponding to the current record.
 
virtual StatusCode releaseContext (Context *&refCtxt) const
 Release existing event iteration context.
 
virtual StatusCode resetCriteria (const std::string &cr, Context &c) const
 Will set a new criteria for the selection of the next list of events and will change the state of the context in a way to point to the new list.
 
virtual StatusCode last (Context &refCtxt) const
 Access last item in the iteration.
 
virtual StatusCode connectCollection (MyContextType *ctxt) const
 Connect collection to selector.
 
virtual StatusCode connectDataSource (const std::string &db, const std::string &typ) const
 Connect collection's data source to selector.
 
virtual StatusCode connectTuple (const std::string &nam, const std::string &itName, NTuple::Tuple *&tup, NTuple::Item< IOpaqueAddress * > *&item) const
 Connect to existing N-tuple.
 
virtual StatusCode connectStatement (const std::string &typ, const std::string &crit, INTuple *tuple) const
 Connect selection statement to refine data access.
 
virtual StatusCode getNextRecord (NTuple::Tuple *tuple) const
 Read next record of the N-tuple.
 
virtual StatusCode getPreviousRecord (NTuple::Tuple *tuple) const
 Read next record of the N-tuple.
 
 EventCollectionSelector (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor.
 
virtual ~EventCollectionSelector ()
 Standard Destructor.
 
- Public Member Functions inherited from extends1< Service, IEvtSelector >
 extends1 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments.
 
 extends1 (A1 a1, A2 a2)
 Templated constructor with 2 arguments.
 
 extends1 (A1 a1)
 Templated constructor with 1 argument.
 
 extends1 ()
 Default constructor.
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast.
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface.
 
virtual std::vector< std::stringgetInterfaceNames () const
 Implementation of IInterface::getInterfaceNames.
 
virtual ~extends1 ()
 Virtual destructor.
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance.
 
virtual const std::stringname () const
 Retrieve name of the service.
 
virtual StatusCode configure ()
 
virtual StatusCode start ()
 
virtual StatusCode stop ()
 
virtual StatusCode terminate ()
 
virtual Gaudi::StateMachine::State FSMState () const
 
virtual Gaudi::StateMachine::State targetFSMState () const
 
virtual StatusCode reinitialize ()
 
virtual StatusCode restart ()
 
virtual StatusCode sysInitialize ()
 Initialize Service.
 
virtual StatusCode sysStart ()
 Initialize Service.
 
virtual StatusCode sysStop ()
 Initialize Service.
 
virtual StatusCode sysFinalize ()
 Finalize Service.
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service.
 
virtual StatusCode sysRestart ()
 Re-initialize the Service.
 
virtual StatusCode setProperty (const Property &p)
 
virtual StatusCode setProperty (const std::string &s)
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 
virtual StatusCode getProperty (Property *p) const
 
virtual const PropertygetProperty (const std::string &name) const
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 
virtual const std::vector
< Property * > & 
getProperties () const
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator.
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job.
 
template<class T >
StatusCode service (const std::string &name, const 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 &name, T *&psvc, bool createIf=true) const
 
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.
 
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< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
 
- Public Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments.
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments.
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument.
 
 CommonMessaging ()
 Default constructor.
 
virtual ~CommonMessaging ()
 Virtual destructor.
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from extend_interfaces1< IEvtSelector >
virtual ~extend_interfaces1 ()
 Virtual destructor.
 
- Public Member Functions inherited from IEvtSelector
 DeclareInterfaceID (IEvtSelector, 2, 0)
 InterfaceID.
 
- Public Member Functions inherited from IInterface
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance.
 
virtual unsigned long release ()=0
 Release Interface instance.
 
virtual unsigned long refCount () const =0
 Current reference count.
 
virtual ~IInterface ()
 Virtual destructor.
 

Protected Attributes

SmartIF< INTupleSvcm_tupleSvc
 Reference to Tuple service.
 
SmartIF< IAddressCreatorm_pAddrCreator
 
std::string m_tupleSvcName
 Name of the event collection service name.
 
std::string m_authentication
 Authentication string (if needed)
 
std::string m_cntName
 Container name.
 
std::string m_itemName
 Item name.
 
std::string m_criteria
 Criteria.
 
std::string m_database
 Datafile name.
 
std::string m_dbType
 Database type identifier.
 
std::string m_dbSvc
 Database service (exclusive property with db type)
 
std::string m_statement
 Selector name.
 

Additional Inherited Members

- Public Types inherited from extends1< Service, IEvtSelector >
typedef extends1 base_class
 Typedef to this class.
 
typedef extend_interfaces1
< IEvtSelector
extend_interfaces_base
 Typedef to the base of this class.
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces.
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface.
 
- Protected Member Functions inherited from Service
virtual ~Service ()
 Standard Destructor.
 
int outputLevel () const
 get the Service's output level
 

Detailed Description

Definition of class EventCollectionSelector.

Basic event selector service. The event selector service itself is able to connect other services to attached streams.

History: +------—+-------------------------------------------—+------—+ | Date | Comment | Who | +------—+-------------------------------------------—+------—+ | 3/10/00 | Initial version | M.Frank | +------—+-------------------------------------------—+------—+

Author
Markus Frank
Version
1.0

Definition at line 41 of file EventCollectionSelector.h.

Constructor & Destructor Documentation

EventCollectionSelector::EventCollectionSelector ( const std::string name,
ISvcLocator svcloc 
)

Standard Constructor.

Definition at line 79 of file EventCollectionSelector.cpp.

: base_class(name, svcloc)
{
declareProperty("CnvService", m_tupleSvcName = "EvtTupleSvc");
declareProperty("Authentication",m_authentication= "");
declareProperty("Container", m_cntName = "B2PiPi");
declareProperty("Item", m_itemName = "Address");
declareProperty("Criteria", m_criteria = "");
declareProperty("DbType", m_dbType = "");
declareProperty("DbService", m_dbSvc = "");
declareProperty("Function", m_statement= "NTuple::Selector");
}
EventCollectionSelector::~EventCollectionSelector ( )
virtual

Standard Destructor.

Definition at line 93 of file EventCollectionSelector.cpp.

{
}

Member Function Documentation

StatusCode EventCollectionSelector::connectCollection ( MyContextType ctxt) const
virtual

Connect collection to selector.

Definition at line 232 of file EventCollectionSelector.cpp.

{
if ( ctxt ) {
if ( status.isSuccess() ) {
status = connectTuple(m_cntName, m_itemName, ctxt->tuple, ctxt->item);
if ( status.isSuccess() ) {
status = connectStatement(m_statement, m_criteria, ctxt->tuple);
if ( status.isSuccess() ) {
*(ctxt->item) = 0;
return status;
}
}
}
return status;
}
}
StatusCode EventCollectionSelector::connectDataSource ( const std::string db,
const std::string typ 
) const
virtual

Connect collection's data source to selector.

Definition at line 120 of file EventCollectionSelector.cpp.

{
if ( svc.isValid( ) && db.length() > 0 ) {
std::string ident = name() + ' ';
ident += "DATAFILE='" + m_database.substr(5,m_database.length()) + "' ";
if ( !m_dbSvc.empty() )
ident += "SVC='" + m_dbSvc + "' ";
else
ident += "TYP='" + m_dbType + "' ";
ident += "OPT='READ' ";
if ( m_authentication.length() > 0 ) {
ident += "AUTH='" + m_authentication + "' ";
}
status = svc->connect(ident);
}
return status;
}
StatusCode EventCollectionSelector::connectStatement ( const std::string typ,
const std::string crit,
INTuple tuple 
) const
virtual

Connect selection statement to refine data access.

Definition at line 167 of file EventCollectionSelector.cpp.

{
std::string seltyp = typ;
if ( seltyp.length() > 0 || crit.length() > 0 ) {
if ( crit.length() > 0 && seltyp.length() == 0 ) seltyp = "NTuple::Selector";
SmartIF<ISelectStatement> stmt(ROOT::Reflex::PluginService::Create<IInterface*>(seltyp, (IInterface*)serviceLocator()));
if ( stmt.isValid( ) ) {
if ( crit.length() > 0 ) stmt->setCriteria(crit);
tuple->attachSelector(stmt).ignore();
}
}
}
StatusCode EventCollectionSelector::connectTuple ( const std::string nam,
const std::string itName,
NTuple::Tuple *&  tup,
NTuple::Item< IOpaqueAddress * > *&  item 
) const
virtual

Connect to existing N-tuple.

Definition at line 141 of file EventCollectionSelector.cpp.

{
std::string top = "/NTUPLES/" + name() + '/' + nam;
StatusCode status = m_tupleSvc->retrieveObject(top, (DataObject*&)tup);
if ( status.isSuccess() ) {
status = tup->item(itName, *item);
if ( status.isSuccess() ) {
return status;
}
else {
log << MSG::ERROR << "Item " << itName << " is not part of the collection:" << top << endmsg;
}
delete item;
item = 0;
}
else {
err << MSG::ERROR << "Cannot connect to collection:" << top << endmsg;
}
tup = 0;
return status;
}
StatusCode EventCollectionSelector::createAddress ( const Context refCtxt,
IOpaqueAddress *&  refpAddr 
) const
virtual

Create new Opaque address corresponding to the current record.

Parameters
refCtxt[IN/OUT] Reference to the context
refpAddr[OUT] Reference to address pointer
Returns
StatusCode indicating success or failure

Implements IEvtSelector.

Definition at line 330 of file EventCollectionSelector.cpp.

{
const MyContextType* ctxt = dynamic_cast<const MyContextType*>(&refCtxt);
if ( ctxt ) {
IOpaqueAddress* pA = *(ctxt->item);
if ( pA ) {
IOpaqueAddress* pAddress = 0;
StatusCode status = m_pAddrCreator->createAddress(pA->svcType(),
pA->clID(),
pA->par(),
pA->ipar(),
pAddress);
if ( status.isSuccess() ) {
refpAddr = pAddress;
}
else {
log << MSG::ERROR << "Failed to access " << pA->par()[0]
<< ":" << pA->par()[1]
<< " SvcTyp:" << long(pA->svcType())
<< " CLID:" << pA->clID()
<< endmsg;
}
}
}
}
StatusCode EventCollectionSelector::createContext ( Context *&  refpCtxt) const
virtual

Create a new event loop context.

Parameters
refpCtxt[IN/OUT] Reference to pointer to store the context
Returns
StatusCode indicating success or failure

Implements IEvtSelector.

Definition at line 261 of file EventCollectionSelector.cpp.

{
refpCtxt = 0;
std::auto_ptr<MyContextType> ctxt(new MyContextType());
StatusCode status = connectCollection(ctxt.get());
if( !status.isSuccess() ) {
log << MSG::ERROR << "Unable to connect Collection file \"" << m_database << "\"" << endmsg;
return status;
}
refpCtxt = ctxt.release();
}
StatusCode EventCollectionSelector::finalize ( )
virtual

Service override: Finalize Service.

Reimplemented from Service.

Definition at line 252 of file EventCollectionSelector.cpp.

{
// release services
}
StatusCode EventCollectionSelector::getNextRecord ( NTuple::Tuple tuple) const
virtual

Read next record of the N-tuple.

Definition at line 183 of file EventCollectionSelector.cpp.

{
if ( 0 != tuple ) {
do {
status = m_tupleSvc->readRecord(tuple);
if ( status.isSuccess() ) {
ISelectStatement* statement = tuple->selector();
bool use_it = (statement) ? (*statement)(tuple) : true;
if ( use_it ) {
return status;
}
}
} while ( status.isSuccess() );
}
return status;
}
StatusCode EventCollectionSelector::getPreviousRecord ( NTuple::Tuple tuple) const
virtual

Read next record of the N-tuple.

Read previous record of the N-tuple.

Definition at line 201 of file EventCollectionSelector.cpp.

{
if ( tuple ) {
IRegistry* pReg = tuple->registry();
if ( pReg ) {
IOpaqueAddress* pAddr = pReg->address();
if ( pAddr ) {
long* ip = (long*)pAddr->ipar();
do {
if ( ip[1] > 1 ) {
ip[1] -= 2;
status = m_tupleSvc->readRecord(tuple);
if ( status.isSuccess() ) {
ISelectStatement* statement = tuple->selector();
bool use_it = (statement) ? (*statement)(tuple) : true;
if ( use_it ) {
return status;
}
}
}
else {
}
} while ( status.isSuccess() );
}
}
}
}
StatusCode EventCollectionSelector::initialize ( )
virtual

Service override: Initialize service.

Reimplemented from Service.

Definition at line 97 of file EventCollectionSelector.cpp.

{
// Initialize base class
if ( !status.isSuccess() ) {
log << MSG::ERROR << "Error initializing base class Service!" << endmsg;
return status;
}
m_pAddrCreator = serviceLocator()->service("EventPersistencySvc");
log << MSG::ERROR << "Unable to locate IAddressCreator interface of " << "EventPersistencySvc" << endmsg;
return status;
}
if( !m_tupleSvc.isValid() ) {
log << MSG::ERROR << "Unable to locate INTupleSvc interface of " << m_tupleSvcName << endmsg;
return status;
}
return status;
}
StatusCode EventCollectionSelector::last ( Context refCtxt) const
virtual

Access last item in the iteration.

Parameters
refCtxt[IN/OUT] Reference to the Context object.
Returns
StatusCode indicating success or failure

Implements IEvtSelector.

Definition at line 387 of file EventCollectionSelector.cpp.

{
}
StatusCode EventCollectionSelector::next ( Context refCtxt) const
virtual

Get next iteration item from the event loop context.

Parameters
refCtxt[IN/OUT] Reference to the context
Returns
StatusCode indicating success or failure

Implements IEvtSelector.

Definition at line 277 of file EventCollectionSelector.cpp.

{
return next(refCtxt, 1);
}
StatusCode EventCollectionSelector::next ( Context refCtxt,
int  jump 
) const
virtual

Get next iteration item from the event loop context, but skip jump elements.

Parameters
refCtxt[IN/OUT] Reference to the context
Returns
StatusCode indicating success or failure

Implements IEvtSelector.

Definition at line 284 of file EventCollectionSelector.cpp.

{
MyContextType *ctxt = dynamic_cast<MyContextType*>(&refCtxt);
if ( ctxt ) {
*(ctxt->item) = ctxt->addressBuffer;
for ( int i=0; i<jump && sc.isSuccess(); ++i ) {
sc = getNextRecord(ctxt->tuple);
}
return sc;
}
}
StatusCode EventCollectionSelector::previous ( Context refCtxt) const
virtual

Get previous iteration item from the event loop context.

Parameters
refCtxt[IN/OUT] Reference to the context
jump[IN] Number of events to be skipped
Returns
StatusCode indicating success or failure

Implements IEvtSelector.

Definition at line 300 of file EventCollectionSelector.cpp.

{
return previous(refCtxt, 1);
}
StatusCode EventCollectionSelector::previous ( Context refCtxt,
int  jump 
) const
virtual

Get previous iteration item from the event loop context, but skip jump elements.

Parameters
refCtxt[IN/OUT] Reference to the context
jump[IN] Number of events to be skipped
Returns
StatusCode indicating success or failure

Implements IEvtSelector.

Definition at line 307 of file EventCollectionSelector.cpp.

{
MyContextType *ctxt = dynamic_cast<MyContextType*>(&refCtxt);
if ( ctxt ) {
*(ctxt->item) = ctxt->addressBuffer;
for ( int i=0; i<jump && sc.isSuccess(); ++i ) {
sc = getPreviousRecord(ctxt->tuple);
}
return sc;
}
}
StatusCode EventCollectionSelector::releaseContext ( Context *&  refCtxt) const
virtual

Release existing event iteration context.

Parameters
refCtxt[IN/OUT] Reference to the context
Returns
StatusCode indicating success or failure

Implements IEvtSelector.

Definition at line 361 of file EventCollectionSelector.cpp.

{
MyContextType *ctxt = dynamic_cast<MyContextType*>(refCtxt);
if ( ctxt ) {
delete ctxt;
ctxt = 0;
}
}
StatusCode EventCollectionSelector::resetCriteria ( const std::string cr,
Context refCtxt 
) const
virtual

Will set a new criteria for the selection of the next list of events and will change the state of the context in a way to point to the new list.

Parameters
crThe new criteria string.
cReference pointer to the Context object.
Returns
StatusCode indicating success or failure

Implements IEvtSelector.

Definition at line 375 of file EventCollectionSelector.cpp.

{
MyContextType *ctxt = dynamic_cast<MyContextType*>(&refCtxt);
if ( ctxt ) {
ctxt->criteria = cr;
}
}
StatusCode EventCollectionSelector::rewind ( Context refCtxt) const
virtual

Rewind the dataset.

Parameters
refCtxt[IN/OUT] Reference to the context
Returns
StatusCode indicating success or failure

Implements IEvtSelector.

Definition at line 323 of file EventCollectionSelector.cpp.

{
}

Member Data Documentation

std::string EventCollectionSelector::m_authentication
protected

Authentication string (if needed)

Definition at line 84 of file EventCollectionSelector.h.

std::string EventCollectionSelector::m_cntName
protected

Container name.

Definition at line 86 of file EventCollectionSelector.h.

std::string EventCollectionSelector::m_criteria
protected

Criteria.

Definition at line 90 of file EventCollectionSelector.h.

std::string EventCollectionSelector::m_database
protected

Datafile name.

Definition at line 92 of file EventCollectionSelector.h.

std::string EventCollectionSelector::m_dbSvc
protected

Database service (exclusive property with db type)

Definition at line 96 of file EventCollectionSelector.h.

std::string EventCollectionSelector::m_dbType
protected

Database type identifier.

Definition at line 94 of file EventCollectionSelector.h.

std::string EventCollectionSelector::m_itemName
protected

Item name.

Definition at line 88 of file EventCollectionSelector.h.

SmartIF<IAddressCreator> EventCollectionSelector::m_pAddrCreator
mutableprotected

Definition at line 80 of file EventCollectionSelector.h.

std::string EventCollectionSelector::m_statement
protected

Selector name.

Definition at line 98 of file EventCollectionSelector.h.

SmartIF<INTupleSvc> EventCollectionSelector::m_tupleSvc
mutableprotected

Reference to Tuple service.

Definition at line 79 of file EventCollectionSelector.h.

std::string EventCollectionSelector::m_tupleSvcName
protected

Name of the event collection service name.

Definition at line 82 of file EventCollectionSelector.h.


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

Generated at Wed Dec 4 2013 14:33:15 for Gaudi Framework, version v24r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004