LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
MCRecoEdep.h
Go to the documentation of this file.
1 #ifndef MCRECOEDEP_H
2 #define MCRECOEDEP_H
3 
4 // LArSoft
9 
10 // Framework includes
11 namespace fhicl {
12  class ParameterSet;
13 }
14 
15 // STL
16 #include <map>
17 #include <vector>
18 
19 namespace sim {
20 
21  namespace details {
22  // Returns a map with all available plane IDs,
23  // each mapped into an index from a compact range.
24  std::map<geo::PlaneID, size_t> createPlaneIndexMap();
25  } // namespace details
26 
27  class MCEdepHit {
28 
29  public:
30  //static const unsigned short kINVALID_USHORT;
31 
32  public:
33  MCEdepHit() { Clear(); }
34 
35  unsigned short timeStart;
36  unsigned short timeEnd;
37  unsigned short timeMax;
38  float qSum;
39  float qMax;
40  void Clear()
41  {
42  //timeStart = timeEnd = timeMax = kINVALID_USHORT;
43  timeStart = timeEnd = timeMax = 0;
44  qSum = qMax = 0;
45  }
46  };
47 
49  public:
50  double _x, _y, _z;
51 
52  public:
53  UniquePosition(double x = 0, double y = 0, double z = 0)
54  {
55  _x = x;
56  _y = y;
57  _z = z;
58  }
59 
60  inline bool operator<(const UniquePosition& rhs) const
61  {
62  if (_x < rhs._x) return true;
63  if (rhs._x < _x) return false;
64  if (_y < rhs._y) return true;
65  if (rhs._y < _y) return false;
66  if (_z < rhs._z) return true;
67  if (rhs._z < _z) return false;
68  return false;
69  }
70  };
71 
72  struct MCEdep {
73  struct deposit {
74  float energy{};
75  float charge{};
76  deposit() = default;
77  deposit(float e, float c) : energy(e), charge(c) {}
78  };
79 
82  std::vector<deposit> deps{};
83 
84  MCEdep() = default;
85 
86  MCEdep(sim::UniquePosition p, geo::PlaneID pi, size_t num_planes, float e, float c, size_t id)
87  : pos(p), pid(pi), deps(num_planes)
88  {
89  deps[id].energy = e;
90  deps[id].charge = c;
91  }
92  };
93 
94  class MCRecoEdep {
95 
96  public:
98  MCRecoEdep(fhicl::ParameterSet const& pset);
99  //ClusterMergeAlg(fhicl::ParameterSet const& pset, art::ActivityRegistry& reg);
100 
101  void MakeMCEdep(const std::vector<sim::SimChannel>& schArray);
102 
103  void MakeMCEdep(const std::vector<sim::SimEnergyDeposit>& sedArray);
104 
105  void MakeMCEdep(const std::vector<sim::SimEnergyDepositLite>& sedArray);
106 
107  bool ExistTrack(const unsigned int track_id) const
108  {
109  return (_track_index.find(track_id) != _track_index.end());
110  }
111 
113  int TrackToEdepIndex(unsigned int track_id) const
114  {
115  auto iter = _track_index.find(track_id);
116  return (iter == _track_index.end() ? -1 : (int)((*iter).second));
117  }
118 
120  const std::vector<sim::MCEdep>& GetEdepArrayAt(size_t edep_index) const;
121 
123  const std::map<unsigned int, size_t> TrackIndexMap() const { return _track_index; }
124 
125  void Clear()
126  {
127  _mc_edeps.clear();
128  _track_index.clear();
129  std::vector<std::vector<sim::MCEdep>>().swap(_mc_edeps);
130  std::map<unsigned int, size_t>().swap(_track_index);
131  }
132 
133  protected:
134  std::vector<sim::MCEdep>& __GetEdepArray__(unsigned int track_id);
135 
138  std::map<unsigned int, size_t> _track_index;
139  std::vector<std::vector<sim::MCEdep>> _mc_edeps;
140 
141  }; // class MCRecoEdep
142 
143 } //namespace cluster
144 #endif
Float_t x
Definition: compare.C:6
MCEdep(sim::UniquePosition p, geo::PlaneID pi, size_t num_planes, float e, float c, size_t id)
Definition: MCRecoEdep.h:86
bool operator<(const UniquePosition &rhs) const
Definition: MCRecoEdep.h:60
void Clear()
Definition: MCRecoEdep.h:40
Float_t y
Definition: compare.C:6
unsigned short timeEnd
Definition: MCRecoEdep.h:36
Double_t z
Definition: plot.C:276
The data type to uniquely identify a Plane.
Definition: geo_types.h:463
std::map< geo::PlaneID, size_t > createPlaneIndexMap()
Definition: MCRecoEdep.cxx:26
unsigned short timeMax
Definition: MCRecoEdep.h:37
int TrackToEdepIndex(unsigned int track_id) const
Converts a track ID to MCEdep array index. Returns -1 if no corresponding array found ...
Definition: MCRecoEdep.h:113
bool ExistTrack(const unsigned int track_id) const
Definition: MCRecoEdep.h:107
parameter set interface
double energy
Definition: plottest35.C:25
const std::map< unsigned int, size_t > TrackIndexMap() const
Returns a map of track id <-> MCEdep vector index.
Definition: MCRecoEdep.h:123
contains information for a single step in the detector simulation (pared down in size to the essentia...
std::map< unsigned int, size_t > _track_index
Definition: MCRecoEdep.h:138
unsigned short timeStart
Definition: MCRecoEdep.h:35
Monte Carlo Simulation.
Definition of data types for geometry description.
std::vector< std::vector< sim::MCEdep > > _mc_edeps
Definition: MCRecoEdep.h:139
deposit(float e, float c)
Definition: MCRecoEdep.h:77
UniquePosition(double x=0, double y=0, double z=0)
Definition: MCRecoEdep.h:53
contains information for a single step in the detector simulation
object containing MC truth information necessary for making RawDigits and doing back tracking ...
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
Float_t e
Definition: plot.C:35