3#include "Identifier/TofID.h"
4#include "RawDataCnv/EventManagement/TofBuilder.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;
29 TEData = (reDigi&m_dataMask);
30 overFlow = (reDigi&m_overflowMask)>>m_overflowIndex;
31 TorQ = (reDigi&m_TQMask)>>m_TQIndex;
41 cerr <<
"TofBuilder::pack can't get digiCol" << endl;
42 return StatusCode::FAILURE;
46 uint32_t teid = 0, tetdc = 0, teadc = 0, reid = 0, redigi = 0, overflow = 0;
48 TofDigiCol::const_iterator pTofDigi = digiCol->begin();
49 for (pTofDigi; pTofDigi!= digiCol->end(); pTofDigi++) {
50 teid = (*pTofDigi)->getIntId();
51 if ( teid == 0xFFFFFFFF ) {
52 m_buf[size++] = (*pTofDigi)->getOverflow();
56 if ((teid&0x4001) == 1)
continue;
58 tetdc = (*pTofDigi)->getTimeChannel();
59 teadc = (*pTofDigi)->getChargeChannel();
61 uint32_t overflow_tmp = (*pTofDigi)->getOverflow();
63 if(tetdc!=0x7FFFFFFF){
64 overflow = ((tetdc > m_dataMask) ? 1 : 0) | (overflow_tmp&1);
65 redigi = (tetdc&m_dataMask)|
66 ((reid<<m_idIndex)&m_idMask)|
67 ((overflow<<m_overflowIndex)&m_overflowMask)|
68 ((0<<m_TQIndex)&m_TQMask);
69 m_buf[size++] = redigi;
72 if(teadc!=0x7FFFFFFF){
73 overflow = ((teadc > m_dataMask) ? 1 : 0) | ((overflow_tmp>>1)&1);
74 redigi = (teadc&m_dataMask)|
75 ((reid<<m_idIndex)&m_idMask)|
76 ((overflow<<m_overflowIndex)&m_overflowMask)|
77 ((1<<m_TQIndex)&m_TQMask);
78 m_buf[size++] = redigi;
84 return StatusCode::SUCCESS;
93 uint32_t nRELayerPos, nRECellPos, nREEaWePos;
94 uint32_t nRELayerMask, nRECellMask, nREEaWeMask;
98 f.open( initFile.c_str());
101 cerr <<
"Error: could not open file " << initFile << endl;
106 cerr <<
"Error: could not find '##TofDigiConf' in file " << initFile << endl;
107 return StatusCode::FAILURE;
128 uint32_t TELayerMax, TEphiMax, TEBaEaWe;
129 uint32_t eawe = 0, layer = 0, cell = 0;
131 if(barrel_ec_eawe == 1) {
142 for(TEBaEaWe = 0; TEBaEaWe < 2; TEBaEaWe++) {
143 if (barrel_ec_eawe != 1 && TEBaEaWe > 0)
break;
144 eawe = TEBaEaWe + (barrel_ec_eawe/2);
145 for(uint32_t TELayer = 0; TELayer <= TELayerMax; TELayer++) {
146 if (barrel_ec_eawe == 1) {
154 for (uint32_t TEphi = 0; TEphi <= TEphiMax; TEphi++) {
156 uint32_t reid = (((eawe<<nREEaWePos)&nREEaWeMask)|
157 ((layer<<nRELayerPos)&nRELayerMask)|
158 ((cell<<nRECellPos)&nRECellMask));
159 uint32_t teid =
TofID::getIntID(barrel_ec_eawe, TELayer, TEphi, TEBaEaWe);
163 m_re2te[reid] = teid;
164 m_te2reMap.insert(TE2REMAP::value_type(teid, reid)) ;
172 return StatusCode::SUCCESS;
178 TE2REMAP::iterator itr = m_te2reMap.find(teid);
180 if (itr == m_te2reMap.end()) {
181 cout <<
"wrong teid in tof" << teid << endl;
ObjectVector< TofDigi > TofDigiCol
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 StatusCode initialize(string &initFile)
virtual StatusCode pack(TofDigiCol *digiCol, WriteRawEvent *&re)
virtual void unPack(uint32_t reDigi, uint32_t &REId, uint32_t &TEData, uint32_t &overFlow, uint32_t &TorQ)
virtual uint32_t getREID(uint32_t teid)
static value_type getPHI_BARREL_MAX()
static value_type getBARREL_EC_MIN()
static value_type getBARREL_EC_MAX()
static value_type getLAYER_ENDCAP_MAX()
static value_type getIntID(int barrel_ec, int layer, int phi_module, int end)
static value_type getLAYER_BARREL_MAX()