LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
MCHitCollection.h
Go to the documentation of this file.
1 
2 #ifndef MCHITCOLLECTION_H
3 #define MCHITCOLLECTION_H
4 
5 // C++ includes
7 #include <vector>
8 
9 namespace sim {
10 
11  class MCHitCollection : public std::vector<sim::MCHit> {
12 
13  public:
15  MCHitCollection(const unsigned int ch = ::sim::kINVALID_UINT)
16  {
17  Reset();
18  fChannel = ch;
19  }
20 
22  void Reset()
23  {
26  }
27 
28  private:
29  unsigned int fChannel;
30 
31  public:
33  unsigned int Channel() const { return fChannel; }
34 
36  inline bool operator<(const MCHitCollection& rhs) const { return fChannel < rhs.fChannel; }
37 
39  inline void push_back(const MCHit& hit)
40  {
41 
42  bool sort = (!empty() && hit < (*rbegin()));
43 
44  std::vector<sim::MCHit>::push_back(hit);
45 
46  if (sort) std::sort(begin(), end());
47  }
48  };
49 }
50 
51 // Define a pointer comparison
52 namespace std {
53  template <>
55  public:
57  {
58  return (*lhs) < (*rhs);
59  }
60  };
61 }
62 
63 #endif
void push_back(const MCHit &hit)
wrapper for push_back
STL namespace.
void Reset()
Method to reset.
bool operator()(const sim::MCHitCollection *lhs, const sim::MCHitCollection *rhs)
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
unsigned int fChannel
Channel number.
Monte Carlo Simulation.
Detector simulation of raw signals on wires.
unsigned int Channel() const
Getter for channel number.
const unsigned int kINVALID_UINT
Definition: MCLimits.h:14
bool operator<(const MCHitCollection &rhs) const
For sorting.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
MCHitCollection(const unsigned int ch=::sim::kINVALID_UINT)
Default ctor.
vec_iX clear()
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:109