Belle II Software  release-05-01-25
CKFResult.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/numerics/WithWeight.h>
13 
14 #include <genfit/MeasuredStateOnPlane.h>
15 #include <TVector3.h>
16 
17 #include <vector>
18 
19 namespace Belle2 {
31  template <class ASeed, class AHit>
32  class CKFResult {
33 
34  public:
36  using Seed = ASeed;
38  using Hit = AHit;
39 
41  template <class AState>
42  CKFResult(const std::vector<TrackFindingCDC::WithWeight<const AState*>>& path, const genfit::MeasuredStateOnPlane& mSoP)
43  : m_seed(path.front()->getSeed()),
44  m_trackPosition(mSoP.getPos()),
45  m_trackMomentum(mSoP.getMom()),
46  m_trackCharge(static_cast<short>(mSoP.getCharge())),
47  m_seedMSoP(path.front()->getMeasuredStateOnPlane()),
48  m_mSoP(mSoP)
49  {
50  m_hits.reserve(path.size());
51 
52  for (const TrackFindingCDC::WithWeight<const AState*> state : path) {
53  const Hit* hit = state->getHit();
54  if (hit) {
55  m_hits.push_back(hit);
56  }
57 
58  if (state->isFitted()) {
59  const double stateChi2 = state->getChi2();
60  m_chi2 += stateChi2;
61 
62  // The initial value of the maximal and minimal chi2 is NAN, so we always override this default value.
63  if (stateChi2 > m_maximalChi2 or std::isnan(m_maximalChi2)) {
64  m_maximalChi2 = stateChi2;
65  }
66 
67  if (stateChi2 < m_minimalChi2 or std::isnan(m_minimalChi2)) {
68  m_minimalChi2 = stateChi2;
69  }
70  }
71 
72  m_weightSum += state.getWeight();
73  }
74  }
75 
77  const std::vector<const AHit*>& getHits() const
78  {
79  return m_hits;
80  }
81 
83  const ASeed* getSeed() const
84  {
85  return m_seed;
86  }
87 
89  double getChi2() const
90  {
91  return m_chi2;
92  }
93 
95  double getMaximalChi2() const
96  {
97  return m_maximalChi2;
98  }
99 
101  double getMinimalChi2() const
102  {
104  }
105 
107  const TVector3& getPosition() const
108  {
110  }
111 
113  const TVector3& getMomentum() const
114  {
116  }
117 
119  short getCharge() const
120  {
122  }
123 
125  double getWeightSum() const
126  {
127  return m_weightSum;
128  }
129 
132  {
133  return m_seedMSoP;
134  }
135 
138  {
139  return m_mSoP;
140  }
141 
142  private:
144  const ASeed* m_seed;
146  std::vector<const AHit*> m_hits;
148  double m_chi2 = 0;
150  double m_maximalChi2 = NAN;
152  double m_minimalChi2 = NAN;
154  TVector3 m_trackPosition;
156  TVector3 m_trackMomentum;
158  short m_trackCharge = 0;
160  TrackFindingCDC::Weight m_weightSum = 0;
165  };
167 }
Belle2::CKFResult::m_hits
std::vector< const AHit * > m_hits
The stored hits.
Definition: CKFResult.h:154
Belle2::CKFResult::m_chi2
double m_chi2
The stored chi2.
Definition: CKFResult.h:156
genfit::MeasuredStateOnPlane
#StateOnPlane with additional covariance matrix.
Definition: MeasuredStateOnPlane.h:39
Belle2::CKFResult::Seed
ASeed Seed
Copy seed definition.
Definition: CKFResult.h:44
Belle2::CKFResult::getSeedMSoP
const genfit::MeasuredStateOnPlane & getSeedMSoP() const
Getter for the mSoP of the seed associated with this result.
Definition: CKFResult.h:139
Belle2::CKFResult::getSeed
const ASeed * getSeed() const
Getter for the stored seeds.
Definition: CKFResult.h:91
Belle2::CKFResult::m_seedMSoP
genfit::MeasuredStateOnPlane m_seedMSoP
The measured state on plane, which was used from the seed.
Definition: CKFResult.h:170
Belle2::CKFResult::getMomentum
const TVector3 & getMomentum() const
Get the momentum this track should start at (defined at the position)
Definition: CKFResult.h:121
Belle2::CKFResult::m_trackMomentum
TVector3 m_trackMomentum
The momentum this track should start at (defined at the position)
Definition: CKFResult.h:164
Belle2::CKFResult::getPosition
const TVector3 & getPosition() const
Get the position this track should start at.
Definition: CKFResult.h:115
Belle2::SpacePoint
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:52
Belle2::CKFResult::m_minimalChi2
double m_minimalChi2
The minimal chi2 of the single states NAN means there is no valid chi2 at all.
Definition: CKFResult.h:160
Belle2::CKFResult::m_seed
const ASeed * m_seed
The stored seed.
Definition: CKFResult.h:152
Belle2::CKFResult::m_trackCharge
short m_trackCharge
The charge of the track.
Definition: CKFResult.h:166
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::CKFResult::getCharge
short getCharge() const
Set the charge of the track.
Definition: CKFResult.h:127
Belle2::CKFResult::Hit
AHit Hit
Copy hit definition.
Definition: CKFResult.h:46
Belle2::CKFResult::getMaximalChi2
double getMaximalChi2() const
Getter for the maximal chi2 of all stored hits. NAN means there is no valid chi2 at all.
Definition: CKFResult.h:103
Belle2::CKFResult::getChi2
double getChi2() const
Getter for the chi2.
Definition: CKFResult.h:97
Belle2::CKFResult::m_weightSum
TrackFindingCDC::Weight m_weightSum
The stored sum of weights.
Definition: CKFResult.h:168
Belle2::CKFResult::getHits
const std::vector< const AHit * > & getHits() const
Getter for the stored hits.
Definition: CKFResult.h:85
Belle2::CKFResult::m_mSoP
genfit::MeasuredStateOnPlane m_mSoP
The measured state on plane, which this result was initialized with.
Definition: CKFResult.h:172
Belle2::TrackFindingCDC::WithWeight
A mixin class to attach a weight to an object.
Definition: WithWeight.h:34
Belle2::CKFResult::CKFResult
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:50
Belle2::CKFResult::m_maximalChi2
double m_maximalChi2
The maximal chi2 of the single states. NAN means there is no valid chi2 at all.
Definition: CKFResult.h:158
Belle2::CKFResult::getMinimalChi2
double getMinimalChi2() const
Getter for the minimal chi2 of all stored hits. NAN means there is no valid chi2 at all.
Definition: CKFResult.h:109
Belle2::CKFResult::getMSoP
const genfit::MeasuredStateOnPlane & getMSoP() const
Getter for the mSoP associated with this result.
Definition: CKFResult.h:145
Belle2::CKFResult::m_trackPosition
TVector3 m_trackPosition
The position this track should start at.
Definition: CKFResult.h:162
Belle2::CKFResult::getWeightSum
double getWeightSum() const
Getter for the sum of weights.
Definition: CKFResult.h:133