KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVGausGumDistribution.cpp
Go to the documentation of this file.
1 //Created by KVClassFactory on Mon Apr 20 14:02:31 2012
2 //Author: John Frankland,,,
3 
5 #include "TMath.h"
6 #include "Riostream.h"
7 
9 
10 
11 
15  : TF1(), fGaussComp(0), fGumbelComp(0)
16 {
17  // default ctor
19  SetNpx(2000);
20  fkFac = 0.;
21  fkGaussNor = 1. / sqrt(2 * TMath::Pi());
22 }
23 
24 
25 
26 
31 
33  : TF1(name, this, &KVGausGumDistribution::GDk, xmin, xmax, 5,
34  "KVGausGumDistribution", "GDk"), fGaussComp(0), fGumbelComp(0)
35 {
36  // normalised sum of Gaussian distribution and Gumbel distribution of k-th rank
37  // f = eta*Gauss(mean,sigma) + (1-eta)*Gumbel(a,b)
38  // free parameters: gauss: (mean,sigma) gumbel: (a,b) eta
39  fRank = k;
40  fkFac = TMath::Power(k, k) / TMath::Factorial(k - 1);
41  fkGaussNor = 1. / sqrt(2 * TMath::Pi());
42  SetParName(0, "#eta");
43  SetParName(1, "#mu");
44  SetParName(2, "#sigma");
45  SetParName(3, "#mu-a_{m}");
46  SetParName(4, "b_{m}");
47  SetParLimits(0, 0., 1.);
48  SetParLimits(1, GetXmin(), GetXmax());
49  SetParLimits(2, 0.01, 200.);
50  SetParLimits(3, 0.01, GetXmax());
51  SetParLimits(4, 0.01, 200.);
53  SetNpx(2000);
54 
55 }
56 
57 
58 
59 
66 
68 {
69  // Copy constructor
70  // This ctor is used to make a copy of an existing object (for example
71  // when a method returns an object), and it is always a good idea to
72  // implement it.
73  // If your class allocates memory in its constructor(s) then it is ESSENTIAL :-)
74 
75  obj.Copy(*this);
76 }
77 
78 
79 
82 
84 {
85  // Destructor
88 }
89 
90 
91 
92 
100 
102 {
103  // This method copies the current state of 'this' object into 'obj'
104  // You should add here any member variables, for example:
105  // (supposing a member variable KVGausGumDistribution::fToto)
106  // CastedObj.fToto = fToto;
107  // or
108  // CastedObj.SetToto( GetToto() );
109 
110  TF1::Copy(obj);
111  KVGausGumDistribution& CastedObj = (KVGausGumDistribution&)obj;
112  CastedObj.fRank = fRank;
113  CastedObj.fkFac = fkFac;
114  CastedObj.fkGaussNor = fkGaussNor;
115 }
116 
117 
118 
119 
122 
124 {
125  // Draw total distribution and the two component distributions
126 
127  TF1::Paint(option);
128  if (!fkGaussNor) fkGaussNor = 1. / sqrt(2 * TMath::Pi());
129 
130  if (!fGaussComp) fGaussComp = new TF1("GaussComp", "[0]*exp(-0.5*((x-[1])/[2])**2)", GetXmin(), GetXmax());
131  if (!fGumbelComp) fGumbelComp = new KVGumbelDistribution("GumbelComp", fRank, false, GetXmin(), GetXmax());
134 
138  fGaussComp->SetNpx(2000);
139 
142  fGumbelComp->SetNpx(2000);
143 
144  fGaussComp->Paint("same");
145  fGumbelComp->Paint("same");
146 }
147 
148 
149 
150 
159 
161 {
162  // Evaluate normalised sum of Gaussian and Gumbel distribution of rank fRank for x
163  // with parameters
164  // par[0] = eta
165  // par[1] = mu
166  // par[2] = sigma
167  // par[3] = distance between gaussian and gumbel >=0
168  // par[4] = b
169 
170  if (p[4] == 0) return 0;
171 
172  Double_t am = p[1] - p[3];
173  Double_t s = (*x - am) / p[4];
174  Double_t gum = (fkFac / p[4]);
175  Double_t es = -fRank * (s + TMath::Exp(-s));
176  gum *= TMath::Exp(es);
177 
178  Double_t gau = fkGaussNor / p[2];
179  s = (*x - p[1]) / p[2];
180  s = TMath::Power(s, 2.) / 2.;
181  gau *= TMath::Exp(-s);
182 
183  Double_t gg = p[0] * gau + (1. - p[0]) * gum;
184  return gg;
185 }
186 
187 
int Int_t
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
#define SafeDelete(p)
char Char_t
double Double_t
const char Option_t
kRed
kBlack
kBlue
float xmin
float xmax
Probability distribution function made of sum of normalised Gaussian and Gumbel distributions.
Int_t fRank
rank of Gumbel distribution
Double_t GDk(Double_t *x, Double_t *p)
void Paint(Option_t *option="")
Draw total distribution and the two component distributions.
virtual ~KVGausGumDistribution()
Destructor.
KVGumbelDistribution * fGumbelComp
non-persistent (not written to disk)
TF1 * fGaussComp
non-persistent (not written to disk)
void Copy(TObject &) const
Gumbel distributions for rank-ordered extremal variables.
virtual void SetLineStyle(Style_t lstyle)
virtual void SetLineWidth(Width_t lwidth)
virtual void SetLineColor(Color_t lcolor)
virtual Double_t GetXmax() const
virtual Double_t GetParameter(const TString &name) const
virtual void Copy(TObject &f1) const
virtual void Paint(Option_t *option="")
virtual void SetNpx(Int_t npx=100)
virtual void SetParLimits(Int_t ipar, Double_t parmin, Double_t parmax)
virtual void SetParName(Int_t ipar, const char *name)
virtual void SetParameters(const Double_t *params)
virtual Double_t GetXmin() const
VecExpr< UnaryOp< Sqrt< T >, SVector< T, D >, T >, T, D > sqrt(const SVector< T, D > &rhs)
Double_t x[n]
const long double s
Definition: KVUnits.h:94
Double_t Factorial(Int_t i)
Double_t Exp(Double_t x)
Double_t Power(Double_t x, Double_t y)
constexpr Double_t Pi()
lv SetLineColor(kBlue)