Execute decoding for an event.
some of this info should be used in the LatomeHeader class and for cross checks also (same as for the mon header)
not we have the packet size from the first packet, check all packet headers before decoding we can decide later if we drop decoding if we have inconsistency
OK all headers checked and we have all info we need to decode each packet, so lets start
for now just getting the ADCs from AT0 Change later to add energy as well and use the BC shift to determine at which BC there is energy
start of packet, bcid still unvalid / should increase by one but take care of rotation at s_nBunches;
the data is packed with 64 bits words. Will be padded with 0s at the end of the timeslot time slot.
lets fill now, using the older code structure but this should be change to support having energy.
432 {
433
434
436
437
438 const unsigned int sourceID = robFrag->rob_source_id();
439
440
441
442
443
444
445
446 m_l1ID = robFrag->rod_lvl1_id();
449 const unsigned int n = robFrag->rod_ndata();
450 if (0 == n) {
453 return;
454 }
456
458 const uint32_t* rod_status = robFrag->rod_status();
459 const unsigned int rod_nstatus = robFrag->rod_nstatus();
460 if (rod_nstatus != 27) {
461 ATH_MSG_WARNING(
"Inconsistent number of rod header status elements: nstatus= " << rod_nstatus);
462 return;
463 }
464 if (rod_nstatus > 8) {
472 }
473
474 }
477
478 LatomeCalibPatterns pat1, pat2, pat3;
479 pat1.DAC = rod_status[9];
480 pat1.delay = rod_status[10];
481 pat1.patterns.resize(4);
482 for (
unsigned int i = 0;
i < 4; ++
i)
483 pat1.patterns[i] = rod_status[i + 11];
484
485 pat2.DAC = rod_status[15];
486 pat2.delay = rod_status[16];
487 pat2.patterns.resize(4);
488 for (
unsigned int i = 0;
i < 4; ++
i)
489 pat2.patterns[i] = rod_status[i + 17];
490
491 pat3.DAC = rod_status[21];
492 pat3.delay = rod_status[22];
493 pat3.patterns.resize(4);
494 for (
unsigned int i = 0;
i < 4; ++
i)
495 pat3.patterns[i] = rod_status[i + 23];
496
498
499 const HWIdentifier hwidEmpty;
500
502
503
504
506 ATH_MSG_WARNING(
"Data corruption, offset found at pos 0 (" << offset <<
") is larger than the ROB fragment size (" <<
m_ROBFragSize <<
"). Ignoring data.");
507 return;
508 }
509
515 << " " << sourceID << std::dec);
516 return;
517 }
518 }
524 << " " << sourceID << std::dec);
525 return;
526 }
527 }
528
535 ATH_MSG_WARNING(
"Data corruption, offset found at pos 0 (" << offset <<
") is larger than the ROB fragment size (" <<
m_ROBFragSize <<
"). Ignoring data.");
536 return;
537 }
538
541 ATH_MSG_WARNING(
"Data corruption, offset found at pos 0 (" << offset <<
") is larger than the ROB fragment size (" <<
m_ROBFragSize <<
"). Ignoring data.");
542 return;
543 }
546 }
547
548 ATH_MSG_DEBUG(
" end of header check computed offset=" << std::dec << offset <<
" nwords in payload=" << n);
549
554 return;
555 }
556
559 return;
560 }
561
564 }
565
566
568 std::vector<unsigned int> bc_size;
571
572 short nBC = 0;
573 short nBC1 = 0;
574 short startBC1 = 0;
577
582 startBC1 = 0;
589 val.latomeChannel = 99999;
590 }
591 } else {
594 }
595
603 } else {
609 }
616 } else {
618 return;
619 }
620
621 switch (type0) {
625 break;
629 break;
633 break;
637 break;
639 break;
640 default:
642 return;
643 }
644
645 switch (type1) {
650 break;
655 break;
660 break;
665 break;
667 break;
668 default:
670 return;
671 }
672
684 }
685
686 val.latomeChannel = 99999;
687 }
688 }
689
691
694
695 for (short iBC = 0; iBC < nBC; ++iBC) {
699 if (iBC < startBC1 || iBC >= startBC1 + nBC1)
701 }
703
704 int nsc = 0;
705 unsigned int oldipacket = 0;
706 for (unsigned int itimeslot = 0; itimeslot < 6; ++itimeslot) {
707 unsigned int l_bcid = (bswap_32(p[s]))>>16;
708 if(itimeslot!=0){
709 if(l_bcid!=bcid){
711 }
712 }
713 else{
716 unsigned int bcid_c =
bcid+1;
719 bcid_c = 0;
720 }
721 if(bcid_c != l_bcid){
722 ATH_MSG_WARNING(
"ERROR: BCID not increasing properly between samples, sourceId: " <<
m_nthLATOME <<
" L1ID is: " <<
m_l1ID <<
", BCID is from payload: " << l_bcid <<
", expected BCID is: " << bcid_c <<
", LATOME channel is: " << nsc );
723 }
724 }
726 }
728
729 unsigned int mux = ((bswap_32(p[s])) >> 8) & 0xff;
733 if (s >= n)
734 break;
735
736 unsigned int timeslotsize = timeslot_nsc[itimeslot];
737 unsigned int nbytes = timeslotsize * nbytesPerChannel;
738 unsigned int n64word = nbytes / 8;
739 if (nbytes % 8)
740 ++n64word;
741 ATH_MSG_DEBUG(
" at BC " << iBC <<
" timeslot " << itimeslot <<
" " << bcid <<
" " << mux <<
" n64word " << n64word <<
" at0 " << (
int)at0 <<
" at1 "
742 << (int)at1 << " l_bcid " << bcid);
743
744 unsigned int wordshift =
s;
745 unsigned int byteshift = 0;
746
749 for (
unsigned int ichan = 0;
ichan < timeslotsize; ++
ichan) {
750 unsigned int at0Data = 0, at1Data = 0, satData = 0;
751 bool at0val = false, at1val = false;
752
753
755 break;
756
757 }
759 decodeChannel(wordshift, byteshift, p, at0, at1, at0Data, at1Data, satData, at0val, at1val);
760 ATH_MSG_DEBUG(
" wordshift " << wordshift <<
" byteshift " << byteshift <<
" at0data " << at0Data <<
" at1Data " << at1Data <<
" satData " << satData
761 << " at0val " << at0val << " at1val " << at1val << " nsc " << nsc);
762
765 if (SCID == hwidEmpty) {
767 }
768 int RAWValue0 = -999;
770 ATH_MSG_DEBUG(
"at0 bad quality bit for SC:" << nsc <<
" BC " << iBC <<
" latome " << robFrag->rod_source_id());
771 } else {
773 RAWValue0 = at0Data;
774 }
775 int defaultADCValue = -1;
776 int defaultEValue = -99999;
778 switch (at0) {
780 if ((unsigned)iBC < rawValuesInEvent.adc.size()) {
781 rawValuesInEvent.adc[iBC] = (at0val) ? RAWValue0 : defaultADCValue;
782 }
783 break;
785 if ((unsigned)iBC < rawValuesInEvent.adc_bas.size()) {
786 rawValuesInEvent.adc_bas[iBC] = (at0val) ? RAWValue0 : defaultADCValue;
787 }
788 break;
790 if ((unsigned)iBC < rawValuesInEvent.et.size()) {
791 rawValuesInEvent.et[iBC] = (at0val) ?
signEnergy(RAWValue0) : defaultEValue;
792 rawValuesInEvent.saturation[iBC] = satData;
793 }
794 break;
796 if ((unsigned)iBC < rawValuesInEvent.et_id.size()) {
797 rawValuesInEvent.et_id[iBC] = (at0val) ?
signEnergy(RAWValue0) : defaultEValue;
798 rawValuesInEvent.saturation[iBC] = satData;
799 }
800 break;
802 break;
803 default:
805 return;
806 }
807
808 int RAWValue1 = -999;
810 ATH_MSG_DEBUG(
"at1 bad quality bit for SC:" << nsc <<
" BC " << iBC <<
" latome " << robFrag->rod_source_id());
811 } else {
813 RAWValue1 = at1Data;
814 }
815
816 const size_t BCidx = iBC - startBC1;
817 switch (at1) {
819 if (BCidx < rawValuesInEvent.adc.size()) {
820 rawValuesInEvent.adc[BCidx] = (at1val) ? RAWValue1 : defaultADCValue;
821 }
822 break;
824 if (BCidx < rawValuesInEvent.adc_bas.size()) {
825 rawValuesInEvent.adc_bas[BCidx] = (at1val) ? RAWValue1 : defaultADCValue;
826 }
827 break;
829 if (BCidx < rawValuesInEvent.et.size()) {
830 rawValuesInEvent.et[BCidx] = (at1val) ?
signEnergy(RAWValue1) : defaultEValue;
831 rawValuesInEvent.saturation[BCidx] = satData;
832 }
833 break;
835 if (BCidx < rawValuesInEvent.et_id.size()) {
838 }
839 break;
841 break;
842 default:
844 return;
845 }
846
848
849 } else {
850 if (wordshift % 2) {
851 ATH_MSG_ERROR(
"inconsistant wordshift in decoding everaged data");
852 return;
853 }
854 unsigned int averageword = bswap_32(p[wordshift]);
855 wordshift += 1;
856 unsigned int sumSq = bswap_32(p[wordshift]);
857 wordshift += 1;
858 unsigned long long sumsqMSB = averageword >> 28;
859 sumsqMSB = sumsqMSB << 32;
860
865 }
866
867 ++nsc;
868
869 }
870
872 if(byteshift!=0){
874 byteshift=0;
875 }
876 ATH_MSG_DEBUG(
"wordshift before: " << wordshift <<
", s: " << s);
877 if ((wordshift - s) % 2)
879 ATH_MSG_DEBUG(
"wordshift after : " << wordshift <<
", s: " << s);
882 <<
"!=" << n64word * 2 <<
" m_ipacket " <<
m_iPacket);
883 }
886 }
887
888 }
889
892 } else {
893 if (onoffmap && clmap) {
895 } else {
897 }
898 }
900}
int signEnergy(unsigned int energy)
void decodeChannel(unsigned int &wordshift, unsigned int &byteshift, const uint32_t *p, MonDataType at0, MonDataType at1, unsigned int &at0Data, unsigned int &at1Data, unsigned int &satData, bool &at0val, bool &at1val)
void fillCalib(const LArLATOMEMapping *map, const LArOnOffIdMapping *onoffmap, const LArCalibLineMapping *clmap)
void fillRaw(const LArLATOMEMapping *map)
Pass ADC values from an event.
unsigned int decodeHeader(const uint32_t *p, unsigned int offset)
std::vector< unsigned short > m_BCIDsInEvent
void increaseWordShift(unsigned int &wordshift)
std::vector< Word > m_packetEnd
unsigned int decodeTrailer(const uint32_t *p, unsigned int offset)
static const int s_nBunches
Maximum value of BCID.
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
setEventNumber setTimeStamp bcid