CMS 3D CMS Logo

DDMaterial.cc
Go to the documentation of this file.
1 #include <ostream>
2 #include <string>
3 #include <vector>
4 
11 
12 using DDI::Material;
13 using namespace geant_units::operators;
14 
16 
26 
40 DDMaterial::DDMaterial(const DDName &name, double z, double a, double d) : DDBase<DDName, std::unique_ptr<Material>>() {
41  create(name, std::make_unique<Material>(z, a, d));
42 }
43 
57  create(name, std::make_unique<Material>(0, 0, density));
58 }
59 
63 int DDMaterial::addMaterial(const DDMaterial &m, double fm) {
64  if (m.ddname() == ddname()) {
65  throw cms::Exception("DDException") << "DDMaterial::addMaterial(..): name-clash\n trying to add material "
66  << m << " to itself! ";
67  }
68  rep().addMaterial(m, fm);
69  return rep().noOfConstituents();
70 }
71 
72 int DDMaterial::noOfConstituents() const { return rep().noOfConstituents(); }
73 
74 DDMaterial::FractionV::value_type DDMaterial::constituent(int i) const { return rep().constituent(i); }
75 
76 double DDMaterial::a() const { return rep().a(); }
77 
78 double DDMaterial::z() const { return rep().z(); }
79 
80 double DDMaterial::density() const { return rep().density(); }
81 
82 namespace {
83  std::ostream &doStream(std::ostream &os, const DDMaterial &mat, int level) {
84  ++level;
85  if (mat) {
86  os << '[' << mat.name() << ']' << " z=" << mat.z() << " a=" << convertUnitsTo(1._g_per_mole, mat.a()) << "*g/mole"
87  << " d=" << convertUnitsTo(1._g_per_cm3, mat.density()) << "*g/cm3";
88  std::string s(2 * level, ' ');
89  for (int i = 0; i < mat.noOfConstituents(); ++i) {
91  os << std::endl << s << i + 1 << " : fm=" << f.second << " : ";
92  doStream(os, f.first, level);
93  }
94  } else
95  os << "* material not declared * ";
96  --level;
97  return os;
98  }
99 } // namespace
100 
101 std::ostream &operator<<(std::ostream &os, const DDMaterial &mat) { return doStream(os, mat, 0); }
personalPlayback.level
level
Definition: personalPlayback.py:22
DDBase.h
mps_fire.i
i
Definition: mps_fire.py:428
g4SimHits_cfi.Material
Material
Definition: g4SimHits_cfi.py:594
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
detailsBasic3DVector::z
float float float z
Definition: extBasic3DVector.h:14
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
DDMaterial::density
double density() const
returns the density
Definition: DDMaterial.cc:80
DDMaterial::z
double z() const
retruns the atomic number
Definition: DDMaterial.cc:78
DDMaterial::noOfConstituents
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
Definition: DDMaterial.cc:72
DDMaterial::constituent
FractionV::value_type constituent(int i) const
returns the i-th compound material and its fraction-mass
Definition: DDMaterial.cc:74
geant_units::operators
Definition: GeantUnits.h:18
DDI::Material
Definition: Material.h:11
alignCSCRings.s
s
Definition: alignCSCRings.py:92
DDMaterial
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
geant_units::operators::convertUnitsTo
constexpr NumType convertUnitsTo(double desiredUnits, NumType val)
Definition: GeantUnits.h:100
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:78
operator<<
std::ostream & operator<<(std::ostream &os, const DDMaterial &mat)
Definition: DDMaterial.cc:101
DDBase< DDName, std::unique_ptr< DDI::Material > >::name
const DDName & name() const
Definition: DDBase.h:59
DDMaterial::a
double a() const
returns the atomic mass
Definition: DDMaterial.cc:76
DDBase< DDName, std::unique_ptr< DDI::Material > >::rep
const DDI::rep_traits< DDName, std::unique_ptr< DDI::Material > >::reference rep() const
Definition: DDBase.h:65
a
double a
Definition: hdecay.h:119
DDBase< DDName, std::unique_ptr< DDI::Material > >::ddname
const DDName & ddname() const
Definition: DDBase.h:61
GeantUnits.h
DDMaterial.h
DDMaterial::DDMaterial
DDMaterial()
Creates a uninitialized reference-object (see DDLogicalPart documentation for details on reference ob...
Definition: DDMaterial.cc:15
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::cuda::device::unique_ptr
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
Definition: device_unique_ptr.h:33
std
Definition: JetResolutionObject.h:76
DDBase< DDName, std::unique_ptr< DDI::Material > >::create
void create(const DDName &name, std::unique_ptr< DDI::Material > vals)
Definition: DDBase.h:96
DDName.h
Exception
Definition: hltDiff.cc:245
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
Exception.h
ztail.d
d
Definition: ztail.py:151
DDBase
Definition: DDBase.h:10
DDMaterial::addMaterial
int addMaterial(const DDMaterial &m, double fm)
adds a material to the mixture proportional to its fraction-mass fm.
Definition: DDMaterial.cc:63
Material.h
fastSimProducer_cff.density
density
Definition: fastSimProducer_cff.py:61