StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StiMaterial.cxx
1 //StiMaterials.h
2 //M.L. Miller (Yale Software)
3 //04/01
4 
5 //#include "StGetConfigValue.hh"
6 #include <assert.h>
7 #include <string.h>
8 #include <stdexcept>
9 #include "Sti/StiMaterial.h"
10 #include "Sti/StiElossCalculator.h"
11 
12 StiMaterial::StiMaterial(){
13 } // StiMaterial()
14 
15 StiMaterial::StiMaterial(const string &name,
16  double z,
17  double a,
18  double density,
19  double radLength,
20  double ionization)
21 {
22  _eloss = 0;
23  set(name,z,a,density,radLength,ionization);
24 }
25 
26 StiMaterial::StiMaterial(const string &name,
27  double z,
28  double a,
29  double density,
30  double X0)
31 {
32  _eloss = 0;
33  set(name,z,a,density,X0);
34 }
35 
36 StiMaterial::~StiMaterial()
37 {
38  delete _eloss; _eloss = 0;
39 
40 } // ~StiMaterial()
41 
50 void StiMaterial::set(const string& name,
51  double z,
52  double a,
53  double density,
54  double radLength,//X0*density
55  double ionization)
56 {
57  setName(name);
58  _density = density;
59  _a = a;
60  _z = z;
61  _ionization = ionization;
62  _x0 = (_density>0)? radLength/density : 1e11;
63  _zOverA = (_a>0)? _z/_a : 0;
64  delete _eloss; _eloss = 0;
65  if (z>0)
66  _eloss = new StiElossCalculator(_zOverA, ionization,_a,_z,_density);
67  assert(_x0>0);
68 
69 }
70 
71 void StiMaterial::set(const string& name,
72  double z,
73  double a,
74  double density,
75  double X0)
76 {
77  setName(name);
78  _density = density;
79  _a = a;
80  _z = z;
81  _x0 = X0;
82  _zOverA = (_a>0)? _z/_a : 0;
83  delete _eloss; _eloss = 0;
84  if (z>0)
86  assert(_x0>0);
87 
88 
89 }
90 ostream& operator<<(ostream& os, const StiMaterial& m)
91 {
92  os << "StiMaterial:" << endl
93  << "Name:" << m.getName()
94  << " Density:" << m.getDensity()<< " g/cm^3"
95  << " X0:" <<m.getX0()
96  << " Z: " <<m.getZ()
97  << " A: " <<m.getA()
98  << endl;
99 
100  return os;
101 }
103 { if (_eloss) return _eloss;
104  assert(strstr(getName().c_str(),"Vac"));
105  return 0;
106 }
StiElossCalculator * _eloss
Keep Energy loss calculator.
Definition: StiMaterial.h:77
double _density
g/cm^3
Definition: StiMaterial.h:69
double _a
Effective A.
Definition: StiMaterial.h:67
StiElossCalculator * getElossCalculator() const
Get Eloss calculator.
double getA() const
Get the effective atomic mass of the material.
Definition: StiMaterial.h:39
double _x0
radiation length in cm.
Definition: StiMaterial.h:75
void set(const string &name, double z, double a, double density, double radLength, double ionization)
Definition: StiMaterial.cxx:50
double getZ() const
Get the effective atomic number of the material.
Definition: StiMaterial.h:41
double _ionization
Effective ionization (in eV)
Definition: StiMaterial.h:71
double _zOverA
zOverA
Definition: StiMaterial.h:73
double getX0() const
Get the radiation length in centimeter.
Definition: StiMaterial.h:37
double getIonization() const
Dummy method.
Definition: StiMaterial.h:45
void setName(const string &newName)
Set the name of the object.
Definition: Named.cxx:15
double getDensity() const
Get the material density in grams/cubic centimeter.
Definition: StiMaterial.h:35
double _z
Effective Z.
Definition: StiMaterial.h:65
const string & getName() const
Get the name of the object.
Definition: Named.cxx:22