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;
47 std::vector<TofDigi*> vEtfDigi;
50 TofDigiCol::const_iterator pTofDigi = digiCol->begin();
51 for (pTofDigi; pTofDigi!= digiCol->end(); pTofDigi++) {
54 vEtfDigi.push_back(*pTofDigi);
57 teid = (*pTofDigi)->getIntId();
58 if ( teid == 0xFFFFFFFF ) {
59 m_buf[size++] = (*pTofDigi)->getOverflow();
63 if ((teid&0x4001) == 1)
continue;
65 tetdc = (*pTofDigi)->getTimeChannel();
66 teadc = (*pTofDigi)->getChargeChannel();
68 uint32_t overflow_tmp = (*pTofDigi)->getOverflow();
70 if(tetdc!=0x7FFFFFFF){
71 overflow = ((tetdc > m_dataMask) ? 1 : 0) | (overflow_tmp&1);
72 redigi = (tetdc&m_dataMask)|
73 ((reid<<m_idIndex)&m_idMask)|
74 ((overflow<<m_overflowIndex)&m_overflowMask)|
75 ((0<<m_TQIndex)&m_TQMask);
76 m_buf[size++] = redigi;
79 if(teadc!=0x7FFFFFFF){
80 overflow = ((teadc > m_dataMask) ? 1 : 0) | ((overflow_tmp>>1)&1);
81 redigi = (teadc&m_dataMask)|
82 ((reid<<m_idIndex)&m_idMask)|
83 ((overflow<<m_overflowIndex)&m_overflowMask)|
84 ((1<<m_TQIndex)&m_TQMask);
85 m_buf[size++] = redigi;
92 uint32_t shift = size;
93 for (std::vector<TofDigi*>::const_iterator pEtfDigi = vEtfDigi.begin();
94 pEtfDigi != vEtfDigi.end();
97 teid = (*pEtfDigi)->getIntId();
98 if ( teid == 0xFFFFFFFF ) {
99 m_buf[size++] = (*pEtfDigi)->getOverflow();
103 tetdc = (*pEtfDigi)->getTimeChannel();
104 teadc = (*pEtfDigi)->getChargeChannel();
106 if ( tetdc != 0x7FFFFFFF )
108 redigi = (tetdc&0x7FFFF) |
110 ((reid<<20)&0xFFF00000);
111 m_buf[size++] = redigi;
114 if ( teadc != 0x7FFFFFFF )
116 redigi = (teadc&0x7FFFF) |
118 ((reid<<20)&0xFFF00000);
119 m_buf[size++] = redigi;
123 if ( size != shift )
append2event(re, 0xa70000, size-shift, shift);
125 return StatusCode::SUCCESS;
134 uint32_t nRELayerPos, nRECellPos, nREEaWePos;
135 uint32_t nRELayerMask, nRECellMask, nREEaWeMask;
139 f.open( initFile.c_str());
142 cerr <<
"Error: could not open file " << initFile << endl;
147 cerr <<
"Error: could not find '##TofDigiConf' in file " << initFile << endl;
148 return StatusCode::FAILURE;
169 uint32_t TELayerMax, TEphiMax, TEBaEaWe;
170 uint32_t eawe = 0, layer = 0, cell = 0;
172 if(barrel_ec_eawe == 1) {
183 for(TEBaEaWe = 0; TEBaEaWe < 2; TEBaEaWe++) {
184 if (barrel_ec_eawe != 1 && TEBaEaWe > 0)
break;
185 eawe = TEBaEaWe + (barrel_ec_eawe/2);
186 for(uint32_t TELayer = 0; TELayer <= TELayerMax; TELayer++) {
187 if (barrel_ec_eawe == 1) {
195 for (uint32_t TEphi = 0; TEphi <= TEphiMax; TEphi++) {
197 uint32_t reid = (((eawe<<nREEaWePos)&nREEaWeMask)|
198 ((layer<<nRELayerPos)&nRELayerMask)|
199 ((cell<<nRECellPos)&nRECellMask));
200 uint32_t teid =
TofID::getIntID(barrel_ec_eawe, TELayer, TEphi, TEBaEaWe);
204 m_re2te[reid] = teid;
205 m_te2reMap.insert(TE2REMAP::value_type(teid, reid)) ;
214 for ( uint32_t module = 0; module < 36; ++module )
216 for ( uint32_t strip = 0; strip < 12; ++strip )
223 m_te2reMap.insert(TE2REMAP::value_type(teid, (teid&0xFFF)));
225 m_te2reMap.insert(TE2REMAP::value_type(teid, (teid&0xFFF)));
227 m_te2reMap.insert(TE2REMAP::value_type(teid, (teid&0xFFF)));
229 m_te2reMap.insert(TE2REMAP::value_type(teid, (teid&0xFFF)));
234 return StatusCode::SUCCESS;
240 TE2REMAP::iterator itr = m_te2reMap.find(teid);
242 if (itr == m_te2reMap.end()) {
243 cout <<
"wrong teid in tof" << teid << endl;
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
ObjectVector< TofDigi > TofDigiCol
void append2event(WriteRawEvent *&re, uint32_t source_id, uint32_t size, uint32_t shift=0)
static bool find(ifstream &f, string msg, string fname)
static bool expect(ifstream &f, string msg, string fname)
static bool expectInt(ifstream &f, string msg, string fname, uint32_t &val1, uint32_t &val2)
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 bool is_mrpc(const Identifier &id)
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()