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