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