CMS 3D CMS Logo

DDMaterial Class Reference

DDMaterial is used to define and access material information. More...

#include <DetectorDescription/Core/interface/DDMaterial.h>

Inheritance diagram for DDMaterial:

DDBase< DDName, DDI::Material * >

List of all members.

Public Types

typedef std::vector< std::pair
< DDMaterial, double > > 
FractionV
 For mixtures of material Fraction defines the fraction-masses of the mixture components.

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, double density)
 Constructor for mixtures.
 DDMaterial (const DDName &name, double z, double a, double d)
 Constructor for construction of an elementary material.
 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).
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

Static Public Member Functions

static void clear ()
 clears the transient store

Friends

std::ostream & operator<< (std::ostream &, const DDMaterial &)


Detailed Description

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:

    DDMaterial hydrogen("Hydrogen", 
                        double z=1, 
                        double a=1.1*g/mole, 
                        density=2*g/cm3);

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 45 of file DDMaterial.h.


Member Typedef Documentation

typedef std::vector<std::pair<DDMaterial,double> > DDMaterial::FractionV

For mixtures of material Fraction defines the fraction-masses of the mixture components.

Definition at line 54 of file DDMaterial.h.


Constructor & Destructor Documentation

DDMaterial::DDMaterial (  ) 

Creates a uninitialized reference-object (see DDLogicalPart documentation for details on reference objects).

Definition at line 16 of file DDMaterial.cc.

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 27 of file DDMaterial.cc.

References DDI::Singleton< I >::instance(), and DDBase< DDName, DDI::Material * >::prep_.

00027                                           : DDBase<DDName,Material*>()
00028 { 
00029   prep_ = StoreT::instance().create(name);
00030 }

DDMaterial::DDMaterial ( const DDName name,
double  z,
double  a,
double  d 
)

Constructor for construction of an elementary material.

Example:
     DDMaterial hydrogen("Hydrogen", 
                          double z=1, 
                          double a=1.1*g/mole, 
                          density=2*g/cm3);

Definition at line 46 of file DDMaterial.cc.

References DDI::Singleton< I >::instance(), and DDBase< DDName, DDI::Material * >::prep_.

00047  : DDBase<DDName,Material*>()
00048 { 
00049   prep_ = StoreT::instance().create(name, new Material(z, a, d));
00050 }

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 65 of file DDMaterial.cc.

References DDI::Singleton< I >::instance(), and DDBase< DDName, DDI::Material * >::prep_.

00066  : DDBase<DDName,Material*>()
00067 { 
00068   prep_ = StoreT::instance().create(name, new Material(0,0,density));
00069 }


Member Function Documentation

double DDMaterial::a (  )  const

returns the atomic mass

Definition at line 103 of file DDMaterial.cc.

References DDBase< DDName, DDI::Material * >::rep().

Referenced by MaterialForOnline::beginJob(), DDG4Builder::convertMaterial(), DDCheckMaterial(), DDHtmlMaDetails::details(), DDDToPersFactory::material(), DDStreamer::materials_write(), and operator<<().

00104 {
00105   return rep().a(); 
00106 }

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 75 of file DDMaterial.cc.

References DCOUT, DDBase< N, C >::ddname(), DDBase< DDName, DDI::Material * >::ddname(), DDBase< DDName, DDI::Material * >::rep(), s, and DDBase< N, C >::toString().

Referenced by DDPersToDDDFactory::material(), DDStreamer::materials_read(), and DDLCompositeMaterial::processElement().

00076 {  
00077   if (m.ddname() == ddname()) {
00078     std::string s = std::string("DDMaterial::addMaterial(..): name-clash ") 
00079              + std::string("\n        trying to add material ") + m.toString() 
00080              + std::string(" to itself! ");
00081     throw DDException( s );
00082   }  
00083   rep().addMaterial(m,fm);
00084   DCOUT('c', std::string(" -> ADDED MATERIAL=") + m.toString() );
00085   return rep().noOfConstituents();
00086 }

void DDMaterial::clear ( void   )  [static]

clears the transient store

Reimplemented from DDBase< DDName, DDI::Material * >.

Definition at line 120 of file DDMaterial.cc.

References DDI::Singleton< I >::instance().

Referenced by DDCompactView::clear().

00121 {
00122   StoreT::instance().clear();
00123 }

DDMaterial::FractionV::value_type DDMaterial::constituent ( int  i  )  const

returns the i-th compound material and its fraction-mass

Definition at line 95 of file DDMaterial.cc.

References DDBase< DDName, DDI::Material * >::rep().

Referenced by MaterialForOnline::beginJob(), DDG4Builder::convertMaterial(), DDHtmlMaDetails::details(), DDDToPersFactory::material(), DDStreamer::materials_write(), and operator<<().

00096 { 
00097   //const DDMaterialImpl::Fraction & f(rep().constituent(i));
00098   //return std::make_pair(DDMaterial(f.first,true), f.second);  
00099   return rep().constituent(i);
00100 }

double DDMaterial::density (  )  const

returns the density

Definition at line 115 of file DDMaterial.cc.

References DDBase< DDName, DDI::Material * >::rep().

Referenced by MaterialForOnline::beginJob(), DDG4Builder::convertMaterial(), DDCheckMaterial(), DDHtmlMaDetails::details(), DDDToPersFactory::material(), DDStreamer::materials_write(), operator<<(), and DDCompactViewImpl::weight().

00116 {
00117   return rep().density(); 
00118 }

int DDMaterial::noOfConstituents (  )  const

returns the number of compound materials or 0 for elementary materials

Definition at line 89 of file DDMaterial.cc.

References DDBase< DDName, DDI::Material * >::rep().

Referenced by MaterialForOnline::beginJob(), DDG4Builder::convertMaterial(), DDCheckMaterial(), DDHtmlMaDetails::details(), DDDToPersFactory::material(), DDStreamer::materials_write(), and operator<<().

00090 {
00091    return rep().noOfConstituents();
00092 }

double DDMaterial::z (  )  const

retruns the atomic number

Definition at line 109 of file DDMaterial.cc.

References DDBase< DDName, DDI::Material * >::rep().

Referenced by MaterialForOnline::beginJob(), DDG4Builder::convertMaterial(), DDCheckMaterial(), DDHtmlMaDetails::details(), DDDToPersFactory::material(), DDStreamer::materials_write(), and operator<<().

00110 {
00111   return rep().z(); 
00112 }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const DDMaterial mat 
) [friend]

Definition at line 132 of file DDMaterial.cc.

00133 { 
00134   static int level=0;
00135   ++level; 
00136   if (mat) {
00137     os << '[' << mat.name() <<']' << " z=" << mat.z() 
00138                      << " a=" << mat.a()/g*mole << "*g/mole" 
00139                      << " d=" << mat.density()/g*cm3 << "*g/cm3";
00140     std::string s(2*level,' ');              
00141     for (int i=0; i<mat.noOfConstituents(); ++i) {
00142        DDMaterial::FractionV::value_type f = mat.constituent(i);
00143        os << std::endl << s << i+1 << " : fm=" << f.second 
00144                   << " : " << f.first;
00145     }                
00146     //--level;
00147   } 
00148   else
00149     os << "* material not declared * ";  
00150   --level;   
00151   return os;
00152 }


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:18:10 2009 for CMSSW by  doxygen 1.5.4