BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
RawDataMdcDigiCnv.cxx
Go to the documentation of this file.
1//====================================================================
2// RawDataMdcDigiCnv.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/PropertyMgr.h"
14#include "GaudiKernel/IJobOptionsSvc.h"
15#include "GaudiKernel/SmartDataPtr.h"
16// for Mutil-thread by tianhl
17#include "GaudiKernel/ThreadGaudi.h"
18// for Mutil-thread by tianhl
19
20#include "EventModel/EventModel.h"
21#include "MdcRawEvent/MdcDigi.h"
22#include "RawDataCnv/EventManagement/RAWEVENT.h"
23#include "RawDataCnv/EventManagement/RawEvent.h"
24#include "RawDataCnv/RawDataInputSvc.h"
25#include "RawDataCnv/RawDataMdcDigiCnv.h"
26
27// REMOVE THIS LINE AFTER "PACKEDRAWEVENT_StorageType" IS ADDED TO
28// THE FILE "GaudiKernel/ClassID.h"
29extern const CLID& CLID_MdcDigiCol;
30
31// Constructor.
34{
35 PropertyMgr m_propMgr;
36 m_propMgr.declareProperty("ExWireFromRun", m_runFrom = 0 );
37 m_propMgr.declareProperty("ExWireToRun", m_runTo = 999999);
38
39 IJobOptionsSvc* jobSvc;
40 serviceLocator()->service("JobOptionsSvc", jobSvc);
41 jobSvc->setMyProperties("RawDataMdcDigiCnv", &m_propMgr);
42}
43
45{
47}
48
49// Return the identification number of this converter to the
50// persistency service.
52{
53 return CLID_MdcDigiCol;
54}
55
57{
58 std::string PackedRawDataCnvSvc_Name("PackedRawDataCnvSvc");
59 std::string RawDataInputSvc_Name("RawDataInputSvc");
60 std::string RawDataMdcDigiCnv_Name("RawDataMdcDigiCnv");
61
62 // for Mutil-thread by tianhl
63 //ConversionSvc* pCnvSvc = 0;
64 //if (pCnvSvc = dynamic_cast<ConversionSvc*>(conversionSvc())){
65 SmartIF<IService> pCnvSvc(conversionSvc());
66 if (isGaudiThreaded(pCnvSvc->name())){
67 PackedRawDataCnvSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
68 RawDataInputSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
69 RawDataMdcDigiCnv_Name += getGaudiThreadIDfromName(pCnvSvc->name());
70 }
71 //}
72
73
74 StatusCode sc = RawDataBaseCnv::initialize();
75 if ( sc.isFailure() ) {
76 return sc;
77 }
78
79 MsgStream log(messageService(), RawDataMdcDigiCnv_Name.c_str());
80
81 // Check RawDataCnvSvc
82 IService* isvc = 0;
83 StatusCode status = serviceLocator()->service(PackedRawDataCnvSvc_Name.c_str(), isvc, true);
84 m_RawDataAccess = dynamic_cast<PackedRawDataCnvSvc*> (isvc);
85 if(m_RawDataAccess == 0 ) {
86 log<<MSG::ERROR<< " RawDataMdcCnv: Cant cast to RawDataCnvSvc " <<endreq;
87 return StatusCode::FAILURE ;
88 }
89
90 IService* svc ;
91 sc = serviceLocator()->getService(RawDataInputSvc_Name.c_str(), svc);
92 //if ( sc.isFailure() ) {
93 // log<<MSG::WARNING << " Cant get RawDataInputSvc " <<endreq;
94 // return sc ;
95 //}
96 m_inputSvc = dynamic_cast<RawDataInputSvc*> (svc);
97 if(m_inputSvc == 0 ) {
98 log<<MSG::WARNING<< " Cant cast to RawDataInputSvc " <<endreq;
99 return StatusCode::FAILURE ;
100 }
101
102 m_cnv = MdcConverter::instance( m_inputSvc->runMode() );
103
104 m_cnv->init(m_runFrom, m_runTo);
105
106 return StatusCode::SUCCESS;
107}
108
109
110StatusCode RawDataMdcDigiCnv::updateObj(IOpaqueAddress* pAddr, DataObject* pObj) {
111 // Purpose and Method: This method does nothing other than announce it has
112 // been called.
113
114 //MsgStream log(msgSvc(), "RawDataMdcDigiCnv");
115 //log << MSG::DEBUG << "RawDataMdcDigiCnv::updateObj" << endreq;
116 return Converter::updateObj(pAddr, pObj);
117}
118
119// Create a converted object in the Transient Data Store.
120StatusCode RawDataMdcDigiCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
121{
122 //MsgStream log(msgSvc(), "RawDataMdcDigiCnv");
123
124 // Purpose and Method: This converter will create an empty MdcDigiCol on
125 // the TDS.
126 MdcDigiCol *digiCol = new MdcDigiCol;
127 pObj = digiCol;
128
129 RAWEVENT* evt = m_inputSvc->currentEvent();
130
131 if (evt == NULL) {
132 //log << MSG::ERROR << "RawDataMdcDigiCnv::createObj has event!" << endreq;
133 return StatusCode::FAILURE;
134 }
135
136 int runId = evt->eventHeader().run_number();
137 m_cnv->setRunId(runId);
138
139 const BufferHolder& mdcBuf = evt->getMdcBuf();
140
141 return m_cnv->convert(mdcBuf, digiCol);
142}
143
144StatusCode RawDataMdcDigiCnv::createRep(DataObject* pObj, IOpaqueAddress*& pAddr)
145{
146 // convert PixelRaw in the container into ByteStream
147 MsgStream log(messageService(), "RawDataMdcDigiCnv");
148
149 WriteRawEvent*& re = m_RawDataAccess->getRawEvent();
150 if (re == 0) {
151 log << " get RawEvent failed !" << endreq;
152 return StatusCode::FAILURE;
153 }
154
155 SmartDataPtr<MdcDigiCol> digiCol(dataProvider(), EventModel::Digi::MdcDigiCol);
156 if (digiCol == 0) {
157 log << "no MdcDigiCol found" << endreq;
158 return StatusCode::FAILURE;
159 }
160 /*
161 else {
162 log << MSG::DEBUG << endreq << "Detailed dump of 1st event: " << endreq << endreq;
163 int ndigi = 0;
164 MdcDigiCol::const_iterator pMdcDigi = digiCol->begin();
165 for (pMdcDigi; pMdcDigi!= digiCol->end(); pMdcDigi++) {
166 log <<MSG::INFO << "Digi " << ndigi++ << " ";
167 // output the digi proper: " << digi " no longer works because
168 // "digi" now returns an integer sort order
169 (**pMdcDigi).fillStream(log.stream());
170 log << endreq;
171 }
172 }
173 */
174
175 return m_cnv->convert(digiCol, re);
176}
const CLID & CLID_MdcDigiCol
Definition: EventModel.cxx:235
ObjectVector< MdcDigi > MdcDigiCol
const CLID & CLID_MdcDigiCol
Definition: EventModel.cxx:235
virtual int runMode()=0
virtual RAWEVENT * currentEvent()=0
static MdcConverter * instance(int runMode=2)
Definition: MdcConverter.cxx:6
static void destroy()
void init(int runFrom, int runTo)
StatusCode convert(const BufferHolder &src, MdcDigiCol *des)
StatusCode initialize()
virtual StatusCode updateObj(IOpaqueAddress *, DataObject *)
override the RawDataBaseCnv version
StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
static const CLID & classID()
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr)
Convert the transient object to the requested representation.
RawDataMdcDigiCnv(ISvcLocator *svc)