CMS 3D CMS Logo

Tubs.cc
Go to the documentation of this file.
2 
3 #include <cmath>
4 #include <vector>
5 
9 
10 using std::fabs;
11 using namespace dd::operators;
12 
13 DDI::Tubs::Tubs(double zhalf,
14  double rIn, double rOut,
15  double startPhi,
16  double deltaPhi)
18 {
19  p_.emplace_back(zhalf);
20  p_.emplace_back(rIn);
21  p_.emplace_back(rOut);
22  p_.emplace_back(startPhi);
23  p_.emplace_back(deltaPhi);
24 }
25 
26 void DDI::Tubs::stream(std::ostream & os) const
27 {
28  os << " zhalf=" << CONVERT_TO( p_[0], cm )
29  << " rIn=" << CONVERT_TO( p_[1], cm )
30  << " rOut=" << CONVERT_TO( p_[2], cm )
31  << " startPhi=" << CONVERT_TO( p_[3], deg )
32  << " deltaPhi=" << CONVERT_TO( p_[4], deg );
33 }
34 
35 double DDI::Tubs::volume() const
36 {
37  double volume=0;
38  double z=2.*p_[0];
39  double rIn=p_[1];
40  double rOut=p_[2];
41  double phi = CONVERT_TO( p_[4], rad );
42 
43  double volume1=1_pi*rIn*rIn*z;
44  double volume2=1_pi*rOut*rOut*z;
45 
46  double slice=fabs(phi/(2_pi));
47 
48  volume=slice*(volume2-volume1);
49 
50  return volume;
51 }
void stream(std::ostream &) const override
Definition: Tubs.cc:26
DDSolidShape
Definition: DDSolidShapes.h:4
#define CONVERT_TO(_x, _y)
Definition: DDUnits.h:6
Tubs(double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
Definition: Tubs.cc:13
double volume() const override
Definition: Tubs.cc:35
std::vector< double > p_
Definition: Solid.h:32
constexpr long double _pi(M_PI)