LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ClusterParamsAlgBase.h
Go to the documentation of this file.
1 
14 #ifndef CLUSTERPARAMSALGBASE_H
15 #define CLUSTERPARAMSALGBASE_H
16 
17 // C/C++ standard libraries
18 #include <algorithm> // std::transform()
19 #include <stdexcept> // std::logic_error
20 #include <string>
21 #include <utility> // std::pair
22 #include <vector>
23 
24 // LArSoft libraries
26 
27 namespace util {
28  class GeometryUtilities;
29 }
30 
32 namespace cluster {
33 
35  namespace details {
36 
38  template <typename T>
39  class Measure_t : public std::pair<T, T> {
40  using Base_t = std::pair<T, T>;
41 
42  public:
43  using Data_t = T;
44 
46  Measure_t() : Base_t(Data_t(0), Data_t(0)) {}
47 
49  Measure_t(Data_t value) : Base_t(value, Data_t(0)) {}
50 
52  Measure_t(Data_t value, Data_t error) : Base_t(value, error) {}
53 
54  Data_t value() const { return Base_t::first; }
55  Data_t& value() { return Base_t::first; }
56 
57  Data_t error() const { return Base_t::second; }
58  Data_t& error() { return Base_t::second; }
59  }; // Measure_t
60 
61  } // namespace details
62 
87  public:
90 
91  virtual ~ClusterParamsAlgBase() = default;
92 
99  virtual void Clear() {}
100 
118  virtual void SetHitsFromPointers(util::GeometryUtilities const& gser,
119  std::vector<recob::Hit const*> const& hits) = 0;
120 
138  virtual void SetHits(util::GeometryUtilities const& gser, std::vector<recob::Hit> const& hits)
139  {
140  std::vector<recob::Hit const*> hitptrs;
141  hitptrs.reserve(hits.size());
142  std::transform(hits.begin(),
143  hits.end(),
144  std::back_inserter(hitptrs),
145  [](recob::Hit const& hit) { return &hit; });
146  SetHitsFromPointers(gser, hitptrs);
147  }
148 
150  virtual void SetVerbose(int level = 1) { verbose = level; }
151 
153 
158  {
159  throw NotImplemented(__func__);
160  }
161  virtual Measure_t EndCharge(util::GeometryUtilities const&) { throw NotImplemented(__func__); }
163 
165 
169  virtual Measure_t StartAngle() { throw NotImplemented(__func__); }
170  virtual Measure_t EndAngle() { throw NotImplemented(__func__); }
172 
174 
178  virtual Measure_t StartOpeningAngle() { throw NotImplemented(__func__); }
179  virtual Measure_t EndOpeningAngle() { throw NotImplemented(__func__); }
181 
184 
189  virtual Measure_t Integral() { throw NotImplemented(__func__); }
190 
198  virtual Measure_t IntegralStdDev() { throw NotImplemented(__func__); }
199 
205  virtual Measure_t SummedADC() { throw NotImplemented(__func__); }
206 
214  virtual Measure_t SummedADCStdDev() { throw NotImplemented(__func__); }
215 
217 
219  virtual size_t NHits() { throw NotImplemented(__func__); }
220 
230  virtual float MultipleHitDensity() { throw NotImplemented(__func__); }
231 
237  virtual float Width(util::GeometryUtilities const&) { throw NotImplemented(__func__); }
238 
239  protected:
240  int verbose = 0;
241 
242  static std::logic_error NotImplemented(std::string function_name)
243  {
244  return std::logic_error(function_name + "() not implemented.");
245  }
246 
247  }; //class ClusterParamsAlgBase
248 
249 } //namespace cluster
250 
251 #endif // CLUSTERPARAMSALGBASE_H
Namespace for general, non-LArSoft-specific utilities.
Definition: PIDAAlg.h:26
virtual Measure_t IntegralStdDev()
Computes the standard deviation on the charge of the cluster hits.
static std::logic_error NotImplemented(std::string function_name)
Declaration of signal hit object.
virtual void SetVerbose(int level=1)
Set the verbosity level.
virtual Measure_t StartCharge(util::GeometryUtilities const &)
Computes the charge on the first and last wire of the track.
virtual Measure_t EndCharge(util::GeometryUtilities const &)
Computes the charge on the first and last wire of the track.
Cluster finding and building.
virtual void Clear()
Restores the class to post-configuration, pre-initialization state.
virtual Measure_t EndAngle()
Computes the angle at the start or end of the cluster.
virtual void SetHits(util::GeometryUtilities const &gser, std::vector< recob::Hit > const &hits)
Sets the list of input hits.
Algorithm collection class computing cluster parameters.
virtual Measure_t SummedADCStdDev()
Computes the standard deviation on the charge of the cluster hits.
void hits()
Definition: readHits.C:15
Measure_t()
Default constructor: initializes to 0.
virtual Measure_t StartOpeningAngle()
Computes the opening angle at the start or end of the cluster.
Type for a simple measurement: value and error.
virtual Measure_t StartAngle()
Computes the angle at the start or end of the cluster.
virtual float MultipleHitDensity()
Fraction of wires in the cluster with more than one hit.
double value
Definition: spectrum.C:18
Detector simulation of raw signals on wires.
virtual Measure_t Integral()
Computes the total charge of the cluster from Hit::Integral()
virtual float Width(util::GeometryUtilities const &)
Computes the width of the cluster.
virtual Measure_t SummedADC()
Computes the total charge of the cluster from Hit::SummedADC()
Measure_t(Data_t value)
Constructor: initializes to the specified value, error is 0.
Measure_t(Data_t value, Data_t error)
Constructor: initializes to the specified value and error.
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:82
virtual Measure_t EndOpeningAngle()
Computes the opening angle at the start or end of the cluster.
virtual size_t NHits()
Returns the number of hits in the cluster.