Belle II Software development
SegmentRejecter.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/SegmentRejecter.h>
9
10#include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
11
12#include <tracking/trackFindingCDC/filters/base/ChooseableFilter.icc.h>
13
14#include <tracking/trackFindingCDC/utilities/Algorithms.h>
15
16#include <framework/core/ModuleParamList.templateDetails.h>
17
18using namespace Belle2;
19using namespace TrackFindingCDC;
20
23
24SegmentRejecter::SegmentRejecter(const std::string& defaultFilterName)
25 : m_segmentFilter(defaultFilterName)
26{
28}
29
31{
32 return "Deletes fake segments that have been rejected by a filter";
33}
34
35void SegmentRejecter::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
36{
37 m_segmentFilter.exposeParameters(moduleParamList, prefix);
38 moduleParamList->addParameter(prefixed(prefix, "deleteRejected"),
40 "Delete the rejected segments instead of marking this as background.",
42}
43
44void SegmentRejecter::apply(std::vector<CDCSegment2D>& segment2Ds)
45{
46 auto reject = [this](CDCSegment2D & segment2D) {
47 double filterWeight = m_segmentFilter(segment2D);
48 segment2D->setCellWeight(filterWeight);
49 if (std::isnan(filterWeight)) {
50 segment2D->setBackgroundFlag();
51 segment2D->setTakenFlag();
52 return true;
53 } else {
54 return false;
55 }
56 };
57
59 erase_remove_if(segment2Ds, reject);
60 } else {
61 std::for_each(segment2Ds.begin(), segment2Ds.end(), reject);
62 }
63}
The Module parameter list class.
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
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 segments instead of marking them as background.
ChooseableFilter< SegmentFilterFactory > m_segmentFilter
Reference to the filter to be used to filter.
std::string getDescription() final
Short description of the findlet.
void apply(std::vector< CDCSegment2D > &segment2Ds) final
Main algorithm.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
SegmentRejecter(const std::string &defaultFilterName="all")
Constructor adding the filter as a subordinary processing signal 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.