MCRecoEdep.h
Go to the documentation of this file.
1 #ifndef MCRECOEDEP_H
2 #define MCRECOEDEP_H
3 
4 // LArSoft
6 namespace sim {
7  class SimChannel;
8  class SimEnergyDeposit;
9 }
10 
11 // Framework includes
12 namespace fhicl { class ParameterSet; }
13 
14 // STL
15 #include <map>
16 #include <vector>
17 
18 namespace sim
19 {
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 
28  class MCEdepHit {
29 
30  public:
31 
32  //static const unsigned short kINVALID_USHORT;
33 
34  public:
35 
36  MCEdepHit(){ Clear(); }
37 
38  unsigned short timeStart;
39  unsigned short timeEnd;
40  unsigned short timeMax;
41  float qSum;
42  float qMax;
43  void Clear()
44  {
45  //timeStart = timeEnd = timeMax = kINVALID_USHORT;
46  timeStart = timeEnd = timeMax = 0;
47  qSum = qMax = 0;
48  }
49  };
50 
52  public:
53  double _x, _y, _z;
54 
55  public:
56  UniquePosition(double x=0, double y=0, double z=0)
57  { _x = x; _y = y; _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 
73 
74  struct MCEdep {
75  struct deposit{
76  float energy {};
77  float charge {};
78  deposit() = default;
79  deposit(float e, float c) : energy(e), charge(c) { }
80  };
81 
84  std::vector<deposit> deps {};
85 
86  MCEdep() = default;
87 
90  size_t num_planes,
91  float e, float c,
92  size_t id) :
93  pos(p), pid(pi), deps(num_planes) { deps[id].energy=e; deps[id].charge=c;}
94  };
95 
96  class MCRecoEdep {
97 
98  public:
99 
100  /// Default constructor with fhicl parameters
101  MCRecoEdep(fhicl::ParameterSet const& pset);
102  //ClusterMergeAlg(fhicl::ParameterSet const& pset, art::ActivityRegistry& reg);
103 
104  void MakeMCEdep(const std::vector<sim::SimChannel>& schArray);
105 
106  void MakeMCEdep(const std::vector<sim::SimEnergyDeposit>& sedArray);
107 
108  bool ExistTrack(const unsigned int track_id) const
109  { return (_track_index.find(track_id) != _track_index.end()); }
110 
111  /// Converts a track ID to MCEdep array index. Returns -1 if no corresponding array found .
112  int TrackToEdepIndex(unsigned int track_id) const
113  {
114  auto iter = _track_index.find(track_id);
115  return (iter == _track_index.end() ? -1 : (int)((*iter).second));
116  }
117 
118  /// Returns a vector of MCEdep object at the given index
119  const std::vector<sim::MCEdep>& GetEdepArrayAt(size_t edep_index) const;
120 
121  /// Returns a map of track id <-> MCEdep vector index
122  const std::map<unsigned int,size_t> TrackIndexMap() const
123  { return _track_index; }
124 
125  void Clear() {
126  _mc_edeps.clear();
127  _track_index.clear();
128  std::vector<std::vector<sim::MCEdep>>().swap(_mc_edeps);
129  std::map<unsigned int,size_t>().swap(_track_index);
130  }
131  protected:
132 
133  std::vector<sim::MCEdep>& __GetEdepArray__(unsigned int track_id);
134 
137  std::map<unsigned int,size_t> _track_index;
138  std::vector<std::vector<sim::MCEdep> > _mc_edeps;
139 
140  }; // class MCRecoEdep
141 
142 } //namespace cluster
143 #endif
MCEdep(sim::UniquePosition p, geo::PlaneID pi, size_t num_planes, float e, float c, size_t id)
Definition: MCRecoEdep.h:88
bool operator<(const UniquePosition &rhs) const
Definition: MCRecoEdep.h:60
void Clear()
Definition: MCRecoEdep.h:43
unsigned short timeEnd
Definition: MCRecoEdep.h:39
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
std::map< geo::PlaneID, size_t > createPlaneIndexMap()
Definition: MCRecoEdep.cxx:22
unsigned short timeMax
Definition: MCRecoEdep.h:40
const double e
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:112
void swap(Handle< T > &a, Handle< T > &b)
bool ExistTrack(const unsigned int track_id) const
Definition: MCRecoEdep.h:108
p
Definition: test.py:223
unsigned short timeStart
Definition: MCRecoEdep.h:38
Code to link reconstructed objects back to the MC truth information.
Definition of data types for geometry description.
std::vector< std::vector< sim::MCEdep > > _mc_edeps
Definition: MCRecoEdep.h:138
deposit(float e, float c)
Definition: MCRecoEdep.h:79
UniquePosition(double x=0, double y=0, double z=0)
Definition: MCRecoEdep.h:56
std::map< unsigned int, size_t > _track_index
Definition: MCRecoEdep.h:137
list x
Definition: train.py:276
float pi
Definition: units.py:11
const std::map< unsigned int, size_t > TrackIndexMap() const
Returns a map of track id <-> MCEdep vector index.
Definition: MCRecoEdep.h:122