Belle II Software  release-08-01-10
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/trackFindingCDC/eventdata/hits/CDCFacet.h>
14 
15 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
16 
17 #include <framework/core/ModuleParamList.templateDetails.h>
18 #include <framework/logging/Logger.h>
19 
20 #include <cmath>
21 
22 using namespace Belle2;
23 using namespace TrackFindingCDC;
24 
26 // : 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
27  : m_param_chi2CutByISuperLayer{35.0, 75.0, 75.0, 75.0, 75.0, 75.0, 75.0, 75.0, 75.0}
28 {
29 }
30 
31 Chi2FacetFilter::Chi2FacetFilter(double chi2Cut, double penaltyWidth)
32  : m_param_chi2CutByISuperLayer{chi2Cut}
33  , m_param_penaltyFactor(penaltyWidth / chi2Cut)
34 {
35 }
36 
38  const std::string& prefix)
39 {
40  Super::exposeParameters(moduleParamList, prefix);
41 
42  moduleParamList->addParameter(prefixed(prefix, "chi2CutByISuperLayer"),
44  "Acceptable chi2 values by superlayer id",
46 
47  moduleParamList->addParameter(prefixed(prefix, "penaltyFactor"),
49  "Factor for cut value to obtain the width used in translation from chi2 values to weight penalties",
51 }
52 
54 {
56  if (m_param_chi2CutByISuperLayer.size() == 1) {
57  for (int iSL = 0; iSL < ISuperLayerUtil::c_N; ++iSL) {
60  }
62  for (int iSL = 0; iSL < ISuperLayerUtil::c_N; ++iSL) {
65  }
66  } else {
67  B2ERROR("Expected chi2CutByISuperLayer to be of length 1 or "
69  << " received "
71  }
72 
73 }
74 
76 {
77  constexpr const int nSteps = 1;
78  const double chi2 = FacetFitter::fit(facet, nSteps);
79 
80  ISuperLayer iSL = facet.getISuperLayer();
81  if (chi2 > m_chi2CutByISuperLayer[iSL] or std::isnan(chi2)) {
82  return NAN;
83  } else {
84  // Introducing a mini penilty to distiguish better facets.
85  double penalty = std::erf(chi2 / m_penaltyWidthByISuperLayer[iSL]);
86 
87  // Good facet contains three points of the track
88  // the amount carried by this facet can the adjusted more realistically
89  return 3 - penalty;
90  }
91 }
The Module parameter list class.
Class representing a triple of neighboring oriented wire with additional trajectory information.
Definition: CDCFacet.h:32
ISuperLayer getISuperLayer() const
Getter for the common superlayer id of the pair.
std::array< double, ISuperLayerUtil::c_N > m_chi2CutByISuperLayer
Memory for the chi2 cut values distinguished by superlayer.
std::vector< double > m_param_chi2CutByISuperLayer
Parameter : The chi2 cut values distinguished by superlayer.
Weight operator()(const CDCFacet &facet) final
Main filter method returning the weight of the facet Returns NAN if the cell shall be rejected.
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, ISuperLayerUtil::c_N > m_penaltyWidthByISuperLayer
Memory for the chi2 cut values distinguished by superlayer.
void initialize() override
Receive and dispatch signal before the start of the event processing.
static double fit(const CDCFacet &facet, int nSteps=100)
Fits a proper line to facet and returns the chi2.
Definition: FacetFitter.cc:166
virtual void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Expose the set of parameters of the filter to the module parameter list.
Definition: Filter.icc.h:40
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.
static const ISuperLayer c_N
Constant representing the total number of cdc superlayers.
Definition: ISuperLayer.h:56