6 #define coutfl std::cout << __FILE__<< " " << __LINE__ << " "
7 #define cerrfl std::cerr << __FILE__<< " " << __LINE__ << " "
29 _required_depth =
depth;
32 for (
int fee = 0; fee < MAX_FEECOUNT; fee++)
42 if ( _myPacketid == -1)
50 cerrfl <<
" received packet " << p->
getIdentifier() <<
" for pool for id " << _myPacketid << endl;
61 for ( fee = 0; fee < MAX_FEECOUNT; fee++)
63 for ( i = 0; i < p->
iValue(fee,
"FEE_LENGTH"); i++)
66 fee_data[fee].push_back(p->
iValue(fee,i,
"") );
78 if ( fee < 0 || fee >= MAX_FEECOUNT)
return 0;
79 if ( index < 0 || (
unsigned int) index >= fee_data[fee].
size() )
return 0;
80 return fee_data[fee][
index];
86 if ( strcmp(what,
"FEE_LENGTH") == 0)
88 if ( fee < 0 || fee >= MAX_FEECOUNT)
return 0;
89 return fee_data[fee].size();
96 if ( strcmp(what,
"NR_HITS") == 0)
98 return intt_hits.size();
101 if ( strcmp(what,
"ADC") == 0)
103 return iValue(hit,
F_ADC);
106 else if ( strcmp(what,
"AMPLITUDE") == 0)
111 if ( strcmp(what,
"CHIP_ID") == 0)
116 if ( strcmp(what,
"CHANNEL_ID") == 0)
121 if ( strcmp(what,
"FULL_FPHX") == 0)
126 if ( strcmp(what,
"FEE") == 0)
128 return iValue(hit,
F_FEE);
131 if ( strcmp(what,
"FPHX_BCO") == 0)
136 if ( strcmp(what,
"FULL_FPHX") == 0)
141 if ( strcmp(what,
"FULL_ROC") == 0)
146 if ( strcmp(what,
"DATAWORD") == 0)
158 if ( hit < 0 || hit >= (
int) intt_hits.size())
return 0;
163 return intt_hits[hit]->bco;
174 if ( strcmp(what,
"BCO") == 0)
176 return lValue(hit,
F_BCO);
187 for (
int fee = 0; fee < MAX_FEECOUNT ; fee++)
189 if ( fee_data[fee].
size() > d) d = fee_data[fee].size();
198 if ( hit < 0 || hit >= (
int) intt_hits.size())
return 0;
204 return intt_hits[hit]->fee;
208 return intt_hits[hit]->channel_id;
212 return intt_hits[hit]->chip_id;
216 return intt_hits[hit]->adc;
220 return intt_hits[hit]->FPHX_BCO;
224 return intt_hits[hit]->full_FPHX;
228 return intt_hits[hit]->full_ROC;
232 return intt_hits[hit]->amplitude;
236 return intt_hits[hit]->word;
248 std::cout <<
"current Pool depth " << min_depth()
249 <<
" required depth: " << _required_depth
252 return ( min_depth() >= _required_depth);
258 std::vector<intt_hit*>::const_iterator hit_itr;
262 for ( hit_itr = intt_hits.begin(); hit_itr != intt_hits.end(); ++hit_itr)
283 if (_is_decoded)
return 0;
288 for (
int fee = 0 ; fee < MAX_FEECOUNT ; fee++)
300 int header_found = 0;
303 std::vector<unsigned int> hitlist;
307 unsigned int remaining = fee_data[fee].size() - _low_mark;
308 if ( fee_data[fee].
size() < _low_mark) remaining = 0;
310 while ( j < (remaining) )
314 if (! header_found && (fee_data[fee][j] & 0xff00ffff )!= 0xad00cade )
320 if ( j > fee_data[fee].
size())
coutfl <<
"Warning " << j <<
" " << fee_data[fee].size() << endl;
328 if ( fee_data[fee].
size() -j >=3 )
330 for (
int k = 0;
k < 3;
k++) hitlist.push_back(fee_data[fee][j++]);
335 coutfl <<
" Warning - size is " << fee_data[fee].size() <<
" probably cut off" << endl;
339 if ( j > fee_data[fee].
size())
coutfl <<
"Warning " << j <<
" " << fee_data[fee].size() << endl;
342 while ( j < fee_data[fee].
size() )
346 if ( ( fee_data[fee][j] & 0xff00ffff ) == 0xad00cade )
351 if ( j > fee_data[fee].
size())
coutfl <<
"Warning " << j <<
" " << fee_data[fee].size() << endl;
353 coutfl <<
"calling decode with size " << hitlist.size() << endl;
354 intt_decode_hitlist (hitlist, fee);
360 if ( fee_data[fee][j] == 0xcafeff80 )
365 intt_decode_hitlist (hitlist, fee);
369 if ( j > fee_data[fee].
size())
coutfl <<
"Warning " << j <<
" " << fee_data[fee].size() << endl;
374 hitlist.push_back(fee_data[fee][j]);
383 remaining = fee_data[fee].size() - _low_mark;
384 if ( fee_data[fee].
size() < _low_mark) remaining = 0;
405 if(hitlist.size()>0&&fee_data[fee].size()>0&&last_index[fee]>=fee_data[fee].size()){
406 last_index[fee] -= hitlist.size();
412 if ( hitlist.size() )
415 intt_decode_hitlist (hitlist, fee);
421 for (
int fee = 0 ; fee < MAX_FEECOUNT ; fee++)
424 for (
unsigned int j = 0;
j < last_index[fee];
j++)
426 if ( fee_data[fee].
size() ) fee_data[fee].erase(fee_data[fee].
begin());
549 if ( hitlist.size() < 3)
551 coutfl <<
"hitlist too short " << endl;
555 unsigned long long BCO = 0;
556 unsigned long long l = 0;
559 BCO |= ( ((l >> 16 ) & 0xff) << 32);
561 BCO |= ( (l & 0xffff) << 16);
562 BCO |= ( (l >> 16) & 0xffff);
563 unsigned int event_counter =hitlist[2];
566 for (
unsigned int i = 3;
i < hitlist.size();
i++)
568 unsigned int x = hitlist[
i];
574 hit->
chip_id = (x >> 23) & 0x3f;
575 hit->
adc = (x >> 29) & 0x7;
584 if (last_bco[fee] > BCO)
586 coutfl <<
"fee " << fee <<
" old bco : 0x" << std::hex
587 << last_bco[fee] <<
", current: 0x" << BCO
588 << std::dec << std::endl;
590 cout << Name() <<
" pushing back hit for FEE " << fee <<
" with BCO 0x" << hex << BCO << dec
591 <<
" chip " << hit->
chip_id<<
" channel " << hit->
channel_id <<
" hit length now " << intt_hits.size() <<
", last bco: 0x" << hex << last_bco[fee] << dec << endl;
594 intt_hits.push_back(hit);
609 os <<
" Number of hits: " << iValue(0,
"NR_HITS") << endl;
613 os <<
" # FEE BCO chip_BCO chip_id channel_id ADC full_phx full_ROC Ampl." << endl;
615 for (
int i = 0;
i < iValue(0,
"NR_HITS");
i++)
617 os << setw(4) <<
i <<
" "
618 << setw(5) << iValue(
i,
F_FEE) <<
" "
619 << hex << setw(11) << lValue(
i,
F_BCO) << dec <<
" "
620 << hex << setw(2) <<
"0x" << iValue(
i,
F_FPHX_BCO) << dec <<
" "
623 << setw(5) << iValue(
i,
F_ADC) <<
" "
628 <<
"0x" << setw(8) << hex << setfill(
'0') << iValue(
i,
F_DATAWORD)
629 << setfill(
' ') << dec << endl;