CMS 3D CMS Logo

Polycone.cc
Go to the documentation of this file.
3 
4 #include <cassert>
5 #include <cmath>
6 
11 
12 using DDI::Polycone;
13 using namespace geant_units::operators;
14 
15 Polycone::Polycone(double startPhi,
16  double deltaPhi,
17  const std::vector<double>& z,
18  const std::vector<double>& rmin,
19  const std::vector<double>& rmax)
21  p_.emplace_back(startPhi);
22  p_.emplace_back(deltaPhi);
23  if ((z.size() != rmin.size()) || (z.size() != rmax.size())) {
24  throw cms::Exception("DDException") << "Polycone(..): std::vectors z,rmin,rmax not of same length";
25  } else {
26  for (unsigned int i = 0; i < z.size(); ++i) {
27  p_.emplace_back(z[i]);
28  p_.emplace_back(rmin[i]);
29  p_.emplace_back(rmax[i]);
30  }
31  }
32 }
33 
34 Polycone::Polycone(double startPhi, double deltaPhi, const std::vector<double>& z, const std::vector<double>& r)
36  p_.emplace_back(startPhi);
37  p_.emplace_back(deltaPhi);
38  if (z.size() != r.size()) {
39  throw cms::Exception("DDException") << "Polycone(..): std::vectors z,rmin,rmax not of same length";
40  } else {
41  for (unsigned int i = 0; i < z.size(); ++i) {
42  p_.emplace_back(z[i]);
43  p_.emplace_back(r[i]);
44  }
45  }
46 }
47 
48 double Polycone::volume() const {
49  double result = -1.;
51  unsigned int loop = (p_.size() - 2) / 3 - 1;
52  assert(loop > 0);
53  double sec = 0;
54  int i = 2;
55  for (unsigned int j = 2; j < (loop + 2); ++j) {
56  double dz = std::fabs(p_[i] - p_[i + 3]);
57  double v_min = dz * 1_pi / 3. * (p_[i + 1] * p_[i + 1] + p_[i + 4] * p_[i + 4] + p_[i + 1] * p_[i + 4]);
58  double v_max = dz * 1_pi / 3. * (p_[i + 2] * p_[i + 2] + p_[i + 5] * p_[i + 5] + p_[i + 2] * p_[i + 5]);
59  double s = v_max - v_min;
60  //assert(s>=0);
61  sec += s;
62  i += 3;
63  }
64  result = sec * std::fabs(p_[1]) / 2._pi;
65  }
66 
68  double volume = 0;
69  double phiFrom = p_[0];
70  double phiTo = p_[0] + p_[1];
71  double slice = (std::fabs(phiFrom - phiTo)) / 2_pi;
72  double zBegin = 0;
73  double zEnd = 0;
74  double rBegin = 0;
75  double rEnd = 0;
76  double z = 0;
77  unsigned int i = 2;
78 
79  while (i < (p_.size() - 2)) {
80  zBegin = p_[i];
81  zEnd = p_[i + 2];
82  rBegin = p_[i + 1];
83  rEnd = p_[i + 3];
84  z = zBegin - zEnd;
85 
86  /* for calculation of volume1 look at calculation of DDConsImpl of a volume1. Furthermore z can be smaller than zero. This makes sense since volumes we have to substract */
87  double volume1 = (rEnd * rEnd + rBegin * rBegin + rBegin * rEnd) * z / 3;
88  volume = volume + volume1;
89  i = i + 2;
90  }
91 
92  /* last line (goes from last z/r value to first */
93  i = p_.size() - 2;
94  zBegin = p_[i];
95  zEnd = p_[2];
96  rBegin = p_[i + 1];
97  rEnd = p_[3];
98  z = zBegin - zEnd;
99 
100  double volume2 = (rEnd * rEnd + rBegin * rBegin + rBegin * rEnd) * z / 3;
101  volume = volume + volume2;
102  volume = std::fabs(slice * 1_pi * volume);
103  result = volume;
104  }
105  return result;
106 }
107 
108 void DDI::Polycone::stream(std::ostream& os) const {
109  os << " startPhi[deg]=" << convertRadToDeg(p_[0]) << " dPhi[deg]=" << convertRadToDeg(p_[1]) << " Sizes[cm]=";
110  for (unsigned k = 2; k < p_.size(); ++k)
111  os << convertMmToCm(p_[k]) << " ";
112 }
DDSolidShapes.h
mps_fire.i
i
Definition: mps_fire.py:428
DDSolidShape
DDSolidShape
Definition: DDSolidShapes.h:6
MessageLogger.h
DDI::Polycone::volume
double volume() const override
Definition: Polycone.cc:48
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::cuda::assert
assert(be >=bs)
geant_units::operators
Definition: GeantUnits.h:18
DDI::Polycone::stream
void stream(std::ostream &) const override
Definition: Polycone.cc:108
Polycone.h
Solid.h
alignCSCRings.s
s
Definition: alignCSCRings.py:92
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
dqmdumpme.k
k
Definition: dqmdumpme.py:60
GeantUnits.h
heppy_loop.loop
loop
Definition: heppy_loop.py:28
DDI::Solid::shape_
DDSolidShape shape_
Definition: Solid.h:29
DDI::Solid
Definition: Solid.h:10
DDI::Polycone
Definition: Polycone.h:11
fileinputsource_cfi.sec
sec
Definition: fileinputsource_cfi.py:87
alignCSCRings.r
r
Definition: alignCSCRings.py:93
PVValHelper::dz
Definition: PVValidationHelpers.h:50
Exception
Definition: hltDiff.cc:246
DDI::Polycone::Polycone
Polycone(double startPhi, double deltaPhi, const std::vector< double > &z, const std::vector< double > &rmin, const std::vector< double > &rmax)
Definition: Polycone.cc:15
Exception.h
geant_units::operators::convertMmToCm
constexpr NumType convertMmToCm(NumType millimeters)
Definition: GeantUnits.h:62
DDSolidShape::ddpolycone_rrz
mps_fire.result
result
Definition: mps_fire.py:311
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
mergeAndRegister.slice
slice
Definition: mergeAndRegister.py:121
DDSolidShape::ddpolycone_rz
DDI::Solid::p_
std::vector< double > p_
Definition: Solid.h:30