Belle II Software  release-08-01-10
LimitedOnStateApplier.icc.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/ckf/general/findlets/LimitedOnStateApplier.dcl.h>
11 #include <tracking/trackFindingCDC/utilities/Functional.h>
12 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
13 
14 #include <framework/core/ModuleParamList.templateDetails.h>
15 
16 #include <algorithm>
17 
18 namespace Belle2 {
23  template <class AState, class AFilter>
25  {
26  this->addProcessingSignalListener(&m_filter);
27  };
28 
29  template <class AState, class AFilter>
31  std::vector<TrackFindingCDC::WithWeight<AState*>>& childStates)
32  {
33  Super::apply(currentPath, childStates);
34 
35  if (m_param_useNStates > 0 and childStates.size() > static_cast<unsigned int>(m_param_useNStates)) {
36  std::sort(childStates.begin(), childStates.end(), TrackFindingCDC::LessOf<TrackFindingCDC::GetWeight>());
37  childStates.erase(childStates.begin() + m_param_useNStates, childStates.end());
38  }
39  };
40 
41  template <class AState, class AFilter>
42  TrackFindingCDC::Weight LimitedOnStateApplier<AState, AFilter>::operator()(const Object& object)
43  {
44  return m_filter(object);
45  };
46 
47  template <class AState, class AFilter>
48  void LimitedOnStateApplier<AState, AFilter>::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
49  {
50  m_filter.exposeParameters(moduleParamList, prefix);
51 
52  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "useNStates"), m_param_useNStates, "Only use the best N states",
53  m_param_useNStates);
54  };
56 }
typename Super::Object Object
The object to filer.
The Module parameter list class.
A mixin class to attach a weight to an object.
Definition: WithWeight.h:24
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
TrackFindingCDC::Weight operator()(const Object &object) override
Copy the filter operator to this method.
void apply(const std::vector< TrackFindingCDC::WithWeight< const AState * >> &currentPath, std::vector< TrackFindingCDC::WithWeight< AState * >> &childStates) override
Apply the filter to each pair of states and current path and let only pass the best N states.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the subfindlet.
LimitedOnStateApplier()
Constructor adding the findlet as a listener.
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...
Definition: Functional.h:127