Gaudi Framework, version v23r10

Home   Generated: Mon Sep 30 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
Gaudi::RootEvtSelector Class Reference

Concrete event selector implementation to access ROOT files. More...

#include <GAUDIROOT/RootEvtSelector.h>

Inheritance diagram for Gaudi::RootEvtSelector:
Inheritance graph
[legend]
Collaboration diagram for Gaudi::RootEvtSelector:
Collaboration graph
[legend]

Public Member Functions

 RootEvtSelector (const std::string &name, ISvcLocator *svcloc)
 Service Constructor.
 
virtual ~RootEvtSelector ()
 Standard destructor.
 
virtual StatusCode initialize ()
 IService implementation: Db event selector override.
 
virtual StatusCode finalize ()
 IService implementation: Service finalization.
 
virtual StatusCode createContext (Context *&refpCtxt) const
 Create a new event loop context.
 
virtual StatusCode last (Context &refContext) const
 Access last item in the iteration.
 
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 *&) 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.
 
- 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

RootCnvSvcm_dbMgr
 Reference to the corresponding conversion service.
 
CLID m_rootCLID
 Class id of root node to create opaque address.
 
std::string m_persName
 Property; Name of the persistency service to search for conversion service.
 
std::string m_cnvSvcName
 Property; Name of the concversion service used to create opaque addresses.
 
std::string m_rootName
 Property: Name of the ROOT entry name.
 
std::string m_criteria
 Property: File criteria to define item iteration.
 
std::string m_dummy
 Property: dummy to fake backwards compatibility.
 

Private Member Functions

StatusCode error (const std::string &msg) const
 Helper method to issue error messages.
 

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

Concrete event selector implementation to access ROOT files.

Author
M.Frank
Version
1.0
Date
20/12/2009

Definition at line 41 of file RootEvtSelector.h.

Constructor & Destructor Documentation

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

Service Constructor.

Definition at line 100 of file RootEvtSelector.cpp.

: base_class(name, svcloc), m_rootCLID(CLID_NULL)
{
m_cnvSvcName = "Gaudi::RootCnvSvc/RootCnvSvc";
m_persName = "EventPersistencySvc";
declareProperty("EvtPersistencySvc",m_persName="EventPersistencySvc");
declareProperty("DbType",m_dummy);
}
virtual Gaudi::RootEvtSelector::~RootEvtSelector ( )
inlinevirtual

Standard destructor.

Definition at line 51 of file RootEvtSelector.h.

{}

Member Function Documentation

StatusCode RootEvtSelector::createAddress ( const Context refCtxt,
IOpaqueAddress *&  pAddr 
) const
virtual

Create new Opaque address corresponding to the current record.

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

Implements IEvtSelector.

Definition at line 272 of file RootEvtSelector.cpp.

{
const RootEvtSelectorContext* pctxt = dynamic_cast<const RootEvtSelectorContext*>(&ctxt);
if ( pctxt ) {
long ent = pctxt->entry();
if ( ent >= 0 ) {
if ( fileit != pctxt->files().end() ) {
const string par[2] = {pctxt->fid(), m_rootName};
const unsigned long ipar[2] = {0,(unsigned long)ent};
return m_dbMgr->createAddress(m_dbMgr->repSvcType(),m_rootCLID,&par[0],&ipar[0],pAddr);
}
}
}
pAddr = 0;
}
StatusCode RootEvtSelector::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 165 of file RootEvtSelector.cpp.

{
refpCtxt = new RootEvtSelectorContext(this);
}
StatusCode RootEvtSelector::error ( const std::string msg) const
private

Helper method to issue error messages.

Definition at line 110 of file RootEvtSelector.cpp.

StatusCode RootEvtSelector::finalize ( )
virtual

IService implementation: Service finalization.

Reimplemented from Service.

Definition at line 157 of file RootEvtSelector.cpp.

{
// Initialize base class
if ( m_dbMgr ) m_dbMgr->release();
m_dbMgr = 0; // release
}
StatusCode RootEvtSelector::initialize ( )
virtual

