KaliVeda
Toolkit for HIC analysis
KVIonRangeTable.cpp
1 //Created by KVClassFactory on Thu Feb 3 10:04:41 2011
2 //Author: frankland,,,,
3 
4 #include "KVIonRangeTable.h"
5 #include "KVIonRangeTableMaterial.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 FIND_MAT_AND_SET(method,newval) \
18  KVIonRangeTableMaterial* M = GetMaterial(mat); \
19  if(M) M->method(newval)
20 #define CHECK_ION_FIND_MAT_AND_EXEC(method,defval) \
21  if(!CheckIon(Z,A)){ \
22  if(Z) Warning(#method , "Ion Z=%d out of range table limits", Z); \
23  return defval; \
24  } \
25 
26  KVIonRangeTableMaterial* M = GetMaterial(mat); \
27  if(M) return M->method; \
28  return defval
29 
31 
32 
33 
36 KVIonRangeTable::KVIonRangeTable(const Char_t* name, const Char_t* title)
37  : KVBase(name, title)
38 {
39  // Default constructor
40 }
41 
42 
43 
46 
48 {
49  // Destructor
50 }
51 
52 
53 
56 
58 {
59  // Generates an instance of the KVIonRangeTable plugin class corresponding to given name.
60 
61  TPluginHandler* ph;
62  //check and load plugin library
63  if (!(ph = LoadPlugin("KVIonRangeTable", name))) {
64  ::Error("KVIonRangeTable::GetRangeTable", "No plugin for KVIonRangeTable with name=%s found in .kvrootrc", name);
65  return 0;
66  }
68  return irt;
69 }
70 
71 
72 
73 
78 
80 {
81  // Return atomic mass of a material in the range table.
82  // "material" can be either the type or the name of the material.
83  // Prints a warning and returns 0 if material is unknown.
84 
85  KVIonRangeTableMaterial* M = GetMaterial(material);
86  if (!M) {
87  KVError::Warning(this, "GetAtomicMass", "Material %s is unknown. Returned mass = 0.", material);
88  return 0.0;
89  }
90  return M->GetMass();
91 }
92 
93 
94 
96 
98 {
99  return GetMaterialWithNameOrType(material);
100 }
101 
102 
103 
105 
107 {
108  return GetMaterialWithPointer(mat);
109 }
110 
111 
112 
116 
118 {
119  // Returns pointer to material for given TGeoMaterial
120  // We try both the name and the title of the TGeoMaterial
121  KVIonRangeTableMaterial* mat = GetMaterial(material->GetTitle());
122  if (!mat) mat = GetMaterial(material->GetName());
123  return mat;
124 }
125 
126 
127 
128 
133 
135 {
136  // Return atomic number of a material in the range table.
137  // "material" can be either the type or the name of the material.
138  // Prints a warning and returns 0 if material is unknown.
139 
140  KVIonRangeTableMaterial* M = GetMaterial(material);
141  if (!M) {
142  KVError::Warning(this, "GetZ", "Material %s is unknown. Returned Z = 0.", material);
143  return 0.0;
144  }
145  return M->GetZ();
146 }
147 
148 
149 
150 
153 
155 {
156  // Returns kTRUE if material of given name or type is in range table.
157  KVIonRangeTableMaterial* M = GetMaterial(material);
158  return (M != 0x0);
159 }
160 
161 
162 
165 
167 {
168  // Returns kTRUE if material corresponding to TGeoMaterial name or type is in range table.
169  KVIonRangeTableMaterial* M = GetMaterial(material);
170  return (M != 0x0);
171 }
172 
173 
174 
175 
178 
180 {
181  // Returns kTRUE if material of given name or type is gaseous.
182  FIND_MAT_AND_EXEC(IsGas(), kFALSE);
183 }
184 
185 
186 
187 
190 
192 {
193  // Return name of material of given type or name if it is in range tables
194  FIND_MAT_AND_EXEC(GetName(), "");
195 }
196 
197 
198 
199 
202 
204 {
205  // Return type of material of given type or name if it is in range tables
206  FIND_MAT_AND_EXEC(GetType(), "");
207 }
208 
209 
210 
211 
214 
216 {
217  // Return density of material (g/cm**3) of given type or name if it is in range tables
218  FIND_MAT_AND_EXEC(GetDensity(), 0.0);
219 }
220 
221 
222 
223 
226 
228 {
229  // Changes the density (g/cm**3) of a material of given type or name if it is in the range tables
230  FIND_MAT_AND_SET(SetDensity, dens);
231 }
232 
233 
234 
235 
240 
241 void KVIonRangeTable::SetTemperatureAndPressure(const Char_t* material, Double_t temperature, Double_t pressure)
242 {
243  // Set temperature (in degrees celsius) and pressure (in torr) for a given
244  // material. This has no effect except for gaseous materials, for which T & P
245  // determine the density (in g/cm**3).
246 
247  KVIonRangeTableMaterial* M = GetMaterial(material);
248  if (M) M->SetTemperatureAndPressure(temperature, pressure);
249 }
250 
251 
252 
253 
258 
260  Double_t Amat, Double_t, Double_t)
261 {
262  // Returns range (in g/cm**2) of ion (Z,A) with energy E (MeV) in material.
263  // Give Amat to change default (isotopic) mass of material,
264  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
265 
266  CHECK_ION_FIND_MAT_AND_EXEC(GetRangeOfIon(Z, A, E, Amat), 0.0);
267 }
268 
269 
270 
275 
277  Double_t Amat, Double_t T, Double_t P)
278 {
279  // Returns linear range (in cm) of ion (Z,A) with energy E (MeV) in material.
280  // Give Amat to change default (isotopic) mass of material,
281  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
282 
283  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearRangeOfIon(Z, A, E, Amat, T, P), 0.0);
284 }
285 
286 
287 
292 
294  Double_t Amat, Double_t, Double_t)
295 {
296  // Returns energy lost (in MeV) by ion (Z,A) with energy E (MeV) after thickness r (in g/cm**2).
297  // Give Amat to change default (isotopic) mass of material,
298  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
299 
300  CHECK_ION_FIND_MAT_AND_EXEC(GetDeltaEOfIon(Z, A, E, r, Amat), 0.0);
301 }
302 
303 
304 
309 
311  Double_t Amat, Double_t T, Double_t P)
312 {
313  // Returns energy lost (in MeV) by ion (Z,A) with energy E (MeV) after thickness d (in cm).
314  // Give Amat to change default (isotopic) mass of material,
315  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
316 
317  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearDeltaEOfIon(Z, A, E, d, Amat, T, P), 0.0);
318 }
319 
320 
321 
326 
328  Double_t Amat, Double_t, Double_t)
329 {
330  // Returns residual energy (in MeV) of ion (Z,A) with incident energy E (MeV) after thickness r (in g/cm**2).
331  // Give Amat to change default (isotopic) mass of material,
332  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
333 
334  CHECK_ION_FIND_MAT_AND_EXEC(GetEResOfIon(Z, A, E, r, Amat), 0.0);
335 }
336 
337 
338 
343 
345  Double_t Amat, Double_t T, Double_t P)
346 {
347  // Returns residual energy (in MeV) of ion (Z,A) with incident energy E (MeV) after thickness d (in cm).
348  // Give Amat to change default (isotopic) mass of material,
349  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
350 
351  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearEResOfIon(Z, A, E, d, Amat, T, P), 0.0);
352 }
353 
354 
355 
359 
361 {
362  // Calculates incident energy (in MeV) of an ion (Z,A) with residual energy Eres (MeV) after thickness e (in g/cm**2).
363  // Give Amat to change default (isotopic) mass of material,
364  CHECK_ION_FIND_MAT_AND_EXEC(GetEIncFromEResOfIon(Z, A, Eres, e, isoAmat), 0.0);
365 }
366 
367 
368 
373 
375  Double_t isoAmat, Double_t T, Double_t P)
376 {
377  // Calculates incident energy (in MeV) of an ion (Z,A) with residual energy Eres (MeV) after thickness e (in cm).
378  // Give Amat to change default (isotopic) mass of material,
379  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
380  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearEIncFromEResOfIon(Z, A, Eres, e, isoAmat, T, P), 0.0);
381 }
382 
383 
384 
388 
390 {
391  // Calculates incident energy (in MeV) of an ion (Z,A) from energy loss DeltaE (MeV) in thickness e (in g/cm**2).
392  // Give Amat to change default (isotopic) mass of material,
393  CHECK_ION_FIND_MAT_AND_EXEC(GetEIncFromDeltaEOfIon(Z, A, DeltaE, e, type, isoAmat), 0.0);
394 }
395 
396 
397 
402 
404  Double_t isoAmat, Double_t T, Double_t P)
405 {
406  // Calculates incident energy (in MeV) of an ion (Z,A) from energy loss DeltaE (MeV) in thickness e (in cm).
407  // Give Amat to change default (isotopic) mass of material,
408  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
409  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearEIncFromDeltaEOfIon(Z, A, deltaE, e, type, isoAmat, T, P), 0.0);
410 }
411 
412 
413 
417 
419 {
420  // Calculates incident energy (in MeV) of an ion (Z,A) from energy loss DeltaE (MeV) in thickness e (in g/cm**2).
421  // Give Amat to change default (isotopic) mass of material,
422  CHECK_ION_FIND_MAT_AND_EXEC(GetDeltaEFromEResOfIon(Z, A, Eres, e, isoAmat), 0.0);
423 }
424 
425 
426 
431 
433 {
434  // Calculates incident energy (in MeV) of an ion (Z,A) from energy loss DeltaE (MeV) in thickness e (in cm).
435  // Give Amat to change default (isotopic) mass of material,
436  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
437  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearDeltaEFromEResOfIon(Z, A, Eres, e, isoAmat, T, P), 0.0);
438 }
439 
440 
441 
448 
450 {
451  // Calculate incident energy (in MeV) for ion (Z,A) for which the range is equal to the
452  // given thickness e (in g/cm**2). At this energy the residual energy of the ion is (just) zero,
453  // for all energies above this energy the residual energy is > 0.
454  // Give Amat to change default (isotopic) mass of material.
455  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
456  CHECK_ION_FIND_MAT_AND_EXEC(GetPunchThroughEnergy(Z, A, e, isoAmat), 0.0);
457 }
458 
459 
460 
467 
469 {
470  // Calculate incident energy (in MeV) for ion (Z,A) for which the range is equal to the
471  // given thickness e (in cm). At this energy the residual energy of the ion is (just) zero,
472  // for all energies above this energy the residual energy is > 0.
473  // Give Amat to change default (isotopic) mass of material.
474  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
475  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearPunchThroughEnergy(Z, A, e, isoAmat, T, P), 0.0);
476 }
477 
478 
479 
483 
485 {
486  // Calculate maximum energy loss (in MeV) of ion (Z,A) in given thickness e (in g/cm**2).
487  // Give Amat to change default (isotopic) mass of material.
488  CHECK_ION_FIND_MAT_AND_EXEC(GetMaxDeltaEOfIon(Z, A, e, isoAmat), 0.0);
489 }
490 
491 
492 
497 
499 {
500  // Calculate incident energy (in MeV) corresponding to maximum energy loss of ion (Z,A)
501  // in given thickness e (in g/cm**2).
502  // Give Amat to change default (isotopic) mass of material.
503 
504  CHECK_ION_FIND_MAT_AND_EXEC(GetEIncOfMaxDeltaEOfIon(Z, A, e, isoAmat), 0.0);
505 }
506 
507 
508 
513 
515 {
516  // Calculate maximum energy loss (in MeV) of ion (Z,A) in given thickness e (in cm).
517  // Give Amat to change default (isotopic) mass of material.
518  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
519 
520  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearMaxDeltaEOfIon(Z, A, e, isoAmat, T, P), 0.0);
521 }
522 
523 
524 
530 
532 {
533  // Calculate incident energy (in MeV) corresponding to maximum energy loss of ion (Z,A)
534  // in given thickness e (in cm).
535  // Give Amat to change default (isotopic) mass of material.
536  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
537 
538  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearEIncOfMaxDeltaEOfIon(Z, A, e, isoAmat, T, P), 0.0);
539 }
540 
541 
542 
546 
548 {
549  // Returns maximum energy (in MeV) for which range table is valid
550  // for given material and incident ion (Z,A)
551 
552  CHECK_ION_FIND_MAT_AND_EXEC(GetEmaxValid(Z, A), 0.0);
553 }
554 
555 
556 
557 
561 
563 {
564  // Return pointer to TGeoMaterial corresponding to this material,
565  // for use in ROOT geometries, VMC, etc.
566 
567  FIND_MAT_AND_EXEC(GetTGeoMaterial(), 0x0);
568 }
569 
570 
571 
573 
575 {
576  printf("%s::%s\n%s\n", ClassName(), GetName(), GetTitle());
577 }
578 
579 
580 
int Int_t
ROOT::R::TRInterface & r
#define d(i)
#define e(i)
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
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 Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Base class for KaliVeda framework.
Definition: KVBase.h:140
virtual const Char_t * GetType() const
Definition: KVBase.h:177
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Definition: KVBase.cpp:795
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.)
void Print(Option_t *="") const override
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.
const Char_t * GetMaterialType(const Char_t *)
Return type of material of given type or name if it is in 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 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 void SetDensity(const Char_t *, Double_t)
Changes the density (g/cm**3) of a material in the range tables.
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.)
const char * GetName() const override
const char * GetTitle() const override
virtual const char * ClassName() const
virtual void Error(const char *method, const char *msgfmt,...) const
Longptr_t ExecPlugin(int nargs)
void Warning(UserClass p, const char *location, const char *va_(fmt),...)
Definition: KVError.h:125
double T(double x)
constexpr Double_t E()
ClassImp(TPyArg)