CMS 3D CMS Logo

DDMaterial.cc
Go to the documentation of this file.
1 #include <ostream>
2 #include <string>
3 #include <vector>
4 
5 #include "CLHEP/Units/GlobalSystemOfUnits.h"
6 #include "CLHEP/Units/SystemOfUnits.h"
13 
14 using DDI::Material;
15 
17 
18 
28 {
29  prep_ = StoreT::instance().create(name);
30 }
31 
32 
46 DDMaterial::DDMaterial(const DDName & name, double z, double a, double d)
47  : DDBase<DDName,Material*>()
48 {
49  prep_ = StoreT::instance().create(name, new Material(z, a, d));
50 }
51 
52 
66  : DDBase<DDName,Material*>()
67 {
68  prep_ = StoreT::instance().create(name, new Material(0,0,density));
69 }
70 
71 
75 int DDMaterial::addMaterial(const DDMaterial & m, double fm)
76 {
77  if (m.ddname() == ddname()) {
78  throw cms::Exception("DDException") << "DDMaterial::addMaterial(..): name-clash\n trying to add material " << m << " to itself! ";
79  }
80  rep().addMaterial(m,fm);
81  return rep().noOfConstituents();
82 }
83 
84 
86 {
87  return rep().noOfConstituents();
88 }
89 
90 
92 {
93  return rep().constituent(i);
94 }
95 
96 
97 double DDMaterial::a() const
98 {
99  return rep().a();
100 }
101 
102 
103 double DDMaterial::z() const
104 {
105  return rep().z();
106 }
107 
108 
109 double DDMaterial::density() const
110 {
111  return rep().density();
112 }
113 
114 namespace {
115  std::ostream &doStream(std::ostream & os, const DDMaterial & mat, int level)
116  {
117  ++level;
118  if (mat) {
119  os << '[' << mat.name() <<']' << " z=" << mat.z()
120  << " a=" << mat.a()/g*mole << "*g/mole"
121  << " d=" << mat.density()/g*cm3 << "*g/cm3";
122  std::string s(2*level,' ');
123  for (int i=0; i<mat.noOfConstituents(); ++i) {
125  os << std::endl << s << i+1 << " : fm=" << f.second
126  << " : ";
127  doStream(os, f.first, level);
128  }
129  }
130  else
131  os << "* material not declared * ";
132  --level;
133  return os;
134  }
135 }
136 
137 std::ostream & operator<<(std::ostream & os, const DDMaterial & mat)
138 {
139  return doStream(os, mat, 0);
140 }
141 
Definition: DDBase.h:10
double a() const
returns the atomic mass
Definition: DDMaterial.cc:97
const DDI::rep_traits< DDName, DDI::Material * >::reference rep() const
Definition: DDBase.h:84
const DDName & name() const
Definition: DDBase.h:78
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
DDMaterial()
Creates a uninitialized reference-object (see DDLogicalPart documentation for details on reference ob...
Definition: DDMaterial.cc:16
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
int addMaterial(const DDMaterial &m, double fm)
adds a material to the mixture proportional to its fraction-mass fm.
Definition: DDMaterial.cc:75
static value_type & instance()
double z() const
retruns the atomic number
Definition: DDMaterial.cc:103
FractionV::value_type constituent(int i) const
returns the i-th compound material and its fraction-mass
Definition: DDMaterial.cc:91
double f[11][100]
double density() const
returns the density
Definition: DDMaterial.cc:109
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
Definition: DDMaterial.cc:85
friend std::ostream & operator<<(std::ostream &, const DDMaterial &)
Definition: DDMaterial.cc:137
const N & ddname() const
Definition: DDBase.h:80