All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 #include <map>
22 #include <vector>
23 
24 namespace pma {
25  // these types to be replaced with use of feature proposed in redmine #12602
26  typedef std::map<unsigned int, std::vector<art::Ptr<recob::Hit>>> view_hitmap;
27  typedef std::map<unsigned int, view_hitmap> tpc_view_hitmap;
28  typedef std::map<unsigned int, tpc_view_hitmap> cryo_tpc_view_hitmap;
29 
30  class Track3D;
31  class TrkCandidate;
32  class TrkCandidateColl;
33 }
34 
36 public:
37  TrkCandidate();
38  TrkCandidate(pma::Track3D* trk, int key = -1, int tid = -1);
39 
40  bool
41  IsValid() const
42  {
43  return fTrack;
44  }
45 
46  bool
47  IsGood() const
48  {
49  return fGood;
50  }
51  void
52  SetGood(bool b)
53  {
54  fGood = b;
55  }
56 
58  Track() const
59  {
60  return fTrack;
61  }
62  void SetTrack(pma::Track3D* trk);
63  void DeleteTrack();
64 
65  const std::vector<size_t>&
66  Clusters() const
67  {
68  return fClusters;
69  }
70  std::vector<size_t>&
72  {
73  return fClusters;
74  }
75 
76  /// Get key of an external object (like a source PFParticle) associated to this track candidate.
77  int
78  Key() const
79  {
80  return fKey;
81  }
82 
83  /// Set key of an external object associated to this track candidate.
84  void
85  SetKey(int key)
86  {
87  fKey = key;
88  }
89 
90  int
91  TreeId() const
92  {
93  return fTreeId;
94  }
95  void
96  SetTreeId(int id)
97  {
98  fTreeId = id;
99  }
100 
101  double
102  Mse() const
103  {
104  return fMse;
105  }
106  void
107  SetMse(double m)
108  {
109  fMse = m;
110  }
111 
112  double
113  Validation() const
114  {
115  return fValidation;
116  }
117  void
118  SetValidation(double v)
119  {
120  fValidation = v;
121  }
122 
123  int
124  Parent() const
125  {
126  return fParent;
127  }
128  void
129  SetParent(int idx)
130  {
131  fParent = idx;
132  }
133 
134  const std::vector<size_t>&
135  Daughters() const
136  {
137  return fDaughters;
138  }
139  std::vector<size_t>&
141  {
142  return fDaughters;
143  }
144 
145 private:
146  int fParent;
147  std::vector<size_t> fDaughters;
148 
150  std::vector<size_t> fClusters;
151  int fKey, fTreeId;
152 
153  double fMse, fValidation;
154 
155  bool fGood;
156 };
157 
159 public:
160  size_t
161  size() const
162  {
163  return fCandidates.size();
164  }
165  void
166  resize(size_t n)
167  {
168  return fCandidates.resize(n);
169  }
170  bool
171  empty() const
172  {
173  return fCandidates.empty();
174  }
175 
176  void
178  {
179  fCandidates.push_back(trk);
180  }
181  void
182  erase_at(size_t pos)
183  {
184  fCandidates.erase(fCandidates.begin() + pos);
185  }
186  void
188  {
189  fCandidates.clear();
190  }
191 
192  TrkCandidate& operator[](size_t i) { return fCandidates[i]; }
193  TrkCandidate const& operator[](size_t i) const { return fCandidates[i]; }
194 
195  TrkCandidate&
197  {
198  return fCandidates.front();
199  }
200  TrkCandidate const&
201  front() const
202  {
203  return fCandidates.front();
204  }
205 
206  TrkCandidate&
208  {
209  return fCandidates.back();
210  }
211  TrkCandidate const&
212  back() const
213  {
214  return fCandidates.back();
215  }
216 
217  std::vector<TrkCandidate> const&
218  tracks() const
219  {
220  return fCandidates;
221  }
222  std::vector<TrkCandidate>&
224  {
225  return fCandidates;
226  }
227 
228  std::vector<TrkCandidate> const&
229  parents() const
230  {
231  return fParents;
232  }
233 
234  int getCandidateIndex(pma::Track3D const* candidate) const;
235  int getCandidateTreeId(pma::Track3D const* candidate) const;
236 
237  void merge(size_t idx1, size_t idx2);
238 
240 
241  void setTreeId(int id, size_t trkIdx, bool isRoot = true);
242  int setTreeIds();
243 
244  void flipTreesToCoordinate(detinfo::DetectorPropertiesData const& detProp, size_t coordinate);
245  void flipTreesByDQdx();
246 
249 
250  pma::Track3D* getTreeCopy(pma::TrkCandidateColl& dst, size_t trkIdx, bool isRoot = true);
251 
252 private:
253  std::vector<TrkCandidate> fCandidates;
254  std::vector<TrkCandidate> fParents;
255 };
256 
257 #endif
TrkCandidate & back()
size_t size() const
bool IsValid() const
pma::Track3D * getTreeCopy(pma::TrkCandidateColl &dst, size_t trkIdx, bool isRoot=true)
std::vector< TrkCandidate > fCandidates
int getCandidateTreeId(pma::Track3D const *candidate) const
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
bool setTreeOriginAtBack(detinfo::DetectorPropertiesData const &detProp, pma::Track3D *trk)
void SetValidation(double v)
void SetTrack(pma::Track3D *trk)
double Validation() const
tuple m
now if test mode generate materials, CRT shell, world, gdml header else just generate CRT shell for u...
void flipTreesToCoordinate(detinfo::DetectorPropertiesData const &detProp, size_t coordinate)
std::map< unsigned int, view_hitmap > tpc_view_hitmap
std::vector< TrkCandidate > fParents
TrkCandidate const & front() const
bool setTreeOriginAtFront(detinfo::DetectorPropertiesData const &detProp, pma::Track3D *trk)
int TreeId() const
int Parent() const
std::vector< size_t > fDaughters
std::map< unsigned int, std::vector< art::Ptr< recob::Hit > > > view_hitmap
int getCandidateIndex(pma::Track3D const *candidate) const
void SetTreeId(int id)
void SetMse(double m)
void merge(size_t idx1, size_t idx2)
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
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
void setTreeId(int id, size_t trkIdx, bool isRoot=true)
TrkCandidate & front()
void push_back(const TrkCandidate &trk)
auto const detProp
std::vector< TrkCandidate > const & tracks() const
double Mse() const
std::vector< TrkCandidate > & tracks()