| 1 | #ifndef MARS_MMath | 
|---|
| 2 | #define MARS_MMath | 
|---|
| 3 |  | 
|---|
| 4 | #ifndef ROOT_TMath | 
|---|
| 5 | #include <TMath.h> // TMath is included here for convinience | 
|---|
| 6 | #endif | 
|---|
| 7 |  | 
|---|
| 8 | class TVector2; | 
|---|
| 9 | class TVector3; | 
|---|
| 10 | class TArrayD; | 
|---|
| 11 |  | 
|---|
| 12 | namespace MMath | 
|---|
| 13 | { | 
|---|
| 14 | inline Double_t DegToHor() { return 1./15; } | 
|---|
| 15 | inline Double_t HorToDeg() { return 15;    } | 
|---|
| 16 |  | 
|---|
| 17 | inline Double_t RadToHor() { return TMath::RadToDeg()/15; } | 
|---|
| 18 | inline Double_t HorToRad() { return 15/TMath::RadToDeg(); } | 
|---|
| 19 |  | 
|---|
| 20 | Double_t GaussProb(Double_t x, Double_t sigma=1, Double_t mean=0); | 
|---|
| 21 |  | 
|---|
| 22 | template <class Size, class Element> Double_t MedianDevImp(Size n, const Element *a) { Double_t med; return MedianDevImp(n, a, med); } | 
|---|
| 23 | template <class Size, class Element> Double_t MedianDevImp(Size n, const Element *a, Double_t &med); | 
|---|
| 24 | Double_t  MedianDev(Long64_t n, const Short_t  *a, Double_t &med); | 
|---|
| 25 | Double_t  MedianDev(Long64_t n, const Int_t    *a, Double_t &med); | 
|---|
| 26 | Double_t  MedianDev(Long64_t n, const Float_t  *a, Double_t &med); | 
|---|
| 27 | Double_t  MedianDev(Long64_t n, const Double_t *a, Double_t &med); | 
|---|
| 28 | Double_t  MedianDev(Long64_t n, const Long_t   *a, Double_t &med); | 
|---|
| 29 | Double_t  MedianDev(Long64_t n, const Long64_t *a, Double_t &med); | 
|---|
| 30 | Double_t  MedianDev(Long64_t n, const Short_t  *a); | 
|---|
| 31 | Double_t  MedianDev(Long64_t n, const Int_t    *a); | 
|---|
| 32 | Double_t  MedianDev(Long64_t n, const Float_t  *a); | 
|---|
| 33 | Double_t  MedianDev(Long64_t n, const Double_t *a); | 
|---|
| 34 | Double_t  MedianDev(Long64_t n, const Long_t   *a); | 
|---|
| 35 | Double_t  MedianDev(Long64_t n, const Long64_t *a); | 
|---|
| 36 |  | 
|---|
| 37 | Double_t Significance(Double_t s, Double_t b); | 
|---|
| 38 | Double_t SignificanceSym(Double_t s, Double_t b); | 
|---|
| 39 | Double_t SignificanceLiMa(Double_t s, Double_t b, Double_t alpha=1); | 
|---|
| 40 | Double_t SignificanceLiMaSigned(Double_t s, Double_t b, Double_t alpha=1); | 
|---|
| 41 | Double_t SignificanceLiMaExc(Double_t s, Double_t b, Double_t alpha=1); | 
|---|
| 42 |  | 
|---|
| 43 | void ReducePrecision(Float_t &val); | 
|---|
| 44 |  | 
|---|
| 45 | TVector3 GetParab(const TVector3 &x, const TVector3 &y); | 
|---|
| 46 | Double_t InterpolParabLin(const TVector3 &vx, const TVector3 &vy, Double_t x); | 
|---|
| 47 | Double_t InterpolParabLog(const TVector3 &vx, const TVector3 &vy, Double_t x); | 
|---|
| 48 | Double_t InterpolParabCos(const TVector3 &vx, const TVector3 &vy, Double_t x); | 
|---|
| 49 |  | 
|---|
| 50 | TVector2 GetIntersectionPoint(const TVector2 &x1, const TVector2 &y1, const TVector2 &x2, const TVector2 &y2); | 
|---|
| 51 |  | 
|---|
| 52 | inline Int_t SolvePol1(Double_t c, Double_t d, Double_t &x1) | 
|---|
| 53 | { | 
|---|
| 54 | if (c==0) | 
|---|
| 55 | return 0; | 
|---|
| 56 |  | 
|---|
| 57 | x1 = -d/c; | 
|---|
| 58 | return 1; | 
|---|
| 59 | } | 
|---|
| 60 | Int_t SolvePol2(Double_t c, Double_t d, Double_t &x1, Double_t &x2); | 
|---|
| 61 | inline Int_t SolvePol2(Double_t b, Double_t c, Double_t d, Double_t &x1, Double_t &x2) | 
|---|
| 62 | { | 
|---|
| 63 | return b==0 ? SolvePol1(c, d, x1) : SolvePol2(c/b, d/b, x1, x2); | 
|---|
| 64 | } | 
|---|
| 65 | Int_t SolvePol3(Double_t b, Double_t c, Double_t d, Double_t &x1, Double_t &x2, Double_t &x3); | 
|---|
| 66 | inline Int_t SolvePol3(Double_t a, Double_t b, Double_t c, Double_t d, Double_t &x1, Double_t &x2, Double_t &x3) | 
|---|
| 67 | { | 
|---|
| 68 | return a==0 ? SolvePol2(b, c, d, x1, x2) : SolvePol3(b/a, c/a, d/a, x1, x2, x3); | 
|---|
| 69 | } | 
|---|
| 70 |  | 
|---|
| 71 | TArrayD LeastSqFitExpW1(Int_t n, Double_t *x, Double_t *y); | 
|---|
| 72 | TArrayD LeastSqFitExp(Int_t n, Double_t *x, Double_t *y); | 
|---|
| 73 | TArrayD LeastSqFitLog(Int_t n, Double_t *x, Double_t *y); | 
|---|
| 74 | TArrayD LeastSqFitPowerLaw(Int_t n, Double_t *x, Double_t *y); | 
|---|
| 75 |  | 
|---|
| 76 | inline Int_t ModF(Double_t dbl, Double_t &frac) { Double_t rc; frac = modf(dbl, &rc); return TMath::Nint(rc); } | 
|---|
| 77 |  | 
|---|
| 78 | inline Double_t Sqrt3(Double_t x) { return TMath::Sign(TMath::Power(TMath::Abs(x), 1./3), x); } | 
|---|
| 79 |  | 
|---|
| 80 | inline Double_t Sgn(Double_t d) { return d<0 ? -1 : 1; } | 
|---|
| 81 | } | 
|---|
| 82 |  | 
|---|
| 83 | #endif | 
|---|