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