LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
MCWireCollection.h
Go to the documentation of this file.
1 
2 #ifndef MCWIRECOLLECTION_H
3 #define MCWIRECOLLECTION_H
4 
5 // C++ includes
7 
8 namespace sim {
9 
10  class MCWireCollection : public std::vector<sim::MCWire> {
11 
12  public:
14  MCWireCollection(const unsigned int ch = sim::kINVALID_UINT)
15  {
16  Reset();
17  fChannel = ch;
18  }
19 
20  void Reset()
21  {
24  }
25 
26  private:
27  unsigned int fChannel;
28 
29  public:
31  unsigned int Channel() const { return fChannel; }
32 
34  inline bool operator<(const MCWireCollection& rhs) const { return fChannel < rhs.fChannel; }
35 
37  inline void push_back(const MCWire& wire)
38  {
39 
40  bool sort = (!empty() && wire < (*rbegin()));
41 
42  std::vector<sim::MCWire>::push_back(wire);
43 
44  if (sort) std::sort(begin(), end());
45  }
46  };
47 }
48 
49 // Define a pointer comparison
50 namespace std {
51  template <>
53  public:
55  {
56  return (*lhs) < (*rhs);
57  }
58  };
59 }
60 
61 #endif
STL namespace.
void push_back(const MCWire &wire)
wrapper for push_back
unsigned int Channel() const
Getter for channel number.
MCWireCollection(const unsigned int ch=sim::kINVALID_UINT)
Default ctor.
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
bool operator<(const MCWireCollection &rhs) const
For sorting.
Monte Carlo Simulation.
const unsigned int kINVALID_UINT
Definition: MCLimits.h:14
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
bool operator()(const sim::MCWireCollection *lhs, const sim::MCWireCollection *rhs)
vec_iX clear()
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:109