]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliExternalTrackParam.h
Fix Coverity reports
[u/mrichter/AliRoot.git] / STEER / AliExternalTrackParam.h
index 08e2211d6022735928e209b732a1c82cd2b7e2d7..3e93a1bb67d8564b8b96b9f2400ca6e31f07af31 100644 (file)
 
 /* $Id$ */
 
+/*****************************************************************************
+ *              "External" track parametrisation class                       *
+ *                                                                           *
+ *      external param0:   local Y-coordinate of a track (cm)                *
+ *      external param1:   local Z-coordinate of a track (cm)                *
+ *      external param2:   local sine of the track momentum azimuthal angle  *
+ *      external param3:   tangent of the track momentum dip angle           *
+ *      external param4:   1/pt (1/(GeV/c))                                  *
+ *                                                                           *
+ * The parameters are estimated at an exact position x in a local coord.     *
+ * system rotated by angle alpha with respect to the global coord.system.    *
+ *        Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch                     *
+ *****************************************************************************/
+#include "TMath.h"
 
-#include "TObject.h"
-#include "AliMagF.h"
-#include "TVector3.h"
+#include "AliVTrack.h"
 
-class AliKalmanTrack;
-class AliTrackReference;
+const Double_t kVeryBig=1./kAlmost0;
+const Double_t kMostProbablePt=0.35;
 
