CMS 3D CMS Logo

Sphere.cc
Go to the documentation of this file.
3 
4 #include <cmath>
5 #include <ostream>
6 #include <vector>
7 
10 
11 using namespace geant_units;
12 using namespace geant_units::operators;
13 
15  double innerRadius, double outerRadius, double startPhi, double deltaPhi, double startTheta, double deltaTheta)
17  p_.emplace_back(innerRadius);
18  p_.emplace_back(outerRadius);
19  p_.emplace_back(startPhi);
20  p_.emplace_back(deltaPhi);
21  p_.emplace_back(startTheta);
22  p_.emplace_back(deltaTheta);
23 }
24 
25 void DDI::Sphere::stream(std::ostream& os) const {
26  os << " innerRadius=" << convertMmToCm(p_[0]) << " outerRadius=" << convertMmToCm(p_[1])
27  << " startPhi=" << convertRadToDeg(p_[2]) << " deltaPhi=" << convertRadToDeg(p_[3])
28  << " startTheta=" << convertRadToDeg(p_[4]) << " deltaTheta=" << convertRadToDeg(p_[5]);
29 }
30 
31 double DDI::Sphere::volume() const {
32  double volume(0.);
33  if (std::fabs(p_[3]) <= 2._pi && std::fabs(p_[5]) <= piRadians) {
34  volume = std::fabs((p_[1] * p_[1] * p_[1] - p_[0] * p_[0] * p_[0]) / 3. *
35  (std::cos(p_[4] + p_[5]) - std::cos(p_[4])) * p_[3]);
36  } else if (std::fabs(p_[3]) <= 2._pi && std::fabs(p_[5]) > piRadians) {
37  volume = std::fabs((p_[1] * p_[1] * p_[1] - p_[0] * p_[0] * p_[0]) / 3. *
38  (std::cos(p_[4] + p_[5] - 180._deg) - std::cos(p_[4])) * p_[3]);
39  } else if (std::fabs(p_[3]) > 2._pi && std::fabs(p_[5]) <= piRadians) {
40  volume = std::fabs((p_[1] * p_[1] * p_[1] - p_[0] * p_[0] * p_[0]) / 3. *
41  (std::cos(p_[4] + p_[5]) - std::cos(p_[4])) * (p_[3] - p_[2]));
42  }
43  return volume;
44 }
DDSolidShapes.h
DDSolidShape
DDSolidShape
Definition: DDSolidShapes.h:6
Sphere.h
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
interestingEgammaIsoDetIdsSequence_cff.outerRadius
outerRadius
Definition: interestingEgammaIsoDetIdsSequence_cff.py:14
geant_units::operators
Definition: GeantUnits.h:18
Solid.h
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
DDSolidShape::ddsphere
GeantUnits.h
interestingEgammaIsoDetIdsSequence_cff.innerRadius
innerRadius
Definition: interestingEgammaIsoDetIdsSequence_cff.py:15
DDI::Solid
Definition: Solid.h:10
DDI::Sphere::volume
double volume() const override
Definition: Sphere.cc:31
angle_units::piRadians
constexpr double piRadians(M_PI)
geant_units::operators::convertMmToCm
constexpr NumType convertMmToCm(NumType millimeters)
Definition: GeantUnits.h:63
DDI::Sphere::stream
void stream(std::ostream &) const override
Definition: Sphere.cc:25
geant_units
Definition: GeantUnits.h:11
DDI::Solid::p_
std::vector< double > p_
Definition: Solid.h:30
DDI::Sphere::Sphere
Sphere(double innerRadius, double outerRadius, double startPhi, double deltaPhi, double startZ, double deltaZ)
Definition: Sphere.cc:14