459 cet::cpu_timer theClockProcess;
461 theClockProcess.start();
463 art::Ptr<artdaq::Fragment> fragmentPtr(fragmentHandle, idx);
465 mf::LogDebug(
"DaqDecoderICARUSTPCwROI") <<
"--> Processing fragment ID: " << fragmentPtr->fragmentID() << std::endl;
466 mf::LogDebug(
"DaqDecoderICARUSTPCwROI") <<
" ==> Current thread index: " << tbb::this_task_arena::current_thread_index() << std::endl;
468 cet::cpu_timer theClockTotal;
470 theClockTotal.start();
473 icarus::PhysCrateFragment physCrateFragment(*fragmentPtr);
475 size_t nBoardsPerFragment = physCrateFragment.nBoards();
476 size_t nChannelsPerBoard = physCrateFragment.nChannelsPerBoard();
477 size_t nSamplesPerChannel = physCrateFragment.nSamplesPerChannel();
481 artdaq::detail::RawFragmentHeader::fragment_id_t fragmentID = fragmentPtr->fragmentID();
483 mf::LogDebug(
fLogCategory) <<
"==> Recovered fragmentID: " << std::hex << fragmentID << std::dec << std::endl;
500 for(
const auto& boardID : readoutIDVec)
505 mf::LogDebug(
fLogCategory) <<
"*** COULD NOT FIND BOARD ***\n" <<
506 " - boardID: " << std::hex << boardID <<
", board map size: " << readoutIDVec.size() <<
", nBoardsPerFragment: " << nBoardsPerFragment;
513 boardIDVec[boardSlot] = boardID;
516 std::string boardIDs =
"";
518 for(
const auto&
id : boardIDVec) boardIDs +=
std::to_string(
id) +
" ";
520 mf::LogDebug(
fLogCategory) <<
" - # boards: " << boardIDVec.size() <<
", boards: " << boardIDs;
522 cet::cpu_timer theClockPedestal;
524 theClockPedestal.start();
527 INoiseFilter* decoderTool =
fDecoderToolVec[tbb::this_task_arena::current_thread_index()].get();
532 channelArrayPair.first.resize(nChannelsPerBoard);
533 channelArrayPair.second.resize(nChannelsPerBoard,icarus_signal_processing::VectorFloat(nSamplesPerChannel));
540 for(
size_t board = 0; board < boardIDVec.size(); board++)
543 if (board >= nBoardsPerFragment)
545 mf::LogInfo(
"TPCDecoderFilter1D") <<
" Asking for board beyond number in fragment, want board " << board <<
", maximum is " << nBoardsPerFragment << std::endl;
549 uint32_t boardSlot = physCrateFragment.DataTileHeader(board)->StatusReg_SlotID();
553 mf::LogDebug(
fLogCategory) <<
"********************************************************************************\n"
554 <<
"FragmentID: " << std::hex << fragmentID << std::dec <<
", Crate: " << crateName <<
", boardID: " << boardSlot <<
"/" << nBoardsPerFragment <<
", size " << channelPlanePairVec.size() <<
"/" << nChannelsPerBoard;
556 if (board != boardSlot)
558 mf::LogInfo(
fLogCategory) <<
"==> Found board/boardSlot mismatch, crate: " << crateName <<
", board: " << board <<
", boardSlot: " << boardSlot <<
" channelPlanePair: " <<
fChannelMap->
getChannelPlanePair(boardIDVec[board]).front().first <<
"/" <<
fChannelMap->
getChannelPlanePair(boardIDVec[board]).front().second <<
", slot: " << channelPlanePairVec[0].first <<
"/" << channelPlanePairVec[0].second;
562 const icarus::A2795DataBlock::data_t* dataBlock = physCrateFragment.BoardData(board);
565 for(
size_t chanIdx = 0; chanIdx < nChannelsPerBoard; chanIdx++)
567 icarus_signal_processing::VectorFloat& rawDataVec = channelArrayPair.second[chanIdx];
570 rawDataVec[
tick] = -dataBlock[chanIdx +
tick * nChannelsPerBoard];
573 channelArrayPair.first[chanIdx] = channelPlanePairVec[chanIdx];
577 decoderTool->process_fragment(clockData, channelArrayPair.first, channelArrayPair.second,
fCoherentNoiseGrouping);
580 icarus_signal_processing::WaveformTools<float> waveformTools;
583 float localPedestal(0.);
584 float localFullRMS(0.);
585 float localTruncRMS(0.);
586 int localNumTruncBins(0);
587 int localRangeBins(0);
592 const icarus_signal_processing::ArrayFloat& denoised = decoderTool->getWaveLessCoherent();
594 icarus_signal_processing::VectorFloat pedCorWaveforms(denoised[0].
size());
596 for(
size_t chanIdx = 0; chanIdx < nChannelsPerBoard; chanIdx++)
604 const icarus_signal_processing::VectorFloat& waveform = decoderTool->getPedCorWaveforms()[chanIdx];
607 std::transform(waveform.begin(),waveform.end(),wvfm.begin(),[](
const auto& val){
return short(std::round(val));});
609 ConcurrentRawDigitCol::iterator newRawObjItr = concurrentRawRawDigitCol.emplace_back(channel,wvfm.size(),wvfm);
611 newRawObjItr->SetPedestal(decoderTool->getPedestalVals()[chanIdx],decoderTool->getFullRMSVals()[chanIdx]);
616 const icarus_signal_processing::VectorFloat& corrections = decoderTool->getCorrectedMedians()[chanIdx];
619 std::transform(corrections.begin(),corrections.end(),wvfm.begin(),[](
const auto& val){
return short(std::round(val));});
622 ConcurrentRawDigitCol::iterator newRawObjItr = coherentRawDigitCol.push_back(
raw::RawDigit(channel,wvfm.size(),wvfm));
624 newRawObjItr->SetPedestal(0.,0.);
628 waveformTools.getPedestalCorrectedWaveform(denoised[chanIdx],
639 std::transform(pedCorWaveforms.begin(),pedCorWaveforms.end(),wvfm.begin(),[](
const auto& val){
return short(std::round(val));});
641 ConcurrentRawDigitCol::iterator newObjItr = concurrentRawDigitCol.emplace_back(channel,wvfm.size(),wvfm);
643 newObjItr->SetPedestal(localPedestal,localFullRMS);
646 const icarus_signal_processing::VectorBool& chanROIs = decoderTool->getROIVals()[chanIdx];
652 while(roiIdx < chanROIs.size())
654 size_t roiStartIdx = roiIdx;
656 while(roiIdx < chanROIs.size() && chanROIs[roiIdx]) roiIdx++;
658 if (roiIdx > roiStartIdx)
660 std::vector<short> holder(roiIdx - roiStartIdx);
662 for(
size_t idx = 0; idx < holder.size(); idx++) holder[idx] = wvfm[roiStartIdx+idx];
664 ROIVec.
add_range(roiStartIdx, std::move(holder));
681 theClockProcess.stop();
683 double totalTime = theClockProcess.accumulated_real_time();
685 mf::LogDebug(
fLogCategory) <<
"--> Exiting fragment processing for thread: " << tbb::this_task_arena::current_thread_index() <<
", time: " << totalTime << std::endl;
std::pair< daq::INoiseFilter::ChannelPlaneVec, icarus_signal_processing::ArrayFloat > ChannelArrayPair
std::vector< ChannelPlanePair > ChannelPlanePairVec
Collection of charge vs time digitized from a single readout channel.
std::vector< unsigned int > ReadoutIDVec
virtual const ReadoutIDVec & getReadoutBoardVec(const unsigned int) const =0
std::vector< std::unique_ptr< INoiseFilter > > fDecoderToolVec
Decoder tools.
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
const datarange_t & add_range(size_type offset, ITER first, ITER last)
Adds a sequence of elements as a range with specified offset.
std::size_t size(FixedBins< T, C > const &) noexcept
bool fOutputCorrection
Should we output the coherent noise correction vectors?
virtual const std::string & getCrateName(const unsigned int) const =0
virtual bool hasBoardID(const unsigned int) const =0
float fSigmaForTruncation
Cut for truncated rms calc.
virtual const ChannelPlanePairVec & getChannelPlanePair(const unsigned int) const =0
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
virtual bool hasFragmentID(const unsigned int) const =0
const icarusDB::IICARUSChannelMap * fChannelMap
std::string to_string(WindowPattern const &pattern)
Class managing the creation of a new recob::Wire object.
virtual unsigned int getBoardSlot(const unsigned int) const =0
bool fOutputRawWaveform
Should we output pedestal corrected (not noise filtered)?
unsigned int ChannelID_t
Type representing the ID of a readout channel.
size_t fCoherentNoiseGrouping
Grouping for removing coherent noise.
const std::string fLogCategory
Output category when logging messages.