KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVRecombination.cpp
1//Created by KVClassFactory on Wed Aug 28 11:48:51 2013
2//Author: Guilain ADEMARD
3
4#include "KVRecombination.h"
5
7
8
9
10
20
22{
23 //Returns Parlog PHD for given E, Z and A:
24 //
25 // PHD(E) = 1/2 * Ed *( 1-1/X * ln|1+X| + X * ln|1+1/X| )
26 // with X = a*A*Z**2/Ed
27 // Ed = energy lost by particle in detector (=E if particle stops)
28 //
29 // x[0] = E (MeV)
30 // par[0] = Z
31 // par[1] = A
32
33 Int_t Z = par[0];
34 Int_t A = par[1];
35 Double_t a = GetParameter(0);
36 Double_t E = x[0] > 0 ? x[0] : 0.000001;
37 Double_t X = a * A * Z * Z / E;
38
39 return (1. - 1. / X * TMath::Log(TMath::Abs(1. + X))
40 + X * TMath::Log(TMath::Abs(1. + 1. / X))
41 ) * E / 2;
42}
43
44
45
48
50{
51 //default initialisations
52 SetType("Pulse Height Defect");
53 SetZandA(1, 1);
54 fParlog = fDeltaEphd = NULL;
55}
56
57
58
61
63{
64 // Default constructor
65 init();
66}
67
68
69
72
74{
75 //Associate PHD calculation to detector
76 init();
78}
79
80
81
84
86{
87 // Destructor
88}
89
90
91
100
102{
103 //Calculate the pulse height defect (in MeV) for a given energy loss in the detector,
104 //a given Z and a given A (Z and A of the particle should be set first using method SetZandA)
105 //The Parlog formula is used:
106 //
107 // PHD(E) = 1/2 * Ed *( 1-1/X * ln|1+X| + X * ln|1+1/X| )
108 // with X = a*A*Z**2/Ed
109 // Ed = energy lost by particle in detector (=E if particle stops)
110
111 return const_cast<KVRecombination*>(this)->GetParlogPHDFunction(GetZ(), GetA())->Eval(energy);
112}
113
114
115
124
126{
127 // Return pointer to TF1 giving energy loss in active layer of detector minus
128 // the pulse height defect for a given nucleus (Z,A).
129 //
130 // If Wrong=kTRUE (default:kFALSE) this will be calculated incorrectly
131 // (if the particle does not stop in the detector) by using the Parlog formula
132 // with the incident energy of the particle instead of the calculated energy
133 // loss of the particle.
134
135 wrong = Wrong;
136
137 if (!fDeltaEphd) {
138 fDeltaEphd = new TF1(Form("KVRecombination:%s:ELossActive", GetDetector()->GetName()),
139 this, &KVRecombination::ELossActive, 0., 1.e+04, 2, "KVRecombination", "ELossActive");
140 fDeltaEphd->SetNpx(gEnv->GetValue("KVPulseHeightDefect.EnergyLoss.Npx", 20));
141 }
143 fDeltaEphd->SetRange(0., GetDetector()->GetSmallestEmaxValid(Z, A));
144 fDeltaEphd->SetTitle(Form("PHD dependent energy loss [MeV] in detector %s for Z=%d A=%d", GetDetector()->GetName(), Z, A));
146 return fDeltaEphd;
147}
148
149
150
156
158{
159 // Calculate energy lost in active layer of detector minus the Parlog PHD
160 // x[0] = incident energy
161 // par[0] = Z
162 // par[1] = A
163
164 Double_t e = x[0];
165 TIter next(GetDetector()->GetListOfAbsorbers());
166 KVMaterial* mat;
167 while ((mat = (KVMaterial*)next()) != GetDetector()->GetActiveLayer()) {
168 // calculate energy losses in absorbers before active layer
169 e = mat->GetERes(par[0], par[1], e); //residual energy after layer
170 if (e <= 0.)
171 return 0.; // return 0 if particle stops in layers before active layer
172 }
173 // calculate energy loss in active layer
174 Double_t dE = mat->GetDeltaE(par[0], par[1], e);
175 // calculate Parlog PHD corresponding to energy lost in active layer
176 Double_t phd;
177 if (wrong) phd = PHDParlog(&e, par); //incorrect calculation using incident energy
178 else phd = PHDParlog(&dE, par);
179
180 return dE - phd;
181}
182
183
184
187
189{
190 // Create TF1* fParlog if not already done
191
192 if (!fParlog) {
193 fParlog = new TF1(Form("ParlogPHD:%s", GetDetector()->GetName()),
194 this, &KVRecombination::PHDParlog, 0., 1.e+04, 2, "KVRecombination", "PHDParlog");
195 fParlog->SetNpx(500);
196 }
197 fParlog->SetParameter(0, Z);
198 fParlog->SetParameter(1, A);
199 return fParlog;
200}
201
202
203
208
210{
211 //Given the PHD (in MeV) of a particle of charge Z and mass A
212 //(set using SetZandA() method), this method inverts the Parlog formula
213 //in order to find the energy loss of the particle in the detector.
214
215 const_cast<KVRecombination*>(this)->GetParlogPHDFunction(GetZ(), GetA());
218 return fParlog->GetX(energy, xmin, xmax);
219}
220
221
int Int_t
#define d(i)
#define e(i)
bool Bool_t
double Double_t
#define X(type, name)
R__EXTERN TEnv * gEnv
float xmin
float xmax
char * Form(const char *fmt,...)
virtual void SetType(const Char_t *str)
Definition KVBase.h:173
Base class for all detector calibrations.
KVDetector * GetDetector() const
void SetDetector(KVDetector *d)
Base class for detector geometry description.
Definition KVDetector.h:160
Description of physical materials used to construct detectors & targets; interface to range tables.
Definition KVMaterial.h:94
virtual Double_t GetERes(Int_t Z, Int_t A, Double_t Einc)
virtual Double_t GetDeltaE(Int_t Z, Int_t A, Double_t Einc)
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
Silicon PHD described by electron-hole recombination model.
Int_t GetA() const
void init()
default initialisations
TF1 * GetParlogPHDFunction(Int_t Z, Int_t A)
Create TF1* fParlog if not already done.
void SetZandA(Int_t z, Int_t a)
Double_t PHDParlog(Double_t *x, Double_t *par)
Int_t GetZ() const
virtual Double_t Invert(Double_t, const KVNameValueList &="") const
TF1 * fParlog
Parlog formula for PHD = f(E,Z,A)
TF1 * fDeltaEphd
deltaE calculated including PHD
Double_t ELossActive(Double_t *x, Double_t *par)
KVRecombination()
Default constructor.
virtual ~KVRecombination()
Destructor.
virtual Double_t Compute(Double_t, const KVNameValueList &="") const
TF1 * GetELossFunction(Int_t Z, Int_t A, Bool_t Wrong=kFALSE)
virtual const char * GetValue(const char *name, const char *dflt) const
virtual void SetRange(Double_t xmin, Double_t xmax)
void SetTitle(const char *title="") override
virtual void SetNpx(Int_t npx=100)
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 GetRange(Double_t &xmin, Double_t &xmax) const
virtual void SetParameters(const Double_t *params)
virtual void SetParameter(const TString &name, Double_t value)
const char * GetName() const override
Double_t x[n]
Eval
constexpr Double_t E()
Double_t Log(Double_t x)
Double_t Abs(Double_t d)
TArc a
ClassImp(TPyArg)