source: trunk/MagicSoft/Mars/mbase/MMath.h@ 8004

Last change on this file since 8004 was 7999, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 3.4 KB
Line 
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
8class TVector3;
9class TArrayD;
10
11namespace MMath
12{
13 inline Double_t DegToHor() { return 1./15; }
14 inline Double_t HorToDeg() { return 15; }
15
16 inline Double_t RadToHor() { return TMath::RadToDeg()/15; }
17 inline Double_t HorToRad() { return 15/TMath::RadToDeg(); }
18
19 Double_t GaussProb(Double_t x, Double_t sigma=1, Double_t mean=0);
20
21 template <class Size, class Element> Double_t MedianDevImp(Size n, const Element *a) { Double_t med; return MedianDevImp(n, a, med); }
22 template <class Size, class Element> Double_t MedianDevImp(Size n, const Element *a, Double_t &med);
23 Double_t MedianDev(Long64_t n, const Short_t *a, Double_t &med);
24 Double_t MedianDev(Long64_t n, const Int_t *a, Double_t &med);
25 Double_t MedianDev(Long64_t n, const Float_t *a, Double_t &med);
26 Double_t MedianDev(Long64_t n, const Double_t *a, Double_t &med);
27 Double_t MedianDev(Long64_t n, const Long_t *a, Double_t &med);
28 Double_t MedianDev(Long64_t n, const Long64_t *a, Double_t &med);
29 Double_t MedianDev(Long64_t n, const Short_t *a);
30 Double_t MedianDev(Long64_t n, const Int_t *a);
31 Double_t MedianDev(Long64_t n, const Float_t *a);
32 Double_t MedianDev(Long64_t n, const Double_t *a);
33 Double_t MedianDev(Long64_t n, const Long_t *a);
34 Double_t MedianDev(Long64_t n, const Long64_t *a);
35
36 Double_t Significance(Double_t s, Double_t b);
37 Double_t SignificanceSym(Double_t s, Double_t b);
38 Double_t SignificanceLiMa(Double_t s, Double_t b, Double_t alpha=1);
39 Double_t SignificanceLiMaSigned(Double_t s, Double_t b, Double_t alpha=1);
40 Double_t SignificanceLiMaExc(Double_t s, Double_t b, Double_t alpha=1);
41
42 void ReducePrecision(Float_t &val);
43
44 TVector3 GetParab(const TVector3 &x, const TVector3 &y);
45 Double_t InterpolParabLin(const TVector3 &vx, const TVector3 &vy, Double_t x);
46 Double_t InterpolParabLog(const TVector3 &vx, const TVector3 &vy, Double_t x);
47 Double_t InterpolParabCos(const TVector3 &vx, const TVector3 &vy, Double_t x);
48
49 inline Int_t SolvePol1(Double_t c, Double_t d, Double_t &x1)
50 {
51 if (c==0)
52 return 0;
53
54 x1 = -d/c;
55 return 1;
56 }
57 Int_t SolvePol2(Double_t c, Double_t d, Double_t &x1, Double_t &x2);
58 inline Int_t SolvePol2(Double_t b, Double_t c, Double_t d, Double_t &x1, Double_t &x2)
59 {
60 return b==0 ? SolvePol1(c, d, x1) : SolvePol2(c/b, d/b, x1, x2);
61 }
62 Int_t SolvePol3(Double_t b, Double_t c, Double_t d, Double_t &x1, Double_t &x2, Double_t &x3);
63 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)
64 {
65 return a==0 ? SolvePol2(b, c, d, x1, x2) : SolvePol3(b/a, c/a, d/a, x1, x2, x3);
66 }
67
68 TArrayD LeastSqFitExpW1(Int_t n, Double_t *x, Double_t *y);
69 TArrayD LeastSqFitExp(Int_t n, Double_t *x, Double_t *y);
70 TArrayD LeastSqFitLog(Int_t n, Double_t *x, Double_t *y);
71 TArrayD LeastSqFitPowerLaw(Int_t n, Double_t *x, Double_t *y);
72
73 inline Int_t ModF(Double_t dbl, Double_t &frac) { Double_t rc; frac = modf(dbl, &rc); return TMath::Nint(rc); }
74
75 inline Double_t Sqrt3(Double_t x) { return TMath::Sign(TMath::Power(TMath::Abs(x), 1./3), x); }
76
77 inline Double_t Sgn(Double_t d) { return d<0 ? -1 : 1; }
78}
79
80#endif
Note: See TracBrowser for help on using the repository browser.