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