CMS 3D CMS Logo

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