DDMaterial is used to define and access material information. More...
#include <DDMaterial.h>
Public Types | |
typedef std::vector< std::pair < DDMaterial, double > > | FractionV |
Public Member Functions | |
double | a () const |
returns the atomic mass | |
int | addMaterial (const DDMaterial &m, double fm) |
adds a material to the mixture proportional to its fraction-mass fm. | |
FractionV::value_type | constituent (int i) const |
returns the i-th compound material and its fraction-mass | |
DDMaterial (const DDName &name) | |
Creates a initialized reference-object or a reference to an allready defined material. | |
DDMaterial () | |
Creates a uninitialized reference-object (see DDLogicalPart documentation for details on reference objects) | |
DDMaterial (const DDName &name, double density) | |
Constructor for mixtures. | |
DDMaterial (const DDName &name, double z, double a, double d) | |
Constructor for construction of an elementary material. | |
double | density () const |
returns the density | |
int | noOfConstituents () const |
returns the number of compound materials or 0 for elementary materials | |
double | z () const |
retruns the atomic number | |
Friends | |
std::ostream & | operator<< (std::ostream &, const DDMaterial &) |
DDMaterial is used to define and access material information.
An object of this class is a reference-object and thus leightweighted. It is uniquely identified by its DDName. Further details concerning reference-objects can be found in the documentation of DDLogicalPart.
A DDMaterial can recursively consist of compound materials (which are DDMaterials as well). Materials consisting of compound materials are called mixtures. Mixtures are defined by their Materials which do not consist of compound materials are called elementary materials.
To define an elementray material, use it like this:
To define a mixture:
DDMaterial mixt("Mix", double density = 5*g/cm3); mixt.addMaterial(hydrogen,0.3); // code for additional compounds belonging to the mixture ...
Note the usage of CLHEP/SystemOfUnits to specify the units of the quantities making up a material.
Definition at line 41 of file DDMaterial.h.
typedef std::vector<std::pair<DDMaterial,double> > DDMaterial::FractionV |
Definition at line 46 of file DDMaterial.h.
DDMaterial::DDMaterial | ( | ) |
Creates a uninitialized reference-object (see DDLogicalPart documentation for details on reference objects)
Definition at line 13 of file DDMaterial.cc.
: DDBase<DDName,Material*>() { }
DDMaterial::DDMaterial | ( | const DDName & | name | ) |
Creates a initialized reference-object or a reference to an allready defined material.
If a DDMaterial with name was already defined, this constructor creates a reference object to the defined material. Otherwise it creates a (default) initialized reference-object to a material with DDName name.
For further details concerning the usage of reference-objects refere to the documentation of DDLogicalPart.
Definition at line 24 of file DDMaterial.cc.
References DDI::Singleton< I >::instance(), and DDBase< DDName, DDI::Material * >::prep_.
: DDBase<DDName,Material*>() { prep_ = StoreT::instance().create(name); }
DDMaterial::DDMaterial | ( | const DDName & | name, |
double | z, | ||
double | a, | ||
double | d | ||
) |
Constructor for construction of an elementary material.
z
atomic number a
atomic mass density
densityExample:
Definition at line 43 of file DDMaterial.cc.
References DDI::Singleton< I >::instance(), and DDBase< DDName, DDI::Material * >::prep_.
: DDBase<DDName,Material*>() { prep_ = StoreT::instance().create(name, new Material(z, a, d)); }
DDMaterial::DDMaterial | ( | const DDName & | name, |
double | density | ||
) |
Constructor for mixtures.
For a mixture material it is sufficient to specify the density of the mixture (in addition to the name). The compounds are added by using the addMaterial(..) method.
The result of this constructor is a reference-object. One can use the mixture material immidiately (without specifying the compund materials). Compound materials can be added at any later stage.
For further details concerning the usage of reference-objects refere to the documentation of DDLogicalPart.
Definition at line 62 of file DDMaterial.cc.
References DDI::Singleton< I >::instance(), and DDBase< DDName, DDI::Material * >::prep_.
: DDBase<DDName,Material*>() { prep_ = StoreT::instance().create(name, new Material(0,0,density)); }
double DDMaterial::a | ( | ) | const |
returns the atomic mass
Definition at line 97 of file DDMaterial.cc.
References DDBase< DDName, DDI::Material * >::rep().
Referenced by MaterialForOnline::beginRun(), DDG4Builder::convertMaterial(), TGeoMgrFromDdd::createMaterial(), TGeoFromDddService::createMaterial(), DDCheckMaterial(), DDCoreToDDXMLOutput::material(), DDStreamer::materials_write(), and operator<<().
{ return rep().a(); }
int DDMaterial::addMaterial | ( | const DDMaterial & | m, |
double | fm | ||
) |
adds a material to the mixture proportional to its fraction-mass fm.
The fraction-masses of all compounds must sum up to 1
Definition at line 72 of file DDMaterial.cc.
References DCOUT, DDBase< N, C >::ddname(), DDBase< DDName, DDI::Material * >::ddname(), Exception, DDBase< DDName, DDI::Material * >::rep(), and DDBase< N, C >::toString().
Referenced by DDStreamer::materials_read(), DDLCompositeMaterial::processElement(), and regressionTest_setup().
DDMaterial::FractionV::value_type DDMaterial::constituent | ( | int | i | ) | const |
returns the i-th compound material and its fraction-mass
Definition at line 89 of file DDMaterial.cc.
References DDBase< DDName, DDI::Material * >::rep().
Referenced by OutputDDToDDL::addToMatStore(), MaterialForOnline::beginRun(), DDG4Builder::convertMaterial(), TGeoMgrFromDdd::createMaterial(), TGeoFromDddService::createMaterial(), DDCheckMaterial(), DDCoreToDDXMLOutput::material(), DDStreamer::materials_write(), and operator<<().
double DDMaterial::density | ( | ) | const |
returns the density
Definition at line 109 of file DDMaterial.cc.
References DDBase< DDName, DDI::Material * >::rep().
Referenced by MaterialForOnline::beginRun(), DDG4Builder::convertMaterial(), TGeoMgrFromDdd::createMaterial(), TGeoFromDddService::createMaterial(), DDCheckMaterial(), DDCoreToDDXMLOutput::material(), DDStreamer::materials_write(), operator<<(), and DDCompactViewImpl::weight().
{ return rep().density(); }
int DDMaterial::noOfConstituents | ( | ) | const |
returns the number of compound materials or 0 for elementary materials
Definition at line 83 of file DDMaterial.cc.
References DDBase< DDName, DDI::Material * >::rep().
Referenced by OutputDDToDDL::addToMatStore(), MaterialForOnline::beginRun(), DDG4Builder::convertMaterial(), TGeoMgrFromDdd::createMaterial(), TGeoFromDddService::createMaterial(), DDCheckMaterial(), DDCoreToDDXMLOutput::material(), DDStreamer::materials_write(), and operator<<().
{ return rep().noOfConstituents(); }
double DDMaterial::z | ( | ) | const |
retruns the atomic number
Definition at line 103 of file DDMaterial.cc.
References DDBase< DDName, DDI::Material * >::rep().
Referenced by MaterialForOnline::beginRun(), DDG4Builder::convertMaterial(), TGeoMgrFromDdd::createMaterial(), TGeoFromDddService::createMaterial(), DDCheckMaterial(), DDCoreToDDXMLOutput::material(), DDStreamer::materials_write(), and operator<<().
{ return rep().z(); }
std::ostream& operator<< | ( | std::ostream & | os, |
const DDMaterial & | mat | ||
) | [friend] |
Definition at line 126 of file DDMaterial.cc.
{ static int level=0; ++level; if (mat) { os << '[' << mat.name() <<']' << " z=" << mat.z() << " a=" << mat.a()/g*mole << "*g/mole" << " d=" << mat.density()/g*cm3 << "*g/cm3"; std::string s(2*level,' '); for (int i=0; i<mat.noOfConstituents(); ++i) { DDMaterial::FractionV::value_type f = mat.constituent(i); os << std::endl << s << i+1 << " : fm=" << f.second << " : " << f.first; } //--level; } else os << "* material not declared * "; --level; return os; }