Belle II Software light-2406-ragdoll
TrackFitResult.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 <framework/gearbox/Const.h>
11#include <framework/datastore/RelationsObject.h>
12#include <framework/dataobjects/Helix.h>
13#include <framework/dataobjects/UncertainHelix.h>
14#include <framework/geometry/BFieldManager.h>
15
16#include <TMatrixDSym.h>
17#include <Math/Vector3D.h>
18#include <Math/Vector4D.h>
19
20#include <stdint.h>
21#include <vector>
22#include <cmath>
23
24namespace Belle2 {
29 class HitPatternCDC;
30 class HitPatternVXD;
31
50 public:
53
73 TrackFitResult(const ROOT::Math::XYZVector& position, const ROOT::Math::XYZVector& momentum,
74 const TMatrixDSym& covariance, const short int charge,
75 const Const::ParticleType& particleType, const float pValue,
76 const float bField,
77 const uint64_t hitPatternCDCInitializer,
78 const uint32_t hitPatternVXDInitializer,
79 const float NDF);
80
93 TrackFitResult(const std::vector<float>& tau, const std::vector<float>& cov5,
94 const Const::ParticleType& particleType, const float pValue,
95 const uint64_t hitPatternCDCInitializer,
96 const uint32_t hitPatternVXDInitializer,
97 const float NDF
98 );
103 void updateTrackFitResult(const TrackFitResult& input);
104
106 void mask() {m_pValue = NAN;}
107
109 ROOT::Math::XYZVector getPosition() const { return getHelix().getPerigee(); }
110
116 ROOT::Math::XYZVector getMomentum() const
117 {
118 const double bField = BFieldManager::getField(getPosition()).Z() / Unit::T;
119 return getHelix().getMomentum(bField);
120 }
121
125 ROOT::Math::PxPyPzEVector get4Momentum() const
126 {
127 const ROOT::Math::XYZVector momentum = getMomentum();
128 return ROOT::Math::PxPyPzEVector(momentum.X(), momentum.Y(), momentum.Z(), getEnergy());
129 }
130
134 double getEnergy() const
135 {
136 return std::sqrt(getMomentum().Mag2() + getParticleType().getMass() * getParticleType().getMass());
137 }
138
142 {
143 const double bField = BFieldManager::getField(getPosition()).Z() / Unit::T;
144 return getHelix().getTransverseMomentum(bField);
145 }
146
148 TMatrixDSym getCovariance6() const
149 {
150 const double bField = BFieldManager::getField(getPosition()).Z() / Unit::T;
152 }
153
156
161 short getChargeSign() const { return (getOmega() > 0) - (getOmega() < 0); }
162
164 double getPValue() const { return m_pValue; }
165
167 float getNDF() const;
168
170 double getChi2() const;
171
172 //------------------------------------------------------------------------
173 // --- Getters for perigee helix parameters
174 //------------------------------------------------------------------------
179 double getD0() const { return m_tau[iD0]; }
180
185 double getPhi0() const { return m_tau[iPhi0]; }
186
188 double getPhi() const { return getPhi0(); }
189
195 double getOmega() const { return m_tau[iOmega]; }
196
201 double getZ0() const { return m_tau[iZ0]; }
202
207 double getTanLambda() const { return m_tau[iTanLambda]; }
208
210 double getCotTheta() const { return getTanLambda(); }
211
216 std::vector<float> getTau() const { return std::vector<float>(m_tau, m_tau + c_NPars); }
217
222 std::vector<float> getCov() const { return std::vector<float>(m_cov5, m_cov5 + c_NCovEntries); }
223
228 TMatrixDSym getCovariance5() const;
229
232 { return Helix(getD0(), getPhi0(), getOmega(), getZ0(), getTanLambda()); }
233
235 Helix getHelix(float momentumScale) const
236 { return Helix(getD0(), getPhi0(), getOmega() / momentumScale, getZ0(), getTanLambda()); }
237
240 {
241 return UncertainHelix(getD0(), getPhi0(), getOmega(), getZ0(),
243 }
244
247
250
252 virtual std::string getInfoHTML() const override;
253
255 private:
256
257 //---------------------------------------------------------------------------------------------------------------------------
259 unsigned int m_pdg;
260
262 Double32_t m_pValue;
263
269 static const unsigned int c_NPars = 5;
270 static const unsigned int c_NCovEntries = 5 * 6 / 2;
276 static const unsigned int iD0 = 0;
277 static const unsigned int iPhi0 = 1;
278 static const unsigned int iOmega = 2;
279 static const unsigned int iZ0 = 3;
280 static const unsigned int iTanLambda = 4;
284 Double32_t m_tau[c_NPars];
285
291
302
304 static const uint16_t c_NDFFlag = 0xFFFF;
305
309 uint16_t m_NDF100;
310
312 /* Version history:
313 ver 10: m_NDF -> m_NDF100, we store NDFx100, to have a 2-digit number inside an integer
314 ver 9: change m_pValue, m_pdg, m_hitPatternVXDInitializer to a non-const value
315 ver 8: add NDF
316 ver 7: fixed sign errors in the translation of position and momentum covariances.
317 ver 6: use fixed size arrays instead of vectors (add schema evolution rule), use Double32_t.
318 ver 5: CDC Hit Pattern now a single variable (add schema evolution rule).
319 ver 4: added hit pattern
320 ver 3: back to vectors for the elements
321 ver 4: fixed-size arrays for the elements <------- incompatible with later version 4
322 ver 3: add data fields for hit patterns
323 ver 2: re-arranging of members
324 ver 1:
325 ver 2: <------- incompatible with later version 2
326 ver 1:
327 */
328 friend class PostMergeUpdaterModule;
329 };
331}
The ParticleType class for identifying different particle types.
Definition: Const.h:408
This class represents an ideal helix in perigee parameterization.
Definition: Helix.h:59
ROOT::Math::XYZVector getMomentum(const double bZ) const
Getter for vector of momentum at the perigee position.
Definition: Helix.cc:89
ROOT::Math::XYZVector getPerigee() const
Getter for the perigee position.
Definition: Helix.cc:69
double getTransverseMomentum(const double bZ) const
Getter for the absolute value of the transverse momentum at the perigee.
Definition: Helix.cc:99
Hit pattern of CDC hits within a track.
Definition: HitPatternCDC.h:35
Hit pattern of the VXD within a track.
Definition: HitPatternVXD.h:37
If the content of two DataStores are merged using the 'MergeDataStoreModule', several kinematic prope...
Defines interface for accessing relations of objects in StoreArray.
Values of the result of a track fit with a given particle hypothesis.
static const unsigned int c_NPars
Number of helix parameters.
Helix getHelix() const
Conversion to framework Helix (without covariance).
TMatrixDSym getCovariance5() const
Getter for covariance matrix of perigee parameters in matrix form.
uint32_t m_hitPatternVXDInitializer
Member for initializing the information about hits in the VXD.
static const unsigned int iZ0
Index for z0.
ClassDefOverride(TrackFitResult, 10)
Values of the result of a track fit with a given particle hypothesis.
static const unsigned int c_NCovEntries
Number of covariance entries.
float getNDF() const
Getter for number of degrees of freedom of the track fit.
Helix getHelix(float momentumScale) const
Conversion to framework Helix with momentum scaling (without covariance).
double getPhi() const
Getter for phi0 with CDF naming convention.
unsigned int m_pdg
PDG Code for hypothesis with which the corresponding fit was performed.
Double32_t m_tau[c_NPars]
perigee helix parameters; tau = d0, phi0, omega, z0, tanLambda.
double getChi2() const
Get chi2 given NDF and p-value.
short getChargeSign() const
Return track charge (1 or -1).
double getPValue() const
Getter for Chi2 Probability of the track fit.
Double32_t m_pValue
Chi2 Probability of the fit.
double getEnergy() const
Getter for the Energy at the closest approach of the track in the r/phi projection.
TMatrixDSym getCovariance6() const
Position and Momentum Covariance Matrix.
double getCotTheta() const
Getter for tanLambda with CDF naming convention.
virtual std::string getInfoHTML() const override
Return a short summary of this object's contents in HTML format.
ROOT::Math::PxPyPzEVector get4Momentum() const
Getter for the 4Momentum at the closest approach of the track in the r/phi projection.
uint16_t m_NDF100
Member for number of degrees of freedom multiplied by 100 in order to store inside an int a float wit...
std::vector< float > getTau() const
Getter for all perigee parameters.
double getOmega() const
Getter for omega.
void updateTrackFitResult(const TrackFitResult &input)
update the TrackFitResults
std::vector< float > getCov() const
Getter for all covariance matrix elements of perigee parameters.
double getD0() const
Getter for d0.
double getTransverseMomentum() const
Getter for the absolute value of the transverse momentum at the perigee.
double getTanLambda() const
Getter for tanLambda.
static const unsigned int iTanLambda
Index tan lambda.
TrackFitResult()
Constructor initializing everything to zero.
static const unsigned int iD0
Index for d0.
uint64_t m_hitPatternCDCInitializer
Member for initializing the information about hits in the CDC.
void mask()
mask this TrackFitResults by setting the pValue to nan
static const unsigned int iOmega
Index for omega.
Const::ParticleType getParticleType() const
Getter for ParticleType of the mass hypothesis of the track fit.
static const uint16_t c_NDFFlag
backward compatibility initialisation for NDF
double getZ0() const
Getter for z0.
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
ROOT::Math::XYZVector getPosition() const
Getter for vector of position at closest approach of track in r/phi projection.
Double32_t m_cov5[c_NCovEntries]
The 15 = 5*(5+1)/2 covariance matrix elements.
static const unsigned int iPhi0
Index for phi0.
HitPatternCDC getHitPatternCDC() const
Getter for the hit pattern in the CDC;.
UncertainHelix getUncertainHelix() const
Conversion to framework Uncertain Helix (i.e., with covariance).
double getPhi0() const
Getter for phi0.
HitPatternVXD getHitPatternVXD() const
Getter for the hit pattern in the VXD;.
This class represents an ideal helix in perigee parameterization including the covariance matrix of t...
TMatrixDSym getCartesianCovariance(const double bZ_tesla=1.5) const
Getter for the position and momentum covariance matrix.
static const double T
[tesla]
Definition: Unit.h:120
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
Definition: BFieldManager.h:91
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24