Belle II Software development
MakeMotherKFit Class Reference

MakeMotherKFit is a class to build mother particle from kinematically fitted daughters. More...

#include <MakeMotherKFit.h>

Public Member Functions

 MakeMotherKFit (void)
 Construct an object with no argument.
 
 ~MakeMotherKFit (void)
 Destruct the object.
 
enum KFitError::ECode addTrack (const KFitTrack &kp)
 Add a track to the make-mother object.
 
enum KFitError::ECode addTrack (const CLHEP::HepLorentzVector &p, const HepPoint3D &x, const CLHEP::HepSymMatrix &e, const double q, const int flag=KFitConst::kAfterFit)
 Add a track to the make-mother object with specifying its momentum, position, error matrix, and charge.
 
enum KFitError::ECode setMagneticField (const double mf)
 Change a magnetic field from the default value KFitConst::kDefaultMagneticField.
 
enum KFitError::ECode setVertex (const HepPoint3D &v)
 Set a vertex position of the mother particle.
 
enum KFitError::ECode setVertexError (const CLHEP::HepSymMatrix &e)
 Set a vertex error matrix of the mother particle.
 
enum KFitError::ECode setTrackVertexError (const CLHEP::HepMatrix &e)
 Set a vertex error matrix of the child particle in the addTrack'ed order.
 
enum KFitError::ECode setTrackZeroVertexError (void)
 Indicate no vertex uncertainty in the child particle in the addTrack'ed order.
 
enum KFitError::ECode setCorrelation (const CLHEP::HepMatrix &e)
 Set a correlation matrix.
 
enum KFitError::ECode setZeroCorrelation (void)
 Indicate no correlation between tracks.
 
enum KFitError::ECode setFlagAtDecayPoint (const bool flag)
 Set a flag to control computational point for the mother particle property at the decay point or not.
 
enum KFitError::ECode setFlagBeforeAfter (const int flag)
 Set a flag to control computational parameters for the mother particle property before or after the fit.
 
enum KFitError::ECode getErrorCode (void) const
 Get a code of the last error.
 
const KFitTrack getMother (void) const
 Get a track object of the mother particle.
 
const CLHEP::HepLorentzVector getMotherMomentum (void) const
 Get a Lorentz vector of the mother particle.
 
const HepPoint3D getMotherPosition (void) const
 Get a position of the mother particle.
 
const CLHEP::HepSymMatrix getMotherError (void) const
 Get an error matrix of the mother particle.
 
enum KFitError::ECode doMake (void)
 Perform a reconstruction of mother particle.
 

Private Member Functions

void calculateError (CLHEP::HepSymMatrix *Ec) const
 Make a matrix to calculate error matrix of the mother particle.
 
void calculateDELMDELC (CLHEP::HepMatrix *e) const
 Make delMdelC to calculate error matrix of the mother particle.
 

Private Attributes

enum KFitError::ECode m_ErrorCode
 Error code.
 
bool m_FlagAtDecayPoint
 Flag controlled by setFlagAtDecayPoint().
 
int m_FlagBeforeAfter
 Flag controlled by setFlagBeforeAfter().
 
bool m_FlagVertexError
 Flag to indicate if the vertex error matrix of the mother particle is preset.
 
bool m_FlagCorrelation
 Flag to indicate if the correlation matrix among the child particles is preset.
 
bool m_FlagTrackVertexError
 Flag to indicate if the vertex error matrix of the child particle is preset.
 
double m_MagneticField
 Magnetic field.
 
int m_TrackCount
 Number of tracks.
 
std::vector< KFitTrackm_Tracks
 Array of track objects of the child particles.
 
std::vector< CLHEP::HepMatrix > m_TrackVertexError
 Array of vertex error matrices of the child particles.
 
std::vector< CLHEP::HepMatrix > m_Correlation
 Array of correlation matrices among the child particles.
 
CLHEP::Hep3Vector m_Vertex
 Vertex position of the mother particle.
 
CLHEP::HepSymMatrix m_VertexError
 Vertex error matrix of the mother particle.
 
