BOSS 7.0.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
24#include "RawDataCnv/RawDataContext.h"
25#include "RawDataCnv/RawDataInputSvc.h"
26#include "RawDataCnv/EventManagement/RAWEVENT.h"
27#include "RawDataCnv/RawDataAddress.h"
28#include "RawDataCnv/RawDataSelector.h"
29
30
31
32extern const CLID& CLID_Event;
33
34RawDataSelector::RawDataSelector( const std::string& name, ISvcLocator* svcloc ) :
35 Service( name, svcloc),
36 m_beginContext(0),
37 m_endContext(0)
38{
39 // Get a pointer to the Job Options Service
40 PropertyMgr m_propMgr;
41 m_propMgr.declareProperty("InputSvc", m_eventSourceName);
42 IJobOptionsSvc* jobSvc;
43 Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc);
44 jobSvc->setMyProperties("RawDataSelector", &m_propMgr);
45
46}
47
49 //if (m_eventSource)
50 //delete m_eventSource;
51 if (m_beginContext)
52 delete m_beginContext;
53 if (m_endContext)
54 delete m_endContext;
55}
56
58
59 // Create a message stream.
60 MsgStream log(messageService(), name());
61
62 // Initialize the Service base class.
63 StatusCode sc = Service::initialize();
64 if( sc.isSuccess() )
65 {
66 setProperties();
67 }
68 else
69 {
70 log << MSG::ERROR << "RawDataSelector::initialize: Unable to " <<
71 "initialize Service base class." << endreq;
72 return sc;
73 }
74
75 IService* svc ;
76
77 // for Mutil-thread by tianhl
78 if (isGaudiThreaded(name()))m_eventSourceName += getGaudiThreadIDfromName(name());
79 log << MSG::INFO << name() << " get RawDataInputSvc by name: " << m_eventSourceName << endreq;
80 // for Mutil-thread by tianhl
81
82 sc = serviceLocator()->getService(m_eventSourceName, svc);
83 if(sc != StatusCode::SUCCESS ) {
84 log<<MSG::ERROR << " Cant get RawDataInputSvc " <<endreq;
85 return sc ;
86 }
87
88 m_eventSource = dynamic_cast<RawDataInputSvc*> (svc);
89 if(m_eventSource == 0 ) {
90 log<<MSG::ERROR<< " Cant cast to RawDataInputSvc " <<endreq;
91 return StatusCode::FAILURE ;
92 }
93
94 m_beginContext = new RawDataContext(this);
95
96 //m_endContext = new RawDataContext(this, m_eventSource->end());
97
98 return sc;
99}
100
101StatusCode
102RawDataSelector::createContext(IEvtSelector::Context*& it) const
103{
104 m_eventSource->initialize();
105 it = m_beginContext;
106 return(StatusCode::SUCCESS);
107}
108
109// Implementation of IEvtSelector::next().
110StatusCode RawDataSelector::next(IEvtSelector::Context& it)const
111{
112 RAWEVENT* pre = m_eventSource->nextEvent();
113 //((RawDataContext &)it).next();
114 return StatusCode::SUCCESS;
115}
116
117//__________________________________________________________________________
118StatusCode RawDataSelector::next(IEvtSelector::Context& ctxt, int jump) const {
119 if ( jump > 0 ) {
120 for ( int i = 0; i < jump; ++i ) {
121 StatusCode status = next(ctxt);
122 if ( !status.isSuccess() ) {
123 return status;
124 }
125 }
126 return StatusCode::SUCCESS;
127 }
128 return StatusCode::FAILURE;
129}
130
131StatusCode RawDataSelector::previous(IEvtSelector::Context& /*it*/) const {
132 MsgStream log(messageService(), name());
133 log << MSG::ERROR << "RawDataSelector::previous() not implemented" << endreq;
134 return(StatusCode::FAILURE);
135}
136
137StatusCode RawDataSelector::previous(IEvtSelector::Context& it,int /*jump*/) const {
138 return(previous(it));
139}
140
141StatusCode RawDataSelector::last(IEvtSelector::Context& it)const {
142 return (StatusCode::FAILURE);
143}
144
145StatusCode RawDataSelector::resetCriteria(const std::string& /*criteria*/, IEvtSelector::Context& /*ctxt*/) const {
146 return(StatusCode::SUCCESS);
147}
148
149
150StatusCode RawDataSelector::rewind(IEvtSelector::Context& /*it*/) const {
151 MsgStream log(messageService(), name());
152 log << MSG::ERROR << "RawDataSelector::rewind() not implemented" << endreq;
153 return(StatusCode::FAILURE);
154}
155
156StatusCode RawDataSelector::createAddress(const IEvtSelector::Context& /*it*/,
157 IOpaqueAddress*& iop) const {
158 iop = new RawDataAddress(CLID_Event, "EventHeader", "EventHeader");
159
160 return(StatusCode::SUCCESS);
161}
162
163StatusCode
164RawDataSelector::releaseContext(IEvtSelector::Context*& /*it*/)const {
165 return(StatusCode::SUCCESS);
166}
167
168StatusCode
169RawDataSelector::queryInterface(const InterfaceID& riid, void** ppvInterface)
170{
171 if ( riid == IEvtSelector::interfaceID() ) {
172 *ppvInterface = (IEvtSelector*)this;
173 }
174 else if ( riid == IProperty::interfaceID() ) {
175 *ppvInterface = (IProperty*)this;
176 }
177 else {
178 return Service::queryInterface( riid, ppvInterface );
179 }
180 addRef();
181 return StatusCode::SUCCESS;
182}
183
184
185
186
const CLID & CLID_Event
Definition: EventModel.cxx:193
const CLID & CLID_Event
Definition: EventModel.cxx:193
virtual RAWEVENT * nextEvent()=0
This class provides the Context for RawDataSelector.
virtual StatusCode previous(Context &it) const
virtual StatusCode initialize()
virtual StatusCode last(Context &it) const
virtual StatusCode createContext(Context *&it) const
RawDataSelector(const std::string &name, ISvcLocator *svcloc)
virtual StatusCode releaseContext(Context *&it) const
virtual StatusCode rewind(Context &it) const
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
virtual StatusCode resetCriteria(const std::string &criteria, Context &context) const
virtual StatusCode createAddress(const Context &it, IOpaqueAddress *&iop) const
virtual StatusCode next(Context &it) const