3#include "Identifier/MdcID.h"
4#include "RawDataCnv/EventManagement/MdcBuilder.h"
11 m_re2te =
new uint32_t[16384];
12 memset((
void*)m_re2te, 0xFF, 16384*
sizeof(uint32_t));
23 uint32_t &overFlow, uint32_t &TorQ)
25 REId = (reDigi&m_idMask)>>m_idIndex;
27 TEData = reDigi&m_dataMask;
28 overFlow = (reDigi&m_overflowMask)>>m_overflowIndex;
29 TorQ = (reDigi&m_TQMask)>>m_TQIndex;
38 cerr <<
"MdcBuilder::pack can't get digiCol" << endl;
39 return StatusCode::FAILURE;
43 uint32_t teid = 0, tetdc = 0, teadc = 0, reid = 0, redigi = 0, overflow = 0;
45 MdcDigiCol::const_iterator pMdcDigi = digiCol->begin();
46 for (pMdcDigi; pMdcDigi!= digiCol->end(); pMdcDigi++) {
50 if ( layer == 20 && wire < 8 ) {
53 else if ( layer == 42 && wire < 8 ) {
56 else if ( layer == 40 ) {
57 if ( wire >= 200 && wire < 208 ) {
60 else if ( wire >= 208 && wire < 216 ) {
68 tetdc = (*pMdcDigi)->getTimeChannel();
69 teadc = (*pMdcDigi)->getChargeChannel();
71 uint32_t overflow_tmp = (*pMdcDigi)->getOverflow();
73 if(tetdc!=0x7FFFFFFF){
74 overflow = ((tetdc > m_dataMask) ? 1 : 0) | (overflow_tmp&1);
75 redigi = (tetdc&m_dataMask)|
76 ((reid<<m_idIndex)&m_idMask)|
77 ((overflow<<m_overflowIndex)&m_overflowMask)|
78 ((0<<m_TQIndex)&m_TQMask);
79 m_buf[size++] = redigi;
82 if(teadc!=0x7FFFFFFF){
83 overflow = ((teadc > m_dataMask) ? 1 : 0) | ((overflow_tmp>>1)&1);
84 redigi = (teadc&m_dataMask)|
85 ((reid<<m_idIndex)&m_idMask)|
86 ((overflow<<m_overflowIndex)&m_overflowMask)|
87 ((1<<m_TQIndex)&m_TQMask);
88 m_buf[size++] = redigi;
94 return StatusCode::SUCCESS;
103 uint32_t NRELAYERPOS, NREWIREPOS, NREEAWEPOS;
104 uint32_t NRELAYERMASK, NREWIREMASK, NREEAWEMASK;
109 f.open( initFile.c_str());
112 cerr <<
"Error: could not open file " << initFile << endl;
117 cerr <<
"Error: could not find '##MdcDigiConf' in file " << initFile << endl;
118 return StatusCode::FAILURE;
133 uint32_t nRELayerPos, nREWirePos, nREEaWePos;
134 uint32_t nRELayerMask, nREWireMask, nREEaWeMask;
142 uint32_t layer, wire;
144 nRELayerPos = NRELAYERPOS;
145 nREWirePos = NREWIREPOS;
146 nRELayerMask = NRELAYERMASK;
147 nREWireMask = NREWIREMASK;
149 for(uint32_t TELayer = 0; TELayer <= TELayerMax; TELayer++ )
156 nRELayerMask = nRELayerMask&0xFFFFFBFF;
157 nREWireMask = nREWireMask|0x00000400;
165 for(uint32_t TEWire = 0; TEWire <= TEWireMax; TEWire++ )
168 uint32_t reid = (((layer<<nRELayerPos)&nRELayerMask)|
169 ((wire<<nREWirePos)&nREWireMask))>>2;
179 cerr <<
"Error: REID overflow !" << reid << endl;
184 m_re2te[reid] = teid;
185 m_te2reMap.insert(TE2REMAP::value_type(teid, reid)) ;
190 return StatusCode::SUCCESS;
196 TE2REMAP::iterator itr = m_te2reMap.find(teid);
198 if (itr == m_te2reMap.end()) {
199 cout <<
"wrong teid in mdc " << teid << endl;
ObjectVector< MdcDigi > MdcDigiCol
void append2event(WriteRawEvent *&re, uint32_t source_id, uint32_t size)
static bool expect(ifstream &f, string msg, string fname)
static bool expectInt(ifstream &f, string msg, string fname, uint32_t &val1, uint32_t &val2)
static bool find(ifstream &f, string msg, string fname)
virtual uint32_t getREID(uint32_t teid)
virtual StatusCode pack(MdcDigiCol *digiCol, WriteRawEvent *&re)
virtual StatusCode initialize(string &initFile)
virtual void unPack(uint32_t reDigi, uint32_t &REId, uint32_t &TEData, uint32_t &overFlow, uint32_t &TorQ)
static value_type getAXIAL_LAYER_MAX()
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
static value_type getAXIAL_WIRE_MAX()
static int wire(const Identifier &id)
static value_type getIntID(unsigned int wireType, unsigned int layer, unsigned int wire)
static value_type getSTEREO_LAYER_MAX()