BOSS 7.0.4
BESIII Offline Software System
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RootEvtSelector Class Reference

RootEvtSelector performs the function of controlling the ApplicationMgr loop. More...

#include <RootEvtSelector.h>

+ Inheritance diagram for RootEvtSelector:

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
 
 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
 

Detailed Description

RootEvtSelector performs the function of controlling the ApplicationMgr loop.

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.

Header
/bes/bes/BossCvs/Event/RootCnvSvc/RootCnvSvc/RootEvtSelector.h,v 1.14 2015/06/14 23:47:16 dengzy Exp

Definition at line 29 of file Event/RootCnvSvc/RootCnvSvc-02-01-13/RootCnvSvc/RootEvtSelector.h.

Constructor & Destructor Documentation

◆ RootEvtSelector() [1/2]

RootEvtSelector::RootEvtSelector ( const std::string &  name,
ISvcLocator *  svcloc 
)

Definition at line 37 of file RootEvtSelector.cxx.

38 : Service( name, svcloc),
39 p_beginContext(0),
40 p_endContext(0) {
41 m_recId = new int;
42 (*m_recId) = -1;
43 declareProperty( "Input", m_jobInput="ROOT");
44 getMaxEvent();
45}

◆ ~RootEvtSelector() [1/2]

RootEvtSelector::~RootEvtSelector ( )

Definition at line 46 of file RootEvtSelector.cxx.

46 {
47 delete m_recId;
48}

◆ RootEvtSelector() [2/2]

RootEvtSelector::RootEvtSelector ( const std::string &  name,
ISvcLocator *  svcloc 
)

◆ ~RootEvtSelector() [2/2]

RootEvtSelector::~RootEvtSelector ( )

Member Function Documentation

◆ createAddress() [1/2]

virtual StatusCode RootEvtSelector::createAddress ( const Context &  it,
IOpaqueAddress *&  iop 
) const
virtual

◆ createAddress() [2/2]

virtual StatusCode RootEvtSelector::createAddress ( const Context &  it,
IOpaqueAddress *&  iop 
) const
virtual

◆ createContext() [1/2]

virtual StatusCode RootEvtSelector::createContext ( Context *&  it) const
virtual

◆ createContext() [2/2]

virtual StatusCode RootEvtSelector::createContext ( Context *&  it) const
virtual

◆ getEntryFromTag() [1/2]

void RootEvtSelector::getEntryFromTag ( ) const

Definition at line 212 of file RootEvtSelector.cxx.

212 {
213 bool flag=true;;
214 MsgStream log(messageService(), name());
215 static std::string tempFile = "";
216 log << MSG::DEBUG <<"current file: "<<m_rootInterface->getCurrentFileName()<<endreq;
217 std::ifstream fin;
218 static std::string tagFile;
219 static int i=-1;
220 static std::vector<int> ventry;
221 int num1 = m_rootInterface->getCurrentFileNum();
222 int num2 = m_rootInterface->getTotalFileNum();
223
224
225 if(tempFile != m_rootInterface->getCurrentFileName())
226 {
227 tempFile = m_rootInterface->getCurrentFileName();
228 log << MSG::DEBUG<<"temp file: "<<tempFile<<endreq;
229 i=-1;
230 ventry.clear();
231 log << MSG::DEBUG<<"num1: "<<num1<<" num2: "<<num2<<endreq;
232 tagFile = (m_rootInterface->getTagInputFile())[num1];
233 log << MSG::DEBUG <<"tag file: "<<tagFile<<endreq;
234 m_tagFilterSvc->getVEntry(tagFile, ventry);
235 } //end of read a tag file
236
237 i++;
238 log << MSG::DEBUG<<"ventry i: "<<i<<endreq;
239 log << MSG::DEBUG<<"ventry size: "<<ventry.size()<<endreq;
240 if(i<ventry.size())
241 {
242 (*m_recId)=ventry[i];
243 log << MSG::DEBUG<<"ventry[i]: "<<ventry[i]<<endreq;
244 }
245 else
246 (*m_recId)= -1;
247
248 log << MSG::DEBUG<<"(*m_recId): "<<(*m_recId)<<endreq;
249
250 int vs = ventry.size();
251
252 if( (i>(vs-1)) && (num1<(num2-1)))
253 {
254 bool endAll = m_rootInterface->checkEndOfTree();
256 }
257 if( (i>(vs-1)) && (num1==(num2-1)))
258 (*m_recId)= -1;
259}
void getEntryFromTag() const
virtual bool checkEndOfTree()
check if all the files is over 2005-11-28
virtual std::vector< std::string > getTagInputFile()
StatusCode getVEntry(string, vector< int > &)

Referenced by getEntryFromTag(), and next().

◆ getEntryFromTag() [2/2]

void RootEvtSelector::getEntryFromTag ( ) const

◆ getRecId() [1/2]

int RootEvtSelector::getRecId ( ) const
inline

◆ getRecId() [2/2]

int RootEvtSelector::getRecId ( ) const
inline