IService implementation: Db event selector override.

Reimplemented from Service.

Definition at line 117 of file RootEvtSelector.cpp.

{
// Initialize base class
if ( !status.isSuccess() ) {
return error("Error initializing base class Service!");
}
if( !ipers.isValid() ) {
return error("Unable to locate IPersistencySvc interface of "+m_persName);
}
IConversionSvc *cnvSvc = 0;
Gaudi::Utils::TypeNameString itm(m_cnvSvcName);
status = ipers->getService(itm.name(),cnvSvc);
if( !status.isSuccess() ) {
status = ipers->getService(itm.type(),cnvSvc);
if( !status.isSuccess() ) {
return error("Unable to locate IConversionSvc interface of database type "+m_cnvSvcName);
}
}
m_dbMgr = dynamic_cast<RootCnvSvc*>(cnvSvc);
if( !m_dbMgr ) {
cnvSvc->release();
return error("Unable to localize service:"+m_cnvSvcName);
}
m_dbMgr->addRef();
// Get DataSvc
if( !eds.isValid() ) {
return error("Unable to localize service EventDataSvc");
}
m_rootCLID = eds->rootCLID();
m_rootName = eds->rootName();
log << MSG::DEBUG << "Selection root:" << m_rootName << " CLID:" << m_rootCLID << endmsg;
return status;
}
StatusCode RootEvtSelector::last ( Context refContext) const
virtual

Access last item in the iteration.

Parameters
refContext[IN/OUT] Reference to the Context object.

Implements IEvtSelector.

Definition at line 171 of file RootEvtSelector.cpp.

{
}
StatusCode RootEvtSelector::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 176 of file RootEvtSelector.cpp.

{
RootEvtSelectorContext* pCtxt = dynamic_cast<RootEvtSelectorContext*>(&ctxt);
if ( pCtxt ) {
TBranch* b = pCtxt->branch();
if ( !b ) {
pCtxt->setBranch(0);
pCtxt->setEntry(-1);
if ( fileit != pCtxt->files().end() ) {
string in = *fileit;
StatusCode sc = m_dbMgr->connectDatabase(in,IDataConnection::READ,&con);
if ( sc.isSuccess() ) {
string section = m_rootName[0] == '/' ? m_rootName.substr(1) : m_rootName;
b = con->getBranch(section,m_rootName);
if ( b ) {
pCtxt->setFID(con->fid());
pCtxt->setBranch(b);
return next(ctxt);
}
}
pCtxt->setFileIterator(++fileit);
return next(ctxt);
}
}
long ent = pCtxt->entry();
Long64_t nent = b->GetEntries();
if ( nent > (ent+1) ) {
pCtxt->setEntry(++ent);
}
pCtxt->setFileIterator(++fit);
pCtxt->setEntry(-1);
pCtxt->setBranch(0);
pCtxt->setFID("");
return next(ctxt);
}
}
StatusCode RootEvtSelector::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 220 of file RootEvtSelector.cpp.

{
if ( jump > 0 ) {
for ( int i = 0; i < jump; ++i ) {
StatusCode status = next(ctxt);
if ( !status.isSuccess() ) {
return status;
}
}
}
}
StatusCode RootEvtSelector::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 234 of file RootEvtSelector.cpp.

{
return error("EventSelector Iterator, operator -- not supported ");
}
StatusCode RootEvtSelector::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 239 of file RootEvtSelector.cpp.

{
if ( jump > 0 ) {
for ( int i = 0; i < jump; ++i ) {
StatusCode status = previous(ctxt);
if ( !status.isSuccess() ) {
return status;
}
}
}
}
StatusCode RootEvtSelector::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 290 of file RootEvtSelector.cpp.

{
RootEvtSelectorContext* pCtxt = dynamic_cast<RootEvtSelectorContext*>(ctxt);
if ( pCtxt ) {
delete pCtxt;
}
}
StatusCode RootEvtSelector::resetCriteria ( const std::string cr,
Context c 
) 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.

