Belle II Software  release-05-01-25
CDCCKFResultFinalizer.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/trackFindingCDC/filters/base/ChooseableFilter.h>
15 #include <tracking/ckf/cdc/filters/paths/CDCPathFilterFactory.h>
16 
17 #include <tracking/trackFindingCDC/numerics/Weight.h>
18 
19 #include <tracking/ckf/cdc/entities/CDCCKFPath.h>
20 #include <tracking/ckf/cdc/entities/CDCCKFResult.h>
21 
22 #include <vector>
23 
24 namespace Belle2 {
29  class ModuleParamList;
30 
32  class CDCCKFResultFinalizer : public TrackFindingCDC::Findlet<const CDCCKFPath, CDCCKFResult> {
33  public:
34  CDCCKFResultFinalizer()
35  {
37  }
38 
40  void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix) override
41  {
42  m_filter.exposeParameters(moduleParamList, prefix);
43  }
44 
46  void apply(const std::vector<CDCCKFPath>& paths, std::vector<CDCCKFResult>& results) override
47  {
48  if (paths.empty()) {
49  return;
50  }
51 
52  const CDCCKFPath* bestElement = nullptr;
53  TrackFindingCDC::Weight bestWeight = -NAN;
54 
55  for (const CDCCKFPath& path : paths) {
56  const TrackFindingCDC::Weight weight = m_filter(path);
57  if (weight <= bestWeight) {
58  continue;
59  }
60  bestWeight = weight;
61  bestElement = &path;
62  }
63 
64  if (bestElement and not std::isnan(bestWeight)) {
65  results.push_back(*bestElement);
66  }
67  }
68 
69  private:
71  TrackFindingCDC::ChooseableFilter<CDCPathFilterFactory> m_filter;
72  };
74 }
Belle2::CDCCKFResultFinalizer::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
Definition: CDCCKFResultFinalizer.h:48
Belle2::CDCCKFResultFinalizer::m_filter
TrackFindingCDC::ChooseableFilter< CDCPathFilterFactory > m_filter
Filter to weigth the best path.
Definition: CDCCKFResultFinalizer.h:79
Belle2::TrackFindingCDC::CompositeProcessingSignalListener::addProcessingSignalListener
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
Definition: CompositeProcessingSignalListener.cc:57
Belle2::CDCCKFResultFinalizer::apply
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.
Definition: CDCCKFResultFinalizer.h:54
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::CDCCKFPath
std::vector< CDCCKFState > CDCCKFPath
Shortcut for the collection of CDC CKF-algorithm states.
Definition: CDCCKFPath.h:29
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46