BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
RawDataEmcDigiCnv.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "EmcRawEvent/EmcDigi.h"
4#include "EventModel/EventModel.h"
5#include "RawDataCnv/EventManagement/RAWEVENT.h"
6#include "RawDataCnv/EventManagement/RawEventDef.h"
7#include "RawDataCnv/Util/EmcConverter.h"
8
9#include "RawDataBaseCnv.h"
10
11extern const CLID& CLID_EmcDigiCol;
12
14public:
15 // Standard Constructor.
16 RawDataEmcDigiCnv( ISvcLocator* svc ) : RawDataBaseCnv( svc, classID() ){};
17
19
20 StatusCode initialize() override {
21 MsgStream log( msgSvc(), "RawDataEmcDigiCnv" );
22
24 if ( sc.isFailure() )
25 {
26 log << MSG::ERROR << "Failed to initialize Converter" << endmsg;
27 return sc;
28 }
29
30 m_cnv = EmcConverter::instance();
31
32 return StatusCode::SUCCESS;
33 }
34
35 // Return the class type of this converter.
36 static const CLID& classID() { return CLID_EmcDigiCol; }
37
38 // Create a converted
39 StatusCode createObj( IOpaqueAddress*, DataObject*& pObj ) {
40 MsgStream log( msgSvc(), "RawDataEmcDigiCnv" );
41
42 // Purpose and Method: This converter will create an empty EmcDigiCol on
43 // the TDS.
44 EmcDigiCol* digiCol = new EmcDigiCol;
45 pObj = digiCol;
46
47 RAWEVENT* evt = m_inputSvc->currentEvent();
48 if ( !evt )
49 {
50 cout << "RawDataEmcDigiCnv::createObj can't get event!" << endl;
51 return StatusCode::FAILURE;
52 }
53
54 const BufferHolder& emcBuf = evt->getEmcBuf();
55
56 return m_cnv->convert( emcBuf, digiCol );
57 }
58
59 StatusCode createRep( DataObject*, IOpaqueAddress*& ) {
60 // convert PixelRaw in the container into ByteStream
61 MsgStream log( msgSvc(), "RawDataEmcDigiCnv" );
62
63 WriteRawEvent*& re = m_cnvSvc->getRawEvent();
64 if ( re == 0 )
65 {
66 log << " get RawEvent failed !" << endmsg;
67 return StatusCode::FAILURE;
68 }
69
70 SmartDataPtr<EmcDigiCol> digiCol( dataProvider(), EventModel::Digi::EmcDigiCol );
71 if ( !digiCol )
72 {
73 log << "no EmcDigiCol found" << endmsg;
74 return StatusCode::FAILURE;
75 }
76
77 return m_cnv->convert( digiCol, re );
78 }
79
80private:
81 /// Emc converter for unpacking or packing data
82 EmcConverter* m_cnv;
83};
ObjectVector< EmcDigi > EmcDigiCol
const CLID & CLID_EmcDigiCol
eformat::write::FullEventFragment WriteRawEvent
const CLID & CLID_EmcDigiCol
IMessageSvc * msgSvc()
static EmcConverter * instance(int runMode=2)
static void destroy()
IRawDataCnvSvc * m_cnvSvc
IRawDataInputSvc * m_inputSvc
RawDataBaseCnv(long storageType, const CLID &clid, ISvcLocator *svc)
StatusCode initialize()
static const CLID & classID()
StatusCode createRep(DataObject *, IOpaqueAddress *&)
StatusCode createObj(IOpaqueAddress *, DataObject *&pObj)
StatusCode initialize() override
RawDataEmcDigiCnv(ISvcLocator *svc)