00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "GaudiKernel/Converter.h"
00013 #include "GaudiKernel/MsgStream.h"
00014
00015 #include "GaudiKernel/ThreadGaudi.h"
00016
00017
00018 #include "EventModel/Event.h"
00019 #include "RawDataCnv/RawDataCnv.h"
00020 #include "RawDataCnv/RawDataAddress.h"
00021 #include "RawDataCnv/RawDataInputSvc.h"
00022 #include "RawDataCnv/EventManagement/RAWEVENT.h"
00023
00024 extern const CLID& CLID_Event;
00025
00026
00027 RawDataCnv::RawDataCnv(ISvcLocator* svc) :
00028 RawDataBaseCnv(PACKEDRAWEVENT_StorageType, classID(), svc)
00029 {
00030
00031 }
00032
00033 StatusCode RawDataCnv::initialize()
00034 {
00035 StatusCode sc = RawDataBaseCnv::initialize();
00036 if( sc.isFailure() ) return sc;
00037
00038 std::string PackedRawDataCnvSvc_Name("PackedRawDataCnvSvc");
00039 std::string RawDataInputSvc_Name("RawDataInputSvc");
00040 std::string RawDataCnv_Name("RawDataCnv");
00041
00042
00043
00044
00045
00046 SmartIF<IService> pCnvSvc(conversionSvc());
00047 if (isGaudiThreaded(pCnvSvc->name())){
00048 PackedRawDataCnvSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00049 RawDataInputSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00050 RawDataCnv_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00051 }
00052
00053
00054
00055 MsgStream log(messageService(), RawDataCnv_Name.c_str());
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 IService* svc ;
00066 sc = serviceLocator()->getService(RawDataInputSvc_Name.c_str(), svc);
00067 if(sc != StatusCode::SUCCESS ) {
00068 log<<MSG::WARNING << " Cant get RawDataInputSvc " <<endreq;
00069 return sc ;
00070 }
00071
00072 m_inputSvc = dynamic_cast<RawDataInputSvc*> (svc);
00073 if(m_inputSvc == 0 ) {
00074 log<<MSG::WARNING << " Cant cast to RawDataInputSvc " <<endreq;
00075 return StatusCode::FAILURE ;
00076 }
00077
00078 return StatusCode::SUCCESS;
00079 }
00080
00081
00082
00083 const CLID& RawDataCnv::classID()
00084 {
00085 return CLID_Event;
00086 }
00087
00088 StatusCode RawDataCnv::updateObj(IOpaqueAddress* pAddr, DataObject* pObj) {
00089
00090
00091
00092
00093
00094 return Converter::updateObj(pAddr, pObj);
00095 }
00096
00097
00098 StatusCode RawDataCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
00099 {
00100 RawDataAddress *pEFAddr;
00101 const RAWEVENT *evt;
00102
00103 Event::EventH * evh = new Event::EventH();
00104 pObj = evh;
00105
00106 if ( (pEFAddr = dynamic_cast<RawDataAddress*>(pAddr)) ) {
00107 evt = m_inputSvc->currentEvent();
00108 if (evt == NULL) return StatusCode::FAILURE;
00109 return StatusCode::SUCCESS;
00110 }
00111 else {
00112 return StatusCode::FAILURE;
00113 }
00114 }
00115
00116 StatusCode RawDataCnv::createRep(DataObject* pObj, IOpaqueAddress*& pAddr)
00117 {
00118 Event::EventH * evh=dynamic_cast<Event::EventH *> (pObj);
00119 if (!evh) {
00120 std::string RawDataCnv_Name("RawDataCnv");
00121
00122
00123
00124 SmartIF<IService> pCnvSvc(conversionSvc());
00125 if (isGaudiThreaded(pCnvSvc->name())){
00126 RawDataCnv_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00127 }
00128
00129 MsgStream log(msgSvc(), RawDataCnv_Name.c_str());
00130 log << MSG::DEBUG << "RawDataCnv::createRep()" << endreq;
00131
00132 log << MSG::ERROR << "Could not downcast Event" << endreq;
00133 return StatusCode::FAILURE;
00134 }
00135
00136 return StatusCode::SUCCESS;
00137 }