Definition at line 61 of file InstallArea/include/RootCnvSvc/RootCnvSvc/RootEvtSelector.h.

61{ return (*m_recId); }

◆ initialize() [1/2]

StatusCode RootEvtSelector::initialize ( )
virtual

Definition at line 51 of file RootEvtSelector.cxx.

51 {
52 MsgStream log(msgSvc(), name());
53 StatusCode sc = Service::initialize();
54 log << MSG::DEBUG << "RootEvtSelector::initialize" << endreq; if( sc.isSuccess() ) {
55 setProperties();
56 } else {
57 log << MSG::ERROR << "Unable to initialize service " << endreq;
58 }
59
60 if(m_jobInput.value() != " "){
61 sc = setCriteria(m_jobInput);
62 if(sc.isFailure()){
63 log << MSG::ERROR << "Unable to get input value" << endreq;
64 return sc;
65 }
66 }
67
68 // Retrieve conversion service handling event iteration
69 sc = serviceLocator()->service("EventCnvSvc", m_addrCreator);
70 if( !sc.isSuccess() ) {
71 log << MSG::ERROR <<
72 "Unable to localize interface IID_IAddressCreator from service:"
73 << "RootEventSelector"
74 << endreq;
75 return sc;
76 }
77
78 // Get DataSvc
79 IDataManagerSvc* eds = 0;
80 sc = serviceLocator()->service("EventDataSvc", eds, true);
81 if( !sc.isSuccess() ) {
82 log << MSG::ERROR
83 << "Unable to localize interface IID_IDataManagerSvc "
84 << "from RootEventSelector"
85 << endreq;
86 return sc;
87 }
88
89 m_rootCLID = eds->rootCLID();
90
91 // provide access to the Root Interface
92 m_rootInterface=RootInterface::Instance(log);
93 log << MSG::INFO << "currentFile in RootEvtSelector::initialize "<<m_rootInterface->getCurrentFileName()<<endreq;
94 if (!m_rootInterface) log << MSG::ERROR << "Unable to start Root service within RootCnvSvc" << endreq;
95
96 // create root event context
97 p_beginContext = new RootEventContext(this);
98
99
100 ITagFilterSvc *tmpSvc;
101
102 ISvcLocator* svcLocator = Gaudi::svcLocator();
103 StatusCode status = svcLocator->service("TagFilterSvc",tmpSvc);
104 if (status.isSuccess()) {
105 log << MSG::INFO << "get the TagFilterSvc" << endreq;
106 m_tagFilterSvc=dynamic_cast<TagFilterSvc *>(tmpSvc);
107 }else {
108 log << MSG::WARNING << "could not get the TagFilterSvc. Ignore it." << endreq;
109 }
110
111 m_rootInterface->setTagInputFile(m_tagFilterSvc->getTagFiles());
112
113 vector<string> dstFiles = m_tagFilterSvc->getDstFiles();
114 int size = dstFiles.size();
115 std::string treeName="Event";
116
117 for(int i=0;i<size;i++)
118 {
119 std::cout<<"RootEvtSelector, dstFile: "<<dstFiles[i]<<std::endl;
120 m_rootInterface->addInput(treeName, dstFiles[i].c_str());
121 }
122 return sc;
123}
This class provides the Context for RootEventSelector.
virtual StatusCode setCriteria(const std::string &criteria)
virtual void setTagInputFile(std::vector< std::string > input)
virtual StatusCode addInput(const std::string &treename, const std::string &file)
add input tree to the list
static RootInterface * Instance(MsgStream log)
singleton behaviour
vector< string > getDstFiles()
char * c_str(Index i)
Definition: EvtCyclic3.cc:252

◆ initialize() [2/2]

virtual StatusCode RootEvtSelector::initialize ( )
virtual

◆ last() [1/2]

virtual StatusCode RootEvtSelector::last ( Context &  it) const
virtual

◆ last() [2/2]

virtual StatusCode RootEvtSelector::last ( Context &  it) const
virtual

◆ next() [1/6]

StatusCode RootEvtSelector::next ( ) const

Definition at line 262 of file RootEvtSelector.cxx.

