60 #include <type_traits> 67 #include "TVirtualPad.h" 79 #include "larevt/CalibrationDBI/Interface/ChannelStatusProvider.h" 80 #include "larevt/CalibrationDBI/Interface/ChannelStatusService.h" 81 #include "larevt/CalibrationDBI/Interface/DetPedestalProvider.h" 82 #include "larevt/CalibrationDBI/Interface/DetPedestalService.h" 91 #include "cetlib_except/demangle.h" 95 template <
typename Stream,
typename T>
98 out << header <<
": " << range.
min() <<
" -- " << range.
max() <<
" (" 99 << (range.
has_data() ?
"valid" :
"invalid") <<
")";
107 template <
typename T>
112 using reference = std::add_lvalue_reference_t<value_type>;
114 using pointer = std::add_pointer_t<value_type>;
188 short MinCharge()
const {
return SampleInfo().min_charge; }
191 short MaxCharge()
const {
return SampleInfo().max_charge; }
206 template <
typename Stream>
207 void Dump(Stream&& out)
const;
211 short min_charge = std::numeric_limits<short>::max();
212 short max_charge = std::numeric_limits<short>::max();
218 mutable ::details::PointerToData_t<raw::RawDigit::ADCvector_t const>
data;
224 void UncompressData()
const;
227 void CollectSampleInfo()
const;
238 std::vector<RawDigitInfo_t>
const&
Digits()
const {
return digits; }
247 bool empty()
const {
return digits.empty(); }
253 void Refill(
art::Handle<std::vector<raw::RawDigit>>& rdcol);
263 template <
typename Stream>
264 void Dump(Stream&& out)
const;
269 bool bUpToDate =
false;
270 std::vector<raw::RawDigit>
const* digits =
nullptr;
274 : bUpToDate(uptodate), digits(newdigits)
277 operator bool()
const {
return bUpToDate; }
284 size_t max_samples = 0;
290 static std::vector<raw::RawDigit>
const* ReadProduct(
art::Event const& evt,
298 return cache.
Digits().cbegin();
303 return cache.
Digits().cend();
313 GridAxisClass(
size_t nDiv,
float new_min,
float new_max) { Init(nDiv, new_min, new_max); }
316 std::ptrdiff_t GetCell(
float coord)
const;
318 std::ptrdiff_t
operator()(
float coord)
const {
return GetCell(coord); }
324 return (iCell >= 0) && ((size_t)iCell < NCells());
328 bool hasCoord(
float coord)
const {
return (coord >= Min()) && (coord < Max()); }
331 float Min()
const {
return min; }
333 float Max()
const {
return max; }
337 float Length()
const {
return max - min; }
340 size_t NCells()
const {
return n_cells; }
349 float LowerEdge(std::ptrdiff_t iCell)
const {
return Min() + CellSize() * iCell; }
352 float UpperEdge(std::ptrdiff_t iCell)
const {
return LowerEdge(iCell + 1); }
355 bool Init(
size_t nDiv,
float new_min,
float new_max);
358 bool SetLimits(
float new_min,
float new_max);
362 bool SetMinCellSize(
float min_size);
366 bool SetMaxCellSize(
float max_size);
372 return SetMinCellSize(min_size) || SetMaxCellSize(max_size);
375 template <
typename Stream>
376 void Dump(Stream&& out)
const;
404 size_t NCells()
const {
return wire_axis.NCells() * tdc_axis.NCells(); }
413 std::ptrdiff_t GetCell(
float wire,
float tick)
const;
416 std::tuple<float, float, float, float> GetCellBox(std::ptrdiff_t iCell)
const;
419 bool hasWire(
float wire)
const {
return wire_axis.hasCoord(wire); }
425 bool hasTick(
float tick)
const {
return tdc_axis.hasCoord(tick); }
432 template <
typename CONT>
433 bool Add(CONT& cont,
float wire,
float tick,
typename CONT::value_type v)
435 std::ptrdiff_t cell = GetCell(wire, tick);
436 if (cell < 0)
return false;
437 cont[(size_t)cell] += v;
447 void SetWireRange(
float min_wire,
float max_wire) { wire_axis.SetLimits(min_wire, max_wire); }
452 wire_axis.Init(nWires, min_wire, max_wire);
456 void SetWireRange(
float min_wire,
float max_wire,
unsigned int nWires,
float min_size)
458 wire_axis.Init(nWires, min_wire, max_wire);
459 wire_axis.SetMinCellSize(min_size);
468 tdc_axis.Init(nTDC, min_tdc, max_tdc);
472 void SetTDCRange(
float min_tdc,
float max_tdc) { tdc_axis.SetLimits(min_tdc, max_tdc); }
475 void SetTDCRange(
float min_tdc,
float max_tdc,
unsigned int nTDC,
float min_size)
477 tdc_axis.Init(nTDC, min_tdc, max_tdc);
478 tdc_axis.SetMinCellSize(min_size);
490 template <
typename Stream>
491 void Dump(Stream&& out)
const;
505 , electronsToADC{dp.ElectronsToADC()}
511 if (adc < 0.)
return 0.;
512 double const dQdX = adc / wirePitch / electronsToADC;
513 return detProp.BirksCorrection(dQdX);
529 std::vector<raw::RawDigit>
const RawDataDrawer::EmptyRawDigits;
532 RawDataDrawer::RawDataDrawer()
533 : digit_cache(new
details::RawDigitCacheDataClass)
537 , fDrawingRange(new
details::CellGridClass)
547 unsigned int nplanes = wireReadoutGeom.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 = wireReadoutGeom.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";
968 size_t const nBoxes = BoxInfo.size();
969 unsigned int nDrawnBoxes = 0;
970 for (
size_t iBox = 0; iBox < nBoxes; ++iBox) {
977 if (!info.
good)
continue;
983 constexpr
float q0 = 1000.;
984 float const sf = bScaleDigitsByCharge ? std::min(std::sqrt((
float)info.
adc / q0), 1.0F) : 1.;
987 float min_wire, max_wire, min_tick, max_tick;
990 float const nsf = 1. - sf;
991 float const half_box_wires = (max_wire - min_wire) / 2.,
992 half_box_ticks = (max_tick - min_tick) / 2.;
995 min_wire += nsf * half_box_wires;
996 max_wire -= nsf * half_box_wires;
997 min_tick += nsf * half_box_ticks;
998 max_tick -= nsf * half_box_ticks;
1005 pBox = &(view->
AddBox(min_wire, min_tick, max_wire, max_tick));
1007 pBox = &(view->
AddBox(min_tick, min_wire, max_tick, max_wire));
1009 pBox->SetFillStyle(1001);
1010 pBox->SetFillColor(color);
1011 pBox->SetBit(kCannotPick);
1016 MF_LOG_DEBUG(
"RawDataDrawer") <<
"Sent " << nDrawnBoxes <<
"/" << BoxInfo.size()
1017 <<
" boxes to be rendered";
1034 "somewhere something went somehow wrong";
1051 if (
std::abs(adc) < RoIthreshold)
return true;
1052 WireRange.add(wireID.
Wire);
1060 int& WireMin = pRawDataDrawer->fWireMin[plane];
1061 int& WireMax = pRawDataDrawer->fWireMax[plane];
1062 int& TimeMin = pRawDataDrawer->fTimeMin[plane];
1063 int& TimeMax = pRawDataDrawer->fTimeMax[plane];
1065 if ((WireMin == WireMax) && WireRange.has_data()) {
1068 <<
"Region of interest for " << std::string(
PlaneID()) <<
" detected to be within wires " 1069 << WireRange.min() <<
" to " << WireRange.max() <<
" (plane has " 1070 << wireReadoutGeom.Nwires(
PlaneID()) <<
" wires)";
1071 WireMax = WireRange.max() + 1;
1072 WireMin = WireRange.min();
1074 if ((TimeMin == TimeMax) && TDCrange.has_data()) {
1076 <<
"Region of interest for " << std::string(
PlaneID()) <<
" detected to be within ticks " 1077 << TDCrange.min() <<
" to " << TDCrange.max();
1078 TimeMax = TDCrange.max() + 1;
1079 TimeMin = TDCrange.min();
1096 << (bExtractRoI ?
" extracted" :
" not extracted")
1099 if (!bExtractRoI)
return;
1103 throw std::runtime_error(
1104 "RawDataDrawer::RunRoIextractor(): somewhere something went somehow wrong");
1130 bool theDroidIAmLookingFor =
false;
1144 std::vector<geo::WireID> WireIDs = wireReadoutGeom.ChannelToWire(rawDigit.Channel());
1147 if (wireID.planeID() !=
pid)
continue;
1148 theDroidIAmLookingFor =
true;
1152 if (theDroidIAmLookingFor)
break;
1155 if (theDroidIAmLookingFor)
break;
1158 if (!theDroidIAmLookingFor)
return;
1168 std::unique_ptr<OperationBaseClass> operation;
1171 MF_LOG_DEBUG(
"RawDataDrawer") << __func__ <<
"() setting up one-pass drawing";
1172 operation.reset(
new BoxDrawer(detProp,
pid,
this, view));
1175 MF_LOG_DEBUG(
"RawDataDrawer") << __func__ <<
"() adding RoI extraction";
1179 std::unique_ptr<OperationBaseClass> drawer(std::move(operation));
1190 "somewhere something went somehow wrong";
1196 MF_LOG_DEBUG(
"RawDataDrawer") << __func__ <<
"() setting up RoI extraction for " <<
pid;
1200 <<
"RawDataDrawer::RunDrawOperation():" 1201 " something went somehow wrong while extracting RoI";
1206 << __func__ <<
"() using existing RoI for " <<
pid <<
": wires ( " <<
fWireMin[plane]
1215 MF_LOG_DEBUG(
"RawDataDrawer") << __func__ <<
"() setting up drawing";
1219 " something went somehow wrong while drawing";
1227 if ((
unsigned int)plane >=
fWireMin.size()) {
1229 <<
" Requested plane " << plane <<
" is larger than those available " << std::endl;
1238 if ((minw == maxw) || (mint == maxt))
return 1;
1241 minw = (minw - 30 < 0) ? 0 : minw - 30;
1242 mint = (mint - 10 < 0) ? 0 : mint - 10;
1246 maxw = (maxw + 10 > (int)wireReadoutGeom.Nwires(planeid)) ? wireReadoutGeom.Nwires(planeid) :
1276 lariov::ChannelStatusProvider
const& channelStatus =
1280 const lariov::DetPedestalProvider& pedestalRetrievalAlg =
1287 if (!channelStatus.IsPresent(channel))
continue;
1293 if (!rawopt->
fSeeBadChannels && channelStatus.IsBad(channel))
continue;
1295 std::vector<geo::WireID> wireids = wireReadoutGeom.ChannelToWire(channel);
1296 for (
auto const& wid : wireids) {
1298 if (wid.planeID() !=
pid)
continue;
1305 if (rawopt->
fPedestalOption == 0) { pedestal = pedestalRetrievalAlg.PedMean(channel); }
1315 <<
". Pedestals not subtracted.";
1318 for (
short d : uncompressed)
1319 histo->Fill(
float(
d) - pedestal);
1354 raw::ChannelID_t const channel = wireReadoutGeom.PlaneWireToChannel(wireid);
1357 << __func__ <<
": no channel associated to " << std::string(wireid);
1362 lariov::ChannelStatusProvider
const& channelStatus =
1365 if (!channelStatus.IsPresent(channel))
return;
1374 const lariov::DetPedestalProvider& pedestalRetrievalAlg =
1390 if (rawopt->
fPedestalOption == 0) { pedestal = pedestalRetrievalAlg.PedMean(channel); }
1400 <<
". Pedestals not subtracted.";
1403 for (
size_t j = 0; j < uncompressed.size(); ++j)
1404 histo->Fill(
float(j),
float(uncompressed[j]) - pedestal);
1421 MF_LOG_DEBUG(
"RawDataDrawer") <<
"RawDataDrawer[" << ((
void*)
this)
1422 <<
"]: resetting the region of interest";
1435 MF_LOG_DEBUG(
"RawDataDrawer") <<
"GetRawDigits() for " << new_timestamp
1436 <<
" (last for: " << *
fCacheID <<
")";
1447 *fCacheID = new_timestamp;
1453 lariov::ChannelStatusProvider::Status_t channel_status)
const 1456 if (!lariov::ChannelStatusProvider::IsValidStatus(channel_status))
return true;
1461 if (channel_status < drawopt->fMinChannelStatus)
return false;
1475 if (!data.hasData()) UncompressData();
1485 void RawDigitInfo_t::Clear()
1488 sample_info.reset();
1491 void RawDigitInfo_t::UncompressData()
const 1499 if (digit->Compression() ==
kNone) {
1501 data.PointToData(digit->ADCs());
1506 int pedestal = (int)digit->GetPedestal();
1508 samples.resize(digit->Samples());
1509 Uncompress(digit->ADCs(), samples, pedestal, digit->Compression());
1510 data.StealData(std::move(samples));
1514 samples.resize(digit->Samples());
1515 Uncompress(digit->ADCs(), samples, digit->Compression());
1516 data.StealData(std::move(samples));
1521 void RawDigitInfo_t::CollectSampleInfo()
const 1529 sample_info->min_charge = stat.
min();
1530 sample_info->max_charge = stat.max();
1536 if (!sample_info) CollectSampleInfo();
1537 return *sample_info;
1540 template <
typename Stream>
1541 void RawDigitInfo_t::Dump(Stream&& out)
const 1543 out <<
" digit at " << ((
void*)digit.get()) <<
" on channel #" << digit->Channel()
1544 <<
" with " << digit->NADC();
1545 if (digit->Compression() ==
kNone)
1546 out <<
" uncompressed data";
1548 out <<
" data items compressed with <" << digit->Compression() <<
">";
1550 out <<
" with data (" << data->size() <<
" samples)";
1552 out <<
" without data";
1561 auto iDigit = std::find_if(
1563 return digit.Channel() == channel;
1565 return (iDigit == digits.cend()) ?
nullptr : &*iDigit;
1568 std::vector<raw::RawDigit>
const* RawDigitCacheDataClass::ReadProduct(
art::Event const&
evt,
1572 if (!evt.
getByLabel(label, rdcol))
return nullptr;
1576 void RawDigitCacheDataClass::Refill(
art::Handle<std::vector<raw::RawDigit>>& rdcol)
1578 digits.resize(rdcol->size());
1579 for (
size_t iDigit = 0; iDigit < rdcol->size(); ++iDigit) {
1581 digits[iDigit].Fill(pDigit);
1582 size_t samples = pDigit->
Samples();
1583 if (samples > max_samples) max_samples = samples;
1587 void RawDigitCacheDataClass::Invalidate()
1592 void RawDigitCacheDataClass::Clear()
1617 if (
empty())
return res;
1619 if (!evt)
return res;
1623 if (!res.digits)
return res;
1625 if (res.digits->empty())
1631 if (!pInfo)
return res;
1633 if (&(pInfo->
Digit()) != &(res.digits->front()))
1636 res.bUpToDate =
true;
1644 if (update_info)
return false;
1646 MF_LOG_DEBUG(
"RawDataDrawer") <<
"Refilling raw digit cache RawDigitCacheDataClass[" 1647 << ((
void*)
this) <<
"] for " << new_timestamp;
1654 <<
"no RawDigit collection '" << new_timestamp.
inputLabel() <<
"' found";
1660 timestamp = new_timestamp;
1664 template <
typename Stream>
1665 void RawDigitCacheDataClass::Dump(Stream&& out)
const 1667 out <<
"Cache at " << ((
void*)
this) <<
" with time stamp " << std::string(timestamp)
1668 <<
" and " << digits.size() <<
" entries (maximum sample: " << max_samples <<
");" 1669 <<
" data at " << ((
void*)digits.data());
1672 digitInfo.Dump(out);
1680 std::ptrdiff_t GridAxisClass::GetCell(
float coord)
const 1682 return std::ptrdiff_t((coord - min) / cell_size);
1686 bool GridAxisClass::Init(
size_t nDiv,
float new_min,
float new_max)
1689 n_cells = std::max(nDiv,
size_t(1));
1690 return SetLimits(new_min, new_max);
1695 bool GridAxisClass::SetLimits(
float new_min,
float new_max)
1699 cell_size =
Length() / float(n_cells);
1701 return std::isnormal(cell_size);
1705 bool GridAxisClass::SetMinCellSize(
float min_size)
1707 if (cell_size >= min_size)
return false;
1710 n_cells = (size_t)std::max(std::floor(
Length() / min_size), 1.0F);
1714 cell_size =
Length() / float(n_cells);
1719 bool GridAxisClass::SetMaxCellSize(
float max_size)
1721 if (cell_size <= max_size)
return false;
1724 n_cells = (size_t)std::max(std::ceil(
Length() / max_size), 1.0F);
1728 cell_size =
Length() / float(n_cells);
1733 template <
typename Stream>
1734 void GridAxisClass::Dump(Stream&& out)
const 1736 out << NCells() <<
" cells from " << Min() <<
" to " << Max() <<
" (length: " <<
Length()
1743 CellGridClass::CellGridClass(
unsigned int nWires,
unsigned int nTDC)
1744 : wire_axis((size_t)nWires, 0., float(nWires)), tdc_axis((size_t)nTDC, 0., float(nTDC))
1750 unsigned int nWires,
1754 :
wire_axis((size_t)nWires, min_wire, max_wire),
tdc_axis((size_t)nTDC, min_tdc, max_tdc)
1772 std::ptrdiff_t iWireCell = (std::ptrdiff_t)(iCell / nTDCCells),
1773 iTDCCell = (std::ptrdiff_t)(iCell % nTDCCells);
1782 template <
typename Stream>
1785 out <<
"Wire axis: ";
1787 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.
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.
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
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.
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.
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
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
virtual bool ProcessWire(geo::WireID const &)
Encapsulate the construction of a single detector plane .
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)
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.
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.
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.
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.