double m_Charge
 Charge of the mother particle.
 
KFitTrack m_Mother
 Track object of the mother particle.
 

Detailed Description

MakeMotherKFit is a class to build mother particle from kinematically fitted daughters.

Definition at line 40 of file MakeMotherKFit.h.

Constructor & Destructor Documentation

◆ MakeMotherKFit()

MakeMotherKFit ( void  )

Construct an object with no argument.

Definition at line 19 of file MakeMotherKFit.cc.

19 :
20 m_Vertex(Hep3Vector()),
21 m_VertexError(HepSymMatrix(3, 0))
22{
24 m_FlagAtDecayPoint = true;
25 m_FlagVertexError = false;
26 m_FlagCorrelation = false;
30 m_TrackCount = 0;
31 m_Charge = 0;
32}
bool m_FlagTrackVertexError
Flag to indicate if the vertex error matrix of the child particle is preset.
double m_Charge
Charge of the mother particle.
bool m_FlagAtDecayPoint
Flag controlled by setFlagAtDecayPoint().
double m_MagneticField
Magnetic field.
CLHEP::Hep3Vector m_Vertex
Vertex position of the mother particle.
enum KFitError::ECode m_ErrorCode
Error code.
CLHEP::HepSymMatrix m_VertexError
Vertex error matrix of the mother particle.
bool m_FlagVertexError
Flag to indicate if the vertex error matrix of the mother particle is preset.
bool m_FlagCorrelation
Flag to indicate if the correlation matrix among the child particles is preset.
int m_TrackCount
Number of tracks.
int m_FlagBeforeAfter
Flag controlled by setFlagBeforeAfter().
static constexpr double kDefaultMagneticField
Default magnetic field when not set externally.
Definition: KFitConst.h:51
static const int kAfterFit
Input parameter to specify after-fit when setting/getting a track attribute.
Definition: KFitConst.h:37

Member Function Documentation

◆ addTrack() [1/2]

enum KFitError::ECode addTrack ( const CLHEP::HepLorentzVector &  p,
const HepPoint3D x,
const CLHEP::HepSymMatrix &  e,
const double  q,
const int  flag = KFitConst::kAfterFit 
)

Add a track to the make-mother object with specifying its momentum, position, error matrix, and charge.

This function internally calls addTrack(const KFitTrack &kp).

Parameters
pLorentz vector of the track
xposition of the track
e(7x7) error matrix of the track
qcharge of the track
flagKFitConst::kBeforeFit or KFitConst::kAfterFit
Returns
error code (zero if success)

Definition at line 49 of file MakeMotherKFit.cc.

50 {
51 if (e.num_row() != (int)KFitConst::kNumber7)
52 {
54 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
55 return m_ErrorCode;
56 }
57
58 return this->addTrack(KFitTrack(p, x, e, q, flag));
59}
static void displayError(const char *file, const int line, const char *func, const enum ECode code)
Display a description of error and its location.
Definition: KFitError.h:72
@ kBadMatrixSize
Wrong correlation matrix size.
Definition: KFitError.h:49
KFitTrack is a container of the track information (Lorentz vector, position, and error matrix),...
Definition: KFitTrack.h:38
enum KFitError::ECode addTrack(const KFitTrack &kp)
Add a track to the make-mother object.
static const int kNumber7
Constant 7 to check matrix size (internal use)
Definition: KFitConst.h:32

◆ addTrack() [2/2]

enum KFitError::ECode addTrack ( const KFitTrack kp)

Add a track to the make-mother object.

Parameters
kpobject of the track
Returns
error code (zero if success)

Definition at line 39 of file MakeMotherKFit.cc.

39 {
40 m_Tracks.push_back(p);
41 m_Charge += p.getCharge();
42 m_TrackCount = m_Tracks.size();
43
45}
std::vector< KFitTrack > m_Tracks
Array of track objects of the child particles.

◆ calculateDELMDELC()

void calculateDELMDELC ( CLHEP::HepMatrix *  e) const
private

