CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDMaterial.cc
Go to the documentation of this file.
2 #include "CLHEP/Units/GlobalSystemOfUnits.h"
5 
6 using DDI::Material;
7 
8 
9 //DDBase<DDName,Material*>::StoreT::pointer_type
10 // DDBase<DDName,Material*>::StoreT::instance_ = 0;
11 
12 
14 
15 
25 {
26  prep_ = StoreT::instance().create(name);
27 }
28 
29 
43 DDMaterial::DDMaterial(const DDName & name, double z, double a, double d)
44  : DDBase<DDName,Material*>()
45 {
46  prep_ = StoreT::instance().create(name, new Material(z, a, d));
47 }
48 
49 
62 DDMaterial::DDMaterial(const DDName & name, double density)
63  : DDBase<DDName,Material*>()
64 {
65  prep_ = StoreT::instance().create(name, new Material(0,0,density));
66 }
67 
68 
72 int DDMaterial::addMaterial(const DDMaterial & m, double fm)
73 {
74  if (m.ddname() == ddname()) {
75  throw cms::Exception("DDException") << "DDMaterial::addMaterial(..): name-clash\n trying to add material " << m << " to itself! ";
76  }
77  rep().addMaterial(m,fm);
78  DCOUT('c', std::string(" -> ADDED MATERIAL=") + m.toString() );
79  return rep().noOfConstituents();
80 }
81 
82 
84 {
85  return rep().noOfConstituents();
86 }
87 
88 
90 {
91  //const DDMaterialImpl::Fraction & f(rep().constituent(i));
92  //return std::make_pair(DDMaterial(f.first,true), f.second);
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 // void DDMaterial::clear()
115 // {
116 // StoreT::instance().clear();
117 // }
118 // private ctor for internal use
119 //DDMaterial::DDMaterial(DDRedirect<DDMaterialImpl>* p, bool dummy)
120 // : DDRegistered<DDMaterialImpl>(p,true)
121 //{
122 // DCOUT_V('C',"DC: (redir) init=" << rep_ );
123 //}
124 
125 
126 std::ostream & operator<<(std::ostream & os, const DDMaterial & mat)
127 {
128  static int level=0;
129  ++level;
130  if (mat) {
131  os << '[' << mat.name() <<']' << " z=" << mat.z()
132  << " a=" << mat.a()/g*mole << "*g/mole"
133  << " d=" << mat.density()/g*cm3 << "*g/cm3";
134  std::string s(2*level,' ');
135  for (int i=0; i<mat.noOfConstituents(); ++i) {
137  os << std::endl << s << i+1 << " : fm=" << f.second
138  << " : " << f.first;
139  }
140  //--level;
141  }
142  else
143  os << "* material not declared * ";
144  --level;
145  return os;
146 }
147 
Definition: DDBase.h:14
double a() const
returns the atomic mass
Definition: DDMaterial.cc:97
int i
Definition: DBlmapReader.cc:9
const DDI::rep_traits< DDName, DDI::Material * >::reference rep() const
Definition: DDBase.h:89
const N & name() const
Definition: DDBase.h:82
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:13
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:18
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
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
double double double z
int addMaterial(const DDMaterial &m, double fm)
adds a material to the mixture proportional to its fraction-mass fm.
Definition: DDMaterial.cc:72
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:89
double f[11][100]
Container::value_type value_type
std::string toString() const
Definition: DDBase.h:86
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:83
double a
Definition: hdecay.h:121
tuple level
Definition: testEve_cfg.py:34
#define DCOUT(M_v_Y, M_v_S)
Definition: DDdebug.h:53
const N & ddname() const
Definition: DDBase.h:84