KaliVeda
Toolkit for HIC analysis
impact_parameter_distribution.cpp
1 //Created by KVClassFactory on Tue Jul 23 15:24:27 2019
2 //Author: John Frankland,,,
3 
4 #include "impact_parameter_distribution.h"
5 #include "TMath.h"
6 
7 #include <TH1.h>
8 
10 
11 namespace KVImpactParameters {
12 
20 
22 
24  {
25  if (par[0] == 0) return 0;
26 
27  if (par[2] == 0) {
28  //sharp cutoff
29  if (x[0] <= par[1]) return par[0] * x[0];
30  return 0;
31  }
32 
33  return par[0] * x[0] / (1. + TMath::Exp((x[0] - par[1]) / par[2]));
34  }
35 
36 
42 
44 
46  {
47  if (p[0] == 0) {
48  // sharp cut-off
49  return TMath::Pi() * TMath::Power(x[0], 2) * 10.;
50  }
51  return -10 * TMath::TwoPi() * TMath::Power(p[0], 2) *
52  TMath::DiLog(-TMath::Exp(x[0] / p[0]));
53  }
54 
55 
62 
64 
65  double ana_centrality(double* x, double* par)
66  {
67  double b = x[0];
68  if (b <= 0) return 0;
69  double b0 = par[0];
70  if (b0 <= 0) return 0;
71  double db = par[1];
72  if (db == 0) {
73  // sharp cut-off
74  if (b > b0) return 1;
75  return TMath::Power(b / b0, 2);
76  }
77  const double pi_sqr_over_6 = TMath::Power(TMath::Pi(), 2) / 6.;
78  double exp_b_minus_b0_over_db = TMath::Exp((b - b0) / db);
79  double db_sqr = db * db;
80  double sigma = sigma_inel(&b0, &db) / 10.; // in fm**2
81  double cb = -TMath::DiLog(-TMath::Exp(b0 / db)) - pi_sqr_over_6
82  + (b * b - b0 * b0) / 2. / db_sqr
83  - (b / db) * TMath::Log(1 + exp_b_minus_b0_over_db)
84  - TMath::DiLog(-exp_b_minus_b0_over_db);
85  cb *= TMath::TwoPi() * db_sqr / sigma;
86  return cb;
87  }
88 
89 
90 
94 
96  : fHisto(nullptr),
97  fIPdist("smooth_pb", smooth_pb, 0., 20., 3),
98  fSigmaR("sigmaR", sigma_inel, 0., 20., 1),
99  fCentrality("centrality", ana_centrality, 0., 20., 2)
100  {
101  // Initialize a default distribution which is triangular (sharp cut-off approximation) with
102  // \f$b_0=1\f$ and \f$\Delta b=0\f$.
103  fIPdist.SetParNames("Norm", "b_{0}", "#Delta b");
104  fSigmaR.SetParName(0, "#Delta b");
105  fCentrality.SetParNames("b_{0}", "#Delta b");
106  fIPdist.SetParameter(0, TMath::TwoPi() * 10.); // default normalisation for dsig/db in mb/fm
107  // sharp cut-off distribution from b=0 to b=1
108  SetB0(1.0);
109  SetDeltaB(0.0);
110  }
111 
112 
113 
117 
119  : fHisto(h),
120  fIPdist(Form("%s_smooth_pb", h->GetName()), smooth_pb, 0., 50., 3),
121  fSigmaR(Form("%s_sigmaR", h->GetName()), sigma_inel, 0., 50., 1),
122  fCentrality(Form("%s_centrality", h->GetName()), ana_centrality, 0., 20., 2)
123  {
124  // Fit \f$P(b)\f$ to the distribution in the histogram
125  // \param[in] h histogram containing impact parameter distribution
126 
127  fIPdist.SetParNames("Norm", "b_{0}", "#Delta b");
128  fSigmaR.SetParName(0, "#Delta b");
129  fCentrality.SetParNames("b_{0}", "#Delta b");
130  FitIPDist(h);
131  }
132 
133 
134 
138 
140  {
141  // Fit impact parameter distribution given in histogram.
142  // \param[in] h histogram containing impact parameter distribution
143 
144  fHisto = h;
145  Double_t minb = h->GetXaxis()->GetBinLowEdge(1);
146  Double_t maxb = h->GetXaxis()->GetBinUpEdge(h->GetXaxis()->GetNbins());
147  Double_t maxy = h->GetMaximum();
148  Double_t bmax = h->GetBinCenter(h->GetMaximumBin());
149  fIPdist.SetParLimits(0, 1., maxy);
150  fIPdist.SetParLimits(1, minb, maxb);
151  fIPdist.SetParLimits(2, 1.e-6, maxb - minb);
152  fIPdist.SetParameters(maxy / 10., bmax, 0.4);
153  h->Fit(&fIPdist, "I");
157  }
158 
159 
160 
164 
166  {
167  // \returns Total reaction cross-section \f$\sigma_R\f$ in [mb] using
168  // current values of \f$b_0\f$ and \f$\Delta b\f$.
169 
170  return fSigmaR.Eval(GetB0());
171  }
172 
173 
174 
178 
180  {
181  // \returns Cross-section per event in [mb] for last fitted histogram. This is the total reaction
182  // cross-section calculated using GetCrossSection() divided by the number of entries in the histogram.
183 
184  return fHisto->GetEntries() ? GetCrossSection() / fHisto->GetEntries() : 0.;
185  }
186 
187 
188 
194 
196  {
197  // Changes \f$\Delta b\f$ and \f$b_0\f$ for a given total cross-section.
198  // \param[in] deltab new value of \f$\Delta b\f$
199  // \param[in] sigmaR required total cross-section \f$\sigma_R\f$. If sigmaR=0 (default),
200  //keep current total cross section
201 
202  Double_t sigma = sigmaR > 0 ? sigmaR : const_cast<impact_parameter_distribution*>(this)->GetCrossSection();
203  SetDeltaB(deltab);
204  Double_t b0 = fSigmaR.GetX(sigma);
205  SetB0(b0);
206  }
207 
208 
209 
213 
215  {
216  // \returns value of impact parameter \f$b\f$ for given value of centrality \f$c_b\f$ using current parameters
217  // \param[in] centrality value of \f$c_b\f$
218 
219  return fCentrality.GetX(centrality);
220  }
221 
222 
223 
227 
229  {
230  // Call this method to use the (model-dependent) histogram containing the impact parameter distribution to compute the centrality
231  //\return the actual centrality histogram from the histogram containing impact parameter distribution (if set)
232 
233  TH1 *centb_histo = nullptr;
234 
235  if(fHisto && fHisto->Integral()>0){
236  TH1 *histo_clone = (TH1*) fHisto->Clone();
237  histo_clone->Scale(1./histo_clone->Integral());
238  centb_histo = histo_clone->GetCumulative(kTRUE);
239  }
240  else Warning("GetCentralityFromHisto", "histogram containing impact parameter distribution is EMPTY");
241 
242  return centb_histo;
243  }
244 
245 }
246 
double Double_t
constexpr Bool_t kTRUE
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t b
char * Form(const char *fmt,...)
Class implementing parametrizable impact parameter distributions.
TF1 fCentrality
centrality as function of impact parameter
void SetDeltaB_WithConstantCrossSection(Double_t deltab, Double_t sigmaR=0)
virtual Double_t GetBinLowEdge(Int_t bin) const
Int_t GetNbins() const
virtual Double_t GetBinUpEdge(Int_t bin) const
virtual void SetParLimits(Int_t ipar, Double_t parmin, Double_t parmax)
virtual Double_t GetX(Double_t y, Double_t xmin=0, Double_t xmax=0, Double_t epsilon=1.E-10, Int_t maxiter=100, Bool_t logx=false) const
virtual void SetParName(Int_t ipar, const char *name)
virtual void SetParameters(const Double_t *params)
virtual void SetParNames(const char *name0="p0", const char *name1="p1", const char *name2="p2", const char *name3="p3", const char *name4="p4", const char *name5="p5", const char *name6="p6", const char *name7="p7", const char *name8="p8", const char *name9="p9", const char *name10="p10")
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
virtual void SetParameter(const TString &name, Double_t value)
virtual Double_t GetBinCenter(Int_t bin) const
TAxis * GetXaxis()
TH1 * GetCumulative(Bool_t forward=kTRUE, const char *suffix="_cumulative") const
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
virtual Double_t GetEntries() const
virtual Double_t Integral(Int_t binx1, Int_t binx2, Option_t *option="") const
virtual Int_t GetMaximumBin() const
virtual void Scale(Double_t c1=1, Option_t *option="")
TObject * Clone(const char *newname="") const override
virtual void Warning(const char *method, const char *msgfmt,...) const
const Double_t sigma
Double_t x[n]
TH1 * h
Double_t sigma_inel(Double_t *x, Double_t *p)
double ana_centrality(double *x, double *par)
Double_t smooth_pb(Double_t *x, Double_t *par)
Double_t DiLog(Double_t x)
Double_t Exp(Double_t x)
Double_t Power(Double_t x, Double_t y)
Double_t Log(Double_t x)
constexpr Double_t Pi()
constexpr Double_t TwoPi()
ClassImp(TPyArg)