60 #include <type_traits> 67 #include "TVirtualPad.h" 78 #include "larevt/CalibrationDBI/Interface/ChannelStatusProvider.h" 79 #include "larevt/CalibrationDBI/Interface/ChannelStatusService.h" 80 #include "larevt/CalibrationDBI/Interface/DetPedestalProvider.h" 81 #include "larevt/CalibrationDBI/Interface/DetPedestalService.h" 90 #include "cetlib_except/demangle.h" 94 template <
typename Stream,
typename T>
97 out << header <<
": " << range.
min() <<
" -- " << range.
max() <<
" (" 98 << (range.
has_data() ?
"valid" :
"invalid") <<
")";
106 template <
typename T>
111 using reference = std::add_lvalue_reference_t<value_type>;
113 using pointer = std::add_pointer_t<value_type>;
187 short MinCharge()
const {
return SampleInfo().min_charge; }
190 short MaxCharge()
const {
return SampleInfo().max_charge; }
205 template <
typename Stream>
206 void Dump(Stream&& out)
const;
210 short min_charge = std::numeric_limits<short>::max();
211 short max_charge = std::numeric_limits<short>::max();
217 mutable ::details::PointerToData_t<raw::RawDigit::ADCvector_t const>
data;
223 void UncompressData()
const;
226 void CollectSampleInfo()
const;
237 std::vector<RawDigitInfo_t>
const&
Digits()
const {
return digits; }
246 bool empty()
const {
return digits.empty(); }
252 void Refill(
art::Handle<std::vector<raw::RawDigit>>& rdcol);
262 template <
typename Stream>
263 void Dump(Stream&& out)
const;
268 bool bUpToDate =
false;
269 std::vector<raw::RawDigit>
const* digits =
nullptr;
273 : bUpToDate(uptodate), digits(newdigits)
276 operator bool()
const {
return bUpToDate; }
283 size_t max_samples = 0;
289 static std::vector<raw::RawDigit>
const* ReadProduct(
art::Event const& evt,
297 return cache.
Digits().cbegin();
302 return cache.
Digits().cend();
312 GridAxisClass(
size_t nDiv,
float new_min,
float new_max) { Init(nDiv, new_min, new_max); }
315 std::ptrdiff_t GetCell(
float coord)
const;
317 std::ptrdiff_t
operator()(
float coord)
const {
return GetCell(coord); }
323 return (iCell >= 0) && ((size_t)iCell < NCells());
327 bool hasCoord(
float coord)
const {
return (coord >= Min()) && (coord < Max()); }
330 float Min()
const {
return min; }
332 float Max()
const {
return max; }
336 float Length()
const {
return max - min; }
339 size_t NCells()
const {
return n_cells; }
348 float LowerEdge(std::ptrdiff_t iCell)
const {
return Min() + CellSize() * iCell; }
351 float UpperEdge(std::ptrdiff_t iCell)
const {
return LowerEdge(iCell + 1); }
354 bool Init(
size_t nDiv,
float new_min,
float new_max);
357 bool SetLimits(
float new_min,
float new_max);
361 bool SetMinCellSize(
float min_size);
365 bool SetMaxCellSize(
float max_size);
371 return SetMinCellSize(min_size) || SetMaxCellSize(max_size);
374 template <
typename Stream>
375 void Dump(Stream&& out)
const;
403 size_t NCells()
const {
return wire_axis.NCells() * tdc_axis.NCells(); }
412 std::ptrdiff_t GetCell(
float wire,
float tick)
const;
415 std::tuple<float, float, float, float> GetCellBox(std::ptrdiff_t iCell)
const;
418 bool hasWire(
float wire)
const {
return wire_axis.hasCoord(wire); }
424 bool hasTick(
float tick)
const {
return tdc_axis.hasCoord(tick); }
431 template <
typename CONT>
432 bool Add(CONT& cont,
float wire,
float tick,
typename CONT::value_type v)
434 std::ptrdiff_t cell = GetCell(wire, tick);
435 if (cell < 0)
return false;
436 cont[(size_t)cell] += v;
446 void SetWireRange(
float min_wire,
float max_wire) { wire_axis.SetLimits(min_wire, max_wire); }
451 wire_axis.Init(nWires, min_wire, max_wire);
455 void SetWireRange(
float min_wire,
float max_wire,
unsigned int nWires,
float min_size)
457 wire_axis.Init(nWires, min_wire, max_wire);
458 wire_axis.SetMinCellSize(min_size);
467 tdc_axis.Init(nTDC, min_tdc, max_tdc);
471 void SetTDCRange(
float min_tdc,
float max_tdc) { tdc_axis.SetLimits(min_tdc, max_tdc); }
474 void SetTDCRange(
float min_tdc,
float max_tdc,
unsigned int nTDC,
float min_size)
476 tdc_axis.Init(nTDC, min_tdc, max_tdc);
477 tdc_axis.SetMinCellSize(min_size);
489 template <
typename Stream>
490 void Dump(Stream&& out)
const;
504 , electronsToADC{dp.ElectronsToADC()}
510 if (adc < 0.)
return 0.;
511 double const dQdX = adc / wirePitch / electronsToADC;
512 return detProp.BirksCorrection(dQdX);
528 std::vector<raw::RawDigit>
const RawDataDrawer::EmptyRawDigits;
531 RawDataDrawer::RawDataDrawer()
532 : digit_cache(new
details::RawDigitCacheDataClass)
536 , fDrawingRange(new
details::CellGridClass)
547 unsigned int nplanes = geo->
Nplanes(tpcid);
570 MF_LOG_DEBUG(
"RawDataDrawer") << __func__ <<
"() setting drawing range as wires ( " << low_wire
571 <<
" - " << high_wire <<
" ), ticks ( " << low_tdc <<
" - " 584 MF_LOG_DEBUG(
"RawDataDrawer") <<
"Pad size not available -- using existing cell size";
599 std::vector<double>
const* zoom )
602 log <<
"ExtractRange() on pad '" << pPad->GetName() <<
"'";
604 TFrame
const* pFrame = pPad->GetFrame();
607 double low_wire = pFrame->GetX1(), high_wire = pFrame->GetX2();
608 double low_tdc = pFrame->GetY1(), high_tdc = pFrame->GetY2();
609 double const wire_pixels = pPad->XtoAbsPixel(high_wire) - pPad->XtoAbsPixel(low_wire);
610 double const tdc_pixels = -(pPad->YtoAbsPixel(high_tdc) - pPad->YtoAbsPixel(low_tdc));
621 log <<
", from external source,";
622 low_wire = (*zoom)[0];
623 high_wire = (*zoom)[1];
624 low_tdc = (*zoom)[2];
625 high_tdc = (*zoom)[3];
628 log <<
" spans wires " << low_wire <<
"-" << high_wire <<
" and TDC " << low_tdc <<
"-" 639 log <<
"\n no frame!";
648 : pRawDataDrawer(data_drawer), planeID(pid)
658 virtual bool Operate(
geo::WireID const& wireID,
size_t tick,
float adc) = 0;
662 virtual std::string
Name()
const {
return cet::demangle_symbol(
typeid(*this).name()); }
666 return Operate(wireID, tick, adc);
681 std::vector<std::unique_ptr<RawDataDrawer::OperationBaseClass>>
operations;
691 for (std::unique_ptr<OperationBaseClass>
const& op : operations)
692 if (!op->Initialize()) bAllOk =
false;
698 for (std::unique_ptr<OperationBaseClass>
const& op : operations)
699 if (op->ProcessWire(wireID))
return true;
704 for (std::unique_ptr<OperationBaseClass>
const& op : operations)
705 if (op->ProcessTick(tick))
return true;
711 for (std::unique_ptr<OperationBaseClass>
const& op : operations)
712 if (!op->Operate(wireID, tick, adc))
return false;
719 for (std::unique_ptr<OperationBaseClass>
const& op : operations)
720 if (!op->Finish()) bAllOk =
false;
724 std::string
Name()
const override 726 std::string msg = cet::demangle_symbol(
typeid(*this).name());
727 msg += (
" [running " +
std::to_string(operations.size()) +
" operations:");
728 for (
auto const& op : operations) {
730 msg +=
" " + op->Name();
743 if (
PlaneID() != new_op->PlaneID()) {
745 <<
"RawDataDrawer::ManyOperations(): trying to run operations on " 746 << std::string(
PlaneID()) <<
" and " << std::string(new_op->PlaneID())
747 <<
" at the same time";
749 if (RawDataDrawerPtr() && (RawDataDrawerPtr() != new_op->RawDataDrawerPtr())) {
751 <<
"RawDataDrawer::ManyOperations(): " 752 "trying to run operations on different RawDataDrawer";
754 operations.emplace_back(std::move(new_op));
767 MF_LOG_DEBUG(
"RawDataDrawer") <<
"RawDataDrawer::RunOperation() running " << operation->
Name();
773 lariov::ChannelStatusProvider
const& channelStatus =
777 const lariov::DetPedestalProvider& pedestalRetrievalAlg =
778 *(lar::providerFrom<lariov::DetPedestalService>());
788 if (!channelStatus.IsPresent(channel))
continue;
797 std::vector<geo::WireID> WireIDs = geom.
ChannelToWire(channel);
799 bool bDrawChannel =
false;
801 if (wireID.planeID() != pid)
continue;
805 if (!bDrawChannel)
continue;
808 bool const bGood = rawopt->
fSeeBadChannels || !channelStatus.IsBad(channel);
813 if (!bGood)
continue;
820 if (rawopt->
fPedestalOption == 0) { pedestal = pedestalRetrievalAlg.PedMean(channel); }
830 <<
". Pedestals not subtracted.";
837 if (wireID.planeID() != pid)
continue;
844 size_t const max_tick = std::min({uncompressed.size(), size_t(
fStartTick +
fTicks)});
846 for (
size_t iTick =
fStartTick; iTick < max_tick; ++iTick) {
851 float const adc = uncompressed[iTick] - pedestal;
854 if (!operation->
Operate(wireID, iTick, adc))
return false;
860 return operation->
Finish();
873 , convertedCharge(0.)
875 , ADCCorrector(detProp,
PlaneID())
889 drawingRange.SetMinWireCellSize(1.F);
891 boxInfo.resize(drawingRange.NCells());
897 return drawingRange.hasWire((
int)wire.
Wire);
905 std::ptrdiff_t cell = drawingRange.GetCell(wire, tick);
906 if (cell < 0)
return true;
912 convertedCharge += ADCCorrector(adc);
924 RawDataDrawerPtr()->fRawCharge[plane] = rawCharge;
925 RawDataDrawerPtr()->fConvertedCharge[plane] = convertedCharge;
929 *(RawDataDrawerPtr()->fDrawingRange) = drawingRange;
932 RawDataDrawerPtr()->QueueDrawingBoxes(view,
PlaneID(), boxInfo);
940 double rawCharge = 0., convertedCharge = 0.;
948 std::vector<BoxInfo_t>
const& BoxInfo)
956 MF_LOG_DEBUG(
"RawDataDrawer") <<
"Filling " << BoxInfo.size() <<
" boxes to be rendered";
967 size_t const nBoxes = BoxInfo.size();
968 unsigned int nDrawnBoxes = 0;
969 for (
size_t iBox = 0; iBox < nBoxes; ++iBox) {
976 if (!info.
good)
continue;
982 constexpr
float q0 = 1000.;
983 float const sf = bScaleDigitsByCharge ? std::min(std::sqrt((
float)info.
adc / q0), 1.0F) : 1.;
986 float min_wire, max_wire, min_tick, max_tick;
994 float const nsf = 1. - sf;
995 float const half_box_wires = (max_wire - min_wire) / 2.,
996 half_box_ticks = (max_tick - min_tick) / 2.;
999 min_wire += nsf * half_box_wires;
1000 max_wire -= nsf * half_box_wires;
1001 min_tick += nsf * half_box_ticks;
1002 max_tick -= nsf * half_box_ticks;
1009 pBox = &(view->
AddBox(min_wire, min_tick, max_wire, max_tick));
1011 pBox = &(view->
AddBox(min_tick, min_wire, max_tick, max_wire));
1013 pBox->SetFillStyle(1001);
1014 pBox->SetFillColor(color);
1015 pBox->SetBit(kCannotPick);
1020 MF_LOG_DEBUG(
"RawDataDrawer") <<
"Sent " << nDrawnBoxes <<
"/" << BoxInfo.size()
1021 <<
" boxes to be rendered";
1038 "somewhere something went somehow wrong";
1055 if (
std::abs(adc) < RoIthreshold)
return true;
1056 WireRange.add(wireID.
Wire);
1064 int& WireMin = pRawDataDrawer->fWireMin[plane];
1065 int& WireMax = pRawDataDrawer->fWireMax[plane];
1066 int& TimeMin = pRawDataDrawer->fTimeMin[plane];
1067 int& TimeMax = pRawDataDrawer->fTimeMax[plane];
1069 if ((WireMin == WireMax) && WireRange.has_data()) {
1072 <<
"Region of interest for " << std::string(
PlaneID()) <<
" detected to be within wires " 1073 << WireRange.min() <<
" to " << WireRange.max() <<
" (plane has " 1075 WireMax = WireRange.max() + 1;
1076 WireMin = WireRange.min();
1078 if ((TimeMin == TimeMax) && TDCrange.has_data()) {
1080 <<
"Region of interest for " << std::string(
PlaneID()) <<
" detected to be within ticks " 1081 << TDCrange.min() <<
" to " << TDCrange.max();
1082 TimeMax = TDCrange.max() + 1;
1083 TimeMin = TDCrange.min();
1100 << (bExtractRoI ?
" extracted" :
" not extracted")
1103 if (!bExtractRoI)
return;
1107 throw std::runtime_error(
1108 "RawDataDrawer::RunRoIextractor(): somewhere something went somehow wrong");
1135 bool theDroidIAmLookingFor =
false;
1147 std::vector<geo::WireID> WireIDs = geom->
ChannelToWire(rawDigit.Channel());
1150 if (wireID.planeID() !=
pid)
continue;
1151 theDroidIAmLookingFor =
true;
1155 if (theDroidIAmLookingFor)
break;
1158 if (theDroidIAmLookingFor)
break;
1161 if (!theDroidIAmLookingFor)
return;
1171 std::unique_ptr<OperationBaseClass> operation;
1174 MF_LOG_DEBUG(
"RawDataDrawer") << __func__ <<
"() setting up one-pass drawing";
1175 operation.reset(
new BoxDrawer(detProp,
pid,
this, view));
1178 MF_LOG_DEBUG(
"RawDataDrawer") << __func__ <<
"() adding RoI extraction";
1182 std::unique_ptr<OperationBaseClass> drawer(std::move(operation));
1193 "somewhere something went somehow wrong";
1199 MF_LOG_DEBUG(
"RawDataDrawer") << __func__ <<
"() setting up RoI extraction for " <<
pid;
1203 <<
"RawDataDrawer::RunDrawOperation():" 1204 " something went somehow wrong while extracting RoI";
1209 << __func__ <<
"() using existing RoI for " <<
pid <<
": wires ( " <<
fWireMin[plane]
1218 MF_LOG_DEBUG(
"RawDataDrawer") << __func__ <<
"() setting up drawing";
1222 " something went somehow wrong while drawing";
1232 if ((
unsigned int)plane >=
fWireMin.size()) {
1234 <<
" Requested plane " << plane <<
" is larger than those available " << std::endl;
1243 if ((minw == maxw) || (mint == maxt))
return 1;
1246 minw = (minw - 30 < 0) ? 0 : minw - 30;
1247 mint = (mint - 10 < 0) ? 0 : mint - 10;
1250 maxw = (maxw + 10 > (int)geo->
Nwires(planeid)) ? geo->
Nwires(planeid) : maxw + 10;
1279 lariov::ChannelStatusProvider
const& channelStatus =
1283 const lariov::DetPedestalProvider& pedestalRetrievalAlg =
1290 if (!channelStatus.IsPresent(channel))
continue;
1296 if (!rawopt->
fSeeBadChannels && channelStatus.IsBad(channel))
continue;
1298 std::vector<geo::WireID> wireids = geo->
ChannelToWire(channel);
1299 for (
auto const& wid : wireids) {
1301 if (wid.planeID() !=
pid)
continue;
1308 if (rawopt->
fPedestalOption == 0) { pedestal = pedestalRetrievalAlg.PedMean(channel); }
1318 <<
". Pedestals not subtracted.";
1321 for (
short d : uncompressed)
1322 histo->Fill(
float(
d) - pedestal);
1360 << __func__ <<
": no channel associated to " << std::string(wireid);
1365 lariov::ChannelStatusProvider
const& channelStatus =
1368 if (!channelStatus.IsPresent(channel))
return;
1377 const lariov::DetPedestalProvider& pedestalRetrievalAlg =
1396 if (rawopt->
fPedestalOption == 0) { pedestal = pedestalRetrievalAlg.PedMean(channel); }
1406 <<
". Pedestals not subtracted.";
1409 for (
size_t j = 0; j < uncompressed.size(); ++j)
1410 histo->Fill(
float(j),
1411 float(uncompressed[j]) - pedestal);
1517 MF_LOG_DEBUG(
"RawDataDrawer") <<
"RawDataDrawer[" << ((
void*)
this)
1518 <<
"]: resetting the region of interest";
1531 MF_LOG_DEBUG(
"RawDataDrawer") <<
"GetRawDigits() for " << new_timestamp
1532 <<
" (last for: " << *
fCacheID <<
")";
1543 *fCacheID = new_timestamp;
1549 lariov::ChannelStatusProvider::Status_t channel_status)
const 1552 if (!lariov::ChannelStatusProvider::IsValidStatus(channel_status))
return true;
1557 if (channel_status < drawopt->fMinChannelStatus)
return false;
1571 if (!data.hasData()) UncompressData();
1581 void RawDigitInfo_t::Clear()
1584 sample_info.reset();
1587 void RawDigitInfo_t::UncompressData()
const 1595 if (digit->Compression() ==
kNone) {
1597 data.PointToData(digit->ADCs());
1602 int pedestal = (int)digit->GetPedestal();
1604 samples.resize(digit->Samples());
1605 Uncompress(digit->ADCs(), samples, pedestal, digit->Compression());
1606 data.StealData(std::move(samples));
1610 samples.resize(digit->Samples());
1611 Uncompress(digit->ADCs(), samples, digit->Compression());
1612 data.StealData(std::move(samples));
1617 void RawDigitInfo_t::CollectSampleInfo()
const 1628 sample_info->min_charge = stat.
min();
1629 sample_info->max_charge = stat.max();
1636 if (!sample_info) CollectSampleInfo();
1637 return *sample_info;
1640 template <
typename Stream>
1641 void RawDigitInfo_t::Dump(Stream&& out)
const 1643 out <<
" digit at " << ((
void*)digit.get()) <<
" on channel #" << digit->Channel()
1644 <<
" with " << digit->NADC();
1645 if (digit->Compression() ==
kNone)
1646 out <<
" uncompressed data";
1648 out <<
" data items compressed with <" << digit->Compression() <<
">";
1650 out <<
" with data (" << data->size() <<
" samples)";
1652 out <<
" without data";
1661 auto iDigit = std::find_if(
1663 return digit.Channel() == channel;
1665 return (iDigit == digits.cend()) ?
nullptr : &*iDigit;
1668 std::vector<raw::RawDigit>
const* RawDigitCacheDataClass::ReadProduct(
art::Event const&
evt,
1672 if (!evt.
getByLabel(label, rdcol))
return nullptr;
1676 void RawDigitCacheDataClass::Refill(
art::Handle<std::vector<raw::RawDigit>>& rdcol)
1678 digits.resize(rdcol->size());
1679 for (
size_t iDigit = 0; iDigit < rdcol->size(); ++iDigit) {
1681 digits[iDigit].Fill(pDigit);
1682 size_t samples = pDigit->
Samples();
1683 if (samples > max_samples) max_samples = samples;
1687 void RawDigitCacheDataClass::Invalidate()
1692 void RawDigitCacheDataClass::Clear()
1717 if (
empty())
return res;
1719 if (!evt)
return res;
1723 if (!res.digits)
return res;
1725 if (res.digits->empty())
1731 if (!pInfo)
return res;
1733 if (&(pInfo->
Digit()) != &(res.digits->front()))
1736 res.bUpToDate =
true;
1744 if (update_info)
return false;
1746 MF_LOG_DEBUG(
"RawDataDrawer") <<
"Refilling raw digit cache RawDigitCacheDataClass[" 1747 << ((
void*)
this) <<
"] for " << new_timestamp;
1754 <<
"no RawDigit collection '" << new_timestamp.
inputLabel() <<
"' found";
1760 timestamp = new_timestamp;
1764 template <
typename Stream>
1765 void RawDigitCacheDataClass::Dump(Stream&& out)
const 1767 out <<
"Cache at " << ((
void*)
this) <<
" with time stamp " << std::string(timestamp)
1768 <<
" and " << digits.size() <<
" entries (maximum sample: " << max_samples <<
");" 1769 <<
" data at " << ((
void*)digits.data());
1772 digitInfo.Dump(out);
1780 std::ptrdiff_t GridAxisClass::GetCell(
float coord)
const 1782 return std::ptrdiff_t((coord - min) / cell_size);
1786 bool GridAxisClass::Init(
size_t nDiv,
float new_min,
float new_max)
1789 n_cells = std::max(nDiv,
size_t(1));
1790 return SetLimits(new_min, new_max);
1795 bool GridAxisClass::SetLimits(
float new_min,
float new_max)
1799 cell_size =
Length() / float(n_cells);
1801 return std::isnormal(cell_size);
1805 bool GridAxisClass::SetMinCellSize(
float min_size)
1807 if (cell_size >= min_size)
return false;
1810 n_cells = (size_t)std::max(std::floor(
Length() / min_size), 1.0F);
1814 cell_size =
Length() / float(n_cells);
1819 bool GridAxisClass::SetMaxCellSize(
float max_size)
1821 if (cell_size <= max_size)
return false;
1824 n_cells = (size_t)std::max(std::ceil(
Length() / max_size), 1.0F);
1828 cell_size =
Length() / float(n_cells);
1833 template <
typename Stream>
1834 void GridAxisClass::Dump(Stream&& out)
const 1836 out << NCells() <<
" cells from " << Min() <<
" to " << Max() <<
" (length: " <<
Length()
1843 CellGridClass::CellGridClass(
unsigned int nWires,
unsigned int nTDC)
1844 : wire_axis((size_t)nWires, 0., float(nWires)), tdc_axis((size_t)nTDC, 0., float(nTDC))
1850 unsigned int nWires,
1854 :
wire_axis((size_t)nWires, min_wire, max_wire),
tdc_axis((size_t)nTDC, min_tdc, max_tdc)
1872 std::ptrdiff_t iWireCell = (std::ptrdiff_t)(iCell / nTDCCells),
1873 iTDCCell = (std::ptrdiff_t)(iCell % nTDCCells);
1882 template <
typename Stream>
1885 out <<
"Wire axis: ";
1887 out <<
"; time axis: ";
int GetRegionOfInterest(int plane, int &minw, int &maxw, int &mint, int &maxt)
float GetPedestal() const
Data_t max() const
Returns the accumulated maximum, or a very small number if no values.
const_pointer operator->() const
details::CellGridClass drawingRange
float Length(const PFPStruct &pfp)
short MaxCharge() const
maximum charge
bool has_data() const
Returns whether at least one datum has been added.
~PointerToData_t()
Destructor: gets rid of the owned data.
int fScaleDigitsByCharge
scale the size of the digit by the charge
bool Update(art::Event const &evt, CacheID_t const &new_timestamp)
BoxDrawer(detinfo::DetectorPropertiesData const &detProp, geo::PlaneID const &pid, RawDataDrawer *dataDrawer, evdb::View2D *new_view)
bool sameProduct(PlaneDataChangeTracker_t const &as) const
Returns whether we are in the same event (the rest could differ)
bool SetCellSizeBoundary(float min_size, float max_size)
ULong64_t Samples() const
Number of samples in the uncompressed ADC data.
bool ProcessTick(size_t tick) override
unsigned int fTPC
TPC number to draw, typically set by TWQProjectionView.
Collection of charge vs time digitized from a single readout channel.
void SetWireRange(float min_wire, float max_wire)
Sets the wire range, leaving the number of wire cells unchanged.
void FillTQHisto(const art::Event &evt, unsigned int plane, unsigned int wire, TH1F *histo)
int adc
total ADC count in this box
raw::RawDigit const & Digit() const
Returns an art pointer to the actual digit.
std::vector< WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
void SetTDCRange(float min_tdc, float max_tdc, unsigned int nTDC, float min_size)
Sets the complete TDC range, with minimum cell size.
void SetWireRange(float min_wire, float max_wire, unsigned int nWires, float min_size)
Sets the complete wire range, with minimum cell size.
bool Operate(geo::WireID const &wireID, size_t tick, float adc) override
OperationBaseClass(geo::PlaneID const &pid, RawDataDrawer *data_drawer=nullptr)
void RunDrawOperation(art::Event const &evt, detinfo::DetectorPropertiesData const &detProp, evdb::View2D *view, unsigned int plane)
void SetWireRange(unsigned int nWires)
Sets the wire range, leaving the number of wire cells unchanged.
Display parameters for the raw data.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
int fDrawRawDataOrCalibWires
0 for raw
const_reference operator*() const
auto coord(Vector &v, unsigned int n) noexcept
Returns an object to manage the coordinate n of a vector.
TNtupleSim Fill(f1, f2, f3, f4)
void Dump(Stream &&out) const
Prints the current axes on the specified stream.
void SetDrawingLimitsFromRoI(geo::PlaneID::PlaneID_t plane)
double fStartTick
low tick
unsigned int PlaneID_t
Type for the ID number.
The data type to uniquely identify a Plane.
details::CacheID_t * fCacheID
information about the last processed plane
GridAxisClass const & WireAxis() const
Return the information about the wires.
std::unique_ptr< SampleInfo_t > sample_info
Information collected from the uncompressed data.
CacheID_t timestamp
object expressing validity range of cached data
ChannelID_t Channel() const
DAQ channel this raw data was read from.
std::vector< std::unique_ptr< RawDataDrawer::OperationBaseClass > > operations
constexpr auto abs(T v)
Returns the absolute value of the argument.
Classes detecting configuration changes.
float cell_size
size of each cell
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
bool SetMinTDCCellSize(float min_size)
Sets the minimum size for TDC cells.
double wirePitch
wire pitch
std::ptrdiff_t GetCell(float wire, float tick) const
Returns the index of specified cell, or -1 if out of range.
GridAxisClass()
Default constructor: an invalid range.
void SetTDCRange(float min_tdc, float max_tdc)
Sets the TDC range, leaving the number of ticks unchanged.
std::vector< BoxInfo_t > boxInfo
Definition of basic raw digits.
void RawDigit2D(art::Event const &evt, detinfo::DetectorPropertiesData const &detProp, evdb::View2D *view, unsigned int plane, bool bZoomToRoI=false)
Draws raw digit content in 2D wire plane representation.
bool hasTick(int tick) const
Returns whether the range includes the specified wire.
bool operator!() const
Returns whether we point to nothing.
A collection of drawable 2-D objects.
WireID_t Wire
Index of the wire within its plane.
int GetColor(double x) const
ManyOperations(geo::PlaneID const &pid, RawDataDrawer *data_drawer=nullptr)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
void PointToData(pointer data)
Point to the specified data, not acquiring ownership.
raw::ChannelID_t Channel() const
Returns the channel of this digit (for convenience)
bool ProcessChannelWithStatus(lariov::ChannelStatusProvider::Status_t channel_status) const
Returns whether a channel with the specified status should be processed.
Classes gathering simple statistics.
std::vector< double > fRawCharge
Sum of Raw Charge.
std::vector< int > fWireMin
lowest wire in interesting region for each plane
bool Update(detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, PFPStruct &pfp)
double electronsToADC
conversion constant
Manages a cell-like division of a coordinate.
std::add_pointer_t< value_type > pointer
void SetDrawingLimits(float low_wire, float high_wire, float low_tdc, float high_tdc)
Fills the viewport borders from the specified extremes.
size_t n_cells
number of cells in the axis
friend class RoIextractorClass
details::ADCCorrectorClass ADCCorrector
IDparameter< geo::PlaneID > PlaneID
Member type of validated geo::PlaneID parameter.
std::vector< int > fTimeMax
highest time in interesting region for each plane
The color scales used by the event display.
Keeps track of the minimum and maximum value we observed.
TBox & AddBox(double x1, double y1, double x2, double y2)
Information about a RawDigit; may contain uncompressed duplicate of data.
art::InputTag const & inputLabel() const
Returns whether we are in the same event (the rest could differ)
OperationBaseClass const * Operator(size_t iOp) const
std::add_lvalue_reference_t< value_type > reference
Data_t min() const
Returns the accumulated minimum, or a very large number if no values.
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
detinfo::DetectorPropertiesData const & detProp
float Length() const
Returns the length of the axis.
double fTicks
number of ticks of the clock
mutable::details::PointerToData_t< raw::RawDigit::ADCvector_t const > data
Uncompressed data.
bool ProcessWire(geo::WireID const &wire) override
void AcquireData(pointer data)
Acquire ownership of the specified data.
PadResolution_t PadResolution
stored pad resolution
short MinCharge() const
minimum charge
raw::RawDigit::ADCvector_t const & Data() const
average charge
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
bool SetMinWireCellSize(float min_size)
Sets the minimum size for wire cells.
double operator()(float adc) const
Applies Birks correction to the specified pedestal-subtracted charge.
Build an association between a numerical range and a ROOT color index for use in, eg...
bool Add(CONT &cont, float wire, float tick, typename CONT::value_type v)
const evdb::ColorScale & RawQ(geo::SigType_t st) const
unsigned int fCryostat
Cryostat number to draw, typically set by TWQProjectionView.
enum geo::_plane_sigtype SigType_t
Enumerate the possible plane projections.
std::string Name() const override
bool hasWire(int wire) const
Returns whether the range includes the specified wire.
std::ptrdiff_t operator()(float coord) const
Returns the index of the specified cell.
ADCCorrectorClass(detinfo::DetectorPropertiesData const &dp, geo::PlaneID const &pid)
unsigned int fMaxChannelStatus
Display channels with this status and below.
Cached set of RawDigitInfo_t.
Collect all the RawData header files together.
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
float UpperEdge(std::ptrdiff_t iCell) const
Returns the upper edge of the cell.
float LowerEdge(std::ptrdiff_t iCell) const
Returns the lower edge of the cell.
void FillQHisto(const art::Event &evt, unsigned int plane, TH1F *histo)
void GetChargeSum(int plane, double &charge, double &convcharge)
virtual bool Initialize()
double fMinSignal
minimum ADC count to display a time bin
void RunRoIextractor(art::Event const &evt, unsigned int plane)
std::vector< int > fWireMax
highest wire in interesting region for each plane
double fTicks
number of TDC ticks to display, ie # fTicks past fStartTick
std::add_lvalue_reference_t< const_value_type > const_reference
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
constexpr bool isValidChannelID(raw::ChannelID_t channel)
void GetRawDigits(art::Event const &evt)
Reads raw::RawDigits; also triggers Reset()
geo::TPCID CurrentTPC() const
Returns the current TPC as a TPCID.
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)
bool hasCell(std::ptrdiff_t iCell) const
Returns whether the cell is present or not.
double TotalClockTicks() const
The data type to uniquely identify a TPC.
Description of geometry of one entire detector.
virtual bool Operate(geo::WireID const &wireID, size_t tick, float adc)=0
bool operator()(geo::WireID const &wireID, size_t tick, float adc)
float Max() const
Returns the extremes of the axis.
bool Initialize() override
bool isEmpty() const
Returns whether minimum and maximum match.
bool Initialize() override
bool bOwned
whether we own our data
Class to aid in the rendering of RawData objects.
Detector simulation of raw signals on wires.
void SetTDCRange(float min_tdc, float max_tdc, unsigned int nTDC)
Sets the complete TDC range.
float CellSize() const
Returns the cell size.
Detects the presence of a new event, data product or wire plane.
std::vector< RawDigitInfo_t > const & Digits() const
Returns the list of digit info.
CellGridClass()
Default constructor: invalid ranges.
bool empty() const
Returns whether the cache is empty() (STL-like interface)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
geo::PlaneID const & PlaneID() const
std::size_t color(std::string const &procname)
void NewData(T const &data)
Create a owned copy of the specified object.
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
RawDigitInfo_t const * FindChannel(raw::ChannelID_t channel) const
Returns a pointer to the digit info of given channel, nullptr if none.
int fTicksPerPoint
number of ticks to include in one point
SigType_t SignalType(PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
virtual bool ProcessWire(geo::WireID const &)
bool fSeeBadChannels
Allow "bad" channels to be viewed.
bool hasCoord(float coord) const
Returns whether the coordinate is included in the range or not.
bool hasRegionOfInterest(geo::PlaneID::PlaneID_t plane) const
void SetWireRange(float min_wire, float max_wire, unsigned int nWires)
Sets the complete wire range.
void PointToData(reference data)
Point to the specified data, not acquiring ownership.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
pointer pData
pointer to data
size_t NCells() const
Returns the length of the axis.
void QueueDrawingBoxes(evdb::View2D *view, geo::PlaneID const &pid, std::vector< BoxInfo_t > const &BoxInfo)
unsigned int Nwires(PlaneID const &planeid) const
Returns the total number of wires in the specified plane.
int fAxisOrientation
0 = TDC values on y-axis, wire number on x-axis, 1 = swapped
void Clear()
Stop pointing to the data; if owned, delete it.
std::vector< art::InputTag > fRawDataLabels
module label that made the raw digits, default is daq
Aid in the rendering of RawData objects.
art::Ptr< raw::RawDigit > digit
a pointer to the actual digit
GridAxisClass(size_t nDiv, float new_min, float new_max)
Constructor: sets the limits and the number of cells.
bool ProcessTick(size_t tick) override
double fStartTick
Starting tick for the display.
bool good
whether the channel is not bad
void Dump(Stream &&out) const
unsigned int WireID_t
Type for the ID number.
bool owned() const
Returns whether we have data and we own it.
unsigned int Nplanes(TPCID const &tpcid=tpc_zero) const
Returns the total number of planes in the specified TPC.
RawDataDrawer * RawDataDrawerPtr() const
size_t MaxSamples() const
Returns the largest number of samples in the unpacked raw digits.
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
void ResetRegionOfInterest()
Forgets about the current region of interest.
details::CellGridClass * fDrawingRange
information about the viewport
std::vector< int > fTimeMin
lowest time in interesting region for each plane
::util::PlaneDataChangeTracker_t CacheID_t
std::add_const_t< value_type > const_value_type
Manages a grid-like division of 2D space.
bool ProcessWire(geo::WireID const &wireID) override
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Applies Birks correction.
OperationBaseClass * Operator(size_t iOp)
virtual std::string Name() const
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
evd::details::RawDigitCacheDataClass * digit_cache
Cache of raw digits.
int fPedestalOption
0: use DetPedestalService; 1: Use pedestal in raw::RawDigt; 2: no ped subtraction ...
void SetTDCRange(unsigned int nTDC)
Sets a simple TDC range: all the ticks, one cell per tick.
void StealData(std::remove_const_t< T > &&data)
Move data from the specified object, and own it.
Namespace collecting geometry-related classes utilities.
std::vector< RawDigitInfo_t > digits
vector of raw digit information
GridAxisClass const & TDCAxis() const
Return the information about the TDCs.
bool hasData() const
Returns whether we have data.
art::Ptr< raw::RawDigit > DigitPtr() const
Returns an art pointer to the actual digit.
bool RunOperation(art::Event const &evt, OperationBaseClass *operation)
std::tuple< float, float, float, float > GetCellBox(std::ptrdiff_t iCell) const
Returns the coordinates { w1, t1, w2, t2 } of specified cell.
art framework interface to geometry description
size_t NCells() const
Returns the total number of cells in the grid.
void SetData(pointer data, bool owned)
Sets the data and the ownership.
bool Operate(geo::WireID const &wireID, size_t tick, float adc) override
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
bool fUncompressWithPed
Option to uncompress with pedestal. Turned off by default.
virtual bool ProcessTick(size_t)
std::add_pointer_t< const_value_type > const_pointer
std::ptrdiff_t GetCell(float coord) const
Returns the index of the specified cell.
void AddOperation(std::unique_ptr< OperationBaseClass > new_op)
std::vector< double > fConvertedCharge
Sum of Charge Converted using Birks' formula.
void ExtractRange(TVirtualPad *pPad, std::vector< double > const *zoom=nullptr)
Fills the viewport information from the specified pad.