#include <RootEvtSelector.h>
Public Member Functions | |
RootEvtSelector (const std::string &name, ISvcLocator *svcloc) | |
~RootEvtSelector () | |
virtual StatusCode | initialize () |
virtual StatusCode | createContext (Context *&it) const |
StatusCode | next () const |
virtual StatusCode | next (Context &it) const |
virtual StatusCode | next (Context &it, int jump) const |
virtual StatusCode | previous (Context &it) const |
virtual StatusCode | previous (Context &it, int jump) const |
virtual StatusCode | last (Context &it) const |
virtual StatusCode | rewind (Context &it) const |
virtual StatusCode | createAddress (const Context &it, IOpaqueAddress *&iop) const |
virtual StatusCode | releaseContext (Context *&it) const |
virtual StatusCode | resetCriteria (const std::string &criteria, Context &context) const |
virtual StatusCode | setCriteria (const std::string &criteria) |
virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvInterface) |
int | getRecId () const |
void | getEntryFromTag () const |
Private Types | |
ROOT | |
NONE | |
enum | CriteriaType { ROOT, NONE } |
Private Member Functions | |
StatusCode | getMaxEvent () |
Private Attributes | |
RootEventContext * | p_beginContext |
RootEventContext * | p_endContext |
std::string | m_criteria |
StringProperty | m_jobInput |
CriteriaType | m_criteriaType |
RootInterface * | m_rootInterface |
IAddressCreator * | m_addrCreator |
CLID | m_rootCLID |
int | m_evtMax |
max nr of events to be treated | |
int * | m_recId |
counts number of event | |
TagFilterSvc * | m_tagFilterSvc |
Adapted to RootCnvSvc from GlastSvc/EventSelector. The input property can now be set either to NONE or to ROOT. If it is NONE, the loop will run until it hits EvtMax. A new class variable was added :m_evtMax which is a local copy of the AppMgrs property.
Definition at line 29 of file RootEvtSelector.h.
enum RootEvtSelector::CriteriaType [private] |
RootEvtSelector::RootEvtSelector | ( | const std::string & | name, | |
ISvcLocator * | svcloc | |||
) |
Definition at line 37 of file RootEvtSelector.cxx.
References getMaxEvent(), m_jobInput, and m_recId.
00038 : Service( name, svcloc), 00039 p_beginContext(0), 00040 p_endContext(0) { 00041 m_recId = new int; 00042 (*m_recId) = -1; 00043 declareProperty( "Input", m_jobInput="ROOT"); 00044 getMaxEvent(); 00045 }
RootEvtSelector::~RootEvtSelector | ( | ) |
Definition at line 46 of file RootEvtSelector.cxx.
References m_recId.
00046 { 00047 delete m_recId; 00048 }
virtual StatusCode RootEvtSelector::createAddress | ( | const Context & | it, | |
IOpaqueAddress *& | iop | |||
) | const [virtual] |
virtual StatusCode RootEvtSelector::createContext | ( | Context *& | it | ) | const [virtual] |
void RootEvtSelector::getEntryFromTag | ( | ) | const |
Definition at line 212 of file RootEvtSelector.cxx.
References RootInterface::checkEndOfTree(), Bes_Common::DEBUG, RootInterface::getCurrentFileName(), RootInterface::getCurrentFileNum(), RootInterface::getTagInputFile(), RootInterface::getTotalFileNum(), TagFilterSvc::getVEntry(), genRecEmupikp::i, m_recId, m_rootInterface, m_tagFilterSvc, num1, and deljobs::string.
Referenced by next().
00212 { 00213 bool flag=true;; 00214 MsgStream log(messageService(), name()); 00215 static std::string tempFile = ""; 00216 log << MSG::DEBUG <<"current file: "<<m_rootInterface->getCurrentFileName()<<endreq; 00217 std::ifstream fin; 00218 static std::string tagFile; 00219 static int i=-1; 00220 static std::vector<int> ventry; 00221 int num1 = m_rootInterface->getCurrentFileNum(); 00222 int num2 = m_rootInterface->getTotalFileNum(); 00223 00224 00225 if(tempFile != m_rootInterface->getCurrentFileName()) 00226 { 00227 tempFile = m_rootInterface->getCurrentFileName(); 00228 log << MSG::DEBUG<<"temp file: "<<tempFile<<endreq; 00229 i=-1; 00230 ventry.clear(); 00231 log << MSG::DEBUG<<"num1: "<<num1<<" num2: "<<num2<<endreq; 00232 tagFile = (m_rootInterface->getTagInputFile())[num1]; 00233 log << MSG::DEBUG <<"tag file: "<<tagFile<<endreq; 00234 m_tagFilterSvc->getVEntry(tagFile, ventry); 00235 } //end of read a tag file 00236 00237 i++; 00238 log << MSG::DEBUG<<"ventry i: "<<i<<endreq; 00239 log << MSG::DEBUG<<"ventry size: "<<ventry.size()<<endreq; 00240 if(i<ventry.size()) 00241 { 00242 (*m_recId)=ventry[i]; 00243 log << MSG::DEBUG<<"ventry[i]: "<<ventry[i]<<endreq; 00244 } 00245 else 00246 (*m_recId)= -1; 00247 00248 log << MSG::DEBUG<<"(*m_recId): "<<(*m_recId)<<endreq; 00249 00250 int vs = ventry.size(); 00251 00252 if( (i>(vs-1)) && (num1<(num2-1))) 00253 { 00254 bool endAll = m_rootInterface->checkEndOfTree(); 00255 getEntryFromTag(); 00256 } 00257 if( (i>(vs-1)) && (num1==(num2-1))) 00258 (*m_recId)= -1; 00259 }
StatusCode RootEvtSelector::getMaxEvent | ( | ) | [private] |
Definition at line 334 of file RootEvtSelector.cxx.
References m_evtMax.
Referenced by RootEvtSelector().
00334 { 00335 IProperty* appPropMgr=0; 00336 StatusCode status = 00337 serviceLocator()->getService("ApplicationMgr", IProperty::interfaceID(), 00338 reinterpret_cast<IInterface*&>( appPropMgr )); 00339 if( status.isFailure() ) return status; 00340 00341 IntegerProperty evtMax("EvtMax",0); 00342 status = appPropMgr->getProperty( &evtMax ); 00343 if (status.isFailure()) return status; 00344 00345 m_evtMax = evtMax.value(); 00346 return status; 00347 }
int RootEvtSelector::getRecId | ( | ) | const [inline] |
Definition at line 61 of file RootEvtSelector.h.
References m_recId.
Referenced by RootCnvSvc::createAddress(), RootEventBaseCnv::createObj(), and RootCnvSvc::updateServiceState().
00061 { return (*m_recId); }
StatusCode RootEvtSelector::initialize | ( | ) | [virtual] |
Definition at line 51 of file RootEvtSelector.cxx.
References RootInterface::addInput(), EvtCyclic3::c_str(), Bes_Common::DEBUG, calibUtil::ERROR, RootInterface::getCurrentFileName(), TagFilterSvc::getDstFiles(), TagFilterSvc::getTagFiles(), genRecEmupikp::i, Bes_Common::INFO, RootInterface::Instance(), m_addrCreator, m_jobInput, m_rootCLID, m_rootInterface, m_tagFilterSvc, msgSvc(), p_beginContext, setCriteria(), RootInterface::setTagInputFile(), delete_small_size::size, deljobs::string, and Bes_Common::WARNING.
00051 { 00052 MsgStream log(msgSvc(), name()); 00053 StatusCode sc = Service::initialize(); 00054 log << MSG::DEBUG << "RootEvtSelector::initialize" << endreq; if( sc.isSuccess() ) { 00055 setProperties(); 00056 } else { 00057 log << MSG::ERROR << "Unable to initialize service " << endreq; 00058 } 00059 00060 if(m_jobInput.value() != " "){ 00061 sc = setCriteria(m_jobInput); 00062 if(sc.isFailure()){ 00063 log << MSG::ERROR << "Unable to get input value" << endreq; 00064 return sc; 00065 } 00066 } 00067 00068 // Retrieve conversion service handling event iteration 00069 sc = serviceLocator()->service("EventCnvSvc", m_addrCreator); 00070 if( !sc.isSuccess() ) { 00071 log << MSG::ERROR << 00072 "Unable to localize interface IID_IAddressCreator from service:" 00073 << "RootEventSelector" 00074 << endreq; 00075 return sc; 00076 } 00077 00078 // Get DataSvc 00079 IDataManagerSvc* eds = 0; 00080 sc = serviceLocator()->service("EventDataSvc", eds, true); 00081 if( !sc.isSuccess() ) { 00082 log << MSG::ERROR 00083 << "Unable to localize interface IID_IDataManagerSvc " 00084 << "from RootEventSelector" 00085 << endreq; 00086 return sc; 00087 } 00088 00089 m_rootCLID = eds->rootCLID(); 00090 00091 // provide access to the Root Interface 00092 m_rootInterface=RootInterface::Instance(log); 00093 log << MSG::INFO << "currentFile in RootEvtSelector::initialize "<<m_rootInterface->getCurrentFileName()<<endreq; 00094 if (!m_rootInterface) log << MSG::ERROR << "Unable to start Root service within RootCnvSvc" << endreq; 00095 00096 // create root event context 00097 p_beginContext = new RootEventContext(this); 00098 00099 00100 ITagFilterSvc *tmpSvc; 00101 00102 ISvcLocator* svcLocator = Gaudi::svcLocator(); 00103 StatusCode status = svcLocator->service("TagFilterSvc",tmpSvc); 00104 if (status.isSuccess()) { 00105 log << MSG::INFO << "get the TagFilterSvc" << endreq; 00106 m_tagFilterSvc=dynamic_cast<TagFilterSvc *>(tmpSvc); 00107 }else { 00108 log << MSG::WARNING << "could not get the TagFilterSvc. Ignore it." << endreq; 00109 } 00110 00111 m_rootInterface->setTagInputFile(m_tagFilterSvc->getTagFiles()); 00112 00113 vector<string> dstFiles = m_tagFilterSvc->getDstFiles(); 00114 int size = dstFiles.size(); 00115 std::string treeName="Event"; 00116 00117 for(int i=0;i<size;i++) 00118 { 00119 std::cout<<"RootEvtSelector, dstFile: "<<dstFiles[i]<<std::endl; 00120 m_rootInterface->addInput(treeName, dstFiles[i].c_str()); 00121 } 00122 return sc; 00123 }
virtual StatusCode RootEvtSelector::last | ( | Context & | it | ) | const [virtual] |
virtual StatusCode RootEvtSelector::next | ( | Context & | it, | |
int | jump | |||
) | const [virtual] |
virtual StatusCode RootEvtSelector::next | ( | Context & | it | ) | const [virtual] |
StatusCode RootEvtSelector::next | ( | ) | const |
Definition at line 262 of file RootEvtSelector.cxx.
References RootInterface::checkEndOfTree(), Bes_Common::DEBUG, Bes_Common::FATAL, RootInterface::getEntries(), getEntryFromTag(), RootInterface::getEOF(), RootInterface::getSelectFromTag(), Bes_Common::INFO, m_criteriaType, m_evtMax, m_recId, m_rootInterface, msgSvc(), NONE, and ROOT.
00262 { 00263 MsgStream log(msgSvc(), name()); 00264 if(m_criteriaType == ROOT) 00265 { 00266 log<<MSG::INFO<<"m_criteriaType == ROOT"<<endreq; 00267 if(m_rootInterface->getSelectFromTag()!=0) 00268 { 00269 getEntryFromTag(); 00270 if((*m_recId)<0) 00271 return StatusCode::FAILURE; 00272 } 00273 00274 else 00275 { 00276 (*m_recId)++; 00277 00278 //if((*m_recId)>m_evtMax){ // if get the max event number? 00279 // return StatusCode::FAILURE; 00280 //}else{ //didn't get the max event number 00281 00282 static int entry = 0; 00283 00284 bool endOfFile = m_rootInterface->getEOF(); 00285 entry++; 00286 bool maxEntry = (entry >m_rootInterface->getEntries() && m_rootInterface->getEntries()>=0); 00287 if(maxEntry) entry =1; 00288 log<<MSG::INFO<<"entry = "<<entry<<" "<<maxEntry<<" "<<endOfFile<<endreq; 00289 if(endOfFile || maxEntry){ //the using file is get max event or get the end of file 00290 bool endAll = m_rootInterface->checkEndOfTree(); 00291 00292 if(endAll){ //if all is finished ? 00293 return StatusCode::FAILURE; 00294 } 00295 } 00296 } 00297 //} // to make it run if not set event number from jobOption 00298 }// end if(m_criteriaType == ROOT) 00299 else if( m_criteriaType == NONE) 00300 { 00301 log << MSG::DEBUG << "Reading Event " << (*m_recId) << endreq; 00302 //If we go over the count set equal to the end 00303 if((*m_recId) > m_evtMax) { 00304 return StatusCode::FAILURE; 00305 } 00306 }else { 00307 //We are going to blow up if this situation happens 00308 log << MSG::FATAL << "Cannot iterate a dead iterator" << endreq; 00309 return StatusCode::FAILURE; 00310 } 00311 00312 log << MSG::DEBUG << "Reading Event " << (*m_recId) << endreq; 00313 log << MSG::DEBUG << "Max Event " << m_evtMax << endreq; 00314 return StatusCode::SUCCESS; 00315 }
virtual StatusCode RootEvtSelector::previous | ( | Context & | it, | |
int | jump | |||
) | const [virtual] |
virtual StatusCode RootEvtSelector::previous | ( | Context & | it | ) | const [virtual] |
StatusCode RootEvtSelector::queryInterface | ( | const InterfaceID & | riid, | |
void ** | ppvInterface | |||
) | [virtual] |
Definition at line 317 of file RootEvtSelector.cxx.
References IID_IRootEvtSelector().
00317 { 00318 if ( riid == IID_IRootEvtSelector ) { 00319 *ppvInterface = (RootEvtSelector*)this; 00320 } 00321 else if ( riid == IEvtSelector::interfaceID() ) { 00322 *ppvInterface = (IEvtSelector*)this; 00323 } 00324 else if ( riid == IProperty::interfaceID() ) { 00325 *ppvInterface = (IProperty*)this; 00326 } 00327 else { 00328 return Service::queryInterface( riid, ppvInterface ); 00329 } 00330 addRef(); 00331 return SUCCESS; 00332 }
virtual StatusCode RootEvtSelector::releaseContext | ( | Context *& | it | ) | const [virtual] |
virtual StatusCode RootEvtSelector::resetCriteria | ( | const std::string & | criteria, | |
Context & | context | |||
) | const [virtual] |
virtual StatusCode RootEvtSelector::rewind | ( | Context & | it | ) | const [virtual] |
StatusCode RootEvtSelector::setCriteria | ( | const std::string & | criteria | ) | [virtual] |
Definition at line 125 of file RootEvtSelector.cxx.
References calibUtil::ERROR, Bes_Common::INFO, m_criteria, m_criteriaType, msgSvc(), NONE, and ROOT.
Referenced by initialize().
00125 { 00126 // Purpose and Method: set the input criteria 00127 MsgStream log(msgSvc(), name()); 00128 m_criteria = criteria; 00129 00130 if( criteria == "ROOT" ) { 00131 log << MSG::INFO << "RootEvtSelector input has been set to ROOT" << endreq; 00132 m_criteriaType = ROOT; 00133 }else if( criteria == "NONE"){ 00134 m_criteriaType = NONE; 00135 log << MSG::INFO << "RootEvtSelector input has been set to NONE" << endreq; 00136 } 00137 else { 00138 log << MSG::ERROR << "Invalid Event Selection Criteria: " << criteria << endreq; 00139 return StatusCode::FAILURE; 00140 } 00141 return StatusCode::SUCCESS; 00142 }
IAddressCreator* RootEvtSelector::m_addrCreator [private] |
std::string RootEvtSelector::m_criteria [private] |
CriteriaType RootEvtSelector::m_criteriaType [private] |
int RootEvtSelector::m_evtMax [private] |
max nr of events to be treated
Definition at line 92 of file RootEvtSelector.h.
Referenced by getMaxEvent(), and next().
StringProperty RootEvtSelector::m_jobInput [private] |
int* RootEvtSelector::m_recId [private] |
counts number of event
Definition at line 95 of file RootEvtSelector.h.
Referenced by getEntryFromTag(), getRecId(), next(), RootEvtSelector(), and ~RootEvtSelector().
CLID RootEvtSelector::m_rootCLID [private] |
RootInterface* RootEvtSelector::m_rootInterface [private] |
Definition at line 83 of file RootEvtSelector.h.
Referenced by getEntryFromTag(), initialize(), and next().
TagFilterSvc* RootEvtSelector::m_tagFilterSvc [private] |
RootEventContext* RootEvtSelector::p_beginContext [private] |
RootEventContext* RootEvtSelector::p_endContext [private] |
Definition at line 76 of file RootEvtSelector.h.