BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
RawDataEvtHeaderCnv.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
2// for Mutil-thread by tianhl
3#include "GaudiKernel/ThreadGaudi.h"
4// for Mutil-thread by tianhl
5
6#include "RawDataCnv/RawDataAddress.h"
7#include "RawDataCnv/RawDataInputSvc.h"
8#include "RawDataCnv/PackedRawDataCnvSvc.h"
9#include "RawDataCnv/EventManagement/RAWEVENT.h"
10#include "EventModel/EventHeader.h"
11#include "RawDataCnv/RawDataEvtHeaderCnv.h"
12
13extern const CLID& CLID_EventHeader;
14
17{
18 // for Mutil-thread by tianhl
19 //init();
20 // for Mutil-thread by tianhl
21}
22
24{
25 StatusCode sc = RawDataBaseCnv::initialize();
26 if ( sc.isFailure() ) return sc;
27
28 std::string PackedRawDataCnvSvc_Name("PackedRawDataCnvSvc");
29 std::string RawDataInputSvc_Name("RawDataInputSvc");
30 std::string RawDataEvtHeaderCnv_Name("RawDataEvtHeaderCnv");
31
32 // for Mutil-thread by tianhl
33 //ConversionSvc* pCnvSvc = 0;
34 //if (pCnvSvc = dynamic_cast<ConversionSvc*>(conversionSvc())){
35 SmartIF<IService> pCnvSvc(conversionSvc());
36 if (isGaudiThreaded(pCnvSvc->name())){
37 PackedRawDataCnvSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
38 RawDataInputSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
39 RawDataEvtHeaderCnv_Name += getGaudiThreadIDfromName(pCnvSvc->name());
40 }
41 //}
42 // for Mutil-thread by tianhl
43 MsgStream log(messageService(), RawDataEvtHeaderCnv_Name.c_str());
44
45 IService* svc = 0;
46 sc = serviceLocator()->service(PackedRawDataCnvSvc_Name.c_str(), svc);
47 if ( sc.isFailure() ) {
48 log << MSG::ERROR << "Can't get RawDataAccess interface" << endreq;
49 return StatusCode::FAILURE;
50 }
51
52 m_RawDataAccess = dynamic_cast<PackedRawDataCnvSvc*> (svc);
53 if (m_RawDataAccess == 0 ) {
54 log << MSG::ERROR << "RawDataEvtHeaderCnv: Cant cast to RawDataCnvSvc" << endreq;
55 return StatusCode::FAILURE;
56 }
57
58 sc = serviceLocator()->getService(RawDataInputSvc_Name.c_str(), svc);
59 if ( sc.isFailure() ) {
60 log << MSG::WARNING << "Cant get RawDataInputSvc " << endreq;
61 return sc ;
62 }
63
64 m_inputSvc = dynamic_cast<RawDataInputSvc*> (svc);
65 if ( m_inputSvc == 0 ) {
66 log << MSG::ERROR << "Cant cast to RawDataInputSvc" << endreq;
67 return StatusCode::FAILURE ;
68 }
69
70 return StatusCode::SUCCESS;
71}
72
74{
75 return CLID_EventHeader;
76}
77
78StatusCode RawDataEvtHeaderCnv::updateObj(IOpaqueAddress* pAddr, DataObject* pObj) {
79 //MsgStream log(msgSvc(), "RawDataEvtHeaderCnv");
80 //log << MSG::DEBUG << "RawDataEvtHeaderCnv::updateObj" << endreq;
81 return Converter::updateObj(pAddr, pObj);
82}
83
84// Create a converted object in the Transient Data Store.
85StatusCode RawDataEvtHeaderCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
86{
87 StatusCode sc;
88 RawDataAddress *pEFAddr;
89 const RAWEVENT *evt;
90
92 pObj = header;
93
94 //if ( (pEFAddr = dynamic_cast<RawDataAddress*>(pAddr)) ) {
95 evt = m_inputSvc->currentEvent();
96
97 if (evt == NULL) return StatusCode::FAILURE;
98
99 header->setEventNumber(evt->eventHeader().event_number());
100 header->setRunNumber(evt->eventHeader().run_number());
101 header->setTime(evt->eventHeader().time());
102 header->setFlag1( evt->eventHeader().flag1() );
103 //header->setFlag2( evt->eventHeader().flag2() );
104
105
106 return StatusCode::SUCCESS;
107 //}
108 //else {
109 // return StatusCode::FAILURE;
110 //}
111
112}
const CLID & CLID_EventHeader
Definition: EventModel.cxx:196
const CLID & CLID_EventHeader
Definition: EventModel.cxx:196
virtual RAWEVENT * currentEvent()=0
StatusCode initialize()
RawDataEvtHeaderCnv(ISvcLocator *svc)
StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
virtual StatusCode updateObj(IOpaqueAddress *, DataObject *)
override the RawDataBaseCnv version
static const CLID & classID()