BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
RawDataSelector.cxx
Go to the documentation of this file.
1//====================================================================
2// EventSelector.cpp
3//--------------------------------------------------------------------
4//
5// Package : RawDataSelector
6//
7// Description: The EventSelector component is able
8// to produce a list of event references given
9// a set of "selection criteria".
10//
11//
12//====================================================================
13
14// Include files
15#include "GaudiKernel/MsgStream.h"
16#include "GaudiKernel/Bootstrap.h"
17#include "GaudiKernel/PropertyMgr.h"
18#include "GaudiKernel/IJobOptionsSvc.h"
19#include "GaudiKernel/ISvcLocator.h"
20// for Mutil-thread by tianhl
21#include "GaudiKernel/ThreadGaudi.h"
22// for Mutil-thread by tianhl
23
29
30
31DECLARE_COMPONENT(RawDataSelector)
32extern const CLID& CLID_Event;
33DECLARE_COMPONENT(RawDataSelector)
34
35RawDataSelector::RawDataSelector( const std::string& name, ISvcLocator* svcloc ) :
36 Service( name, svcloc),
37 m_beginContext(0),
38 m_endContext(0)
39{
40 // Get a pointer to the Job Options Service
41 PropertyMgr m_propMgr;
42 m_propMgr.declareProperty("InputSvc", m_eventSourceName);
43 IJobOptionsSvc* jobSvc;
44 Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc);
45 jobSvc->setMyProperties("RawDataSelector", &m_propMgr);
46
47}
48
50 //if (m_eventSource)
51 //delete m_eventSource;
52 if (m_beginContext)
53 delete m_beginContext;
54 if (m_endContext)
55 delete m_endContext;
56}
57
59
60 // Create a message stream.
61 MsgStream log(messageService(), name());
62
63 // Initialize the Service base class.
64 StatusCode sc = Service::initialize();
65 if( sc.isSuccess() )
66 {
67 setProperties();
68 }
69 else
70 {
71 log << MSG::ERROR << "RawDataSelector::initialize: Unable to " <<
72 "initialize Service base class." << endreq;
73 return sc;
74 }
75
76 IService* svc ;
77
78 // for Mutil-thread by tianhl
79 if (isGaudiThreaded(name()))m_eventSourceName += getGaudiThreadIDfromName(name());
80 log << MSG::INFO << name() << " get RawDataInputSvc by name: " << m_eventSourceName << endreq;
81 // for Mutil-thread by tianhl
82
83 sc = serviceLocator()->getService(m_eventSourceName, svc);
84 if(sc != StatusCode::SUCCESS ) {
85 log<<MSG::ERROR << " Cant get RawDataInputSvc " <<endreq;
86 return sc ;
87 }
88
89 m_eventSource = dynamic_cast<RawDataInputSvc*> (svc);
90 if(m_eventSource == 0 ) {
91 log<<MSG::ERROR<< " Cant cast to RawDataInputSvc " <<endreq;
92 return StatusCode::FAILURE ;
93 }
94
95 m_beginContext = new RawDataContext(this);
96
97 //m_endContext = new RawDataContext(this, m_eventSource->end());
98
99 return sc;
100}
101
102StatusCode
103RawDataSelector::createContext(IEvtSelector::Context*& it) const
104{
105 m_eventSource->initialize();
106 it = m_beginContext;
107 return(StatusCode::SUCCESS);
108}
109
110// Implementation of IEvtSelector::next().
111StatusCode RawDataSelector::next(IEvtSelector::Context& it)const
112{
113 RAWEVENT* pre = m_eventSource->nextEvent();
114 //((RawDataContext &)it).next();
115 return StatusCode::SUCCESS;
116}
117
118//__________________________________________________________________________
119StatusCode RawDataSelector::next(IEvtSelector::Context& ctxt, int jump) const {
120 if ( jump > 0 ) {
121 for ( int i = 0; i < jump; ++i ) {
122 StatusCode status = next(ctxt);
123 if ( !status.isSuccess() ) {
124 return status;
125 }
126 }
127 return StatusCode::SUCCESS;
128 }
129 return StatusCode::FAILURE;
130}
131
132StatusCode RawDataSelector::previous(IEvtSelector::Context& /*it*/) const {
133 MsgStream log(messageService(), name());
134 log << MSG::ERROR << "RawDataSelector::previous() not implemented" << endreq;
135 return(StatusCode::FAILURE);
136}
137
138StatusCode RawDataSelector::previous(IEvtSelector::Context& it,int /*jump*/) const {
139 return(previous(it));
140}
141
142StatusCode RawDataSelector::last(IEvtSelector::Context& it)const {
143 return (StatusCode::FAILURE);
144}
145
146StatusCode RawDataSelector::resetCriteria(const std::string& /*criteria*/, IEvtSelector::Context& /*ctxt*/) const {
147 return(StatusCode::SUCCESS);
148}
149
150
151StatusCode RawDataSelector::rewind(IEvtSelector::Context& /*it*/) const {
152 MsgStream log(messageService(), name());
153 log << MSG::ERROR << "RawDataSelector::rewind() not implemented" << endreq;
154 return(StatusCode::FAILURE);
155}
156
157StatusCode RawDataSelector::createAddress(const IEvtSelector::Context& /*it*/,
158 IOpaqueAddress*& iop) const {
159 iop = new RawDataAddress(CLID_Event, "EventHeader", "EventHeader");
160
161 return(StatusCode::SUCCESS);
162}
163
164StatusCode
165RawDataSelector::releaseContext(IEvtSelector::Context*& /*it*/)const {
166 return(StatusCode::SUCCESS);
167}
168
169StatusCode
170RawDataSelector::queryInterface(const InterfaceID& riid, void** ppvInterface)
171{
172 if ( riid == IEvtSelector::interfaceID() ) {
173 *ppvInterface = (IEvtSelector*)this;
174 }
175 else if ( riid == IProperty::interfaceID() ) {
176 *ppvInterface = (IProperty*)this;
177 }
178 else {
179 return Service::queryInterface( riid, ppvInterface );
180 }
181 addRef();
182 return StatusCode::SUCCESS;
183}
184
185
186
187
const CLID & CLID_Event
const CLID & CLID_Event
StatusCode initialize()
virtual RAWEVENT * nextEvent()=0
This class provides the Context for RawDataSelector.
virtual StatusCode previous(Context &it) const
virtual StatusCode createAddress(const Context &it, IOpaqueAddress *&iop) const
virtual StatusCode initialize()
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
virtual StatusCode resetCriteria(const std::string &criteria, Context &context) const
virtual StatusCode last(Context &it) const
virtual StatusCode rewind(Context &it) const
virtual StatusCode next(Context &it) const
virtual StatusCode createContext(Context *&it) const
virtual StatusCode releaseContext(Context *&it) const