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/trackingUtilities/eventdata/hits/CDCFacet.h>
13#include <tracking/trackingUtilities/eventdata/hits/CDCWireHit.h>
14
15#include <tracking/trackingUtilities/geometry/UncertainParameterLine2D.h>
16
17#include <tracking/trackingUtilities/utilities/StringManipulation.h>
18
19#include <framework/core/ModuleParamList.templateDetails.h>
20
21using namespace Belle2;
22using namespace CDC;
23using namespace TrackFindingCDC;
24using namespace TrackingUtilities;
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
32Chi2FacetRelationFilter::Chi2FacetRelationFilter(double chi2Cut, double penaltyWidth)
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
76Weight 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 penalty to distinguish 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 subtract
93 // to avoid double counting.
94 // Also introduce a small penalty value to distinguish better continuations
95 // in the graph
96 return -2 - penalty;
97 }
98}
The Module parameter list class.
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.
TrackingUtilities::Weight operator()(const TrackingUtilities::CDCFacet &fromFacet, const TrackingUtilities::CDCFacet &toFacet) final
Main filter method returning the weight of the neighborhood relation.
std::array< double, CDC::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.
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.
const CDC::CDCWire & getEndWire() const
Getter for the wire the third oriented wire hit is based on.
const CDCWireHit & getStartWireHit() const
Getter for the hit wire of the first oriented wire hit.
bool isOnWire(const CDC::CDCWire &wire) const
Checks if the wire hit is based on the given wire.
Definition CDCWireHit.h:245
void initialize() override
Receive and dispatch signal before the start of the event processing.
virtual void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Expose the set of parameters of the filter to the module parameter list.
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.
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