-class AliExternalTrackParam: public TObject {
+class AliVVertex;
+class TPolyMarker3D; 
+
+const Double_t kC0max=100*100, // SigmaY<=100cm
+               kC2max=100*100, // SigmaZ<=100cm
+               kC5max=1*1,     // SigmaSin<=1
+               kC9max=1*1,     // SigmaTan<=1
+               kC14max=100*100; // Sigma1/Pt<=100 1/GeV
+
+class AliExternalTrackParam: public AliVTrack {
  public:
   AliExternalTrackParam();
+  AliExternalTrackParam(const AliExternalTrackParam &);
+  AliExternalTrackParam& operator=(const AliExternalTrackParam & trkPar);
   AliExternalTrackParam(Double_t x, Double_t alpha, 
                        const Double_t param[5], const Double_t covar[15]);
-  AliExternalTrackParam(const AliKalmanTrack& track);
-  static AliExternalTrackParam * MakeTrack(const AliTrackReference *ref, Double_t mass);
-
-  virtual const Double_t* GetParameter() const;
-  virtual const Double_t* GetCovariance() const;
-  virtual Double_t     X() const {return fX;};
-  virtual Double_t     Alpha() const {return fAlpha;};
-  virtual AliExternalTrackParam* CreateExternalParam() const;
-  virtual void         ResetCovariance(Double_t factor = 10.,
-                                      Bool_t clearOffDiagonal = kTRUE);
-  virtual Double_t     Y() const {return fParam[0];};
-  virtual Double_t     Z() const {return fParam[1];};
-  virtual void         GetXYZ(Float_t r[3]) const;
-  virtual void         GetGlobalXYZ(Double_t &x, Double_t &y, Double_t &z ) const;
-  virtual Bool_t       PropagateTo(Double_t x,  Double_t x0, Double_t rho);
-  virtual Bool_t       PropagateToDCA(Double_t x, Double_t y,  Double_t x0, Double_t rho);
-  virtual Bool_t       RotateTo(Double_t alpha);
-  virtual Bool_t       CorrectForMaterial(Double_t d, Double_t x0, Double_t rho);
-  virtual Bool_t       GetProlongationAt(Double_t x, Double_t& y, 
-                                        Double_t& z) const;
-  virtual Double_t     GetXAtVertex(Double_t x = 0, Double_t y = 0) const;
-
-  //  virtual Double_t     GetPredictedChi2(const AliCluster* cluster);
-  //  virtual Bool_t       Update(const AliCluster* cluster);
-
-  virtual Double_t     SigmaPhi() const;
-  virtual Double_t     SigmaTheta() const;
-  virtual Double_t     SigmaPt() const;
-  virtual TVector3     Momentum() const;
-  virtual TVector3     Position() const;
-
-  virtual void         Print(Option_t* option = "") const;
-  // local magnetic field manipulation 
-  void     SaveLocalConvConst();
-  Double_t GetLocalConvConst() const;
+  AliExternalTrackParam(const AliVTrack *vTrack);
+  AliExternalTrackParam(Double_t xyz[3],Double_t pxpypz[3],
+                       Double_t cv[21],Short_t sign);
+  virtual ~AliExternalTrackParam(){}
+
+  template <typename T>
+  void Set(T x, T alpha, const T param[5], const T covar[15]) {
+    //  Sets the parameters
+    fX=x; fAlpha=alpha;
+    for (Int_t i = 0; i < 5; i++)  fP[i] = param[i];
+    for (Int_t i = 0; i < 15; i++) fC[i] = covar[i];
+
+    CheckCovariance();
+
+  }
+
+  void Set(Double_t xyz[3],Double_t pxpypz[3],Double_t cv[21],Short_t sign);
+
+  static void SetMostProbablePt(Double_t pt) { fgMostProbablePt=pt; }
+  static Double_t GetMostProbablePt() { return fgMostProbablePt; }
+
+  void Reset();
+  void ResetCovariance(Double_t s2);
+  void AddCovariance(const Double_t cov[15]);
+
+  const Double_t *GetParameter() const {return fP;}
+  const Double_t *GetCovariance() const {return fC;}
+
+  Double_t GetAlpha() const {return fAlpha;}
+  Double_t GetX() const {return fX;}
+  Double_t GetY()    const {return fP[0];}
+  Double_t GetZ()    const {return fP[1];}
+  Double_t GetSnp()  const {return fP[2];}
+  Double_t GetTgl()  const {return fP[3];}
+  Double_t GetSigned1Pt()  const {return fP[4];}
+
+  Double_t GetSigmaY2() const {return fC[0];}
+  Double_t GetSigmaZY() const {return fC[1];}
+  Double_t GetSigmaZ2() const {return fC[2];}
+  Double_t GetSigmaSnpY() const {return fC[3];}
+  Double_t GetSigmaSnpZ() const {return fC[4];}
+  Double_t GetSigmaSnp2() const {return fC[5];}
+  Double_t GetSigmaTglY() const {return fC[6];}
+  Double_t GetSigmaTglZ() const {return fC[7];}
+  Double_t GetSigmaTglSnp() const {return fC[8];}
+  Double_t GetSigmaTgl2() const {return fC[9];}
+  Double_t GetSigma1PtY() const {return fC[10];}
+  Double_t GetSigma1PtZ() const {return fC[11];}
+  Double_t GetSigma1PtSnp() const {return fC[12];}
+  Double_t GetSigma1PtTgl() const {return fC[13];}
+  Double_t GetSigma1Pt2() const {return fC[14];}
+
+  // additional functions for AliVParticle
+  Double_t Px() const;
+  Double_t Py() const;
+  Double_t Pz() const { return Pt()*GetTgl(); }
+  Double_t Pt() const { return TMath::Abs(GetSignedPt()); }
+  Double_t P() const { return GetP(); }
+  Bool_t   PxPyPz(Double_t p[3]) const { return GetPxPyPz(p); }
   
-  static void SetFieldMap(const AliMagF *map) { fgkFieldMap=map; }
-  static const AliMagF *GetFieldMap() { return fgkFieldMap; }
-
-  static void SetUniformFieldTracking() {
-     if (fgkFieldMap==0) {
-        printf("AliKalmanTrack: Field map has not been set !\n"); 
-        exit(1);
-     } 
-     fgConvConst=1000/0.299792458/(fgkFieldMap->SolenoidField()+1e-13);
+  Double_t Xv() const;
+  Double_t Yv() const;
+  Double_t Zv() const {return GetZ();}
+  Bool_t   XvYvZv(Double_t x[3]) const { return GetXYZ(x); }
+
+  Double_t OneOverPt() const { return 1./Pt(); }
+  Double_t Phi() const;
+  Double_t Theta() const;
+  virtual Double_t E() const;
+  virtual Double_t M() const;
+  Double_t Eta() const;
+  virtual Double_t Y() const;
+  virtual Short_t  Charge() const { return (Short_t)GetSign(); }
+  virtual const Double_t *PID() const { return 0x0; }
+
+  // additional functions from AliVTrack
+  virtual Int_t    GetID() const { return -999; }
+  virtual UChar_t  GetITSClusterMap() const {return 0; }
+  virtual ULong_t  GetStatus() const { return 0; }
+
+  Double_t GetSign() const {return (fP[4]>0) ? 1 : -1;}
+  Double_t GetP() const;
+  Double_t GetSignedPt() const {
+    return (TMath::Abs(fP[4])>kAlmost0) ? 1./fP[4]:TMath::Sign(kVeryBig,fP[4]);
   }
-  static void SetNonuniformFieldTracking() { fgConvConst=0.; }
+  Double_t Get1P() const;
+  virtual Double_t GetC(Double_t b) const {return fP[4]*b*kB2C;}
+  void GetDZ(Double_t x,Double_t y,Double_t z,Double_t b,Float_t dz[2]) const; 
+  Double_t GetD(Double_t xv, Double_t yv, Double_t b) const; 
+  Double_t GetLinearD(Double_t xv, Double_t yv) const; 
+
+  Bool_t CorrectForMeanMaterial(Double_t xOverX0, Double_t xTimesRho, 
+        Double_t mass,  Bool_t anglecorr=kFALSE,
+       Double_t (*f)(Double_t)=AliExternalTrackParam::BetheBlochSolid);
+
+  Bool_t CorrectForMeanMaterialdEdx(Double_t xOverX0, Double_t xTimesRho, 
+       Double_t mass, Double_t dEdx, Bool_t anglecorr=kFALSE);
+
+  Bool_t CorrectForMeanMaterialZA(Double_t xOverX0, Double_t xTimesRho, 
+                                  Double_t mass,
+                                  Double_t zOverA=0.49848,
+                                  Double_t density=2.33,
+                                  Double_t exEnergy=173e-9,
+                                  Double_t jp1=0.20,
+                                  Double_t jp2=3.00,
+                                  Bool_t anglecorr=kFALSE
+  );
 
- private:
-  Double_t             fMass;       // mass associated to the particle
-  Double_t             fX;          // x coordinate for the parametrisation
-  Double_t             fAlpha;      // azimuthal angle for the parametrisation
-  Double_t             fParam[5];   // track parameter (y, z, sin(azimuthal angel), tan(dip angle), 1/pt)
-  Double_t             fCovar[15];  // track parameter covariance
   //
-  static const AliMagF *fgkFieldMap;//pointer to the magnetic field map
-  static Double_t fgConvConst;      //conversion "curvature(1/cm) -> pt(GeV/c)"
-  Double_t fLocalConvConst;         //local conversion "curvature(1/cm) -> pt(GeV/c)"
+  // Bethe-Bloch formula parameterizations
+  //
+  static Double_t BetheBlochAleph(Double_t bg,
+                                  Double_t kp1=0.76176e-1,
+                                  Double_t kp2=10.632,
+                                  Double_t kp3=0.13279e-4,
+                                  Double_t kp4=1.8631,
+                                  Double_t kp5=1.9479
+                                 );
+  static Double_t BetheBlochGeant(Double_t bg,
+                                  Double_t kp0=2.33,
+                                  Double_t kp1=0.20,
+                                  Double_t kp2=3.00,
+                                  Double_t kp3=173e-9,
+                                  Double_t kp4=0.49848
+                                 );
+    
+  static Double_t BetheBlochSolid(Double_t bg);
+  static Double_t BetheBlochGas(Double_t bg);
+
+  Double_t GetPredictedChi2(Double_t p[2],Double_t cov[3]) const;
 
+  Double_t 
+    GetPredictedChi2(Double_t p[3],Double_t covyz[3],Double_t covxyz[3]) const;
 
-  ClassDef(AliExternalTrackParam, 3)
+  Double_t GetPredictedChi2(const AliExternalTrackParam *t) const;
+
+  Bool_t 
+    PropagateTo(Double_t p[3],Double_t covyz[3],Double_t covxyz[3],Double_t b);
+
+  Double_t *GetResiduals(Double_t *p,Double_t *cov,Bool_t updated=kTRUE) const;
+  Bool_t Update(Double_t p[2],Double_t cov[3]);
+  Bool_t Rotate(Double_t alpha);
+  Bool_t PropagateTo(Double_t x, Double_t b);
+  Bool_t Propagate(Double_t alpha, Double_t x, Double_t b);
+  Bool_t PropagateBxByBz(Double_t alpha, Double_t x, Double_t b[3]);
+  void   Propagate(Double_t len,Double_t x[3],Double_t p[3],Double_t bz) const;
+  Bool_t Intersect(Double_t pnt[3], Double_t norm[3], Double_t bz) const;
+
+  static void g3helx3(Double_t qfield, Double_t step, Double_t vect[7]); 
+  Bool_t PropagateToBxByBz(Double_t x, const Double_t b[3]);
+
+  void GetHelixParameters(Double_t h[6], Double_t b) const;
+  Double_t GetDCA(const AliExternalTrackParam *p, Double_t b,
+    Double_t &xthis,Double_t &xp) const;
+  Double_t PropagateToDCA(AliExternalTrackParam *p, Double_t b);
+  Bool_t PropagateToDCA(const AliVVertex *vtx, Double_t b, Double_t maxd,
+                        Double_t dz[2]=0, Double_t cov[3]=0);
+  Bool_t PropagateToDCABxByBz(const AliVVertex *vtx, Double_t b[3], 
+         Double_t maxd, Double_t dz[2]=0, Double_t cov[3]=0);
+  
+  void GetDirection(Double_t d[3]) const;
+  Bool_t GetPxPyPz(Double_t *p) const;
+  Bool_t GetXYZ(Double_t *p) const;
+  Bool_t GetCovarianceXYZPxPyPz(Double_t cv[21]) const;
+  Bool_t GetPxPyPzAt(Double_t x, Double_t b, Double_t p[3]) const;
+  Bool_t GetXYZAt(Double_t x, Double_t b, Double_t r[3]) const;
+  Bool_t GetYAt(Double_t x,  Double_t b,  Double_t &y) const;
+  Bool_t GetZAt(Double_t x,  Double_t b,  Double_t &z) const;
+  void Print(Option_t* option = "") const;
+  Double_t GetSnpAt(Double_t x,Double_t b) const;
+
+  //Deprecated
+  Bool_t CorrectForMaterial(Double_t d, Double_t x0, Double_t mass,
+        Double_t (*f)(Double_t)=AliExternalTrackParam::BetheBlochSolid);
+
+  Bool_t GetDistance(AliExternalTrackParam *param2, Double_t x, Double_t dist[3], Double_t b);
+  Int_t GetIndex(Int_t i, Int_t j) const;
+  Int_t GetLabel() const {return -1;} 
+  Int_t PdgCode()  const {return 0;}
+
+  //
+  // visualization (M. Ivanov)
+  //
+  virtual void FillPolymarker(TPolyMarker3D *pol, Float_t magf, Float_t minR, Float_t maxR, Float_t stepR);
+  virtual void DrawTrack(Float_t magF, Float_t minR, Float_t maxR, Float_t stepR);
+
+  virtual Bool_t Translate(Double_t *vTrasl,Double_t *covV);
+
+  void CheckCovariance();
+
+/*  protected: */
+ private:
+  Double_t &Par(Int_t i) {return fP[i];}
+  Double_t &Cov(Int_t i) {return fC[i];}
+  
+ private:
+  Double32_t           fX;     // X coordinate for the point of parametrisation
+  Double32_t           fAlpha; // Local <-->global coor.system rotation angle
+  Double32_t           fP[5];  // The track parameters
+  Double32_t           fC[15]; // The track parameter covariance matrix
+
+  static Double32_t    fgMostProbablePt; // "Most probable" pt
+                                         // (to be used if Bz=0)
+  ClassDef(AliExternalTrackParam, 8)
 };
 
+inline void AliExternalTrackParam::ResetCovariance(Double_t s2) {
+  //
+  // Reset the covarince matrix to "something big"
+  //
+
+  s2 = TMath::Abs(s2);
+  Double_t fC0=fC[0]*s2,
+           fC2=fC[2]*s2,
+           fC5=fC[5]*s2,
+           fC9=fC[9]*s2,
+           fC14=fC[14]*s2;
+  if (fC0>kC0max)  fC0 = kC0max;
+  if (fC2>kC2max)  fC2 = kC2max;
+  if (fC5>kC5max)  fC5 = kC5max;
+  if (fC9>kC9max)  fC9 = kC9max;
+  if (fC14>kC14max)  fC14 = kC14max;
 
-inline void AliExternalTrackParam::SaveLocalConvConst() {
-  //---------------------------------------------------------------------
-  // Saves local conversion constant "curvature (1/cm) -> pt (GeV/c)" 
-  //---------------------------------------------------------------------
-     if (fgConvConst > 0 || fgConvConst < 0) return; //uniform field tracking
-     Float_t r[3]={0.,0.,0.}; GetXYZ(r);
-     Float_t b[3]; fgkFieldMap->Field(r,b);
-     fLocalConvConst=1000/0.299792458/(1e-13 - b[2]);
-} 
-
-inline Double_t AliExternalTrackParam::GetLocalConvConst() const {
-  //---------------------------------------------------------------------
-  // Returns conversion constant "curvature (1/cm) -> pt (GeV/c)" 
-  //---------------------------------------------------------------------
-     if (fgConvConst > 0 || fgConvConst < 0) return fgConvConst; //uniform field tracking
-     return fLocalConvConst;
-} 
-
-
-inline void AliExternalTrackParam::GetXYZ(Float_t r[3]) const {
-  //---------------------------------------------------------------------
-  // Returns the position of the track in the global coord. system 
-  //---------------------------------------------------------------------
-  Double_t cs=TMath::Cos(fAlpha), sn=TMath::Sin(fAlpha);
-  r[0]=fX*cs - fParam[0]*sn; r[1]=fX*sn + fParam[0]*cs; r[2]=fParam[1];
-}
 
-inline void AliExternalTrackParam::GetGlobalXYZ(Double_t &x, Double_t &y, Double_t &z) const {
-  //---------------------------------------------------------------------
-  // Returns the position of the track in the global coord. system 
-  //---------------------------------------------------------------------
-  Double_t cs=TMath::Cos(fAlpha), sn=TMath::Sin(fAlpha);
-  x=fX*cs - fParam[0]*sn; y=fX*sn + fParam[0]*cs; z=fParam[1];
+    fC[0] = fC0;
+    fC[1] = 0.;  fC[2] = fC2;
+    fC[3] = 0.;  fC[4] = 0.;  fC[5] = fC5;
+    fC[6] = 0.;  fC[7] = 0.;  fC[8] = 0.;  fC[9] = fC9;
+    fC[10]= 0.;  fC[11]= 0.;  fC[12]= 0.;  fC[13]= 0.;  fC[14] = fC14;
 }