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 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 
82  KVIonRangeTableMaterial* M = GetMaterial(material);
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 
137  KVIonRangeTableMaterial* M = GetMaterial(material);
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.
154  KVIonRangeTableMaterial* M = GetMaterial(material);
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.
166  KVIonRangeTableMaterial* M = GetMaterial(material);
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 type of material of given type or name if it is in range tables
203  FIND_MAT_AND_EXEC(GetType(), "");
204 }
205 
206 
207 
208 
211 
213 {
214  // Return density of material (g/cm**3) of given type or name if it is in range tables
215  FIND_MAT_AND_EXEC(GetDensity(), 0.0);
216 }
217 
218 
219 
220 
225 
226 void KVIonRangeTable::SetTemperatureAndPressure(const Char_t* material, Double_t temperature, Double_t pressure)
227 {
228  // Set temperature (in degrees celsius) and pressure (in torr) for a given
229  // material. This has no effect except for gaseous materials, for which T & P
230  // determine the density (in g/cm**3).
231 
232  KVIonRangeTableMaterial* M = GetMaterial(material);
233  if (M) M->SetTemperatureAndPressure(temperature, pressure);
234 }
235 
236 
237 
238 
243 
245  Double_t Amat, Double_t, Double_t)
246 {
247  // Returns range (in g/cm**2) of ion (Z,A) with energy E (MeV) in material.
248  // Give Amat to change default (isotopic) mass of material,
249  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
250 
251  CHECK_ION_FIND_MAT_AND_EXEC(GetRangeOfIon(Z, A, E, Amat), 0.0);
252 }
253 
254 
255 
260 
262  Double_t Amat, Double_t T, Double_t P)
263 {
264  // Returns linear range (in cm) of ion (Z,A) with energy E (MeV) in material.
265  // Give Amat to change default (isotopic) mass of material,
266  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
267 
268  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearRangeOfIon(Z, A, E, Amat, T, P), 0.0);
269 }
270 
271 
272 
277 
279  Double_t Amat, Double_t, Double_t)
280 {
281  // Returns energy lost (in MeV) by ion (Z,A) with energy E (MeV) after thickness r (in g/cm**2).
282  // Give Amat to change default (isotopic) mass of material,
283  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
284 
285  CHECK_ION_FIND_MAT_AND_EXEC(GetDeltaEOfIon(Z, A, E, r, Amat), 0.0);
286 }
287 
288 
289 
294 
296  Double_t Amat, Double_t T, Double_t P)
297 {
298  // Returns energy lost (in MeV) by ion (Z,A) with energy E (MeV) after thickness d (in cm).
299  // Give Amat to change default (isotopic) mass of material,
300  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
301 
302  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearDeltaEOfIon(Z, A, E, d, Amat, T, P), 0.0);
303 }
304 
305 
306 
311 
313  Double_t Amat, Double_t, Double_t)
314 {
315  // Returns residual energy (in MeV) of ion (Z,A) with incident energy E (MeV) after thickness r (in g/cm**2).
316  // Give Amat to change default (isotopic) mass of material,
317  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
318 
319  CHECK_ION_FIND_MAT_AND_EXEC(GetEResOfIon(Z, A, E, r, Amat), 0.0);
320 }
321 
322 
323 
328 
330  Double_t Amat, Double_t T, Double_t P)
331 {
332  // Returns residual energy (in MeV) of ion (Z,A) with incident energy E (MeV) after thickness d (in cm).
333  // Give Amat to change default (isotopic) mass of material,
334  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
335 
336  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearEResOfIon(Z, A, E, d, Amat, T, P), 0.0);
337 }
338 
339 
340 
344 
346 {
347  // Calculates incident energy (in MeV) of an ion (Z,A) with residual energy Eres (MeV) after thickness e (in g/cm**2).
348  // Give Amat to change default (isotopic) mass of material,
349  CHECK_ION_FIND_MAT_AND_EXEC(GetEIncFromEResOfIon(Z, A, Eres, e, isoAmat), 0.0);
350 }
351 
352 
353 
358 
360  Double_t isoAmat, Double_t T, Double_t P)
361 {
362  // Calculates incident energy (in MeV) of an ion (Z,A) with residual energy Eres (MeV) after thickness e (in cm).
363  // Give Amat to change default (isotopic) mass of material,
364  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
365  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearEIncFromEResOfIon(Z, A, Eres, e, isoAmat, T, P), 0.0);
366 }
367 
368 
369 
373 
375 {
376  // Calculates incident energy (in MeV) of an ion (Z,A) from energy loss DeltaE (MeV) in thickness e (in g/cm**2).
377  // Give Amat to change default (isotopic) mass of material,
378  CHECK_ION_FIND_MAT_AND_EXEC(GetEIncFromDeltaEOfIon(Z, A, DeltaE, e, type, isoAmat), 0.0);
379 }
380 
381 
382 
387 
389  Double_t isoAmat, Double_t T, Double_t P)
390 {
391  // Calculates incident energy (in MeV) of an ion (Z,A) from energy loss DeltaE (MeV) in thickness e (in cm).
392  // Give Amat to change default (isotopic) mass of material,
393  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
394  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearEIncFromDeltaEOfIon(Z, A, deltaE, e, type, isoAmat, T, P), 0.0);
395 }
396 
397 
398 
402 
404 {
405  // Calculates incident energy (in MeV) of an ion (Z,A) from energy loss DeltaE (MeV) in thickness e (in g/cm**2).
406  // Give Amat to change default (isotopic) mass of material,
407  CHECK_ION_FIND_MAT_AND_EXEC(GetDeltaEFromEResOfIon(Z, A, Eres, e, isoAmat), 0.0);
408 }
409 
410 
411 
416 
418 {
419  // Calculates incident energy (in MeV) of an ion (Z,A) from energy loss DeltaE (MeV) in thickness e (in cm).
420  // Give Amat to change default (isotopic) mass of material,
421  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
422  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearDeltaEFromEResOfIon(Z, A, Eres, e, isoAmat, T, P), 0.0);
423 }
424 
425 
426 
433 
435 {
436  // Calculate incident energy (in MeV) for ion (Z,A) for which the range is equal to the
437  // given thickness e (in g/cm**2). At this energy the residual energy of the ion is (just) zero,
438  // for all energies above this energy the residual energy is > 0.
439  // Give Amat to change default (isotopic) mass of material.
440  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
441  CHECK_ION_FIND_MAT_AND_EXEC(GetPunchThroughEnergy(Z, A, e, isoAmat), 0.0);
442 }
443 
444 
445 
452 
454 {
455  // Calculate incident energy (in MeV) for ion (Z,A) for which the range is equal to the
456  // given thickness e (in cm). At this energy the residual energy of the ion is (just) zero,
457  // for all energies above this energy the residual energy is > 0.
458  // Give Amat to change default (isotopic) mass of material.
459  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
460  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearPunchThroughEnergy(Z, A, e, isoAmat, T, P), 0.0);
461 }
462 
463 
464 
468 
470 {
471  // Calculate maximum energy loss (in MeV) of ion (Z,A) in given thickness e (in g/cm**2).
472  // Give Amat to change default (isotopic) mass of material.
473  CHECK_ION_FIND_MAT_AND_EXEC(GetMaxDeltaEOfIon(Z, A, e, isoAmat), 0.0);
474 }
475 
476 
477 
482 
484 {
485  // Calculate incident energy (in MeV) corresponding to maximum energy loss of ion (Z,A)
486  // in given thickness e (in g/cm**2).
487  // Give Amat to change default (isotopic) mass of material.
488 
489  CHECK_ION_FIND_MAT_AND_EXEC(GetEIncOfMaxDeltaEOfIon(Z, A, e, isoAmat), 0.0);
490 }
491 
492 
493 
498 
500 {
501  // Calculate maximum energy loss (in MeV) of ion (Z,A) in given thickness e (in cm).
502  // Give Amat to change default (isotopic) mass of material.
503  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
504 
505  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearMaxDeltaEOfIon(Z, A, e, isoAmat, T, P), 0.0);
506 }
507 
508 
509 
515 
517 {
518  // Calculate incident energy (in MeV) corresponding to maximum energy loss of ion (Z,A)
519  // in given thickness e (in cm).
520  // Give Amat to change default (isotopic) mass of material.
521  // give temperature (degrees C) & pressure (torr) (T,P) for gaseous materials.
522 
523  CHECK_ION_FIND_MAT_AND_EXEC(GetLinearEIncOfMaxDeltaEOfIon(Z, A, e, isoAmat, T, P), 0.0);
524 }
525 
526 
527 
531 
533 {
534  // Returns maximum energy (in MeV) for which range table is valid
535  // for given material and incident ion (Z,A)
536 
537  CHECK_ION_FIND_MAT_AND_EXEC(GetEmaxValid(Z, A), 0.0);
538 }
539 
540 
541 
542 
546 
548 {
549  // Return pointer to TGeoMaterial corresponding to this material,
550  // for use in ROOT geometries, VMC, etc.
551 
552  FIND_MAT_AND_EXEC(GetTGeoMaterial(), 0x0);
553 }
554 
555 
556 
558 
560 {
561  printf("%s::%s\n%s\n", ClassName(), GetName(), GetTitle());
562 }
563 
564 
565 
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:139
virtual const Char_t * GetType() const
Definition: KVBase.h:176
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Definition: KVBase.cpp:772
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 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 Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
Longptr_t ExecPlugin(int nargs)
double T(double x)
constexpr Double_t E()
ClassImp(TPyArg)