CGEM BOSS 6.6.5.h
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// Constructor.
27RawDataCnv::RawDataCnv(ISvcLocator* svc) :
29{
30 //init();
31}
32
34{
35 StatusCode sc = RawDataBaseCnv::initialize();
36 if( sc.isFailure() ) return sc;
37
38 std::string PackedRawDataCnvSvc_Name("PackedRawDataCnvSvc");
39 std::string RawDataInputSvc_Name("RawDataInputSvc");
40 std::string RawDataCnv_Name("RawDataCnv");
41
42 // for Mutil-thread by tianhl
43 //ConversionSvc* pCnvSvc = 0;
44 //SmartIF<IService> pCnvSvc(conversionSvc());
45 //if (pCnvSvc = dynamic_cast<ConversionSvc*>(conversionSvc())){
46 SmartIF<IService> pCnvSvc(conversionSvc());
47 if (isGaudiThreaded(pCnvSvc->name())){
48 PackedRawDataCnvSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
49 RawDataInputSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
50 RawDataCnv_Name += getGaudiThreadIDfromName(pCnvSvc->name());
51 }
52 //}
53 // for Mutil-thread by tianhl
54
55 MsgStream log(messageService(), RawDataCnv_Name.c_str());
56 /*if (StatusCode::SUCCESS != service("PackedRawDataCnvSvc",
57 m_RawDataAccess) || !m_RawDataAccess )
58 {
59 log << MSG::ERROR << " Can't get RawDataAccess interface "
60 << endreq;
61 return StatusCode::FAILURE;
62 }
63 log << MSG::INFO << " RawDataCnvSvc retrieved "<< endreq; */
64
65 IService* svc ;
66 sc = serviceLocator()->getService(RawDataInputSvc_Name.c_str(), svc);
67 if(sc != StatusCode::SUCCESS ) {
68 log<<MSG::WARNING << " Cant get RawDataInputSvc " <<endreq;
69 return sc ;
70 }
71
72 m_inputSvc = dynamic_cast<RawDataInputSvc*> (svc);
73 if(m_inputSvc == 0 ) {
74 log<<MSG::WARNING << " Cant cast to RawDataInputSvc " <<endreq;
75 return StatusCode::FAILURE ;
76 }
77
78 return StatusCode::SUCCESS;
79}
80
81// Return the identification number of this converter to the
82// persistency service.
84{
85 return CLID_Event;
86}
87
88StatusCode RawDataCnv::updateObj(IOpaqueAddress* pAddr, DataObject* pObj) {
89 // Purpose and Method: This method does nothing other than announce it has
90 // been called.
91
92 //MsgStream log(msgSvc(), "RawDataCnv");
93 //log << MSG::DEBUG << "RawDataCnv::updateObj" << endreq;
94 return Converter::updateObj(pAddr, pObj);
95}
96
97// Create a converted object in the Transient Data Store.
98StatusCode RawDataCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
99{
100 RawDataAddress *pEFAddr;
101 const RAWEVENT *evt;
102
103 Event::EventH * evh = new Event::EventH();
104 pObj = evh;
105
106 if ( (pEFAddr = dynamic_cast<RawDataAddress*>(pAddr)) ) {
107 evt = m_inputSvc->currentEvent();
108 if (evt == NULL) return StatusCode::FAILURE;
109 return StatusCode::SUCCESS;
110 }
111 else {
112 return StatusCode::FAILURE;
113 }
114}
115
116StatusCode RawDataCnv::createRep(DataObject* pObj, IOpaqueAddress*& pAddr)
117{
118 Event::EventH * evh=dynamic_cast<Event::EventH *> (pObj);
119 if (!evh) {
120 std::string RawDataCnv_Name("RawDataCnv");
121 //ConversionSvc* pCnvSvc = 0;
122 //SmartIF<IService> pCnvSvc(conversionSvc());
123 //if (pCnvSvc = dynamic_cast<ConversionSvc*>(conversionSvc())){
124 SmartIF<IService> pCnvSvc(conversionSvc());
125 if (isGaudiThreaded(pCnvSvc->name())){
126 RawDataCnv_Name += getGaudiThreadIDfromName(pCnvSvc->name());
127 }
128 //}
129 MsgStream log(msgSvc(), RawDataCnv_Name.c_str());
130 log << MSG::DEBUG << "RawDataCnv::createRep()" << endreq;
131
132 log << MSG::ERROR << "Could not downcast Event" << endreq;
133 return StatusCode::FAILURE;
134 }
135 // nothing to do, will be done in lower converters
136 return StatusCode::SUCCESS;
137}
unsigned const long PACKEDRAWEVENT_StorageType
const CLID & CLID_Event
const CLID & CLID_Event
IMessageSvc * msgSvc()
virtual RAWEVENT * currentEvent()=0
StatusCode initialize()
virtual StatusCode updateObj(IOpaqueAddress *, DataObject *)
override the RawDataBaseCnv version
StatusCode initialize()
StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr)
Convert the transient object to the requested representation.
static const CLID & classID()
RawDataCnv(ISvcLocator *svc)