9 #ifndef GAUDIROOTCNV_ROOTEVTSELECTORCONTEXT_H
10 #define GAUDIROOTCNV_ROOTEVTSELECTORCONTEXT_H
13 #include "RootCnv/RootEvtSelector.h"
35 typedef std::vector<std::string>
Files;
59 m_fiter = m_files.begin();
74 const std::string&
fid()
const {
return m_fid; }
81 #endif // GAUDIROOTCNV_ROOTEVTSELECTORCONTEXT_H
84 #include "GaudiKernel/ClassID.h"
85 #include "GaudiKernel/MsgStream.h"
86 #include "GaudiKernel/AttribStringParser.h"
87 #include "GaudiKernel/TypeNameString.h"
88 #include "GaudiKernel/IDataManagerSvc.h"
89 #include "GaudiKernel/IPersistencySvc.h"
90 #include "GaudiKernel/ISvcLocator.h"
91 #include "RootCnv/RootCnvSvc.h"
92 #include "RootCnv/RootDataConnection.h"
95 using namespace Gaudi;
100 :
base_class(name, svcloc), m_rootCLID(CLID_NULL)
104 declareProperty(
"EvtPersistencySvc",
m_persName=
"EventPersistencySvc");
105 declareProperty(
"DbType",
m_dummy);
120 return error(
"Error initializing base class Service!");
125 return error(
"Unable to locate IPersistencySvc interface of "+
m_persName);
129 status = ipers->getService(itm.
name(),cnvSvc);
131 status = ipers->getService(itm.
type(),cnvSvc);
133 return error(
"Unable to locate IConversionSvc interface of database type "+
m_cnvSvcName);
146 return error(
"Unable to localize service EventDataSvc");
178 TBranch* b = pCtxt->
branch();
183 if ( fileit != pCtxt->
files().end() ) {
202 long ent = pCtxt->
entry();
203 Long64_t nent = b->GetEntries();
204 if ( nent > (ent+1) ) {
221 for (
int i = 0;
i < jump; ++
i ) {
234 return error(
"EventSelector Iterator, operator -- not supported ");
240 for (
int i = 0;
i < jump; ++
i ) {
256 if ( fileit != pCtxt->
files().end() ) {
257 string input = *fileit;
274 long ent = pctxt->
entry();
277 if ( fileit != pctxt->
files().end() ) {
279 const unsigned long ipar[2] = {0,(
unsigned long)ent};
305 string db, typ,
item,
sel, stmt, aut, addr;
307 if ( criteria.compare(0,5,
"FILE ")==0 ) {
310 db = criteria.substr(5);
313 using Parser = Gaudi::Utils::AttribStringParser;
314 for(
auto attrib: Parser(criteria)) {
315 string tmp = attrib.tag.substr(0,3);
317 db = std::move(attrib.value);
319 else if(tmp==
"OPT") {
320 if(attrib.value.compare(0, 3,
"REA") != 0) {
321 log <<
MSG::ERROR <<
"Option:\"" << attrib.value <<
"\" not valid" <<
endmsg;
325 else if (tmp==
"TYP") {
326 typ = std::move(attrib.value);
328 else if(tmp==
"ADD") {
329 item = std::move(attrib.value);
331 else if(tmp==
"SEL") {
332 sel = std::move(attrib.value);
334 else if(tmp==
"FUN") {
335 stmt = std::move(attrib.value);
337 else if(tmp==
"AUT") {
338 aut = std::move(attrib.value);
340 else if(tmp==
"COL") {
341 addr = std::move(attrib.value);
353 int ipos = rest.find_first_not_of(
" ,");
354 if (ipos == -1 )
break;
355 rest = rest.substr(ipos,string::npos);
356 int lpos = rest.find_first_of(
" ,");
357 files.push_back(rest.substr(0,lpos ));
358 if (lpos == -1 )
break;
359 rest = rest.substr(lpos,string::npos);
365 return error(
"Invalid iteration context.");
Definition of the MsgStream class used to transmit messages.
StatusCode initialize() override
const Files & files() const
Access to the file container.
std::string m_persName
Property; Name of the persistency service to search for conversion service.
virtual StatusCode rewind(Context &refCtxt) const
Rewind the dataset.
virtual StatusCode initialize()
IService implementation: Db event selector override.
Files::const_iterator fileIterator() const
Access to the file iterator.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
const std::string & fid() const
Access file id.
virtual StatusCode last(Context &refContext) const
Access last item in the iteration.
RootEvtSelectorContext(const RootEvtSelector *s)
Standard constructor with initialization.
StatusCode finalize() override
virtual StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress)
IAddressCreator implementation: Address creation.
std::vector< std::string > Files
Definition of the file container.
bool isSuccess() const
Test for a status code of SUCCESS.
std::string m_fid
Connection fid.
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...
std::string m_dummy
Property: dummy to fake backwards compatibility.
virtual StatusCode previous(Context &refCtxt) const
Get previous iteration item from the event loop context.
virtual StatusCode disconnect(const std::string &dbName)
Disconnect from an existing data stream.
~RootEvtSelectorContext() override=default
Standard destructor.
void * identifier() const override
Context identifier.
virtual StatusCode finalize()
IService implementation: Service finalization.
Helper class to parse a string of format "type/name".
virtual long repSvcType() const
Retrieve the class type of the data store the converter uses.
std::string m_cnvSvcName
Property; Name of the concversion service used to create opaque addresses.
ROOT specific event selector context.
This class is used for returning status codes from appropriate routines.
TBranch * getBranch(const std::string §ion, const std::string &branch_name)
Access data branch by name: Get existing branch in read only mode.
const RootEvtSelector * m_sel
Reference to the hosting event selector instance.
void setFiles(const Files &f)
Set the file container.
void setBranch(TBranch *b)
Set the top level branch (typically /Event) used to iterate.
StatusCode connectDatabase(const std::string &dataset, int mode, RootDataConnection **con)
Connect the output file to the service with open mode.
Concrete event selector implementation to access ROOT files.
void setEntry(long e)
Set current event entry number.
virtual unsigned long release()=0
Release Interface instance.
Base class used to extend a class implementing other interfaces.
StatusCode error(const std::string &msg) const
Helper method to issue error messages.
const std::string & type() const
const std::string & fid() const
Access connection fid.
void setFID(const std::string &fid)
Set connection FID.
Files::const_iterator m_fiter
The iterator to the.
RootCnvSvc * m_dbMgr
Reference to the corresponding conversion service.
Data persistency service interface.
void setFileIterator(Files::const_iterator i)
Set file iterator.
TBranch * branch() const
Access to the top level branch (typically /Event) used to iterate.
const std::string & name() const
RootEvtSelector(const std::string &name, ISvcLocator *svcloc)
Service Constructor.
Opaque address interface definition.
Files m_files
The file container managed by this context.
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.
CLID m_rootCLID
Class id of root node to create opaque address.
Concrete implementation of the IDataConnection interface to access ROOT files.
TBranch * m_branch
Reference to the top level branch (typically /Event) used to iterate.
Helper functions to set/get the application return code.
long entry() const
Access to the current event entry number.
virtual StatusCode next(Context &refCtxt) const
Get next iteration item from the event loop context.
virtual StatusCode createContext(Context *&refpCtxt) const
Create a new event loop context.
std::string m_rootName
Property: Name of the ROOT entry name.
long m_entry
Current entry of current file.