Belle II Software  release-05-01-25
LimitedOnStateApplier.icc.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/ckf/general/findlets/LimitedOnStateApplier.dcl.h>
13 #include <tracking/trackFindingCDC/utilities/Functional.h>
14 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
15 
16 #include <framework/core/ModuleParamList.templateDetails.h>
17 
18 #include <algorithm>
19 
20 namespace Belle2 {
25  template <class AState, class AFilter>
27  {
28  this->addProcessingSignalListener(&m_filter);
29  };
30 
31  template <class AState, class AFilter>
32  void LimitedOnStateApplier<AState, AFilter>::apply(const std::vector<TrackFindingCDC::WithWeight<const AState*>>& currentPath,
33  std::vector<TrackFindingCDC::WithWeight<AState*>>& childStates)
34  {
35  Super::apply(currentPath, childStates);
36 
37  if (m_param_useNStates > 0 and childStates.size() > static_cast<unsigned int>(m_param_useNStates)) {
38  std::sort(childStates.begin(), childStates.end(), TrackFindingCDC::LessOf<TrackFindingCDC::GetWeight>());
39  childStates.erase(childStates.begin() + m_param_useNStates, childStates.end());
40  }
41  };
42 
43  template <class AState, class AFilter>
44  TrackFindingCDC::Weight LimitedOnStateApplier<AState, AFilter>::operator()(const Object& object)
45  {
46  return m_filter(object);
47  };
48 
49  template <class AState, class AFilter>
50  void LimitedOnStateApplier<AState, AFilter>::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
51  {
52  m_filter.exposeParameters(moduleParamList, prefix);
53 
54  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "useNStates"), m_param_useNStates, "Only use the best N states",
55  m_param_useNStates);
56  };
58 }
Belle2::TrackFindingCDC::BinaryJoin
Functor factory turning a binary functor and two functors into a new functor which executes the binar...
Definition: Functional.h:137
Belle2::LimitedOnStateApplier::LimitedOnStateApplier
LimitedOnStateApplier()
Constructor adding the findlet as a listener.
Definition: LimitedOnStateApplier.icc.h:34
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::LimitedOnStateApplier::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the subfindlet.
Definition: LimitedOnStateApplier.icc.h:58
Belle2::LimitedOnStateApplier::operator()
TrackFindingCDC::Weight operator()(const Object &object) override
Copy the filter operator to this method.
Definition: LimitedOnStateApplier.icc.h:52
Belle2::LimitedOnStateApplier::apply
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.
Definition: LimitedOnStateApplier.icc.h:40