EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MatchCandidate.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MatchCandidate.h
1 //
2 // AYK (ayk@bnl.gov)
3 //
4 // Match candidate (possible track) class;
5 //
6 // Initial port from OLYMPUS sources: Oct'2015;
7 //
8 
9 #include <TObject.h>
10 
11 #include <HoughNodeGroup.h>
12 
13 #ifndef _MATCH_CANDIDATE_
14 #define _MATCH_CANDIDATE_
15 
16 class HoughTree;
17 
18 //#define _USE_ALL_MEMBERS_VECTOR_
19 
20 class MatchCandidate: public TObject
21 {
22  public:
23  MatchCandidate(const HoughTree *tree = 0);
25  delete [] mMemberCount;
26 
27  // FIXME: and the internals, please;
28  //for(unsigned mm=0; mm<_members.size(); ++) {
29  //} //for mm
30 #ifdef _USE_ALL_MEMBERS_VECTOR_
31  delete [] mAllMembers;
32 #endif
33  delete [] mSelMembers;
34 
35  delete [] mId;
36  };
37 
38  virtual void ShapeItUpForInspection(const HoughTree *tree, const unsigned id[]);
39  virtual bool IsReadyForFinalFit() const = 0;
40 
41  void ResetToTheVirginState();
42 
44  unsigned GetOkGroupCounter() const { return mOkGroupCounter; };
46 
47  //void SetAccountedAsGoodTrack(bool status) { mAccountedAsGoodTrack = status; };
48  //bool IsAccountedAsGoodTrack() const { return mAccountedAsGoodTrack; };
49 
50  void SetGroupedStatus(bool status) { mGrouped = status; };
51  bool IsGrouped() const { return mGrouped; };
52 
53  void SetInactive() {
54  for(unsigned gr=0; gr<GetGdim(); gr++)
55  for(unsigned mm=0; mm<GetLinearMemberCount(gr); mm++)
56  ResetMemberPtr(gr, mm);
57 
58  mActive = false;
59  };
60  bool IsActive() const { return mActive; };
61  // It looks like there is no need to overcomplicate this stuff (used for
62  // printout purposes only and HoughTree knows better the dimension of this array);
63  const unsigned *GetIdPtr() const { return mId; };
64 
65  bool IsSubset(const HoughTree *tree, const MatchCandidate *reference) const;
66 
67  void ResetMemberPtr(unsigned gr, unsigned mm) {
68  GroupMember *member = GetSelMember(gr, mm);
69 
70  if (member) {
71  member->EraseMatchCandidate(this);
72 
73  mSelMembers[gr][mm] = 0;
74  } //if
75  };
76  void ResetMemberPtr(unsigned gr, GroupMember *member) {
77  for(unsigned mm=0; mm<mMemberCount[gr]; mm++)
78  if (mSelMembers[gr][mm] == member)
79  ResetMemberPtr(gr, mm);
80  };
81  void ResetMemberCount(unsigned gr) { mMemberCount[gr] = 0; };
82 
83  // This is just to do loops correctly; there can be gaps after member removal, etc;
84  unsigned GetLinearMemberCount(unsigned gr) const { return mMemberCount[gr]; };
85 
86  // These two routines do not distinguish between BUSY and non-BUSY members;
87  unsigned GetAliveMemberCount(unsigned gr) const {
88  unsigned count = 0;
89 
90  for(unsigned mm=0; mm<mMemberCount[gr]; mm++)
91  if (mSelMembers[gr][mm])
92  count++;
93 
94  return count;
95  };
96  // FIXME: this call usage indeed assumes at most one hit per plane in the final fit;
97  GroupMember *GetFirstAliveMember(unsigned gr) const {
98  for(unsigned mm=0; mm<mMemberCount[gr]; mm++)
99  if (mSelMembers[gr][mm])
100  return mSelMembers[gr][mm];
101 
102  return 0;
103  };
104  unsigned GetAliveGroupCount() const {
105  unsigned count = 0;
106 
107  for(unsigned gr=0; gr<GetGdim(); gr++)
108  if (GetAliveMemberCount(gr))
109  count++;
110 
111  return count;
112  };
113  unsigned GetAliveMemberCount() const {
114  unsigned count = 0;
115 
116  for(unsigned gr=0; gr<GetGdim(); gr++)
117  count += GetAliveMemberCount(gr);
118 
119  return count;
120  };
121 
122  void AddMember(unsigned gr, GroupMember *member);
123  // FIXME: range check;
124  GroupMember *GetSelMember(unsigned gr, unsigned mm) { return mSelMembers[gr][mm]; };
125 
126  virtual double GetTrackQualityParameter() const = 0;
127 
128  bool HasAmbiguousHits() const;
129  __u64 Ambiguity() const;
130  bool SiamGroupCandidate(unsigned minHitCount);
131 
132  // FIXME: perhaps do it better later;
133  unsigned GetGdim() const { return mGdim; };
134 
135  private:
136  // May be reset to 0 during purging (is a subset of some other candidate);
137  bool mActive;
138 
139  // If 'true', this candidate is participating in some group already;
140  bool mGrouped;
141 
142  // Is selected as a good track candidate already;
143  //bool mAccountedAsGoodTrack; //!
144 
145  // Just copy over HoughTree value; FIXME: do it better later;
146  unsigned mGdim;
147 
148  // Just cell ndim-index at the highest level for now; it is more convenient
149  // to store it like this instead of the single __u32 1D-milti-index;
150  // does not cost much RAM anyway; perhaps account weights later as well?;
151  unsigned *mId;
152 
153  // THINK: during tree search procedure (depending on the road width) it can
154  // happen, that there are (much) more hit candidates, than actually allowed
155  // to be left during the final fit (typically 1 per plane); for now prefer to
156  // maintain two vectors, which are populated identically during tree search,
157  // but mSelMembers[] gets purged during ambiguity resolution pass; the idea
158  // of having all original hits intact in mAllMembers[] vector is to allow
159  // more efficient conflict resolution later in case hit borrowing is allowed
160  // (basically want to be able to try hit replacement in some tracks as long
161  // as chi^2 CCDF value can be maintained above threshold); FIXME: once debugging
162  // is over may want to incorporate more efficient storage scheme;
163  unsigned *mMemberCount;
164 #ifdef _USE_ALL_MEMBERS_VECTOR_
165  std::vector<GroupMember*> *mAllMembers;
166 #endif
167  std::vector<GroupMember*> *mSelMembers;
168 
169  // Basically the number of fired planes, no matter BUSY or new ones;
170  unsigned mOkGroupCounter;
171 
173 };
174 
175 #endif