Make delMdelC to calculate error matrix of the mother particle.

Parameters
edelMdelC container

Definition at line 306 of file MakeMotherKFit.cc.

307{
308 // ...local parameters
309 double sum_a = 0;
310
311 for (int i = 0; i < m_TrackCount; i++) {
312 const double c = Belle2::Const::speedOfLight * 1e-4;
313 double a = -c * m_MagneticField * m_Tracks[i].getCharge();
314 sum_a += a;
315
316 // ...sets "a" in dMdC.
317 (*dMdC)[0][5 + i * KFitConst::kNumber7] = a;
318 (*dMdC)[1][4 + i * KFitConst::kNumber7] = -a;
319
320 // ...sets "1" in dMdC.
321 (*dMdC)[0][0 + i * KFitConst::kNumber7] = 1.;
322 (*dMdC)[1][1 + i * KFitConst::kNumber7] = 1.;
323 (*dMdC)[2][2 + i * KFitConst::kNumber7] = 1.;
324 (*dMdC)[3][3 + i * KFitConst::kNumber7] = 1.;
325 }
326
327 // ...sets "1" in dMdC.
328 (*dMdC)[4][0 + m_TrackCount * KFitConst::kNumber7] = 1.;
329 (*dMdC)[5][1 + m_TrackCount * KFitConst::kNumber7] = 1.;
330 (*dMdC)[6][2 + m_TrackCount * KFitConst::kNumber7] = 1.;
331
332 // ...sets "sum_a" in dMdC.
333 (*dMdC)[0][1 + m_TrackCount * KFitConst::kNumber7] = - sum_a;
334 (*dMdC)[1][0 + m_TrackCount * KFitConst::kNumber7] = sum_a;
335}
static const double speedOfLight
[cm/ns]
Definition: Const.h:695

◆ calculateError()

void calculateError ( CLHEP::HepSymMatrix *  Ec) const
private

Make a matrix to calculate error matrix of the mother particle.

Parameters
Ecerror matrix container

Definition at line 254 of file MakeMotherKFit.cc.

255{
256 // ...error matrix of tracks
257 {
258 int i = 0;
259 for (const auto& track : m_Tracks) {
260 (*Ec).sub(i * KFitConst::kNumber7 + 1, track.getError(m_FlagBeforeAfter));
261 i++;
262 }
263 }
264
265
266 // ...error matrix between tracks
267 if (m_FlagCorrelation) {
268 int i = 0, j = 1;
269 for (const auto& hm : m_Correlation) {
270 for (int k = 0; k < KFitConst::kNumber7; k++) for (int l = 0; l < KFitConst::kNumber7; l++) {
271 (*Ec)[k + i * KFitConst::kNumber7][l + j * KFitConst::kNumber7] = hm[k][l];
272 }
273
274 if (j != m_TrackCount - 1) {
275 j++;
276 } else if (i != m_TrackCount - 2) {
277 i++;
278 j = i + 1;
279 } else {
280 break;
281 }
282 }
283 }
284
285
286 // ...error of vertex
287 if (m_FlagVertexError) {
289 }
290
291
292 // ...error matrix between vertex and tracks
294 int i = 0;
295 for (const auto& hm : m_TrackVertexError) {
296 for (int j = 0; j < 3; j++) for (int k = 0; k < KFitConst::kNumber7; k++) {
297 (*Ec)[j + m_TrackCount * KFitConst::kNumber7][k + i * KFitConst::kNumber7] = hm[j][k];
298 }
299 i++;
300 }
301 }
302}
std::vector< CLHEP::HepMatrix > m_TrackVertexError
Array of vertex error matrices of the child particles.
std::vector< CLHEP::HepMatrix > m_Correlation
Array of correlation matrices among the child particles.

◆ doMake()

enum KFitError::ECode doMake ( void  )

Perform a reconstruction of mother particle.

Returns
error code (zero if success)

Definition at line 192 of file MakeMotherKFit.cc.

