10#include <tracking/vxdHoughTracking/findlets/SVDHoughTrackingTreeSearcher.dcl.h>
11#include <framework/core/ModuleParamList.templateDetails.h>
12#include <framework/logging/Logger.h>
13#include <tracking/trackFindingCDC/utilities/Algorithms.h>
14#include <tracking/trackFindingCDC/utilities/Functional.h>
15#include <tracking/trackFindingCDC/utilities/Range.h>
16#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
23 namespace vxdHoughTracking {
25 template <
class AHit,
class APathFilter,
class AResult>
31 template <
class AHit,
class APathFilter,
class AResult>
33 const std::string& prefix)
35 m_pathFilter.exposeParameters(moduleParamList, prefix);
37 moduleParamList->
addParameter(TrackFindingCDC::prefixed(prefix,
"twoHitFilterLimit"),
38 m_applyTwoHitFilterIfMoreChildStates,
39 "Use the TwoHitFilter (path length == 1) if there are more child states than this value.",
40 m_applyTwoHitFilterIfMoreChildStates);
43 template <
class AHit,
class APathFilter,
class AResult>
46 std::vector<AResult>& results)
48 B2ASSERT(
"Expected relation to be sorted", std::is_sorted(relations.begin(), relations.end()));
50 m_automaton.applyTo(hits, relations);
52 std::vector<const AHit*> seedHits;
53 for (
const AHit* hit : hits) {
54 if (hit->getDataCache().layer >= 5) {
55 seedHits.emplace_back(hit);
59 std::vector<TrackFindingCDC::WithWeight<const AHit*>> path;
60 for (
const AHit* seedHit : seedHits) {
61 B2DEBUG(29,
"Starting with new seed...");
63 path.emplace_back(seedHit, 0);
64 traverseTree(path, relations, results);
66 B2ASSERT(
"Something went wrong during the path traversal", path.empty());
68 B2DEBUG(29,
"... finished with seed");
72 template <
class AHit,
class APathFilter,
class AResult>
76 std::vector<AResult>& results)
80 const AHit* currentHit = path.back();
82 TrackFindingCDC::asRange(std::equal_range(relations.begin(), relations.end(), currentHit));
84 std::vector<TrackFindingCDC::WithWeight<AHit*>> childHits;
86 AHit* childHit = continuation.getTo();
87 TrackFindingCDC::Weight weight = continuation.getWeight();
90 if (std::count(path.begin(), path.end(), childHit)) {
93 B2FATAL(
"Cycle detected!");
96 childHits.emplace_back(childHit, weight);
100 const std::vector<TrackFindingCDC::WithWeight<const AHit*>>& constPath = path;
101 if (path.size() > 1 or childHits.size() > m_applyTwoHitFilterIfMoreChildStates) {
102 m_pathFilter.apply(constPath, childHits);
105 if (childHits.empty()) {
106 B2DEBUG(29,
"Terminating this route, as there are no possible child states.");
107 if (path.size() >= 3) {
108 results.emplace_back(path);
116 B2DEBUG(29,
"Having found " << childHits.size() <<
" child states.");
119 path.emplace_back(childHit, childHit.getWeight());
120 traverseTree(path, relations, results);
The Module parameter list class.
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
Type for two related objects with a weight.
A mixin class to attach a weight to an object.
APathFilter m_pathFilter
State rejecter to decide which available continuations should be traversed next.
SVDHoughTrackingTreeSearcher()
Construct this findlet and add the subfindlet as listener.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters of the subfindlet.
void traverseTree(std::vector< TrackFindingCDC::WithWeight< const AHit * > > &path, const std::vector< TrackFindingCDC::WeightedRelation< AHit > > &relations, std::vector< AResult > &results)
Implementation of the traverseTree function.
void apply(std::vector< AHit * > &hits, const std::vector< TrackFindingCDC::WeightedRelation< AHit > > &relations, std::vector< AResult > &results) final
Main function of this findlet: traverse a tree starting from a given seed hits.
void addParameter(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.
Functor factory turning a binary functor and two functors into a new functor which executes the binar...