6 #define coutfl cout << __FILE__<< " " << __LINE__ << " "
7 #define cerrfl cerr << __FILE__<< " " << __LINE__ << " "
22 std::vector<intt_hit*>::const_iterator hit_itr;
44 if ( hitlist.size() < 3)
50 unsigned long long BCO = 0;
51 unsigned long long l = 0;
54 BCO |= ( ((l >> 16 ) & 0xff) << 32);
56 BCO |= ( (l & 0xffff) << 16);
57 BCO |= ( (l >> 16) & 0xffff);
58 unsigned int event_counter =hitlist[2];
60 for (
unsigned int i = 3;
i < hitlist.size();
i++)
62 unsigned int x = hitlist[
i];
68 hit->
chip_id = (x >> 23) & 0x3f;
69 hit->
adc = (x >> 29) & 0x7;
91 unsigned int index = 0;
96 while ( index < payload_length)
99 while ( (buffer[index] & 0xff00ffff ) != 0xf000caf0 )
101 coutfl <<
"skipping at " << index <<
" values " << hex << buffer[
index] << dec << endl;
103 if (index >= payload_length)
105 coutfl <<
" reached end at " << index <<
" values " << hex << buffer[
index] << dec << endl;
112 unsigned short fee = ( buffer[
index] >> 20 ) & 0xf;
113 unsigned short len = ( (buffer[
index] >> 16) & 0xf) >>1;
117 for (
int i = 0;
i < len ;
i++)
120 fee_data[fee].push_back(buffer[index++]);
147 int header_found = 0;
149 std::vector<unsigned int> hitlist;
156 if (! header_found && (
fee_data[fee][j] & 0xff00ffff )!= 0xad00cade )
168 for (
int k = 0;
k < 3;
k++) hitlist.push_back(
fee_data[fee][j++]);
181 if ( (
fee_data[fee][j] & 0xff00ffff ) == 0xad00cade )
193 if (
fee_data[fee][j] == 0xcafeff80 )
203 hitlist.push_back(
fee_data[fee][j]);
235 if ( hit < 0 || hit >= (
int)
intt_hits.size())
return 0;
284 if ( index < 0 || (
unsigned int) index >=
fee_data[fee].
size() )
return 0;
292 if ( hit < 0 || hit >= (
int)
intt_hits.size())
return 0;
309 if ( strcmp(what,
"NR_HITS") == 0)
314 if ( strcmp(what,
"FEE_LENGTH") == 0)
323 else if ( strcmp(what,
"ADC") == 0)
328 else if ( strcmp(what,
"AMPLITUDE") == 0)
333 if ( strcmp(what,
"CHIP_ID") == 0)
338 if ( strcmp(what,
"CHANNEL_ID") == 0)
343 if ( strcmp(what,
"FULL_FPHX") == 0)
348 if ( strcmp(what,
"FEE") == 0)
353 if ( strcmp(what,
"FPHX_BCO") == 0)
358 if ( strcmp(what,
"FULL_FPHX") == 0)
363 if ( strcmp(what,
"FULL_ROC") == 0)
368 if ( strcmp(what,
"DATAWORD") == 0)
380 if ( strcmp(what,
"BCO") == 0)
394 os <<
" Number of hits: " <<
iValue(0,
"NR_HITS") << endl;
398 os <<
" # FEE BCO chip_BCO chip_id channel_id ADC full_phx full_ROC Ampl." << endl;
400 for (
int i = 0;
i <
iValue(0,
"NR_HITS");
i++)
402 os << setw(4) <<
i <<
" "
414 << setfill(
' ') << dec << endl;
423 unsigned short n =
x;
424 n = ((n >> 1) & 0x55555555) | ((n << 1) & 0xaaaaaaaa);
425 n = ((n >> 2) & 0x33333333) | ((n << 2) & 0xcccccccc);
426 n = ((n >> 4) & 0x0f0f0f0f) | ((n << 4) & 0xf0f0f0f0);
427 n = ((n >> 8) & 0x00ff00ff) | ((n << 8) & 0xff00ff00);
438 unsigned short crc = 0xffff;
442 unsigned short x =
fee_data[fee].at(i++);
445 for (
unsigned short k = 0;
k < 16;
k++)
447 crc = crc & 1 ? (crc >> 1) ^ 0xa001 : crc >> 1;