Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PointIdAlgTools::IPointIdAlg Class Referenceabstract

#include <IPointIdAlg.h>

Inheritance diagram for PointIdAlgTools::IPointIdAlg:
img::DataProviderAlg PointIdAlgTools::PointIdAlgKeras PointIdAlgTools::PointIdAlgSonicTriton PointIdAlgTools::PointIdAlgTf PointIdAlgTools::PointIdAlgTriton

Classes

struct  Config
 

Public Member Functions

virtual ~IPointIdAlg () noexcept=default
 
virtual std::vector< float > Run (std::vector< std::vector< float >> const &inp2d) const =0
 
virtual std::vector< std::vector< float > > Run (std::vector< std::vector< std::vector< float >>> const &inps, int samples=-1) const =0
 
float predictIdValue (unsigned int wire, float drift, size_t outIdx=0)
 
std::vector< float > predictIdVector (unsigned int wire, float drift)
 
std::vector< std::vector< float > > predictIdVectors (const std::vector< std::pair< unsigned int, float >> &points)
 
std::vector< std::string > const & outputLabels (void) const
 
bool isInsideFiducialRegion (unsigned int wire, float drift) const
 
- Public Member Functions inherited from img::DataProviderAlg
 DataProviderAlg (const fhicl::ParameterSet &pset)
 
 DataProviderAlg (const Config &config)
 
virtual ~DataProviderAlg ()
 
bool setWireDriftData (const detinfo::DetectorClocksData &clock_data, const detinfo::DetectorPropertiesData &det_prop, const std::vector< recob::Wire > &wires, unsigned int plane, unsigned int tpc, unsigned int cryo)
 
std::vector< float > const & wireData (size_t widx) const
 
std::vector< std::vector< float > > getPatch (size_t wire, float drift, size_t patchSizeW, size_t patchSizeD) const
 
float getPixelOrZero (int wire, int drift) const
 
double getAdcSum () const
 
size_t getAdcArea () const
 
float poolMax (int wire, int drift, size_t r=0) const
 Pool max value in a patch around the wire/drift pixel. More...
 
unsigned int Cryo () const
 Pool sum of pixels in a patch around the wire/drift pixel. More...
 
unsigned int TPC () const
 
unsigned int Plane () const
 
unsigned int NWires () const
 
unsigned int NScaledDrifts () const
 
unsigned int NCachedDrifts () const
 
unsigned int DriftWindow () const
 
float ZeroLevel () const
 Level of zero ADC after scaling. More...
 
double LifetimeCorrection (detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, double tick) const
 

Protected Member Functions

bool bufferPatch (size_t wire, float drift, std::vector< std::vector< float >> &patch)
 
bool bufferPatch (size_t wire, float drift)
 
void resizePatch (void)
 
- Protected Member Functions inherited from img::DataProviderAlg
std::vector< float > downscaleMax (std::size_t dst_size, std::vector< float > const &adc, size_t tick0) const
 
std::vector< float > downscaleMaxMean (std::size_t dst_size, std::vector< float > const &adc, size_t tick0) const
 
std::vector< float > downscaleMean (std::size_t dst_size, std::vector< float > const &adc, size_t tick0) const
 
std::vector< float > downscale (std::size_t dst_size, std::vector< float > const &adc, size_t tick0) const
 
size_t getDriftIndex (float drift) const
 
std::optional< std::vector< float > > setWireData (std::vector< float > const &adc, size_t wireIdx) const
 
bool patchFromDownsampledView (size_t wire, float drift, size_t size_w, size_t size_d, std::vector< std::vector< float >> &patch) const
 
bool patchFromOriginalView (size_t wire, float drift, size_t size_w, size_t size_d, std::vector< std::vector< float >> &patch) const
 
virtual DataProviderAlgView resizeView (detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, size_t wires, size_t drifts)
 

Protected Attributes

std::vector< std::stringfNNetOutputs
 
size_t fPatchSizeW
 
size_t fPatchSizeD
 
std::vector< std::vector< float > > fWireDriftPatch
 
size_t fCurrentWireIdx
 
size_t fCurrentScaledDrift
 
- Protected Attributes inherited from img::DataProviderAlg
DataProviderAlgView fAlgView
 
