BOSS 8.0.0
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
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
 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.17 2022/01/24 04:07:17 maqm Exp $

Definition at line 31 of file Event/RootCnvSvc/include/RootCnvSvc/RootEvtSelector.h.

Constructor & Destructor Documentation

◆ RootEvtSelector() [1/3]

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

Definition at line 38 of file RootEvtSelector.cxx.

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

Referenced by queryInterface(), and RootEvtSelector().

◆ ~RootEvtSelector() [1/3]

RootEvtSelector::~RootEvtSelector ( )

Definition at line 45 of file RootEvtSelector.cxx.

45{ delete m_recId; }

◆ RootEvtSelector() [2/3]

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

◆ ~RootEvtSelector() [2/3]

RootEvtSelector::~RootEvtSelector ( )

◆ RootEvtSelector() [3/3]

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

◆ ~RootEvtSelector() [3/3]

RootEvtSelector::~RootEvtSelector ( )

Member Function Documentation

◆ createAddress() [1/3]

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

◆ createAddress() [2/3]

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

◆ createAddress() [3/3]

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

◆ createContext() [1/3]

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

◆ createContext() [2/3]

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

◆ createContext() [3/3]

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

◆ getEntryFromTag() [1/3]

void RootEvtSelector::getEntryFromTag ( ) const

Definition at line 209 of file RootEvtSelector.cxx.

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

Referenced by getEntryFromTag(), and next().

◆ getEntryFromTag() [2/3]

void RootEvtSelector::getEntryFromTag ( ) const

◆ getEntryFromTag() [3/3]

void RootEvtSelector::getEntryFromTag ( ) const

◆ getRecId() [1/3]

int RootEvtSelector::getRecId ( ) const
inline

Definition at line 62 of file Event/RootCnvSvc/include/RootCnvSvc/RootEvtSelector.h.

62{ return ( *m_recId ); }

◆ getRecId() [2/3]

int RootEvtSelector::getRecId ( ) const
inline

Definition at line 62 of file InstallArea/x86_64-el9-gcc13-dbg/include/RootCnvSvc/RootEvtSelector.h.

62{ return ( *m_recId ); }

◆ getRecId() [3/3]

int RootEvtSelector::getRecId ( ) const
inline

Definition at line 62 of file InstallArea/x86_64-el9-gcc13-opt/include/RootCnvSvc/RootEvtSelector.h.

62{ return ( *m_recId ); }

◆ initialize() [1/3]

StatusCode RootEvtSelector::initialize ( )
virtual

Definition at line 48 of file RootEvtSelector.cxx.

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

◆ initialize() [2/3]

virtual StatusCode RootEvtSelector::initialize ( )
virtual

◆ initialize() [3/3]

virtual StatusCode RootEvtSelector::initialize ( )
virtual

◆ last() [1/3]

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

◆ last() [2/3]

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

◆ last() [3/3]

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

◆ next() [1/9]

StatusCode RootEvtSelector::next ( ) const

Definition at line 256 of file RootEvtSelector.cxx.

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

Referenced by createContext().

◆ next() [2/9]

StatusCode RootEvtSelector::next ( ) const

◆ next() [3/9]

StatusCode RootEvtSelector::next ( ) const

◆ next() [4/9]

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

◆ next() [5/9]

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

◆ next() [6/9]

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

◆ next() [7/9]

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

◆ next() [8/9]

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

◆ next() [9/9]

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

◆ previous() [1/6]

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

◆ previous() [2/6]

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

◆ previous() [3/6]

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

◆ previous() [4/6]

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

◆ previous() [5/6]

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

◆ previous() [6/6]

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

◆ queryInterface() [1/3]

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

Definition at line 314 of file RootEvtSelector.cxx.

314 {
315 if ( riid == IID_IRootEvtSelector ) { *ppvInterface = (RootEvtSelector*)this; }
316 else if ( riid == IEvtSelector::interfaceID() ) { *ppvInterface = (IEvtSelector*)this; }
317 else if ( riid == IProperty::interfaceID() ) { *ppvInterface = (IProperty*)this; }
318 else { return Service::queryInterface( riid, ppvInterface ); }
319 addRef();
320 return StatusCode::SUCCESS;
321}
RootEvtSelector(const std::string &name, ISvcLocator *svcloc)

Referenced by resetCriteria().

◆ queryInterface() [2/3]

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

◆ queryInterface() [3/3]

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

◆ releaseContext() [1/3]

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

◆ releaseContext() [2/3]

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

◆ releaseContext() [3/3]

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

◆ resetCriteria() [1/3]

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

◆ resetCriteria() [2/3]

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

◆ resetCriteria() [3/3]

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

◆ rewind() [1/3]

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

◆ rewind() [2/3]

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

◆ rewind() [3/3]

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

◆ setCriteria() [1/3]

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

Definition at line 123 of file RootEvtSelector.cxx.

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

Referenced by initialize(), and resetCriteria().

◆ setCriteria() [2/3]

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

◆ setCriteria() [3/3]

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

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