CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Torus.cc
Go to the documentation of this file.
3 
4 #include <cmath>
5 #include <vector>
6 
9 
10 using std::sqrt;
11 using namespace geant_units;
12 using namespace geant_units::operators;
13 
14 DDI::Torus::Torus(double pRMin, double pRMax, double pRTor, double pSPhi, double pDPhi) : Solid(DDSolidShape::ddtorus) {
15  p_.emplace_back(pRMin); // ......... 0
16  p_.emplace_back(pRMax); // ......... 1
17  p_.emplace_back(pRTor); // ......... 2
18  p_.emplace_back(pSPhi); // ......... 3
19  p_.emplace_back(pDPhi); // ......... 4
20 }
21 
22 void DDI::Torus::stream(std::ostream& os) const {
23  os << " rMin=" << convertMmToCm(p_[0]) << " rMax=" << convertRadToDeg(p_[1]) << " rTor=" << convertRadToDeg(p_[2])
24  << " sPhi=" << convertMmToCm(p_[3]) << " dPhi=" << convertMmToCm(p_[4]);
25 }
26 
27 double DDI::Torus::volume() const {
28  double volume = 0;
29 
30  /* use notation as described in documentation about geant 4 shapes */
31 
32  // From Geant4: { fCubicVolume = fDPhi*pi*fRtor*(fRmax*fRmax-fRmin*fRmin);
33 
34  volume = p_[4] * piRadians * p_[2] * (p_[1] * p_[1] - p_[0] * p_[0]);
35 
36  return volume;
37 }
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
void stream(std::ostream &) const override
Definition: Torus.cc:22
T sqrt(T t)
Definition: SSEVec.h:19
double volume() const override
Definition: Torus.cc:27
constexpr double piRadians(M_PI)
DDSolidShape
Definition: DDSolidShapes.h:6
Torus(double pRMin, double pRMax, double pRTor, double pSPhi, double pDPhi)
Definition: Torus.cc:14
std::vector< double > p_
Definition: Solid.h:30
constexpr NumType convertMmToCm(NumType millimeters)
Definition: GeantUnits.h:63