262 {
263 MsgStream log(msgSvc(), name());
264 if(m_criteriaType == ROOT)
265 {
266 log<<MSG::INFO<<"m_criteriaType == ROOT"<<endreq;
267 if(m_rootInterface->getSelectFromTag()!=0)
268 {
270 if((*m_recId)<0)
271 return StatusCode::FAILURE;
272 }
273
274 else
275 {
276 (*m_recId)++;
277
278 //if((*m_recId)>m_evtMax){ // if get the max event number?
279 // return StatusCode::FAILURE;
280 //}else{ //didn't get the max event number
281
282 static int entry = 0;
283
284 bool endOfFile = m_rootInterface->getEOF();
285 entry++;
286 bool maxEntry = (entry >m_rootInterface->getEntries() && m_rootInterface->getEntries()>=0);
287 if(maxEntry) entry =1;
288 log<<MSG::INFO<<"entry = "<<entry<<" "<<maxEntry<<" "<<endOfFile<<endreq;
289 if(endOfFile || maxEntry){ //the using file is get max event or get the end of file
290 bool endAll = m_rootInterface->checkEndOfTree();
291
292 if(endAll){ //if all is finished ?
293 return StatusCode::FAILURE;
294 }
295 }
296 }
297 //} // to make it run if not set event number from jobOption
298 }// end if(m_criteriaType == ROOT)
299 else if( m_criteriaType == NONE)
300 {
301 log << MSG::DEBUG << "Reading Event " << (*m_recId) << endreq;
302 //If we go over the count set equal to the end
303 if((*m_recId) > m_evtMax) {
304 return StatusCode::FAILURE;
305 }
306 }else {
307 //We are going to blow up if this situation happens
308 log << MSG::FATAL << "Cannot iterate a dead iterator" << endreq;
309 return StatusCode::FAILURE;
310 }
311
312 log << MSG::DEBUG << "Reading Event " << (*m_recId) << endreq;
313 log << MSG::DEBUG << "Max Event " << m_evtMax << endreq;
314 return StatusCode::SUCCESS;
315}

◆ next() [2/6]

StatusCode RootEvtSelector::next ( ) const

◆ next() [3/6]

virtual StatusCode RootEvtSelector::next ( Context &  it) const
virtual

◆ next() [4/6]

virtual StatusCode RootEvtSelector::next ( Context &  it) const
virtual

◆ next() [5/6]

virtual StatusCode RootEvtSelector::next ( Context &  it,
int  jump 
) const
virtual

◆ next() [6/6]

virtual StatusCode RootEvtSelector::next ( Context &  it,
int  jump 
) const
virtual

◆ previous() [1/4]

virtual StatusCode RootEvtSelector::previous ( Context &  it) const
virtual

◆ previous() [2/4]

virtual StatusCode RootEvtSelector::previous ( Context &  it) const
virtual

◆ previous() [3/4]

virtual StatusCode RootEvtSelector::previous ( Context &  it,
int  jump 
) const
virtual

◆ previous() [4/4]

virtual StatusCode RootEvtSelector::previous ( Context &  it,
int  jump 
) const
virtual

◆ queryInterface() [1/2]

StatusCode RootEvtSelector::queryInterface ( const InterfaceID &  riid,
void **  ppvInterface 
)
virtual

Definition at line 317 of file RootEvtSelector.cxx.

317 {
318 if ( riid == IID_IRootEvtSelector ) {
319 *ppvInterface = (RootEvtSelector*)this;
320 }
321 else if ( riid == IEvtSelector::interfaceID() ) {
322 *ppvInterface = (IEvtSelector*)this;
323 }
324 else if ( riid == IProperty::interfaceID() ) {
325 *ppvInterface = (IProperty*)this;
326 }
327 else {
328 return Service::queryInterface( riid, ppvInterface );
329 }
330 addRef();
331 return SUCCESS;
332}
RootEvtSelector performs the function of controlling the ApplicationMgr loop.

◆ queryInterface() [2/2]

virtual StatusCode RootEvtSelector::queryInterface ( const InterfaceID &  riid,
void **  ppvInterface 
)
virtual

◆ releaseContext() [1/2]

virtual StatusCode RootEvtSelector::releaseContext ( Context *&  it) const
virtual

◆ releaseContext() [2/2]

virtual StatusCode RootEvtSelector::releaseContext ( Context *&  it) const
virtual

◆ resetCriteria() [1/2]

virtual StatusCode RootEvtSelector::resetCriteria ( const std::string &  criteria,
Context &  context 
) const
virtual

◆ resetCriteria() [2/2]

virtual StatusCode RootEvtSelector::resetCriteria ( const std::string &  criteria,
Context &  context 
) const
virtual

◆ rewind() [1/2]

virtual StatusCode RootEvtSelector::rewind ( Context &  it) const
virtual

◆ rewind() [2/2]

virtual StatusCode RootEvtSelector::rewind ( Context &  it) const
virtual

◆ setCriteria() [1/2]

StatusCode RootEvtSelector::setCriteria ( const std::string &  criteria)
virtual

Definition at line 125 of file RootEvtSelector.cxx.

125 {
126 // Purpose and Method: set the input criteria
127 MsgStream log(msgSvc(), name());
128 m_criteria = criteria;
129
130 if( criteria == "ROOT" ) {
131 log << MSG::INFO << "RootEvtSelector input has been set to ROOT" << endreq;
132 m_criteriaType = ROOT;
133 }else if( criteria == "NONE"){
134 m_criteriaType = NONE;
135 log << MSG::INFO << "RootEvtSelector input has been set to NONE" << endreq;
136 }
137 else {
138 log << MSG::ERROR << "Invalid Event Selection Criteria: " << criteria << endreq;
139 return StatusCode::FAILURE;
140 }
141 return StatusCode::SUCCESS;
142}

Referenced by initialize().

◆ setCriteria() [2/2]

virtual StatusCode RootEvtSelector::setCriteria ( const std::string &  criteria)
virtual

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