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