StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
KFParticleBase.h
1 //---------------------------------------------------------------------------------
2 // The KFParticleBase class
3 // .
4 // @author S.Gorbunov, I.Kisel
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 Group =-
16 //_________________________________________________________________________________
17 #ifndef KFParticleBASE_H
18 #define KFParticleBASE_H
19 #include "TObject.h"
20 class KFParticleBase : public TObject {
21  public:
22  // ABSTRACT METHODS HAVE TO BE DEFINED IN USER CLASS
23  // Virtual method to access the magnetic field
24  virtual void GetFieldValue(const Double_t xyz[], Double_t B[]) const = 0;
25  // Virtual methods needed for particle transportation
26  // One can use particular implementations for collider (only Bz component)
27  // geometry and for fixed-target (CBM-like) geometry which are provided below
28  // in TRANSPORT section
29 
30  // Get dS to xyz[] space point
31  virtual Double_t GetDStoPoint( const Double_t xyz[] ) const = 0;
32  // Get dS to other particle p (dSp for particle p also returned)
33  virtual void GetDStoParticle( const KFParticleBase &p,
34  Double_t &DS, Double_t &DSp ) const = 0;
35  // Transport on dS value along trajectory, output to P,C
36  virtual void Transport( Double_t dS, Double_t P[], Double_t C[] ) const = 0;
38  virtual ~KFParticleBase() {}
39  // Initialisation from "cartesian" coordinates ( X Y Z Px Py Pz )
40  // Parameters, covariance matrix, charge, and mass hypothesis should be provided
41  void Initialize( const Double_t Param[], const Double_t Cov[], Int_t Charge, Double_t Mass, Int_t PID = 0);
42  // Initialise covariance matrix and set current parameters to 0.0
43  void Initialize();
44  virtual void Clear(Option_t * /*option*/ ="");
45  // Set decay vertex parameters for linearisation
46  void SetVtxGuess( Double_t x, Double_t y, Double_t z );
47  void SetID(Int_t id=0) {fID = id;}
48  void SetParentID(Int_t id=0) {fParentID = id;}
49  // ACCESSORS
50  Int_t GetID() const {return fID;}
51  Int_t GetParentID() const {return fParentID;}
52  Double_t GetX () const { return fP[0]; }
53  Double_t GetY () const { return fP[1]; }
54  Double_t GetZ () const { return fP[2]; }
55  Double_t GetPx () const { return fP[3]; }
56  Double_t GetPy () const { return fP[4]; }
57  Double_t GetPz () const { return fP[5]; }
58  Double_t GetE () const { return fP[6]; }
59  Double_t GetS () const { return fP[7]; }
60  Short_t GetQ () const { return fQ; }
61  Double_t GetChi2 () const { return fChi2; }
62  Short_t GetNDF () const { return fNDF; }
63 
64  const Double_t *GetParameter() const { return fP;}
65  Double_t GetParameter ( Int_t i ) const { return fP[i];}
66  const Double_t *GetCovariance() const { return fC;}
67  Double_t GetCovariance( Int_t i ) const { return fC[i]; }
68  Double_t GetCovariance( Int_t i, Int_t j ) const { return fC[IJ(i,j)]; }
69 
70  // Accessors with calculations( &value, &estimated sigma )
71  // error flag returned (0 means no error during calculations)
72 
73  Int_t GetMomentum ( Double_t &P, Double_t &SigmaP ) const ;
74  Int_t GetPt ( Double_t &Pt, Double_t &SigmaPt ) const ;
75  Int_t GetEta ( Double_t &Eta, Double_t &SigmaEta ) const ;
76  Int_t GetPhi ( Double_t &Phi, Double_t &SigmaPhi ) const ;
77  Int_t GetMass ( Double_t &M, Double_t &SigmaM ) const ;
78  Int_t GetDecayLength ( Double_t &L, Double_t &SigmaL ) const ;
79  Int_t GetDecayLengthXY ( Double_t &L, Double_t &SigmaL ) const ;
80  Int_t GetLifeTime ( Double_t &T, Double_t &SigmaT ) const ;
81  Int_t GetR ( Double_t &R, Double_t &SigmaR ) const ;
82 
83  //
84  // MODIFIERS
85  //
86 
87  Double_t & X () { return fP[0]; }
88  Double_t & Y () { return fP[1]; }
89  Double_t & Z () { return fP[2]; }
90  Double_t & Px () { return fP[3]; }
91  Double_t & Py () { return fP[4]; }
92  Double_t & Pz () { return fP[5]; }
93  Double_t & E () { return fP[6]; }
94  Double_t & S () { return fP[7]; }
95  Short_t & Q () { return fQ; }
96  Double_t & Chi2 () { return fChi2; }
97  Short_t & NDF () { return fNDF; }
98 
99  Double_t & Parameter ( Int_t i ) { return fP[i]; }
100  Double_t & Covariance( Int_t i ) { return fC[i]; }
101  Double_t & Covariance( Int_t i, Int_t j ) { return fC[IJ(i,j)]; }
102 
103 
104  //
105  // CONSTRUCTION OF THE PARTICLE BY ITS DAUGHTERS AND MOTHER
106  // USING THE KALMAN FILTER METHOD
107  //
108 
109 
110  // Simple way to add daughter ex. D0+= Pion;
111 
112  void operator +=( const KFParticleBase &Daughter );
113 
114  // Add daughter track to the particle
115 
116  void AddDaughter( const KFParticleBase &Daughter );
117 
118  // Set production vertex
119 
120  void SetProductionVertex( const KFParticleBase &Vtx );
121 
122  // Set mass constraint
123 
124  void SetMassConstraint( Double_t Mass, Double_t SigmaMass = 0 );
125 
126  // Set no decay length for resonances
127 
128  void SetNoDecayLength();
129 
130 
131  // Everything in one go
132 
133  void Construct( const KFParticleBase *vDaughters[], Int_t NDaughters,
134  const KFParticleBase *ProdVtx=0, Double_t Mass=-1, Bool_t IsConstrained=0 );
135 
136 
137  //
138  // TRANSPORT
139  //
140  // ( main transportation parameter is S = SignedPath/Momentum )
141  // ( parameters of decay & production vertices are stored locally )
142  //
143 
144 
145  // Transport the particle to its decay vertex
146 
147  void TransportToDecayVertex();
148 
149  // Transport the particle to its production vertex
150 
151  void TransportToProductionVertex();
152 
153  // Transport the particle on dS parameter (SignedPath/Momentum)
154 
155  void TransportToDS( Double_t dS );
156 
157  // Particular extrapolators one can use
158 
159  Double_t GetDStoPointBz( Double_t Bz, const Double_t xyz[] ) const;
160 
161  void GetDStoParticleBz( Double_t Bz, const KFParticleBase &p,
162  Double_t &dS, Double_t &dS1 ) const ;
163 
164  // Double_t GetDStoPointCBM( const Double_t xyz[] ) const;
165 
166  void TransportBz( Double_t Bz, Double_t dS, Double_t P[], Double_t C[] ) const;
167  void TransportCBM( Double_t dS, Double_t P[], Double_t C[] ) const;
168 
169 
170  //
171  // OTHER UTILITIES
172  //
173 
174  // Calculate distance from another object [cm]
175 
176  Double_t GetDistanceFromVertex( const Double_t vtx[] ) const;
177  Double_t GetDistanceFromVertex( const KFParticleBase &Vtx ) const;
178  Double_t GetDistanceFromParticle( const KFParticleBase &p ) const;
179 
180  // Calculate sqrt(Chi2/ndf) deviation from vertex
181  // v = [xyz], Cv=[Cxx,Cxy,Cyy,Cxz,Cyz,Czz]-covariance matrix
182 
183  Double_t GetDeviationFromVertex( const Double_t v[],
184  const Double_t Cv[]=0 ) const;
185  Double_t GetDeviationFromVertex( const KFParticleBase &Vtx ) const;
186  Double_t GetDeviationFromParticle( const KFParticleBase &p ) const;
187 
188  // Subtract the particle from the vertex
189 
190  void SubtractFromVertex( KFParticleBase &Vtx ) const ;
191  void SubtractFromParticle( KFParticleBase &Vtx ) const;
192 
193  // Special method for creating gammas
194 
195  void ConstructGammaBz( const KFParticleBase &daughter1,
196  const KFParticleBase &daughter2, Double_t Bz );
197  virtual void Print(Option_t *opt="") const;
198  Int_t IdTruth() const { return fIdTruth;}
199  Int_t QaTruth() const { return fQuality; }
200  Int_t IdParentMcVx() const {return fIdParentMcVx;}
201  Int_t IdParentVx() const {return IdParentMcVx();}
202 
203  void SetIdTruth(Int_t idtru,Int_t qatru=0) {fIdTruth = (UShort_t) idtru; fQuality = (UShort_t) qatru;}
204  void SetIdParentMcVx(Int_t id) {fIdParentMcVx = id;}
205  void SetPDG ( Int_t pdg ) { fPDG = pdg; }
206  Int_t GetPDG () const { return fPDG; }
207  protected:
208 
209  static Int_t IJ( Int_t i, Int_t j ){
210  return ( j<=i ) ? i*(i+1)/2+j :j*(j+1)/2+i;
211  }
212 
213  Double_t & Cij( Int_t i, Int_t j ){ return fC[IJ(i,j)]; }
214 
215  void Convert( Bool_t ToProduction );
216  void TransportLine( Double_t S, Double_t P[], Double_t C[] ) const ;
217  Double_t GetDStoPointLine( const Double_t xyz[] ) const;
218 
219  static Bool_t InvertSym3( const Double_t A[], Double_t Ainv[] );
220  static void InvertCholetsky3(Double_t a[6]);
221 
222  static void MultQSQt( const Double_t Q[], const Double_t S[],
223  Double_t SOut[] );
224 
225  static Double_t GetSCorrection( const Double_t Part[], const Double_t XYZ[] );
226 
227  void GetMeasurement( const Double_t XYZ[], Double_t m[], Double_t V[] ) const ;
228 
229  Char_t fBeg[1];
230  Int_t fID;
231  Int_t fParentID;
232  Double32_t fP[8]; // Main particle parameters {X,Y,Z,Px,Py,Pz,E,S[=DecayLength/P]}
233  Double32_t fC[36]; // Low-triangle covariance matrix of fP
234  Short_t fQ; // Particle charge
235  Short_t fNDF; // Number of degrees of freedom
236  Double32_t fChi2; // Chi^2
237 
238  Double32_t fSFromDecay; // Distance from decay vertex to current position
239  Bool_t fAtProductionVertex;
240 
241  Double32_t fVtxGuess[3];
242 
243  Bool_t fIsLinearized;
244  UShort_t fIdTruth; // MC track id
245  UShort_t fQuality; // quality of this information (percentage of hits coming from the above MC track)
246  UShort_t fIdParentMcVx; // for track and McTrack for vertex
247  Short_t fPDG; // pdg hypothesis
248  Char_t fEnd[1];
249  ClassDef(KFParticleBase,4)
250 };
251 std::ostream& operator<<(std::ostream& os, KFParticleBase const & particle);
252 #endif
Double32_t fVtxGuess[3]
Flag shows that the particle error along its trajectory is taken from production vertex.
Bool_t fIsLinearized
Guess for the position of the decay vertex ( used for linearisation of equations ) ...
UShort_t fIdTruth
Flag shows that the guess is present.