BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
RawDataMucDigiCnv.cxx
Go to the documentation of this file.
1//====================================================================
2// RawDataMucDigiCnv.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/MsgStream.h"
13#include "GaudiKernel/SmartDataPtr.h"
14// for Mutil-thread by tianhl
15#include "GaudiKernel/ThreadGaudi.h"
16// for Mutil-thread by tianhl
17
18#include "EventModel/EventModel.h"
19#include "MucRawEvent/MucDigi.h"
20#include "RawDataCnv/EventManagement/RAWEVENT.h"
21#include "RawDataCnv/EventManagement/RawEvent.h"
22#include "RawDataCnv/RawDataInputSvc.h"
23#include "RawDataCnv/RawDataMucDigiCnv.h"
24
25
26
27extern const CLID& CLID_MucDigiCol;
28
29// Constructor.
32{
33}
34
36{
38}
39
40// Return the identification number of this converter to the
41// persistency service.
43{
44 return CLID_MucDigiCol;
45}
46
48{
49 std::string PackedRawDataCnvSvc_Name("PackedRawDataCnvSvc");
50 std::string RawDataInputSvc_Name("RawDataInputSvc");
51 std::string RawDataMucDigiCnv_Name("RawDataMucDigiCnv");
52
53 // for Mutil-thread by tianhl
54 //ConversionSvc* pCnvSvc = 0;
55 //if (pCnvSvc = dynamic_cast<ConversionSvc*>(conversionSvc())){
56 SmartIF<IService> pCnvSvc(conversionSvc());
57 if (isGaudiThreaded(pCnvSvc->name())){
58 PackedRawDataCnvSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
59 RawDataInputSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
60 RawDataMucDigiCnv_Name += getGaudiThreadIDfromName(pCnvSvc->name());
61 }
62 //}
63
64 MsgStream log(messageService(), RawDataMucDigiCnv_Name.c_str());
65
66 StatusCode sc = RawDataBaseCnv::initialize();
67 if ( sc.isFailure() ) {
68 return sc;
69 }
70
71 // Check RawDataCnvSvc
72 IService* isvc = 0;
73 StatusCode status = serviceLocator()->service(PackedRawDataCnvSvc_Name.c_str(), isvc, true);
74 m_RawDataAccess = dynamic_cast<PackedRawDataCnvSvc*> (isvc);
75 if(m_RawDataAccess == 0 ) {
76 log<<MSG::ERROR<< " MucRawDataCnv: Cant cast to RawDataCnvSvc " <<endreq;
77 return StatusCode::FAILURE ;
78 }
79
80 IService* svc ;
81 sc = serviceLocator()->getService(RawDataInputSvc_Name.c_str(), svc);
82 //if ( sc.isFailure() ) {
83 // log<<MSG::WARNING << " Cant get RawDataInputSvc " <<endreq;
84 // return sc ;
85 //}
86 m_inputSvc = dynamic_cast<RawDataInputSvc*> (svc);
87 if ( m_inputSvc == 0 ) {
88 log<< MSG::WARNING << " Cant cast to RawDataInputSvc " <<endreq;
89 return StatusCode::FAILURE ;
90 }
91
92 m_cnv = MucConverter::instance();
93
94 return StatusCode::SUCCESS;
95}
96
97
98StatusCode RawDataMucDigiCnv::updateObj(IOpaqueAddress* pAddr, DataObject* pObj) {
99 // Purpose and Method: This method does nothing other than announce it has
100 // been called.
101
102 //MsgStream log(msgSvc(), "RawDataMucDigiCnv");
103 //log << MSG::DEBUG << "RawDataMucDigiCnv::updateObj" << endreq;
104 return Converter::updateObj(pAddr, pObj);
105}
106
107// Create a converted object in the Transient Data Store.
108StatusCode RawDataMucDigiCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
109{
110 //MsgStream log(msgSvc(), "RawDataMucDigiCnv");
111 // Purpose and Method: This converter will create an empty MucDigiCol on
112 // the TDS.
113 MucDigiCol *digiCol = new MucDigiCol;
114 pObj = digiCol;
115
116 RAWEVENT* evt = m_inputSvc->currentEvent();
117 if (evt == NULL) {
118 cout << "RawDataMucDigiCnv::createObj has event!" << endl;
119 return StatusCode::FAILURE;
120 }
121
122 const BufferHolder& mucBuf = evt->getMucBuf();
123
124 return m_cnv->convert(mucBuf, digiCol);
125}
126
127StatusCode RawDataMucDigiCnv::createRep(DataObject* pObj, IOpaqueAddress*& pAddr)
128{
129 // convert PixelRaw in the container into ByteStream
130 //MsgStream log(messageService(), "RawDataMucDigiCnv");
131
132 WriteRawEvent*& re = m_RawDataAccess->getRawEvent();
133 if (re == 0) {
134 //log << " get RawEvent failed !" << endreq;
135 return StatusCode::FAILURE;
136 }
137
138 SmartDataPtr<MucDigiCol> digiCol(dataProvider(), EventModel::Digi::MucDigiCol);
139 if (digiCol == 0) {
140 //log << "no MucDigiCol found" << endreq;
141 return StatusCode::FAILURE;
142 }
143 /*
144 else {
145 log << MSG::INFO << endreq << "Detailed dump of 1st event: " << endreq << endreq;
146 int ndigi = 0;
147 MucDigiCol::const_iterator pMucDigi = digiCol->begin();
148 for (pMucDigi; pMucDigi!= digiCol->end(); pMucDigi++) {
149 log <<MSG::INFO << "Digi " << ndigi++ << " ";
150 // output the digi proper: " << digi " no longer works because
151 // "digi" now returns an integer sort order
152 (**pMucDigi).fillStream(log.stream());
153 log << endreq;
154 }
155 }
156 */
157
158 return m_cnv->convert(digiCol, re);
159}
const CLID & CLID_MucDigiCol
Definition: EventModel.cxx:244
ObjectVector< MucDigi > MucDigiCol
const CLID & CLID_MucDigiCol
Definition: EventModel.cxx:244
virtual RAWEVENT * currentEvent()=0
static MucConverter * instance()
Definition: MucConverter.cxx:5
static void destroy()
StatusCode convert(const BufferHolder &src, MucDigiCol *des)
StatusCode initialize()
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr)
Convert the transient object to the requested representation.
virtual StatusCode updateObj(IOpaqueAddress *, DataObject *)
override the RawDataBaseCnv version
RawDataMucDigiCnv(ISvcLocator *svc)
StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
static const CLID & classID()