5#include "GaudiKernel/MsgStream.h"
6#include "GaudiKernel/StatusCode.h"
7#include "GaudiKernel/SvcFactory.h"
8#include "GaudiKernel/IDataManagerSvc.h"
9#include "GaudiKernel/IAddressCreator.h"
10#include "GaudiKernel/GenericAddress.h"
11#include "RootCnvSvc/RootEvtSelector.h"
12#include "RootCnvSvc/RootInterface.h"
13#include "RootCnvSvc/RootEventContext.h"
14#include "EventModel/EventModel.h"
24 : Service( name, svcloc),
29 declareProperty(
"Input", m_jobInput=
"ROOT");
38 MsgStream log(
msgSvc(), name());
39 StatusCode sc = Service::initialize();
40 log << MSG::DEBUG <<
"RootEvtSelector::initialize" << endreq;
if( sc.isSuccess() ) {
43 log << MSG::ERROR <<
"Unable to initialize service " << endreq;
46 if(m_jobInput.value() !=
" "){
49 log << MSG::ERROR <<
"Unable to get input value" << endreq;
55 sc = serviceLocator()->service(
"EventCnvSvc", m_addrCreator);
56 if( !sc.isSuccess() ) {
58 "Unable to localize interface IID_IAddressCreator from service:"
59 <<
"RootEventSelector"
64 IDataManagerSvc* eds = 0;
65 sc = serviceLocator()->service(
"EventDataSvc", eds,
true);
66 if( !sc.isSuccess() ) {
68 <<
"Unable to localize interface IID_IDataManagerSvc "
69 <<
"from RootEventSelector"
74 m_rootCLID = eds->rootCLID();
78 if (!m_rootInterface) log << MSG::ERROR <<
"Unable to start Root service within RootCnvSvc" << endreq;
88 MsgStream log(
msgSvc(), name());
89 m_criteria = criteria;
91 if( criteria ==
"ROOT" ) {
92 log << MSG::INFO <<
"RootEvtSelector input has been set to ROOT" << endreq;
93 m_criteriaType =
ROOT;
94 }
else if( criteria ==
"NONE"){
95 m_criteriaType = NONE;
96 log << MSG::INFO <<
"RootEvtSelector input has been set to NONE" << endreq;
99 log << MSG::ERROR <<
"Invalid Event Selection Criteria: " << criteria << endreq;
100 return StatusCode::FAILURE;
102 return StatusCode::SUCCESS;
109 return(StatusCode::SUCCESS);
121 for (
int i = 0; i < jump; ++i ) {
122 StatusCode status =
next(ctxt);
123 if ( !status.isSuccess() ) {
127 return StatusCode::SUCCESS;
129 return StatusCode::FAILURE;
133 MsgStream log(messageService(), name());
134 log << MSG::ERROR <<
"RootEvtSelector::previous() not implemented" << endreq;
135 return(StatusCode::FAILURE);
143 if (it.identifier() == p_endContext->
identifier()) {
144 MsgStream log(messageService(), name());
145 log << MSG::DEBUG <<
"last(): Last event in InputStream." <<endreq;
146 return(StatusCode::SUCCESS);
148 return (StatusCode::FAILURE);
152 return(StatusCode::SUCCESS);
157 MsgStream log(messageService(), name());
158 log << MSG::ERROR <<
"RootEvtSelector::rewind() not implemented" << endreq;
159 return(StatusCode::FAILURE);
164 return(StatusCode::SUCCESS);
168 IOpaqueAddress*& iop)
const {
170 return(StatusCode::SUCCESS);
175 MsgStream log(
msgSvc(), name());
177 if(m_criteriaType ==
ROOT)
179 log<<MSG::INFO<<
"m_criteriaType == ROOT"<<endreq;
185 static int entry = 0;
187 bool endOfFile = m_rootInterface->
getEOF();
190 if(maxEntry) entry =1;
191 log<<MSG::INFO<<
"entry = "<<entry<<
" "<<maxEntry<<
" "<<endOfFile<<endreq;
192 if(endOfFile || maxEntry){
196 return StatusCode::FAILURE;
201 else if( m_criteriaType == NONE)
203 log << MSG::DEBUG <<
"Reading Event " << (*m_recId) << endreq;
205 if((*m_recId) > m_evtMax) {
206 return StatusCode::FAILURE;
210 log << MSG::FATAL <<
"Cannot iterate a dead iterator" << endreq;
211 return StatusCode::FAILURE;
213 log << MSG::DEBUG <<
"Reading Event " << (*m_recId) << endreq;
214 log << MSG::DEBUG <<
"Max Event " << m_evtMax << endreq;
215 return StatusCode::SUCCESS;
219 if ( riid == IID_IRootEvtSelector ) {
222 else if ( riid == IEvtSelector::interfaceID() ) {
223 *ppvInterface = (IEvtSelector*)
this;
225 else if ( riid == IProperty::interfaceID() ) {
226 *ppvInterface = (IProperty*)
this;
229 return Service::queryInterface( riid, ppvInterface );
235StatusCode RootEvtSelector::getMaxEvent() {
236 IProperty* appPropMgr=0;
238 serviceLocator()->getService(
"ApplicationMgr", IProperty::interfaceID(),
239 reinterpret_cast<IInterface*&
>( appPropMgr ));
240 if( status.isFailure() )
return status;
242 IntegerProperty evtMax(
"EvtMax",0);
243 status = appPropMgr->getProperty( &evtMax );
244 if (status.isFailure())
return status;
246 m_evtMax = evtMax.value();
const long int ROOT_StorageType
const long int ROOT_StorageType
This class provides the Context for RootEventSelector.
virtual void * identifier() const
Inequality operator.
RootEvtSelector performs the function of controlling the ApplicationMgr loop.
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
virtual StatusCode setCriteria(const std::string &criteria)
virtual StatusCode rewind(Context &it) const
virtual StatusCode resetCriteria(const std::string &criteria, Context &context) const
virtual StatusCode initialize()
virtual StatusCode last(Context &it) const
virtual StatusCode releaseContext(Context *&it) const
virtual StatusCode previous(Context &it) const
virtual StatusCode createContext(Context *&it) const
virtual StatusCode createAddress(const Context &it, IOpaqueAddress *&iop) const
RootEvtSelector(const std::string &name, ISvcLocator *svcloc)
virtual bool checkEndOfTree()
check if all the files is over 2005-11-28
virtual Int_t getEntries()
get nr of entries
virtual bool getEOF()
get EOF flag
static RootInterface * Instance(MsgStream log)
singleton behaviour