The Gaudi Framework  v32r2 (46d42edc)
Gaudi::RootEvtSelector Class Reference

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

#include <GAUDIROOT/RootEvtSelector.h>

Inheritance diagram for Gaudi::RootEvtSelector:
Collaboration diagram for Gaudi::RootEvtSelector:

Public Member Functions

StatusCode initialize () override
 IService implementation: Db event selector override. More...
 
StatusCode finalize () override
 IService implementation: Service finalization. More...
 
StatusCode createContext (Context *&refpCtxt) const override
 Create a new event loop context. More...
 
StatusCode last (Context &refContext) const override
 Access last item in the iteration. More...
 
StatusCode next (Context &refCtxt) const override
 Get next iteration item from the event loop context. More...
 
StatusCode next (Context &refCtxt, int jump) const override
 Get next iteration item from the event loop context, but skip jump elements. More...
 
StatusCode previous (Context &refCtxt) const override
 Get previous iteration item from the event loop context. More...
 
StatusCode previous (Context &refCtxt, int jump) const override
 Get previous iteration item from the event loop context, but skip jump elements. More...
 
StatusCode rewind (Context &refCtxt) const override
 Rewind the dataset. More...
 
StatusCode createAddress (const Context &refCtxt, IOpaqueAddress *&) const override
 Create new Opaque address corresponding to the current record. More...
 
StatusCode releaseContext (Context *&refCtxt) const override
 Release existing event iteration context. More...
 
StatusCode resetCriteria (const std::string &cr, Context &c) const override
 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. More...
 
- Public Member Functions inherited from extends< Service, IEvtSelector >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service. More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service. More...
 
StatusCode sysStart () override
 Initialize Service. More...
 
StatusCode sysStop () override
 Initialize Service. More...
 
StatusCode sysFinalize () override
 Finalize Service. More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
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. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, 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. More...
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const
 Backward compatibility function for getting the output level. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 

Protected Attributes

RootCnvSvcm_dbMgr
 Reference to the corresponding conversion service. More...
 
CLID m_rootCLID = CLID_NULL
 Class id of root node to create opaque address. More...
 
Gaudi::Property< std::stringm_persName
 
Gaudi::Property< std::stringm_dummy {this, "DbType", "", "dummy property to fake backwards compatibility"}
 
std::string m_cnvSvcName = "Gaudi::RootCnvSvc/RootCnvSvc"
 Property; Name of the concversion service used to create opaque addresses. More...
 
std::string m_rootName
 Property: Name of the ROOT entry name. More...
 
std::string m_criteria
 Property: File criteria to define item iteration. More...
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::Property< int > m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
 
Gaudi::Property< bool > m_auditInit {this, "AuditServices", false, " unused"}
 
Gaudi::Property< bool > m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
 
Gaudi::Property< bool > m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
 
Gaudi::Property< bool > m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
 
Gaudi::Property< bool > m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
 
Gaudi::Property< bool > m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
 
Gaudi::Property< bool > m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service. More...
 

Private Member Functions

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

Additional Inherited Members

- Public Types inherited from extends< Service, IEvtSelector >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from Service
using Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 
- Protected Member Functions inherited from Service
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Detailed Description

Concrete event selector implementation to access ROOT files.

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

Definition at line 39 of file RootEvtSelector.h.

Member Function Documentation

◆ createAddress()

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

Create new Opaque address corresponding to the current record.

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

Definition at line 267 of file RootEvtSelector.cpp.

