22 #include "eformat/FullEventFragment.h"
36 #include "boost/io/ios_state.hpp"
37 #include "boost/date_time/local_time/local_time.hpp"
38 #include "boost/date_time/posix_time/posix_time.hpp"
46 #include <arpa/inet.h>
50 using namespace boost::local_time;
51 using namespace boost::posix_time;
70 static const time_zone_ptr gva_tz(
new posix_time_zone((std::string)
"CET+01CEST01:00:00,M3.5.0/02:00:00,M10.5.0/03:00:00"));
71 local_date_time gva_time(from_time_t(unix_time),gva_tz);
80 struct tm gva_tm(to_tm(gva_time));
81 strftime(
dateTime, 32,
"%Y-%b-%d %H:%M:%S %Z", &gva_tm);
108 , m_RobSvc(
"ROBDataProviderSvc",
name)
111 , m_tileToolTiming(
"TileCondToolTiming")
112 , m_tileCondToolOfcCool(
"TileCondToolOfcCool")
113 , m_tileToolEmscale(
"TileCondToolEmscale")
191 return StatusCode::SUCCESS;
197 std::string unitName[5]={
"ADC counts",
"pCb",
"CspCb",
"MeV",
"unknown"};
200 std::cout << std::endl <<
"DSP reco fragments not found" << std::endl;
203 std::cout << std::endl <<
"Units in DSP reco fragments are " << unitName[
std::min(
m_unit,4)] << std::endl;
206 std::cout << std::endl <<
"StatFrag5[40..129]";
207 for (
int i = 40;
i < 130;
i++) {
208 if (
i % 10 == 0) std::cout << std::endl <<
" [" << std::setw(3) <<
i <<
"] : ";
211 std::cout << std::endl;
216 return StatusCode::SUCCESS;
221 static std::atomic<bool> notFirst =
false;
225 const EventContext &ctx = Gaudi::Hive::currentContext();
228 const eformat::FullEventFragment<const uint32_t*> *
event =
m_RobSvc->getEvent(ctx);
233 int lvl1tt =
event->lvl1_trigger_type();
235 return StatusCode::SUCCESS;
254 if (
m_dumpOnce && notFirst)
return StatusCode::SUCCESS;
266 boost::io::ios_base_all_saver coutsave(std::cout);
267 std::cout << std::fixed;
269 std::cout <<
"============================" << std::endl;
270 std::cout <<
"Event time (sec): " << (
uint32_t)
event->bc_time_seconds() << std::endl;
271 std::cout <<
"Event time (ns): " << (
uint32_t)
event->bc_time_nanoseconds() << std::endl;
272 std::cout <<
"Global ID: " << (
uint32_t)
event->global_id() << std::endl;
273 std::cout <<
"Run Type: " << (
uint32_t)
event->run_type() << std::endl;
274 std::cout <<
"Run Number: " << (
uint32_t)
event->run_no() << std::endl;
275 std::cout <<
"Lumi Block: " << (
uint32_t)
event->lumi_block() << std::endl;
276 std::cout <<
"Level1 ID: " << (
uint32_t)
event->lvl1_id() << std::endl;
277 std::cout <<
"BCID: " << (
uint32_t)
event->bc_id() << std::endl;
278 std::cout <<
"Level1 trig type: " << (
uint32_t)
event->lvl1_trigger_type() << std::endl;
279 std::cout <<
"Level1 Nwords: " << (
uint32_t)
event->nlvl1_trigger_info() << std::endl;
280 std::cout <<
"============================" << std::endl;
285 std::cout <<
" Invalid event, some ROB fragments might be truncated" << std::endl << std::endl;
294 for (
size_t irob = 0; irob < nrob; ++irob) {
296 event->child(fprob, irob);
302 unsigned int version = robf.rod_version();
303 unsigned int source_id = robf.rod_source_id();
304 eformat::helper::SourceIdentifier
id = eformat::helper::SourceIdentifier(source_id);
305 unsigned int subdet_id =
id.subdetector_id();
306 unsigned int module_id =
id.module_id();
307 int robsourceid = robf.source_id();
310 || (subdet_id >= 0x50 && subdet_id < 0x60)
311 || (robsourceid >= 0x510000 && robsourceid < 0x550000);
317 std::cout <<
" ROB frag ID " << std::hex <<
"0x" << robf.source_id() << std::dec
318 <<
" size " << robf.fragment_size_word() << std::endl;
321 std::cout <<
" ROD frag ID " << std::hex <<
"0x" << robf.rod_source_id() << std::dec
322 <<
" size " << robf.rod_fragment_size_word() << std::endl;
325 std::cout << std::endl;
331 std::cout <<
" Format Vers. " << std::hex <<
"0x" << robf.rod_version() << std::dec << std::endl;
332 std::cout <<
" Source ID " << std::hex <<
"0x" << robf.rod_source_id() << std::dec << std::endl;
333 std::cout <<
" Source ID str " << eformat::helper::SourceIdentifier(robf.source_id()).human().c_str() << std::endl;
334 std::cout <<
" SubDetect ID " << std::hex <<
"0x" << subdet_id << std::dec << std::endl;
335 std::cout <<
" Module ID " << std::hex <<
"0x" << module_id << std::dec << std::endl;
336 std::cout <<
" Run number " << (
int) robf.rod_run_no() << std::endl;
337 std::cout <<
" Level1 ID " << robf.rod_lvl1_id() << std::endl;
338 std::cout <<
" BCID " << robf.rod_bc_id() << std::endl;
339 std::cout <<
" Lvl1 TrigType " << robf.rod_lvl1_trigger_type() << std::endl;
340 std::cout <<
" Event Type " << robf.rod_detev_type() << std::endl;
341 std::cout <<
" Fragment size " << robf.rod_fragment_size_word() << std::endl;
342 std::cout <<
" Header size " << robf.rod_header_size_word() << std::endl;
343 std::cout <<
" Trailer size " << robf.rod_trailer_size_word() << std::endl;
344 std::cout <<
" N data " << robf.rod_ndata() << std::endl;
345 std::cout <<
" N status " << robf.rod_nstatus() << std::endl;
346 std::cout <<
" Status pos " << robf.rod_status_position() << std::endl;
349 unsigned int max_allowed_size = robf.rod_fragment_size_word();
350 unsigned int delta = robf.rod_header_size_word() + robf.rod_trailer_size_word();
351 if (max_allowed_size >= delta) {
352 max_allowed_size -= delta;
354 std::cout <<
" Problem with ROD data: total length " << max_allowed_size
355 <<
" is less than " << delta <<
" - size of header+trailer" << std::endl;
356 max_allowed_size = 0;
359 unsigned int size = robf.rod_nstatus();
360 bool bad_status = (robf.rod_status_position()==0 &&
size > max_allowed_size);
362 if (robf.rod_status_position() > 1
363 || robf.rod_ndata() > max_allowed_size
364 ||
size > max_allowed_size - robf.rod_ndata()
366 std::cout <<
" Problem with status words - assuming no status words" << std::endl;
372 robf.rod_status(
stat);
373 std::cout.unsetf(std::ios::fixed);
375 std::cout <<
" Status[" <<
ind <<
"] = " <<
stat[
ind] <<
"\t\t" <<
stat[
ind] / 1000000. - 1. << std::endl;
377 std::cout << std::fixed;
379 std::cout <<
" No status words" << std::endl;
385 unsigned int size = robf.rod_ndata();
386 if (
size > max_allowed_size) {
387 if (
size - robf.rod_trailer_size_word() < max_allowed_size) {
388 std::cout<<
" Problem with data size - assuming that trailer size is " << robf.rod_trailer_size_word()-(
size-max_allowed_size)
389 <<
" words instead of " << robf.rod_trailer_size_word() <<
" and data size is " <<
size <<
" words " << std::endl;
390 max_allowed_size =
size;
391 }
else if (
size - robf.rod_trailer_size_word() == max_allowed_size) {
392 std::cout<<
" Problem with data size - assuming that trailer is absent "
393 <<
" ROD size " << robf.rod_fragment_size_word()
394 <<
" header size " << robf.rod_header_size_word()
395 <<
" data size " <<
size << std::endl;
396 max_allowed_size =
size;
398 max_allowed_size += robf.rod_trailer_size_word();
399 size = max_allowed_size;
400 std::cout<<
" Problem with data size - assuming " <<
size <<
" words and no trailer at all"<<std::endl;
402 std::cout << std::endl <<
"Dump of whole ROB fragment 0x" << std::hex << robf.rod_source_id() << std::dec
403 <<
" (" << robf.rod_fragment_size_word()+robf.header_size_word() <<
" words)" << std::endl;
411 robf.rod_status(
data);
416 if (subdet_id == 0) {
417 std::cout<<
" Problem with ROD frag - SubDetector ID is 0" <<std::endl;
418 if (source_id >= 0x5100 && source_id < 0x5500 && robsourceid >= 0x510000 && robsourceid < 0x550000) {
419 std::cout<<
" Looks like ROD frag is in old format, ROD Source ID is 0x" << std::hex << source_id
420 <<
" assuming that ROD Source ID is 0x" << robsourceid << std::dec << std::endl;
421 source_id = robsourceid;
422 subdet_id = robsourceid>>16;
426 if ((subdet_id >= 0x50 && subdet_id < 0x60) ||
431 if (!(subdet_id == 0 ||
size < 13
433 ||
data[5] == 0x34127856 ||
data[
size-1] == 0x65872143)) {
436 if (subdet_id == 0) {
441 std::cout << std::endl << std::hex <<
"NO DATA in ROB fragment 0x" << robf.rod_source_id() << std::dec << std::endl << std::endl;
443 std::cout << std::endl;
455 return StatusCode::SUCCESS;
460 stream <<
"0x" << std::setw(4);
464 stream <<
"\n mod" << std::setw(2);
468 stream << std::hex << std::setfill(
'0') << std::setw(8);
472 stream << std::setfill(
' ') << std::dec;
476 stream << std::setw(5) << std::setprecision(1);
480 stream << std::setw(5) << std::setprecision(2);
484 stream << std::setw(4) << std::setprecision(1);
488 stream << std::setw(4) << std::setprecision(1);
494 boost::io::ios_base_all_saver coutsave(std::cout);
495 std::cout << std::endl <<
" Fragment data as 4 byte words:" << std::hex << std::setfill(
'0') ;
497 for (
unsigned int cnter = 0; cnter <
size; ++cnter) {
498 if (!(cnter % 8)) std::cout << std::endl;
499 std::cout << std::setw(8) << (*
data++) <<
" ";
502 std::cout <<std::setfill(
' ') << std::dec << std::endl << std::endl;
508 ,
const EventContext& ctx) {
510 int s,
c,
f, nfrag,
ngain,
nchan, nsamp,
size,
ch,
extra = 0,
pmt, fragType, nhits = 0;
511 int id,
type, rflag,
unit, pulse, nsmpl, algor, niter;
512 const unsigned int*
data;
514 char fr[2] = {
'F',
'R' };
515 char gb[2] = {
'G',
'B' };
516 std::string unitName[4] = {
"ADC count",
"pCb",
"Cs pCb",
"MeV" };
517 std::string shapeName[4] = {
"Phys",
"Laser",
"CIS",
"Simul" };
518 std::string
algName[8] = {
"Unknown",
"OF1",
"OF2",
"Fit",
"ManyAmps",
"Flat",
"Alg6",
"Alg7" };
519 boost::io::ios_base_all_saver coutsave(std::cout);
528 bool isFrag5 =
false;
530 std::vector<unsigned int> OFC;
534 bool beamROD = (subdet_id == 0x50 || subdet_id >= 0x60);
535 if (subdet_id >= 0x60) {
546 for (
f = 0;
f < nfrag; ++
f) {
548 id = frag[
f]->
id & 0xFFFF;
549 type = (frag[
f]->
id >> 16) & 0xFF;
550 rflag = (frag[
f]->
id) >> 24;
551 unit = (rflag & 0xC0) >> 6;
552 pulse = (rflag & 0x30) >> 4;
553 nsmpl = (rflag & 0x08) >> 3;
554 algor = (rflag & 0x04) >> 2;
555 niter = (rflag & 0x03);
561 const unsigned char *
adc;
562 const unsigned short *
result;
563 int tmdb_ch1 =
std::min(5U,((robsourceid)>>16)&0xF);
564 bool EB = (tmdb_ch1>2);
566 int tmdb_ch2 = (((robsourceid))&0xF)*nmod;
567 const char * dr56EB[10] = {
"D5-L",
"D5-R",
"D6-L",
"D6-R",
"D4-L",
"D4-R",
"XX-X",
"XX-X",
"XX-X",
"XX-X" };
568 const char * dr56LB[10] = {
"D0-x",
"D1-L",
"D1-R",
"D2-L",
"D2-R",
"D3-L",
"D3-R",
"B8-L",
"B8-R",
"XX-X" };
569 const char ** dr56rl = (EB) ? dr56EB : dr56LB;
570 const char * ch11[6] = {
"AUX",
"LBA",
"LBC",
"EBA",
"EBC",
"UNK" };
571 const char * ch12[6] = {
"aux",
"lba",
"lbc",
"eba",
"ebc",
"unk" };
572 const char * dr56hlEB[4] = {
" D6L ",
" D6H ",
" D56L",
" D56H"};
573 const char * dr56hlLB[4] = {
" DxL ",
" DxH ",
" DxxL",
" DxxH"};
575 const char * dr56thEB[4] = {
" D5 ",
" D6 ",
" D56 ",
"BCID "};
576 const char * dr56thLB[4] = {
" Dx ",
" Dy ",
" Dxy ",
"BCID "};
577 const char ** dr56th = (
m_runPeriod < 3) ? (EB ? dr56hlEB : dr56hlLB)
578 : (EB ? dr56thEB : dr56thLB);
580 const char *
tit[4] = {
"TMDB digits",
"TMDB energy",
"TMDB decision",
"Unknown"};
582 std::cout << std::hex << std::endl <<
tit[
type&3] <<
" fragment 0x" <<
type <<
" vers 0x"<<
id <<
", "
583 << std::dec <<
size <<
" words found"<< std::endl << std::endl;
588 int ntd = (EB) ? 3 : 1;
589 int ntdl = (EB) ? 9 : 5;
597 std::cout <<
"ch cell ";
599 std::cout <<
" S"<<
ind;
601 std::cout << std::endl;
602 adc =
reinterpret_cast<const unsigned char *
>(
data);
603 for (
int pword=0;pword<nch;++pword) {
604 int pword1=pword%nchmod;
605 if (!EB && nchmod==8) {
607 if (pword1==0) pword1=9;
610 if (pword1>6) pword1=9;
613 if (pword1>9) pword1=9;
615 std::cout << std::setw(2) << pword <<
" | " << ch11[tmdb_ch1] <<std::setfill(
'0')<<std::setw(2) <<tmdb_ch2+
count
616 <<
"-" <<std::setfill(
' ')<<std::setw(4)<<dr56rl[pword1];
618 std::cout <<
" | " << std::setw(3) << (
static_cast<unsigned>(
adc[pword+nch*
ind]) );
620 std::cout << std::endl;
621 if ((pword+1)%nchmod==0)
count+=1;
628 std::cout <<
"ch cell energy" << std::endl;
629 for (
int pword=0;pword<
size;++pword) {
630 int pword1=pword%nchmod;
631 if (!EB && nchmod==8) {
633 if (pword1==0) pword1=9;
636 if (pword1>6) pword1=9;
639 if (pword1>9) pword1=9;
641 std::cout << std::setw(2) << pword<<
" | " << ch11[tmdb_ch1] <<std::setfill(
'0')<<std::setw(2) <<tmdb_ch2+
count
642 <<
"-" <<std::setfill(
' ')<<std::setw(4)<<dr56rl[pword1]
643 <<
" | "<< std::setw(6) <<
static_cast<int>(
data[pword])
645 if ((pword+1)%nchmod==0)
count+=1;
651 std::cout <<
"nn name TMDB SL_Board SL_Trigger_Sector "
652 << dr56th[3] << dr56th[2] << dr56th[1] << dr56th[0] << std::endl;
653 result =
reinterpret_cast<const unsigned short *
>(
data);
656 int tmdb = (tmdb_ch2) / 8 + 1;
657 int slb =
tmdb * 3 - 1;
659 for (
int pword = 0; pword < ntd; ++pword) {
660 count = (EB) ? pword * 3 : pword * 4 + 1;
661 unsigned short r =
result[pword];
663 int slts1 = slb * 2 - 2;
664 int slts2 = slts1 + 1;
665 std::string slt_sectors =
" - ";
667 std::stringstream slts12;
668 slts12 << std::setfill(
' ') << std::setw(2) << slts1 <<
"-"
669 << std::setfill(
' ') << std::setw(2) << std::left << slts2;
670 slt_sectors = slts12.str();
672 std::stringstream slb_name;
673 slb_name <<
"SL_E" << std::setfill(
'0') << std::setw(2) << (EB ?
std::to_string(slb) :
"XX");
674 for(
int pqword = 0; pqword < 4; ++pqword){
675 std::cout << std::setw(2) << pqword + pword * 4 <<
" | "
676 << ((
count > 0 &&
count < ntdl) ? ch11[tmdb_ch1] : ch12[tmdb_ch1])
677 << std::setfill(
'0') << std::setw(2) << tmdb_ch2 +
count
678 << std::setfill(
' ') << std::setw(6) << tmdb_name
679 << std::setfill(
' ') << std::setw(10) << slb_name.str()
680 << std::setfill(
' ') << std::setw(15) << slt_sectors
681 << std::setfill(
' ') << std::setw(11) << ((
m_runPeriod < 3) ? ((
r >> 3) & 1) :
bcid)
682 << std::setw(5) << ((
r >> 2) & 1) << std::setw(5) << ((
r >> 1) & 1) << std::setw(5) << (
r & 1) << std::endl;
687 if (slb > 24) slb = 1;
695 }
else if (
id < 0x100 || beamROD) {
704 bool isLastChannelEOB = ((
data[
size - 1] >> 24) & 0x7) == 0x4;
706 std::cout <<
"\nBeam ToF TDC, ";
708 std::cout <<
"\nBeam TDC 0x" << std::setfill(
'0') << std::hex << std::setw(2) <<
id <<
setupDec <<
", ";
710 std::cout << (isLastChannelEOB ?
size - 1 :
size) <<
" hits found";
714 unsigned short res1 = (
data[
c] >> 13) & 0
x1;
717 : (
data[
c] >> 16) & 0x7FF;
720 int wordType = (
data[
c] >> 24) & 0x7;
721 if (wordType == 0
x2) {
722 std::cout <<
"\n header, " << ((
data[
c] >> 8) & 0x3F) <<
" channels";
723 }
else if (wordType == 0x4) {
724 std::cout <<
"\n end of block, event counter: " << (
data[
c] & 0xFFFFFF) << std::endl;
726 std::cout <<
"\n unknown word: 0x" << std::hex <<
data[
c] << std::dec << std::endl;
731 std::cout <<
"\n ch" << std::setw(3) <<
chan <<
":";
734 }
else if (nhits % 8 == 0) {
739 std::cout <<
" U" << std::setw(4) <<
time;
741 std::cout <<
" " << std::setw(4) <<
time;
744 std::cout << std::endl;
754 std::cout <<
"\nBeam TDC 0x" << std::setfill(
'0') << std::hex << std::setw(2) <<
id <<
setupDec <<
", " <<
size <<
" hits found";
766 std::cout <<
"\n ch" << std::setw(3) <<
chan <<
":";
769 }
else if (nhits % 8 == 0) {
774 std::cout <<
" " << gb[
bad] <<
fr[edge] << std::setw(6) <<
time;
776 std::cout <<
" " <<
fr[edge] << std::setw(6) <<
time;
779 std::cout << std::endl;
785 bool isLastChannelEOB = ((
data[
size - 1] >> 24) & 0x7) == 0x4;
786 std::cout <<
"\nBeam ADC, " << (isLastChannelEOB ?
size - 1 :
size) <<
" hits found";
790 unsigned short res1 = (
data[
c] >> 13) & 0
x1;
792 : (
data[
c] >> 16) & 0x7FF;
795 int wordType = (
data[
c] >> 24) & 0x7;
796 if (wordType == 0
x2) {
797 std::cout <<
"\n header, " << ((
data[
c] >> 8) & 0x3F) <<
" channels";
798 }
else if (wordType == 0x4) {
799 std::cout <<
"\n end of block, event counter: " << (
data[
c] & 0xFFFFFF) << std::endl;
801 std::cout <<
"\n unknown word: 0x" << std::hex <<
data[
c] << std::dec << std::endl;
806 std::cout <<
"\n ch" << std::setw(3) <<
chan <<
":";
809 }
else if (nhits % 8 == 0) {
814 std::cout <<
" U" << std::setw(4) <<
time;
816 std::cout <<
" " << std::setw(4) <<
time;
819 std::cout << std::endl;
829 std::cout <<
"\nTile Beam ADC, " <<
size <<
" channels found";
831 std::cout <<
"\nBeam ADC 0x" << std::hex << std::setfill(
'0') << std::setw(2) <<
id <<
setupDec <<
", " <<
size <<
" channels found";
834 if (
c % 8 == 0) std::cout <<
setupMod <<
c / 8 <<
":";
835 std::cout << std::setw(9) <<
data[
c];
837 std::cout << std::endl;
841 std::cout <<
"\nMuon ADC, " <<
size <<
" channels found";
843 if (
c % 8 == 0) std::cout <<
setupMod <<
c / 8 <<
":";
844 std::cout << std::setw(9) <<
data[
c];
846 std::cout << std::endl;
850 std::cout <<
"\nMuon2 ADC, " <<
size <<
" channels found";
852 if (
c % 8 == 0) std::cout <<
setupMod <<
c / 8 <<
":";
853 std::cout << std::setw(9) <<
data[
c];
855 std::cout << std::endl;
861 std::cout<<
"\nLaser Pattern Unit, " <<
size <<
" words found (hex)";
863 std::cout<<
"\nCommon Pattern Unit, " <<
size <<
" words found (hex)";
866 if (
c % 8 == 0) std::cout <<
setupMod <<
c/8 <<
":";
869 std::cout << std::endl;
875 std::cout<<
"\nLASTROD Laser Object, " <<
size <<
" words found (hex)";
877 if (
c % 8 == 0) std::cout <<
setupMod <<
c/8 <<
":";
880 std::cout<<std::endl<<std::endl;
883 std::cout<<
"CRITICAL ERROR! Unknown format!"<<std::endl;
885 const unsigned int *
p;
887 int Filter = 0, ReqAmp = 0, MeasAmp = 0, Delay = 0, TDC1 = 0, TDC2 = 0;
891 std::cout <<
" Laser Counter: " << std::setw(5) << Counter << std::endl;
893 if ((*
p & 0xFF000000) == 0x20000000) {
894 ReqAmp = *
p & 0xFFFF;
896 Filter = (((*
p >> 16) & 7) ^ 7) + 2;
898 std::cout <<
" Filter Wheel: " << std::setw(5) <<
Filter << std::endl;
900 std::cout <<
" Required Amp: " << std::setw(5) << ReqAmp << std::endl;
902 std::cout <<
"ERROR in Laser Fragment: decoding word 14." << std::endl;
906 if ((*
p & 0xFF000000) == 0x21000000) {
907 Delay = (*
p >> 12) & 0xFFF;
908 MeasAmp = *
p & 0xFFF;
909 std::cout <<
" Measured Amp: " << std::setw(5) << MeasAmp << std::endl;
910 std::cout <<
" Delay: " << std::setw(5) << Delay << std::endl;
912 std::cout <<
"ERROR in Laser Fragment: decoding word 15." << std::endl;
916 bool TDCPrint =
true;
918 if ((*
p & 0xFF000000) == 0x22000000) {
920 TDC1 = (*
p >> 16) & 0xF;
921 TDC2 = (*
p >> 20) & 0xF;
926 std::cout <<
"ERROR in Laser Fragment: decoding word 16." << std::endl;
930 if ((*
p & 0xFF000000) == 0x23000000) {
932 TDC1 = (TDC1 << 12) + (*
p & 0xFFF);
933 TDC2 = (TDC2 << 12) + ((*
p >> 12) & 0xFFF);
938 std::cout <<
"ERROR in Laser Fragment: decoding word 17." << std::endl;
943 std::cout <<
" TDC1 data: " << std::setw(5) << TDC1 << std::endl;
944 std::cout <<
" TDC2 data: " << std::setw(5) << TDC2 << std::endl;
947 int chan0 = 0,
chan1 = 0, chan2 = 0, chan3 = 0, chan4 = 0, chan5 = 0, chan6 = 0, chan7 = 0;
949 if ((*
p & 0xFF000000) == 0x44000000) {
950 chan0 = (*
p & 0xFFF) ^ 0xFFF;
951 chan1 = ((*
p >> 12) & 0xFFF) ^ 0xFFF;
953 std::cout <<
"ERROR in Laser Fragment: decoding word 18." << std::endl;
957 if ((*
p & 0xFF000000) == 0x45000000) {
958 chan2 = (*
p & 0xFFF) ^ 0xFFF;
959 chan3 = ((*
p >> 12) & 0xFFF) ^ 0xFFF;
961 std::cout <<
"ERROR in Laser Fragment: decoding word 19." << std::endl;
965 if ((*
p & 0xFF000000) == 0x46000000) {
966 chan4 = (*
p & 0xFFF) ^ 0xFFF;
967 chan5 = ((*
p >> 12) & 0xFFF) ^ 0xFFF;
969 std::cout <<
"ERROR in Laser Fragment: decoding word 20." << std::endl;
973 if ((*
p & 0xFF000000) == 0x47000000) {
974 chan6 = (*
p & 0xFFF) ^ 0xFFF;
975 chan7 = ((*
p >> 12) & 0xFFF) ^ 0xFFF;
977 std::cout <<
"ERROR in Laser Fragment: decoding word 21." << std::endl;
981 int diode1_Ped = 0, diode1_PedRMS = 0
982 , diode2_Ped = 0, diode2_PedRMS = 0
983 , diode3_Ped = 0, diode3_PedRMS = 0
984 , diode4_Ped = 0, diode4_PedRMS = 0
985 , PMT1_Ped = 0, PMT1_PedRMS = 0
986 , PMT2_Ped = 0, PMT2_PedRMS = 0;
988 diode1_Ped = (*
p >> 16) & 0xFFFF;
989 diode1_PedRMS = *
p & 0xFFFF;
992 diode2_Ped = (*
p >> 16) & 0xFFFF;
993 diode2_PedRMS = *
p & 0xFFFF;
996 diode3_Ped = (*
p >> 16) & 0xFFFF;
997 diode3_PedRMS = *
p & 0xFFFF;
1000 diode4_Ped = (*
p >> 16) & 0xFFFF;
1001 diode4_PedRMS = *
p & 0xFFFF;
1004 PMT1_Ped = (*
p >> 16) & 0xFFFF;
1005 PMT1_PedRMS = *
p & 0xFFFF;
1008 PMT2_Ped = (*
p >> 16) & 0xFFFF;
1009 PMT2_PedRMS = *
p & 0xFFFF;
1012 time_t Ped_Last_Run = *
p;
1015 int diode1_alpha = 0, diode1_alphaRMS = 0
1016 , diode2_alpha = 0, diode2_alphaRMS = 0
1017 , diode3_alpha = 0, diode3_alphaRMS = 0
1018 , diode4_alpha = 0, diode4_alphaRMS = 0;
1020 diode1_alpha = (*
p >> 16) & 0xFFFF;
1021 diode1_alphaRMS = *
p & 0xFFFF;
1024 diode2_alpha = (*
p >> 16) & 0xFFFF;
1025 diode2_alphaRMS = *
p & 0xFFFF;
1028 diode3_alpha = (*
p >> 16) & 0xFFFF;
1029 diode3_alphaRMS = *
p & 0xFFFF;
1032 diode4_alpha = (*
p >> 16) & 0xFFFF;
1033 diode4_alphaRMS = *
p & 0xFFFF;
1036 time_t Alpha_Last_Run = *
p;
1039 time_t PedAlpha_Last_Run(0);
1041 int diode1_PedAlpha = 0, diode1_PedAlphaRMS = 0
1042 , diode2_PedAlpha = 0, diode2_PedAlphaRMS = 0
1043 , diode3_PedAlpha = 0, diode3_PedAlphaRMS = 0
1044 , diode4_PedAlpha = 0, diode4_PedAlphaRMS = 0;
1047 diode1_PedAlpha = (*
p >> 16) & 0xFFFF;
1048 diode1_PedAlphaRMS = *
p & 0xFFFF;
1051 diode2_PedAlpha = (*
p >> 16) & 0xFFFF;
1052 diode2_PedAlphaRMS = *
p & 0xFFFF;
1055 diode3_PedAlpha = (*
p >> 16) & 0xFFFF;
1056 diode3_PedAlphaRMS = *
p & 0xFFFF;
1059 diode4_PedAlpha = (*
p >> 16) & 0xFFFF;
1060 diode4_PedAlphaRMS = *
p & 0xFFFF;
1063 PedAlpha_Last_Run = *
p;
1067 std::cout << std::endl <<
" | ADC | Pedestal(RMS) | Alpha (RMS) | PedAlpha(RMS) |" << std::endl;
1069 std::cout <<
" Diode 1 | " << std::setw(5) << chan0 <<
" | " <<
setupPr1 << diode1_Ped / 10.0 <<
" (" <<
setupPr2 << diode1_PedRMS / 100.0 <<
") | " <<
setupPr1 << diode1_alpha / 10.0 <<
" (" <<
setupPr2 << diode1_alphaRMS / 100.0 <<
") |" << std::endl;
1070 std::cout <<
" Diode 2 | " << std::setw(5) <<
chan1 <<
" | " <<
setupPr1 << diode2_Ped / 10.0 <<
" (" <<
setupPr2 << diode2_PedRMS / 100.0 <<
") | " <<
setupPr1 << diode2_alpha / 10.0 <<
" (" <<
setupPr2 << diode2_alphaRMS / 100.0 <<
") |" << std::endl;
1071 std::cout <<
" Diode 3 | " << std::setw(5) << chan2 <<
" | " <<
setupPr1 << diode3_Ped / 10.0 <<
" (" <<
setupPr2 << diode3_PedRMS / 100.0 <<
") | " <<
setupPr1 << diode3_alpha / 10.0 <<
" (" <<
setupPr2 << diode3_alphaRMS / 100.0 <<
") |" << std::endl;
1072 std::cout <<
" Diode 4 | " << std::setw(5) << chan3 <<
" | " <<
setupPr1 << diode4_Ped / 10.0 <<
" (" <<
setupPr2 << diode4_PedRMS / 100.0 <<
") | " <<
setupPr1 << diode4_alpha / 10.0 <<
" (" <<
setupPr2 << diode4_alphaRMS / 100.0 <<
") |" << std::endl;
1074 std::cout <<
" Diode 1 | " << std::setw(5) << chan0 <<
" | " <<
setupPr1 << diode1_Ped / 10.0 <<
" (" <<
setupPr2 << diode1_PedRMS / 100.0 <<
") | " <<
setupPr1 << diode1_alpha / 10.0 <<
" (" <<
setupPr2 << diode1_alphaRMS / 100.0 <<
") | " <<
setupPr1 << diode1_PedAlpha / 10.0 <<
" (" <<
setupPr2 << diode1_PedAlphaRMS / 100.0 <<
") |" << std::endl;
1075 std::cout <<
" Diode 2 | " << std::setw(5) <<
chan1 <<
" | " <<
setupPr1 << diode2_Ped / 10.0 <<
" (" <<
setupPr2 << diode2_PedRMS / 100.0 <<
") | " <<
setupPr1 << diode2_alpha / 10.0 <<
" (" <<
setupPr2 << diode2_alphaRMS / 100.0 <<
") | " <<
setupPr1 << diode2_PedAlpha / 10.0 <<
" (" <<
setupPr2 << diode2_PedAlphaRMS / 100.0 <<
") |" << std::endl;
1076 std::cout <<
" Diode 3 | " << std::setw(5) << chan2 <<
" | " <<
setupPr1 << diode3_Ped / 10.0 <<
" (" <<
setupPr2 << diode3_PedRMS / 100.0 <<
") | " <<
setupPr1 << diode3_alpha / 10.0 <<
" (" <<
setupPr2 << diode3_alphaRMS / 100.0 <<
") | " <<
setupPr1 << diode3_PedAlpha / 10.0 <<
" (" <<
setupPr2 << diode3_PedAlphaRMS / 100.0 <<
") |" << std::endl;
1077 std::cout <<
" Diode 4 | " << std::setw(5) << chan3 <<
" | " <<
setupPr1 << diode4_Ped / 10.0 <<
" (" <<
setupPr2 << diode4_PedRMS / 100.0 <<
") | " <<
setupPr1 << diode4_alpha / 10.0 <<
" (" <<
setupPr2 << diode4_alphaRMS / 100.0 <<
") | " <<
setupPr1 << diode4_PedAlpha / 10.0 <<
" (" <<
setupPr2 << diode4_PedAlphaRMS / 100.0 <<
") |" << std::endl;
1080 std::cout <<
" PMT 1 | " << std::setw(5) << chan4 <<
" | " <<
setupPr1 << PMT1_Ped / 10.0 <<
" (" <<
setupPr2 << PMT1_PedRMS / 100.0 <<
") | x | x |" << std::endl;
1081 std::cout <<
" PMT 2 | " << std::setw(5) << chan5 <<
" | " <<
setupPr1 << PMT2_Ped / 10.0 <<
" (" <<
setupPr2 << PMT2_PedRMS / 100.0 <<
") | x | x |" << std::endl;
1082 std::cout <<
" InjChrg | " << std::setw(5) << chan6 <<
" | x | x | x |" << std::endl;
1083 std::cout <<
" Spare | " << std::setw(5) << chan7 <<
" | x | x | x |" << std::endl;
1085 std::cout << std::endl <<
" | Date & Time (GMT) | Date & Time (CERN)" << std::endl;
1089 gmtime_r(&Ped_Last_Run, &TimeInfo);
1090 strftime(buf, 80,
"%d.%m.%Y %H:%M:%S", &TimeInfo);
1092 std::cout <<
" Pedestal | " << buf <<
" | " <<
cern_local_time(Ped_Last_Run) << std::endl;
1094 gmtime_r(&Alpha_Last_Run, &TimeInfo);
1095 strftime(buf, 80,
"%d.%m.%Y %H:%M:%S", &TimeInfo);
1097 std::cout <<
" Alpha | " << buf <<
" | " <<
cern_local_time(Alpha_Last_Run) << std::endl;
1099 gmtime_r(&PedAlpha_Last_Run, &TimeInfo);
1100 strftime(buf, 80,
"%d.%m.%Y %H:%M:%S", &TimeInfo);
1102 std::cout <<
" PedAlpha | " << buf <<
" | " <<
cern_local_time(PedAlpha_Last_Run) << std::endl;
1104 int diodeTemp = 0, secsDiodeT = 0
1105 , boxTemp = 0, secsBoxT = 0
1106 , boxHum = 0, secsBoxH = 0
1107 , gasFlow = 0, secsGasF = 0;
1109 diodeTemp = *
p & 0xFFF;
1110 secsDiodeT = (*
p >> 12) & 0xFFFFF;
1112 boxTemp = *
p & 0xFFF;
1113 secsBoxT = (*
p >> 12) & 0xFFFFF;
1115 boxHum = *
p & 0xFFF;
1116 secsBoxH = (*
p >> 12) & 0xFFFFF;
1118 gasFlow = *
p & 0xFFF;
1119 secsGasF = (*
p >> 12) & 0xFFFFF;
1122 std::cout << std::endl <<
" | Time | Value |" << std::endl;
1123 std::cout <<
" Laser diode temp | " << std::setw(7) << secsDiodeT <<
" | " <<
setupPr3 << diodeTemp / 10.0 <<
" |" << std::endl;
1124 std::cout <<
" Laser box temp | " << std::setw(7) << secsBoxT <<
" | " <<
setupPr3 << boxTemp / 10.0 <<
" |" << std::endl;
1125 std::cout <<
" Laser box humidity | " << std::setw(7) << secsBoxH <<
" | " <<
setupPr3 << boxHum / 10.0 <<
" |" << std::endl;
1126 std::cout <<
" Laser box gas flow | " << std::setw(7) << secsGasF <<
" | " <<
setupPr3 << gasFlow / 10.0 <<
" |" << std::endl;
1128 std::bitset<32> PLCstatus = *
p;
1129 int PLCtime = (*
p >> 12) & 0xFFFFF;
1132 int Alpha0 = PLCstatus[0];
1133 int Alpha1 = PLCstatus[1];
1134 int Alpha2 = PLCstatus[2];
1135 int LV = PLCstatus[3];
1136 int HV1 = PLCstatus[4];
1137 int HV2 = PLCstatus[5];
1138 int ShOpen = PLCstatus[6];
1139 int ShClose = PLCstatus[7];
1140 int Ilock = PLCstatus[8];
1141 int Alarm = PLCstatus[9];
1142 int Err = PLCstatus[11];
1144 const char *YesNo[2] = {
" No",
"Yes"};
1145 const char *OnOff[2] = {
"Off",
" On"};
1147 std::cout << std::endl <<
" Time | Err | Alarm | Ilock | ShClose | ShOpen | HV2 | HV1 | LV | Alpha2 | Alpha1 | Alpha0 |"
1148 << std::endl <<
" " << std::setw(7) << PLCtime
1149 <<
" | " << YesNo[Err] <<
" | " << OnOff[Alarm] <<
" | " << OnOff[Ilock] <<
" | " << YesNo[ShClose]
1150 <<
" | " << YesNo[ShOpen] <<
" | " << OnOff[HV2] <<
" | " << OnOff[HV1] <<
" | " << OnOff[LV]
1151 <<
" | " << OnOff[Alpha2] <<
" | " << OnOff[Alpha1] <<
" | " << OnOff[Alpha0] <<
" |" << std::endl;
1154 std::cout <<
"CRITICAL ERROR! Wrong size" << std::endl;
1164 std::cout<<
"\nLASTROD New Laser Object, " <<
size <<
" words found" << std::endl;
1166 bool first_half_present = (
size == 25 ||
size == 26 ||
size == 128 ||
size == 129);
1167 bool second_half_present = (
size == 99 ||
size == 100 ||
size == 128 ||
size == 129);
1169 if ( ! (first_half_present || second_half_present) ) {
1170 std::cout <<
"CRITICAL ERROR! Unknown format!" << std::endl;
1173 const char *
name[17] = {
" PhotoDiode 0",
1196 const unsigned int *
p =
data;
1198 if (first_half_present) {
1206 std::cout << std::endl <<
" DAQ type: " << std::setw(5) << (
data[0]%0xFF) << std::endl;
1207 std::cout <<
" Laser Counter: " << std::setw(5) <<
data[1] << std::endl;
1208 std::cout <<
" Required Amp: " << std::setw(5) << (
data[2]>>16) << std::endl;
1209 std::cout <<
" Measured Amp: " << std::setw(5) << (
data[2]&0xFFFF) << std::endl;
1210 std::cout <<
" Filter Wheel: " << std::setw(5) << (
data[3]>>16 & 0x000F) << std::endl;
1211 std::cout <<
" Delay: " << std::setw(5) << (
data[3]&0xFFFF) << std::endl;
1212 std::cout <<
" Linearity DAC: " << std::setw(5) << (
data[4]&0xFFFF) << std::endl;
1213 std::cout << std::endl;
1217 std::cout <<
" HG LG" << std::endl;
1218 for (
int n=0;
n<17; ++
n) {
1220 std::cout <<
name[
n] <<
": " << std::setw(5) << ((*p)&0xFFFF) << std::setw(6) << ((*p)>>16) <<
" => " << std::setw(5) << (8500-((*p)&0xFFFF)) << std::setw(6) << (8500-((*p)>>16))<< std::endl;
1241 std::bitset<32>
status = *(
p++);
1242 const char *YesNo[2] = {
" No",
"Yes"};
1243 std::cout << std::endl;
1244 std::cout <<
"| Link| Link| Bad | Bad | TTC | TTC | PLL | PLL |Laser|Laser|Inter| Comb| Busy| Long|" << std::endl;
1245 std::cout <<
"| not | not | VME | TTC |doubl|singl| lock| lock| temp| diod| lock| run | | busy|" << std::endl;
1246 std::cout <<
"| full| down|clock|clock|error|error| VME | TTC |fault| off |close| fini| |>5sec|" << std::endl;
1247 std::cout <<
"|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|" << std::endl;
1248 std::cout <<
"| " << YesNo[
status[27]] <<
" | " << YesNo[
status[26]] <<
" | " << YesNo[
status[24]] <<
" | " << YesNo[
status[22]] <<
" | " << YesNo[
status[20]] <<
" | " << YesNo[
status[19]] <<
" | " << YesNo[
status[16]] <<
" | " << YesNo[
status[15]] <<
" | " << YesNo[
status[10]] <<
" | " << YesNo[
status[9]] <<
" | " << YesNo[
status[8]] <<
" | " << YesNo[
status[6]] <<
" | " << YesNo[
status[1]] <<
" | " << YesNo[
status[0]] <<
" |" << std::endl;
1250 std::cout << std::endl <<
" FPGA Global Status: 0x" << std::hex
1251 <<
status.to_ulong() <<
" => " <<
status.to_string() << std::dec << std::endl;
1253 gmtime_r(&tim, &TimeInfo);
1254 strftime(buf, 80,
"%d.%m.%Y %H:%M:%S", &TimeInfo);
1255 std::cout <<
"DCS Time Stamp (GMT): " << buf <<
" => " <<
cern_local_time(tim) << std::endl;
1256 std::cout <<
" PhotoDiode Polarity: " << std::setw(5) << (*
p++) << std::endl;
1260 if (second_half_present) {
1261 std::cout <<
" Calibration Type: " << std::setw(5) << (*
p++) << std::endl;
1263 gmtime_r(&tim, &TimeInfo);
1264 strftime(buf, 80,
"%d.%m.%Y %H:%M:%S", &TimeInfo);
1265 std::cout <<
" Time Stamp (GMT): " << buf <<
" => " <<
cern_local_time(tim) << std::endl;
1268 if (
p[96]==0 || (
p[96]==3072 && (*
p)<21504000)) {
1269 std::cout <<
" Number of events: " <<
p[96] <<
" => assuming 1024" << std::endl << std::endl;
1272 std::cout <<
" Number of events: " << std::setw(5) <<
p[96] << std::endl << std::endl;
1274 std::cout <<
" pedHG rmsHG pedLG rmsLG" << std::endl;
1275 for (
int n=0;
n<16; ++
n) {
1288 double ped0 =
double(sum0)/nevt;
1289 double ped1 =
double(sum1)/nevt;
1291 double rms0 =
double(ssq0)/nevt - ped0*ped0;
1292 double rms1 =
double(ssq1)/nevt - ped1*ped1;
1293 if (rms0>0.0) rms0 = sqrt(rms0);
1294 if (rms1>0.0) rms1 = sqrt(rms1);
1296 std::cout <<
name[
n] <<
":" << std::setw(11) << sum0 << std::setw(11) << sum1 << std::setw(11) << msb0 << std::setw(11) << lsb0 << std::setw(11) << msb1 << std::setw(11) << lsb1 <<
" => " << std::setw(7) << std::setprecision(1) << 8500.-ped0 <<
" +/- " << std::setw(7) << std::setprecision(1) << rms0 <<
" " << std::setw(7) << std::setprecision(1) << 8500.-ped1 <<
" +/- " << std::setw(7) << std::setprecision(1) << rms1 << std::endl;
1304 std::cout <<
"\nLaser ADC, " <<
size <<
" channels found";
1306 if (
c % 8 == 0) std::cout <<
setupMod <<
c/8<<
":";
1307 std::cout << std::setw(9) <<
data[
c];
1309 std::cout << std::endl;
1313 std::cout <<
"\nECAL ADC, " <<
size <<
" channels found";
1315 if (
c % 8 == 0) std::cout <<
setupMod <<
c/8<<
":";
1316 std::cout << std::setw(9) <<
data[
c];
1318 std::cout << std::endl;
1322 std::cout <<
"\nDigi parameters, " <<
size <<
" words found";
1324 if (
c % 8 == 0) std::cout <<
setupMod <<
c/8<<
":";
1325 std::cout << std::setw(11) <<
data[
c];
1327 std::cout << std::endl;
1330 const unsigned int *
p =
data;
1331 int Counter = 0,
Mode = 0, Samples = 0, Pipeline = 0, I3Delay = 0,
Event = 0, Phase = 0,
1332 DAC = 0, Capacity = 0, Card = 0,
RunType = 0, microsec = 0;
1334 bool DefFormat =
true;
1335 if (
size == 4) DefFormat =
false;
1359 const char *RunTypeText;
1361 case 1: RunTypeText =
"Physics";
break;
1362 case 2: RunTypeText =
"Laser";
break;
1363 case 4: RunTypeText =
"Pedestals";
break;
1364 case 8: RunTypeText =
"CIS mono";
break;
1365 case 16: RunTypeText =
"CIS scan";
break;
1366 default: RunTypeText =
"Unknown";
break;
1369 std::cout <<
"\n CIS Counter: " << std::setw(3) << Counter<< std::endl;
1370 std::cout <<
"\n Run Type: " << std::setw(3) <<
RunType <<
" (" << RunTypeText <<
")";
1372 std::cout <<
"\n Samples: " << std::setw(3) << Samples;
1373 std::cout <<
"\n Pipeline: " << std::setw(3) << Pipeline << std::endl;
1375 const char* ModeText;
1378 ModeText =
"Normal";
1380 case 1: ModeText =
"Calibration";
break;
1381 default: ModeText =
"Unknown";
break;
1386 gmtime_r(&
Time, &TimeInfo);
1387 strftime(buf, 80,
"%d.%m.%Y %H:%M:%S", &TimeInfo);
1388 std::cout << std::endl;
1390 std::cout <<
" Microsec.: " << microsec << std::endl << std::endl;
1391 std::cout <<
" Mode: " << std::setw(3) <<
Mode <<
" (" << ModeText <<
")" << std::endl;
1392 std::cout <<
" Samples: " << std::setw(3) << Samples << std::endl;
1393 std::cout <<
" Pipeline: " << std::setw(3) << Pipeline << std::endl;
1394 std::cout <<
" I3Delay: " << std::setw(3) << I3Delay << std::endl;
1395 std::cout <<
" Event: " << std::setw(3) <<
Event << std::endl;
1396 std::cout <<
" Phase: " << std::setw(3) << Phase << std::endl;
1397 std::cout <<
" DAC: " << std::setw(3) << DAC << std::endl;
1398 std::cout <<
" Capacity: " << std::setw(3) << Capacity <<
" pF" << std::endl;
1399 std::cout <<
" Card: " << std::setw(3) << Card << std::endl;
1402 int last =
size - 1;
1403 for (; last > 15; --last) {
1404 if (
data[last] != 0)
break;
1407 std::cout <<
"\n Remaing " << last - 15 <<
" non-zero words (hex):";
1408 for (
c = 16;
c <= last; ++
c) {
1409 if (
c % 8 == 0) std::cout <<
setupMod <<
c/8<<
":";
1410 std::cout << std::hex << std::setw(11) <<
data[
c] << std::dec;
1412 std::cout << std:: endl;
1417 std::cout <<
"CRITICAL ERROR! Unknown format!" << std::endl;
1422 std::cout <<
"\nAdder FADC, " <<
size <<
" words found (hex)" ;
1424 if (
c % 8 == 0) std::cout <<
setupMod <<
c/8<<
":";
1425 std::cout << std::hex << std::setw(9) <<
data[
c] << std::dec;
1427 std::cout << std::endl;
1438 std::cout <<
"\nCoincidence trigger frag " <<
id -
COIN_TRIG1_FRAG + 1 <<
", " <<
size <<
" words found (hex)";
1440 if (
c % 8 == 0) std::cout <<
setupMod <<
c/8<<
":";
1441 std::cout << std::hex << std::setw(11) <<
data[
c] << std::dec;
1443 std::cout << std::endl;
1447 std::cout <<
"\nUnknown fragment [0x" << std::hex <<
id << std::dec <<
"], " <<
size <<
" words found" << std::endl;
1454 fragType = (*itr).second;
1456 fragType = (
id >> 8);
1457 if (fragType > 4 || fragType < 1) fragType = 2;
1468 std::cout <<
"\nDigitizer fragment 0x" << std::hex <<
id << std::dec <<
", " <<
size <<
" words found:"
1469 <<
"\t" <<
nchan / 3 <<
" chips, " << nsamp <<
"+2 samples" << std::endl;
1473 }
else if (
ngain == 2) {
1480 std::cout <<
"\nfirst data word:" << std::setw(12) <<
data[0] <<
" (0x"<<
setup0 <<
data[0] <<
setupDec <<
")";
1485 std::cout <<
"\n" << std::setw(3) <<
extra <<
" extra words:";
1490 std::cout << std::endl;
1493 std::cout <<
"\nPMT Ch | BCID M G";
1494 for (
s = 0;
s < nsamp; ++
s) {
1495 std::cout << std::setw(4) <<
s <<
" ";
1498 std::cout <<
" Head/Data/CRC\n---|---|-------------------------";
1499 for (
s = 0;
s < nsamp; ++
s) {
1500 std::cout <<
"-----";
1510 std::cout <<
"\n" << std::setw(3) <<
pmt << std::setw(3) <<
ch <<
" |";
1512 std::cout <<
"\n -- " << std::setw(2) <<
ch <<
" |";
1516 std::cout << std::setw(5) << (
channel[
ch].bcid) << std::setw(2) << ((
channel[
ch].flag >> 3) & 3);
1521 std::cout << std::setw(2) << (
channel[
ch].gain);
1523 for (
s = 0;
s < nsamp; ++
s) {
1524 std::cout << std::setw(5) << (
channel[
ch].sample[
s]);
1567 for (
int i = 0;
i < 7;
i++) {
1571 std::cout <<
" RawERR ";
1574 for (
int i = 0;
i < 7;
i++) {
1575 std::cout << std::setw(5) << Frag5Data[
ch].
s[
i] ;
1580 if (!OK) std::cout <<
"\nOF weights: ERROR";
1584 std::cout << std::endl;
1586 for (
int ch = 0;
ch < 48;
ch++) {
1588 for (
int i = 0;
i < 7;
i++) {
1605 std::cout <<
" " <<
ch <<
",";
1608 std::cout <<
"\nCompare Raw <=> Frag5: ";
1610 std::cout <<
"OK" << std::endl;
1612 std::cout <<
"ERROR" << std::endl;
1620 std::cout <<
"\nRaw data compressed fragment 0x" << std::hex <<
id << std::dec <<
", " <<
size <<
" words found" << std::endl;
1625 std::cout <<
"\nRaw data compressed fragment 0x" << std::hex <<
id << std::dec <<
", " <<
size <<
" words found:"
1626 <<
"\t" <<
ngain <<
" gain, " <<
nchan <<
" channels in total" << std::endl;
1628 std::cout <<
"\nPMT Ch |";
1629 for (
int j = 1; j <= ((nsamp / 2) + 1); j++) {
1630 std::cout <<
" HexWord" << j <<
" ";
1634 for (
int l = 1;
l <= nsamp;
l++) {
1635 std::cout <<
" Smp" <<
l;
1642 std::cout <<
"\n" << std::setw(3) <<
pmt << std::setw(3) <<
ch <<
" |";
1644 std::cout <<
"\n -- " << std::setw(2) <<
ch <<
" |";
1646 std::cout << std::hex << std::setfill(
'0');
1647 for (
int j = 0; j < ((nsamp / 2) + 1); j++) {
1648 std::cout <<
" " << std::setw(8) << rawcomp[
i].
words[j] <<
" ";
1651 for (
int l = 0;
l < nsamp;
l++) {
1652 std::cout << std::setw(6) << rawcomp[
i].
samples[
l];
1654 if (!rawcomp[
i].verif) std::cout <<
" Wrong Data";
1661 std::cout <<
"\nReco non calibrated energy fragment 0x" << std::hex <<
id << std::dec <<
", " <<
size <<
" words found:"
1662 <<
"\t" <<
ngain <<
" gain, " <<
nchan <<
" channels in total" << std::endl
1663 <<
"\tATTENTION: HIGH gain amplitude is divided by 64" << std::endl;
1665 std::cout <<
"\nPMT Ch | full word | G amp time q amp time qual";
1669 std::cout <<
"\n" << std::setw(3) <<
pmt << std::setw(3) <<
ch <<
" |";
1671 std::cout <<
"\n -- " << std::setw(2) <<
ch <<
" |";
1674 << std::setw(1) << recochan[
ch].
gain << std::setw(6) << recochan[
ch].
amp << std::setw(5) << recochan[
ch].
time
1675 << std::setw(3) << recochan[
ch].
quality << std::setw(10) << std::setprecision(1) <<
float (recochan[
ch].
gain ? recochan[
ch].d_amp / 64. : recochan[
ch].d_amp)
1676 << std::setw(11) << std::setprecision(4) << (
float) recochan[
ch].d_time << std::setw(8) << std::setprecision(1) << (
float) recochan[
ch].d_quality;
1686 std::cout <<
"\nReco calibrated energy fragment 0x" << std::hex <<
id << std::dec <<
", " <<
size <<
" words found:"
1687 <<
"\t" << ((
nchan > 48 &&
nchan < 96) ? 1 :
ngain) <<
" gain, " << unitName[
unit].c_str() <<
" units, " <<
nchan <<
" channels in total" << std::endl;
1690 std::cout <<
"Reco flags: 0x" << std::hex << std::setfill(
'0') << rflag <<
setupDec <<
" units: " << unitName[
unit].c_str() <<
" pulse_shape: " << shapeName[pulse].c_str() <<
" nsamples: " << 7 + 2 * nsmpl <<
" algorithm: " <<
algName[algor + 1].c_str() <<
" niterations: " << niter << std::endl;
1692 std::cout <<
"Reco flags: 0x" << std::hex << std::setfill(
'0') << rflag <<
setupDec <<
" units: " << unitName[
unit].c_str() <<
" pulse_shape: " << shapeName[pulse].c_str() <<
" nsamples: " << 7 + 2 * nsmpl <<
" algorithm: " <<
algName[algor * 4 + niter].c_str() << std::endl;
1695 std::cout <<
"\nPMT Ch | full word | G amp time b q amp time qual";
1699 std::cout <<
"\n" << std::setw(3) <<
pmt << std::setw(3) <<
ch <<
" |";
1701 std::cout <<
"\n -- " << std::setw(2) <<
ch <<
" |";
1707 std::cout <<
" 0x" <<
setup0 << recocalib[
ch].
word <<
setupDec <<
" | " << std::setw(1) << recocalib[
ch].
gain << std::setw(6) << recocalib[
ch].
amp << std::setw(5) << recocalib[
ch].
time << std::setw(2) << recocalib[
ch].
bad << std::setw(3) << recocalib[
ch].
quality << std::setw(10) << std::setprecision(1) << recocalib[
ch].
d_amp << std::setw(11) << std::setprecision(4) << recocalib[
ch].
d_time << std::setw(8) << std::setprecision(1) << recocalib[
ch].
d_quality;
1709 if (recocalib[
ch].
bad != 0) {
1710 std::cout <<
" Bad channel";
1725 std::cout <<
"\nFrag5 Compressed fragment 0x" << std::hex <<
id << std::dec <<
", " <<
size <<
" words found:"
1726 <<
"\t" << 1 <<
" gain, " << unitName[
unit].c_str() <<
" units, " <<
nchan <<
" channels in total" << std::endl;
1735 std::vector<double>
a(7),
b(7),
c(7),
g(7),
dg(7);
1751 for (
int i = 0;
i < 7; ++
i) {
1770 int size_L2 = (*((
const uint32_t*)
data - 3 + 2) >> (32 - 2 - 3)) & 0x7;
1771 std::cout <<
"size_L2: " << size_L2 <<
" |";
1776 std::cout <<
" SumEt: " << SumEt <<
", SumEz: " << SumEz <<
", SumE: " << SumE << std::endl;
1778 std::cout << std::endl;
1782 #define code_ped4 TileRawChannel2Bytes5::code_ped4
1783 #define code_ped5 TileRawChannel2Bytes5::code_ped5
1784 #define code_amp5 TileRawChannel2Bytes5::code_amp5
1785 #define code_amp6 TileRawChannel2Bytes5::code_amp6
1786 #define code_raws TileRawChannel2Bytes5::code_raws
1787 #define code_rawf TileRawChannel2Bytes5::code_rawf
1788 #define code_full TileRawChannel2Bytes5::code_full
1789 #define code_dump TileRawChannel2Bytes5::code_dump
1790 #define code_null TileRawChannel2Bytes5::code_null
1792 int cnt_ped4, cnt_ped5, cnt_amp5, cnt_amp6, cnt_raws, cnt_rawf, cnt_full, cnt_dump, cnt_null;
1793 cnt_ped4 = cnt_ped5 = cnt_amp5 = cnt_amp6 = cnt_raws = cnt_rawf = cnt_full = cnt_dump = cnt_null = 0;
1794 std::cout <<
"PMT Ch | full word | Type G B ectrl ereco ebin ene time | s1 s2 s3 s4 s5 s6 s7";
1796 const char *strcode_empty =
"----";
1797 const char *strcode_ped4 =
"ped4";
1798 const char *strcode_ped5 =
"ped5";
1799 const char *strcode_amp5 =
"amp5";
1800 const char *strcode_amp6 =
"amp6";
1801 const char *strcode_raws =
"raws";
1802 const char *strcode_rawf =
"rawf";
1803 const char *strcode_full =
"full";
1804 const char *strcode_dump =
"dump";
1805 const char *strcode_null =
"null";
1806 const char *strcode_error =
"ERR ";
1812 std::cout <<
"\n" << std::setw(3) <<
pmt << std::setw(3) <<
ch <<
" |";
1814 std::cout <<
"\n -- " << std::setw(2) <<
ch <<
" |";
1818 const char *scode = strcode_empty;
1823 float ene = Frag5Data[
ch].
ene;
1826 for (
int i = 0;
i < 7;
i++) {
1827 s[
i] = Frag5Data[
ch].
s[
i];
1831 case code_ped4: scode = strcode_ped4; cnt_ped4++;
break;
1832 case code_ped5: scode = strcode_ped5; cnt_ped5++;
break;
1833 case code_amp5: scode = strcode_amp5; cnt_amp5++;
break;
1834 case code_amp6: scode = strcode_amp6; cnt_amp6++;
break;
1835 case code_raws: scode = strcode_raws; cnt_raws++;
break;
1836 case code_rawf: scode = strcode_rawf; cnt_rawf++;
break;
1837 case code_full: scode = strcode_full; cnt_full++;
break;
1838 case code_dump: scode = strcode_dump; cnt_dump++;
break;
1839 case code_null: scode = strcode_null; cnt_null++;
break;
1840 default: scode = strcode_error;
break;
1843 int ene_recobin = ene_bin + (
gain == 0 ? 512 : 2048);
1853 ene_bin += (
gain == 0 ? 512 : 2048);
1860 }
else if (ene_ctrl > 0x7FFF) {
1872 std::cout << std::setw(7) << ene_ctrl << std::setw(7) << ene_recobin << std::setw(6) << ene_bin << std::setw(10) << std::setprecision(4) << ene <<
" -- ";
1876 std::cout << std::setw(7) << ene_ctrl << std::setw(7) << ene_recobin << std::setw(6) << ene_bin << std::setw(10) << std::setprecision(4) << ene << std::setw(6) << std::setprecision(1) <<
time <<
" ";
1880 std::cout <<
" ----- ----- ---- --- -- ";
1885 std::cout <<
"| " << std::setw(4) <<
s[0] << std::setw(5) <<
s[1] << std::setw(5) <<
s[2] << std::setw(5) <<
s[3] << std::setw(5) <<
s[4] << std::setw(5) <<
s[5] << std::setw(5) <<
s[6] <<
" " ;
1886 if (ene_ctrl != ene_recobin) {
1888 std::cout <<
" ERR";
1892 std::cout <<
"\n\nFrag5 Self-Consistency: ";
1894 std::cout <<
"OK" << std::endl;
1896 std::cout <<
"ERROR" << std::endl;
1899 std::cout <<
"\nped4" << cnt_ped4 <<
", ped5 " << cnt_ped5 <<
", amp5 " << cnt_amp5 <<
", amp6 " << cnt_amp6 <<
", raws " << cnt_raws <<
", rawf " << cnt_rawf <<
", full " << cnt_full <<
", dump " << cnt_dump <<
", null " << cnt_null << std::endl;
1906 std::cout <<
"\nFELIX fragment 0x" << std::hex <<
id << std::dec <<
", " <<
size <<
" words found" << std::endl;
1910 std::cout << std::hex << std::endl;
1911 bool phase2format = (
size>
head && correct_data[2] == 0x12345678 && correct_data[
size-1] == 0x87654321);
1913 int thisVersion = (((correct_data[3] >> 16) & 0xFFFF) == 0) ? 1 : 0;
1914 const char * namesV0[] = {
"size_packet",
"elink",
"SOP",
"runParam1",
"runParam2",
"runParam3",
"runParam4",
"BC_MD_ID",
"L1ID" };
1915 const char * namesV1[] = {
"size_packet",
"elink",
"SOP",
"version",
"MODULE_BC_MD",
"L1ID",
"BCR" ,
"runParam1",
"runParam2",
"runParam3"};
1916 const char **
names = (thisVersion) ? namesV1 : namesV0;
1917 if (thisVersion)
head = 10;
1919 std::cout << std::setw(13) <<
names[
i] << std::setw(10) << correct_data[
i] << std::endl;
1924 std::cout <<
" Word" << std::setw(3) <<
i << std::setw(10) << correct_data[
i] << std::endl;
1927 std::cout << std::dec << std::endl;
1928 FelixData_t digitsHighGain, digitsLowGain, digitsMetaData;
1929 unpack_frag6(correct_data.data(),
size, digitsHighGain, digitsLowGain, digitsMetaData);
1931 std::cout <<
" MD1 MD2 MD3 MD4" << std::endl;
1932 std::cout <<
"-----------------------------------------------------";
1933 const char * metaNamesV0[] = {
"BCID",
"L1ID",
"ModuleID",
"RunType",
"RunNumber",
"PedHi",
"PedLo",
"ChargeInj",
"TimeInj",
"Capacitor",
"ECR" };
1934 const char * metaNamesV1[] = {
"BCID",
"L1ID",
"ModuleID",
"RunType",
"RunNumber",
"PedHi",
"PedLo",
"ChargeInj",
"TimeInj",
"Capacitor",
"ECR",
"BCR",
"Version",
"FragID" };
1935 const char ** metaNames = (
version) ? metaNamesV1 : metaNamesV0;
1936 for (
size_t i = 0;
i < digitsMetaData.size(); ++
i) {
1937 std::cout << std::endl << std::setw(13) << metaNames[
i];
1938 for (
size_t j = 0; j<digitsMetaData[
i].size(); ++j) {
1939 std::cout << std::setw(10) << digitsMetaData[
i][j];
1942 std::cout << std::endl << std::endl;
1945 if (digitsLowGain[0].
size()>0)
1947 if (digitsHighGain[0].
size()>0)
1950 std::cout <<
" ch G ";
1951 for (
size_t s = 0;
s < nsamp; ++
s) {
1952 std::cout << std::setw(5) <<
s;
1954 std::string
a(8+nsamp*5,
'-');
1955 std::cout << std::endl <<
a;
1957 for (
size_t ch = 0;
ch < digitsHighGain.size() ; ++
ch) {
1958 std::cout << std::endl << std::setw(3) <<
ch <<
" HG ";
1959 for (
size_t s = 0;
s < digitsHighGain[
ch].size(); ++
s) {
1960 std::cout << std::setw(5) << (digitsHighGain[
ch][
s]);
1964 for (
size_t ch = 0;
ch < digitsLowGain.size() ; ++
ch) {
1965 std::cout << std::endl << std::setw(3) <<
ch <<
" LG ";
1966 for (
size_t s = 0;
s < digitsLowGain[
ch].size(); ++
s) {
1967 std::cout << std::setw(5) << (digitsLowGain[
ch][
s]);
1970 std::cout << std::endl << std::endl;
1978 std::cout <<
"\nQuality fragment 0x" << std::hex <<
id <<
", " << std::dec <<
size <<
" words found:" << std::endl;
1981 std::cout <<
" ATTENTION: Error bits found in the Data Quality fragment 0xA" << std::endl;
1984 std::cout <<
" --------------------------------------" << std::endl;
1985 std::cout <<
" | Quality Block | Word (16bit)" << std::endl;
1987 std::cout <<
" | DSP BCID | " << std::dec << (DQword.
dspbcid & 0x7FFF) << std::endl;
1989 std::cout <<
" | DSP BCID | not filled (" << std::dec << DQword.
dspbcid <<
")" << std::endl;
1991 std::cout <<
" | Global CRC | " << std::hex <<
"0x" << std::setw(1) << DQword.
global_crc << std::setfill(
'0') << std::endl;
1992 std::cout <<
" | BCID checks | " <<
setup0x4 << DQword.
bcid << std::endl;
1993 std::cout <<
" | Mem parity err | " <<
setup0x4 << DQword.
memory << std::endl;
1994 std::cout <<
" | Single strobe err | " <<
setup0x4 << DQword.
Sstrobe << std::endl;
1995 std::cout <<
" | Double strobe err | " <<
setup0x4 << DQword.
Dstrobe << std::endl;
2002 std::cout <<
" --------------------------------------" << std::setfill(
' ') << std::dec << std::endl;
2006 std::cout <<
"\nUnknown (type " <<
type <<
") fragment 0x" << std::hex <<
id <<
", " << std::dec <<
size <<
" words found" << std::endl;
2009 std::cout << std::endl;
2011 std::cout <<
"\nType " <<
type <<
" fragment 0x" << std::hex <<
id <<
", " << std::dec <<
size <<
" words found" << std::endl;
2012 std::cout <<
"\nEmpty Event" << std::endl;
2022 std::cout <<
"size of data block: " << nw << std::endl;
2023 for (
i = 0;
i < nw;
i++,
data++) {
2024 std::cout << std::setw(4) <<
i <<
": 0x" << std::hex << std::setw(8) << *
data <<
"\t" << std::dec << std::setw(10) << *
data << std::endl;
2039 std::cout <<
" *(p) = 0x" << std::hex << (*(
data)) << std::dec << ((
m_v3Format)?
"":
" => ERROR Corrupted frag separator") << std::endl;
2040 std::cout <<
" v3Format = true" << std::endl;
2043 std::cout << std::endl <<
"Dump of whole data fragment ("
2044 <<
size <<
" words)" << std::endl;
2058 std::cout <<
"\nWarning: garbage in frag " << nfrag <<
" of current ROD -> ignore it" << std::endl;
2060 std::cout <<
"Id: \t" << std::setw(10) << (frag[nfrag]->
id) << std::endl;
2061 std::cout <<
"Bad data:" << std::endl;
2062 std::cout <<
"Before:\t" <<
offset-1 <<
"\t" <<
data[
offset-1] <<
"\t0x" << std::hex <<
data[
offset-1] << std::dec << std::endl;
2077 std::cout <<
"\nWarning: frag " << nfrag <<
" of current ROD is damaged" << std::endl;
2079 std::cout <<
"Id: \t" << std::setw(10) << (frag[nfrag]->
id) << std::endl;
2080 std::cout <<
"Bad data:" << std::endl;
2081 unsigned int newsize = 0;
2082 std::cout <<
"Before:\t" <<
offset-1 <<
"\t" <<
data[
offset-1] <<
"\t0x" << std::hex <<
data[
offset-1] << std::dec << std::endl;
2094 std::cout <<
"Correct size is:\t" << std::setw(10) << newsize << std::endl;
2109 std::cout <<
"\nWarning: last fragment in current ROD is garbage -> ignore it" << std::endl;
2110 std::cout <<
"N good frag: \t" << std::setw(10) << nfrag << std::endl;
2111 std::cout <<
"Last frag:" << std::endl;
2113 std::cout <<
"\t" <<
i <<
"\t" <<
data[
i] <<
"\t0x" << std::hex <<
data[
i] << std::dec << std::endl;
2126 std::vector<unsigned int>
bcid(Tile::MAX_MINIDRAWER);
2127 std::vector<unsigned int> l1id(Tile::MAX_MINIDRAWER);
2128 std::vector<unsigned int> moduleID(Tile::MAX_MINIDRAWER);
2129 std::vector<unsigned int>
runType (Tile::MAX_MINIDRAWER);
2130 std::vector<unsigned int>
runNumber(Tile::MAX_MINIDRAWER);
2131 std::vector<unsigned int> pedestalHi(Tile::MAX_MINIDRAWER);
2132 std::vector<unsigned int> pedestalLo(Tile::MAX_MINIDRAWER);
2133 std::vector<unsigned int> chargeInjected(Tile::MAX_MINIDRAWER);
2134 std::vector<unsigned int> timeInjected(Tile::MAX_MINIDRAWER);
2135 std::vector<unsigned int> capacitor(Tile::MAX_MINIDRAWER);
2136 std::vector<unsigned int> ecr(Tile::MAX_MINIDRAWER);
2137 std::vector<unsigned int> bcr(Tile::MAX_MINIDRAWER);
2138 std::vector<unsigned int> packetVersion(Tile::MAX_MINIDRAWER);
2139 std::vector<unsigned int> fragmentID(Tile::MAX_MINIDRAWER);
2141 digitsHighGain.clear();
2142 digitsLowGain.clear();
2143 digitsMetaData.clear();
2146 int mdFragmentSize = (*data) & 0xFFFF;
2147 int sampleNumber = mdFragmentSize / Tile::MAX_MINIDRAWER_CHAN;
2150 while (
data < end_data) {
2151 if (*
data == 0x12345678 ) {
2152 mdFragmentSize = (*(
data - 2)) & 0xFFFF;
2154 if ((++
data < end_data)) {
2155 version = (((*
data >> 16) & 0xFFFF) == 0) ? 1 : 0;
2157 int mdSizeOverhead = (
version == 0) ? 10 : 11;
2158 int delta = mdFragmentSize - (sampleNumber * Tile::MAX_MINIDRAWER_CHAN + mdSizeOverhead);
2160 ATH_MSG_WARNING(
"FRAG6: Unexpected MD fragment size " << mdFragmentSize <<
" => "
2161 << sampleNumber <<
" samples will be unpacked and last "
2162 << delta <<
" words will be ignored ");
2164 unsigned int miniDrawer = -1;
2168 if (trailer < end_data && *trailer == 0x87654321) {
2169 unsigned int paramsSize = 3;
2172 unsigned int fragSize = *
data & 0xFF;
2173 paramsSize = (*
data >> 8 ) & 0xFF;
2175 miniDrawer = *(
data + 4) & 0xFF;
2176 moduleID[miniDrawer ] = (*
data >> 16) & 0xFF;
2179 if (fragSize != sampleNumber * Tile::MAX_MINIDRAWER_CHAN) {
2180 std::cout <<
"Minidrawer [" << miniDrawer
2181 <<
"] has unexpected fragment size: " << fragSize
2182 <<
" correct value for " << sampleNumber
2183 <<
" samples is " << sampleNumber * Tile::MAX_MINIDRAWER_CHAN << std::endl;
2186 if (paramsSize == 3){
2189 pedestalLo[miniDrawer] = *(++
data) & 0xFFF;
2190 pedestalHi[miniDrawer] = (*
data >> 12 ) & 0xFFF;
2192 chargeInjected[miniDrawer] = *(++
data) & 0xFFF;
2193 timeInjected[miniDrawer] = (*
data >> 12) & 0xFF;
2194 capacitor[miniDrawer] = (*
data >> 20) & 0
x1;
2197 std::cout <<
"Minidrawer [" << miniDrawer
2198 <<
"] has unexpected number of parameter words: " << paramsSize
2199 <<
" => ignore them !!!" << std::endl;
2203 bcid[miniDrawer] = (*(++
data) >> 16) & 0xFFFF;
2204 l1id[miniDrawer] = *(++
data) & 0xFFFFFF;
2205 ecr[miniDrawer] = (*
data >> 24) & 0xFF;
2207 miniDrawer = *(
data + 1) & 0xFF;
2209 packetVersion[miniDrawer] = (*data) & 0xFF;
2210 fragmentID[miniDrawer] = (*
data >> 8) & 0xFF;
2212 bcid[miniDrawer] = (*(++
data) >> 8) & 0xFFF;
2213 moduleID[miniDrawer] = (*
data >> 20) & 0xFFF;
2215 l1id[miniDrawer] = *(++
data) & 0xFFFFFF;
2216 ecr[miniDrawer] = (*
data >> 24) & 0xFF;
2218 bcr[miniDrawer] = *(++
data);
2220 if (packetVersion[miniDrawer] == 1) {
2221 pedestalLo[miniDrawer] = *(++
data) & 0xFFF;
2222 pedestalHi[miniDrawer] = (*
data >> 12 ) & 0xFFF;
2229 pedestalLo[miniDrawer] = *(++
data) & 0xFFF;
2230 pedestalHi[miniDrawer] = (*
data >> 12 ) & 0xFFF;
2234 chargeInjected[miniDrawer] = *(++
data) & 0xFFF;
2235 timeInjected[miniDrawer] = (*
data >> 12) & 0xFF;
2236 capacitor[miniDrawer] = (*
data >> 20) & 0
x1;
2243 size_t start_channel(miniDrawer * Tile::MAX_MINIDRAWER_CHAN);
2244 size_t end_channel(start_channel + Tile::MAX_MINIDRAWER_CHAN);
2246 if (end_channel > digitsHighGain.size()) digitsHighGain.resize(end_channel);
2248 digitsHighGain[
channel].resize(sampleNumber);
2249 for (
int samplesIdx = 0; samplesIdx<sampleNumber; ++samplesIdx) {
2255 if (end_channel > digitsLowGain.size()) digitsLowGain.resize(end_channel);
2257 digitsLowGain[
channel].resize(sampleNumber);
2258 for (
int samplesIdx = 0; samplesIdx<sampleNumber; ++samplesIdx) {
2267 std::cout <<
"Wrong trailer for MD[" << miniDrawer <<
"] => skip MD fragment !!!" << std::endl;
2275 digitsMetaData.push_back(
bcid);
2276 digitsMetaData.push_back(l1id);
2277 digitsMetaData.push_back(moduleID);
2278 digitsMetaData.push_back(
runType);
2280 digitsMetaData.push_back(pedestalHi);
2281 digitsMetaData.push_back(pedestalLo);
2282 digitsMetaData.push_back(chargeInjected);
2283 digitsMetaData.push_back(timeInjected);
2284 digitsMetaData.push_back(capacitor);
2285 digitsMetaData.push_back(ecr);
2287 digitsMetaData.push_back(bcr);
2288 digitsMetaData.push_back(packetVersion);
2289 digitsMetaData.push_back(fragmentID);
2301 const unsigned int *
data = frag->
data;
2315 DQword.
bcid =
w & 0xFFFF;
2316 DQword.
memory = (
w >> 16) & 0xFFFF;
2327 DQword.
Dstrobe = (
w >> 16) & 0xFFFF;
2372 ,
int nchannel_max,
unsigned int
2373 ,
int ,
int *
ngain,
int *nchannel) {
2379 const unsigned int *
data = frag->
data;
2382 for (;
ch <
size &&
ch < nchannel_max; ++
ch) {
2405 ,
int nchannel_max,
unsigned int
2407 ,
int ,
int *
ngain,
int *nchannel) {
2413 const unsigned int *
data = frag->
data;
2416 for (;
ch <
size &&
ch < nchannel_max; ++
ch) {
2439 ,
int nchannel_max,
unsigned int ,
int
2440 ,
int*
ngain,
int* nchannel,
int* nsample) {
2446 unsigned int id = frag->
id;
2447 int frag1version = (
id >> 31) & 0
x1;
2448 int nbchanformat1 = (
id >> 24) & 0x3F;
2450 if (frag1version == 0) {
2452 if ((
size % 4) != 0) {
2453 std::cout <<
" Format Type 1: Raw compressed : Wrong Size = " <<
size << std::endl;
2465 const unsigned int *
data = frag->
data;
2470 unsigned int w =
data[
i++];
2472 nsamp = ((
w >> 8) & 0x0F);
2473 rawcomp[
ch].
chan = (
w & 0xFF);
2476 for (
int j = 1; j < ((nsamp / 2) + 1); j++) {
2478 for (
int l = 1;
l < nsamp;
l += 2) {
2483 rawcomp[
ch].
verif = (((*nsample) == nsamp) && (rawcomp[
ch].
chan < 48));
2484 if (!rawcomp[
ch].verif) {
2486 std::cout <<
" Verification ERROR for channel # " <<
ch <<
" (ch=" << rawcomp[
ch].
chan <<
" g=" << rawcomp[
ch].
gain <<
" ns=" << nsamp <<
" 0x" << std::hex << (rawcomp[
ch].
words[0] & 0xFFFF) << std::dec <<
")!" << std::endl;
2488 unsigned short v = 0;
2489 for (
int k = 0;
k < nsamp;
k++) {
2497 }
else if (frag1version == 1) {
2500 int SizeOfFrag1 =
size * 2;
2501 int nbchanformat2 = (SizeOfFrag1 - (3 * nbchanformat1)) / 5;
2503 int nchan = nbchanformat1 + nbchanformat2;
2508 const unsigned int *
p = frag->
data;
2510 if ((
nchan) > 48 || ((nbchanformat1 * 3) + (nbchanformat2 * 5) > SizeOfFrag1)) {
2511 std::cout <<
" Format Type 1: Raw compressed : ERROR" <<
" fragId=0x" << std::hex
2512 << (
id & 0xFFFF) << std::dec <<
" frag1Version=" << frag1version <<
" Nsamp=" << nsamp
2513 <<
" NchanFormat1=" << nbchanformat1 <<
" NchanFormat2=" << nbchanformat2
2514 <<
" Wrong Size=" <<
size << std::endl;
2528 for (
int chf1 = 0; chf1 < nbchanformat1; ++chf1) {
2535 word3 = (
uint16_t) ((*(
p + 1) >> 16) & 0xFFFF);
2539 rawcomp[
ch].
words[1] = (*
p + 1) & 0xFFFF0000;
2547 word2 = (
uint16_t) ((*(
p + 1) >> 16) & 0xFFFF);
2551 rawcomp[
ch].
words[0] = (*p) & 0xFFFF;
2561 rawcomp[
ch].
samples[0] = ((word3 >> 4) & 0xF) + Smin;
2562 rawcomp[
ch].
samples[1] = ((word3 >> 0) & 0xF) + Smin;
2563 rawcomp[
ch].
samples[2] = ((word3 >> 8) & 0xF) + Smin;
2564 rawcomp[
ch].
samples[3] = ((word3 >> 12) & 0xF) + Smin;
2565 rawcomp[
ch].
samples[4] = ((word2 >> 4) & 0xF) + Smin;
2566 rawcomp[
ch].
samples[5] = ((word2 >> 0) & 0xF) + Smin;
2567 rawcomp[
ch].
samples[6] = ((word2 >> 8) & 0xF) + Smin;
2573 p += 1 + ptr16index;
2577 for (
int chf2 = 0; chf2 < nbchanformat2; ++chf2) {
2584 word3 = (
uint16_t) ((*(
p + 1) >> 16) & 0xFFFF);
2586 word5 = (
uint16_t) ((*(
p + 2) >> 16) & 0xFFFF);
2591 rawcomp[
ch].
words[2] = (*
p + 2) & 0xFFFF0000;
2596 channel = ((*(
p + 1) >> 16) & 0x3F);
2598 word2 = (
uint16_t) ((*(
p + 1) >> 16) & 0xFFFF);
2600 word4 = (
uint16_t) ((*(
p + 2) >> 16) & 0xFFFF);
2604 rawcomp[
ch].
words[0] = (*p) & 0xFFFF;
2611 int gain = ((word2 >> 6) & 0
x1);
2613 rawcomp[
ch].
samples[0] = ((
word1 << 9) & 0x200) + ((word2 >> 7) & 0x1FF);
2615 rawcomp[
ch].
samples[2] = (word4 << 5 & 0x3E0) + ((
word1 >> 11) & 0x1F);
2616 rawcomp[
ch].
samples[3] = (word4 >> 5) & 0x3FF;
2617 rawcomp[
ch].
samples[4] = ((word3 << 1) & 0x3FE) + ((word4 >> 15) & 0
x1);
2618 rawcomp[
ch].
samples[5] = ((word5 << 7) & 0x380) + ((word3 >> 9) & 0x7F);
2619 rawcomp[
ch].
samples[6] = (word5 >> 3) & 0x3FF;
2625 p += (2 + ptr16index);
2640 ,
int*
ngain,
int* nchannel,
int* nsample) {
2643 static std::atomic<bool>
first =
true;
2644 int m,
c,
s,
size,
ch,
dm, dgm = 0, digim[5], digm[4] = { 0, 0, 0, 0 },
status = 0;
2645 int nchip, nchip2,
nchan, nchan2, nsamp, nsamp1, nsamp2, gain_offs;
2646 const unsigned int *
data;
2647 unsigned int val, headword, firstword, crcword;
2648 unsigned int hlflags,
word1, word2, word3, word4, word5;
2659 }
else if (
size > 272 &&
size < 405) {
2667 nsamp2 =
size/nchip;
2677 for (
m = 0;
m < nchip;
m++) {
2679 dgm = ((*data) >> 15) & 3;
2681 std::cout <<
"Good parity, chip" << std::setw(3) <<
m <<
", mode" << std::setw(2) << (
int) dgm <<
", head 0x" <<
setup0 <<
data[0] <<
", data 0x" << std::setw(8) <<
data[1] <<
setupDec << std::endl;
2684 if (((
data[0] >> 31) == 1) && ((
data[1] >> 31) == 0)) {
2692 if (
m == nchip &&
dm == 0) {
2694 for (
m = 0;
m < nchip;
m++) {
2695 dgm = ((*data) >> 15) & 3;
2697 std::cout <<
"Chip" << std::setw(3) <<
m <<
", mode" << std::setw(2) << (
int) dgm <<
", head 0x" <<
setup0 <<
data[0] <<
", data 0x" << std::setw(8) <<
data[1] <<
setupDec << std::endl;
2699 if (((
data[0] >> 31) == 1) && ((
data[1] >> 31) == 0)) {
2707 if (
m == nchip &&
dm == 0) {
2712 std::cout <<
"Warning: No valid header found, calibration running mode(=1) assumed" << std::endl;
2715 std::cout <<
"Warning: No valid header found, normal running mode(=0) assumed" << std::endl;
2719 std::cout <<
"Warning: No valid header found, keeping previous running mode(=" << (
int)
m_digi_mode <<
")" << std::endl;
2726 for (
c = 0;
c <
dm; ++
c) {
2729 for (
c = 0;
c < 4; ++
c) {
2739 std::cout <<
"\nMode=" <<
m_digi_mode <<
" found in header of chip " <<
m << std::endl;
2741 std::cout <<
"\nMode=" <<
m_digi_mode <<
" found in header of chip " <<
m <<
" with bad parity" << std::endl;
2744 std::cout <<
"\nCalibration mode selected, effective number of chips is twice bigger" << std::endl;
2757 if (nsamp2 % 2 == 0) {
2761 nsamp2 =
size / nchip;
2762 nsamp1 = nsamp2 - 1;
2764 gain_offs =
size / 2;
2770 nsamp1 = (nsamp2 - 1) / 2;
2775 nsamp1 = nsamp2 - 1;
2784 for (
m = 0;
m < nchip;
m++) {
2792 for (
s = nsamp;
s > 0;) {
2794 for (
c = 0;
c < 3;
c++) {
2795 samp[
c][
s] =
val & 0x3FF;
2801 firstword =
data[1];
2802 if (gain_offs > 0) {
2803 crcword =
data[nsamp1 + gain_offs];
2805 crcword =
data[nsamp1];
2807 hlflags = ((headword) >> 12) & 7;
2811 word4 = (word5 != 0) ? 32 : 0;
2817 word3 = (headword) & 0xFFF;
2818 word2 = (headword >> 12) & 0x3FFF;
2819 word1 = (headword >> 26) & 0xF;
2822 for (
c = 0;
c < 3;
c++) {
2824 if (
ch < nchannel_max) {
2834 channel[
ch].err = word4 | ((smax == 1023) ? 256 : 0)
2835 | ((smin == 0) ? 512 : 0);
2844 *
ngain = (gain_offs != 0) ? 2 : 1;
2879 unsigned int parity, data_word, answer = 0;
2883 data_word = *frame++;
2886 for (j = 0; j < 32; j++) {
2887 parity ^= data_word;
2891 if ((parity &= 1) == 0) answer |= 1 <<
i;
2923 unsigned int data_word, answer = 0;
2927 data_word = *frame++;
2929 if ((data_word >> 31) != startbit) {
2963 #define CRC_error_0 1
2964 #define CRC_error_1 2
2965 #define CRC_do_not_match 4
2967 #define CRC_POLY 0x8005
2970 unsigned int CRC_error =
CRC_ok;
2974 unsigned int *
data, word, CRC_word;
2975 unsigned short bit_in, bit_out, reg, reg1, reg2;
2980 length = 2 * framelen + 1;
2983 memcpy(
data, frame, framelen *
sizeof(
int));
2984 memcpy(
data + framelen, frame + delta, framelen *
sizeof(
int));
2985 CRC_word = frame[framelen + delta];
2987 memcpy(
data, frame + delta, framelen *
sizeof(
int));
2988 memcpy(
data + framelen, frame, framelen *
sizeof(
int));
2989 CRC_word = frame[framelen];
2994 memcpy(
data, frame, framelen *
sizeof(
int));
2995 CRC_word = frame[framelen];
3002 for (
i = 0;
i < 2;
i++) {
3005 for (j = 0; j <
length; j++) {
3008 for (
k =
i;
k < 32;
k += 2) {
3010 bit_in = (word >>
k) & 1;
3011 bit_out = reg & 0x8000;
3012 reg = ((reg << 1) | bit_in);
3021 for (
k = 16; reg != 0; reg >>= 1) {
3022 reg1 |= (reg & 1) << (--
k);
3028 for (
k =
i;
k < 32;
k += 2) {
3030 bit_in = (CRC_word >>
k) & 1;
3031 reg2 = ((reg2 << 1) | bit_in);
3034 if (reg1 != reg2) CRC_error |=
error[
i];
3063 unsigned short val, Min = 0xFFFF, Max = 0;
3065 for (
t = 0;
t < frame_length; ++
t) {
3082 std::vector<uint32_t>
data;
3086 while (
p < data_end) {
3089 data.push_back(*(
p));
3090 data.push_back(*(++
p));
3095 data.push_back((ntohs(
v >> 16) << 16) | (ntohs(
v & 0xFFFF)));