Belle II Software  release-05-02-19
StackTreeSearcher.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/findlets/base/Findlet.h>
13 
14 #include <tracking/ckf/cdc/findlets/CDCCKFStateCreator.h>
15 #include <tracking/ckf/cdc/findlets/CDCCKFStateFilter.h>
16 #include <tracking/ckf/cdc/findlets/CDCCKFPathMerger.h>
17 #include <tracking/ckf/cdc/findlets/CDCCKFPathSelector.h>
18 
19 #include <tracking/ckf/cdc/entities/CDCCKFState.h>
20 #include <tracking/ckf/cdc/entities/CDCCKFPath.h>
21 
22 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
23 #include <framework/core/ModuleParamList.h>
24 
25 
26 namespace Belle2 {
31  class StackTreeSearcher : public
33  TrackFindingCDC::Findlet<CDCCKFPath, const TrackFindingCDC::CDCWireHit* const> {
34  public:
35  StackTreeSearcher()
36  {
41  }
42 
44  void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix) override
45  {
46  m_stateCreator.exposeParameters(moduleParamList, prefix);
47  m_stateFilter.exposeParameters(moduleParamList, TrackFindingCDC::prefixed("state", prefix));
48  m_pathMerger.exposeParameters(moduleParamList, prefix);
49  m_pathSelector.exposeParameters(moduleParamList, TrackFindingCDC::prefixed("path", prefix));
50  }
51 
53  void apply(std::vector<CDCCKFPath>& paths,
54  const std::vector<const TrackFindingCDC::CDCWireHit*>& wireHits) override
55  {
56 
57  if (paths.empty()) {
58  return;
59  }
60 
61  std::vector<CDCCKFPath> newPaths;
62  std::vector<CDCCKFState> nextStates;
63 
64  for (CDCCKFPath& path : paths) {
65  B2DEBUG(100, "Testing one path from " << path.back());
66  m_stateCreator.apply(nextStates, path, wireHits);
67  m_stateFilter.apply(path, nextStates);
68 
69  // TODO: Attention: if there is no hit anymore, the path will not be added to the final set!
70  for (const auto& nextState : nextStates) {
71  path.push_back(nextState);
72 
73  B2DEBUG(100, "will go to " << nextState);
74  newPaths.push_back(path);
75  path.pop_back();
76  }
77  B2DEBUG(100, "Now having " << newPaths.size() << " in flight");
78  nextStates.clear();
79  }
80 
81  B2DEBUG(100, "Having found " << newPaths.size() << " new paths");
82  for (const auto& path : newPaths) {
83  B2DEBUG(100, path);
84  }
85 
86  m_pathMerger.apply(newPaths);
87  B2DEBUG(100, "Having found " << newPaths.size() << " new paths after merging");
88  for (const auto& path : newPaths) {
89  B2DEBUG(100, path);
90  }
91 
92  m_pathSelector.apply(newPaths);
93  B2DEBUG(100, "Having found " << newPaths.size() << " new paths after selection");
94  for (const auto& path : newPaths) {
95  B2DEBUG(100, path);
96  }
97 
98  if (newPaths.empty()) {
99  return;
100  }
101 
102  paths.swap(newPaths);
103  newPaths.clear();
104 
105  apply(paths, wireHits);
106  }
107 
108  private:
110  CDCCKFStateCreator m_stateCreator;
112  CDCCKFStateFilter m_stateFilter;
114  CDCCKFPathMerger m_pathMerger;
116  CDCCKFPathSelector m_pathSelector;
117  };
119 }
Belle2::StackTreeSearcher::m_pathSelector
CDCCKFPathSelector m_pathSelector
algorithm to select N best paths, for further processing.
Definition: StackTreeSearcher.h:124
Belle2::CDCCKFPathSelector::apply
void apply(std::vector< CDCCKFPath > &newPaths) override
main method of the findlet, out of all paths "newPaths" select the best N=m_maximalCandidatesInFlight
Definition: CDCCKFPathSelector.h:52
Belle2::StackTreeSearcher::apply
void apply(std::vector< CDCCKFPath > &paths, const std::vector< const TrackFindingCDC::CDCWireHit * > &wireHits) override
Main method to update the paths. Input: vector of the selected paths and a vector of CDC wirehits to ...
Definition: StackTreeSearcher.h:61
Belle2::StackTreeSearcher::m_stateFilter
CDCCKFStateFilter m_stateFilter
algorithm to perform state filtering
Definition: StackTreeSearcher.h:120
Belle2::CDCCKFStateFilter::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
Definition: CDCCKFStateFilter.h:58
Belle2::CDCCKFPathMerger::apply
void apply(std::vector< CDCCKFPath > &newPaths) override
main method of the findlet, reads/returns merged paths
Definition: CDCCKFPathMerger.h:35
Belle2::TrackFindingCDC::CompositeProcessingSignalListener::addProcessingSignalListener
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
Definition: CompositeProcessingSignalListener.cc:57
Belle2::StackTreeSearcher::m_pathMerger
CDCCKFPathMerger m_pathMerger
algorithm to merge similar paths
Definition: StackTreeSearcher.h:122
Belle2::CDCCKFStateCreator::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
Definition: CDCCKFStateCreator.h:62
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::Findlet::exposeParameters
virtual void exposeParameters(ModuleParamList *moduleParamList __attribute__((unused)), const std::string &prefix __attribute__((unused)))
Forward prefixed parameters of this findlet to the module parameter list.
Definition: Findlet.h:79
Belle2::CDCCKFPath
std::vector< CDCCKFState > CDCCKFPath
Shortcut for the collection of CDC CKF-algorithm states.
Definition: CDCCKFPath.h:29
Belle2::CDCCKFPathSelector::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
Definition: CDCCKFPathSelector.h:43
Belle2::CDCCKFStateFilter::apply
void apply(const CDCCKFPath &path, std::vector< CDCCKFState > &nextStates) override
Apply the findlet and do the state selection.
Definition: CDCCKFStateFilter.h:70
Belle2::CDCCKFStateCreator::apply
void apply(std::vector< CDCCKFState > &nextStates, const CDCCKFPath &path, const std::vector< const TrackFindingCDC::CDCWireHit * > &wireHits) override
Main method of the findlet. Select + create states (output parameter nextStates) suitable for the inp...
Definition: CDCCKFStateCreator.h:93
Belle2::StackTreeSearcher::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
Definition: StackTreeSearcher.h:52
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46
Belle2::StackTreeSearcher::m_stateCreator
CDCCKFStateCreator m_stateCreator
algorthim to create CDC-CDF states while traversing the path
Definition: StackTreeSearcher.h:118