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 // Same value as FacetFitter::fit(fromFacet, toFacet, 0).chi2() without constructing the line
81 const double chi2 = FacetFitter::fitChi2(fromFacet, toFacet);
82
83 ISuperLayer iSL = fromFacet.getISuperLayer();
84 if (chi2 > m_chi2CutByISuperLayer[iSL] or std::isnan(chi2)) {
85 return NAN;
86 } else {
87 // Introducing a mini penalty to distinguish better facets.
88 double penalty = std::erf(chi2 / m_penaltyWidthByISuperLayer[iSL]);
89
90 // The facets contain three hits of the track each.
91 // However they have 2 common hits which we have to subtract
92 // to avoid double counting.
93 // Also introduce a small penalty value to distinguish better continuations
94 // in the graph
95 return -2 - penalty;
96 }
97}
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 fitChi2(const TrackingUtilities::CDCFacet &fromFacet, const TrackingUtilities::CDCFacet &toFacet)
Calculate only the chi2 of a line fitted to the hits of the two facets.
Class representing a triple of neighboring oriented wire with additional trajectory information.
Definition CDCFacet.h:33
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:243
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.
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