659 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
" RCE fragment type " << (
int) frag.type() <<
" doesn't match expected value: " <<
_rce_fragment_type <<
" Discarding RCE fragment";
671 artdaq::Fragment cfragloc(frag);
672 size_t cdsize = cfragloc.dataSizeBytes();
673 const uint64_t* cdptr = (uint64_t
const*) (cfragloc.dataBeginBytes() + 12);
674 HeaderFragmentUnpack
const cdheader(cdptr);
676 if (cdsize>16) cdsize -= 16;
677 bool isOkay = RceFragmentUnpack::isOkay(cdptr,cdsize);
680 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"RCE Fragment isOkay failed: " << cdsize <<
" Discarding this fragment";
690 uint32_t ch_counter = 0;
691 for (
int i = 0; i < rce.size(); ++i)
693 auto const * rce_stream = rce.get_stream(i);
694 size_t n_ch = rce_stream->getNChannels();
695 size_t n_ticks = rce_stream->getNTicks();
696 if (n_ticks == 0)
continue;
697 auto const identifier = rce_stream->getIdentifier();
698 uint32_t crateNumber = identifier.getCrate();
699 uint32_t slotNumber = identifier.getSlot();
700 uint32_t fiberNumber = identifier.getFiber();
705 bool apafound =
true;
709 for (
unsigned int j=0; j<adsiz; ++j)
731 MF_LOG_WARNING(
"_process_RCE:") <<
"Bad crate number, discarding fragment on request: " 732 << (
int) crateNumber;
736 if (slotNumber > 4 || fiberNumber == 0 || fiberNumber > 4)
740 MF_LOG_WARNING(
"_process_RCE:") <<
"Bad slot, fiber number, discarding fragment on request: " 741 <<
" " << slotNumber <<
" " << fiberNumber;
754 TpcStream
const &
stream = rce_stream->getStream ();
755 TpcToc toc (stream.getToc ());
756 TpcPacket pktRec (stream.getPacket ());
757 TpcPacketBody pktBdy (pktRec.getRecord ());
758 int npkts = toc.getNPacketDscs ();
759 for (
int ipkt = 0; ipkt < npkts; ++ipkt)
761 TpcTocPacketDsc pktDsc (toc.getPacketDsc (ipkt));
762 unsigned int o64 = pktDsc.getOffset64 ();
763 unsigned int pktType = pktDsc.getType ();
764 unsigned nWibFrames = pktDsc.getNWibFrames ();
765 WibFrame
const *wf = pktBdy.getWibFrames (pktType, o64);
766 for (
unsigned iwf = 0; iwf < nWibFrames; ++iwf)
768 auto const &colddata = wf->getColdData ();
769 auto cvt0 = colddata[0].getConvertCount ();
771 std::cout <<
"RCE coldata convert count: " << cvt0 <<
std::endl;
788 size_t ntc10 = ( 0.9 * (
float) ntickscheck );
790 n_ticks == ntickscheck ||
792 (crateNumber == 3 && slotNumber == 3 && fiberNumber == 2) &&
793 n_ticks < ntickscheck && n_ticks > ntc10)
797 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"Nticks differs from median or FEMB302 nticks not expected: " << n_ticks <<
" " 798 << ntickscheck <<
" Discarding this fragment";
807 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"Nticks not the required value: " << n_ticks <<
" " 829 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"Nticks different for two channel streams: " << n_ticks
848 size_t buffer_size = n_ch * n_ticks;
854 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"n_ch*nticks too large: " << n_ch <<
" * " << n_ticks <<
" = " <<
865 if (
_buffer.capacity() < buffer_size)
874 int16_t* adcs =
_buffer.data();
875 bool sgmcdretcode = rce_stream->getMultiChannelData(adcs);
880 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"getMutliChannelData returns error flag: " 881 <<
" c:s:f:ich: " << crateNumber <<
" " << slotNumber <<
" " << fiberNumber <<
" Discarding Data";
892 unsigned int crateloc = crateNumber;
896 for (
size_t i_ch = 0; i_ch < n_ch; i_ch++)
911 v_adc.push_back(adcs[i_tick+_rce_fix110_nticks]);
915 v_adc.push_back(v_adc.back());
921 for (
size_t i_tick = 0; i_tick < n_ticks; i_tick++)
923 v_adc.push_back(adcs[i_tick]);
941 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"Duplicate Channel: " << offlineChannel
942 <<
" c:s:f:ich: " << crateNumber <<
" " << slotNumber <<
" " << fiberNumber <<
" " << i_ch <<
" Discarding Data";
959 auto uncompressed_nticks = v_adc.size();
968 raw::RawDigit raw_digit(offlineChannel, uncompressed_nticks, v_adc, cflag);
969 raw_digit.SetPedestal(median,sigma);
970 raw_digits.push_back(raw_digit);
973 timestamps.push_back(rdtimestamp);
976 auto const rawdigitptr = rdpm(raw_digits.size()-1);
977 auto const rdtimestampptr = tspm(timestamps.size()-1);
978 tsassocs.addSingle(rawdigitptr,rdtimestampptr);
long int _max_offline_channel
enum raw::_compress Compress_t
Collection of charge vs time digitized from a single readout channel.
unsigned int _full_tick_count
bool _duplicate_channel_checklist[15360]
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
unsigned int _default_crate_if_unexpected
bool _print_coldata_convert_count
unsigned int _tick_count_this_event
unsigned int duplicate_channels
size_t _rce_buffer_size_checklimit
unsigned int GetOfflineNumberFromDetectorElements(unsigned int crate, unsigned int slot, unsigned int fiber, unsigned int fembchannel, FelixOrRCE frswitch)
bool _initialized_tick_count_this_event
std::vector< int16_t > _buffer
unsigned int _rce_fix110_nticks
unsigned int incorrect_ticks
void computeMedianSigma(raw::RawDigit::ADCvector_t &v_adc, float &median, float &sigma)
long int _min_offline_channel
std::vector< int > _apas_to_decode
bool _enforce_full_tick_count
bool _enforce_no_duplicate_channels
bool _rce_check_buffer_size
bool _rce_drop_frags_with_badsf
bool _DiscardedCorruptData
unsigned int error_counter
bool _enforce_same_tick_count
void Compress(std::vector< short > &adc, raw::Compress_t compress)
Compresses a raw data buffer.
#define MF_LOG_WARNING(category)
bool _rce_drop_frags_with_badc
bool _rce_enforce_fragment_type_match
const unsigned int _duplicate_channel_checklist_size
unsigned int ChipFromOfflineChannel(unsigned int offlineChannel) const
Returns chip number.
double median(sqlite3 *db, std::string const &table_name, std::string const &column_name)
QTextStream & endl(QTextStream &s)