192 {
193 // ...makes matrix.
194 HepMatrix dMdC(KFitConst::kNumber7, KFitConst::kNumber7 * m_TrackCount + 3, 0);
195 HepSymMatrix Ec(KFitConst::kNumber7 * m_TrackCount + 3, 0);
196
197
198 // ...sets error matrix
199 if (m_FlagCorrelation && m_Correlation.size() != static_cast<unsigned int>((m_TrackCount * m_TrackCount - m_TrackCount) / 2))
200 {
202 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
203 return m_ErrorCode;
204 }
205 if (m_FlagTrackVertexError && m_TrackVertexError.size() != (unsigned int)m_TrackCount)
206 {
208 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
209 return m_ErrorCode;
210 }
211 this->calculateError(&Ec);
212
213
214 // ...makes delMdelC to calculate error matrix of mother particle.
215 this->calculateDELMDELC(&dMdC);
216
217
218 // ...calculates error matrix of mother particle.
219 HepSymMatrix Em(Ec.similarity(dMdC));
220
221
222 // ...makes mother particle
223 double px = 0, py = 0, pz = 0, E = 0;
224 for (int i = 0; i < m_TrackCount; i++)
225 {
226 double a = 0, dx = 0, dy = 0;
227 if (m_FlagAtDecayPoint) {
228 const double c = Belle2::Const::speedOfLight * 1e-4;
229 a = -c * m_MagneticField * m_Tracks[i].getCharge();
230 dx = m_Vertex.x() - m_Tracks[i].getPosition(m_FlagBeforeAfter).x();
231 dy = m_Vertex.y() - m_Tracks[i].getPosition(m_FlagBeforeAfter).y();
232 }
233 px += m_Tracks[i].getMomentum(m_FlagBeforeAfter).x() - a * dy;
234 py += m_Tracks[i].getMomentum(m_FlagBeforeAfter).y() + a * dx;
235 pz += m_Tracks[i].getMomentum(m_FlagBeforeAfter).z();
236 E += m_Tracks[i].getMomentum(m_FlagBeforeAfter).t();
237 }
238
239
240 // ...momentum
241 m_Mother.setMomentum(HepLorentzVector(px, py, pz, E));
242 // ...position
244 // ...error
245 m_Mother.setError(Em);
247
248
250}
R E
internal precision of FFTW codelets
@ kBadTrackSize
Track count too small to perform fit.
Definition: KFitError.h:47
void setCharge(const double q)
Set a charge of the track.
Definition: KFitTrack.cc:134
void setPosition(const HepPoint3D &x, const int flag=KFitConst::kBeforeFit)
Set a position of the track.
Definition: KFitTrack.cc:109
void setMomentum(const CLHEP::HepLorentzVector &p, const int flag=KFitConst::kBeforeFit)
Set a Lorentz vector of the track.
Definition: KFitTrack.cc:95
void setError(const CLHEP::HepSymMatrix &e, const int flag=KFitConst::kBeforeFit)
Set an error matrix of the track.
Definition: KFitTrack.cc:121
KFitTrack m_Mother
Track object of the mother particle.
void calculateError(CLHEP::HepSymMatrix *Ec) const
Make a matrix to calculate error matrix of the mother particle.
void calculateDELMDELC(CLHEP::HepMatrix *e) const
Make delMdelC to calculate error matrix of the mother particle.

◆ getErrorCode()

enum KFitError::ECode getErrorCode ( void  ) const

Get a code of the last error.

Returns
error code

Definition at line 159 of file MakeMotherKFit.cc.

159 {
160 return m_ErrorCode;
161}

◆ getMother()

const KFitTrack getMother ( void  ) const

Get a track object of the mother particle.

Returns
track object of the mother particle

Definition at line 164 of file MakeMotherKFit.cc.

165{
166 return m_Mother;
167}

◆ getMotherError()

const HepSymMatrix getMotherError ( void  ) const

Get an error matrix of the mother particle.

Returns
error matrix of the mother particle

Definition at line 185 of file MakeMotherKFit.cc.

