CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
RawDataHltRawCnv.cxx
Go to the documentation of this file.
1//====================================================================
2// RawDataHltRawCnv.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
19#include "Identifier/HltID.h"
20#include "HltEvent/HltRaw.h"
26
27
28extern const CLID& CLID_HltRawCol;
29
30// Constructor.
33{
34 //init();
35}
37}
38
39// Return the identification number of this converter to the
40// persistency service.
42{
43 return CLID_HltRawCol;
44}
45
47{
48 std::string PackedRawDataCnvSvc_Name("PackedRawDataCnvSvc");
49 std::string RawDataInputSvc_Name("RawDataInputSvc");
50 std::string RawDataHltRawCnv_Name("RawDataHltRawCnv");
51
52 // for Mutil-thread by tianhl
53 //ConversionSvc* pCnvSvc = 0;
54 //if (pCnvSvc = dynamic_cast<ConversionSvc*>(conversionSvc())){
55 SmartIF<IService> pCnvSvc(conversionSvc());
56 if (isGaudiThreaded(pCnvSvc->name())){
57 PackedRawDataCnvSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
58 RawDataInputSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
59 RawDataHltRawCnv_Name += getGaudiThreadIDfromName(pCnvSvc->name());
60 }
61 //}
62
63 MsgStream log(messageService(), RawDataHltRawCnv_Name.c_str());
64 StatusCode sc = RawDataBaseCnv::initialize();
65 if (StatusCode::SUCCESS != sc) {
66
67 return sc;
68 }
69
70 // Check RawDataCnvSvc
71 IService* isvc = 0;
72 StatusCode status = serviceLocator()->service(PackedRawDataCnvSvc_Name.c_str(), isvc, true);
73
74 m_RawDataAccess = dynamic_cast<PackedRawDataCnvSvc*> (isvc);
75 if(m_RawDataAccess == 0 ) {
76 log<<MSG::ERROR<< " RawDataCnv: Cant cast to RawDataCnvSvc " <<endreq;
77 return StatusCode::FAILURE ;
78 }
79
80 if(m_RawDataAccess)
81 log << MSG::INFO << "RawDataCnvSvc retrieved "<< endreq;
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
90 m_inputSvc = dynamic_cast<RawDataInputSvc*> (svc);
91 if(m_inputSvc == 0 ) {
92 log<<MSG::WARNING<< " Cant cast to RawDataInputSvc " <<endreq;
93 return StatusCode::FAILURE ;
94 }
95
96 return StatusCode::SUCCESS;
97}
98
99
100StatusCode RawDataHltRawCnv::updateObj(IOpaqueAddress* pAddr, DataObject* pObj) {
101 // Purpose and Method: This method does nothing other than announce it has
102 // been called.
103
104 //MsgStream log(msgSvc(), "RawDataHltRawCnv");
105 //log << MSG::DEBUG << "RawDataHltRawCnv::updateObj" << endreq;
106 return Converter::updateObj(pAddr, pObj);
107}
108
109// Create a converted object in the Transient Data Store.
110StatusCode RawDataHltRawCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
111{
112 //MsgStream log(msgSvc(), "RawDataHltRawCnv");
113 RawDataAddress *pEFAddr;
114 uint32_t TEData[2];
115
116 // Purpose and Method: This converter will create an empty HltRawCol on
117 // the TDS.
118 HltRawCol *digiCol = new HltRawCol;
119 pObj = digiCol;
120
121 RAWEVENT *evt = m_inputSvc->currentEvent();
122 if (evt == NULL) {
123 cout << "RawDataHltRawCnv::createObj can't get event!" << endl;
124 return StatusCode::FAILURE;
125 }
126
127 int digiId = 0;
128 const BufferHolder& hltBuf = evt->getHltBuf();
129 uint32_t nbuf = hltBuf.nBuf();
130
131 uint32_t REId = 0, TEId = 0;
132 uint32_t nmdc=0,ntof=0,nemc=0,nmuc=0;
133 for (uint32_t i = 0; i < nbuf; i++) {
134 uint32_t* buf = hltBuf(i);
135 uint32_t bufSize = hltBuf.bufSize(i);
136 for (uint32_t j = 0; j < bufSize; j++, digiId++) {
137
138 m_hltBuilder.unPack(buf[j], digiId, REId, TEData[0], TEData[1]);
139 TEId = m_hltBuilder.getTEID(REId);
140 if ( TEId == 0xFFFFFFFF ) continue;
141
142// log << MSG::NIL << "HLT digit No: " << digiId << "="<<std::hex<<buf[j]
143// <<"===>"<<TEId<<" : "<<TEData[0]<<","<<TEData[1]<<std::dec<<endreq;
144 for (uint32_t k=0; k< 2;k++){
145 // Create new track
146 if(k==0||(k==1&&TEData[k])){
147 if(k==1) TEId+=1;
149 nmdc=TEData[k]&0xFF;
150 ntof=(TEData[k]>>8)&0xFF;
151 nemc=(TEData[k]>>16)&0xFF;
152 nmuc=(TEData[k]>>24)&0xFF;
153 //log << MSG::INFO << "number=" << std::hex <<TEData[k] <<std::dec<< endreq;
154 }
155 HltRaw* hltRaw = new HltRaw(HltID::convert(TEId,nmdc,ntof,nemc,nmuc));
156 hltRaw->setIntChannel(TEData[k]);
157 //hltRaw->setFloatChannel(TEData[k]);
158 hltRaw->setChargeChannel(TEData[k]);
159
160 digiCol->push_back ( hltRaw );
161 }
162 }
163 }
164 }
165 return StatusCode::SUCCESS;
166}
167
168StatusCode RawDataHltRawCnv::createRep(DataObject* pObj, IOpaqueAddress*& pAddr)
169{
170 // convert PixelRaw in the container into ByteStream
171 //MsgStream log(messageService(), "RawDataHltRawCnv");
172
173 WriteRawEvent*& re = m_RawDataAccess->getRawEvent();
174 if(re == 0) {
175 //log << " get RawEvent failed !" << endreq;
176 return StatusCode::FAILURE;
177 }
178
179 SmartDataPtr<HltRawCol> digiCol(dataProvider(), EventModel::Hlt::HltRawCol);
180 if (digiCol == 0) {
181 //log << "no HltRawCol found" << endreq;
182 return StatusCode::FAILURE;
183 }
184 /*
185 else {
186 log << MSG::INFO << endreq << "Detailed dump of 1st event: " << endreq << endreq;
187 int ndigi = 0;
188 HltRawCol::const_iterator pHltRaw = digiCol->begin();
189 for (pHltRaw; pHltRaw!= digiCol->end(); pHltRaw++) {
190 log <<MSG::INFO << "Raw " << ndigi++ << " ";
191 // output the digi proper: " << digi " no longer works because
192 // "digi" now returns an integer sort order
193 (**pHltRaw).fillStream(log.stream());
194 log << endreq;
195 }
196 }
197 */
198 return m_hltBuilder.pack(digiCol, re);
199}
200
201
unsigned const long PACKEDRAWEVENT_StorageType
Definition: ClassID_temp.h:17
const CLID & CLID_HltRawCol
Definition: EventModel.cxx:329
ObjectVector< HltRaw > HltRawCol
Definition: HltRaw.h:35
const CLID & CLID_HltRawCol
Definition: EventModel.cxx:329
uint32_t nBuf() const
Definition: BufferHolder.h:15
uint32_t bufSize(int i) const
Definition: BufferHolder.h:16
uint32_t getTEID(uint32_t reid)
Definition: HltBuilder.h:16
void unPack(uint32_t reDigi, uint32_t n, uint32_t &REId, uint32_t &TEData1, uint32_t &TEData2)
Definition: HltBuilder.cxx:22
StatusCode pack(HltRawCol *digiCol, WriteRawEvent *&re)
Definition: HltBuilder.cxx:47
static bool is_number(const Identifier &id)
Definition: HltID.cxx:108
static Identifier convert(const unsigned int id, const int nmdc=0, const int ncgem=0, const int ntof=0, const int nemc=0, const int nmuc=0)
convert global id to sub-id(Identifier)
Definition: HltID.cxx:12
Definition: HltRaw.h:15
void setIntChannel(const unsigned int intChannel)
Definition: HltRaw.h:21
virtual RAWEVENT * currentEvent()=0
virtual WriteRawEvent *& getRawEvent()
const BufferHolder & getHltBuf() const
Definition: RAWEVENT.h:95
StatusCode initialize()
static const CLID & classID()
StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr)
Convert the transient object to the requested representation.
virtual StatusCode updateObj(IOpaqueAddress *, DataObject *)
override the RawDataBaseCnv version
StatusCode initialize()
RawDataHltRawCnv(ISvcLocator *svc)
void setChargeChannel(const unsigned int chargeChannel)
Definition: RawData.cxx:30
_EXTERN_ std::string HltRawCol
Definition: EventModel.h:79