CMS 3D CMS Logo

List of all members | Public Member Functions
DDI::Sphere Class Reference

#include <Sphere.h>

Inheritance diagram for DDI::Sphere:
DDI::Solid

Public Member Functions

 Sphere (double innerRadius, double outerRadius, double startPhi, double deltaPhi, double startZ, double deltaZ)
 
void stream (std::ostream &) const override
 
double volume () const override
 
- Public Member Functions inherited from DDI::Solid
const std::vector< double > & parameters () const
 
void setParameters (std::vector< double > const &p)
 
DDSolidShape shape () const
 
 Solid ()
 
 Solid (DDSolidShape shape)
 
virtual ~Solid ()
 

Additional Inherited Members

- Protected Attributes inherited from DDI::Solid
std::vector< double > p_
 
DDSolidShape shape_
 

Detailed Description

Definition at line 9 of file Sphere.h.

Constructor & Destructor Documentation

DDI::Sphere::Sphere ( double  innerRadius,
double  outerRadius,
double  startPhi,
double  deltaPhi,
double  startZ,
double  deltaZ 
)

Definition at line 14 of file Sphere.cc.

References ddsphere, and DDI::Solid::p_.

21 {
22  p_.emplace_back(innerRadius);
23  p_.emplace_back(outerRadius);
24  p_.emplace_back(startPhi);
25  p_.emplace_back(deltaPhi);
26  p_.emplace_back(startTheta);
27  p_.emplace_back(deltaTheta);
28 }
Solid()
Definition: Solid.h:14
std::vector< double > p_
Definition: Solid.h:32

Member Function Documentation

void DDI::Sphere::stream ( std::ostream &  os) const
overridevirtual

Reimplemented from DDI::Solid.

Definition at line 30 of file Sphere.cc.

References CONVERT_TO, and DDI::Solid::p_.

31 {
32  os << " innerRadius=" << CONVERT_TO( p_[0], cm )
33  << " outerRadius=" << CONVERT_TO( p_[1], cm )
34  << " startPhi=" << CONVERT_TO( p_[2], deg )
35  << " deltaPhi=" << CONVERT_TO( p_[3], deg )
36  << " startTheta=" << CONVERT_TO( p_[4], deg )
37  << " deltaTheta=" << CONVERT_TO( p_[5], deg );
38 }
#define CONVERT_TO(_x, _y)
Definition: DDUnits.h:6
std::vector< double > p_
Definition: Solid.h:32
double DDI::Sphere::volume ( void  ) const
overridevirtual

Reimplemented from DDI::Solid.

Definition at line 40 of file Sphere.cc.

References _pi(), funct::cos(), and DDI::Solid::p_.

41 {
42  double volume(0.);
43  if ( std::fabs(p_[3]) <= 2._pi && std::fabs(p_[5]) <= _pi ) {
44  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]);
45  } else if (std::fabs(p_[3]) <= 2._pi && std::fabs(p_[5]) > _pi ) {
46  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]);
47  } else if (std::fabs(p_[3]) > 2._pi && std::fabs(p_[5]) <= _pi ) {
48  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]));
49  }
50  return volume;
51 }
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double volume() const override
Definition: Sphere.cc:40
std::vector< double > p_
Definition: Solid.h:32
constexpr long double _pi(M_PI)