Belle II Software  release-05-01-25
Chi2FacetFilter.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <tracking/trackFindingCDC/filters/facet/Chi2FacetFilter.h>
12 
13 #include <tracking/trackFindingCDC/fitting/FacetFitter.h>
14 
15 #include <tracking/trackFindingCDC/eventdata/hits/CDCFacet.h>
16 
17 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
18 
19 #include <framework/core/ModuleParamList.templateDetails.h>
20 #include <framework/logging/Logger.h>
21 
22 #include <cmath>
23 
24 using namespace Belle2;
25 using namespace TrackFindingCDC;
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 
33 Chi2FacetFilter::Chi2FacetFilter(double chi2Cut, double penaltyWidth)
34  : m_param_chi2CutByISuperLayer{chi2Cut}
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 penilty to distiguish 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 }
Belle2::TrackFindingCDC::ISuperLayerUtil::c_N
static const ISuperLayer c_N
Constant representing the total number of cdc superlayers.
Definition: ISuperLayer.h:66
Belle2::TrackFindingCDC::Chi2FacetFilter::m_penaltyWidthByISuperLayer
std::array< double, ISuperLayerUtil::c_N > m_penaltyWidthByISuperLayer
Memory for the chi2 cut values distinguished by superlayer.
Definition: Chi2FacetFilter.h:76
Belle2::TrackFindingCDC::Chi2FacetFilter::Chi2FacetFilter
Chi2FacetFilter()
Constructor with the default chi2 cut value and width parameter.
Definition: Chi2FacetFilter.cc:27
Belle2::TrackFindingCDC::FacetFitter::fit
static double fit(const CDCFacet &facet, int nSteps=100)
Fits a proper line to facet and returns the chi2.
Belle2::TrackFindingCDC::Chi2FacetFilter::initialize
void initialize() final
Initialise the parameter caches before the processing starts.
Definition: Chi2FacetFilter.cc:55
Belle2::TrackFindingCDC::CompositeProcessingSignalListener::initialize
void initialize() override
Receive and dispatch signal before the start of the event processing.
Definition: CompositeProcessingSignalListener.cc:17
Belle2::TrackFindingCDC::Chi2FacetFilter::m_param_chi2CutByISuperLayer
std::vector< double > m_param_chi2CutByISuperLayer
Parameter : The chi2 cut values distinguished by superlayer.
Definition: Chi2FacetFilter.h:66
Belle2::ModuleParamList::addParameter
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Definition: ModuleParamList.templateDetails.h:38
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::Chi2FacetFilter::m_chi2CutByISuperLayer
std::array< double, ISuperLayerUtil::c_N > m_chi2CutByISuperLayer
Memory for the chi2 cut values distinguished by superlayer.
Definition: Chi2FacetFilter.h:73
Belle2::TrackFindingCDC::Filter::exposeParameters
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:42
Belle2::TrackFindingCDC::Chi2FacetFilter::m_param_penaltyFactor
double m_param_penaltyFactor
Parameter : The chi2 cut values distinguished by superlayer.
Definition: Chi2FacetFilter.h:69
Belle2::TrackFindingCDC::Chi2FacetFilter::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the set of parameters of the filter to the module parameter list.
Definition: Chi2FacetFilter.cc:39
Belle2::TrackFindingCDC::CDCFacet
Class representing a triple of neighboring oriented wire with additional trajectory information.
Definition: CDCFacet.h:42
Belle2::TrackFindingCDC::Chi2FacetFilter::operator()
Weight operator()(const CDCFacet &facet) final
Main filter method returning the weight of the facet Returns NAN if the cell shall be rejected.
Definition: Chi2FacetFilter.cc:77
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46
Belle2::TrackFindingCDC::CDCRLWireHitTriple::getISuperLayer
ISuperLayer getISuperLayer() const
Getter for the common superlayer id of the pair.
Definition: CDCRLWireHitTriple.h:151