KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVIonRangeTable.cpp
Go to the documentation of this file.
1 //Created by KVClassFactory on Thu Feb 3 10:04:41 2011
2 //Author: frankland,,,,
3 
4 #include "KVIonRangeTable.h"
6 #include <TPluginManager.h>
7 #include <TError.h>
8 #include "TGeoManager.h"
9 
10 
12 
13 #define FIND_MAT_AND_EXEC(method,defval) \
14  KVIonRangeTableMaterial* M = GetMaterial(mat); \
15  if(M) return M->method; \
16  return defval
17 #define CHECK_ION_FIND_MAT_AND_EXEC(method,defval) \
18  if(!CheckIon(Z,A)){ \
19  if(Z) Warning(#method , "Ion Z=%d out of range table limits", Z); \
20  return defval; \
21  } \
22 
23  KVIonRangeTableMaterial* M = GetMaterial(mat); \
24  if(M) return M->method; \
25  return defval
26 
28 
29 
30 
33 KVIonRangeTable::KVIonRangeTable(const Char_t* name, const Char_t* title)
34  : KVBase(name, title)
35 {
36  // Default constructor
37 }
38 
39 
40 
43 
45 {
46  // Destructor
47 }
48 
49 
50 
53 
55 {
56  // Generates an instance of the KVIonRangeTable plugin class corresponding to given name.
57 
58  TPluginHandler* ph;
59  //check and load plugin library
60  if (!(ph = LoadPlugin("KVIonRangeTable", name))) {
61  ::Error("KVIonRangeTable::GetRangeTable", "No plugin for KVIonRangeTable with name=%s found in .kvrootrc", name);
62  return 0;
63  }
65  return irt;
66 }
67 
68 
69 
70 
75 
77 {
78  // Return atomic mass of a material in the range table.
79  // "material" can be either the type or the name of the material.
80  // Prints a warning and returns 0 if material is unknown.
81 
83  if (!M) {
84  Warning("GetAtomicMass", "Material %s is unknown. Returned mass = 0.", material);
85  return 0.0;
86  }
87  return M->GetMass();
88 }
89 
90 
91 
93 
95 {
96  return GetMaterialWithNameOrType(material);
97 }
98 
99 
100 
102 
104 {
105  return GetMaterialWithPointer(mat);
106 }
107 
108 
109 
113 
115 {
116  // Returns pointer to material for given TGeoMaterial
117  // We try both the name and the title of the TGeoMaterial
118  KVIonRangeTableMaterial* mat = GetMaterial(material->GetTitle());
119  if (!mat) mat = GetMaterial(material->GetName());
120  return mat;
121 }
122 
123 
124 
125 
130 
132 {
133  // Return atomic number of a material in the range table.
134  // "material" can be either the type or the name of the material.
135  // Prints a warning and returns 0 if material is unknown.
136 
138  if (!M) {
139  Warning("GetZ", "Material %s is unknown. Returned Z = 0.", material);
140  return 0.0;
141  }
142  return M->GetZ();
143 }
144 
145 
146 
147 
150 
152 {
153  // Returns kTRUE if material of given name or type is in range table.
155  return (M != 0x0);
156 }
157 
158 
159 
162 
164 {
165  // Returns kTRUE if material corresponding to TGeoMaterial name or type is in range table.
167  return (M != 0x0);
168 }
169 
170 
171 
172 
175 
177 {
178  // Returns kTRUE if material of given name or type is gaseous.
179  FIND_MAT_AND_EXEC(IsGas(), kFALSE);
180 }
181 
182 
183 
184 
187 
189 {
190  // Return name of material of given type or name if it is in range tables
191  FIND_MAT_AND_EXEC(GetName(), "");
192 }
193 
194 
195 
196 
199 
201 {
202  // Return density of material (g/cm**3) of given type or name if it is in range tables
204 }
205 
206 
207 
208 
213 
214 void KVIonRangeTable::SetTemperatureAndPressure(const Char_t* material, Double_t temperature, Double_t pressure)
215 {
216  // Set temperature (in degrees celsius) and pressure (in torr) for a given
217  // material. This has no effect except for gaseous materials, for which T & P
218  // determine the density (in g/cm**3).
219 
221  if (M) M->SetTemperatureAndPressure(temperature, pressure);
222 }
223 
224 
225 
226 
231 
233  Double_t Amat, Double_t, Double_t)
234 {
235  // Returns range (in g/cm**2) of ion (Z,A) with energy E (MeV) in material.
236  // Give Amat to change default (isotopic) mass of material,
237  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
238 
239  CHECK_ION_FIND_MAT_AND_EXEC(GetRangeOfIon(Z, A, E, Amat), 0.0);
240 }
241 
242 
243 
248 
250  Double_t Amat, Double_t T, Double_t P)
251 {
252  // Returns linear range (in cm) of ion (Z,A) with energy E (MeV) in material.
253  // Give Amat to change default (isotopic) mass of material,
254  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
255 
256  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearRangeOfIon(Z, A, E, Amat, T, P), 0.0);
257 }
258 
259 
260 
265 
267  Double_t Amat, Double_t, Double_t)
268 {
269  // Returns energy lost (in MeV) by ion (Z,A) with energy E (MeV) after thickness r (in g/cm**2).
270  // Give Amat to change default (isotopic) mass of material,
271  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
272 
273  CHECK_ION_FIND_MAT_AND_EXEC(GetDeltaEOfIon(Z, A, E, r, Amat), 0.0);
274 }
275 
276 
277 
282 
284  Double_t Amat, Double_t T, Double_t P)
285 {
286  // Returns energy lost (in MeV) by ion (Z,A) with energy E (MeV) after thickness d (in cm).
287  // Give Amat to change default (isotopic) mass of material,
288  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
289 
290  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearDeltaEOfIon(Z, A, E, d, Amat, T, P), 0.0);
291 }
292 
293 
294 
299 
301  Double_t Amat, Double_t, Double_t)
302 {
303  // Returns residual energy (in MeV) of ion (Z,A) with incident energy E (MeV) after thickness r (in g/cm**2).
304  // Give Amat to change default (isotopic) mass of material,
305  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
306 
307  CHECK_ION_FIND_MAT_AND_EXEC(GetEResOfIon(Z, A, E, r, Amat), 0.0);
308 }
309 
310 
311 
316 
318  Double_t Amat, Double_t T, Double_t P)
319 {
320  // Returns residual energy (in MeV) of ion (Z,A) with incident energy E (MeV) after thickness d (in cm).
321  // Give Amat to change default (isotopic) mass of material,
322  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
323 
324  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearEResOfIon(Z, A, E, d, Amat, T, P), 0.0);
325 }
326 
327 
328 
332 
334 {
335  // Calculates incident energy (in MeV) of an ion (Z,A) with residual energy Eres (MeV) after thickness e (in g/cm**2).
336  // Give Amat to change default (isotopic) mass of material,
337  CHECK_ION_FIND_MAT_AND_EXEC(GetEIncFromEResOfIon(Z, A, Eres, e, isoAmat), 0.0);
338 }
339 
340 
341 
346 
348  Double_t isoAmat, Double_t T, Double_t P)
349 {
350  // Calculates incident energy (in MeV) of an ion (Z,A) with residual energy Eres (MeV) after thickness e (in cm).
351  // Give Amat to change default (isotopic) mass of material,
352  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
353  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearEIncFromEResOfIon(Z, A, Eres, e, isoAmat, T, P), 0.0);
354 }
355 
356 
357 
361 
363 {
364  // Calculates incident energy (in MeV) of an ion (Z,A) from energy loss DeltaE (MeV) in thickness e (in g/cm**2).
365  // Give Amat to change default (isotopic) mass of material,
366  CHECK_ION_FIND_MAT_AND_EXEC(GetEIncFromDeltaEOfIon(Z, A, DeltaE, e, type, isoAmat), 0.0);
367 }
368 
369 
370 
375 
377  Double_t isoAmat, Double_t T, Double_t P)
378 {
379  // Calculates incident energy (in MeV) of an ion (Z,A) from energy loss DeltaE (MeV) in thickness e (in cm).
380  // Give Amat to change default (isotopic) mass of material,
381  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
382  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearEIncFromDeltaEOfIon(Z, A, deltaE, e, type, isoAmat, T, P), 0.0);
383 }
384 
385 
386 
390 
392 {
393  // Calculates incident energy (in MeV) of an ion (Z,A) from energy loss DeltaE (MeV) in thickness e (in g/cm**2).
394  // Give Amat to change default (isotopic) mass of material,
395  CHECK_ION_FIND_MAT_AND_EXEC(GetDeltaEFromEResOfIon(Z, A, Eres, e, isoAmat), 0.0);
396 }
397 
398 
399 
404 
406 {
407  // Calculates incident energy (in MeV) of an ion (Z,A) from energy loss DeltaE (MeV) in thickness e (in cm).
408  // Give Amat to change default (isotopic) mass of material,
409  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
410  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearDeltaEFromEResOfIon(Z, A, Eres, e, isoAmat, T, P), 0.0);
411 }
412 
413 
414 
421 
423 {
424  // Calculate incident energy (in MeV) for ion (Z,A) for which the range is equal to the
425  // given thickness e (in g/cm**2). At this energy the residual energy of the ion is (just) zero,
426  // for all energies above this energy the residual energy is > 0.
427  // Give Amat to change default (isotopic) mass of material.
428  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
430 }
431 
432 
433 
440 
442 {
443  // Calculate incident energy (in MeV) for ion (Z,A) for which the range is equal to the
444  // given thickness e (in cm). At this energy the residual energy of the ion is (just) zero,
445  // for all energies above this energy the residual energy is > 0.
446  // Give Amat to change default (isotopic) mass of material.
447  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
449 }
450 
451 
452 
456 
458 {
459  // Calculate maximum energy loss (in MeV) of ion (Z,A) in given thickness e (in g/cm**2).
460  // Give Amat to change default (isotopic) mass of material.
461  CHECK_ION_FIND_MAT_AND_EXEC(GetMaxDeltaEOfIon(Z, A, e, isoAmat), 0.0);
462 }
463 
464 
465 
470 
472 {
473  // Calculate incident energy (in MeV) corresponding to maximum energy loss of ion (Z,A)
474  // in given thickness e (in g/cm**2).
475  // Give Amat to change default (isotopic) mass of material.
476 
478 }
479 
480 
481 
486 
488 {
489  // Calculate maximum energy loss (in MeV) of ion (Z,A) in given thickness e (in cm).
490  // Give Amat to change default (isotopic) mass of material.
491  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
492 
493  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearMaxDeltaEOfIon(Z, A, e, isoAmat, T, P), 0.0);
494 }
495 
496 
497 
503 
505 {
506  // Calculate incident energy (in MeV) corresponding to maximum energy loss of ion (Z,A)
507  // in given thickness e (in cm).
508  // Give Amat to change default (isotopic) mass of material.
509  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
510 
512 }
513 
514 
515 
519 
521 {
522  // Returns maximum energy (in MeV) for which range table is valid
523  // for given material and incident ion (Z,A)
524 
526 }
527 
528 
529 
530 
534 
536 {
537  // Return pointer to TGeoMaterial corresponding to this material,
538  // for use in ROOT geometries, VMC, etc.
539 
541 }
542 
543 
544 
546 
548 {
549  printf("%s::%s\n%s\n", ClassName(), GetName(), GetTitle());
550 }
551 
552 
553 
int Int_t
#define CHECK_ION_FIND_MAT_AND_EXEC(method, defval)
KVIonRangeTableMaterial * M
#define FIND_MAT_AND_EXEC(method, defval)
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
ROOT::R::TRInterface & r
#define d(i)
#define e(i)
char Char_t
const Bool_t kFALSE
bool Bool_t
double Double_t
const char Option_t
int type
Base class for KaliVeda framework.
Definition: KVBase.h:141
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Definition: KVBase.cpp:793
Material for use in energy loss & range calculations.
void SetTemperatureAndPressure(Double_t T, Double_t P)
Abstract base class for calculation of range & energy loss of charged particles in matter.
KVIonRangeTableMaterial * GetMaterial(const Char_t *material) const
Returns pointer to material of given name or type.
virtual Bool_t IsMaterialGas(const Char_t *)
Return kTRUE if material is gaseous.
virtual Double_t GetLinearEIncFromDeltaEOfIon(const Char_t *mat, Int_t Z, Int_t A, Double_t DeltaE, Double_t e, enum SolType type=kEmax, Double_t isoAmat=0., Double_t T=-1., Double_t P=-1.)
virtual Double_t GetEIncFromEResOfIon(const Char_t *mat, Int_t Z, Int_t A, Double_t Eres, Double_t e, Double_t isoAmat=0., Double_t T=-1., Double_t P=-1.)
virtual const Char_t * GetMaterialName(const Char_t *)
Return name of material of given type or name if it is in range tables.
virtual Double_t GetAtomicMass(const Char_t *)
Returns atomic mass of a material in the range tables.
virtual Double_t GetLinearMaxDeltaEOfIon(const Char_t *mat, Int_t Z, Int_t A, Double_t e, Double_t isoAmat=0., Double_t T=-1., Double_t P=-1.)
virtual void Print(Option_t *="") const
virtual Double_t GetRangeOfIon(const Char_t *mat, Int_t Z, Int_t A, Double_t E, Double_t Amat=0., Double_t T=-1., Double_t P=-1.)
virtual Double_t GetEResOfIon(const Char_t *mat, Int_t Z, Int_t A, Double_t E, Double_t r, Double_t Amat=0., Double_t T=-1., Double_t P=-1.)
static KVIonRangeTable * GetRangeTable(const Char_t *name)
Generates an instance of the KVIonRangeTable plugin class corresponding to given name.
virtual KVIonRangeTableMaterial * GetMaterialWithPointer(TGeoMaterial *) const
virtual Double_t GetMaxDeltaEOfIon(const Char_t *mat, Int_t Z, Int_t A, Double_t e, Double_t isoAmat=0., Double_t T=-1., Double_t P=-1.)
virtual Double_t GetLinearEIncFromEResOfIon(const Char_t *mat, Int_t Z, Int_t A, Double_t Eres, Double_t e, Double_t isoAmat=0., Double_t T=-1., Double_t P=-1.)
virtual TGeoMaterial * GetTGeoMaterial(const Char_t *material)
Create and return pointer to TGeoMaterial/Mixture corresponding to material.
virtual Double_t GetZ(const Char_t *)
Returns atomic number of a material in the range tables.
virtual Double_t GetLinearEResOfIon(const Char_t *mat, Int_t Z, Int_t A, Double_t E, Double_t d, Double_t Amat=0., Double_t T=-1., Double_t P=-1.)
virtual Double_t GetEIncFromDeltaEOfIon(const Char_t *mat, Int_t Z, Int_t A, Double_t DeltaE, Double_t e, enum SolType type=kEmax, Double_t isoAmat=0., Double_t T=-1., Double_t P=-1.)
virtual KVIonRangeTableMaterial * GetMaterialWithNameOrType(const Char_t *material) const =0
virtual Double_t GetPunchThroughEnergy(const Char_t *mat, Int_t Z, Int_t A, Double_t e, Double_t isoAmat=0., Double_t T=-1., Double_t P=-1.)
virtual Double_t GetEmaxValid(const Char_t *material, Int_t Z, Int_t A)
virtual Double_t GetLinearEIncOfMaxDeltaEOfIon(const Char_t *mat, Int_t Z, Int_t A, Double_t e, Double_t isoAmat=0., Double_t T=-1., Double_t P=-1.)
virtual Double_t GetLinearPunchThroughEnergy(const Char_t *mat, Int_t Z, Int_t A, Double_t e, Double_t isoAmat=0., Double_t T=-1., Double_t P=-1.)
virtual Double_t GetLinearDeltaEFromEResOfIon(const Char_t *mat, Int_t Z, Int_t A, Double_t ERes, Double_t e, Double_t isoAmat=0., Double_t T=-1., Double_t P=-1.)
virtual Bool_t IsMaterialKnown(const Char_t *)
Return kTRUE if material is in range tables.
virtual Double_t GetLinearDeltaEOfIon(const Char_t *mat, Int_t Z, Int_t A, Double_t E, Double_t d, Double_t Amat=0., Double_t T=-1., Double_t P=-1.)
virtual Double_t GetDeltaEFromEResOfIon(const Char_t *mat, Int_t Z, Int_t A, Double_t ERes, Double_t e, Double_t isoAmat=0., Double_t T=-1., Double_t P=-1.)
virtual ~KVIonRangeTable()
Destructor.
virtual Double_t GetEIncOfMaxDeltaEOfIon(const Char_t *mat, Int_t Z, Int_t A, Double_t e, Double_t isoAmat=0., Double_t T=-1., Double_t P=-1.)
virtual Double_t GetDeltaEOfIon(const Char_t *mat, Int_t Z, Int_t A, Double_t E, Double_t r, Double_t Amat=0., Double_t T=-1., Double_t P=-1.)
virtual void SetTemperatureAndPressure(const Char_t *, Double_t temperature, Double_t pressure)
virtual Double_t GetDensity(const Char_t *)
Returns density (g/cm**3) of a material in the range tables.
virtual Double_t GetLinearRangeOfIon(const Char_t *mat, Int_t Z, Int_t A, Double_t E, Double_t Amat=0., Double_t T=-1., Double_t P=-1.)
virtual const char * GetName() const
virtual const char * GetTitle() const
virtual const char * ClassName() const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
Longptr_t ExecPlugin(int nargs, const T &... params)
double T(double x)
constexpr Double_t E()