PandaRoot
KFParticleBaseSIMD.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 //---------------------------------------------------------------------------------
14 // The KFParticleBaseSIMD class
15 // .
16 // @author S.Gorbunov, I.Kisel, I.Kulakov, M.Zyzak
17 // @version 1.0
18 // @since 13.05.07
19 //
20 // Class to reconstruct and store the decayed particle parameters.
21 // The method is described in CBM-SOFT note 2007-003,
22 // ``Reconstruction of decayed particles based on the Kalman filter'',
23 // http://www.gsi.de/documents/DOC-2007-May-14-1.pdf
24 //
25 // This class describes general mathematics which is used by KFParticle class
26 //
27 // -= Copyright &copy ALICE HLT and CBM L1 Groups =-
28 //_________________________________________________________________________________
29 
30 #ifndef KFParticleBaseSIMD_H
31 #define KFParticleBaseSIMD_H
32 
33 #include "RootTypesDef.h"
34 
35 #include <vector>
36 #include "CbmL1Def.h"
37 
39 
40  public:
41  //*
42  //* ABSTRACT METHODS HAVE TO BE DEFINED IN USER CLASS
43  //*
44 
45  //* Virtual method to access the magnetic field
46 
47  virtual void GetFieldValue(const fvec xyz[], fvec B[]) const = 0;
48 
49  //* Virtual methods needed for particle transportation
50  //* One can use particular implementations for collider (only Bz component)
51  //* geometry and for fixed-target (CBM-like) geometry which are provided below
52  //* in TRANSPORT section
53 
54  //* Get dS to xyz[] space point
55 
56  virtual fvec GetDStoPoint(const fvec xyz[]) const = 0;
57 
58  //* Get dS to other particle p (dSp for particle p also returned)
59 
60  virtual void GetDStoParticle(const KFParticleBaseSIMD &p, fvec &DS, fvec &DSp) const = 0;
61 
62  //* Transport on dS value along trajectory, output to P,C
63 
64  virtual void Transport(fvec dS, fvec P[], fvec C[]) const = 0;
65 
66  //*
67  //* INITIALIZATION
68  //*
69 
70  //* Constructor
71 
73 
74  //* Destructor
75 
76  virtual ~KFParticleBaseSIMD() { ; }
77 
78  //* Initialisation from "cartesian" coordinates ( X Y Z Px Py Pz )
79  //* Parameters, covariance matrix, charge, and mass hypothesis should be provided
80 
81  void Initialize(const fvec Param[], const fvec Cov[], fvec Charge, fvec Mass);
82 
83  //* Initialise covariance matrix and set current parameters to 0.0
84 
85  void Initialize();
86 
87  //* Set decay vertex parameters for linearisation
88 
89  void SetVtxGuess(fvec x, fvec y, fvec z);
90  void SetVtxErrGuess(fvec &x, fvec &y, fvec &z);
91 
92  //* Set consruction method
93 
95 
96  //* Set and get mass hypothesis of the particle
97  void SetMassHypo(fvec m) { fMassHypo = m; }
98  const fvec &GetMassHypo() const { return fMassHypo; }
99 
100  //* Returns the sum of masses of the daughters
101  const fvec &GetSumDaughterMass() const { return SumDaughterMass; }
102 
103  //*
104  //* ACCESSORS
105  //*
106 
107  //* Simple accessors
108 
109  fvec GetX() const { return fP[0]; }
110  fvec GetY() const { return fP[1]; }
111  fvec GetZ() const { return fP[2]; }
112  fvec GetPx() const { return fP[3]; }
113  fvec GetPy() const { return fP[4]; }
114  fvec GetPz() const { return fP[5]; }
115  fvec GetE() const { return fP[6]; }
116  fvec GetS() const { return fP[7]; }
117  fvec GetQ() const { return fQ; }
118  fvec GetChi2() const { return fChi2; }
119  fvec GetNDF() const { return fNDF; }
120 
121  const fvec &X() const { return fP[0]; }
122  const fvec &Y() const { return fP[1]; }
123  const fvec &Z() const { return fP[2]; }
124  const fvec &Px() const { return fP[3]; }
125  const fvec &Py() const { return fP[4]; }
126  const fvec &Pz() const { return fP[5]; }
127  const fvec &E() const { return fP[6]; }
128  const fvec &S() const { return fP[7]; }
129  const fvec &Q() const { return fQ; }
130  const fvec &Chi2() const { return fChi2; }
131  const fvec &NDF() const { return fNDF; }
132 
133  fvec GetParameter(Int_t i) const { return fP[i]; }
134  fvec GetCovariance(Int_t i) const { return fC[i]; }
135  fvec GetCovariance(Int_t i, Int_t j) const { return fC[IJ(i, j)]; }
136 
137  //* Accessors with calculations( &value, &estimated sigma )
138  //* error flag returned (0 means no error during calculations)
139 
140  fvec GetMomentum(fvec &P, fvec &SigmaP) const;
141  fvec GetPt(fvec &Pt, fvec &SigmaPt) const;
142  fvec GetEta(fvec &Eta, fvec &SigmaEta) const;
143  fvec GetPhi(fvec &Phi, fvec &SigmaPhi) const;
144  fvec GetMass(fvec &M, fvec &SigmaM) const;
145  fvec GetDecayLength(fvec &L, fvec &SigmaL) const;
146  fvec GetDecayLengthXY(fvec &L, fvec &SigmaL) const;
147  fvec GetLifeTime(fvec &T, fvec &SigmaT) const;
148  fvec GetR(fvec &R, fvec &SigmaR) const;
149 
150  //*
151  //* MODIFIERS
152  //*
153 
154  fvec &X() { return fP[0]; }
155  fvec &Y() { return fP[1]; }
156  fvec &Z() { return fP[2]; }
157  fvec &Px() { return fP[3]; }
158  fvec &Py() { return fP[4]; }
159  fvec &Pz() { return fP[5]; }
160  fvec &E() { return fP[6]; }
161  fvec &S() { return fP[7]; }
162  fvec &Q() { return fQ; }
163  fvec &Chi2() { return fChi2; }
164  fvec &NDF() { return fNDF; }
165 
166  fvec &Parameter(Int_t i) { return fP[i]; }
167  fvec &Covariance(Int_t i) { return fC[i]; }
168  fvec &Covariance(Int_t i, Int_t j) { return fC[IJ(i, j)]; }
169 
170  //*
171  //* CONSTRUCTION OF THE PARTICLE BY ITS DAUGHTERS AND MOTHER
172  //* USING THE KALMAN FILTER METHOD
173  //*
174 
175  //* Simple way to add daughter ex. D0+= Pion;
176 
177  void operator+=(const KFParticleBaseSIMD &Daughter);
178 
179  //* Add daughter track to the particle
180 
181  void AddDaughter(const KFParticleBaseSIMD &Daughter, Bool_t isAtVtxGuess = 0);
182 
183  void AddDaughterWithEnergyFit(const KFParticleBaseSIMD &Daughter, Bool_t isAtVtxGuess);
184  void AddDaughterWithEnergyCalc(const KFParticleBaseSIMD &Daughter, Bool_t isAtVtxGuess);
185  void AddDaughterWithEnergyFitMC(const KFParticleBaseSIMD &Daughter, Bool_t isAtVtxGuess);
186  // with mass constrained
187 
188  //* Set production vertex
189 
190  void SetProductionVertex(const KFParticleBaseSIMD &Vtx);
191 
192  //* Set mass constraint
193 
194  void SetNonlinearMassConstraint(fvec Mass);
195  void SetMassConstraint(fvec Mass, fvec SigmaMass = 0);
196 
197  //* Set no decay length for resonances
198 
199  void SetNoDecayLength();
200 
201  //* Everything in one go
202 
203  void Construct(const KFParticleBaseSIMD *vDaughters[], Int_t nDaughters, const KFParticleBaseSIMD *ProdVtx = nullptr, Float_t Mass = -1, Bool_t IsConstrained = 0,
204  Bool_t isAtVtxGuess = 0);
205 
206  //*
207  //* TRANSPORT
208  //*
209  //* ( main transportation parameter is S = SignedPath/Momentum )
210  //* ( parameters of decay & production vertices are stored locally )
211  //*
212 
213  //* Transport the particle to its decay vertex
214 
215  void TransportToDecayVertex();
216 
217  //* Transport the particle to its production vertex
218 
220 
221  //* Transport the particle on dS parameter (SignedPath/Momentum)
222 
223  void TransportToDS(fvec dS);
224 
225  //* Particular extrapolators one can use
226 
227  fvec GetDStoPointBz(fvec Bz, const fvec xyz[]) const;
228  fvec GetDStoPointBy(fvec By, const fvec xyz[]) const;
229 
230  void GetDStoParticleBz(fvec Bz, const KFParticleBaseSIMD &p, fvec &dS, fvec &dS1) const;
231  void GetDStoParticleBy(fvec B, const KFParticleBaseSIMD &p, fvec &dS, fvec &dS1) const;
232 
233  fvec GetDStoPointCBM(const fvec xyz[]) const;
234  void GetDStoParticleCBM(const KFParticleBaseSIMD &p, fvec &dS, fvec &dS1) const;
235 
236  void TransportBz(fvec Bz, fvec dS, fvec P[], fvec C[]) const;
237  void TransportCBM(fvec dS, fvec P[], fvec C[]) const;
238 
239  //*
240  //* OTHER UTILITIES
241  //*
242 
243  //* Calculate distance from another object [cm]
244 
245  fvec GetDistanceFromVertex(const fvec vtx[]) const;
248 
249  //* Calculate sqrt(Chi2/ndf) deviation from vertex
250  //* v = [xyz], Cv=[Cxx,Cxy,Cyy,Cxz,Cyz,Czz]-covariance matrix
251 
252  fvec GetDeviationFromVertex(const fvec v[], const fvec Cv[] = 0) const;
255 
256  //* Subtract the particle from the vertex
257 
258  void SubtractFromVertex(KFParticleBaseSIMD &Vtx) const;
259  void SubtractFromParticle(KFParticleBaseSIMD &Vtx) const;
260 
261  //* Special method for creating gammas
262 
263  void ConstructGammaBz(const KFParticleBaseSIMD &daughter1, const KFParticleBaseSIMD &daughter2, fvec Bz);
264 
265  //* return parameters for the Armenteros-Podolanski plot
266  static void GetArmenterosPodolanski(KFParticleBaseSIMD &positive, KFParticleBaseSIMD &negative, fvec QtAlfa[2]);
267 
268  //* Rotates the KFParticle object around OZ axis, OZ axis is set by the vertex position
269  void RotateXY(fvec angle, fvec Vtx[3]);
270 
271  fvec Id() const { return fId; };
272  int NDaughters() const { return fDaughterIds.size(); };
273  std::vector<fvec> &DaughterIds() { return fDaughterIds; };
274  fvec GetDaughterId(int iD) const { return fDaughterIds[iD]; }
275 
276  void SetId(fvec id) { fId = id; }; // should be always used (manualy)
277  void SetNDaughters(int n) { fDaughterIds.reserve(n); }
278  void AddDaughterId(fvec id) { fDaughterIds.push_back(id); };
279  void CleanDaughtersId() { fDaughterIds.clear(); }
280 
281  void SetPDG(int pdg) { fPDG = pdg; }
282  const int &GetPDG() const { return fPDG; }
283 
284  void GetDistanceToVertexLine(const KFParticleBaseSIMD &Vertex, fvec &l, fvec &dl, fvec *isParticleFromVertex = nullptr) const;
285 
286  protected:
287  static Int_t IJ(Int_t i, Int_t j) { return (j <= i) ? i * (i + 1) / 2 + j : j * (j + 1) / 2 + i; }
288 
289  fvec &Cij(Int_t i, Int_t j) { return fC[IJ(i, j)]; }
290 
291  void Convert(bool ToProduction);
292  void TransportLine(fvec S, fvec P[], fvec C[]) const;
293  fvec GetDStoPointLine(const fvec xyz[]) const;
294  void GetDStoParticleLine(const KFParticleBaseSIMD &p, fvec &dS, fvec &dS1) const;
295 
296  void GetDSIter(const KFParticleBaseSIMD &p, fvec const &dS, fvec x[3], fvec dx[3], fvec ddx[3]) const;
297 
298  static fvec InvertSym3(const fvec A[], fvec Ainv[]);
299  static void InvertCholetsky3(fvec a[6]);
300 
301  static void MultQSQt(const fvec Q[], const fvec S[], fvec SOut[]);
302 
303  static void multQSQt1(const fvec J[11], fvec S[]);
304 
305  fvec GetSCorrection(const fvec Part[], const fvec XYZ[]) const;
306 
307  void GetMeasurement(const fvec XYZ[], fvec m[], fvec V[], Bool_t isAtVtxGuess = 0) const;
308 
309  //* Mass constraint function. is needed for the nonlinear mass constraint and a fit with mass constraint
310  void SetMassConstraint(fvec *mP, fvec *mC, fvec mJ[7][7], fvec mass, fvec mask);
311 
312  fvec fP[8]; //* Main particle parameters {X,Y,Z,Px,Py,Pz,E,S[=DecayLength/P]}
313  fvec fC[36]; //* Low-triangle covariance matrix of fP
314  fvec fQ; //* Particle charge
315  fvec fNDF; //* Number of degrees of freedom
316  fvec fChi2; //* Chi^2
317 
318  fvec fSFromDecay; //* Distance from decay vertex to current position
319 
320  Bool_t fAtProductionVertex; //* Flag shows that the particle error along
321  //* its trajectory is taken from production vertex
322  Bool_t fIsVtxGuess;
324 
325  fvec fVtxGuess[3]; //* Guess for the position of the decay vertex
326  //* ( used for linearisation of equations )
327  fvec fVtxErrGuess[3]; //* Guess for the initial error of the decay vertex
328 
329  Bool_t fIsLinearized; //* Flag shows that the guess is present
330 
331  Int_t fConstructMethod; //* Determines the method for the particle construction.
332  //* 0 - Energy considered as an independent veriable, fitted independently from momentum, without any constraints on mass
333  //* 1 - Energy considered as a dependent variable, calculated from the momentum and mass hypothesis
334  //* 2 - Energy considered as an independent variable, fitted independently from momentum, with constraints on mass of daughter particle
335 
336  fvec SumDaughterMass; //* sum of the daughter particles masses
337  fvec fMassHypo; //* sum of the daughter particles masses
338 
339  fvec fId; // id of particle
340  std::vector<fvec> fDaughterIds; // id of particles it created from. if size == 1 then this is id of track.
341 
342  int fPDG; // pdg hypothesis
343 };
344 
345 #endif
const fvec & Y() const
void AddDaughterWithEnergyFit(const KFParticleBaseSIMD &Daughter, Bool_t isAtVtxGuess)
std::vector< fvec > fDaughterIds
fvec GetEta(fvec &Eta, fvec &SigmaEta) const
void GetDStoParticleBy(fvec B, const KFParticleBaseSIMD &p, fvec &dS, fvec &dS1) const
void TransportToDecayVertex()
const fvec & Px() const
const fvec & S() const
fvec GetMass(fvec &M, fvec &SigmaM) const
fvec & Covariance(Int_t i, Int_t j)
const fvec & Z() const
static void MultQSQt(const fvec Q[], const fvec S[], fvec SOut[])
__m128 m
Definition: P4_F32vec4.h:38
fvec GetDistanceFromParticle(const KFParticleBaseSIMD &p) const
virtual void GetDStoParticle(const KFParticleBaseSIMD &p, fvec &DS, fvec &DSp) const =0
const fvec & Py() const
fvec GetPhi(fvec &Phi, fvec &SigmaPhi) const
void TransportCBM(fvec dS, fvec P[], fvec C[]) const
virtual void Transport(fvec dS, fvec P[], fvec C[]) const =0
void SetVtxErrGuess(fvec &x, fvec &y, fvec &z)
fvec GetDStoPointLine(const fvec xyz[]) const
void TransportToProductionVertex()
void GetDStoParticleBz(fvec Bz, const KFParticleBaseSIMD &p, fvec &dS, fvec &dS1) const
void ConstructGammaBz(const KFParticleBaseSIMD &daughter1, const KFParticleBaseSIMD &daughter2, fvec Bz)
static void GetArmenterosPodolanski(KFParticleBaseSIMD &positive, KFParticleBaseSIMD &negative, fvec QtAlfa[2])
void AddDaughterId(fvec id)
void GetMeasurement(const fvec XYZ[], fvec m[], fvec V[], Bool_t isAtVtxGuess=0) const
void operator+=(const KFParticleBaseSIMD &Daughter)
void TransportBz(fvec Bz, fvec dS, fvec P[], fvec C[]) const
fvec GetMomentum(fvec &P, fvec &SigmaP) const
fvec & Cij(Int_t i, Int_t j)
virtual void GetFieldValue(const fvec xyz[], fvec B[]) const =0
void SubtractFromVertex(KFParticleBaseSIMD &Vtx) const
void RotateXY(fvec angle, fvec Vtx[3])
__m128 v
Definition: P4_F32vec4.h:15
unsigned int i
Definition: P4_F32vec4.h:33
void Construct(const KFParticleBaseSIMD *vDaughters[], Int_t nDaughters, const KFParticleBaseSIMD *ProdVtx=nullptr, Float_t Mass=-1, Bool_t IsConstrained=0, Bool_t isAtVtxGuess=0)
const int & GetPDG() const
void SetMassHypo(fvec m)
const fvec & Q() const
void AddDaughterWithEnergyCalc(const KFParticleBaseSIMD &Daughter, Bool_t isAtVtxGuess)
fvec GetCovariance(Int_t i) const
const fvec & Chi2() const
void Convert(bool ToProduction)
fvec & Covariance(Int_t i)
const fvec & Pz() const
void TransportLine(fvec S, fvec P[], fvec C[]) const
fvec GetDStoPointBy(fvec By, const fvec xyz[]) const
static fvec InvertSym3(const fvec A[], fvec Ainv[])
void GetDistanceToVertexLine(const KFParticleBaseSIMD &Vertex, fvec &l, fvec &dl, fvec *isParticleFromVertex=nullptr) const
fvec GetDeviationFromParticle(const KFParticleBaseSIMD &p) const
const fvec & GetSumDaughterMass() const
fvec GetSCorrection(const fvec Part[], const fvec XYZ[]) const
std::vector< fvec > & DaughterIds()
void AddDaughterWithEnergyFitMC(const KFParticleBaseSIMD &Daughter, Bool_t isAtVtxGuess)
void TransportToDS(fvec dS)
static void InvertCholetsky3(fvec a[6])
const fvec & E() const
void SetConstructMethod(Int_t m)
void SubtractFromParticle(KFParticleBaseSIMD &Vtx) const
void AddDaughter(const KFParticleBaseSIMD &Daughter, Bool_t isAtVtxGuess=0)
fvec GetDStoPointCBM(const fvec xyz[]) const
fvec GetDistanceFromVertex(const fvec vtx[]) const
virtual fvec GetDStoPoint(const fvec xyz[]) const =0
fvec GetLifeTime(fvec &T, fvec &SigmaT) const
fvec GetDaughterId(int iD) const
const fvec & X() const
static Int_t IJ(Int_t i, Int_t j)
const fvec & NDF() const
fvec GetPt(fvec &Pt, fvec &SigmaPt) const
void GetDStoParticleLine(const KFParticleBaseSIMD &p, fvec &dS, fvec &dS1) const
const fvec & GetMassHypo() const
fvec GetR(fvec &R, fvec &SigmaR) const
void SetProductionVertex(const KFParticleBaseSIMD &Vtx)
fvec GetDStoPointBz(fvec Bz, const fvec xyz[]) const
void SetNonlinearMassConstraint(fvec Mass)
void SetVtxGuess(fvec x, fvec y, fvec z)
void GetDSIter(const KFParticleBaseSIMD &p, fvec const &dS, fvec x[3], fvec dx[3], fvec ddx[3]) const
void GetDStoParticleCBM(const KFParticleBaseSIMD &p, fvec &dS, fvec &dS1) const
static void multQSQt1(const fvec J[11], fvec S[])
fvec & Parameter(Int_t i)
fvec GetParameter(Int_t i) const
fvec GetDecayLengthXY(fvec &L, fvec &SigmaL) const
void SetMassConstraint(fvec Mass, fvec SigmaMass=0)
fvec GetDeviationFromVertex(const fvec v[], const fvec Cv[]=0) const
fvec GetDecayLength(fvec &L, fvec &SigmaL) const
fvec GetCovariance(Int_t i, Int_t j) const