00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "GaudiKernel/MsgStream.h"
00016 #include "GaudiKernel/Bootstrap.h"
00017 #include "GaudiKernel/PropertyMgr.h"
00018 #include "GaudiKernel/IJobOptionsSvc.h"
00019 #include "GaudiKernel/ISvcLocator.h"
00020
00021 #include "GaudiKernel/ThreadGaudi.h"
00022
00023
00024 #include "RawDataCnv/RawDataContext.h"
00025 #include "RawDataCnv/RawDataInputSvc.h"
00026 #include "RawDataCnv/EventManagement/RAWEVENT.h"
00027 #include "RawDataCnv/RawDataAddress.h"
00028 #include "RawDataCnv/RawDataSelector.h"
00029
00030
00031
00032 extern const CLID& CLID_Event;
00033
00034 RawDataSelector::RawDataSelector( const std::string& name, ISvcLocator* svcloc ) :
00035 Service( name, svcloc),
00036 m_beginContext(0),
00037 m_endContext(0)
00038 {
00039
00040 PropertyMgr m_propMgr;
00041 m_propMgr.declareProperty("InputSvc", m_eventSourceName);
00042 IJobOptionsSvc* jobSvc;
00043 Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc);
00044 jobSvc->setMyProperties("RawDataSelector", &m_propMgr);
00045
00046 }
00047
00048 RawDataSelector::~RawDataSelector() {
00049
00050
00051 if (m_beginContext)
00052 delete m_beginContext;
00053 if (m_endContext)
00054 delete m_endContext;
00055 }
00056
00057 StatusCode RawDataSelector::initialize() {
00058
00059
00060 MsgStream log(messageService(), name());
00061
00062
00063 StatusCode sc = Service::initialize();
00064 if( sc.isSuccess() )
00065 {
00066 setProperties();
00067 }
00068 else
00069 {
00070 log << MSG::ERROR << "RawDataSelector::initialize: Unable to " <<
00071 "initialize Service base class." << endreq;
00072 return sc;
00073 }
00074
00075 IService* svc ;
00076
00077
00078 if (isGaudiThreaded(name()))m_eventSourceName += getGaudiThreadIDfromName(name());
00079 log << MSG::INFO << name() << " get RawDataInputSvc by name: " << m_eventSourceName << endreq;
00080
00081
00082 sc = serviceLocator()->getService(m_eventSourceName, svc);
00083 if(sc != StatusCode::SUCCESS ) {
00084 log<<MSG::ERROR << " Cant get RawDataInputSvc " <<endreq;
00085 return sc ;
00086 }
00087
00088 m_eventSource = dynamic_cast<RawDataInputSvc*> (svc);
00089 if(m_eventSource == 0 ) {
00090 log<<MSG::ERROR<< " Cant cast to RawDataInputSvc " <<endreq;
00091 return StatusCode::FAILURE ;
00092 }
00093
00094 m_beginContext = new RawDataContext(this);
00095
00096
00097
00098 return sc;
00099 }
00100
00101 StatusCode
00102 RawDataSelector::createContext(IEvtSelector::Context*& it) const
00103 {
00104 m_eventSource->initialize();
00105 it = m_beginContext;
00106 return(StatusCode::SUCCESS);
00107 }
00108
00109
00110 StatusCode RawDataSelector::next(IEvtSelector::Context& it)const
00111 {
00112 RAWEVENT* pre = m_eventSource->nextEvent();
00113
00114 return StatusCode::SUCCESS;
00115 }
00116
00117
00118 StatusCode RawDataSelector::next(IEvtSelector::Context& ctxt, int jump) const {
00119 if ( jump > 0 ) {
00120 for ( int i = 0; i < jump; ++i ) {
00121 StatusCode status = next(ctxt);
00122 if ( !status.isSuccess() ) {
00123 return status;
00124 }
00125 }
00126 return StatusCode::SUCCESS;
00127 }
00128 return StatusCode::FAILURE;
00129 }
00130
00131 StatusCode RawDataSelector::previous(IEvtSelector::Context& ) const {
00132 MsgStream log(messageService(), name());
00133 log << MSG::ERROR << "RawDataSelector::previous() not implemented" << endreq;
00134 return(StatusCode::FAILURE);
00135 }
00136
00137 StatusCode RawDataSelector::previous(IEvtSelector::Context& it,int ) const {
00138 return(previous(it));
00139 }
00140
00141 StatusCode RawDataSelector::last(IEvtSelector::Context& it)const {
00142 return (StatusCode::FAILURE);
00143 }
00144
00145 StatusCode RawDataSelector::resetCriteria(const std::string& , IEvtSelector::Context& ) const {
00146 return(StatusCode::SUCCESS);
00147 }
00148
00149
00150 StatusCode RawDataSelector::rewind(IEvtSelector::Context& ) const {
00151 MsgStream log(messageService(), name());
00152 log << MSG::ERROR << "RawDataSelector::rewind() not implemented" << endreq;
00153 return(StatusCode::FAILURE);
00154 }
00155
00156 StatusCode RawDataSelector::createAddress(const IEvtSelector::Context& ,
00157 IOpaqueAddress*& iop) const {
00158 iop = new RawDataAddress(CLID_Event, "EventHeader", "EventHeader");
00159
00160 return(StatusCode::SUCCESS);
00161 }
00162
00163 StatusCode
00164 RawDataSelector::releaseContext(IEvtSelector::Context*& )const {
00165 return(StatusCode::SUCCESS);
00166 }
00167
00168 StatusCode
00169 RawDataSelector::queryInterface(const InterfaceID& riid, void** ppvInterface)
00170 {
00171 if ( riid == IEvtSelector::interfaceID() ) {
00172 *ppvInterface = (IEvtSelector*)this;
00173 }
00174 else if ( riid == IProperty::interfaceID() ) {
00175 *ppvInterface = (IProperty*)this;
00176 }
00177 else {
00178 return Service::queryInterface( riid, ppvInterface );
00179 }
00180 addRef();
00181 return StatusCode::SUCCESS;
00182 }
00183
00184
00185
00186