BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
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
 

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.11 2008/01/09 00:05:48 codeman Exp

Definition at line 27 of file RootEvtSelector.h.

Constructor & Destructor Documentation

◆ RootEvtSelector()

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

Definition at line 23 of file RootEvtSelector.cxx.

24 : Service( name, svcloc),
25 p_beginContext(0),
26 p_endContext(0) {
27 m_recId = new int;
28 (*m_recId) = -1;
29 declareProperty( "Input", m_jobInput="ROOT");
30 getMaxEvent();
31}

◆ ~RootEvtSelector()

RootEvtSelector::~RootEvtSelector ( )

Definition at line 32 of file RootEvtSelector.cxx.

32 {
33 delete m_recId;
34}

Member Function Documentation

◆ createAddress()

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

Definition at line 167 of file RootEvtSelector.cxx.

168 {
169 iop = new GenericAddress(ROOT_StorageType, CLID_Event, " ", " ", 0);
170 return(StatusCode::SUCCESS);
171}
const CLID & CLID_Event
Definition: EventModel.cxx:189
const long int ROOT_StorageType

◆ createContext()

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

Definition at line 106 of file RootEvtSelector.cxx.

107{
108 it = p_beginContext;
109 return(StatusCode::SUCCESS);
110}

◆ getRecId()

int RootEvtSelector::getRecId ( ) const
inline

Definition at line 59 of file RootEvtSelector.h.

59{ return (*m_recId); }

Referenced by RootCnvSvc::createAddress(), RootEventBaseCnv::createObj(), and RootCnvSvc::updateServiceState().

◆ initialize()

StatusCode RootEvtSelector::initialize ( )
virtual

Definition at line 37 of file RootEvtSelector.cxx.

37 {
38 MsgStream log(msgSvc(), name());
39 StatusCode sc = Service::initialize();
40 log << MSG::DEBUG << "RootEvtSelector::initialize" << endreq; if( sc.isSuccess() ) {
41 setProperties();
42 } else {
43 log << MSG::ERROR << "Unable to initialize service " << endreq;
44 }
45
46 if(m_jobInput.value() != " "){
47 sc = setCriteria(m_jobInput);
48 if(sc.isFailure()){
49 log << MSG::ERROR << "Unable to get input value" << endreq;
50 return sc;
51 }
52 }
53
54 // Retrieve conversion service handling event iteration
55 sc = serviceLocator()->service("EventCnvSvc", m_addrCreator);
56 if( !sc.isSuccess() ) {
57 log << MSG::ERROR <<
58 "Unable to localize interface IID_IAddressCreator from service:"
59 << "RootEventSelector"
60 << endreq;
61 return sc;
62 }
63 // Get DataSvc
64 IDataManagerSvc* eds = 0;
65 sc = serviceLocator()->service("EventDataSvc", eds, true);
66 if( !sc.isSuccess() ) {
67 log << MSG::ERROR
68 << "Unable to localize interface IID_IDataManagerSvc "
69 << "from RootEventSelector"
70 << endreq;
71 return sc;
72 }
73
74 m_rootCLID = eds->rootCLID();
75
76 // provide access to the Root Interface
77 m_rootInterface=RootInterface::Instance(log);
78 if (!m_rootInterface) log << MSG::ERROR << "Unable to start Root service within RootCnvSvc" << endreq;
79
80 // create root event context
81 p_beginContext = new RootEventContext(this);
82
83 return sc;
84}
IMessageSvc * msgSvc()
This class provides the Context for RootEventSelector.
virtual StatusCode setCriteria(const std::string &criteria)
static RootInterface * Instance(MsgStream log)
singleton behaviour

◆ last()

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

Definition at line 142 of file RootEvtSelector.cxx.

142 {
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);
147 }
148 return (StatusCode::FAILURE);
149}
virtual void * identifier() const
Inequality operator.

◆ next() [1/3]

StatusCode RootEvtSelector::next ( ) const

Definition at line 174 of file RootEvtSelector.cxx.

