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