CMS 3D CMS Logo

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