Implements IEvtSelector.

Definition at line 302 of file RootEvtSelector.cpp.

{
RootEvtSelectorContext* ctxt = dynamic_cast<RootEvtSelectorContext*>(&context);
string db, typ, item, sel, stmt, aut, addr;
if ( ctxt ) {
if ( criteria.substr(0,5) == "FILE " ) {
// The format for the criteria is:
// FILE filename1, filename2 ...
db = criteria.substr(5);
}
else {
Tokenizer tok(true);
tok.analyse(criteria," ","","","=","'","'");
for(Tokenizer::Items::iterator i=tok.items().begin(); i!=tok.items().end();i++) {
string tmp = (*i).tag().substr(0,3);
if(tmp=="DAT") {
db = (*i).value();
}
if(tmp=="OPT") {
if((*i).value() != "REA") {
log << MSG::ERROR << "Option:\"" << (*i).value() << "\" not valid" << endmsg;
}
}
if (tmp=="TYP") {
typ = (*i).value();
}
if(tmp=="ADD") {
item = (*i).value();
}
if(tmp=="SEL") {
sel = (*i).value();
}
if(tmp=="FUN") {
stmt = (*i).value();
}
if(tmp=="AUT") {
aut = (*i).value();
}
if(tmp=="COL") {
addr = (*i).value();
}
}
}
// It's now time to parse the criteria for the event selection
// The format for the criteria is:
// FILE filename1, filename2 ...
// JOBID number1-number2, number3, ...
string rest = db;
files.clear();
while(true) {
int ipos = rest.find_first_not_of(" ,");
if (ipos == -1 ) break;
rest = rest.substr(ipos,string::npos);// remove blanks before
int lpos = rest.find_first_of(" ,"); // locate next blank
files.push_back(rest.substr(0,lpos )); // insert in list
if (lpos == -1 ) break;
rest = rest.substr(lpos,string::npos);// get the rest
}
ctxt->setFiles(files);
ctxt->setFileIterator(ctxt->files().begin());
}
return error("Invalid iteration context.");
}
StatusCode RootEvtSelector::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 253 of file RootEvtSelector.cpp.

{
RootEvtSelectorContext* pCtxt = dynamic_cast<RootEvtSelectorContext*>(&ctxt);
if ( pCtxt ) {
if ( fileit != pCtxt->files().end() ) {
string input = *fileit;
}
pCtxt->setFID("");
pCtxt->setEntry(-1);
pCtxt->setBranch(0);
pCtxt->setFileIterator(pCtxt->files().begin());
}
}

Member Data Documentation

std::string Gaudi::RootEvtSelector::m_cnvSvcName
protected

Property; Name of the concversion service used to create opaque addresses.

Definition at line 138 of file RootEvtSelector.h.

std::string Gaudi::RootEvtSelector::m_criteria
protected

Property: File criteria to define item iteration.

Definition at line 142 of file RootEvtSelector.h.

RootCnvSvc* Gaudi::RootEvtSelector::m_dbMgr
mutableprotected

Reference to the corresponding conversion service.

Definition at line 132 of file RootEvtSelector.h.

std::string Gaudi::RootEvtSelector::m_dummy
protected

Property: dummy to fake backwards compatibility.

Definition at line 144 of file RootEvtSelector.h.

std::string Gaudi::RootEvtSelector::m_persName
protected

Property; Name of the persistency service to search for conversion service.

Definition at line 136 of file RootEvtSelector.h.

CLID Gaudi::RootEvtSelector::m_rootCLID
protected

Class id of root node to create opaque address.

Definition at line 134 of file RootEvtSelector.h.

std::string Gaudi::RootEvtSelector::m_rootName
protected

Property: Name of the ROOT entry name.

Definition at line 140 of file RootEvtSelector.h.


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

Generated at Mon Sep 30 2013 14:52:06 for Gaudi Framework, version v23r10 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004