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.
430 {
431
432
434
435
436 const unsigned int sourceID = robFrag->rob_source_id();
437
438
439
440
441
442
443
444 m_l1ID = robFrag->rod_lvl1_id();
447 const unsigned int n = robFrag->rod_ndata();
448 if (0 == n) {
451 return;
452 }
454 const uint32_t* rod_status = robFrag->rod_status();
455 const unsigned int rod_nstatus = robFrag->rod_nstatus();
456 if (rod_nstatus != 27) {
457 ATH_MSG_WARNING(
"Inconsistent number of rod header status elements: nstatus= " << rod_nstatus);
458 return;
459 }
460 if (rod_nstatus > 8) {
464 }
467
468 LatomeCalibPatterns pat1, pat2, pat3;
469 pat1.DAC = rod_status[9];
470 pat1.delay = rod_status[10];
471 pat1.patterns.resize(4);
472 for (
unsigned int i = 0;
i < 4; ++
i)
473 pat1.patterns[i] = rod_status[i + 11];
474
475 pat2.DAC = rod_status[15];
476 pat2.delay = rod_status[16];
477 pat2.patterns.resize(4);
478 for (
unsigned int i = 0;
i < 4; ++
i)
479 pat2.patterns[i] = rod_status[i + 17];
480
481 pat3.DAC = rod_status[21];
482 pat3.delay = rod_status[22];
483 pat3.patterns.resize(4);
484 for (
unsigned int i = 0;
i < 4; ++
i)
485 pat3.patterns[i] = rod_status[i + 23];
486
488
489 const HWIdentifier hwidEmpty;
490
492
495 ATH_MSG_WARNING(
"Data corruption, offset found at pos 0 (" << offset <<
") is larger than the ROB fragment size (" <<
m_ROBFragSize <<
"). Ignoring data.");
496 return;
497 }
498
504 << " " << sourceID << std::dec);
505 return;
506 }
507 }
513 << " " << sourceID << std::dec);
514 return;
515 }
516 }
517
524 ATH_MSG_WARNING(
"Data corruption, offset found at pos 0 (" << offset <<
") is larger than the ROB fragment size (" <<
m_ROBFragSize <<
"). Ignoring data.");
525 return;
526 }
529 ATH_MSG_WARNING(
"Data corruption, offset found at pos 0 (" << offset <<
") is larger than the ROB fragment size (" <<
m_ROBFragSize <<
"). Ignoring data.");
530 return;
531 }
534 }
535
536 ATH_MSG_DEBUG(
" end of header check computed offset=" << std::dec << offset <<
" nwords in payload=" << n);
537
542 return;
543 }
544
547 return;
548 }
549
552 }
553
555 std::vector<unsigned int> bc_size;
558
559 short nBC = 0;
560 short nBC1 = 0;
561 short startBC1 = 0;
564
569 startBC1 = 0;
576 val.latomeChannel = 99999;
577 }
578 } else {
581 }
582
590 } else {
596 }
603 } else {
605 return;
606 }
607
608 switch (type0) {
612 break;
616 break;
620 break;
624 break;
626 break;
627 default:
629 return;
630 }
631
632 switch (type1) {
637 break;
642 break;
647 break;
652 break;
654 break;
655 default:
657 return;
658 }
659
671 }
672
673 val.latomeChannel = 99999;
674 }
675 }
676
678
681
682 for (short iBC = 0; iBC < nBC; ++iBC) {
686 if (iBC < startBC1 || iBC >= startBC1 + nBC1)
688 }
690
691 int nsc = 0;
692 unsigned int oldipacket = 0;
693 for (unsigned int itimeslot = 0; itimeslot < 6; ++itimeslot) {
694 unsigned int l_bcid = (bswap_32(p[s]))>>16;
695 if(itimeslot!=0){
696 if(l_bcid!=bcid){
698 }
699 }
700 else{
703 unsigned int bcid_c =
bcid+1;
706 bcid_c = 0;
707 }
708 if(bcid_c != l_bcid){
709 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 );
710 }
711 }
713 }
715
716 unsigned int mux = ((bswap_32(p[s])) >> 8) & 0xff;
720 if (s >= n)
721 break;
722
723 unsigned int timeslotsize = timeslot_nsc[itimeslot];
724 unsigned int nbytes = timeslotsize * nbytesPerChannel;
725 unsigned int n64word = nbytes / 8;
726 if (nbytes % 8)
727 ++n64word;
728 ATH_MSG_DEBUG(
" at BC " << iBC <<
" timeslot " << itimeslot <<
" " << bcid <<
" " << mux <<
" n64word " << n64word <<
" at0 " << (
int)at0 <<
" at1 "
729 << (int)at1 << " l_bcid " << bcid);
730
731 unsigned int wordshift =
s;
732 unsigned int byteshift = 0;
733
736 for (
unsigned int ichan = 0;
ichan < timeslotsize; ++
ichan) {
737 unsigned int at0Data = 0, at1Data = 0, satData = 0;
738 bool at0val = false, at1val = false;
739
740
742 break;
743
744 }
746 decodeChannel(wordshift, byteshift, p, at0, at1, at0Data, at1Data, satData, at0val, at1val);
747 ATH_MSG_DEBUG(
" wordshift " << wordshift <<
" byteshift " << byteshift <<
" at0data " << at0Data <<
" at1Data " << at1Data <<
" satData " << satData
748 << " at0val " << at0val << " at1val " << at1val << " nsc " << nsc);
749
752 if (SCID == hwidEmpty) {
754 }
755 int RAWValue0 = -999;
757 ATH_MSG_DEBUG(
"at0 bad quality bit for SC:" << nsc <<
" BC " << iBC <<
" latome " << robFrag->rod_source_id());
758 } else {
760 RAWValue0 = at0Data;
761 }
762 int defaultADCValue = -1;
763 int defaultEValue = -99999;
765 switch (at0) {
767 if ((unsigned)iBC < rawValuesInEvent.adc.size()) {
768 rawValuesInEvent.adc[iBC] = (at0val) ? RAWValue0 : defaultADCValue;
769 }
770 break;
772 if ((unsigned)iBC < rawValuesInEvent.adc_bas.size()) {
773 rawValuesInEvent.adc_bas[iBC] = (at0val) ? RAWValue0 : defaultADCValue;
774 }
775 break;
777 if ((unsigned)iBC < rawValuesInEvent.et.size()) {
778 rawValuesInEvent.et[iBC] = (at0val) ?
signEnergy(RAWValue0) : defaultEValue;
779 rawValuesInEvent.saturation[iBC] = satData;
780 }
781 break;
783 if ((unsigned)iBC < rawValuesInEvent.et_id.size()) {
784 rawValuesInEvent.et_id[iBC] = (at0val) ?
signEnergy(RAWValue0) : defaultEValue;
785 rawValuesInEvent.saturation[iBC] = satData;
786 }
787 break;
789 break;
790 default:
792 return;
793 }
794
795 int RAWValue1 = -999;
797 ATH_MSG_DEBUG(
"at1 bad quality bit for SC:" << nsc <<
" BC " << iBC <<
" latome " << robFrag->rod_source_id());
798 } else {
800 RAWValue1 = at1Data;
801 }
802
803 const size_t BCidx = iBC - startBC1;
804 switch (at1) {
806 if (BCidx < rawValuesInEvent.adc.size()) {
807 rawValuesInEvent.adc[BCidx] = (at1val) ? RAWValue1 : defaultADCValue;
808 }
809 break;
811 if (BCidx < rawValuesInEvent.adc_bas.size()) {
812 rawValuesInEvent.adc_bas[BCidx] = (at1val) ? RAWValue1 : defaultADCValue;
813 }
814 break;
816 if (BCidx < rawValuesInEvent.et.size()) {
817 rawValuesInEvent.et[BCidx] = (at1val) ?
signEnergy(RAWValue1) : defaultEValue;
818 rawValuesInEvent.saturation[BCidx] = satData;
819 }
820 break;
822 if (BCidx < rawValuesInEvent.et_id.size()) {
825 }
826 break;
828 break;
829 default:
831 return;
832 }
833
835
836 } else {
837 if (wordshift % 2) {
838 ATH_MSG_ERROR(
"inconsistant wordshift in decoding everaged data");
839 return;
840 }
841 unsigned int averageword = bswap_32(p[wordshift]);
842 wordshift += 1;
843 unsigned int sumSq = bswap_32(p[wordshift]);
844 wordshift += 1;
845 unsigned long long sumsqMSB = averageword >> 28;
846 sumsqMSB = sumsqMSB << 32;
847
852 }
853
854 ++nsc;
855
856 }
857
859 if(byteshift!=0){
861 byteshift=0;
862 }
863 ATH_MSG_DEBUG(
"wordshift before: " << wordshift <<
", s: " << s);
864 if ((wordshift - s) % 2)
866 ATH_MSG_DEBUG(
"wordshift after : " << wordshift <<
", s: " << s);
869 <<
"!=" << n64word * 2 <<
" m_ipacket " <<
m_iPacket);
870 }
873 }
874
875 }
876
879 } else {
880 if (onoffmap && clmap) {
882 } else {
884 }
885 }
887}
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.
setEventNumber setTimeStamp bcid