LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
MCDataHolder.h
Go to the documentation of this file.
1 #ifndef MCDATAHOLDER_H
2 #define MCDATAHOLDER_H
3 
5 #include <algorithm>
6 #include <array>
7 
8 namespace sim {
9 
10  class MCEnDep {
11 
12  public:
13  MCEnDep() { Reset(); }
14  ~MCEnDep() {}
15 
16  protected:
17  std::array<float, 3> fVertex;
18  float fEnergy;
19  unsigned int fTrackId;
20 
21  public:
22  void Reset()
23  {
24  fVertex.fill(::sim::kINVALID_FLOAT);
25  fEnergy = ::sim::kINVALID_FLOAT;
26  fTrackId = ::sim::kINVALID_UINT;
27  }
28 
29  void SetVertex(float x, float y, float z)
30  {
31  fVertex.at(0) = x;
32  fVertex.at(1) = y;
33  fVertex.at(2) = z;
34  }
35 
36  void SetEnergy(float e) { fEnergy = e; }
37 
38  void SetTrackId(unsigned int id) { fTrackId = id; }
39 
40  const std::array<float, 3>& Vertex() const { return fVertex; }
41 
42  float Energy() const { return fEnergy; }
43 
44  unsigned int TrackId() const { return fTrackId; }
45 
46  inline bool operator<(const MCEnDep& e) const
47  {
48  if (fTrackId < e.fTrackId) return true;
49  if (fTrackId > e.fTrackId) return false;
50 
51  if (fVertex.at(0) < e.fVertex.at(0)) return true;
52  if (fVertex.at(0) > e.fVertex.at(0)) return false;
53 
54  if (fVertex.at(1) < e.fVertex.at(1)) return true;
55  if (fVertex.at(1) > e.fVertex.at(1)) return false;
56 
57  if (fVertex.at(2) < e.fVertex.at(2)) return true;
58  if (fVertex.at(2) > e.fVertex.at(2)) return false;
59 
60  if (fEnergy < e.fEnergy) return true;
61  if (fEnergy > e.fEnergy) return false;
62 
63  return false;
64  }
65  };
66 }
67 
68 namespace std {
69  template <>
70  class less<sim::MCEnDep*> {
71  public:
72  bool operator()(const sim::MCEnDep* lhs, const sim::MCEnDep* rhs) { return (*lhs) < (*rhs); }
73  };
74 }
75 
76 #endif
Float_t x
Definition: compare.C:6
static constexpr float kINVALID_FLOAT
Definition: TruncMean.h:32
unsigned int fTrackId
Definition: MCDataHolder.h:19
void SetEnergy(float e)
Definition: MCDataHolder.h:36
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:276
bool operator()(const sim::MCEnDep *lhs, const sim::MCEnDep *rhs)
Definition: MCDataHolder.h:72
STL namespace.
void SetTrackId(unsigned int id)
Definition: MCDataHolder.h:38
std::array< float, 3 > fVertex
Definition: MCDataHolder.h:17
unsigned int TrackId() const
Definition: MCDataHolder.h:44
void SetVertex(float x, float y, float z)
Definition: MCDataHolder.h:29
void Reset()
Definition: MCDataHolder.h:22
Monte Carlo Simulation.
float Energy() const
Definition: MCDataHolder.h:42
const unsigned int kINVALID_UINT
Definition: MCLimits.h:14
bool operator<(const MCEnDep &e) const
Definition: MCDataHolder.h:46
Float_t e
Definition: plot.C:35
const std::array< float, 3 > & Vertex() const
Definition: MCDataHolder.h:40
const float kINVALID_FLOAT
Definition: MCLimits.h:12