174 {
175 MsgStream log(msgSvc(), name());
176
177 if(m_criteriaType == ROOT)
178 {
179 log<<MSG::INFO<<"m_criteriaType == ROOT"<<endreq;
180 (*m_recId)++;
181
182 //if((*m_recId)>m_evtMax){ // if get the max event number?
183 // return StatusCode::FAILURE;
184 //}else{ //didn't get the max event number
185 static int entry = 0;
186
187 bool endOfFile = m_rootInterface->getEOF();
188 entry++;
189 bool maxEntry = (entry >m_rootInterface->getEntries() && m_rootInterface->getEntries()>=0);
190 if(maxEntry) entry =1;
191 log<<MSG::INFO<<"entry = "<<entry<<" "<<maxEntry<<" "<<endOfFile<<endreq;
192 if(endOfFile || maxEntry){ //the using file is get max event or get the end of file
193 bool endAll = m_rootInterface->checkEndOfTree();
194
195 if(endAll){ //if all is finished ?
196 return StatusCode::FAILURE;
197 }
198 }
199 //} // to make it run if not set event number from jobOption
200 }
201 else if( m_criteriaType == NONE)
202 {
203 log << MSG::DEBUG << "Reading Event " << (*m_recId) << endreq;
204 //If we go over the count set equal to the end
205 if((*m_recId) > m_evtMax) {
206 return StatusCode::FAILURE;
207 }
208 }else {
209 //We are going to blow up if this situation happens
210 log << MSG::FATAL << "Cannot iterate a dead iterator" << endreq;
211 return StatusCode::FAILURE;
212 }
213 log << MSG::DEBUG << "Reading Event " << (*m_recId) << endreq;
214 log << MSG::DEBUG << "Max Event " << m_evtMax << endreq;
215 return StatusCode::SUCCESS;
216}
virtual bool checkEndOfTree()
check if all the files is over 2005-11-28
virtual Int_t getEntries()
get nr of entries
Definition: RootInterface.h:51
virtual bool getEOF()
get EOF flag
Definition: RootInterface.h:49

◆ next() [2/3]

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

◆ next() [3/3]

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

◆ previous() [1/2]

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

◆ previous() [2/2]

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

◆ queryInterface()

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

Definition at line 218 of file RootEvtSelector.cxx.

218 {
219 if ( riid == IID_IRootEvtSelector ) {
220 *ppvInterface = (RootEvtSelector*)this;
221 }
222 else if ( riid == IEvtSelector::interfaceID() ) {
223 *ppvInterface = (IEvtSelector*)this;
224 }
225 else if ( riid == IProperty::interfaceID() ) {
226 *ppvInterface = (IProperty*)this;
227 }
228 else {
229 return Service::queryInterface( riid, ppvInterface );
230 }
231 addRef();
232 return SUCCESS;
233}
RootEvtSelector performs the function of controlling the ApplicationMgr loop.

◆ releaseContext()

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

Definition at line 163 of file RootEvtSelector.cxx.

163 {
164 return(StatusCode::SUCCESS);
165}

◆ resetCriteria()

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

Definition at line 151 of file RootEvtSelector.cxx.

151 {
152 return(StatusCode::SUCCESS);
153}

◆ rewind()

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

Definition at line 156 of file RootEvtSelector.cxx.

156 {
157 MsgStream log(messageService(), name());
158 log << MSG::ERROR << "RootEvtSelector::rewind() not implemented" << endreq;
159 return(StatusCode::FAILURE);
160}

◆ setCriteria()

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

Definition at line 86 of file RootEvtSelector.cxx.

86 {
87 // Purpose and Method: set the input criteria
88 MsgStream log(msgSvc(), name());
89 m_criteria = criteria;
90
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;
97 }
98 else {
99 log << MSG::ERROR << "Invalid Event Selection Criteria: " << criteria << endreq;
100 return StatusCode::FAILURE;
101 }
102 return StatusCode::SUCCESS;
103}

Referenced by initialize().


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