CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Sphere.cc
Go to the documentation of this file.
4 #include "CLHEP/Units/GlobalSystemOfUnits.h"
5 #include "CLHEP/Units/GlobalPhysicalConstants.h"
6 
7 #include <cmath>
8 #include <ostream>
9 
10 DDI::Sphere::Sphere(double innerRadius,
11  double outerRadius,
12  double startPhi,
13  double deltaPhi,
14  double startTheta,
15  double deltaTheta)
16  : Solid(ddsphere)
17 {
18  p_.push_back(innerRadius);
19  p_.push_back(outerRadius);
20  p_.push_back(startPhi);
21  p_.push_back(deltaPhi);
22  p_.push_back(startTheta);
23  p_.push_back(deltaTheta);
24 }
25 
26 
27 void DDI::Sphere::stream(std::ostream & os) const
28 {
29  os << " innerRadius=" << p_[0]/cm
30  << " outerRadius=" << p_[1]/cm
31  << " startPhi=" << p_[2]/deg
32  << " deltaPhi=" << p_[3]/deg
33  << " startTheta=" << p_[4]/deg
34  << " deltaTheta=" << p_[5]/deg;
35 }
36 
37 double DDI::Sphere::volume() const
38 {
39  double volume(0.);
40  if ( std::fabs(p_[3]) <= 2.*Geom::pi() && std::fabs(p_[5]) <= Geom::pi() ) {
41  volume = std::fabs((p_[1]*p_[1]*p_[1] - p_[0]*p_[0]*p_[0])/3. * (std::cos(p_[4]+p_[5]) - std::cos(p_[4]))*p_[3]);
42  } else if (std::fabs(p_[3]) <= 2.*Geom::pi() && std::fabs(p_[5]) > Geom::pi() ) {
43  volume = std::fabs((p_[1]*p_[1]*p_[1] - p_[0]*p_[0]*p_[0])/3. * (std::cos(p_[4]+p_[5]-180.*deg) - std::cos(p_[4]))*p_[3]);
44  } else if (std::fabs(p_[3]) > 2.*Geom::pi() && std::fabs(p_[5]) <= Geom::pi() ) {
45  volume = std::fabs((p_[1]*p_[1]*p_[1] - p_[0]*p_[0]*p_[0])/3. * (std::cos(p_[4]+p_[5]) - std::cos(p_[4]))*(p_[3]-p_[2]));
46  }
47  return volume;
48 }
49 
50 
Sphere(double innerRadius, double outerRadius, double startPhi, double deltaPhi, double startZ, double deltaZ)
Definition: Sphere.cc:10
double deltaPhi(float phi1, float phi2)
Definition: VectorUtil.h:30
double volume() const
Definition: Sphere.cc:37
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double pi()
Definition: Pi.h:31
std::vector< double > p_
Definition: Solid.h:41
void stream(std::ostream &) const
Definition: Sphere.cc:27