BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
RawDataHltRawCnv.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "HltEvent/HltRaw.h"
4#include "Identifier/HltID.h"
5#include "RawDataCnv/EventManagement/HltBuilder.h"
6#include "RawDataCnv/RawDataAddress.h"
7
8#include "RawDataBaseCnv.h"
9
10extern const CLID& CLID_HltRawCol;
11
13private:
14 /// HltBuilder for packing or unpacking data
15 HltBuilder m_hltBuilder;
16
17public:
18 RawDataHltRawCnv( ISvcLocator* svc ) : RawDataBaseCnv( svc, classID() ) {}
19
20 static const CLID& classID() { return CLID_HltRawCol; }
21
22 StatusCode createObj( IOpaqueAddress* pAddr, DataObject*& pObj ) {
23 // MsgStream log(msgSvc(), "RawDataHltRawCnv");
24 RawDataAddress* pEFAddr;
25 uint32_t TEData[2];
26
27 // Purpose and Method: This converter will create an empty HltRawCol on
28 // the TDS.
29 HltRawCol* digiCol = new HltRawCol;
30 pObj = digiCol;
31
32 RAWEVENT* evt = m_inputSvc->currentEvent();
33 if ( !evt )
34 {
35 cout << "RawDataHltRawCnv::createObj can't get event!" << endl;
36 return StatusCode::FAILURE;
37 }
38
39 int digiId = 0;
40 const BufferHolder& hltBuf = evt->getHltBuf();
41 uint32_t nbuf = hltBuf.nBuf();
42
43 uint32_t REId = 0, TEId = 0;
44 uint32_t nmdc = 0, ntof = 0, nemc = 0, nmuc = 0;
45 for ( uint32_t i = 0; i < nbuf; i++ )
46 {
47 uint32_t* buf = hltBuf( i );
48 uint32_t bufSize = hltBuf.bufSize( i );
49 for ( uint32_t j = 0; j < bufSize; j++, digiId++ )
50 {
51
52 m_hltBuilder.unPack( buf[j], digiId, REId, TEData[0], TEData[1] );
53 TEId = m_hltBuilder.getTEID( REId );
54 if ( TEId == 0xFFFFFFFF ) continue;
55
56 // log << MSG::NIL << "HLT digit No: " << digiId << "="<<std::hex<<buf[j]
57 // <<"===>"<<TEId<<" : "<<TEData[0]<<","<<TEData[1]<<std::dec<<endmsg;
58 for ( uint32_t k = 0; k < 2; k++ )
59 {
60 // Create new track
61 if ( k == 0 || ( k == 1 && TEData[k] ) )
62 {
63 if ( k == 1 ) TEId += 1;
64 if ( HltID::is_number( HltID::convert( TEId ) ) )
65 {
66 nmdc = TEData[k] & 0xFF;
67 ntof = ( TEData[k] >> 8 ) & 0xFF;
68 nemc = ( TEData[k] >> 16 ) & 0xFF;
69 nmuc = ( TEData[k] >> 24 ) & 0xFF;
70 // log << MSG::INFO << "number=" << std::hex <<TEData[k] <<std::dec<< endmsg;
71 }
72 HltRaw* hltRaw = new HltRaw( HltID::convert( TEId, nmdc, ntof, nemc, nmuc ) );
73 hltRaw->setIntChannel( TEData[k] );
74 // hltRaw->setFloatChannel(TEData[k]);
75 hltRaw->setChargeChannel( TEData[k] );
76
77 digiCol->push_back( hltRaw );
78 }
79 }
80 }
81 }
82 return StatusCode::SUCCESS;
83 }
84
85 StatusCode createRep( DataObject* pObj, IOpaqueAddress*& pAddr ) {
86 // convert PixelRaw in the container into ByteStream
87 // MsgStream log(msgSvc(), "RawDataHltRawCnv");
88
89 WriteRawEvent*& re = m_cnvSvc->getRawEvent();
90 if ( re == 0 )
91 {
92 // log << " get RawEvent failed !" << endmsg;
93 return StatusCode::FAILURE;
94 }
95
96 SmartDataPtr<HltRawCol> digiCol( dataProvider(), EventModel::Hlt::HltRawCol );
97 if ( digiCol == 0 )
98 {
99 // log << "no HltRawCol found" << endmsg;
100 return StatusCode::FAILURE;
101 }
102
103 return m_hltBuilder.pack( digiCol, re );
104 }
105};
const CLID & CLID_HltRawCol
ObjectVector< HltRaw > HltRawCol
eformat::write::FullEventFragment WriteRawEvent
const CLID & CLID_HltRawCol
static Identifier convert(const unsigned int id, const int nmdc=0, const int ntof=0, const int nemc=0, const int nmuc=0)
convert global id to sub-id(Identifier)
Definition HltID.cxx:10
static bool is_number(const Identifier &id)
Definition HltID.cxx:97
void setIntChannel(const unsigned int intChannel)
IRawDataCnvSvc * m_cnvSvc
IRawDataInputSvc * m_inputSvc
RawDataBaseCnv(long storageType, const CLID &clid, ISvcLocator *svc)
static const CLID & classID()
StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr)
RawDataHltRawCnv(ISvcLocator *svc)
void setChargeChannel(const unsigned int chargeChannel)
Definition RawData.cxx:24