267  {
268  const RootEvtSelectorContext* pctxt = dynamic_cast<const RootEvtSelectorContext*>( &ctxt );
269  if ( pctxt ) {
270  long ent = pctxt->entry();
271  if ( ent >= 0 ) {
272  auto fileit = pctxt->fileIterator();
273  if ( fileit != pctxt->files().end() ) {
274  const string par[2] = {pctxt->fid(), m_rootName};
275  const unsigned long ipar[2] = {0, (unsigned long)ent};
276  return m_dbMgr->createAddress( m_dbMgr->repSvcType(), m_rootCLID, &par[0], &ipar[0], pAddr );
277  }
278  }
279  }
280  pAddr = nullptr;
281  return StatusCode::FAILURE;
282 }
StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress) override
IAddressCreator implementation: Address creation.
Definition: RootCnvSvc.cpp:347
long repSvcType() const override
Retrieve the class type of the data store the converter uses.
T end(T... args)
RootCnvSvc * m_dbMgr
Reference to the corresponding conversion service.
Files::const_iterator fileIterator() const
Access to the file iterator.
ROOT specific event selector context.
long entry() const
Access to the current event entry number.
constexpr static const auto FAILURE
Definition: StatusCode.h:86
CLID m_rootCLID
Class id of root node to create opaque address.
const std::string & fid() const
Access connection fid.
std::string m_rootName
Property: Name of the ROOT entry name.
const Files & files() const
Access to the file container.

◆ createContext()

StatusCode RootEvtSelector::createContext ( Context *&  refpCtxt) const
override

Create a new event loop context.

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

Definition at line 167 of file RootEvtSelector.cpp.

