469 std::ios oldState(
nullptr);
470 oldState.copyfmt(std::cout);
472 std::cout <<
"RCE Fragment: all numbers in hex " <<
std::hex 473 <<
" SequenceID = " << frag.sequenceID()
474 <<
" fragmentID = " << frag.fragmentID()
475 <<
" fragmentType = " << (unsigned)frag.type()
476 <<
" Timestamp = " << frag.timestamp() <<
std::endl;
477 std::cout <<
"Offset Data";
478 artdaq::Fragment fragloc(frag);
479 unsigned char *dbegin =
reinterpret_cast<unsigned char *
>(fragloc.dataAddress());
480 size_t dsize = fragloc.dataSizeBytes();
482 for (
size_t bcounter=0; bcounter<dsize;++bcounter)
484 if ( (offcounter % 8) == 0 )
493 std::cout.copyfmt(oldState);
498 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
" RCE fragment type " << (
int) frag.type() <<
" doesn't match expected value: " <<
_rce_fragment_type <<
" Discarding RCE fragment";
509 artdaq::Fragment cfragloc(frag);
510 size_t cdsize = cfragloc.dataSizeBytes();
511 const uint64_t* cdptr = (uint64_t
const*) (cfragloc.dataBeginBytes() + 12);
512 HeaderFragmentUnpack
const cdheader(cdptr);
514 if (cdsize>16) cdsize -= 16;
515 bool isOkay = RceFragmentUnpack::isOkay(cdptr,cdsize);
518 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"RCE Fragment isOkay failed: " << cdsize <<
" Discarding this fragment";
523 DataFragmentUnpack df(cdptr);
529 TString outfilename=
"rce";
530 outfilename += frag.sequenceID();
532 outfilename += frag.fragmentID();
533 outfilename+=
".fragment";
534 rce.save(outfilename.Data());
535 std::cout <<
"Saved an RCE fragment with " << rce.size() <<
" streams: " << outfilename <<
std::endl;
538 uint32_t ch_counter = 0;
539 for (
int i = 0; i < rce.size(); ++i)
541 auto const * rce_stream = rce.get_stream(i);
542 size_t n_ch = rce_stream->getNChannels();
543 size_t n_ticks = rce_stream->getNTicks();
544 auto const identifier = rce_stream->getIdentifier();
545 uint32_t crateNumber = identifier.getCrate();
546 uint32_t slotNumber = identifier.getSlot();
547 uint32_t fiberNumber = identifier.getFiber();
551 if (crateNumber == 0 || crateNumber > 6 || slotNumber > 4 || fiberNumber == 0 || fiberNumber > 4)
555 MF_LOG_WARNING(
"_process_RCE:") <<
"Bad crate, slot, fiber number, discarding fragment on request: " 556 << crateNumber <<
" " << slotNumber <<
" " << fiberNumber;
566 if (runNumber > 2572)
568 auto oldfiber = fiberNumber;
569 auto oldslot = slotNumber;
571 if (oldslot == 0 && oldfiber == 4)
576 if (oldslot == 1 && oldfiber == 4)
581 if (oldslot == 1 && oldfiber == 3)
586 if (oldslot == 0 && oldfiber == 3)
595 if (runNumber > 1530 && runNumber < 2572)
597 auto oldfiber = fiberNumber;
598 auto oldslot = slotNumber;
602 if (oldslot == 2 && oldfiber == 1)
607 if (oldslot == 1 && oldfiber == 1)
612 if (oldslot == 2 && oldfiber == 3)
617 if (oldslot == 1 && oldfiber == 3)
623 oldfiber = fiberNumber;
624 oldslot = slotNumber;
626 if (oldslot == 0 && oldfiber == 4)
631 if (oldslot == 1 && oldfiber == 4)
636 if (oldslot == 0 && oldfiber == 3)
641 if (oldslot == 1 && oldfiber == 3)
650 if ( slotNumber == 1 && fiberNumber == 1 )
655 if ( slotNumber == 2 && fiberNumber == 1 )
664 std::cout <<
"Printing coldata convert counts for slot: " << slotNumber <<
" fiber: " << fiberNumber <<
std::endl;
669 TpcStream
const &
stream = rce_stream->getStream ();
670 TpcToc toc (stream.getToc ());
671 TpcPacket pktRec (stream.getPacket ());
672 TpcPacketBody pktBdy (pktRec.getRecord ());
673 int npkts = toc.getNPacketDscs ();
674 for (
int ipkt = 0; ipkt < npkts; ++ipkt)
676 TpcTocPacketDsc pktDsc (toc.getPacketDsc (ipkt));
677 unsigned int o64 = pktDsc.getOffset64 ();
678 unsigned int pktType = pktDsc.getType ();
679 unsigned nWibFrames = pktDsc.getNWibFrames ();
680 WibFrame
const *wf = pktBdy.getWibFrames (pktType, o64);
681 for (
unsigned iwf = 0; iwf < nWibFrames; ++iwf)
683 auto const &colddata = wf->getColdData ();
684 auto cvt0 = colddata[0].getConvertCount ();
686 int diff = (
int) cvt0 - (
int) iwf;
687 std::cout <<
"Packet: " << ipkt <<
" WIB frame: " << iwf <<
" RCE coldata convert count: " << cvt0 <<
" Difference: " << diff <<
std::endl;
707 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"Nticks not the required value: " << n_ticks <<
" " 729 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"Nticks different for two channel streams: " << n_ticks
748 size_t buffer_size = n_ch * n_ticks;
754 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"n_ch*nticks too large: " << n_ch <<
" * " << n_ticks <<
" = " <<
765 if (
_buffer.capacity() < buffer_size)
774 int16_t* adcs =
_buffer.data();
775 bool sgmcdretcode = rce_stream->getMultiChannelData(adcs);
780 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"getMutliChannelData returns error flag: " 781 <<
" c:s:f:ich: " << crateNumber <<
" " << slotNumber <<
" " << fiberNumber <<
" Discarding Data";
793 for (
size_t i_ch = 0; i_ch < n_ch; i_ch++)
800 for (
size_t i_tick = 0; i_tick < n_ticks; i_tick++)
802 v_adc.push_back(adcs[i_tick]);
819 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"Duplicate Channel: " << offlineChannel
820 <<
" c:s:f:ich: " << crateNumber <<
" " << slotNumber <<
" " << fiberNumber <<
" " << i_ch <<
" Discarding Data";
837 auto uncompressed_nticks = v_adc.size();
846 raw::RawDigit raw_digit(offlineChannel, uncompressed_nticks, v_adc, cflag);
847 raw_digit.SetPedestal(median,sigma);
848 raw_digits.push_back(raw_digit);
851 timestamps.push_back(rdtimestamp);
854 auto const rawdigitptr = rdpm(raw_digits.size()-1);
855 auto const rdtimestampptr = tspm(timestamps.size()-1);
856 tsassocs.addSingle(rawdigitptr,rdtimestampptr);
unsigned int duplicate_channels
bool _DiscardedCorruptData
bool _rce_drop_frags_with_badcsf
enum raw::_compress Compress_t
bool _duplicate_channel_checklist[15360]
Collection of charge vs time digitized from a single readout channel.
size_t _rce_buffer_size_checklimit
bool _enforce_no_duplicate_channels
bool _enforce_full_tick_count
bool _rce_save_frags_to_files
void computeMedianSigma(raw::RawDigit::ADCvector_t &v_adc, float &median, float &sigma)
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
QTextStream & hex(QTextStream &s)
bool _print_coldata_convert_count
const unsigned int _duplicate_channel_checklist_size
unsigned int _tick_count_this_event
unsigned int _full_tick_count
unsigned int GetOfflineNumberFromDetectorElements(unsigned int crate, unsigned int slot, unsigned int fiber, unsigned int fembchannel, FelixOrRCE frswitch)
bool _enforce_same_tick_count
Q_EXPORT QTSManip setw(int w)
bool _initialized_tick_count_this_event
unsigned int incorrect_ticks
void Compress(std::vector< short > &adc, raw::Compress_t compress)
Compresses a raw data buffer.
#define MF_LOG_WARNING(category)
std::vector< int16_t > _buffer
Q_EXPORT QTSManip setfill(int f)
bool _rce_check_buffer_size
double median(sqlite3 *db, std::string const &table_name, std::string const &column_name)
QTextStream & endl(QTextStream &s)
unsigned int error_counter