Belle II Software development
Chi2FacetRelationFilter.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/filters/facetRelation/Chi2FacetRelationFilter.h>
9
10#include <tracking/trackFindingCDC/fitting/FacetFitter.h>
11
12#include <tracking/trackFindingCDC/eventdata/hits/CDCFacet.h>
13#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
14
15#include <tracking/trackFindingCDC/geometry/UncertainParameterLine2D.h>
16
17#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
18
19#include <framework/core/ModuleParamList.templateDetails.h>
20
21using namespace Belle2;
22using namespace TrackFindingCDC;
23
25// : 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
26 : m_param_chi2CutByISuperLayer{89.0, 130.0, 130.0, 130.0, 130.0, 130.0, 130.0, 130.0, 130.0}
27{
28}
29
30Chi2FacetRelationFilter::Chi2FacetRelationFilter(double chi2Cut, double penaltyWidth)
31 : m_param_chi2CutByISuperLayer{chi2Cut}
32 , m_param_penaltyFactor(penaltyWidth / chi2Cut)
33{
34}
35
37 const std::string& prefix)
38{
39 Super::exposeParameters(moduleParamList, prefix);
40
41 moduleParamList->addParameter(prefixed(prefix, "chi2CutByISuperLayer"),
43 "Acceptable chi2 values by superlayer id",
45
46 moduleParamList->addParameter(prefixed(prefix, "penaltyFactor"),
48 "Factor for cut value to obtain the width used in translation from chi2 values to weight penalties",
50}
51
53{
55 if (m_param_chi2CutByISuperLayer.size() == 1) {
56 for (int iSL = 0; iSL < ISuperLayerUtil::c_N; ++iSL) {
59 }
61 for (int iSL = 0; iSL < ISuperLayerUtil::c_N; ++iSL) {
64 }
65 } else {
66 B2ERROR("Expected chi2CutByISuperLayer to be of length 1 or "
68 << " received "
70 }
71
72}
73
74Weight Chi2FacetRelationFilter::operator()(const CDCFacet& fromFacet, const CDCFacet& toFacet)
75{
76 if (fromFacet.getStartWireHit().isOnWire(toFacet.getEndWire())) return NAN;
77
78 constexpr const int nSteps = 0;
79 const UncertainParameterLine2D fitLine = FacetFitter::fit(fromFacet, toFacet, nSteps);
80 const double chi2 = fitLine.chi2();
81
82 ISuperLayer iSL = fromFacet.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 // The facets contain three hits of the track each.
90 // However they have 2 common hits which we have to subtract
91 // to avoid double counting.
92 // Also introduce a small penalty value to distinguish better continuations
93 // in the graph
94 return -2 - penalty;
95 }
96}
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.
const CDCWireHit & getStartWireHit() const
Getter for the hit wire of the first oriented wire hit.
const CDCWire & getEndWire() const
Getter for the wire the third oriented wire hit is based on.
bool isOnWire(const CDCWire &wire) const
Checks if the wire hit is based on the given wire.
Definition: CDCWireHit.h:242
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.
double m_param_penaltyFactor
Parameter : The chi2 cut values distinguished by superlayer.
void initialize() final
Initialise the parameter caches before the processing starts.
Chi2FacetRelationFilter()
Constructor with the default chi2 cut value and width parameter.
std::array< double, ISuperLayerUtil::c_N > m_penaltyWidthByISuperLayer
Memory for the chi2 cut values distinguished by superlayer.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the set of parameters of the filter to the module parameter list.
Weight operator()(const CDCFacet &fromFacet, const CDCFacet &toFacet) final
Main filter method returning the weight of the neighborhood relation.
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
A parameter line including including an line covariance matrix which is interpreted as located in the...
double chi2() const
Getter for the chi square value of the line fit.
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