Belle II Software development
CKFResult.h
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#pragma once
9
10#include <tracking/trackFindingCDC/numerics/WithWeight.h>
11
12#include <genfit/MeasuredStateOnPlane.h>
13#include <Math/Vector3D.h>
14
15#include <vector>
16
17namespace Belle2 {
29 template <class ASeed, class AHit>
30 class CKFResult {
31
32 public:
34 using Seed = ASeed;
36 using Hit = AHit;
37
39 template <class AState>
40 CKFResult(const std::vector<TrackFindingCDC::WithWeight<const AState*>>& path, const genfit::MeasuredStateOnPlane& mSoP)
41 : m_seed(path.front()->getSeed()),
42 m_trackPosition(mSoP.getPos()),
43 m_trackMomentum(mSoP.getMom()),
44 m_trackCharge(static_cast<short>(mSoP.getCharge())),
45 m_seedMSoP(path.front()->getMeasuredStateOnPlane()),
46 m_mSoP(mSoP)
47 {
48 m_hits.reserve(path.size());
49
50 for (const TrackFindingCDC::WithWeight<const AState*> state : path) {
51 const Hit* hit = state->getHit();
52 if (hit) {
53 m_hits.push_back(hit);
54 }
55
56 if (state->isFitted()) {
57 const double stateChi2 = state->getChi2();
58 m_chi2 += stateChi2;
59
60 // The initial value of the maximal and minimal chi2 is NAN, so we always override this default value.
61 if (stateChi2 > m_maximalChi2 or std::isnan(m_maximalChi2)) {
62 m_maximalChi2 = stateChi2;
63 }
64
65 if (stateChi2 < m_minimalChi2 or std::isnan(m_minimalChi2)) {
66 m_minimalChi2 = stateChi2;
67 }
68 }
69
70 m_weightSum += state.getWeight();
71 }
72 }
73
75 const std::vector<const AHit*>& getHits() const
76 {
77 return m_hits;
78 }
79
81 const ASeed* getSeed() const
82 {
83 return m_seed;
84 }
85
87 double getChi2() const
88 {
89 return m_chi2;
90 }
91
93 double getMaximalChi2() const
94 {
95 return m_maximalChi2;
96 }
97
99 double getMinimalChi2() const
100 {
101 return m_minimalChi2;
102 }
103
105 const ROOT::Math::XYZVector& getPosition() const
106 {
107 return m_trackPosition;
108 }
109
111 const ROOT::Math::XYZVector& getMomentum() const
112 {
113 return m_trackMomentum;
114 }
115
117 short getCharge() const
118 {
119 return m_trackCharge;
120 }
121
123 double getWeightSum() const
124 {
125 return m_weightSum;
126 }
127
129 const genfit::MeasuredStateOnPlane& getSeedMSoP() const
130 {
131 return m_seedMSoP;
132 }
133
135 const genfit::MeasuredStateOnPlane& getMSoP() const
136 {
137 return m_mSoP;
138 }
139
140 private:
142 const ASeed* m_seed;
144 std::vector<const AHit*> m_hits;
146 double m_chi2 = 0;
148 double m_maximalChi2 = NAN;
150 double m_minimalChi2 = NAN;
152 ROOT::Math::XYZVector m_trackPosition;
154 ROOT::Math::XYZVector m_trackMomentum;
156 short m_trackCharge = 0;
158 TrackFindingCDC::Weight m_weightSum = 0;
160 genfit::MeasuredStateOnPlane m_seedMSoP;
162 genfit::MeasuredStateOnPlane m_mSoP;
163 };
165}
Object for temporary storage of a CKF tree search result.
Definition: CKFResult.h:30
double getMaximalChi2() const
Getter for the maximal chi2 of all stored hits. NAN means there is no valid chi2 at all.
Definition: CKFResult.h:93
AHit Hit
Copy hit definition.
Definition: CKFResult.h:36
CKFResult(const std::vector< TrackFindingCDC::WithWeight< const AState * > > &path, const genfit::MeasuredStateOnPlane &mSoP)
Constructor from the path of the result and the final mSoP, which defines the track position of the r...
Definition: CKFResult.h:40
genfit::MeasuredStateOnPlane m_mSoP
The measured state on plane, which this result was initialized with.
Definition: CKFResult.h:162
const ROOT::Math::XYZVector & getPosition() const
Get the position this track should start at.
Definition: CKFResult.h:105
short getCharge() const
Set the charge of the track.
Definition: CKFResult.h:117
const ASeed * getSeed() const
Getter for the stored seeds.
Definition: CKFResult.h:81
double getMinimalChi2() const
Getter for the minimal chi2 of all stored hits. NAN means there is no valid chi2 at all.
Definition: CKFResult.h:99
ROOT::Math::XYZVector m_trackMomentum
The momentum this track should start at (defined at the position)
Definition: CKFResult.h:154
double getChi2() const
Getter for the chi2.
Definition: CKFResult.h:87
std::vector< const AHit * > m_hits
The stored hits.
Definition: CKFResult.h:144
TrackFindingCDC::Weight m_weightSum
The stored sum of weights.
Definition: CKFResult.h:158
short m_trackCharge
The charge of the track.
Definition: CKFResult.h:156
double m_chi2
The stored chi2.
Definition: CKFResult.h:146
const genfit::MeasuredStateOnPlane & getMSoP() const
Getter for the mSoP associated with this result.
Definition: CKFResult.h:135
const std::vector< const AHit * > & getHits() const
Getter for the stored hits.
Definition: CKFResult.h:75
const ASeed * m_seed
The stored seed.
Definition: CKFResult.h:142
ASeed Seed
Copy seed definition.
Definition: CKFResult.h:34
double getWeightSum() const
Getter for the sum of weights.
Definition: CKFResult.h:123
double m_maximalChi2
The maximal chi2 of the single states. NAN means there is no valid chi2 at all.
Definition: CKFResult.h:148
ROOT::Math::XYZVector m_trackPosition
The position this track should start at.
Definition: CKFResult.h:152
genfit::MeasuredStateOnPlane m_seedMSoP
The measured state on plane, which was used from the seed.
Definition: CKFResult.h:160
double m_minimalChi2
The minimal chi2 of the single states NAN means there is no valid chi2 at all.
Definition: CKFResult.h:150
const genfit::MeasuredStateOnPlane & getSeedMSoP() const
Getter for the mSoP of the seed associated with this result.
Definition: CKFResult.h:129
const ROOT::Math::XYZVector & getMomentum() const
Get the momentum this track should start at (defined at the position)
Definition: CKFResult.h:111
A mixin class to attach a weight to an object.
Definition: WithWeight.h:24
Abstract base class for different kinds of events.