Dynamic tree structure with weighted items in each node which are markable through out the tree.
More...
|
| template<class Ts> |
| void | seed (const Ts &items) |
| | Take the item set and insert them into the top node of the hough space.
|
| |
| template<class AItemInDomainMeasure> |
| std::vector< std::pair< ADomain, std::vector< T > > > | findHeavyLeavesDisjoint (AItemInDomainMeasure &weightItemInDomain, int maxLevel, double minWeight) |
| | Find all children node at maximum level and add them to the result list. Skip nodes if their weight is below minWeight.
|
| |
| template<class AItemInDomainMeasure, class ASkipNodePredicate> |
| std::vector< std::pair< ADomain, std::vector< T > > > | findLeavesDisjoint (AItemInDomainMeasure &weightItemInDomain, int maxLevel, ASkipNodePredicate &skipNode) |
| | Find all children node at maximum level and add them to the result list. Skip nodes if skipNode returns true.
|
| |
| template<class AItemInDomainMeasure, class ASkipNodePredicate> |
| std::vector< std::pair< ADomain, std::vector< T > > > | findHeaviestLeafRepeated (AItemInDomainMeasure &weightItemInDomain, int maxLevel, ASkipNodePredicate &skipNode) |
| | Go through all children until maxLevel is reached and find the heaviest leaves.
|
| |
| template<class AItemInDomainMeasure, class ASkipNodePredicate> |
| std::unique_ptr< std::pair< ADomain, std::vector< T > > > | findHeaviestLeafSingle (AItemInDomainMeasure &weightItemInDomain, int maxLevel, ASkipNodePredicate &skipNode) |
| | Go through all children until the maxLevel is reached and find the leaf with the highest weight.
|
| |
| template<class AItemInDomainMeasure, class ASkipNodePredicate> |
| Node * | findHeaviestLeaf (AItemInDomainMeasure &weightItemInDomain, int maxLevel, ASkipNodePredicate &skipNode) |
| | Go through all children until the maxLevel is reached and find the leaf with the highest weight.
|
| |
| template<class AItemInDomainMeasure, class AIsLeafPredicate> |
| void | fillWalk (AItemInDomainMeasure &weightItemInDomain, AIsLeafPredicate &isLeaf) |
| | Walk through the children and fill them if necessary until isLeaf returns true.
|
| |
| template<class ATreeWalker> |
| void | walkHeighWeightFirst (ATreeWalker &walker) |
| | Walk the tree investigating the heaviest children with priority.
|
| |
| void | fell () |
| | Fell to tree meaning deleting all child nodes from the tree. Keeps the top node.
|
| |
| void | raze () |
| | Like fell but also releases all memory the tree has acquired during long executions.
|
| |
| Node & | getTopNode () |
| | Getter for the top node of the tree.
|
| |
| const Node & | getTopNode () const |
| | Constant getter for the top node of the tree.
|
| |
| Node & | getTopNode () |
| | Getter for the top node of the tree.
|
| |
| const Node & | getTopNode () const |
| | Constant getter for the top node of the tree.
|
| |
| int | getNNodes () const |
| | Gets the number of nodes currently contained in the tree Also demonstrates how to walk over the tree.
|
| |
| int | getNNodes () const |
| | Gets the number of nodes currently contained in the tree Also demonstrates how to walk over the tree.
|
| |
| std::map< int, int > | getNNodesByLevel () const |
| | Gets the number of nodes by level in the tree Also demonstrates how to walk over the tree.
|
| |
| std::map< int, int > | getNNodesByLevel () const |
| | Gets the number of nodes by level in the tree Also demonstrates how to walk over the tree.
|
| |
| void | walk (AWalker &walker) |
| | Forward walk to the top node.
|
| |
| void | walk (AWalker &walker, APriorityMeasure &priority) |
| | Forward walk to the top node.
|
| |
| void | walk (AWalker &walker) |
| | Forward walk to the top node.
|
| |
| void | walk (AWalker &walker, APriorityMeasure &priority) |
| | Forward walk to the top node.
|
| |
template<class T, class ADomain, class ADomainDivsion>
class Belle2::TrackFindingCDC::WeightedFastHoughTree< T, ADomain, ADomainDivsion >
Dynamic tree structure with weighted items in each node which are markable through out the tree.
Used to build fast hough type algorithms, where objects are allowed to carry weights relative to the hough space part (here called a ADomain) they are contained in. The shared marks allow for iterative extraction of hough peaks such that other areas of the hough space notice that certain element have already been consumed.
Definition at line 49 of file WeightedFastHoughTree.h.
template<class T, class ADomain, class ADomainDivsion>
template<class AItemInDomainMeasure, class AIsLeafPredicate>
| void fillWalk |
( |
AItemInDomainMeasure & | weightItemInDomain, |
|
|
AIsLeafPredicate & | isLeaf ) |
|
inline |
Walk through the children and fill them if necessary until isLeaf returns true.
Uses the weightItemInDomain to create weights for the items (or decide if an item belongs to a mode or not).
Definition at line 239 of file WeightedFastHoughTree.h.
241 {
242 auto walker = [&weightItemInDomain, &isLeaf](Node * node) {
243
244
245 if (isLeaf(node)) {
246
247 return false;
248 }
249
250
251
252
253 typename Node::Children* children = node->getChildren();
254 if (not children) {
255 node->createChildren();
256 children = node->getChildren();
257 for (Node& childNode : *children) {
258 assert(childNode.getChildren() == nullptr);
259 assert(childNode.size() == 0);
260 auto measure =
261
262 [&childNode, &weightItemInDomain](WithSharedMark<T>& markableItem) -> TrackingUtilities::Weight {
263
264 T & item(markableItem);
265 return weightItemInDomain(item, &childNode);
266 };
267 childNode.insert(*node, measure);
268 }
269 }
270
271 return true;
272 };
273 walkHeighWeightFirst(walker);
274 }
template<class T, class ADomain, class ADomainDivsion>
template<class AItemInDomainMeasure, class ASkipNodePredicate>
| Node * findHeaviestLeaf |
( |
AItemInDomainMeasure & | weightItemInDomain, |
|
|
int | maxLevel, |
|
|
ASkipNodePredicate & | skipNode ) |
|
inline |
Go through all children until the maxLevel is reached and find the leaf with the highest weight.
If no node could be found, return a nullptr. A node is skipped if skipNode is returns true for this node.
Definition at line 201 of file WeightedFastHoughTree.h.
204 {
205 Node* heaviestNode = nullptr;
206 TrackingUtilities::Weight heighestWeigth = NAN;
207 auto isLeaf = [&heaviestNode, &heighestWeigth, maxLevel, &skipNode](Node * node) {
208
209 if (skipNode(node)) {
210 return true;
211 }
212
213 TrackingUtilities::Weight nodeWeight = node->getWeight();
214
215 if (not std::isnan(heighestWeigth) and not(nodeWeight > heighestWeigth)) {
216 return true;
217 }
218
219
220
221
222 if (node->getLevel() >= maxLevel) {
223 heaviestNode = node;
224 heighestWeigth = nodeWeight;
225 return true;
226 }
227 return false;
228 };
229 fillWalk(weightItemInDomain, isLeaf);
230 return heaviestNode;
231 }
template<class T, class ADomain, class ADomainDivsion>
template<class AItemInDomainMeasure, class ASkipNodePredicate>
| std::vector< std::pair< ADomain, std::vector< T > > > findHeaviestLeafRepeated |
( |
AItemInDomainMeasure & | weightItemInDomain, |
|
|
int | maxLevel, |
|
|
ASkipNodePredicate & | skipNode ) |
|
inline |
Go through all children until maxLevel is reached and find the heaviest leaves.
For this, the single heaviest leaf is found and added to an internal list. The process is repeated until no leaf can be found anymore. A node is skipped if skipNode is returns true for this node.
Definition at line 154 of file WeightedFastHoughTree.h.
157 {
158 std::vector<std::pair<ADomain, std::vector<T> > > found;
159 Node* node = findHeaviestLeaf(weightItemInDomain, maxLevel, skipNode);
160 while (node) {
161 const ADomain* domain = node;
162 found.emplace_back(*domain, std::vector<T>(node->begin(), node->end()));
163 for (WithSharedMark<T>& markableItem : *node) {
164 markableItem.mark();
165 }
166 node = findHeaviestLeaf(weightItemInDomain, maxLevel, skipNode);
167 }
168 return found;
169 }
template<class T, class ADomain, class ADomainDivsion>
template<class AItemInDomainMeasure>
| static std::vector< std::pair< ADomain, std::vector< T > > > findHeaviestLeafRepeated |
( |
AItemInDomainMeasure & | weightItemInDomain, |
|
|
int | maxLevel, |
|
|
const TrackingUtilities::Weight | minWeight = NAN ) |
|
inlinestatic |
Go through all children until maxLevel is reached and find the heaviest leaves.
For this, the single heaviest leaf is found and added to an internal list. The process is repeated until no leaf can be found anymore. A node is skipped if the weight is below minWeight.
Definition at line 135 of file WeightedFastHoughTree.h.
138 {
139 auto skipLowWeightNode = [minWeight](const Node * node) {
140 return not(node->getWeight() >= minWeight);
141 };
142 return findHeaviestLeafRepeated(weightItemInDomain, maxLevel, skipLowWeightNode);
143 }
template<class T, class ADomain, class ADomainDivsion>
template<class AItemInDomainMeasure, class ASkipNodePredicate>
| std::unique_ptr< std::pair< ADomain, std::vector< T > > > findHeaviestLeafSingle |
( |
AItemInDomainMeasure & | weightItemInDomain, |
|
|
int | maxLevel, |
|
|
ASkipNodePredicate & | skipNode ) |
|
inline |
Go through all children until the maxLevel is reached and find the leaf with the highest weight.
If no node could be found, return an empty list, otherwise return a list with just on element. A node is skipped if skipNode is returns true for this node.
Definition at line 178 of file WeightedFastHoughTree.h.
181 {
182 using Result = std::pair<ADomain, std::vector<T> >;
183 std::unique_ptr<Result> found = nullptr;
184 Node* node = findHeaviestLeaf(weightItemInDomain, maxLevel, skipNode);
185 if (node) {
186 const ADomain* domain = node;
187 found.reset(new Result(*domain, std::vector<T>(node->begin(), node->end())));
188 for (WithSharedMark<T>& markableItem : *node) {
189 markableItem.mark();
190 }
191 }
192 return found;
193 }