Go to the documentation of this file.00001 #include "DetectorDescription/Base/interface/DDdebug.h"
00002 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00003 #include "DetectorDescription/Core/interface/DDMaterial.h"
00004 #include "DetectorDescription/Core/src/Material.h"
00005
00006 using DDI::Material;
00007
00008
00009
00010
00011
00012
00013 DDMaterial::DDMaterial() : DDBase<DDName,Material*>() { }
00014
00015
00024 DDMaterial::DDMaterial(const DDName & name) : DDBase<DDName,Material*>()
00025 {
00026 prep_ = StoreT::instance().create(name);
00027 }
00028
00029
00043 DDMaterial::DDMaterial(const DDName & name, double z, double a, double d)
00044 : DDBase<DDName,Material*>()
00045 {
00046 prep_ = StoreT::instance().create(name, new Material(z, a, d));
00047 }
00048
00049
00062 DDMaterial::DDMaterial(const DDName & name, double density)
00063 : DDBase<DDName,Material*>()
00064 {
00065 prep_ = StoreT::instance().create(name, new Material(0,0,density));
00066 }
00067
00068
00072 int DDMaterial::addMaterial(const DDMaterial & m, double fm)
00073 {
00074 if (m.ddname() == ddname()) {
00075 throw cms::Exception("DDException") << "DDMaterial::addMaterial(..): name-clash\n trying to add material " << m << " to itself! ";
00076 }
00077 rep().addMaterial(m,fm);
00078 DCOUT('c', std::string(" -> ADDED MATERIAL=") + m.toString() );
00079 return rep().noOfConstituents();
00080 }
00081
00082
00083 int DDMaterial::noOfConstituents() const
00084 {
00085 return rep().noOfConstituents();
00086 }
00087
00088
00089 DDMaterial::FractionV::value_type DDMaterial::constituent(int i) const
00090 {
00091
00092
00093 return rep().constituent(i);
00094 }
00095
00096
00097 double DDMaterial::a() const
00098 {
00099 return rep().a();
00100 }
00101
00102
00103 double DDMaterial::z() const
00104 {
00105 return rep().z();
00106 }
00107
00108
00109 double DDMaterial::density() const
00110 {
00111 return rep().density();
00112 }
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 std::ostream & operator<<(std::ostream & os, const DDMaterial & mat)
00127 {
00128 static int level=0;
00129 ++level;
00130 if (mat) {
00131 os << '[' << mat.name() <<']' << " z=" << mat.z()
00132 << " a=" << mat.a()/g*mole << "*g/mole"
00133 << " d=" << mat.density()/g*cm3 << "*g/cm3";
00134 std::string s(2*level,' ');
00135 for (int i=0; i<mat.noOfConstituents(); ++i) {
00136 DDMaterial::FractionV::value_type f = mat.constituent(i);
00137 os << std::endl << s << i+1 << " : fm=" << f.second
00138 << " : " << f.first;
00139 }
00140
00141 }
00142 else
00143 os << "* material not declared * ";
00144 --level;
00145 return os;
00146 }
00147