Belle II Software  release-08-01-10
TrackRejecter.cc
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 #include <tracking/trackFindingCDC/findlets/minimal/TrackRejecter.h>
9 
10 #include <tracking/trackFindingCDC/eventdata/tracks/CDCTrack.h>
11 
12 #include <tracking/trackFindingCDC/filters/base/ChooseableFilter.icc.h>
13 
14 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
15 #include <tracking/trackFindingCDC/utilities/Algorithms.h>
16 
17 #include <framework/core/ModuleParamList.templateDetails.h>
18 
19 using namespace Belle2;
20 using namespace TrackFindingCDC;
21 
24 
25 TrackRejecter::TrackRejecter(const std::string& defaultFilterName)
26  : m_trackFilter(defaultFilterName)
27 {
29 }
30 
32 {
33  return "Deletes fake tracks that have been rejected by a filter";
34 }
35 
36 void TrackRejecter::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
37 {
38  m_trackFilter.exposeParameters(moduleParamList, prefix);
39  moduleParamList->addParameter(prefixed(prefix, "deleteRejected"),
41  "Delete the rejected tracks instead of marking them as background.",
43 }
44 
45 void TrackRejecter::apply(std::vector<CDCTrack>& tracks)
46 {
47  auto reject = [this](CDCTrack & track) {
48  double filterWeight = m_trackFilter(track);
49  track->setCellWeight(filterWeight);
50  if (std::isnan(filterWeight)) {
51  track->setBackgroundFlag();
52  track->setTakenFlag();
53  return true;
54  } else {
55  return false;
56  }
57  };
58 
60  erase_remove_if(tracks, reject);
61  } else {
62  std::for_each(tracks.begin(), tracks.end(), reject);
63  }
64 }
The Module parameter list class.
Class representing a sequence of three dimensional reconstructed hits.
Definition: CDCTrack.h:41
Convenvience wrapper to setup a Chooseable filter from a specific factory object.
Filter can delegate to a filter chosen and set up at run time by parameters.
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
bool m_param_deleteRejected
Parameter : Switch to delete the tracks instead of marking them as background.
Definition: TrackRejecter.h:55
void apply(std::vector< CDCTrack > &tracks) final
Main algorithm.
std::string getDescription() final
Short description of the findlet.
TrackRejecter(const std::string &defaultFilterName="all")
Constructor adding the filter as a subordinary processing signal listener.
ChooseableFilter< TrackFilterFactory > m_trackFilter
Reference to the filter to be used to filter.
Definition: TrackRejecter.h:58
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
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.