BOSS 7.0.2
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
19#include "EventModel/EventModel.h"
20#include "LumiDigi/LumiDigi.h"
21#include "TofRawEvent/TofDigi.h"
22#include "RawDataCnv/EventManagement/RAWEVENT.h"
23#include "RawDataCnv/EventManagement/RawEvent.h"
24#include "RawDataCnv/RawDataInputSvc.h"
25#include "RawDataCnv/RawDataTofDigiCnv.h"
26
27
28extern const CLID& CLID_TofDigiCol;
29
30// Constructor.
33{
34}
35
37{
39}
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 const BufferHolder& etfBuf = evt->getEtfBuf();
144
145 return m_cnv->convert(tofBuf, etfBuf, digiCol, lumiDigiCol);
146}
147
148StatusCode RawDataTofDigiCnv::createRep(DataObject* pObj, IOpaqueAddress*& pAddr)
149{
150 // convert PixelRaw in the container into ByteStream
151 //MsgStream log(messageService(), "RawDataTofDigiCnv");
152
153 WriteRawEvent*& re = m_RawDataAccess->getRawEvent();
154 if (re == 0) {
155 //log << " get RawEvent failed !" << endreq;
156 return StatusCode::FAILURE;
157 }
158
159 SmartDataPtr<TofDigiCol> digiCol(dataProvider(), EventModel::Digi::TofDigiCol);
160 if (digiCol == 0) {
161 //log << "no TofDigiCol found" << endreq;
162 return StatusCode::FAILURE;
163 }
164 /*
165 else {
166 log << MSG::INFO << endreq << "Detailed dump of 1st event: " << endreq << endreq;
167 int ndigi = 0;
168 TofDigiCol::const_iterator pTofDigi = digiCol->begin();
169 for (pTofDigi; pTofDigi!= digiCol->end(); pTofDigi++) {
170 log <<MSG::INFO << "Digi " << ndigi++ << " ";
171 // output the digi proper: " << digi " no longer works because
172 // "digi" now returns an integer sort order
173 (**pTofDigi).fillStream(log.stream());
174 log << endreq;
175 }
176 }
177 */
178
179 return m_cnv->convert(digiCol, re);
180}
const CLID & CLID_TofDigiCol
Definition: EventModel.cxx:241
ObjectVector< LumiDigi > LumiDigiCol
ObjectVector< TofDigi > TofDigiCol
const CLID & CLID_TofDigiCol
Definition: EventModel.cxx:241
virtual RAWEVENT * currentEvent()=0
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()
Definition: TofConverter.cxx:6