KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVedaLossInverseRangeFunction.cpp
Go to the documentation of this file.
1 //Created by KVClassFactory on Tue Jan 26 14:52:11 2016
2 //Author: John Frankland,,,
3 
5 #include "TF1.h"
6 #include "TMath.h"
7 
8 #define LOG(x) TMath::Log(x)
9 #define EXP(x) TMath::Exp(x)
10 
12 
13 
14 
28  Int_t A,
29  Double_t riso,
30  Int_t ninter)
31 {
32  // Initialise from VEDALOSS range function object
33  //
34  // \param A is mass of ion used in call to KVedaLossMaterial::GetRangeFunction
35  // \param riso is value corresponding to previous call to KVedaLossMaterial::GetRangeFunction
36  // \param ninter number of points in graph used for interpolation
37  //
38  // We make a graph from 0.01 MeV/nucleon to EMAX.
39  //
40  // We divide the calculated range by the current value of riso,
41  // thereby effectively ensuring that we always calculate range
42  // values corresponding to riso=1
43 
44  Double_t emin, emax, estep;
45  range_func->GetRange(emin, emax);
46 
47  TGraph e_vs_range;
48  emin = 0.01;
49  emax /= A;
50 
51  Double_t logriso = LOG(riso);
52 
53  estep = (LOG(emax) - LOG(emin)) / (ninter - 1.);
54 
55  for (int i = 0; i < ninter; ++i) {
56  double loge = LOG(emin) + i * estep;
57  // we divide the calculated range by the current value of riso,
58  // thereby effectively ensuring that we always calculate range
59  // values corresponding to riso=1
60  double R = LOG(range_func->Eval(EXP(loge) * A)) - logriso;
61  e_vs_range.SetPoint(i, R, loge);
62  }
63 
64 #ifdef USING_ROOT5
65  fInterpol = new TSpline3(range_func->GetTitle(), &e_vs_range);
66 #else
67  fInterpol.reset(new TSpline3(range_func->GetTitle(), &e_vs_range));
68 #endif
69 }
70 
71 
72 
77 
79 {
80  // \param range of ion in \f$g/cm^2\f$
81  // \param riso takes into account any change in ion mass and/or material mass
82  // \returns corresponding energy in MeV/nucleon
83 
84  if (range <= 0) return 0;
85  return EXP(fInterpol->Eval(LOG(range) - LOG(riso)));
86 }
87 
88 
int Int_t
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
#define EXP(x)
#define LOG(x)
double Double_t
Dedicated optimised inversion of range-energy function for KVedaLoss.
std::unique_ptr< TSpline3 > fInterpol
interpolation of inverse range-energy curve
Double_t GetEnergyPerNucleon(Double_t range, Double_t riso)
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
constexpr Double_t R()