CMS 3D CMS Logo

Public Types | Public Member Functions | Friends

DDMaterial Class Reference

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

#include <DDMaterial.h>

Inheritance diagram for DDMaterial:
DDBase< DDName, DDI::Material * >

List of all members.

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 &)

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


Member Typedef Documentation

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

Definition at line 46 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 13 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 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 density

Example:

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

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));
}

Member Function Documentation

double DDMaterial::a ( ) const
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().

{  
  if (m.ddname() == ddname()) {
    throw cms::Exception("DDException") << "DDMaterial::addMaterial(..): name-clash\n        trying to add material " << m << " to itself! ";
  }  
  rep().addMaterial(m,fm);
  DCOUT('c', std::string(" -> ADDED MATERIAL=") + m.toString() );
  return rep().noOfConstituents();
}
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<<().

{ 
  //const DDMaterialImpl::Fraction & f(rep().constituent(i));
  //return std::make_pair(DDMaterial(f.first,true), f.second);  
  return rep().constituent(i);
}
double DDMaterial::density ( ) const
int DDMaterial::noOfConstituents ( ) const
double DDMaterial::z ( ) const

Friends And Related Function Documentation

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;
}