EDownscaleMode fDownscaleMode
 
size_t fDriftWindow
 
bool fDownscaleFullView
 
float fDriftWindowInv
 
calo::CalorimetryAlg fCalorimetryAlg
 
geo::GeometryCore const * fGeometry
 

Additional Inherited Members

- Public Types inherited from img::DataProviderAlg
enum  EDownscaleMode { kMax = 1, kMaxMean = 2, kMean = 3 }
 

Detailed Description

Definition at line 25 of file IPointIdAlg.h.

Constructor & Destructor Documentation

virtual PointIdAlgTools::IPointIdAlg::~IPointIdAlg ( )
virtualdefaultnoexcept

Member Function Documentation

bool PointIdAlgTools::IPointIdAlg::bufferPatch ( size_t  wire,
float  drift,
std::vector< std::vector< float >> &  patch 
)
inlineprotected

Definition at line 158 of file IPointIdAlg.h.

159  {
160  if (fDownscaleFullView) {
161  size_t sd = (size_t)(drift / fDriftWindow);
162  if ((fCurrentWireIdx == wire) && (fCurrentScaledDrift == sd))
163  return true; // still within the current position
164 
165  fCurrentWireIdx = wire;
166  fCurrentScaledDrift = sd;
167 
168  return patchFromDownsampledView(wire, drift, fPatchSizeW, fPatchSizeD, patch);
169  }
170  else {
171  if ((fCurrentWireIdx == wire) && (fCurrentScaledDrift == drift))
172  return true; // still within the current position
173 
174  fCurrentWireIdx = wire;
175  fCurrentScaledDrift = drift;
176 
177  return patchFromOriginalView(wire, drift, fPatchSizeW, fPatchSizeD, patch);
178  }
179  }
bool patchFromOriginalView(size_t wire, float drift, size_t size_w, size_t size_d, std::vector< std::vector< float >> &patch) const
bool patchFromDownsampledView(size_t wire, float drift, size_t size_w, size_t size_d, std::vector< std::vector< float >> &patch) const
bool PointIdAlgTools::IPointIdAlg::bufferPatch ( size_t  wire,
float  drift 
)
inlineprotected

Definition at line 182 of file IPointIdAlg.h.

183  {
184  return bufferPatch(wire, drift, fWireDriftPatch);
185  }
std::vector< std::vector< float > > fWireDriftPatch
Definition: IPointIdAlg.h:154
bool bufferPatch(size_t wire, float drift, std::vector< std::vector< float >> &patch)
Definition: IPointIdAlg.h:158
bool PointIdAlgTools::IPointIdAlg::isInsideFiducialRegion ( unsigned int  wire,
float  drift 
) const
inline

Definition at line 136 of file IPointIdAlg.h.

137  {
138  size_t marginW = fPatchSizeW / 8; // fPatchSizeX/2 will make patch always completely filled
139  size_t marginD = fPatchSizeD / 8;
140 
141  size_t scaledDrift = (size_t)(drift / fDriftWindow);
142  if ((wire >= marginW) && (wire < fAlgView.fNWires - marginW) && (scaledDrift >= marginD) &&
143  (scaledDrift < fAlgView.fNScaledDrifts - marginD)) {
144  return true;
145  }
146  else {
147  return false;
148  }
149  }
DataProviderAlgView fAlgView
std::vector<std::string> const& PointIdAlgTools::IPointIdAlg::outputLabels ( void  ) const
inline

Definition at line 131 of file IPointIdAlg.h.

132  {
133  return fNNetOutputs;
134  }
std::vector< std::string > fNNetOutputs
Definition: IPointIdAlg.h:152
float PointIdAlgTools::IPointIdAlg::predictIdValue ( unsigned int  wire,
float  drift,
size_t  outIdx = 0 
)
inline

Definition at line 75 of file IPointIdAlg.h.

