Belle II Software  release-05-02-19
Chi2FacetRelationFilter.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - 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 #include <tracking/trackFindingCDC/filters/facetRelation/Chi2FacetRelationFilter.h>
11 
12 #include <tracking/trackFindingCDC/fitting/FacetFitter.h>
13 
14 #include <tracking/trackFindingCDC/eventdata/hits/CDCFacet.h>
15 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
16 
17 #include <tracking/trackFindingCDC/geometry/UncertainParameterLine2D.h>
18 
19 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
20 
21 #include <framework/core/ModuleParamList.templateDetails.h>
22 
23 using namespace Belle2;
24 using namespace TrackFindingCDC;
25 
27 // : m_param_chi2CutByISuperLayer{89.0, 268.0, 205.0, 206.0, 182.0, 200.0, 174.0, 197.0, 197.0} // efficiency 0.99 is a bit to loose
28  : m_param_chi2CutByISuperLayer{89.0, 130.0, 130.0, 130.0, 130.0, 130.0, 130.0, 130.0, 130.0}
29 {
30 }
31 
32 Chi2FacetRelationFilter::Chi2FacetRelationFilter(double chi2Cut, double penaltyWidth)
33  : m_param_chi2CutByISuperLayer{chi2Cut}
34  , m_param_penaltyFactor(penaltyWidth / chi2Cut)
35 {
36 }
37 
39  const std::string& prefix)
40 {
41  Super::exposeParameters(moduleParamList, prefix);
42 
43  moduleParamList->addParameter(prefixed(prefix, "chi2CutByISuperLayer"),
45  "Acceptable chi2 values by superlayer id",
47 
48  moduleParamList->addParameter(prefixed(prefix, "penaltyFactor"),
50  "Factor for cut value to obtain the width used in translation from chi2 values to weight penalties",
52 }
53 
55 {
57  if (m_param_chi2CutByISuperLayer.size() == 1) {
58  for (int iSL = 0; iSL < ISuperLayerUtil::c_N; ++iSL) {
61  }
63  for (int iSL = 0; iSL < ISuperLayerUtil::c_N; ++iSL) {
66  }
67  } else {
68  B2ERROR("Expected chi2CutByISuperLayer to be of length 1 or "
70  << " received "
72  }
73 
74 }
75 
76 Weight Chi2FacetRelationFilter::operator()(const CDCFacet& fromFacet, const CDCFacet& toFacet)
77 {
78  if (fromFacet.getStartWireHit().isOnWire(toFacet.getEndWire())) return NAN;
79 
80  constexpr const int nSteps = 0;
81  const UncertainParameterLine2D fitLine = FacetFitter::fit(fromFacet, toFacet, nSteps);
82  const double chi2 = fitLine.chi2();
83 
84  ISuperLayer iSL = fromFacet.getISuperLayer();
85  if (chi2 > m_chi2CutByISuperLayer[iSL] or std::isnan(chi2)) {
86  return NAN;
87  } else {
88  // Introducing a mini penilty to distiguish better facets.
89  double penalty = std::erf(chi2 / m_penaltyWidthByISuperLayer[iSL]);
90 
91  // The facets contain three hits of the track each.
92  // However they have 2 common hits which we have to substract
93  // to avoid double counting.
94  // Also introduce a small penalty value to distiguish better continuations
95  // in the graph
96  return -2 - penalty;
97  }
98 }
Belle2::TrackFindingCDC::ISuperLayerUtil::c_N
static const ISuperLayer c_N
Constant representing the total number of cdc superlayers.
Definition: ISuperLayer.h:66
Belle2::TrackFindingCDC::Chi2FacetRelationFilter::Chi2FacetRelationFilter
Chi2FacetRelationFilter()
Constructor with the default chi2 cut value and width parameter.
Definition: Chi2FacetRelationFilter.cc:26
Belle2::TrackFindingCDC::CDCRLWireHitTriple::getStartWireHit
const CDCWireHit & getStartWireHit() const
Getter for the hit wire of the first oriented wire hit.
Definition: CDCRLWireHitTriple.h:212
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::Chi2FacetRelationFilter::m_param_penaltyFactor
double m_param_penaltyFactor
Parameter : The chi2 cut values distinguished by superlayer.
Definition: Chi2FacetRelationFilter.h:66
Belle2::TrackFindingCDC::CompositeProcessingSignalListener::initialize
void initialize() override
Receive and dispatch signal before the start of the event processing.
Definition: CompositeProcessingSignalListener.cc:17
Belle2::TrackFindingCDC::CDCWireHit::isOnWire
bool isOnWire(const CDCWire &wire) const
Checks if the wire hit is based on the given wire.
Definition: CDCWireHit.h:250
Belle2::TrackFindingCDC::UncertainParameterLine2D::chi2
double chi2() const
Getter for the chi square value of the line fit.
Definition: UncertainParameterLine2D.h:110
Belle2::TrackFindingCDC::CDCRLWireHitTriple::getEndWire
const CDCWire & getEndWire() const
Getter for the wire the third oriented wire hit is based on.
Definition: CDCRLWireHitTriple.h:182
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::Filter< Relation< const CDCFacet > >::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::Chi2FacetRelationFilter::initialize
void initialize() final
Initialise the parameter caches before the processing starts.
Definition: Chi2FacetRelationFilter.cc:54
Belle2::TrackFindingCDC::CDCFacet
Class representing a triple of neighboring oriented wire with additional trajectory information.
Definition: CDCFacet.h:42
Belle2::TrackFindingCDC::Chi2FacetRelationFilter::m_param_chi2CutByISuperLayer
std::vector< double > m_param_chi2CutByISuperLayer
Parameter : The chi2 cut values distinguished by superlayer.
Definition: Chi2FacetRelationFilter.h:63
Belle2::TrackFindingCDC::Chi2FacetRelationFilter::m_chi2CutByISuperLayer
std::array< double, ISuperLayerUtil::c_N > m_chi2CutByISuperLayer
Memory for the chi2 cut values distinguished by superlayer.
Definition: Chi2FacetRelationFilter.h:70
Belle2::TrackFindingCDC::Chi2FacetRelationFilter::operator()
Weight operator()(const CDCFacet &fromFacet, const CDCFacet &toFacet) final
Main filter method returning the weight of the neighborhood relation.
Definition: Chi2FacetRelationFilter.cc:76
Belle2::TrackFindingCDC::Chi2FacetRelationFilter::m_penaltyWidthByISuperLayer
std::array< double, ISuperLayerUtil::c_N > m_penaltyWidthByISuperLayer
Memory for the chi2 cut values distinguished by superlayer.
Definition: Chi2FacetRelationFilter.h:73
Belle2::TrackFindingCDC::UncertainParameterLine2D
A parameter line including including an line covariance matrix which is interpreted as located in the...
Definition: UncertainParameterLine2D.h:34
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46
Belle2::TrackFindingCDC::Chi2FacetRelationFilter::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the set of parameters of the filter to the module parameter list.
Definition: Chi2FacetRelationFilter.cc:38
Belle2::TrackFindingCDC::CDCRLWireHitTriple::getISuperLayer
ISuperLayer getISuperLayer() const
Getter for the common superlayer id of the pair.
Definition: CDCRLWireHitTriple.h:151