BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
RawDataCnv.cxx
Go to the documentation of this file.
1//====================================================================
2// RawDataCnv.cxx
3//====================================================================
4//
5// Description: A converter class to unpack Event Filter packed raw
6// event persistent data and place it in the Transient
7// Data Store of Athena.
8//
9//--------------------------------------------------------------------
10
11// Include files.
12#include "GaudiKernel/Converter.h"
13#include "GaudiKernel/MsgStream.h"
14// for Mutil-thread by tianhl
15#include "GaudiKernel/ThreadGaudi.h"
16// for Mutil-thread by tianhl
17
18#include "EventModel/Event.h"
23
24extern const CLID& CLID_Event;
25
26//DECLARE_COMPONENT(RawDataCnv)
27
28// Constructor.
29RawDataCnv::RawDataCnv(ISvcLocator* svc) :
31{
32 //init();
33}
34
36{
37 StatusCode sc = RawDataBaseCnv::initialize();
38 if( sc.isFailure() ) return sc;
39
40 std::string PackedRawDataCnvSvc_Name("PackedRawDataCnvSvc");
41 std::string RawDataInputSvc_Name("RawDataInputSvc");
42 std::string RawDataCnv_Name("RawDataCnv");
43
44 // for Mutil-thread by tianhl
45 //ConversionSvc* pCnvSvc = 0;
46 //SmartIF<IService> pCnvSvc(conversionSvc());
47 //if (pCnvSvc = dynamic_cast<ConversionSvc*>(conversionSvc())){
48 SmartIF<IService> pCnvSvc(conversionSvc());
49 if (isGaudiThreaded(pCnvSvc->name())){
50 PackedRawDataCnvSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
51 RawDataInputSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
52 RawDataCnv_Name += getGaudiThreadIDfromName(pCnvSvc->name());
53 }
54 //}
55 // for Mutil-thread by tianhl
56
57 MsgStream log(messageService(), RawDataCnv_Name.c_str());
58 /*if (StatusCode::SUCCESS != service("PackedRawDataCnvSvc",
59 m_RawDataAccess) || !m_RawDataAccess )
60 {
61 log << MSG::ERROR << " Can't get RawDataAccess interface "
62 << endreq;
63 return StatusCode::FAILURE;
64 }
65 log << MSG::INFO << " RawDataCnvSvc retrieved "<< endreq; */
66
67 IService* svc ;
68 sc = serviceLocator()->getService(RawDataInputSvc_Name.c_str(), svc);
69 if(sc != StatusCode::SUCCESS ) {
70 log<<MSG::WARNING << " Cant get RawDataInputSvc " <<endreq;
71 return sc ;
72 }
73
74 m_inputSvc = dynamic_cast<RawDataInputSvc*> (svc);
75 if(m_inputSvc == 0 ) {
76 log<<MSG::WARNING << " Cant cast to RawDataInputSvc " <<endreq;
77 return StatusCode::FAILURE ;
78 }
79
80 return StatusCode::SUCCESS;
81}
82
83// Return the identification number of this converter to the
84// persistency service.
86{
87 return CLID_Event;
88}
89
90StatusCode RawDataCnv::updateObj(IOpaqueAddress* pAddr, DataObject* pObj) {
91 // Purpose and Method: This method does nothing other than announce it has
92 // been called.
93
94 //MsgStream log(msgSvc(), "RawDataCnv");
95 //log << MSG::DEBUG << "RawDataCnv::updateObj" << endreq;
96 return Converter::updateObj(pAddr, pObj);
97}
98
99// Create a converted object in the Transient Data Store.
100StatusCode RawDataCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
101{
102 RawDataAddress *pEFAddr;
103 const RAWEVENT *evt;
104
105 Event::EventH * evh = new Event::EventH();
106 pObj = evh;
107
108 if ( (pEFAddr = dynamic_cast<RawDataAddress*>(pAddr)) ) {
109 evt = m_inputSvc->currentEvent();
110 if (evt == NULL) return StatusCode::FAILURE;
111 return StatusCode::SUCCESS;
112 }
113 else {
114 return StatusCode::FAILURE;
115 }
116}
117
118StatusCode RawDataCnv::createRep(DataObject* pObj, IOpaqueAddress*& pAddr)
119{
120 Event::EventH * evh=dynamic_cast<Event::EventH *> (pObj);
121 if (!evh) {
122 std::string RawDataCnv_Name("RawDataCnv");
123 //ConversionSvc* pCnvSvc = 0;
124 //SmartIF<IService> pCnvSvc(conversionSvc());
125 //if (pCnvSvc = dynamic_cast<ConversionSvc*>(conversionSvc())){
126 SmartIF<IService> pCnvSvc(conversionSvc());
127 if (isGaudiThreaded(pCnvSvc->name())){
128 RawDataCnv_Name += getGaudiThreadIDfromName(pCnvSvc->name());
129 }
130 //}
131 MsgStream log(msgSvc(), RawDataCnv_Name.c_str());
132 log << MSG::DEBUG << "RawDataCnv::createRep()" << endreq;
133
134 log << MSG::ERROR << "Could not downcast Event" << endreq;
135 return StatusCode::FAILURE;
136 }
137 // nothing to do, will be done in lower converters
138 return StatusCode::SUCCESS;
139}
unsigned const long PACKEDRAWEVENT_StorageType
Definition: ClassID_temp.h:17
const CLID & CLID_Event
Definition: EventModel.cxx:193
const CLID & CLID_Event
Definition: EventModel.cxx:193
IMessageSvc * msgSvc()
#define NULL
virtual RAWEVENT * currentEvent()=0
StatusCode initialize()
virtual StatusCode updateObj(IOpaqueAddress *, DataObject *)
override the RawDataBaseCnv version
Definition: RawDataCnv.cxx:90
StatusCode initialize()
Definition: RawDataCnv.cxx:35
StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Definition: RawDataCnv.cxx:100
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr)
Convert the transient object to the requested representation.
Definition: RawDataCnv.cxx:118
static const CLID & classID()
Definition: RawDataCnv.cxx:85
RawDataCnv(ISvcLocator *svc)
Definition: RawDataCnv.cxx:29