]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/SPECTRA/Nuclei/B2/B2.h
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / Nuclei / B2 / B2.h
1 #ifndef B2_H
2 #define B2_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6
7 // some common functions
8 // author: Eulogio Serradilla <eulogio.serradilla@cern.ch>
9
10 #if !defined(__CINT__) || defined(__MAKECINT__)
11 #include <TFile.h>
12 #include <TList.h>
13 #include <TString.h>
14 #include <TH1D.h>
15 #include <TF1.h>
16 #include <cstdlib>
17 #endif
18
19 template <class T>
20 inline T* FindObj(TFile* f, const TString& name)
21 {
22 //
23 // check if the object exists
24 //
25         T* obj = dynamic_cast<T*>(f->Get(name.Data()));
26         if(obj == 0)
27         {
28                 f->Error("Get","%s not found", name.Data());
29                 exit(1);
30         }
31         
32         return obj;
33 }
34
35 template <class T>
36 inline T* FindObj(TFile* f, const TString& dir, const TString& name)
37 {
38 //
39 // check if the object exists
40 //
41         if(dir=="") return FindObj<T>(f,name);
42         return FindObj<T>(f, dir + "/" + name + ";1");
43 }
44
45 template <class T>
46 inline T* FindObj(const TList* l, const TString& name)
47 {
48 //
49 // check if the object exists
50 //
51         T* obj = dynamic_cast<T*>(l->FindObject(name.Data()));
52         
53         if(obj == 0)
54         {
55                 l->Error("FindObject","%s not found", name.Data());
56                 exit(1);
57         }
58         
59         return obj;
60 }
61
62 inline TH1D* Divide(const TH1* hX, const TH1* hY, const TString& name)
63 {
64 //
65 // clone and divide
66 //
67         TH1D* q = dynamic_cast<TH1D*>(hX->Clone(name.Data()));
68         
69         if(q == 0)
70         {
71                 hX->Warning("Clone", "could not clone %s", hX->GetName());
72                 return q;
73         }
74         
75         q->Sumw2();
76         q->Divide(hY);
77         
78         return q;
79 }
80
81 inline Double_t GetMass(const TString& name)
82 {
83 //
84 // return particle mass
85 //
86         TString particle=name;
87         particle.ToLower();
88         
89         if(particle.Contains("electron")) return 0.000511;
90         if(particle.Contains("muon")) return 0.10566;
91         if(particle.Contains("pion")) return 0.13957;
92         if(particle.Contains("kaon")) return 0.49368;
93         if(particle.Contains("proton")) return 0.93827;
94         if(particle.Contains("deuteron")) return 1.87561;
95         if(particle.Contains("triton")) return 2.80925;
96         if(particle.Contains("he3")) return 2.80923;
97         if(particle.Contains("alpha")) return 3.727417;
98         
99         //cerr << "Warning unknown particle " << particle << endl;
100         
101         return 0;
102 }
103
104 inline TF1* Tsallis(Double_t m0, const TString& name, Double_t xmin=0, Double_t xmax=10)
105 {
106 //
107 // Tsallis distribution
108 // Journal of Statistical Physics, Vol. 52, Nos. 1/2, 1988
109 // J. Phys. G: Nucl. Part. Phys. 39 (2012)
110 //
111         TF1* fnc = new TF1(name.Data(), Form("[0]*sqrt(x*x+%f)*pow(1+([1]-1)*sqrt(x*x+%f)/[2],[1]/(1-[1]))/pow(2*TMath::Pi(),3)",m0*m0,m0*m0),xmin,xmax);
112         
113         fnc->SetParNames("gV","q","T");
114         fnc->SetParameters(100., 1.1, 0.07);
115         
116         fnc->SetParLimits(0, 0., 1.e+7);
117         fnc->SetParLimits(1, 1.0001, 3.);
118         fnc->SetParLimits(2, 0.001, 0.3);
119         
120         return fnc;
121 }
122
123 inline TF1* TsallisDYield(Double_t m0, const TString& name, Double_t xmin=0, Double_t xmax=10)
124 {
125 //
126 // Tsallis distribution for differential yield
127 //
128         TF1* fnc = new TF1(name.Data(), Form("[0]*x*sqrt(x*x+%f)*pow(1+([1]-1)*sqrt(x*x+%f)/[2],[1]/(1-[1]))/pow(2.*TMath::Pi(),2)",m0*m0,m0*m0),xmin,xmax);
129         
130         fnc->SetParNames("gV","q","T");
131         fnc->SetParameters(100., 1.1, 0.07);
132         
133         fnc->SetParLimits(0, 0., 1.e+7);
134         fnc->SetParLimits(1, 1.0001, 3.);
135         fnc->SetParLimits(2, 0.001, 0.3);
136         
137         return fnc;
138 }
139
140 inline TF1* PtTsallisDYield(Double_t m0, const TString& name, Double_t xmin=0, Double_t xmax=10)
141 {
142 //
143 // Tsallis distribution for mean pt
144 //
145         TF1* fnc = new TF1(name.Data(), Form("[0]*x*x*sqrt(x*x+%f)*pow(1+([1]-1)*sqrt(x*x+%f)/[2],[1]/(1-[1]))/pow(2.*TMath::Pi(),2)",m0*m0,m0*m0),xmin,xmax);
146         
147         fnc->SetParNames("gV","q","T");
148         fnc->SetParameters(100., 1.1, 0.07);
149         
150         fnc->SetParLimits(0, 0., 1.e+7);
151         fnc->SetParLimits(1, 1.0001, 3.);
152         fnc->SetParLimits(2, 0.001, 0.3);
153         
154         return fnc;
155 }
156
157 inline TF1* QTsallis(Double_t m0, const TString& name, Double_t xmin=0, Double_t xmax=10)
158 {
159 //
160 // q-Tsallis distribution
161 // Phys. Rev. C 83, 064903 (2011)
162 // Phys. Rev. C 75, 064901 (2007)
163 //
164         TF1* fnc = new TF1(name.Data(), Form("[0]*([1]-1)*([1]-2)*pow(1+(sqrt(x*x+%f)-%f)/([1]*[2]),-[1])/(2*TMath::Pi()*[1]*[2]*([1]*[2]+%f*([1]-2)))", m0*m0, m0, m0), xmin, xmax);
165         
166         fnc->SetParNames("dN/dy","n","C");
167         fnc->SetParameters(0.05, 7, 0.3);
168         
169         fnc->SetParLimits(0, 0, 10);
170         fnc->SetParLimits(1, 4, 50);
171         fnc->SetParLimits(2, 0.01, 10);
172         
173         return fnc;
174 }
175
176 inline TF1* QTsallisDYield(Double_t m0, const TString& name, Double_t xmin=0, Double_t xmax=10)
177 {
178 //
179 // q-Tsallis distribution for differential yield
180 //
181         TF1* fnc = new TF1(name.Data(), Form("x*[0]*([1]-1)*([1]-2)*pow(1+(sqrt(x*x+%f)-%f)/([1]*[2]),-[1])/([1]*[2]*([1]*[2]+%f*([1]-2)))", m0*m0, m0, m0), xmin, xmax);
182         
183         fnc->SetParNames("dN/dy","n","C");
184         fnc->SetParameters(0.05, 7, 0.3);
185         
186         fnc->SetParLimits(0, 0, 1);
187         fnc->SetParLimits(1, 4, 50);
188         fnc->SetParLimits(2, 0.01, 10);
189         
190         return fnc;
191 }
192
193 inline TF1* PtQTsallisDYield(Double_t m0, const TString& name, Double_t xmin=0, Double_t xmax=10)
194 {
195 //
196 // q-Tsallis distribution for mean pt
197 //
198         TF1* fnc = new TF1(name.Data(), Form("x*x*[0]*([1]-1)*([1]-2)*pow(1+(sqrt(x*x+%f)-%f)/([1]*[2]),-[1])/([1]*[2]*([1]*[2]+%f*([1]-2)))", m0*m0, m0, m0), xmin, xmax);
199         
200         fnc->SetParNames("dN/dy","n","C");
201         fnc->SetParameters(0.05, 7, 0.3);
202         
203         fnc->SetParLimits(0, 0, 1);
204         fnc->SetParLimits(1, 4, 50);
205         fnc->SetParLimits(2, 0.01, 10);
206         
207         return fnc;
208 }
209
210 #endif // B2_H