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.
447 {
449 const unsigned int sourceID = robFrag->rob_source_id();
450 m_l1ID = robFrag->rod_lvl1_id();
453 const unsigned int n = robFrag->rod_ndata();
454 if (0 == n) {
457 return;
458 }
460
462 const uint32_t* rod_status = robFrag->rod_status();
463 const unsigned int rod_nstatus = robFrag->rod_nstatus();
464 if (rod_nstatus != 27) {
465 ATH_MSG_WARNING(
"Inconsistent number of rod header status elements: nstatus= " << rod_nstatus);
466 return;
467 }
468 if (rod_nstatus > 8) {
476 }
477
478 }
481
482 LatomeCalibPatterns pat1, pat2, pat3;
483 pat1.DAC = rod_status[9];
484 pat1.delay = rod_status[10];
485 pat1.patterns.resize(4);
486 for (
unsigned int i = 0;
i < 4; ++
i)
487 pat1.patterns[i] = rod_status[i + 11];
488
489 pat2.DAC = rod_status[15];
490 pat2.delay = rod_status[16];
491 pat2.patterns.resize(4);
492 for (
unsigned int i = 0;
i < 4; ++
i)
493 pat2.patterns[i] = rod_status[i + 17];
494
495 pat3.DAC = rod_status[21];
496 pat3.delay = rod_status[22];
497 pat3.patterns.resize(4);
498 for (
unsigned int i = 0;
i < 4; ++
i)
499 pat3.patterns[i] = rod_status[i + 23];
500
502
503 const HWIdentifier hwidEmpty;
504
506
507
508
510 ATH_MSG_WARNING(
"Data corruption, offset found at pos 0 (" << offset <<
") is larger than the ROB fragment size (" <<
m_ROBFragSize <<
"). Ignoring data.");
511 return;
512 }
513
519 << " " << sourceID << std::dec);
520 return;
521 }
522 }
528 << " " << sourceID << std::dec);
529 return;
530 }
531 }
532
539 ATH_MSG_WARNING(
"Data corruption, offset found at pos 0 (" << offset <<
") is larger than the ROB fragment size (" <<
m_ROBFragSize <<
"). Ignoring data.");
540 return;
541 }
542
545 ATH_MSG_WARNING(
"Data corruption, offset found at pos 0 (" << offset <<
") is larger than the ROB fragment size (" <<
m_ROBFragSize <<
"). Ignoring data.");
546 return;
547 }
550 }
551
552 ATH_MSG_DEBUG(
" end of header check computed offset=" << std::dec << offset <<
" nwords in payload=" << n);
553
558 return;
559 }
560
563 return;
564 }
565
568 }
569
570
572 std::vector<unsigned int> bc_size;
575
576 short nBC = 0;
577 short nBC1 = 0;
578 short startBC1 = 0;
581
586 startBC1 = 0;
593 val.latomeChannel = 99999;
594 }
595 } else {
598 }
599
607 } else {
613 }
620 } else {
622 return;
623 }
624
625 switch (type0) {
629 break;
633 break;
637 break;
641 break;
643 break;
644 default:
646 return;
647 }
648
649 switch (type1) {
654 break;
659 break;
664 break;
669 break;
671 break;
672 default:
674 return;
675 }
676
688 }
689
690 val.latomeChannel = 99999;
691 }
692 }
693
695
698
699 for (short iBC = 0; iBC < nBC; ++iBC) {
703 if (iBC < startBC1 || iBC >= startBC1 + nBC1)
705 }
707
708 int nsc = 0;
709 unsigned int oldipacket = 0;
710 for (unsigned int itimeslot = 0; itimeslot < 6; ++itimeslot) {
711 unsigned int l_bcid = (bswap_32(p[s]))>>16;
712 if(itimeslot!=0){
713 if(l_bcid!=bcid){
715 }
716 }
717 else{
720 unsigned int bcid_c =
bcid+1;
723 bcid_c = 0;
724 }
725 if(bcid_c != l_bcid){
726 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 );
727 }
728 }
730 }
732
733 unsigned int mux = ((bswap_32(p[s])) >> 8) & 0xff;
737 if (s >= n)
738 break;
739
740 unsigned int timeslotsize = timeslot_nsc[itimeslot];
741 unsigned int nbytes = timeslotsize * nbytesPerChannel;
742 unsigned int n64word = nbytes / 8;
743 if (nbytes % 8)
744 ++n64word;
745 ATH_MSG_DEBUG(
" at BC " << iBC <<
" timeslot " << itimeslot <<
" " << bcid <<
" " << mux <<
" n64word " << n64word <<
" at0 " << (
int)at0 <<
" at1 "
746 << (int)at1 << " l_bcid " << bcid);
747
748 unsigned int wordshift =
s;
749 unsigned int byteshift = 0;
750
753 for (
unsigned int ichan = 0;
ichan < timeslotsize; ++
ichan) {
754 unsigned int at0Data = 0, at1Data = 0, satData = 0;
755 bool at0val = false, at1val = false;
756
757
759 break;
760
761 }
763 decodeChannel(wordshift, byteshift, p, at0, at1, at0Data, at1Data, satData, at0val, at1val);
764 ATH_MSG_DEBUG(
" wordshift " << wordshift <<
" byteshift " << byteshift <<
" at0data " << at0Data <<
" at1Data " << at1Data <<
" satData " << satData
765 << " at0val " << at0val << " at1val " << at1val << " nsc " << nsc);
766
769 if (SCID == hwidEmpty) {
771 }
772 int RAWValue0 = -999;
774 ATH_MSG_DEBUG(
"at0 bad quality bit for SC:" << nsc <<
" BC " << iBC <<
" latome " << robFrag->rod_source_id());
775 } else {
777 RAWValue0 = at0Data;
778 }
779 int defaultADCValue = -1;
780 int defaultEValue = -99999;
782 switch (at0) {
784 if ((unsigned)iBC < rawValuesInEvent.adc.size()) {
785 rawValuesInEvent.adc[iBC] = (at0val) ? RAWValue0 : defaultADCValue;
786 }
787 break;
789 if ((unsigned)iBC < rawValuesInEvent.adc_bas.size()) {
790 rawValuesInEvent.adc_bas[iBC] = (at0val) ? RAWValue0 : defaultADCValue;
791 }
792 break;
794 if ((unsigned)iBC < rawValuesInEvent.et.size()) {
795 rawValuesInEvent.et[iBC] = (at0val) ?
signEnergy(RAWValue0) : defaultEValue;
796 rawValuesInEvent.saturation[iBC] = satData;
797 }
798 break;
800 if ((unsigned)iBC < rawValuesInEvent.et_id.size()) {
801 rawValuesInEvent.et_id[iBC] = (at0val) ?
signEnergy(RAWValue0) : defaultEValue;
802 rawValuesInEvent.saturation[iBC] = satData;
803 }
804 break;
806 break;
807 default:
809 return;
810 }
811
812 int RAWValue1 = -999;
814 ATH_MSG_DEBUG(
"at1 bad quality bit for SC:" << nsc <<
" BC " << iBC <<
" latome " << robFrag->rod_source_id());
815 } else {
817 RAWValue1 = at1Data;
818 }
819
820 const size_t BCidx = iBC - startBC1;
821 switch (at1) {
823 if (BCidx < rawValuesInEvent.adc.size()) {
824 rawValuesInEvent.adc[BCidx] = (at1val) ? RAWValue1 : defaultADCValue;
825 }
826 break;
828 if (BCidx < rawValuesInEvent.adc_bas.size()) {
829 rawValuesInEvent.adc_bas[BCidx] = (at1val) ? RAWValue1 : defaultADCValue;
830 }
831 break;
833 if (BCidx < rawValuesInEvent.et.size()) {
834 rawValuesInEvent.et[BCidx] = (at1val) ?
signEnergy(RAWValue1) : defaultEValue;
835 rawValuesInEvent.saturation[BCidx] = satData;
836 }
837 break;
839 if (BCidx < rawValuesInEvent.et_id.size()) {
842 }
843 break;
845 break;
846 default:
848 return;
849 }
850
852
853 } else {
854 if (wordshift % 2) {
855 ATH_MSG_ERROR(
"inconsistant wordshift in decoding everaged data");
856 return;
857 }
858 unsigned int averageword = bswap_32(p[wordshift]);
859 wordshift += 1;
860 unsigned int sumSq = bswap_32(p[wordshift]);
861 wordshift += 1;
862 unsigned long long sumsqMSB = averageword >> 28;
863 sumsqMSB = sumsqMSB << 32;
864
869 }
870
871 ++nsc;
872
873 }
874
876 if(byteshift!=0){
878 byteshift=0;
879 }
880 ATH_MSG_DEBUG(
"wordshift before: " << wordshift <<
", s: " << s);
881 if ((wordshift - s) % 2)
883 ATH_MSG_DEBUG(
"wordshift after : " << wordshift <<
", s: " << s);
886 <<
"!=" << n64word * 2 <<
" m_ipacket " <<
m_iPacket);
887 }
890 }
891
892 }
893
896 } else {
897 if (onoffmap && clmap) {
899 } else {
901 }
902 }
904}
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