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"
18#include "GaudiKernel/SmartIF.h"
19#include "GaudiKernel/Bootstrap.h"
20#include "GaudiKernel/IAppMgrUI.h"
21#include "GaudiKernel/IProperty.h"
22#include "GaudiKernel/ISvcLocator.h"
40 : base_class( name, svcloc),
45 declareProperty(
"Input", m_jobInput=
"ROOT");
54 MsgStream log(
msgSvc(), name());
55 StatusCode sc = Service::initialize();
56 log << MSG::DEBUG <<
"RootEvtSelector::initialize" << endreq;
if( sc.isSuccess() ) {
59 log << MSG::ERROR <<
"Unable to initialize service " << endreq;
62 if(m_jobInput.value() !=
" "){
65 log << MSG::ERROR <<
"Unable to get input value" << endreq;
71 sc = serviceLocator()->service(
"EventCnvSvc", m_addrCreator);
72 if( !sc.isSuccess() ) {
74 "Unable to localize interface IID_IAddressCreator from service:"
75 <<
"RootEventSelector"
81 IDataManagerSvc* eds = 0;
82 sc = serviceLocator()->service(
"EventDataSvc", eds,
true);
83 if( !sc.isSuccess() ) {
85 <<
"Unable to localize interface IID_IDataManagerSvc "
86 <<
"from RootEventSelector"
91 m_rootCLID = eds->rootCLID();
95 log << MSG::INFO <<
"currentFile in RootEvtSelector::initialize "<<m_rootInterface->
getCurrentFileName()<<endreq;
96 if (!m_rootInterface) log << MSG::ERROR <<
"Unable to start Root service within RootCnvSvc" << endreq;
104 ISvcLocator* svcLocator = Gaudi::svcLocator();
105 StatusCode status = svcLocator->service(
"TagFilterSvc",tmpSvc);
106 if (status.isSuccess()) {
107 log << MSG::INFO <<
"get the TagFilterSvc" << endreq;
110 log << MSG::WARNING <<
"could not get the TagFilterSvc. Ignore it." << endreq;
115 vector<string> dstFiles = m_tagFilterSvc->
getDstFiles();
116 int size = dstFiles.size();
117 std::string treeName=
"Event";
119 for(
int i=0;i<size;i++)
121 std::cout<<
"RootEvtSelector, dstFile: "<<dstFiles[i]<<std::endl;
122 m_rootInterface->
addInput(treeName, dstFiles[i].c_str());
129 MsgStream log(
msgSvc(), name());
130 m_criteria = criteria;
132 if( criteria ==
"ROOT" ) {
133 log << MSG::INFO <<
"RootEvtSelector input has been set to ROOT" << endreq;
134 m_criteriaType =
ROOT;
135 }
else if( criteria ==
"NONE"){
136 m_criteriaType = NONE;
137 log << MSG::INFO <<
"RootEvtSelector input has been set to NONE" << endreq;
140 log << MSG::ERROR <<
"Invalid Event Selection Criteria: " << criteria << endreq;
141 return StatusCode::FAILURE;
143 return StatusCode::SUCCESS;
150 return(StatusCode::SUCCESS);
162 for (
int i = 0; i < jump; ++i ) {
163 StatusCode status =
next(ctxt);
164 if ( !status.isSuccess() ) {
168 return StatusCode::SUCCESS;
170 return StatusCode::FAILURE;
174 MsgStream log(messageService(), name());
175 log << MSG::ERROR <<
"RootEvtSelector::previous() not implemented" << endreq;
176 return(StatusCode::FAILURE);
184 if (it.identifier() == p_endContext->
identifier()) {
185 MsgStream log(messageService(), name());
186 log << MSG::DEBUG <<
"last(): Last event in InputStream." <<endreq;
187 return(StatusCode::SUCCESS);
189 return (StatusCode::FAILURE);
193 return(StatusCode::SUCCESS);
198 MsgStream log(messageService(), name());
199 log << MSG::ERROR <<
"RootEvtSelector::rewind() not implemented" << endreq;
200 return(StatusCode::FAILURE);
205 return(StatusCode::SUCCESS);
209 IOpaqueAddress*& iop)
const {
211 return(StatusCode::SUCCESS);
216 MsgStream log(messageService(), name());
217 static std::string tempFile =
"";
220 static std::string tagFile;
222 static std::vector<int> ventry;
230 log << MSG::DEBUG<<
"temp file: "<<tempFile<<endreq;
233 log << MSG::DEBUG<<
"num1: "<<
num1<<
" num2: "<<num2<<endreq;
235 log << MSG::DEBUG <<
"tag file: "<<tagFile<<endreq;
236 m_tagFilterSvc->
getVEntry(tagFile, ventry);
240 log << MSG::DEBUG<<
"ventry i: "<<i<<endreq;
241 log << MSG::DEBUG<<
"ventry size: "<<ventry.size()<<endreq;
244 (*m_recId)=ventry[i];
245 log << MSG::DEBUG<<
"ventry[i]: "<<ventry[i]<<endreq;
250 log << MSG::DEBUG<<
"(*m_recId): "<<(*m_recId)<<endreq;
252 int vs = ventry.size();
254 if( (i>(vs-1)) && (
num1<(num2-1)))
259 if( (i>(vs-1)) && (
num1==(num2-1)))
265 MsgStream log(
msgSvc(), name());
266 if(m_criteriaType ==
ROOT)
268 log<<MSG::INFO<<
"m_criteriaType == ROOT"<<endreq;
273 return StatusCode::FAILURE;
284 static int entry = 0;
286 bool endOfFile = m_rootInterface->
getEOF();
289 if(maxEntry) entry =1;
290 log<<MSG::INFO<<
"entry = "<<entry<<
" "<<maxEntry<<
" "<<endOfFile<<endreq;
291 if(endOfFile || maxEntry){
295 return StatusCode::FAILURE;
301 else if( m_criteriaType == NONE)
303 log << MSG::DEBUG <<
"Reading Event " << (*m_recId) << endreq;
305 if((*m_recId) > m_evtMax) {
306 return StatusCode::FAILURE;
310 log << MSG::FATAL <<
"Cannot iterate a dead iterator" << endreq;
311 return StatusCode::FAILURE;
314 log << MSG::DEBUG <<
"Reading Event " << (*m_recId) << endreq;
315 log << MSG::DEBUG <<
"Max Event " << m_evtMax << endreq;
316 return StatusCode::SUCCESS;
320 if ( riid == IID_IRootEvtSelector ) {
323 else if ( riid == IEvtSelector::interfaceID() ) {
324 *ppvInterface = (IEvtSelector*)
this;
326 else if ( riid == IProperty::interfaceID() ) {
327 *ppvInterface = (IProperty*)
this;
330 return Service::queryInterface( riid, ppvInterface );
336StatusCode RootEvtSelector::getMaxEvent() {
337 IProperty* appPropMgr=0;
339 serviceLocator()->getService(
"ApplicationMgr", IProperty::interfaceID(),
340 reinterpret_cast<IInterface*&
>( appPropMgr ));
341 if( status.isFailure() )
return status;
343 IntegerProperty evtMax(
"EvtMax",0);
344 status = appPropMgr->getProperty( &evtMax );
345 if (status.isFailure())
return status;
347 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 createContext(Context *&it) const
virtual StatusCode initialize()
void getEntryFromTag() const
virtual StatusCode createAddress(const Context &it, IOpaqueAddress *&iop) const
virtual StatusCode rewind(Context &it) const
virtual StatusCode previous(Context &it) const
virtual StatusCode resetCriteria(const std::string &criteria, Context &context) const
virtual StatusCode releaseContext(Context *&it) const
virtual StatusCode last(Context &it) const
virtual int getTotalFileNum()
virtual bool getSelectFromTag()
virtual bool checkEndOfTree()
check if all the files is over 2005-11-28
virtual Int_t getEntries()
get nr of entries
virtual void setTagInputFile(std::vector< std::string > input)
virtual bool getEOF()
get EOF flag
virtual StatusCode addInput(const std::string &treename, const std::string &file)
add input tree to the list
static RootInterface * Instance(MsgStream log)
singleton behaviour
virtual std::vector< std::string > getTagInputFile()
virtual int getCurrentFileNum()
virtual std::string getCurrentFileName()
vector< string > getTagFiles()
vector< string > getDstFiles()
StatusCode getVEntry(string, vector< int > &)