340 std::ios oldState(
nullptr);
341 oldState.copyfmt(std::cout);
343 std::cout <<
"RCE Fragment: all numbers in hex " <<
std::hex 344 <<
" SequenceID = " << frag.sequenceID()
345 <<
" fragmentID = " << frag.fragmentID()
346 <<
" fragmentType = " << (unsigned)frag.type()
347 <<
" Timestamp = " << frag.timestamp() <<
std::endl;
348 std::cout <<
"Offset Data";
349 artdaq::Fragment fragloc(frag);
350 unsigned char *dbegin =
reinterpret_cast<unsigned char *
>(fragloc.dataAddress());
351 size_t dsize = fragloc.dataSizeBytes();
353 for (
size_t bcounter=0; bcounter<dsize;++bcounter)
355 if ( (offcounter % 8) == 0 )
364 std::cout.copyfmt(oldState);
374 artdaq::Fragment cfragloc(frag);
375 size_t cdsize = cfragloc.dataSizeBytes();
376 const uint64_t* cdptr = (uint64_t
const*) (cfragloc.dataBeginBytes() + 12);
377 HeaderFragmentUnpack
const cdheader(cdptr);
379 if (cdsize>16) cdsize -= 16;
380 bool isOkay = RceFragmentUnpack::isOkay(cdptr,cdsize);
383 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"RCE Fragment isOkay failed: " << cdsize <<
" Discarding this fragment";
394 TString outfilename=
"rce_";
395 outfilename += evt.
run();
397 outfilename += frag.sequenceID();
399 outfilename += frag.fragmentID();
400 outfilename+=
".fragment";
401 rce.save(outfilename.Data());
402 std::cout <<
"Saved an RCE fragment with " << rce.size() <<
" streams: " << outfilename <<
std::endl;
405 uint32_t ch_counter = 0;
406 for (
int i = 0; i < rce.size(); ++i)
408 auto const * rce_stream = rce.get_stream(i);
409 size_t n_ch = rce_stream->getNChannels();
410 size_t n_ticks = rce_stream->getNTicks();
411 if (n_ticks == 0)
continue;
412 auto const identifier = rce_stream->getIdentifier();
413 uint32_t crateNumber = identifier.getCrate();
417 uint32_t slotNumber = identifier.getSlot();
418 uint32_t fiberNumber = identifier.getFiber();
421 bool foundapainlist =
false;
422 for (
size_t ialist=0; ialist < apalist.size(); ++ ialist)
425 (apalist[ialist] == (
int) crateNumber) ||
426 (apalist[ialist] == 7 && (crateNumber == 0 || crateNumber > 6)) )
428 foundapainlist =
true;
432 if (!foundapainlist)
continue;
440 uint32_t runNumber = evt.
run();
445 if (runNumber > 2572)
447 auto oldfiber = fiberNumber;
448 auto oldslot = slotNumber;
450 if (oldslot == 0 && oldfiber == 4)
455 if (oldslot == 1 && oldfiber == 4)
460 if (oldslot == 1 && oldfiber == 3)
465 if (oldslot == 0 && oldfiber == 3)
474 if (runNumber > 1530 && runNumber < 2572)
476 auto oldfiber = fiberNumber;
477 auto oldslot = slotNumber;
481 if (oldslot == 2 && oldfiber == 1)
486 if (oldslot == 1 && oldfiber == 1)
491 if (oldslot == 2 && oldfiber == 3)
496 if (oldslot == 1 && oldfiber == 3)
502 oldfiber = fiberNumber;
503 oldslot = slotNumber;
505 if (oldslot == 0 && oldfiber == 4)
510 if (oldslot == 1 && oldfiber == 4)
515 if (oldslot == 0 && oldfiber == 3)
520 if (oldslot == 1 && oldfiber == 3)
529 if ( slotNumber == 1 && fiberNumber == 1 )
534 if ( slotNumber == 2 && fiberNumber == 1 )
545 if (slotNumber > 4 || fiberNumber == 0 || fiberNumber > 4)
549 MF_LOG_WARNING(
"_process_RCE:") <<
"Bad crate, slot, fiber number, discarding fragment on request: " 550 << crateNumber <<
" " << slotNumber <<
" " << fiberNumber;
561 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"Nticks not the required value: " << n_ticks <<
" " 580 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"Nticks different for two channel streams: " << n_ticks
597 size_t buffer_size = n_ch * n_ticks;
603 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"n_ch*nticks too large: " << n_ch <<
" * " << n_ticks <<
" = " <<
614 std::vector<int16_t> _buffer(buffer_size);
616 int16_t* adcs = _buffer.data();
617 bool sgmcdretcode = rce_stream->getMultiChannelData(adcs);
622 MF_LOG_WARNING(
"_process_RCE_AUX:") <<
"getMutliChannelData returns error flag: " 623 <<
" c:s:f:ich: " << crateNumber <<
" " << slotNumber <<
" " << fiberNumber <<
" Discarding Data";
633 unsigned int crateloc = crateNumber;
638 for (
size_t i_ch = 0; i_ch < n_ch; i_ch++)
647 for (
size_t i_tick = 0; i_tick < n_ticks; i_tick++)
649 v_adc.push_back(adcs[i_tick]);
662 auto uncompressed_nticks = v_adc.size();
666 raw::RawDigit raw_digit(offlineChannel, uncompressed_nticks, v_adc, cflag);
667 raw_digit.SetPedestal(median,sigma);
668 raw_digits.push_back(raw_digit);
671 timestamps.push_back(rdtimestamp);
bool _DiscardedCorruptData
bool _rce_check_buffer_size
size_t _rce_buffer_size_checklimit
enum raw::_compress Compress_t
Collection of charge vs time digitized from a single readout channel.
long int _max_offline_channel
unsigned int _tick_count_this_event
bool _rce_drop_frags_with_badc
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)
unsigned int _full_tick_count
bool _rce_save_frags_to_files
bool _enforce_full_tick_count
Q_EXPORT QTSManip setw(int w)
bool _initialized_tick_count_this_event
void computeMedianSigma(raw::RawDigit::ADCvector_t &v_adc, float &median, float &sigma)
bool _rce_drop_frags_with_badsf
long int _min_offline_channel
#define MF_LOG_WARNING(category)
bool _enforce_same_tick_count
Q_EXPORT QTSManip setfill(int f)
double median(sqlite3 *db, std::string const &table_name, std::string const &column_name)
QTextStream & endl(QTextStream &s)