PandaRoot
KFParticleBase.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 KFParticleBase 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 ALIKFPARTICLEBASE_H
31 #define ALIKFPARTICLEBASE_H
32 
33 //#include "TObject.h"
34 #include "RootTypesDef.h"
35 
36 #include <vector>
37 
38 class KFParticleBase : public TObject {
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 Double_t xyz[], Double_t 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 Double_t GetDStoPoint(const Double_t xyz[]) const = 0;
57 
58  //* Get dS to other particle p (dSp for particle p also returned)
59 
60  virtual void GetDStoParticle(const KFParticleBase &p, Double_t &DS, Double_t &DSp) const = 0;
61 
62  //* Transport on dS value along trajectory, output to P,C
63 
64  virtual void Transport(Double_t dS, Double_t P[], Double_t C[]) const = 0;
65 
66  //*
67  //* INITIALIZATION
68  //*
69 
70  //* Constructor
71 
73 
74  //* Destructor
75 
76  virtual ~KFParticleBase() { ; }
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 Double_t Param[], const Double_t Cov[], Int_t Charge, Double_t 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(Double_t x, Double_t y, Double_t z);
90 
91  //* Set consruction method
92 
94 
95  //* Set and get mass hypothesis of the particle
96  void SetMassHypo(Double_t m) { fMassHypo = m; }
97  const Double_t &GetMassHypo() const { return fMassHypo; }
98 
99  //* Returns the sum of masses of the daughters
100  const Double_t &GetSumDaughterMass() const { return SumDaughterMass; }
101 
102  //*
103  //* ACCESSORS
104  //*
105 
106  //* Simple accessors
107 
108  Double_t GetX() const { return fP[0]; }
109  Double_t GetY() const { return fP[1]; }
110  Double_t GetZ() const { return fP[2]; }
111  Double_t GetPx() const { return fP[3]; }
112  Double_t GetPy() const { return fP[4]; }
113  Double_t GetPz() const { return fP[5]; }
114  Double_t GetE() const { return fP[6]; }
115  Double_t GetS() const { return fP[7]; }
116  Int_t GetQ() const { return fQ; }
117  Double_t GetChi2() const { return fChi2; }
118  Int_t GetNDF() const { return fNDF; }
119 
120  const Double_t &X() const { return fP[0]; }
121  const Double_t &Y() const { return fP[1]; }
122  const Double_t &Z() const { return fP[2]; }
123  const Double_t &Px() const { return fP[3]; }
124  const Double_t &Py() const { return fP[4]; }
125  const Double_t &Pz() const { return fP[5]; }
126  const Double_t &E() const { return fP[6]; }
127  const Double_t &S() const { return fP[7]; }
128  const Int_t &Q() const { return fQ; }
129  const Double_t &Chi2() const { return fChi2; }
130  const Int_t &NDF() const { return fNDF; }
131 
132  Double_t GetParameter(Int_t i) const { return fP[i]; }
133  Double_t GetCovariance(Int_t i) const { return fC[i]; }
134  Double_t GetCovariance(Int_t i, Int_t j) const { return fC[IJ(i, j)]; }
135 
136  //* Accessors with calculations( &value, &estimated sigma )
137  //* error flag returned (0 means no error during calculations)
138 
139  Int_t GetMomentum(Double_t &P, Double_t &SigmaP) const;
140  Int_t GetPt(Double_t &Pt, Double_t &SigmaPt) const;
141  Int_t GetEta(Double_t &Eta, Double_t &SigmaEta) const;
142  Int_t GetPhi(Double_t &Phi, Double_t &SigmaPhi) const;
143  Int_t GetMass(Double_t &M, Double_t &SigmaM) const;
144  Int_t GetDecayLength(Double_t &L, Double_t &SigmaL) const;
145  Int_t GetDecayLengthXY(Double_t &L, Double_t &SigmaL) const;
146  Int_t GetLifeTime(Double_t &T, Double_t &SigmaT) const;
147  Int_t GetR(Double_t &R, Double_t &SigmaR) const;
148 
149  //*
150  //* MODIFIERS
151  //*
152 
153  Double_t &X() { return fP[0]; }
154  Double_t &Y() { return fP[1]; }
155  Double_t &Z() { return fP[2]; }
156  Double_t &Px() { return fP[3]; }
157  Double_t &Py() { return fP[4]; }
158  Double_t &Pz() { return fP[5]; }
159  Double_t &E() { return fP[6]; }
160  Double_t &S() { return fP[7]; }
161  Int_t &Q() { return fQ; }
162  Double_t &Chi2() { return fChi2; }
163  Int_t &NDF() { return fNDF; }
164 
165  Double_t &Parameter(Int_t i) { return fP[i]; }
166  Double_t &Covariance(Int_t i) { return fC[i]; }
167  Double_t &Covariance(Int_t i, Int_t j) { return fC[IJ(i, j)]; }
168 
169  //*
170  //* CONSTRUCTION OF THE PARTICLE BY ITS DAUGHTERS AND MOTHER
171  //* USING THE KALMAN FILTER METHOD
172  //*
173 
174  //* Simple way to add daughter ex. D0+= Pion;
175 
176  void operator+=(const KFParticleBase &Daughter);
177 
178  //* Add daughter track to the particle
179 
180  void AddDaughter(const KFParticleBase &Daughter);
181 
182  void AddDaughterWithEnergyFit(const KFParticleBase &Daughter);
183  void AddDaughterWithEnergyCalc(const KFParticleBase &Daughter);
184  void AddDaughterWithEnergyFitMC(const KFParticleBase &Daughter); // with mass constrained
185 
186  //* Set production vertex
187 
188  void SetProductionVertex(const KFParticleBase &Vtx);
189 
190  //* Set mass constraint
191 
192  void SetNonlinearMassConstraint(Double_t Mass);
193  void SetMassConstraint(Double_t Mass, Double_t SigmaMass = 0);
194 
195  //* Set no decay length for resonances
196 
197  void SetNoDecayLength();
198 
199  //* Everything in one go
200 
201  void Construct(const KFParticleBase *vDaughters[], Int_t nDaughters, const KFParticleBase *ProdVtx = nullptr, Double_t Mass = -1, Bool_t IsConstrained = 0);
202 
203  //*
204  //* TRANSPORT
205  //*
206  //* ( main transportation parameter is S = SignedPath/Momentum )
207  //* ( parameters of decay & production vertices are stored locally )
208  //*
209 
210  //* Transport the particle to its decay vertex
211 
212  void TransportToDecayVertex();
213 
214  //* Transport the particle to its production vertex
215 
217 
218  //* Transport the particle on dS parameter (SignedPath/Momentum)
219 
220  void TransportToDS(Double_t dS);
221 
222  //* Particular extrapolators one can use
223 
224  Double_t GetDStoPointBz(Double_t Bz, const Double_t xyz[]) const;
225  Double_t GetDStoPointBy(Double_t By, const Double_t xyz[]) const;
226 
227  void GetDStoParticleBz(Double_t Bz, const KFParticleBase &p, Double_t &dS, Double_t &dS1) const;
228  void GetDStoParticleBy(Double_t B, const KFParticleBase &p, Double_t &dS, Double_t &dS1) const;
229 
230  Double_t GetDStoPointCBM(const Double_t xyz[]) const;
231  void GetDStoParticleCBM(const KFParticleBase &p, Double_t &dS, Double_t &dS1) const;
232 
233  void TransportBz(Double_t Bz, Double_t dS, Double_t P[], Double_t C[]) const;
234  void TransportCBM(Double_t dS, Double_t P[], Double_t C[]) const;
235 
236  //*
237  //* OTHER UTILITIES
238  //*
239 
240  //* Calculate distance from another object [cm]
241 
242  Double_t GetDistanceFromVertex(const Double_t vtx[]) const;
243  Double_t GetDistanceFromVertex(const KFParticleBase &Vtx) const;
244  Double_t GetDistanceFromParticle(const KFParticleBase &p) const;
245 
246  //* Calculate sqrt(Chi2/ndf) deviation from vertex
247  //* v = [xyz], Cv=[Cxx,Cxy,Cyy,Cxz,Cyz,Czz]-covariance matrix
248 
249  Double_t GetDeviationFromVertex(const Double_t v[], const Double_t Cv[] = 0) const;
250  Double_t GetDeviationFromVertex(const KFParticleBase &Vtx) const;
251  Double_t GetDeviationFromParticle(const KFParticleBase &p) const;
252 
253  //* Subtract the particle from the vertex
254 
255  void SubtractFromVertex(KFParticleBase &Vtx) const;
256 
257  //* Special method for creating gammas
258 
259  void ConstructGammaBz(const KFParticleBase &daughter1, const KFParticleBase &daughter2, double Bz);
260 
261  //* return parameters for the Armenteros-Podolanski plot
262  static void GetArmenterosPodolanski(KFParticleBase &positive, KFParticleBase &negative, Double_t QtAlfa[2]);
263 
264  //* Rotates the KFParticle object around OZ axis, OZ axis is set by the vertex position
265  void RotateXY(Double_t angle, Double_t Vtx[3]);
266 
267  int Id() const { return fId; };
268  int NDaughters() const { return fDaughtersIds.size(); };
269  const std::vector<int> &DaughterIds() const { return fDaughtersIds; };
270 
271  void SetId(int id) { fId = id; }; // should be always used (manualy)
272  void AddDaughterId(int id) { fDaughtersIds.push_back(id); };
273 
274  void SetPDG(int pdg) { fPDG = pdg; }
275  int GetPDG() const { return fPDG; }
276 
277  protected:
278  static Int_t IJ(Int_t i, Int_t j) { return (j <= i) ? i * (i + 1) / 2 + j : j * (j + 1) / 2 + i; }
279 
280  Double_t &Cij(Int_t i, Int_t j) { return fC[IJ(i, j)]; }
281 
282  void Convert(bool ToProduction);
283  void TransportLine(Double_t S, Double_t P[], Double_t C[]) const;
284  Double_t GetDStoPointLine(const Double_t xyz[]) const;
285  void GetDStoParticleLine(const KFParticleBase &p, Double_t &dS, Double_t &dS1) const;
286 
287  void GetDSIter(const KFParticleBase &p, Double_t const &dS, Double_t x[3], Double_t dx[3], Double_t ddx[3]) const;
288 
289  static Bool_t InvertSym3(const Double_t A[], Double_t Ainv[]);
290 
291  static void MultQSQt(const Double_t Q[], const Double_t S[], Double_t SOut[]);
292 
293  static Double_t GetSCorrection(const Double_t Part[], const Double_t XYZ[]);
294 
295  void GetMeasurement(const Double_t XYZ[], Double_t m[], Double_t V[]) const;
296 
297  //* Mass constraint function. is needed for the nonlinear mass constraint and a fit with mass constraint
298  void SetMassConstraint(Double_t *mP, Double_t *mC, Double_t mJ[7][7], Double_t mass);
299 
300  Double_t fP[8]; //* Main particle parameters {X,Y,Z,Px,Py,Pz,E,S[=DecayLength/P]}
301  Double_t fC[36]; //* Low-triangle covariance matrix of fP
302  Int_t fQ; //* Particle charge
303  Int_t fNDF; //* Number of degrees of freedom
304  Double_t fChi2; //* Chi^2
305 
306  Double_t 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 
311  Double_t fVtxGuess[3]; //* Guess for the position of the decay vertex
312  //* ( used for linearisation of equations )
313 
314  Bool_t fIsLinearized; //* Flag shows that the guess is present
315 
316  Int_t fConstructMethod; //* Determines the method for the particle construction.
317  //* 0 - Energy considered as an independent veriable, fitted independently from momentum, without any constraints on mass
318  //* 1 - Energy considered as a dependent variable, calculated from the momentum and mass hypothesis
319  //* 2 - Energy considered as an independent variable, fitted independently from momentum, with constraints on mass of daughter particle
320 
321  Double_t SumDaughterMass; //* sum of the daughter particles masses
322  Double_t fMassHypo; //* sum of the daughter particles masse
323 
324  int fId; // id of particle
325  std::vector<int> fDaughtersIds; // id of particles it created from. if size == 1 then this is id of track. TODO use in functions. why unsigned short int doesn't work???
326 
327  int fPDG; // pdg hypothesis
328 
329  // ClassDef( KFParticleBase, 1 );
330 };
331 
332 #endif
Double_t GetPy() const
Double_t GetDistanceFromVertex(const Double_t vtx[]) const
Double_t GetZ() const
Double_t & Y()
void SetConstructMethod(Int_t m)
void TransportToProductionVertex()
void TransportToDecayVertex()
static void GetArmenterosPodolanski(KFParticleBase &positive, KFParticleBase &negative, Double_t QtAlfa[2])
void GetDStoParticleLine(const KFParticleBase &p, Double_t &dS, Double_t &dS1) const
void SetNonlinearMassConstraint(Double_t Mass)
__m128 m
Definition: P4_F32vec4.h:38
Int_t GetQ() const
Double_t GetPx() const
Double_t fVtxGuess[3]
Int_t GetMomentum(Double_t &P, Double_t &SigmaP) const
Double_t GetPz() const
Double_t fP[8]
void TransportCBM(Double_t dS, Double_t P[], Double_t C[]) const
Int_t GetPhi(Double_t &Phi, Double_t &SigmaPhi) const
Double_t & S()
Double_t & Chi2()
const Int_t & Q() const
Double_t GetDStoPointBz(Double_t Bz, const Double_t xyz[]) const
const Double_t & Pz() const
void GetDStoParticleCBM(const KFParticleBase &p, Double_t &dS, Double_t &dS1) const
Double_t GetDStoPointBy(Double_t By, const Double_t xyz[]) const
Int_t GetMass(Double_t &M, Double_t &SigmaM) const
Double_t GetY() const
const Double_t & Py() const
void SubtractFromVertex(KFParticleBase &Vtx) const
void SetVtxGuess(Double_t x, Double_t y, Double_t z)
Double_t GetParameter(Int_t i) const
void operator+=(const KFParticleBase &Daughter)
const Double_t & Chi2() const
void AddDaughterWithEnergyCalc(const KFParticleBase &Daughter)
static Int_t IJ(Int_t i, Int_t j)
const Double_t & Y() const
__m128 v
Definition: P4_F32vec4.h:15
static Double_t GetSCorrection(const Double_t Part[], const Double_t XYZ[])
unsigned int i
Definition: P4_F32vec4.h:33
Double_t & X()
Int_t GetNDF() const
int Id() const
void SetNoDecayLength()
virtual void GetDStoParticle(const KFParticleBase &p, Double_t &DS, Double_t &DSp) const =0
Double_t & Cij(Int_t i, Int_t j)
int GetPDG() const
Int_t GetEta(Double_t &Eta, Double_t &SigmaEta) const
Int_t GetPt(Double_t &Pt, Double_t &SigmaPt) const
void GetDStoParticleBy(Double_t B, const KFParticleBase &p, Double_t &dS, Double_t &dS1) const
void SetMassHypo(Double_t m)
void TransportLine(Double_t S, Double_t P[], Double_t C[]) const
void SetProductionVertex(const KFParticleBase &Vtx)
virtual void Transport(Double_t dS, Double_t P[], Double_t C[]) const =0
Double_t & E()
Double_t SumDaughterMass
virtual void GetFieldValue(const Double_t xyz[], Double_t B[]) const =0
const Double_t & GetMassHypo() const
void GetDStoParticleBz(Double_t Bz, const KFParticleBase &p, Double_t &dS, Double_t &dS1) const
Double_t GetCovariance(Int_t i, Int_t j) const
void SetMassConstraint(Double_t Mass, Double_t SigmaMass=0)
Double_t fSFromDecay
Int_t GetDecayLengthXY(Double_t &L, Double_t &SigmaL) const
const Int_t & NDF() const
void RotateXY(Double_t angle, Double_t Vtx[3])
Double_t GetDeviationFromVertex(const Double_t v[], const Double_t Cv[]=0) const
Double_t fC[36]
virtual ~KFParticleBase()
const std::vector< int > & DaughterIds() const
int NDaughters() const
static void MultQSQt(const Double_t Q[], const Double_t S[], Double_t SOut[])
Double_t GetCovariance(Int_t i) const
Int_t GetR(Double_t &R, Double_t &SigmaR) const
void SetPDG(int pdg)
Double_t GetChi2() const
void AddDaughterWithEnergyFit(const KFParticleBase &Daughter)
const Double_t & Px() const
Double_t GetDStoPointCBM(const Double_t xyz[]) const
const Double_t & GetSumDaughterMass() const
void AddDaughterId(int id)
void Convert(bool ToProduction)
Double_t GetX() const
void AddDaughterWithEnergyFitMC(const KFParticleBase &Daughter)
Double_t GetE() const
void Construct(const KFParticleBase *vDaughters[], Int_t nDaughters, const KFParticleBase *ProdVtx=nullptr, Double_t Mass=-1, Bool_t IsConstrained=0)
void GetMeasurement(const Double_t XYZ[], Double_t m[], Double_t V[]) const
void TransportToDS(Double_t dS)
Double_t GetS() const
void GetDSIter(const KFParticleBase &p, Double_t const &dS, Double_t x[3], Double_t dx[3], Double_t ddx[3]) const
const Double_t & X() const
Double_t & Px()
Double_t GetDeviationFromParticle(const KFParticleBase &p) const
Double_t & Z()
static Bool_t InvertSym3(const Double_t A[], Double_t Ainv[])
Bool_t fAtProductionVertex
Double_t & Covariance(Int_t i, Int_t j)
Double_t fMassHypo
Double_t GetDStoPointLine(const Double_t xyz[]) const
void AddDaughter(const KFParticleBase &Daughter)
Double_t & Parameter(Int_t i)
Double_t & Pz()
std::vector< int > fDaughtersIds
Double_t GetDistanceFromParticle(const KFParticleBase &p) const
void SetId(int id)
const Double_t & S() const
Int_t GetDecayLength(Double_t &L, Double_t &SigmaL) const
Double_t & Py()
const Double_t & E() const
const Double_t & Z() const
void ConstructGammaBz(const KFParticleBase &daughter1, const KFParticleBase &daughter2, double Bz)
virtual Double_t GetDStoPoint(const Double_t xyz[]) const =0
Double_t & Covariance(Int_t i)
void TransportBz(Double_t Bz, Double_t dS, Double_t P[], Double_t C[]) const
Int_t GetLifeTime(Double_t &T, Double_t &SigmaT) const