24#include "TGeoMaterial.h"
28const double RootGM::Material::fgkVacuumDensity = 1.e-25;
29const double RootGM::Material::fgkVacuumTemperature = 2.73;
30const double RootGM::Material::fgkVacuumPressure = 2.96077e-23;
35 :
VGM::IMaterial(), fMaterial(0), fElements()
47 std::cerr <<
" RootGM::Material::Material: " << std::endl;
48 std::cerr <<
" No element defined.";
49 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
55 if (density < fgkVacuumDensity || element->Z() < 1.0) {
56 fMaterial =
new TGeoMaterial(name.data(), element->
A(), element->
Z(),
58 TGeoMaterial::kMatStateGas, fgkVacuumTemperature,
62 fMaterial =
new TGeoMaterial(name.data(), element->
A(), element->
Z(),
67 fElements.push_back(element);
70 fMaterial->SetRadLen(radlen, intlen);
80 :
VGM::IMaterial(), fMaterial(0), fElements()
94 std::cerr <<
" RootGM::Material::Material: " << std::endl;
95 std::cerr <<
" No element defined.";
96 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
102 if (density < fgkVacuumDensity || element->Z() < 1.0) {
103 fMaterial =
new TGeoMaterial(name.data(), element->
A(), element->
Z(),
105 TGeoMaterial::kMatStateGas,
110 fMaterial =
new TGeoMaterial(name.data(), element->
A(), element->
Z(),
117 fElements.push_back(element);
120 fMaterial->SetRadLen(radlen, intlen);
129 :
VGM::IMaterial(), fMaterial(0), fElements()
140 if (!elements.size()) {
141 std::cerr <<
" RootGM::Material::Material: " << std::endl;
142 std::cerr <<
" No elements defined.";
143 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
148 if (elements.size() != fractions.size()) {
149 std::cerr <<
" RootGM::Material::Material: " << std::endl;
150 std::cerr <<
" Elements size and fractions size differ." << std::endl;
151 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
155 fMaterial =
new TGeoMixture(
158 TGeoMixture* mixture = (TGeoMixture*)fMaterial;
161 for (UInt_t i = 0; i < elements.size(); i++) {
163 mixture->AddElement(element->
A(), element->
Z(), fractions[i]);
164 fElements.push_back(element);
175 :
VGM::IMaterial(), fMaterial(0), fElements()
189 if (!elements.size()) {
190 std::cerr <<
" RootGM::Material::Material: " << std::endl;
191 std::cerr <<
" No elements defined.";
192 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
197 if (elements.size() != fractions.size()) {
198 std::cerr <<
" RootGM::Material::Material: " << std::endl;
199 std::cerr <<
" Elements size and fractions size differ." << std::endl;
200 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
204 fMaterial =
new TGeoMixture(
207 fMaterial->SetState(GetGeoState(state));
211 TGeoMixture* mixture = (TGeoMixture*)fMaterial;
214 for (UInt_t i = 0; i < elements.size(); i++) {
216 mixture->AddElement(element->
A(), element->
Z(), fractions[i]);
217 fElements.push_back(element);
227 :
VGM::IMaterial(), fMaterial(0), fElements()
238 if (!elements.size()) {
239 std::cerr <<
" RootGM::Material::Material: " << std::endl;
240 std::cerr <<
" No elements defined.";
241 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
246 if (elements.size() != atomCounts.size()) {
247 std::cerr <<
" RootGM::Material::Material: " << std::endl;
248 std::cerr <<
" Elements size and atomCounts size differ." << std::endl;
249 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
253 fMaterial =
new TGeoMixture(
256 TGeoMixture* mixture = (TGeoMixture*)fMaterial;
263 for (
unsigned i = 0; i < elements.size(); i++)
264 amol += elements[i]->A() * atomCounts[i];
267 for (
unsigned i = 0; i < elements.size(); i++) {
269 double fraction = atomCounts[i] * element->
A() / amol;
270 mixture->AddElement(element->
A(), element->
Z(), fraction);
271 fElements.push_back(element);
282 :
VGM::IMaterial(), fMaterial(0), fElements()
293 if (!elements.size()) {
294 std::cerr <<
" RootGM::Material::Material: " << std::endl;
295 std::cerr <<
" No elements defined.";
296 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
301 if (elements.size() != atomCounts.size()) {
302 std::cerr <<
" RootGM::Material::Material: " << std::endl;
303 std::cerr <<
" Elements size and atomCounts size differ." << std::endl;
304 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
308 fMaterial =
new TGeoMixture(
311 fMaterial->SetState(GetGeoState(state));
315 TGeoMixture* mixture = (TGeoMixture*)fMaterial;
322 for (
unsigned i = 0; i < elements.size(); i++)
323 amol += elements[i]->A() * atomCounts[i];
326 for (UInt_t i = 0; i < elements.size(); i++) {
328 double fraction = atomCounts[i] * element->
A() / amol;
329 mixture->AddElement(element->
A(), element->
Z(), fraction);
330 fElements.push_back(element);
340 :
VGM::IMaterial(), fMaterial(material), fElements(elements)
356 :
VGM::IMaterial(rhs), fMaterial(rhs.fMaterial), fElements(rhs.fElements)
372void RootGM::Material::CheckIndex(
int iel)
const
374 if (iel < 0 || iel >= NofElements()) {
375 std::cerr <<
" RootGM::Material::CheckIndex: " << std::endl;
376 std::cerr <<
" Index of element outside limits." << std::endl;
377 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
384TGeoMaterial::EGeoMaterialState RootGM::Material::GetGeoState(
389 return TGeoMaterial::kMatStateUndefined;
391 return TGeoMaterial::kMatStateSolid;
393 return TGeoMaterial::kMatStateLiquid;
395 return TGeoMaterial::kMatStateGas;
397 return TGeoMaterial::kMatStateUndefined;
400 return TGeoMaterial::kMatStateUndefined;
405 TGeoMaterial::EGeoMaterialState state)
const
408 case TGeoMaterial::kMatStateUndefined:
410 case TGeoMaterial::kMatStateSolid:
412 case TGeoMaterial::kMatStateLiquid:
414 case TGeoMaterial::kMatStateGas:
430 return std::string(fMaterial->GetName());
454 return GetVGMState(fMaterial->GetState());
472 if (!fMaterial->IsMixture())
475 return ((TGeoMixture*)fMaterial)->GetNelements();
483 return fElements[iel];
491 if (!fMaterial->IsMixture())
494 return ((TGeoMixture*)fMaterial)->GetWmixt()[iel];
502 if (NofElements() == 1)
return 1.0;
506 std::cerr <<
"RootGM::Material::AtomCount is not implemented" << std::endl;
void AddMaterial(VGM::IMaterial *, TGeoMaterial *)
static MaterialMap * Instance()
VGM implementation for Root material.
virtual double Density() const
Return the density in g/cm3.
virtual double NuclearInterLength() const
Return the nuclear interaction length in mm.
virtual double Temperature() const
Return the temperature in kelvins.
virtual std::string Name() const
Return the name of this element.
virtual double Pressure() const
Return the density in atmosphere.
virtual double RadiationLength() const
Return the radiation length in mm.
virtual VGM::MaterialState State() const
Return the material state.
virtual VGM::IElement * Element(int iel) const
Return the i-th element constituing this material.
virtual double AtomCount(int iel) const
Return the atom count of the i-th element constituing this material.
virtual int NofElements() const
Return the number of elements constituing this material.
virtual double MassFraction(int iel) const
Return the mass fraction of the i-th element constituing this material.
static double Pressure()
Return Root pressure unit in VGM unit.
static double Length()
Return Root length unit in VGM units.
static double MassDensity()
Return Root mass density unit in VGM units.
static double Temperature()
Return Root temperature unit in VGM unit.
The VGM interface to elements.
virtual double Z() const =0
Return the effective atomic number.
virtual double A() const =0
Return the effective effective mass of a mole in g/mole.
std::vector< int > AtomCountVector
std::vector< double > MassFractionVector
std::vector< IElement * > ElementVector
@ kLiquid
Liquid material.
@ kUndefined
Undefined material state.