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