KaliVeda
Toolkit for HIC analysis
KVGumGumDistribution.cpp
1 //Created by KVClassFactory on Wed Jun 13 11:49:37 2012
2 //Author: dgruyer
3 
4 #include "KVGumGumDistribution.h"
5 #include "TMath.h"
6 #include "Riostream.h"
7 
9 
10 
11 
12 
15 KVGumGumDistribution::KVGumGumDistribution(): TF1(), fFirstGumbel(0), fLastGumbel(0)
16 {
17  // Default constructor
19  SetNpx(2000);
20  fkFac = 0.;
21 }
22 
23 
24 
25 
30 
32  : TF1(name, this, &KVGumGumDistribution::GDk, xmin, xmax, 5), fFirstGumbel(0), fLastGumbel(0)
33 {
34  // normalised sum of Gumbel distribution and Gumbel distribution of k-th rank
35  // f = eta*Gumbel(mu,sigma) + (1-eta)*Gumbel(ap,bp)
36  // free parameters: gauss: (mean,sigma) gumbel: (a,b) eta
37  fRank = k;
38  fkFac = TMath::Power(k, k) / TMath::Factorial(k - 1);
39 
40  SetParName(0, "#eta");
41  SetParName(1, "#mu");
42  SetParName(2, "#sigma");
43  SetParName(3, "#mu-a_{m}");
44  SetParName(4, "b_{m}");
45 
46  SetParLimits(0, 0., 1.);
47  SetParLimits(1, GetXmin(), GetXmax());
48  SetParLimits(2, 0.01, 200.);
49  SetParLimits(3, 0.01, 300.);
50  SetParLimits(4, 0.01, 200.);
51 
53  SetNpx(2000);
54 }
55 
56 
57 
58 
65 
67 {
68  // Copy constructor
69  // This ctor is used to make a copy of an existing object (for example
70  // when a method returns an object), and it is always a good idea to
71  // implement it.
72  // If your class allocates memory in its constructor(s) then it is ESSENTIAL :-)
73 
74  obj.Copy(*this);
75 }
76 
77 
78 
81 
83 {
84  // Destructor
85  SafeDelete(fFirstGumbel);
86  SafeDelete(fLastGumbel);
87 }
88 
89 
90 
91 
99 
101 {
102  // This method copies the current state of 'this' object into 'obj'
103  // You should add here any member variables, for example:
104  // (supposing a member variable KVGumGumDistribution::fToto)
105  // CastedObj.fToto = fToto;
106  // or
107  // CastedObj.SetToto( GetToto() );
108 
109  TF1::Copy(obj);
110  KVGumGumDistribution& CastedObj = (KVGumGumDistribution&)obj;
111  CastedObj.fRank = fRank;
112  CastedObj.fkFac = fkFac;
113 }
114 
115 
116 
117 
120 
122 {
123  // Draw total distribution and the two component distributions
124 
126 
127  if (!fLastGumbel) fLastGumbel = new KVGumbelDistribution("GumbelLast", fRank, false, GetXmin(), GetXmax());
128  if (!fFirstGumbel) fFirstGumbel = new KVGumbelDistribution("GumbelFirst", fRank, false, GetXmin(), GetXmax());
129  fLastGumbel->SetParameters(GetParameter(1), -GetParameter(2), -fkFac * GetParameter(0));
130  fFirstGumbel->SetParameters(GetParameter(1) - GetParameter(3), GetParameter(4), fkFac * (1. - GetParameter(0)));
131 
132  fLastGumbel->SetLineColor(kBlue);
133  fLastGumbel->SetLineStyle(9);
134  fLastGumbel->SetLineWidth(1);
135  fLastGumbel->SetNpx(2000);
136 
137  fFirstGumbel->SetLineColor(kRed);
138  fFirstGumbel->SetLineWidth(1);
139  fFirstGumbel->SetNpx(2000);
140 
141  fLastGumbel->Paint(option);
142  fFirstGumbel->Paint(option);
143 }
144 
145 
146 
147 
148 
158 
160 {
161  // Evaluate normalised sum of Gaussian and Gumbel distribution of rank fRank for x
162  // with parameters
163  // par[0] = eta
164  // par[1] = mu
165  // par[2] = sigma
166  // par[3] = distance between gaussian and gumbel >=0
167  // par[4] = b
168 
169 // if(p[4]==0) return 0;
170 
171  Double_t am = p[1] - p[3];
172  Double_t s = (*x - am) / p[4];
173  Double_t gum = (fkFac / p[4]);
174  Double_t es = -fRank * (s + TMath::Exp(-s));
175  gum *= TMath::Exp(es);
176 
177  Double_t am2 = p[1];
178  Double_t bm2 = -p[2];
179  Double_t s2 = (*x - am2) / bm2;
180  Double_t gum2 = -(fkFac / bm2);
181  Double_t es2 = -fRank * (s2 + TMath::Exp(-s2));
182  gum2 *= TMath::Exp(es2);
183 
184  Double_t gg = p[0] * gum2 + (1. - p[0]) * gum;
185  return gg;
186 }
187 
188 
int Int_t
#define SafeDelete(p)
char Char_t
double Double_t
const char Option_t
kRed
kBlack
kBlue
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t SetLineColor
char name[80]
float xmin
float xmax
Sum of normalised Gumbel first asymptote and Gumbel last asymptote.
void Paint(Option_t *option="") override
Draw total distribution and the two component distributions.
Double_t GDk(Double_t *x, Double_t *p)
void Copy(TObject &) const override
KVGumGumDistribution()
Default constructor.
virtual ~KVGumGumDistribution()
Destructor.
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 SetNpx(Int_t npx=100)
void Copy(TObject &f1) const override
void Paint(Option_t *option="") override
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
Double_t x[n]
Double_t Factorial(Int_t i)
Double_t Exp(Double_t x)
Double_t Power(Double_t x, Double_t y)
ClassImp(TPyArg)