76  {
77  float result = 0.;
78 
79  if (!bufferPatch(wire, drift)) {
80  mf::LogError("PointIdAlg") << "Patch buffering failed.";
81  return result;
82  }
83 
84  auto out = Run(fWireDriftPatch);
85  if (!out.empty()) { result = out[outIdx]; }
86  else {
87  mf::LogError("PointIdAlg") << "Problem with applying model to input.";
88  }
89 
90  return result;
91  }
std::vector< std::vector< float > > fWireDriftPatch
Definition: IPointIdAlg.h:154
static QCString result
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
bool bufferPatch(size_t wire, float drift, std::vector< std::vector< float >> &patch)
Definition: IPointIdAlg.h:158
virtual std::vector< float > Run(std::vector< std::vector< float >> const &inp2d) const =0
std::vector<float> PointIdAlgTools::IPointIdAlg::predictIdVector ( unsigned int  wire,
float  drift 
)
inline

Definition at line 95 of file IPointIdAlg.h.

96  {
97  std::vector<float> result;
98 
99  if (!bufferPatch(wire, drift)) {
100  mf::LogError("PointIdAlg") << "Patch buffering failed.";
101  return result;
102  }
103 
104  result = Run(fWireDriftPatch);
105  if (result.empty()) { mf::LogError("PointIdAlg") << "Problem with applying model to input."; }
106 
107  return result;
108  }
std::vector< std::vector< float > > fWireDriftPatch
Definition: IPointIdAlg.h:154
static QCString result
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
bool bufferPatch(size_t wire, float drift, std::vector< std::vector< float >> &patch)
Definition: IPointIdAlg.h:158
virtual std::vector< float > Run(std::vector< std::vector< float >> const &inp2d) const =0
std::vector<std::vector<float> > PointIdAlgTools::IPointIdAlg::predictIdVectors ( const std::vector< std::pair< unsigned int, float >> &  points)
inline

Definition at line 112 of file IPointIdAlg.h.

113  {
114  if (points.empty()) { return std::vector<std::vector<float>>(); }
115 
116  std::vector<std::vector<std::vector<float>>> inps(
117  points.size(),
118  std::vector<std::vector<float>>(fPatchSizeW, std::vector<float>(fPatchSizeD)));
119  for (size_t i = 0; i < points.size(); ++i) {
120  unsigned int wire = points[i].first;
121  float drift = points[i].second;
122  if (!bufferPatch(wire, drift, inps[i])) {
123  throw cet::exception("PointIdAlg") << "Patch buffering failed" << std::endl;
124  }
125  }
126 
127  return Run(inps);
128  }
bool bufferPatch(size_t wire, float drift, std::vector< std::vector< float >> &patch)
Definition: IPointIdAlg.h:158
virtual std::vector< float > Run(std::vector< std::vector< float >> const &inp2d) const =0
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
void PointIdAlgTools::IPointIdAlg::resizePatch ( void  )
inlineprotected

Definition at line 188 of file IPointIdAlg.h.

189  {
191  for (auto& r : fWireDriftPatch)
192  r.resize(fPatchSizeD);
193  }
std::vector< std::vector< float > > fWireDriftPatch
Definition: IPointIdAlg.h:154
virtual std::vector<float> PointIdAlgTools::IPointIdAlg::Run ( std::vector< std::vector< float >> const &  inp2d) const
pure virtual
virtual std::vector<std::vector<float> > PointIdAlgTools::IPointIdAlg::Run ( std::vector< std::vector< std::vector< float >>> const &  inps,
int  samples = -1 
) const
pure virtual

Member Data Documentation

size_t PointIdAlgTools::IPointIdAlg::fCurrentScaledDrift
protected

Definition at line 155 of file IPointIdAlg.h.

size_t PointIdAlgTools::IPointIdAlg::fCurrentWireIdx
protected

Definition at line 155 of file IPointIdAlg.h.

std::vector<std::string> PointIdAlgTools::IPointIdAlg::fNNetOutputs
protected

Definition at line 152 of file IPointIdAlg.h.

size_t PointIdAlgTools::IPointIdAlg::fPatchSizeD
protected

Definition at line 153 of file IPointIdAlg.h.

size_t PointIdAlgTools::IPointIdAlg::fPatchSizeW
protected

Definition at line 153 of file IPointIdAlg.h.

std::vector<std::vector<float> > PointIdAlgTools::IPointIdAlg::fWireDriftPatch
protected

Definition at line 154 of file IPointIdAlg.h.


The documentation for this class was generated from the following file: