CMS 3D CMS Logo

Tubs.cc
Go to the documentation of this file.
2 
3 #include <cmath>
4 #include <vector>
5 
6 #include "CLHEP/Units/GlobalPhysicalConstants.h"
7 #include "CLHEP/Units/GlobalSystemOfUnits.h"
8 #include "CLHEP/Units/SystemOfUnits.h"
11 
12 using std::fabs;
13 
14 DDI::Tubs::Tubs(double zhalf,
15  double rIn, double rOut,
16  double startPhi,
17  double deltaPhi)
18  : Solid(ddtubs)
19 {
20  p_.emplace_back(zhalf);
21  p_.emplace_back(rIn);
22  p_.emplace_back(rOut);
23  p_.emplace_back(startPhi);
24  p_.emplace_back(deltaPhi);
25 }
26 
27 
28 void DDI::Tubs::stream(std::ostream & os) const
29 {
30  os << " zhalf=" << p_[0]/cm
31  << " rIn=" << p_[1]/cm
32  << " rOut=" << p_[2]/cm
33  << " startPhi=" << p_[3]/deg
34  << " deltaPhi=" << p_[4]/deg;
35 }
36 
37 
38 double DDI::Tubs::volume() const
39 {
40  double volume=0;
41  double z=2.*p_[0];
42  double rIn=p_[1];
43  double rOut=p_[2];
44  double phi=p_[4]/rad;
45 
46  double volume1=pi*rIn*rIn*z;
47  double volume2=pi*rOut*rOut*z;
48 
49  double slice=fabs(phi/(2*pi));
50 
51  volume=slice*(volume2-volume1);
52 
53  return volume;
54 }
55 
void stream(std::ostream &) const override
Definition: Tubs.cc:28
Tubs(double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
Definition: Tubs.cc:14
const Double_t pi
double volume() const override
Definition: Tubs.cc:38
std::vector< double > p_
Definition: Solid.h:32