186{
188}
const CLHEP::HepSymMatrix getError(const int flag=KFitConst::kAfterFit) const
Get an error matrix of the track.
Definition: KFitTrack.cc:172
static const int kBeforeFit
Input parameter to specify before-fit when setting/getting a track attribute.
Definition: KFitConst.h:35

◆ getMotherMomentum()

const HepLorentzVector getMotherMomentum ( void  ) const

Get a Lorentz vector of the mother particle.

Returns
Lorentz vector of the mother particle

Definition at line 171 of file MakeMotherKFit.cc.

172{
174}
const CLHEP::HepLorentzVector getMomentum(const int flag=KFitConst::kAfterFit) const
Get a Lorentz vector of the track.
Definition: KFitTrack.cc:156

◆ getMotherPosition()

const HepPoint3D getMotherPosition ( void  ) const

Get a position of the mother particle.

Returns
position of the mother particle

Definition at line 178 of file MakeMotherKFit.cc.

179{
181}
const HepPoint3D getPosition(const int flag=KFitConst::kAfterFit) const
Get a position of the track.
Definition: KFitTrack.cc:164

◆ setCorrelation()

enum KFitError::ECode setCorrelation ( const CLHEP::HepMatrix &  e)

Set a correlation matrix.

Parameters
e(7x7) correlation matrix
Returns
error code (zero if success)

Definition at line 119 of file MakeMotherKFit.cc.

119 {
120 if (e.num_row() != (int)KFitConst::kNumber7 || e.num_col() != (int)KFitConst::kNumber7)
121 {
123 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
124 return m_ErrorCode;
125 }
126
127 m_Correlation.push_back(e);
128 m_FlagCorrelation = true;
129
131}

◆ setFlagAtDecayPoint()

enum KFitError::ECode setFlagAtDecayPoint ( const bool  flag)

Set a flag to control computational point for the mother particle property at the decay point or not.

Parameters
flagtrue for yes, false for no
Returns
error code (zero if success)

Definition at line 143 of file MakeMotherKFit.cc.

143 {
144 m_FlagAtDecayPoint = flag;
145
147}

◆ setFlagBeforeAfter()

enum KFitError::ECode setFlagBeforeAfter ( const int  flag)

Set a flag to control computational parameters for the mother particle property before or after the fit.

Parameters
flagKFitConst::kBeforeFit or KFitConst::kAfterFit
Returns
error code (zero if success)

Definition at line 151 of file MakeMotherKFit.cc.

151 {
152 m_FlagBeforeAfter = flag;
153
155}

◆ setMagneticField()

enum KFitError::ECode setMagneticField ( const double  mf)

Change a magnetic field from the default value KFitConst::kDefaultMagneticField.

Parameters
mfmagnetic field to set
Returns
error code (zero if success)

Definition at line 63 of file MakeMotherKFit.cc.

63 {
64 m_MagneticField = mf;
65
67}

◆ setTrackVertexError()

enum KFitError::ECode setTrackVertexError ( const CLHEP::HepMatrix &  e)

Set a vertex error matrix of the child particle in the addTrack'ed order.

Parameters
e(3x7) vertex error matrix
Returns
error code (zero if success)

Definition at line 95 of file MakeMotherKFit.cc.

95 {
96 if (e.num_row() != 3 || e.num_col() != (int)KFitConst::kNumber7)
97 {
99 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
100 return m_ErrorCode;
101 }
102
103 m_TrackVertexError.push_back(e);
105
107}

◆ setTrackZeroVertexError()

enum KFitError::ECode setTrackZeroVertexError ( void  )

Indicate no vertex uncertainty in the child particle in the addTrack'ed order.

Returns
error code (zero if success)

Definition at line 111 of file MakeMotherKFit.cc.

111 {
112 HepMatrix zero(3, KFitConst::kNumber7, 0);
113
114 return this->setTrackVertexError(zero);
115}
enum KFitError::ECode setTrackVertexError(const CLHEP::HepMatrix &e)
Set a vertex error matrix of the child particle in the addTrack'ed order.

