All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MCHitCollection.h
Go to the documentation of this file.
1 
2 #ifndef MCHITCOLLECTION_H
3 #define MCHITCOLLECTION_H
4 
5 // C++ includes
6 #include <vector>
8 
9 namespace sim {
10 
11  class MCHitCollection : public std::vector<sim::MCHit> {
12 
13  public:
14 
15  /// Default ctor
16  MCHitCollection(const unsigned int ch= ::sim::kINVALID_UINT)
17  {
18  Reset();
19  fChannel = ch;
20  }
21 
22  /// Method to reset
23  void Reset()
24  {
26  std::vector<sim::MCHit>::clear();
27  }
28 
29  private:
30 
31  unsigned int fChannel; ///< Channel number
32 
33 
34  public:
35 
36  /// Getter for channel number
37  unsigned int Channel() const { return fChannel; }
38 
39  /// For sorting
40  inline bool operator< ( const MCHitCollection& rhs ) const { return fChannel < rhs.fChannel; }
41 
42  /// wrapper for push_back
43  inline void push_back(const MCHit& hit)
44  {
45 
46  bool sort = (!empty() && hit < (*rbegin()));
47 
48  std::vector<sim::MCHit>::push_back(hit);
49 
50  if(sort) std::sort(begin(),end());
51 
52  }
53  };
54 }
55 
56 // Define a pointer comparison
57 namespace std {
58  template <>
59  class less<sim::MCHitCollection*>
60  {
61  public:
62  bool operator()( const sim::MCHitCollection* lhs, const sim::MCHitCollection* rhs )
63  { return (*lhs) < (*rhs); }
64  };
65 }
66 
67 #endif
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
void push_back(const MCHit &hit)
wrapper for push_back
process_name hit
Definition: cheaterreco.fcl:51
void Reset()
Method to reset.
bool operator()(const sim::MCHitCollection *lhs, const sim::MCHitCollection *rhs)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
unsigned int fChannel
Channel number.
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
unsigned int Channel() const
Getter for channel number.
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
const unsigned int kINVALID_UINT
Definition: MCLimits.h:14
bool operator<(const MCHitCollection &rhs) const
For sorting.
MCHitCollection(const unsigned int ch=::sim::kINVALID_UINT)
Default ctor.
bool empty(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:555