BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcConverter.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/Bootstrap.h"
3
6
7EmcConverter* EmcConverter::s_instance = 0;
8
10{
11 if ( s_instance == 0 ) {
12 s_instance = new EmcConverter(runMode);
13 }
14
15 return s_instance;
16}
17
19{
20 if ( s_instance != 0 ) {
21 delete s_instance;
22 s_instance = 0;
23 }
24}
25
26StatusCode EmcConverter::convert(const BufferHolder& src, EmcDigiCol* des)
27{
28 uint32_t REId, TEId, TETDC, TEADC, measure;
29 uint32_t nbuf = src.nBuf();
30
31 for (uint32_t i = 0; i < nbuf; ++i) { //loop the buffer
32 uint32_t* buf = src(i);
33 uint32_t* bufend = buf + src.bufSize(i);
34 for (; buf < bufend; ++buf) { //loop the digit
35
36 m_builder.unPack(*buf, REId, TETDC, TEADC, measure);
37
38 TEId = m_builder.getTEID(REId);
39 if ( TEId == 0xFFFFFFFF ) continue;
40
41 if ( m_EmcProvider ) {
42 // by fucd: if not good digi, reject. Only for online mode now
44 |EmcRawDataProvider::DropHot,TEId,measure,TEADC,TETDC)) continue;
45 Identifier id(TEId);
46 m_EmcProvider->doCalib(id, measure, TEADC);
47 }
48
49 // create and set the DataObject
50 EmcDigi* emcDigi = new EmcDigi(Identifier(TEId), TETDC, TEADC);
51 emcDigi->setMeasure(measure);
52 des->push_back(emcDigi);
53 }
54 }
55
56 return StatusCode::SUCCESS;
57}
58
60{
61 return m_builder.pack(src, des);
62}
63
64EmcConverter::EmcConverter(int runMode)
65 : m_runMode(runMode),
66 m_EmcProvider(0)
67{
68 if ( m_runMode == 1 ) {
69 // by fucd: only when online mode, use raw data provider here
70 IService* svc ;
71 StatusCode sc = Gaudi::svcLocator()->getService("RawDataProviderSvc", svc);
72 //if ( sc.isFailure() ) {
73 // log << MSG::ERROR << "Cannot get Raw Data Provider Service!" << endreq;
74 //}
75 IRawDataProviderSvc* rawSvc = dynamic_cast<IRawDataProviderSvc*> (svc);
76 if ( rawSvc != 0 ) {
77 m_EmcProvider = rawSvc->getEmcProvider();
78 }
79 else {
80 std::cerr << "Failed to get the RawDataProviderSvc" << std::endl;
81 }
82 }
83}
84
85EmcConverter::~EmcConverter()
86{
87}
ObjectVector< EmcDigi > EmcDigiCol
Definition: EmcDigi.h:43
uint32_t nBuf() const
Definition: BufferHolder.h:15
uint32_t bufSize(int i) const
Definition: BufferHolder.h:16
StatusCode pack(EmcDigiCol *digiCol, WriteRawEvent *&re)
Definition: EmcBuilder.cxx:33
uint32_t getTEID(uint32_t reid)
Definition: EmcBuilder.h:16
void unPack(uint32_t reDigi, uint32_t &REId, uint32_t &TETDC, uint32_t &TEADC, uint32_t &measure)
Definition: EmcBuilder.cxx:22
static EmcConverter * instance(int runMode=2)
Definition: EmcConverter.cxx:9
static void destroy()
StatusCode convert(const BufferHolder &src, EmcDigiCol *des)
void setMeasure(const unsigned int measure)
Definition: EmcDigi.h:24
bool isGoodEmcDigi(uint32_t control, uint32_t id, uint32_t measure, uint32_t adc, uint32_t tdc)
void doCalib(Identifier &id, uint32_t &measure, uint32_t &adc)
virtual EmcRawDataProvider * getEmcProvider()=0