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.
1 
3 #include "CLHEP/Units/GlobalSystemOfUnits.h"
7 
8 
9 using DDI::Material;
10 
11 
12 //DDBase<DDName,Material*>::StoreT::pointer_type
13 // DDBase<DDName,Material*>::StoreT::instance_ = 0;
14 
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 
65 DDMaterial::DDMaterial(const DDName & name, double density)
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  std::string s = std::string("DDMaterial::addMaterial(..): name-clash ")
79  + std::string("\n trying to add material ") + m.toString()
80  + std::string(" to itself! ");
81  throw DDException( s );
82  }
83  rep().addMaterial(m,fm);
84  DCOUT('c', std::string(" -> ADDED MATERIAL=") + m.toString() );
85  return rep().noOfConstituents();
86 }
87 
88 
90 {
91  return rep().noOfConstituents();
92 }
93 
94 
96 {
97  //const DDMaterialImpl::Fraction & f(rep().constituent(i));
98  //return std::make_pair(DDMaterial(f.first,true), f.second);
99  return rep().constituent(i);
100 }
101 
102 
103 double DDMaterial::a() const
104 {
105  return rep().a();
106 }
107 
108 
109 double DDMaterial::z() const
110 {
111  return rep().z();
112 }
113 
114 
115 double DDMaterial::density() const
116 {
117  return rep().density();
118 }
119 
120 // void DDMaterial::clear()
121 // {
122 // StoreT::instance().clear();
123 // }
124 // private ctor for internal use
125 //DDMaterial::DDMaterial(DDRedirect<DDMaterialImpl>* p, bool dummy)
126 // : DDRegistered<DDMaterialImpl>(p,true)
127 //{
128 // DCOUT_V('C',"DC: (redir) init=" << rep_ );
129 //}
130 
131 
132 std::ostream & operator<<(std::ostream & os, const DDMaterial & mat)
133 {
134  static int level=0;
135  ++level;
136  if (mat) {
137  os << '[' << mat.name() <<']' << " z=" << mat.z()
138  << " a=" << mat.a()/g*mole << "*g/mole"
139  << " d=" << mat.density()/g*cm3 << "*g/cm3";
140  std::string s(2*level,' ');
141  for (int i=0; i<mat.noOfConstituents(); ++i) {
143  os << std::endl << s << i+1 << " : fm=" << f.second
144  << " : " << f.first;
145  }
146  //--level;
147  }
148  else
149  os << "* material not declared * ";
150  --level;
151  return os;
152 }
153 
Definition: DDBase.h:18
double a() const
returns the atomic mass
Definition: DDMaterial.cc:103
int i
Definition: DBlmapReader.cc:9
const DDI::rep_traits< DDName, DDI::Material * >::reference rep() const
Definition: DDBase.h:95
const N & name() const
Definition: DDBase.h:88
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
DDMaterial()
Creates a uninitialized reference-object (see DDLogicalPart documentation for details on reference ob...
Definition: DDMaterial.cc:16
An exception for DDD errors.
Definition: DDException.h:23
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:18
Container::value_type value_type
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
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:109
Definition: DDAxes.h:10
FractionV::value_type constituent(int i) const
returns the i-th compound material and its fraction-mass
Definition: DDMaterial.cc:95
double f[11][100]
std::string toString() const
Definition: DDBase.h:92
double density() const
returns the density
Definition: DDMaterial.cc:115
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
Definition: DDMaterial.cc:89
double a
Definition: hdecay.h:121
tuple level
Definition: testEve_cfg.py:34
string s
Definition: asciidump.py:422
#define DCOUT(M_v_Y, M_v_S)
Definition: DDdebug.h:53
const N & ddname() const
Definition: DDBase.h:90