PmaTrkCandidate.h
Go to the documentation of this file.
1 /**
2  * @file PmaTrkCandidate.h
3  *
4  * @author D.Stefan and R.Sulej
5  *
6  * @brief Track finding helper for the Projection Matching Algorithm
7  *
8  * Candidate for 3D track. Used to test 2D cluster associations, validadion result, MSE value.
9  * See PmaTrack3D.h file for details.
10  */
11 
12 #ifndef TrkCandidate_h
13 #define TrkCandidate_h
14 
16 
17 namespace detinfo {
18  class DetectorPropertiesData;
19 }
20 
21 namespace pma {
22  // these types to be replaced with use of feature proposed in redmine #12602
23  typedef std::map<unsigned int, std::vector<art::Ptr<recob::Hit>>> view_hitmap;
24  typedef std::map<unsigned int, view_hitmap> tpc_view_hitmap;
25  typedef std::map<unsigned int, tpc_view_hitmap> cryo_tpc_view_hitmap;
26 
27  class Track3D;
28  class TrkCandidate;
29  class TrkCandidateColl;
30 }
31 
33 public:
34  TrkCandidate();
35  TrkCandidate(pma::Track3D* trk, int key = -1, int tid = -1);
36 
37  bool
38  IsValid() const
39  {
40  return fTrack;
41  }
42 
43  bool
44  IsGood() const
45  {
46  return fGood;
47  }
48  void
49  SetGood(bool b)
50  {
51  fGood = b;
52  }
53 
55  Track() const
56  {
57  return fTrack;
58  }
59  void SetTrack(pma::Track3D* trk);
60  void DeleteTrack();
61 
62  const std::vector<size_t>&
63  Clusters() const
64  {
65  return fClusters;
66  }
67  std::vector<size_t>&
69  {
70  return fClusters;
71  }
72 
73  /// Get key of an external object (like a source PFParticle) associated to this track candidate.
74  int
75  Key() const
76  {
77  return fKey;
78  }
79 
80  /// Set key of an external object associated to this track candidate.
81  void
82  SetKey(int key)
83  {
84  fKey = key;
85  }
86 
87  int
88  TreeId() const
89  {
90  return fTreeId;
91  }
92  void
93  SetTreeId(int id)
94  {
95  fTreeId = id;
96  }
97 
98  double
99  Mse() const
100  {
101  return fMse;
102  }
103  void
104  SetMse(double m)
105  {
106  fMse = m;
107  }
108 
109  double
110  Validation() const
111  {
112  return fValidation;
113  }
114  void
115  SetValidation(double v)
116  {
117  fValidation = v;
118  }
119 
120  int
121  Parent() const
122  {
123  return fParent;
124  }
125  void
126  SetParent(int idx)
127  {
128  fParent = idx;
129  }
130 
131  const std::vector<size_t>&
132  Daughters() const
133  {
134  return fDaughters;
135  }
136  std::vector<size_t>&
138  {
139  return fDaughters;
140  }
141 
142 private:
143  int fParent;
144  std::vector<size_t> fDaughters;
145 
147  std::vector<size_t> fClusters;
148  int fKey, fTreeId;
149 
150  double fMse, fValidation;
151 
152  bool fGood;
153 };
154 
156 public:
157  size_t
158  size() const
159  {
160  return fCandidates.size();
161  }
162  void
163  resize(size_t n)
164  {
165  return fCandidates.resize(n);
166  }
167  bool
168  empty() const
169  {
170  return fCandidates.empty();
171  }
172 
173  void
175  {
176  fCandidates.push_back(trk);
177  }
178  void
179  erase_at(size_t pos)
180  {
181  fCandidates.erase(fCandidates.begin() + pos);
182  }
183  void
185  {
186  fCandidates.clear();
187  }
188 
189  TrkCandidate& operator[](size_t i) { return fCandidates[i]; }
190  TrkCandidate const& operator[](size_t i) const { return fCandidates[i]; }
191 
192  TrkCandidate&
194  {
195  return fCandidates.front();
196  }
197  TrkCandidate const&
198  front() const
199  {
200  return fCandidates.front();
201  }
202 
203  TrkCandidate&
205  {
206  return fCandidates.back();
207  }
208  TrkCandidate const&
209  back() const
210  {
211  return fCandidates.back();
212  }
213 
214  std::vector<TrkCandidate> const&
215  tracks() const
216  {
217  return fCandidates;
218  }
219  std::vector<TrkCandidate>&
221  {
222  return fCandidates;
223  }
224 
225  std::vector<TrkCandidate> const&
226  parents() const
227  {
228  return fParents;
229  }
230 
231  int getCandidateIndex(pma::Track3D const* candidate) const;
232  int getCandidateTreeId(pma::Track3D const* candidate) const;
233 
234  void merge(size_t idx1, size_t idx2);
235 
236  void setParentDaughterConnections();
237 
238  void setTreeId(int id, size_t trkIdx, bool isRoot = true);
239  int setTreeIds();
240 
241  void flipTreesToCoordinate(detinfo::DetectorPropertiesData const& detProp, size_t coordinate);
242  void flipTreesByDQdx();
243 
244  bool setTreeOriginAtFront(detinfo::DetectorPropertiesData const& detProp, pma::Track3D* trk);
245  bool setTreeOriginAtBack(detinfo::DetectorPropertiesData const& detProp, pma::Track3D* trk);
246 
247  pma::Track3D* getTreeCopy(pma::TrkCandidateColl& dst, size_t trkIdx, bool isRoot = true);
248 
249 private:
250  std::vector<TrkCandidate> fCandidates;
251  std::vector<TrkCandidate> fParents;
252 };
253 
254 #endif
TrkCandidate & back()
size_t size() const
bool IsValid() const
std::vector< TrkCandidate > fCandidates
Implementation of the Projection Matching Algorithm.
void SetKey(int key)
Set key of an external object associated to this track candidate.
int Key() const
Get key of an external object (like a source PFParticle) associated to this track candidate...
TrkCandidate const & back() const
bool IsGood() const
void erase_at(size_t pos)
std::vector< TrkCandidate > const & parents() const
void SetGood(bool b)
std::map< unsigned int, tpc_view_hitmap > cryo_tpc_view_hitmap
void SetValidation(double v)
double Validation() const
std::map< unsigned int, view_hitmap > tpc_view_hitmap
std::vector< TrkCandidate > fParents
TrkCandidate const & front() const
def key(type, name=None)
Definition: graph.py:13
int TreeId() const
std::void_t< T > n
int Parent() const
std::vector< size_t > fDaughters
std::map< unsigned int, std::vector< art::Ptr< recob::Hit > > > view_hitmap
void SetTreeId(int id)
void SetMse(double m)
General LArSoft Utilities.
TrkCandidate const & operator[](size_t i) const
std::vector< size_t > fClusters
void SetParent(int idx)
pma::Track3D * fTrack
const std::vector< size_t > & Clusters() const
static bool * b
Definition: config.cpp:1043
std::vector< size_t > & Daughters()
const std::vector< size_t > & Daughters() const
std::vector< size_t > & Clusters()
TrkCandidate & operator[](size_t i)
pma::Track3D * Track() const
TrkCandidate & front()
void push_back(const TrkCandidate &trk)
std::vector< TrkCandidate > const & tracks() const
double Mse() const
std::vector< TrkCandidate > & tracks()