CMS 3D CMS Logo

Cons.cc
Go to the documentation of this file.
3 
4 #include <cmath>
5 #include <ostream>
6 #include <vector>
7 
10 
11 using namespace geant_units;
12 using namespace geant_units::operators;
13 
14 DDI::Cons::Cons(double zhalf,
15  double rInMinusZ,
16  double rOutMinusZ,
17  double rInPlusZ,
18  double rOutPlusZ,
19  double startPhi,
20  double deltaPhi)
22 {
23  p_.emplace_back(zhalf);
24  p_.emplace_back(rInMinusZ);
25  p_.emplace_back(rOutMinusZ);
26  p_.emplace_back(rInPlusZ);
27  p_.emplace_back(rOutPlusZ);
28  p_.emplace_back(startPhi);
29  p_.emplace_back(deltaPhi);
30 }
31 
32 void
33 DDI::Cons::stream( std::ostream & os ) const
34 {
35  os << " zhalf=" << convertMmToCm( p_[0] )
36  << " rIn-Z=" << convertMmToCm( p_[1] )
37  << " rOut-Z=" << convertMmToCm( p_[2] )
38  << " rIn+Z=" << convertMmToCm( p_[3] )
39  << " rOut+Z=" << convertMmToCm( p_[4] )
40  << " startPhi=" << convertRadToDeg( p_[5] )
41  << " deltaPhi=" << convertRadToDeg( p_[6] );
42 }
43 
44 double DDI::Cons::volume() const
45 {
46  /* zhalf is the half length of the cone,
47  phiTo is always clockwise rotated from phiFrom
48  rInMinusZ is always smaller than rOutMinusZ (same for r*PlusZ)
49  They are the distances relative to the rotation axes */
50 
51  /* calculation normalize from 0 to z */
52 
53  /* The function f=rInMinusZ+((rInPlusZ-rInMinusZ)/z)*x defines
54  the radius of the the rotation from 0 to z. Raised to the power
55  of 2 integrated on x from 0 to z. Multiplied by pi, gives the
56  volume that needs to substracted from the other volume */
57 
58  /* f^2=rInMinusZ*rInMinusZ+2*rInMinusZ*((rInPlusZ-rInMinusZ)/z)*x+((rInPlusZ-rInMinusZ)*(rInPlusZ-rInMinusZ)*x*x)/(z*z) */
59 
60  /* primitive of f^2 is: rInMinusZ*rInMinusZ*x+rInMinusZ*((rInPlusZ-rInMinusZ)/z)*(x*x)+(rInPlusZ-rInMinusZ)*(rInPlusZ-rInMinusZ)*(x*x*x)/(3*z*z) */
61 
62  /*integration from 0 to z yields: pi*( rInMinusZ*rInMinusZ*z+rInMinusZ*(rInPlusZ-rInMinusZ)*z+((rInPlusZ-rInMinusZ)*(rInPlusZ-rInMinusZ)*z)/(3) ) */
63 
64  double zhalf=p_[0];
65  double rInMinusZ=p_[1];
66  double rOutMinusZ=p_[2];
67  double rInPlusZ=p_[3];
68  double rOutPlusZ=p_[4];
69  //double phiFrom=p_[5]/rad;
70  double deltaPhi=std::abs( p_[6]);
71  double z=2*zhalf;
72 
73  double volume1=1_pi*(rInPlusZ*rInPlusZ+rInMinusZ*rInMinusZ+rInMinusZ*rInPlusZ)*z/3;
74 
75  double volume2=1_pi*(rOutPlusZ*rOutPlusZ+rOutMinusZ*rOutMinusZ+rOutMinusZ*rOutPlusZ)*z/3;
76 
77  double slice=deltaPhi/(2_pi);
78  double volume=slice*(volume2-volume1);
79 
80  return volume;
81 
82 }
83 
84 
double volume() const override
Definition: Cons.cc:44
DDSolidShape
Definition: DDSolidShapes.h:6
constexpr NumType convertRadToDeg(NumType radians)
Definition: GeantUnits.h:98
void stream(std::ostream &) const override
Definition: Cons.cc:33
Cons(double zhalf, double rInMinusZ, double rOutMinusZ, double rInPlusZ, double rOutPlusZ, double startPhi, double deltaPhi)
Definition: Cons.cc:14
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< double > p_
Definition: Solid.h:32
constexpr NumType convertMmToCm(NumType millimeters)
Definition: GeantUnits.h:110