KaliVeda
Toolkit for HIC analysis
cavata_prescription.cpp
1 //Created by KVClassFactory on Fri Jan 15 18:14:06 2010
2 //Author: John Frankland,,,
3 
4 #include "cavata_prescription.h"
5 
7 
8 
9 
11 namespace KVImpactParameters {
13  {
14  fData = h;
15  fEvol = evol;
16  fIPScale = nullptr;
17  fObsTransform = nullptr;
18  Bmax = 1.0;
19  }
20 
21 
22 
25 
27  {
28  // Destructor
32  }
33 
34 
35 
52 
54  {
55  // Calculate the relationship between the impact parameter and the observable
56  // whose distribution is contained in the histogram given to the constructor.
57  //
58  // \param[in] npoints number of points to use to calculate scale (points in generated TGraph).
59  // The greater the number of points, the more accurate the results.
60  // Default value is 100. Maximum value is number of bins in histogram of observable, fData.
61  // \param[in] bmax the maximum reduced impact parameter for the data
62  //
63  // For a given value \f$X\f$ of the observable \f$x\f$, the reduced impact parameter
64  // \f$\hat{b}\f$ is calculated from the distribution of \f$x\f$, \f$Y(x)\f$, using the following formula:
65  //\f[
66  //\hat{b}^{2} = \frac{\int^{\infty}_{x=X} Y(x) dx}{\int_{0}^{\infty} Y(x) dx}
67  //\f]
68  //
69  // \remark To obtain absolute values of impact parameter/cross-section use MakeAbsoluteScale().
70 
71  if (bmax > 1.0) {
72  Warning("MakeScale", "called with bmax>1.0 - calling MakeAbsoluteScale for absolute impact parameters");
73  MakeAbsoluteScale(npoints, bmax);
74  return;
75  }
76  Bmax = bmax;
77  Smax = pow(bmax, 2.); //total reduced X-section
78  make_scale(npoints);
79  }
80 
81 
82 
84 
86  {
87  std::unique_ptr<TH1> cumul(HM.CumulatedHisto(fData, fEvol.Data(), -1, -1, "max"));
88  Int_t nbins = cumul->GetNbinsX();
89  Int_t first_bin = 1;
90  Int_t last_bin = nbins;
91  npoints = TMath::Min(nbins, npoints);
92  fIPScale = new TGraph(npoints);
93  fXSecScale = new TGraph(npoints);
94  Double_t delta_bin = 1.*(last_bin - first_bin) / (npoints - 1.);
95  Int_t bin;
96  for (int i = 0; i < npoints; i++) {
97  bin = first_bin + i * delta_bin;
98  Double_t et12 = cumul->GetBinCenter(bin);
99  Double_t b = Bmax * sqrt(cumul->GetBinContent(bin));
100  Double_t sigma = Smax * cumul->GetBinContent(bin);
101  fIPScale->SetPoint(i, et12, b);
102  fXSecScale->SetPoint(i, et12, sigma);
103  }
104 
105  fObsTransform = new TF1("fObsTransform", this, &cavata_prescription::BTransform,
106  fData->GetXaxis()->GetXmin(), fData->GetXaxis()->GetXmax(), 0, "KVImpactParameter", "BTransform");
107  fObsTransformXSec = new TF1("fObsTransformXSec", this, &cavata_prescription::XTransform,
108  fData->GetXaxis()->GetXmin(), fData->GetXaxis()->GetXmax(), 0, "KVImpactParameter", "XTransform");
109  }
110 
111 
112 
129 
131  {
132  // Calculate the relationship between the impact parameter and the observable
133  // whose distribution is contained in the histogram given to the constructor.
134  //
135  // \param[in] npoints number of points to use to calculate scale (points in generated TGraph).
136  // The greater the number of points, the more accurate the results.
137  // Default value is 100. Maximum value is number of bins in histogram of observable, fData.
138  // \param[in] bmax the maximum absolute impact parameter for the data in [fm]
139  //
140  // For a given value \f$X\f$ of the observable \f$x\f$, the reduced impact parameter
141  // \f$\hat{b}\f$ is calculated from the distribution of \f$x\f$, \f$Y(x)\f$, using the following formula:
142  //\f[
143  //\hat{b}^{2} = \frac{\int^{\infty}_{x=X} Y(x) dx}{\int_{0}^{\infty} Y(x) dx}
144  //\f]
145  //
146  // \remark To obtain reduced values of impact parameter/cross-section use MakeScale().
147 
148  Bmax = bmax;
149  Smax = GetXSecFromIP(bmax); //total X-section in [mb]
150  make_scale(npoints);
151  }
152 
153 
154 
163 
165  {
166  // Function using the TGraph calculated with MakeScale() or MakeAbsoluteScale() in order to
167  // transform distributions of the observable histogrammed in fData
168  // into distributions of the impact parameter.
169  //
170  // This function is used to generate the TF1 fObsTransform
171  //
172  // \param[in] x[0] value of observable
173 
174  return fIPScale->Eval(*x);
175  }
176 
177 
178 
187 
189  {
190  // Function using the TGraph calculated with MakeScale() or MakeAbsoluteScale() in order to
191  // transform distributions of the observable histogrammed in fData
192  // into distributions of cross-section.
193  //
194  // This function is used to generate the TF1 fObsTransformXsec
195  //
196  // \param[in] x[0] value of observable
197 
198  return fXSecScale->Eval(*x);
199  }
200 
201 
202 
218 
220  {
221  // Transform the distribution of the observable contained in the histogram 'obs'
222  // into a distribution of the impact parameter.
223  //
224  // \param[in] obs pointer to histogram containing observable distribution for some selected events
225  // \param[in] nbinx number of bins in created impact parameter histo (default = 100)
226  // \param[in] norm
227  // \parblock
228  // - norm = "" (default)
229  // no adjustment is made for the change in bin width due to the transformation
230  // - norm = "width"
231  // bin contents are adjusted for width change, so that the integral of the histogram
232  // contents taking into account the bin width (i.e. TH1::Integral("width")) is the same.
233  // \endparblock
234  // \return pointer to histogram filled with impact parameter distribution
235 
236  if (!fObsTransform) {
237  Error("GetIPDistribution", "Call MakeScale first to calculate correspondance observable<->i.p.");
238  return 0;
239  }
240  return HM.ScaleHisto(obs, fObsTransform, 0, nbinx, -1, 0., Bmax, -1, -1, norm);
241  }
242 
243 
244 
258 
260  {
261  // Draw evolution of any observable as function of impact parameter
262  //
263  // \param[in] obscor pointer to histogram containing bidim correlating some observable on Y axis with
264  // the observable used to calculate the impact parameter on the X axis
265  // \param[in] moment give moment of Y to use for evolution ("GetMean", "GetRMS", "GetKurtosis", etc. methods of TH1)
266  // \param[in] axis
267  // \parblock
268  // - if the impact parameter observable is on the Y-axis of obscor, use axis="X"
269  // - by default axis="Y", i.e. we assume that the I.P. observable is on the X axis)
270  //\endparblock
271  // \return pointer to TGraph giving evolution of given moment of Y as a function
272  // of the impact parameter
273 
274  if (!fObsTransform) {
275  Error("GetIPEvolution", "Call MakeScale first to calculate correspondance observable<->i.p.");
276  return 0;
277  }
278  TGraphErrors* gre = HM.GetMomentEvolution(obscor, moment, "", axis);
279  TGraph* gr = HM.ScaleGraph(gre, fObsTransform, 0);
280  delete gre;
281  return gr;
282  }
283 
284 
285 
286 
302 
304  {
305  // Transform the distribution of the observable contained in the histogram obs
306  // into a distribution of cross-section
307  //
308  // \param[in] obs pointer to histogram containing observable distribution for some selected events
309  // \param[in] nbinx number of bins in created impact parameter histo (default = 100)
310  // \param[in] norm
311  // \parblock
312  // - norm = "" (default)
313  // no adjustment is made for the change in bin width due to the transformation
314  // - norm = "width"
315  // bin contents are adjusted for width change, so that the integral of the histogram
316  // contents taking into account the bin width (i.e. TH1::Integral("width")) is the same.
317  // \endparblock
318  // \return pointer to histogram filled with cross-section distribution
319 
320  if (!fObsTransformXSec) {
321  Error("GetXSecDistribution", "Call MakeScale first to calculate correspondance observable<->i.p.");
322  return 0;
323  }
324  return HM.ScaleHisto(obs, fObsTransformXSec, 0, nbinx, -1, 0., Smax, -1, -1, norm);
325  }
326 
327 
328 
342 
344  {
345  // Draw evolution of any observable as function of cross-section
346  //
347  // \param[in] obscor pointer to histogram containing bidim correlating some observable on Y axis with
348  // the observable used to calculate the impact parameter on the X axis
349  // \param[in] moment give moment of Y to use for evolution ("GetMean", "GetRMS", "GetKurtosis", etc. methods of TH1)
350  // \param[in] axis
351  // \parblock
352  // - if the impact parameter observable is on the Y-axis of obscor, use axis="X"
353  // - by default axis="Y", i.e. we assume that the I.P. observable is on the X axis)
354  //\endparblock
355  // \return pointer to TGraph giving evolution of given moment of Y as a function
356  // of cross-section
357 
358 
359  if (!fObsTransformXSec) {
360  Error("GetXSecEvolution", "Call MakeScale first to calculate correspondance observable<->i.p.");
361  return 0;
362  }
363  TGraphErrors* gre = HM.GetMomentEvolution(obscor, moment, "", axis);
365  delete gre;
366  return gr;
367  }
368 
369 
370 
399 
400  std::vector<Double_t> cavata_prescription::SliceXSec(Int_t nslices, Double_t totXsec)
401  {
402  // Generate vector of observable values which can be used to select nslices
403  // of constant cross-section.
404  //
405  // \note the vector will contain (nslices-1) values
406  //
407  // \param[in] nslices number of slices to generates
408  // \param[in] totXsec total cross-section to slice
409  // \returns vector containing (nslices-1) values of the observable to make cuts
410  //
411  // Example:
412  //~~~~~~~~~~~~{.cpp}
413  // KVImpactParameter ip(data); // histo containing observable distribution
414  // ip.MakeAbsoluteScale(100,ip.GetIPFromXSec(data->Integral()))
415  // std::vector<Double_t> slices = ip.SliceXSec(5, Xsec);
416  // if(obs > slices[0]){
417  // // most central events (observable increases when b decreases)
418  // // with cross-section Xsec/5
419  // } else if(obs > slices[1]){
420  // // next most central events, cross-section=Xsec/5
421  // }
422  // ...
423  // } else if(obs > slices[3]){
424  // // next-to-most-peripheral events
425  // } else {
426  // // most peripheral events (obs < slices[3])
427  // }
428  //~~~~~~~~~~~~
429 
430  Double_t xsecSlice = totXsec / double(nslices);
431  std::vector<Double_t> slices(nslices - 1);
432  for (int i = 0; i < nslices - 1; ++i) {
433  slices[i] = GetObservableXSec((i + 1) * xsecSlice);
434  }
435  return slices;
436  }
437 
438 
439 
446 
447  double cavata_prescription::GetMeanBForSCA(double bmin, double bmax) const
448  {
449  // Calculate the mean impact parameter for b in [bmin,bmax]
450  // in sharp cut-off approximation i.e. assuming a triangular distribution:
451  //\f[
452  //\bar{b} = \frac{2(b^3_{max}-b^3_{min})}{3(b^2_{max}-b^2_{min})}
453  //\f]
454 
455  return (2. / 3.) * (pow(bmax, 3) - pow(bmin, 3)) / (pow(bmax, 2) - pow(bmin, 2));
456  }
457 
458 
459 
466 
467  double cavata_prescription::GetSigmaBForSCA(double bmin, double bmax) const
468  {
469  // Calculate the standard deviation of impact parameter for b in [bmin,bmax]
470  // in sharp cut-off approximation i.e. assuming a triangular distribution:
471  //\f[
472  //\sigma^2_b = \frac{(b^4_{max}-b^4_{min})}{2(b^2_{max}-b^2_{min})} - \bar{b}^2
473  //\f]
474 
475  return sqrt(0.5 * (pow(bmax, 4) - pow(bmin, 4)) / (pow(bmax, 2) - pow(bmin, 2)) - pow(GetMeanBForSCA(bmin, bmax), 2));
476  }
477 
478 
479 }
480 
int Int_t
#define SafeDelete(p)
double Double_t
const char Option_t
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
TGraph * ScaleGraph(const TGraph *hh, TF1 *fx=nullptr, TF1 *fy=nullptr) const
TGraphErrors * GetMomentEvolution(TH2 *hh, TString momentx, TString momenty, TString axis="Y", Double_t stat_min=0)
TH1 * ScaleHisto(TH1 *hh, TF1 *fx, TF1 *fy=NULL, Int_t nx=-1, Int_t ny=-1, Double_t xmin=-1., Double_t xmax=-1., Double_t ymin=-1., Double_t ymax=-1., Option_t *norm="")
TH1 * CumulatedHisto(TH1 *hh, TString direction="C", Int_t bmin=-1, Int_t bmax=-1, Option_t *norm="surf")
Impact parameter estimation neglecting using sharp cut-off approximation.
Double_t BTransform(Double_t *, Double_t *)
double GetMeanBForSCA(double bmin, double bmax) const
TGraph * fXSecScale
derived relation between observable and cross-section
TGraph * GetIPEvolution(TH2 *obscor, TString moment, TString axis="Y")
TGraph * fIPScale
derived relation between observable and impact-parameter
std::vector< Double_t > SliceXSec(Int_t nslices, Double_t totXsec)
TF1 * fObsTransform
function for transforming observable into impact parameter
TGraph * GetXSecEvolution(TH2 *obscor, TString moment, TString axis="Y")
TF1 * fObsTransformXSec
function for transforming observable into cross-section
Double_t XTransform(Double_t *, Double_t *)
KVHistoManipulator HM
for scaling transormations of histograms, graphs, etc.
void MakeScale(Int_t npoints=100, Double_t bmax=1.0)
TH1 * fData
histogram containing distribution of ip-related observable
static Double_t GetXSecFromIP(Double_t bmax)
TString fEvol
how the observable evolves with b
Double_t Smax
maximum of cross-section scale
double GetSigmaBForSCA(double bmin, double bmax) const
TH1 * GetIPDistribution(TH1 *obs, Int_t nbinx=100, Option_t *norm="")
void MakeAbsoluteScale(Int_t npoints=100, Double_t bmax=1.0)
TH1 * GetXSecDistribution(TH1 *obs, Int_t nbinx=100, Option_t *norm="")
Double_t GetXmax() const
Double_t GetXmin() const
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
virtual Double_t Eval(Double_t x, TSpline *spline=nullptr, Option_t *option="") const
TAxis * GetXaxis()
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
const char * Data() const
Expr< UnaryOp< Sqrt< T >, SMatrix< T, D, D2, R >, T >, T, D, D2, R > sqrt(const SMatrix< T, D, D2, R > &rhs)
RVec< PromoteTypes< T0, T1 > > pow(const T0 &x, const RVec< T1 > &v)
const Double_t sigma
Double_t x[n]
TGraphErrors * gr
TH1 * h
Double_t Min(Double_t a, Double_t b)
ClassImp(TPyArg)