Belle II Software development
Chi2FacetFilter.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
9#include <tracking/trackFindingCDC/filters/facet/Chi2FacetFilter.h>
10
11#include <tracking/trackFindingCDC/fitting/FacetFitter.h>
12
13#include <tracking/trackingUtilities/eventdata/hits/CDCFacet.h>
14
15#include <tracking/trackingUtilities/utilities/StringManipulation.h>
16
17#include <framework/core/ModuleParamList.templateDetails.h>
18#include <framework/logging/Logger.h>
19
20#include <cmath>
21
22using namespace Belle2;
23using namespace CDC;
24using namespace TrackFindingCDC;
25using namespace TrackingUtilities;
26
28// : m_param_chi2CutByISuperLayer{35.0, 130.0, 73.0, 76.0, 76.0, 84.0, 76.0, 100.0, 110.0} // efficiency 0.99 is a bit to loose
29 : m_param_chi2CutByISuperLayer{35.0, 75.0, 75.0, 75.0, 75.0, 75.0, 75.0, 75.0, 75.0}
30{
31}
32
33Chi2FacetFilter::Chi2FacetFilter(double chi2Cut, double penaltyWidth)
35 , m_param_penaltyFactor(penaltyWidth / chi2Cut)
36{
37}
38
40 const std::string& prefix)
41{
42 Super::exposeParameters(moduleParamList, prefix);
43
44 moduleParamList->addParameter(prefixed(prefix, "chi2CutByISuperLayer"),
46 "Acceptable chi2 values by superlayer id",
48
49 moduleParamList->addParameter(prefixed(prefix, "penaltyFactor"),
51 "Factor for cut value to obtain the width used in translation from chi2 values to weight penalties",
53}
54
56{
58 if (m_param_chi2CutByISuperLayer.size() == 1) {
59 for (int iSL = 0; iSL < ISuperLayerUtil::c_N; ++iSL) {
62 }
64 for (int iSL = 0; iSL < ISuperLayerUtil::c_N; ++iSL) {
67 }
68 } else {
69 B2ERROR("Expected chi2CutByISuperLayer to be of length 1 or "
71 << " received "
73 }
74
75}
76
78{
79 constexpr const int nSteps = 1;
80 const double chi2 = FacetFitter::fit(facet, nSteps);
81
82 ISuperLayer iSL = facet.getISuperLayer();
83 if (chi2 > m_chi2CutByISuperLayer[iSL] or std::isnan(chi2)) {
84 return NAN;
85 } else {
86 // Introducing a mini penalty to distinguish better facets.
87 double penalty = std::erf(chi2 / m_penaltyWidthByISuperLayer[iSL]);
88
89 // Good facet contains three points of the track
90 // the amount carried by this facet can the adjusted more realistically
91 return 3 - penalty;
92 }
93}
The Module parameter list class.
std::vector< double > m_param_chi2CutByISuperLayer
Parameter : The chi2 cut values distinguished by superlayer.
Chi2FacetFilter()
Constructor with the default chi2 cut value and width parameter.
double m_param_penaltyFactor
Parameter : The chi2 cut values distinguished by superlayer.
void initialize() final
Initialise the parameter caches before the processing starts.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the set of parameters of the filter to the module parameter list.
std::array< double, CDC::ISuperLayerUtil::c_N > m_penaltyWidthByISuperLayer
Memory for the chi2 cut values distinguished by superlayer.
TrackingUtilities::Weight operator()(const TrackingUtilities::CDCFacet &facet) final
Main filter method returning the weight of the facet Returns NAN if the cell shall be rejected.
std::array< double, CDC::ISuperLayerUtil::c_N > m_chi2CutByISuperLayer
Memory for the chi2 cut values distinguished by superlayer.
static double fit(const TrackingUtilities::CDCFacet &facet, int nSteps=100)
Fits a proper line to facet and returns the chi2.
Class representing a triple of neighboring oriented wire with additional trajectory information.
Definition CDCFacet.h:32
CDC::ISuperLayer getISuperLayer() const
Getter for the common superlayer id of the pair.
virtual void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
signed short ISuperLayer
The type of the layer and superlayer ids.
Definition ISuperLayer.h:24
Abstract base class for different kinds of events.
static const ISuperLayer c_N
Constant representing the total number of cdc superlayers.
Definition ISuperLayer.h:56