◆ setVertex()

enum KFitError::ECode setVertex ( const HepPoint3D v)

Set a vertex position of the mother particle.

Parameters
vvertex position
Returns
error code (zero if success)

Definition at line 71 of file MakeMotherKFit.cc.

71 {
72 m_Vertex = v;
73
75}

◆ setVertexError()

enum KFitError::ECode setVertexError ( const CLHEP::HepSymMatrix &  e)

Set a vertex error matrix of the mother particle.

Parameters
e(3x3) vertex error matrix
Returns
error code (zero if success)

Definition at line 79 of file MakeMotherKFit.cc.

79 {
80 if (e.num_row() != 3)
81 {
83 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
84 return m_ErrorCode;
85 }
86
87 m_VertexError = e;
88 m_FlagVertexError = true;
89
91}

◆ setZeroCorrelation()

enum KFitError::ECode setZeroCorrelation ( void  )

Indicate no correlation between tracks.

Returns
error code (zero if success)

Definition at line 135 of file MakeMotherKFit.cc.

135 {
136 HepMatrix zero(KFitConst::kNumber7, KFitConst::kNumber7, 0);
137
138 return this->setCorrelation(zero);
139}
enum KFitError::ECode setCorrelation(const CLHEP::HepMatrix &e)
Set a correlation matrix.

Member Data Documentation

◆ m_Charge

double m_Charge
private

Charge of the mother particle.

Definition at line 180 of file MakeMotherKFit.h.

◆ m_Correlation

std::vector<CLHEP::HepMatrix> m_Correlation
private

Array of correlation matrices among the child particles.

Definition at line 170 of file MakeMotherKFit.h.

◆ m_ErrorCode

enum KFitError::ECode m_ErrorCode
private

Error code.

Definition at line 146 of file MakeMotherKFit.h.

◆ m_FlagAtDecayPoint

bool m_FlagAtDecayPoint
private

Flag controlled by setFlagAtDecayPoint().

Definition at line 149 of file MakeMotherKFit.h.

◆ m_FlagBeforeAfter

int m_FlagBeforeAfter
private

Flag controlled by setFlagBeforeAfter().

Definition at line 151 of file MakeMotherKFit.h.

◆ m_FlagCorrelation

bool m_FlagCorrelation
private

Flag to indicate if the correlation matrix among the child particles is preset.

Definition at line 155 of file MakeMotherKFit.h.

◆ m_FlagTrackVertexError

bool m_FlagTrackVertexError
private

Flag to indicate if the vertex error matrix of the child particle is preset.

Definition at line 157 of file MakeMotherKFit.h.

◆ m_FlagVertexError

bool m_FlagVertexError
private

Flag to indicate if the vertex error matrix of the mother particle is preset.

Definition at line 153 of file MakeMotherKFit.h.

◆ m_MagneticField

double m_MagneticField
private

Magnetic field.

Definition at line 160 of file MakeMotherKFit.h.

◆ m_Mother

KFitTrack m_Mother
private

Track object of the mother particle.

Definition at line 182 of file MakeMotherKFit.h.

◆ m_TrackCount

int m_TrackCount
private

Number of tracks.

Definition at line 162 of file MakeMotherKFit.h.

◆ m_Tracks

std::vector<KFitTrack> m_Tracks
private

Array of track objects of the child particles.

Definition at line 166 of file MakeMotherKFit.h.

◆ m_TrackVertexError

std::vector<CLHEP::HepMatrix> m_TrackVertexError
private

Array of vertex error matrices of the child particles.

Definition at line 168 of file MakeMotherKFit.h.

◆ m_Vertex

CLHEP::Hep3Vector m_Vertex
private

Vertex position of the mother particle.

Definition at line 174 of file MakeMotherKFit.h.

◆ m_VertexError

CLHEP::HepSymMatrix m_VertexError
private

Vertex error matrix of the mother particle.

Definition at line 176 of file MakeMotherKFit.h.


The documentation for this class was generated from the following files: