343 std::ios oldState(
nullptr);
344 oldState.copyfmt(std::cout);
346 std::cout <<
"RCE Fragment: all numbers in hex " <<
std::hex 347 <<
" SequenceID = " << frag.sequenceID()
348 <<
" fragmentID = " << frag.fragmentID()
349 <<
" fragmentType = " << (unsigned)frag.type()
350 <<
" Timestamp = " << frag.timestamp() <<
std::endl;
351 std::cout <<
"Offset Data";
352 artdaq::Fragment fragloc(frag);
353 unsigned char *dbegin =
reinterpret_cast<unsigned char *
>(fragloc.dataAddress());
354 size_t dsize = fragloc.dataSizeBytes();
356 for (
size_t bcounter=0; bcounter<dsize;++bcounter)
358 if ( (offcounter % 8) == 0 )
367 std::cout.copyfmt(oldState);
380 TString outfilename=
"rce_";
381 outfilename += evt.
run();
383 outfilename += frag.sequenceID();
385 outfilename += frag.fragmentID();
386 outfilename+=
".fragment";
387 rce.save(outfilename.Data());
388 std::cout <<
"Saved an RCE fragment with " << rce.size() <<
" streams: " << outfilename <<
std::endl;
392 artdaq::Fragment cfragloc(frag);
393 size_t cdsize = cfragloc.dataSizeBytes();
394 const uint64_t* cdptr = (uint64_t
const*) (cfragloc.dataBeginBytes() + 12);
395 HeaderFragmentUnpack
const cdheader(cdptr);
397 if (cdsize>16) cdsize -= 16;
398 bool isOkay = RceFragmentUnpack::isOkay(cdptr,cdsize);
401 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"RCE Fragment isOkay failed: " << cdsize <<
" Discarding this fragment";
410 uint32_t ch_counter = 0;
411 for (
int i = 0; i < rce.size(); ++i)
413 auto const * rce_stream = rce.get_stream(i);
414 size_t n_ch = rce_stream->getNChannels();
415 size_t n_ticks = rce_stream->getNTicks();
416 if (n_ticks == 0)
continue;
417 auto const identifier = rce_stream->getIdentifier();
418 uint32_t crateNumber = identifier.getCrate();
419 uint32_t slotNumber = identifier.getSlot();
420 uint32_t fiberNumber = identifier.getFiber();
423 bool foundapainlist =
false;
424 for (
size_t ialist=0; ialist < apalist.size(); ++ ialist)
427 (apalist[ialist] == (
int) crateNumber) ||
428 (apalist[ialist] == 7 && (crateNumber == 0 || crateNumber > 6)) )
430 foundapainlist =
true;
434 if (!foundapainlist)
continue;
438 if (slotNumber > 4 || fiberNumber == 0 || fiberNumber > 4)
442 MF_LOG_WARNING(
"_process_RCE:") <<
"Bad crate, slot, fiber number, discarding fragment on request: " 443 << crateNumber <<
" " << slotNumber <<
" " << fiberNumber;
454 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"Nticks not the required value: " << n_ticks <<
" " 473 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"Nticks different for two channel streams: " << n_ticks
490 size_t buffer_size = n_ch * n_ticks;
496 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"n_ch*nticks too large: " << n_ch <<
" * " << n_ticks <<
" = " <<
507 std::vector<int16_t> _buffer(buffer_size);
509 int16_t* adcs = _buffer.data();
510 bool sgmcdretcode = rce_stream->getMultiChannelData(adcs);
515 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"getMutliChannelData returns error flag: " 516 <<
" c:s:f:ich: " << crateNumber <<
" " << slotNumber <<
" " << fiberNumber <<
" Discarding Data";
526 unsigned int crateloc = crateNumber;
530 for (
size_t i_ch = 0; i_ch < n_ch; i_ch++)
543 v_adc.push_back(adcs[i_tick+_rce_fix110_nticks]);
547 v_adc.push_back(v_adc.back());
553 for (
size_t i_tick = 0; i_tick < n_ticks; i_tick++)
555 v_adc.push_back(adcs[i_tick]);
568 auto uncompressed_nticks = v_adc.size();
572 raw::RawDigit raw_digit(offlineChannel, uncompressed_nticks, v_adc, cflag);
573 raw_digit.SetPedestal(median,sigma);
574 raw_digits.push_back(raw_digit);
577 timestamps.push_back(rdtimestamp);
enum raw::_compress Compress_t
Collection of charge vs time digitized from a single readout channel.
long int _max_offline_channel
void computeMedianSigma(raw::RawDigit::ADCvector_t &v_adc, float &median, float &sigma)
unsigned int _default_crate_if_unexpected
unsigned int _tick_count_this_event
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
QTextStream & hex(QTextStream &s)
unsigned int GetOfflineNumberFromDetectorElements(unsigned int crate, unsigned int slot, unsigned int fiber, unsigned int fembchannel, FelixOrRCE frswitch)
bool _rce_drop_frags_with_badsf
bool _DiscardedCorruptData
unsigned int _full_tick_count
bool _enforce_same_tick_count
bool _initialized_tick_count_this_event
Q_EXPORT QTSManip setw(int w)
bool _enforce_full_tick_count
bool _rce_save_frags_to_files
bool _rce_check_buffer_size
#define MF_LOG_WARNING(category)
Q_EXPORT QTSManip setfill(int f)
unsigned int _rce_fix110_nticks
unsigned int ChipFromOfflineChannel(unsigned int offlineChannel) const
Returns chip number.
double median(sqlite3 *db, std::string const &table_name, std::string const &column_name)
size_t _rce_buffer_size_checklimit
QTextStream & endl(QTextStream &s)
bool _rce_drop_frags_with_badc
long int _min_offline_channel