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 
27 {
28  prep_ = StoreT::instance().create(name);
29 }
30 
31 
45 DDMaterial::DDMaterial(const DDName & name, double z, double a, double d)
46  : DDBase<DDName,Material*>()
47 {
48  prep_ = StoreT::instance().create(name, new Material(z, a, d));
49 }
50 
51 
65  : DDBase<DDName,Material*>()
66 {
67  prep_ = StoreT::instance().create(name, new Material(0,0,density));
68 }
69 
70 
74 int DDMaterial::addMaterial(const DDMaterial & m, double fm)
75 {
76  if (m.ddname() == ddname()) {
77  throw cms::Exception("DDException") << "DDMaterial::addMaterial(..): name-clash\n trying to add material " << m << " to itself! ";
78  }
79  rep().addMaterial(m,fm);
80  return rep().noOfConstituents();
81 }
82 
83 
85 {
86  return rep().noOfConstituents();
87 }
88 
89 
91 {
92  return rep().constituent(i);
93 }
94 
95 
96 double DDMaterial::a() const
97 {
98  return rep().a();
99 }
100 
101 
102 double DDMaterial::z() const
103 {
104  return rep().z();
105 }
106 
107 
108 double DDMaterial::density() const
109 {
110  return rep().density();
111 }
112 
113 namespace {
114  std::ostream &doStream(std::ostream & os, const DDMaterial & mat, int level)
115  {
116  ++level;
117  if (mat) {
118  os << '[' << mat.name() <<']' << " z=" << mat.z()
119  << " a=" << mat.a()/g*mole << "*g/mole"
120  << " d=" << mat.density()/g*cm3 << "*g/cm3";
121  std::string s(2*level,' ');
122  for (int i=0; i<mat.noOfConstituents(); ++i) {
124  os << std::endl << s << i+1 << " : fm=" << f.second
125  << " : ";
126  doStream(os, f.first, level);
127  }
128  }
129  else
130  os << "* material not declared * ";
131  --level;
132  return os;
133  }
134 }
135 
136 std::ostream & operator<<(std::ostream & os, const DDMaterial & mat)
137 {
138  return doStream(os, mat, 0);
139 }
140 
Definition: DDBase.h:10
double a() const
returns the atomic mass
Definition: DDMaterial.cc:96
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:74
static value_type & instance()
double z() const
retruns the atomic number
Definition: DDMaterial.cc:102
FractionV::value_type constituent(int i) const
returns the i-th compound material and its fraction-mass
Definition: DDMaterial.cc:90
double f[11][100]
double density() const
returns the density
Definition: DDMaterial.cc:108
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
Definition: DDMaterial.cc:84
friend std::ostream & operator<<(std::ostream &, const DDMaterial &)
Definition: DDMaterial.cc:136
const N & ddname() const
Definition: DDBase.h:80