KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVImpactParameter.cpp
Go to the documentation of this file.
1 //Created by KVClassFactory on Fri Jan 15 18:14:06 2010
2 //Author: John Frankland,,,
3 
4 #include "KVImpactParameter.h"
5 
7 
8 
9 
10 
11 
22 {
23  // Default constructor
24  //
25  // Argument 'data' is pointer to data histogram containing distribution of the observable
26  // which is used to calculate the impact parameter. Usually, this will be an observable
27  // which is supposed to increase or decrease monotonically as a function of b.
28  //
29  // By default, evol = "D" which means observable increases as b decreases.
30  // Call with evol = "C" if the observable increases as b increases.
31  fData = data;
32  fEvol = evol;
33  fIPScale = 0;
34  fObsTransform = 0;
35  Bmax = 1.0;
36 }
37 
38 
39 
42 
44 {
45  // Destructor
48 }
49 
50 
51 
58 
72 
74 {
75  // Calculate the relationship between the impact parameter and the observable
76  // whose distribution is contained in the histogram fData.
77  //
78  // For a given value X of the observable x, the reduced impact parameter
79  // b_hat is calculated from the distribution of x, Y(x), using the following formula:
80  /*
81  BEGIN_LATEX
82  \hat{b}^{2} = \frac{\int^{\infty}_{x=X} Y(x) dx}{\int_{0}^{\infty} Y(x) dx}
83  END_LATEX
84  */
85  // npoints = number of points for which to calculate the impact parameter.
86  //
87  // The greater the number of points, the more accurate the results.
88  // Default value is 100. Maximum value is number of bins in histogram of observable, fData.
89  //
90  // bmax is the maximum reduced impact parameter for the data.
91  //
92  // To obtain absolute values of impact parameter/cross-section,
93  // use MakeAbsoluteScale.
94 
95  if (bmax > 1.0) {
96  Warning("MakeScale", "called with bmax>1.0 - calling MakeAbsoluteScale for absolute impact parameters");
97  MakeAbsoluteScale(npoints, bmax);
98  return;
99  }
100  Bmax = bmax;
101  Smax = pow(bmax, 2.); //total reduced X-section
102  make_scale(npoints);
103 }
104 
105 
106 
108 
110 {
111  TH1* cumul = HM.CumulatedHisto(fData, fEvol.Data(), -1, -1, "max");
112  Int_t nbins = cumul->GetNbinsX();
113  Int_t first_bin = 1;
114  Int_t last_bin = nbins;
115  npoints = TMath::Min(nbins, npoints);
116  fIPScale = new TGraph(npoints);
117  fXSecScale = new TGraph(npoints);
118  Double_t delta_bin = 1.*(last_bin - first_bin) / (npoints - 1.);
119  Int_t bin;
120  for (int i = 0; i < npoints; i++) {
121  bin = first_bin + i * delta_bin;
122  Double_t et12 = cumul->GetBinCenter(bin);
123  Double_t b = Bmax * sqrt(cumul->GetBinContent(bin));
124  Double_t sigma = Smax * cumul->GetBinContent(bin);
125  fIPScale->SetPoint(i, et12, b);
126  fXSecScale->SetPoint(i, et12, sigma);
127  }
128  delete cumul;
129 
130  fObsTransform = new TF1("fObsTransform", this, &KVImpactParameter::BTransform,
131  fData->GetXaxis()->GetXmin(), fData->GetXaxis()->GetXmax(), 0, "KVImpactParameter", "BTransform");
132  fObsTransformXSec = new TF1("fObsTransformXSec", this, &KVImpactParameter::XTransform,
133  fData->GetXaxis()->GetXmin(), fData->GetXaxis()->GetXmax(), 0, "KVImpactParameter", "XTransform");
134 }
135 
136 
137 
144 
157 
159 {
160  // Calculate the relationship between the impact parameter and the observable
161  // whose distribution is contained in the histogram fData.
162  //
163  // For a given value X of the observable x, the reduced impact parameter
164  // b_hat is calculated from the distribution of x, Y(x), using the following formula:
165  /*
166  BEGIN_LATEX
167  \hat{b}^{2} = \frac{\int^{\infty}_{x=X} Y(x) dx}{\int_{0}^{\infty} Y(x) dx}
168  END_LATEX
169  */
170  // npoints = number of points for which to calculate the impact parameter.
171  //
172  // The greater the number of points, the more accurate the results.
173  // Default value is 100. Maximum value is number of bins in histogram of observable, fData.
174  //
175  // bmax is the maximum absolute impact parameter for the data in [fm].
176  //
177  // To obtain values of reduced impact parameter/cross-section, use MakeScale.
178 
179  Bmax = bmax;
180  Smax = GetXSecFromIP(bmax); //total X-section in [mb]
181  make_scale(npoints);
182 }
183 
184 
185 
192 
194 {
195  // Function using the TGraph calculated with MakeScale/MakeAbsoluteScale in order to
196  // transform distributions of the observable histogrammed in fData
197  // into distributions of the impact parameter.
198  //
199  // This function is used to generate the TF1 fObsTransform
200 
201  return fIPScale->Eval(*x);
202 }
203 
204 
205 
212 
214 {
215  // Function using the TGraph calculated with MakeScale/MakeAbsoluteScale in order to
216  // transform distributions of the observable histogrammed in fData
217  // into distributions of cross-section.
218  //
219  // This function is used to generate the TF1 fObsTransformXsec
220 
221  return fXSecScale->Eval(*x);
222 }
223 
224 
225 
235 
237 {
238  // Transform the distribution of the observable contained in the histogram 'obs'
239  // into a distribution of the impact parameter.
240  // User's responsibility to delete histo.
241  //
242  // * nbinx = number of bins in I.P. histo (default = 100)
243  // * norm = "" (default) : no adjustment is made for the change in bin width due to the transformation
244  // * norm = "width" : bin contents are adjusted for width change, so that the integral of the histogram
245  // contents taking into account the bin width (i.e. TH1::Integral("width")) is the same.
246 
247  if (!fObsTransform) {
248  Error("GetIPDistribution", "Call MakeScale first to calculate correspondance observable<->i.p.");
249  return 0;
250  }
251  return HM.ScaleHisto(obs, fObsTransform, 0, nbinx, -1, 0., Bmax, -1, -1, norm);
252 }
253 
254 
255 
266 
268 {
269  // obscor = pointer to histogram containing bidim correlating some observable Y with
270  // the observable used to calculate the impact parameter.
271  //
272  // Return pointer to TGraph giving evolution of any given moment of Y as a function
273  // of the impact parameter, with moment = "GetMean", "GetRMS", "GetKurtosis", etc.
274  // (methods of TH1)
275  //
276  // If the impact parameter observable is on the Y-axis of obscor, use axis="X"
277  // (by default axis="Y", i.e. we assume that the I.P. observable is on the x axis).
278 
279  if (!fObsTransform) {
280  Error("GetIPEvolution", "Call MakeScale first to calculate correspondance observable<->i.p.");
281  return 0;
282  }
283  TGraphErrors* gre = HM.GetMomentEvolution(obscor, moment, "", axis);
284  TGraph* gr = HM.ScaleGraph(gre, fObsTransform, 0);
285  delete gre;
286  return gr;
287 }
288 
289 
290 
291 
301 
303 {
304  // Transform the distribution of the observable contained in the histogram 'obs'
305  // into a distribution of cross-section
306  // User's responsibility to delete histo.
307  //
308  // * nbinx = number of bins in I.P. histo (default = 100)
309  // * norm = "" (default) : no adjustment is made for the change in bin width due to the transformation
310  // * norm = "width" : bin contents are adjusted for width change, so that the integral of the histogram
311  // contents taking into account the bin width (i.e. TH1::Integral("width")) is the same.
312 
313  if (!fObsTransformXSec) {
314  Error("GetXSecDistribution", "Call MakeScale first to calculate correspondance observable<->i.p.");
315  return 0;
316  }
317  return HM.ScaleHisto(obs, fObsTransformXSec, 0, nbinx, -1, 0., Smax, -1, -1, norm);
318 }
319 
320 
321 
332 
334 {
335  // obscor = pointer to histogram containing bidim correlating some observable Y with
336  // the observable used to calculate the impact parameter.
337  //
338  // Return pointer to TGraph giving evolution of any given moment of Y as a function
339  // of cross section, with moment = "GetMean", "GetRMS", "GetKurtosis", etc.
340  // (methods of TH1)
341  //
342  // If the impact parameter observable is on the Y-axis of obscor, use axis="X"
343  // (by default axis="Y", i.e. we assume that the I.P. observable is on the x axis).
344 
345  if (!fObsTransformXSec) {
346  Error("GetXSecEvolution", "Call MakeScale first to calculate correspondance observable<->i.p.");
347  return 0;
348  }
349  TGraphErrors* gre = HM.GetMomentEvolution(obscor, moment, "", axis);
351  delete gre;
352  return gr;
353 }
354 
355 
356 
380 
381 std::vector<Double_t> KVImpactParameter::SliceXSec(Int_t nslices, Double_t totXsec)
382 {
383  // Generate vector of observable values which can be used to select nslices
384  // of constant cross-section. Each slice will correspond to a cross-section
385  // totXsec/nslices.
386  // Note that the vector will contain (nslices-1) values
387  //
388  //~~~~~~~~~~~~{.cpp}
389  // KVImpactParameter ip(data); // histo containing observable distribution
390  // ip.MakeAbsoluteScale(100,ip.GetIPFromXSec(data->Integral()))
391  // std::vector<Double_t> slices = ip.SliceXSec(5, Xsec);
392  // if(obs > slices[0]){
393  // // most central events (observable increases when b decreases)
394  // // with cross-section Xsec/5
395  // } else if(obs > slices[1]){
396  // // next most central events, cross-section=Xsec/5
397  // }
398  // ...
399  // } else if(obs > slices[3]){
400  // // next-to-most-peripheral events
401  // } else {
402  // // most peripheral events (obs < slices[3])
403  // }
404  //~~~~~~~~~~~~
405 
406  Double_t xsecSlice = totXsec / double(nslices);
407  std::vector<Double_t> slices(nslices - 1);
408  for (int i = 0; i < nslices - 1; ++i) {
409  slices[i] = GetObservableXSec((i + 1) * xsecSlice);
410  }
411  return slices;
412 }
413 
414 
415 
int Int_t
double
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
#define SafeDelete(p)
#define b(i)
double Double_t
const char Option_t
double pow(double, double)
TGraph * ScaleGraph(TGraph *hh, TF1 *fx, TF1 *fy)
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 analysis tools.
TH1 * fData
histogram containing distribution of ip-related observable
static Double_t GetXSecFromIP(Double_t bmax)
Double_t XTransform(Double_t *, Double_t *)
Double_t BTransform(Double_t *, Double_t *)
TString fEvol
how the observable evolves with b
Double_t Smax
maximum of cross-section scale
std::vector< Double_t > SliceXSec(Int_t nslices, Double_t totXsec)
TF1 * fObsTransformXSec
function for transforming observable into cross-section
TGraph * GetIPEvolution(TH2 *obscor, TString moment, TString axis="Y")
TF1 * fObsTransform
function for transforming observable into impact parameter
void make_scale(Int_t npoints)
void MakeAbsoluteScale(Int_t npoints=100, Double_t bmax=1.0)
TH1 * GetIPDistribution(TH1 *obs, Int_t nbinx=100, Option_t *norm="")
Double_t Bmax
maximum of ip scale
TGraph * fIPScale
derived relation between observable and impact-parameter
Double_t GetObservableXSec(Double_t sigma)
KVHistoManipulator HM
TGraph * fXSecScale
derived relation between observable and cross-section
TGraph * GetXSecEvolution(TH2 *obscor, TString moment, TString axis="Y")
void MakeScale(Int_t npoints=100, Double_t bmax=1.0)
TH1 * GetXSecDistribution(TH1 *obs, Int_t nbinx=100, Option_t *norm="")
virtual ~KVImpactParameter()
Destructor.
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
virtual Double_t GetBinCenter(Int_t bin) const
TAxis * GetXaxis()
virtual Int_t GetNbinsX() const
virtual Double_t GetBinContent(Int_t bin) const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
const char * Data() const
VecExpr< UnaryOp< Sqrt< T >, SVector< T, D >, T >, T, D > sqrt(const SVector< T, D > &rhs)
const Double_t sigma
Double_t x[n]
TGraphErrors * gr
Double_t Min(Double_t a, Double_t b)