Belle II Software  release-08-01-10
CDCCKFResultFinalizer.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #pragma once
9 
10 #include <tracking/trackFindingCDC/findlets/base/Findlet.h>
11 
12 #include <tracking/trackFindingCDC/filters/base/ChooseableFilter.h>
13 #include <tracking/ckf/cdc/filters/paths/CDCPathFilterFactory.h>
14 
15 #include <tracking/trackFindingCDC/numerics/Weight.h>
16 
17 #include <tracking/ckf/cdc/entities/CDCCKFPath.h>
18 #include <tracking/ckf/cdc/entities/CDCCKFResult.h>
19 
20 #include <vector>
21 
22 namespace Belle2 {
27  class ModuleParamList;
28 
30  class CDCCKFResultFinalizer : public TrackFindingCDC::Findlet<const CDCCKFPath, CDCCKFResult> {
31  public:
33  {
35  }
36 
38  void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix) override
39  {
40  m_filter.exposeParameters(moduleParamList, prefix);
41  }
42 
44  void apply(const std::vector<CDCCKFPath>& paths, std::vector<CDCCKFResult>& results) override
45  {
46  if (paths.empty()) {
47  return;
48  }
49 
50  const CDCCKFPath* bestElement = nullptr;
51  TrackFindingCDC::Weight bestWeight = -NAN;
52 
53  for (const CDCCKFPath& path : paths) {
54  const TrackFindingCDC::Weight weight = m_filter(path);
55  if (weight <= bestWeight) {
56  continue;
57  }
58  bestWeight = weight;
59  bestElement = &path;
60  }
61 
62  if (bestElement and not std::isnan(bestWeight)) {
63  results.push_back(*bestElement);
64  }
65  }
66 
67  private:
70  };
72 }
Findlet to finalize CKF Paths in terms of final result.
TrackFindingCDC::ChooseableFilter< CDCPathFilterFactory > m_filter
Filter to weigth the best path.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
void apply(const std::vector< CDCCKFPath > &paths, std::vector< CDCCKFResult > &results) override
main method of the findlet, for a list of paths create a list of results.
The Module parameter list class.
Convenvience wrapper to setup a Chooseable filter from a specific factory object.
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
Interface for a minimal algorithm part that wants to expose some parameters to a module.
Definition: Findlet.h:26
std::vector< CDCCKFState > CDCCKFPath
Shortcut for the collection of CDC CKF-algorithm states.
Definition: CDCCKFPath.h:19
Abstract base class for different kinds of events.