167  {
168  refpCtxt = new RootEvtSelectorContext( this );
169  return StatusCode::SUCCESS;
170 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
ROOT specific event selector context.

◆ error()

StatusCode RootEvtSelector::error ( const std::string msg) const
private

Helper method to issue error messages.

Definition at line 118 of file RootEvtSelector.cpp.

118  {
119  MsgStream log( msgSvc(), name() );
120  log << MSG::ERROR << msg << endmsg;
121  return StatusCode::FAILURE;
122 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
constexpr static const auto FAILURE
Definition: StatusCode.h:86
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

◆ finalize()

StatusCode RootEvtSelector::finalize ( )
override

IService implementation: Service finalization.

Definition at line 159 of file RootEvtSelector.cpp.

159  {
160  // Initialize base class
161  if ( m_dbMgr ) m_dbMgr->release();
162  m_dbMgr = nullptr; // release
163  return Service::finalize();
164 }
StatusCode finalize() override
Definition: Service.cpp:164
RootCnvSvc * m_dbMgr
Reference to the corresponding conversion service.

◆ initialize()

StatusCode RootEvtSelector::initialize ( )
override

IService implementation: Db event selector override.

Definition at line 125 of file RootEvtSelector.cpp.

125  {
126  // Initialize base class
127  StatusCode status = Service::initialize();
128  if ( !status.isSuccess() ) { return error( "Error initializing base class Service!" ); }
129 
130  auto ipers = serviceLocator()->service<IPersistencySvc>( m_persName );
131  if ( !ipers ) { return error( "Unable to locate IPersistencySvc interface of " + m_persName ); }
132  IConversionSvc* cnvSvc = nullptr;
134  status = ipers->getService( itm.name(), cnvSvc );
135  if ( !status.isSuccess() ) {
136  status = ipers->getService( itm.type(), cnvSvc );
137  if ( !status.isSuccess() ) {
138  return error( "Unable to locate IConversionSvc interface of database type " + m_cnvSvcName );
139  }
140  }
141  m_dbMgr = dynamic_cast<RootCnvSvc*>( cnvSvc );
142  if ( !m_dbMgr ) {
143  cnvSvc->release();
144  return error( "Unable to localize service:" + m_cnvSvcName );
145  }
146  m_dbMgr->addRef();
147 
148  // Get DataSvc
149  auto eds = serviceLocator()->service<IDataManagerSvc>( "EventDataSvc" );
150  if ( !eds ) { return error( "Unable to localize service EventDataSvc" ); }
151  m_rootCLID = eds->rootCLID();
152  m_rootName = eds->rootName();
153  MsgStream log( msgSvc(), name() );
154  log << MSG::DEBUG << "Selection root:" << m_rootName << " CLID:" << m_rootCLID << endmsg;
155  return status;
156 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
StatusCode initialize() override
Definition: Service.cpp:60
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:277
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Gaudi::Property< std::string > m_persName
RootCnvSvc * m_dbMgr
Reference to the corresponding conversion service.
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:76
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Helper class to parse a string of format "type/name".
std::string m_cnvSvcName
Property; Name of the concversion service used to create opaque addresses.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
bool isSuccess() const
Definition: StatusCode.h:267
virtual unsigned long release()=0
Release Interface instance.
Data persistency service interface.
CLID m_rootCLID
Class id of root node to create opaque address.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
std::string m_rootName
Property: Name of the ROOT entry name.

◆ last()

StatusCode RootEvtSelector::last ( Context &  refContext) const
override

Access last item in the iteration.

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

Definition at line 173 of file RootEvtSelector.cpp.

173 { return StatusCode::FAILURE; }
constexpr static const auto FAILURE
Definition: StatusCode.h:86

◆ next() [1/2]

StatusCode RootEvtSelector::next ( Context &  refCtxt) const
override

Get next iteration item from the event loop context.

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

Definition at line 176 of file RootEvtSelector.cpp.

176  {
177  RootEvtSelectorContext* pCtxt = dynamic_cast<RootEvtSelectorContext*>( &ctxt );
178  if ( pCtxt ) {
179  TBranch* b = pCtxt->branch();
180  if ( !b ) {
181  auto fileit = pCtxt->fileIterator();
182  pCtxt->setBranch( nullptr );
183  pCtxt->setEntry( -1 );
184  if ( fileit != pCtxt->files().end() ) {
185  RootDataConnection* con = nullptr;
186  string in = *fileit;
188  if ( sc.isSuccess() ) {
189  string section = m_rootName[0] == '/' ? m_rootName.substr( 1 ) : m_rootName;
190  b = con->getBranch( section, m_rootName );
191  if ( b ) {
192  pCtxt->setFID( con->fid() );
193  pCtxt->setBranch( b );
194  return next( ctxt );
195  }
196  }
197  m_dbMgr->disconnect( in ).ignore();
198  pCtxt->setFileIterator( ++fileit );
199  return next( ctxt );
200  }
201  return StatusCode::FAILURE;
202  }
203  long ent = pCtxt->entry();
204  Long64_t nent = b->GetEntries();
205  if ( nent > ( ent + 1 ) ) {
206  pCtxt->setEntry( ++ent );
207  return StatusCode::SUCCESS;
208  }
209  auto fit = pCtxt->fileIterator();
210  pCtxt->setFileIterator( ++fit );
211  pCtxt->setEntry( -1 );
212  pCtxt->setBranch( nullptr );
213  pCtxt->setFID( "" );
214  return next( ctxt );
215  }
216  return StatusCode::FAILURE;
217 }
StatusCode next(Context &refCtxt) const override
Get next iteration item from the event loop context.
TBranch * getBranch(std::string_view section, std::string_view branch_name)
Access data branch by name: Get existing branch in read only mode.
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
const std::string & fid() const
Access file id.
T end(T... args)
StatusCode connectDatabase(const std::string &dataset, int mode, RootDataConnection **con)
Connect the output file to the service with open mode.
Definition: RootCnvSvc.cpp:194
RootCnvSvc * m_dbMgr
Reference to the corresponding conversion service.
Files::const_iterator fileIterator() const
Access to the file iterator.
ROOT specific event selector context.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
bool isSuccess() const
Definition: StatusCode.h:267
virtual StatusCode disconnect(const std::string &dbName)
Disconnect from an existing data stream.
Definition: RootCnvSvc.cpp:341
void setBranch(TBranch *b)
Set the top level branch (typically /Event) used to iterate.
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
void setEntry(long e)
Set current event entry number.
long entry() const
Access to the current event entry number.
void setFID(const std::string &fid)
Set connection FID.
constexpr static const auto FAILURE
Definition: StatusCode.h:86
T substr(T... args)
void setFileIterator(Files::const_iterator i)
Set file iterator.
Concrete implementation of the IDataConnection interface to access ROOT files.
TBranch * branch() const
Access to the top level branch (typically /Event) used to iterate.
std::string m_rootName
Property: Name of the ROOT entry name.
const Files & files() const
Access to the file container.

◆ next() [2/2]

StatusCode RootEvtSelector::next ( Context &  refCtxt,
int  jump 
) const
override

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

Definition at line 220 of file RootEvtSelector.cpp.

220  {
221  if ( jump > 0 ) {
222  for ( int i = 0; i < jump; ++i ) {
223  StatusCode status = next( ctxt );
224  if ( !status.isSuccess() ) { return status; }
225  }
226  return StatusCode::SUCCESS;
227  }
228  return StatusCode::FAILURE;
229 }
StatusCode next(Context &refCtxt) const override
Get next iteration item from the event loop context.
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
bool isSuccess() const
Definition: StatusCode.h:267
constexpr static const auto FAILURE
Definition: StatusCode.h:86

◆ previous() [1/2]

StatusCode RootEvtSelector::previous ( Context &  refCtxt) const
override

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

Definition at line 232 of file RootEvtSelector.cpp.

232  {
233  return error( "EventSelector Iterator, operator -- not supported " );
234 }
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)

◆ previous() [2/2]

StatusCode RootEvtSelector::previous ( Context &  refCtxt,
int  jump 
) const
override

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

Definition at line 237 of file RootEvtSelector.cpp.

237  {
238  if ( jump > 0 ) {
239  for ( int i = 0; i < jump; ++i ) {
240  StatusCode status = previous( ctxt );
241  if ( !status.isSuccess() ) { return status; }
242  }
243  return StatusCode::SUCCESS;
244  }
245  return StatusCode::FAILURE;
246 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
StatusCode previous(Context &refCtxt) const override
Get previous iteration item from the event loop context.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
bool isSuccess() const
Definition: StatusCode.h:267
constexpr static const auto FAILURE
Definition: StatusCode.h:86

◆ releaseContext()

StatusCode RootEvtSelector::releaseContext ( Context *&  refCtxt) const
override

Release existing event iteration context.

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

Definition at line 285 of file RootEvtSelector.cpp.

285  {
286  RootEvtSelectorContext* pCtxt = dynamic_cast<RootEvtSelectorContext*>( ctxt );
287  if ( pCtxt ) {
288  delete pCtxt;
289  return StatusCode::SUCCESS;
290  }
291  return StatusCode::FAILURE;
292 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
ROOT specific event selector context.
constexpr static const auto FAILURE
Definition: StatusCode.h:86

◆ resetCriteria()

StatusCode RootEvtSelector::resetCriteria ( const std::string cr,
Context &  c 
) const
override

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.

Definition at line 296 of file RootEvtSelector.cpp.

296  {
297  MsgStream log( msgSvc(), name() );
298  RootEvtSelectorContext* ctxt = dynamic_cast<RootEvtSelectorContext*>( &context );
299  string db, typ, item, sel, stmt, aut, addr;
300  if ( ctxt ) {
301  if ( criteria.compare( 0, 5, "FILE " ) == 0 ) {
302  // The format for the criteria is:
303  // FILE filename1, filename2 ...
304  db = criteria.substr( 5 );
305  } else {
306  using Parser = Gaudi::Utils::AttribStringParser;
307  for ( auto attrib : Parser( criteria ) ) {
308  string tmp = attrib.tag.substr( 0, 3 );
309  if ( tmp == "DAT" ) {
310  db = std::move( attrib.value );
311  } else if ( tmp == "OPT" ) {
312  if ( attrib.value.compare( 0, 3, "REA" ) != 0 ) {
313  log << MSG::ERROR << "Option:\"" << attrib.value << "\" not valid" << endmsg;
314  return StatusCode::FAILURE;
315  }
316  } else if ( tmp == "TYP" ) {
317  typ = std::move( attrib.value );
318  } else if ( tmp == "ADD" ) {
319  item = std::move( attrib.value );
320  } else if ( tmp == "SEL" ) {
321  sel = std::move( attrib.value );
322  } else if ( tmp == "FUN" ) {
323  stmt = std::move( attrib.value );
324  } else if ( tmp == "AUT" ) {
325  aut = std::move( attrib.value );
326  } else if ( tmp == "COL" ) {
327  addr = std::move( attrib.value );
328  }
329  }
330  }
331  // It's now time to parse the criteria for the event selection
332  // The format for the criteria is:
333  // FILE filename1, filename2 ...
334  // JOBID number1-number2, number3, ...
336  string rest = db;
337  files.clear();
338  while ( true ) {
339  int ipos = rest.find_first_not_of( " ," );
340  if ( ipos == -1 ) break;
341  rest = rest.substr( ipos, string::npos ); // remove blanks before
342  int lpos = rest.find_first_of( " ," ); // locate next blank
343  files.push_back( rest.substr( 0, lpos ) ); // insert in list
344  if ( lpos == -1 ) break;
345  rest = rest.substr( lpos, string::npos ); // get the rest
346  }
347  ctxt->setFiles( files );
348  ctxt->setFileIterator( ctxt->files().begin() );
349  return StatusCode::SUCCESS;
350  }
351  return error( "Invalid iteration context." );
352 }
Parse attribute strings allowing iteration over the various attributes.
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
T find_first_not_of(T... args)
sel
Definition: IOTest.py:94
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274
T push_back(T... args)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
ROOT specific event selector context.
T find_first_of(T... args)
T clear(T... args)
T move(T... args)
void setFiles(const Files &f)
Set the file container.
T begin(T... args)
constexpr static const auto FAILURE
Definition: StatusCode.h:86
T substr(T... args)
void setFileIterator(Files::const_iterator i)
Set file iterator.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
const Files & files() const
Access to the file container.

◆ rewind()

StatusCode RootEvtSelector::rewind ( Context &  refCtxt) const
override

Rewind the dataset.

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

Definition at line 249 of file RootEvtSelector.cpp.

249  {
250  RootEvtSelectorContext* pCtxt = dynamic_cast<RootEvtSelectorContext*>( &ctxt );
251  if ( pCtxt ) {
252  auto fileit = pCtxt->fileIterator();
253  if ( fileit != pCtxt->files().end() ) {
254  string input = *fileit;
255  m_dbMgr->disconnect( input ).ignore();
256  }
257  pCtxt->setFID( "" );
258  pCtxt->setEntry( -1 );
259  pCtxt->setBranch( nullptr );
260  pCtxt->setFileIterator( pCtxt->files().begin() );
261  return StatusCode::SUCCESS;
262  }
263  return StatusCode::FAILURE;
264 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
T end(T... args)
RootCnvSvc * m_dbMgr
Reference to the corresponding conversion service.
Files::const_iterator fileIterator() const
Access to the file iterator.
ROOT specific event selector context.
virtual StatusCode disconnect(const std::string &dbName)
Disconnect from an existing data stream.
Definition: RootCnvSvc.cpp:341
void setBranch(TBranch *b)
Set the top level branch (typically /Event) used to iterate.
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
void setEntry(long e)
Set current event entry number.
T begin(T... args)
void setFID(const std::string &fid)
Set connection FID.
constexpr static const auto FAILURE
Definition: StatusCode.h:86
void setFileIterator(Files::const_iterator i)
Set file iterator.
const Files & files() const
Access to the file container.

Member Data Documentation

◆ m_cnvSvcName

std::string Gaudi::RootEvtSelector::m_cnvSvcName = "Gaudi::RootCnvSvc/RootCnvSvc"
protected

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

Definition at line 137 of file RootEvtSelector.h.

◆ m_criteria

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

Property: File criteria to define item iteration.

Definition at line 141 of file RootEvtSelector.h.

◆ m_dbMgr

RootCnvSvc* Gaudi::RootEvtSelector::m_dbMgr
mutableprotected

Reference to the corresponding conversion service.

Definition at line 128 of file RootEvtSelector.h.

◆ m_dummy

Gaudi::Property<std::string> Gaudi::RootEvtSelector::m_dummy {this, "DbType", "", "dummy property to fake backwards compatibility"}
protected

Definition at line 134 of file RootEvtSelector.h.

◆ m_persName

Gaudi::Property<std::string> Gaudi::RootEvtSelector::m_persName
protected
Initial value:
{this, "EvtPersistencySvc", "EventPersistencySvc",
"Name of the persistency service to search for conversion service"}

Definition at line 132 of file RootEvtSelector.h.

◆ m_rootCLID

CLID Gaudi::RootEvtSelector::m_rootCLID = CLID_NULL
protected

Class id of root node to create opaque address.

Definition at line 130 of file RootEvtSelector.h.

◆ m_rootName

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

Property: Name of the ROOT entry name.

Definition at line 139 of file RootEvtSelector.h.


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