CMS 3D CMS Logo

List of all members | Public Member Functions
DDI::Polyhedra Class Reference

#include <Polyhedra.h>

Inheritance diagram for DDI::Polyhedra:
DDI::Solid

Public Member Functions

 Polyhedra (int sides, double startPhi, double deltaPhi, const std::vector< double > &z, const std::vector< double > &rmin, const std::vector< double > &rmax)
 
 Polyhedra (int sides, double startPhi, double deltaPhi, const std::vector< double > &z, const std::vector< double > &r)
 
void stream (std::ostream &) const override
 
double volume () const override
 
- Public Member Functions inherited from DDI::Solid
const std::vector< double > & parameters () const
 
void setParameters (std::vector< double > const &p)
 
DDSolidShape shape () const
 
 Solid ()
 
 Solid (DDSolidShape shape)
 
virtual ~Solid ()
 

Additional Inherited Members

- Protected Attributes inherited from DDI::Solid
std::vector< double > p_
 
DDSolidShape shape_
 

Detailed Description

Definition at line 11 of file Polyhedra.h.

Constructor & Destructor Documentation

Polyhedra::Polyhedra ( int  sides,
double  startPhi,
double  deltaPhi,
const std::vector< double > &  z,
const std::vector< double > &  rmin,
const std::vector< double > &  rmax 
)

Definition at line 18 of file Polyhedra.cc.

References ddpolyhedra_rrz, Exception, mps_fire::i, and DDI::Solid::p_.

23 {
24  p_.emplace_back(sides);
25  p_.emplace_back(startPhi);
26  p_.emplace_back(deltaPhi);
27  if((z.size()!=rmin.size()) || (z.size()!=rmax.size()) )
28  {
29  throw cms::Exception("DDException") << "Polyhedra(..): std::vectors z,rmin,rmax not of same length";
30  }
31  else
32  {
33  for(unsigned int i=0;i<z.size(); ++i)
34  {
35  p_.emplace_back(z[i]);
36  p_.emplace_back(rmin[i]);
37  p_.emplace_back(rmax[i]);
38  }
39  }
40 }
float float float z
Solid()
Definition: Solid.h:14
std::vector< double > p_
Definition: Solid.h:32
Polyhedra::Polyhedra ( int  sides,
double  startPhi,
double  deltaPhi,
const std::vector< double > &  z,
const std::vector< double > &  r 
)

Definition at line 42 of file Polyhedra.cc.

References ddpolyhedra_rz, Exception, mps_fire::i, and DDI::Solid::p_.

45 {
46  p_.emplace_back(sides);
47  p_.emplace_back(startPhi);
48  p_.emplace_back(deltaPhi);
49  if(z.size()!=r.size())
50  {
51  throw cms::Exception("DDException") << "Polyhedra(..): std::vectors z,rmin,rmax not of same length";
52  }
53  else
54  {
55  for(unsigned int i=0;i<z.size(); ++i)
56  {
57  p_.emplace_back(z[i]);
58  p_.emplace_back(r[i]);
59  }
60  }
61 }
float float float z
Solid()
Definition: Solid.h:14
std::vector< double > p_
Definition: Solid.h:32

Member Function Documentation

void DDI::Polyhedra::stream ( std::ostream &  os) const
overridevirtual

Reimplemented from DDI::Solid.

Definition at line 173 of file Polyhedra.cc.

References gen::k, and DDI::Solid::p_.

174 {
175  os << " sides=" << p_[0]
176  << " startPhi[deg]=" << p_[1]/deg
177  << " dPhi[deg]=" << p_[2]/deg
178  << " Sizes[cm]=";
179  for (unsigned k=3; k<p_.size(); ++k)
180  os << p_[k]/cm << " ";
181 }
int k[5][pyjets_maxn]
std::vector< double > p_
Definition: Solid.h:32
double Polyhedra::volume ( void  ) const
overridevirtual

Reimplemented from DDI::Solid.

Definition at line 63 of file Polyhedra.cc.

References a, alpha, pfBoostedDoubleSVAK8TagInfos_cfi::beta, funct::cos(), ddpolyhedra_rrz, PVValHelper::dz, HcalTopologyMode::H2, mps_fire::i, createfilelist::int, heppy_loop::loop, DDI::Solid::p_, alignCSCRings::s, DDI::Solid::shape(), and funct::sin().

64 {
65  double volume = 0;
66  /* the following assumption is made:
67  there are at least 3 eaqual sides
68  if there is a complete circle (this has to be done,
69  otherwise you can not define a polygon in a circle */
70 
71  /* the calculation for the volume is similar as in
72  the case of the polycone. However, the rotation
73  is not defined as part of a circle, but as sides
74  in a regular polygon (specified by parameter "sides").
75  The sides are defined betwee startPhi and endPhi and
76  form triangles within the circle they are defined in.
77  First we need to determine the aread of side.
78  let alpha |startPhi-endPhi|.
79  the half the angle of 1 side is beta=0.5*(alph/sides).
80  If r is the raddius of the circle in which the regular polygon is defined,
81  the are of such a side will be
82  0.5*(height side)*(base side)=0.5*(cos(beta)*r)*(2*sin(beta)*r)= cos(beta)sin(beta)*r*r.
83  r is the radius that varies if we "walk" over the boundaries of
84  the polygon that is described by the z and r values
85  (this yields the same integral primitive as used with the Polycone.
86  Read Polycone documentation in code first if you do not understand this */
87 
88  //FIXME: rz, rrz !!
90  {
91  int loop = (p_.size()-3)/3 -1;
92  double sec=0;
93  double a = 0.5*fabs(p_[2]/rad / p_[0]);
94  int i=3;
95  for (int j=3; j<(loop+3); ++j)
96  {
97  double dz= fabs(p_[i]-p_[i+3]);
98  /*
99  double ai, aii;
100  ai = (p_[i+2]*p_[i+2] - p_[i+1]*p_[i+1]);
101  aii = (p_[i+5]*p_[i+5] - p_[i+4]*p_[i+4]);
102  //double s = dz/3.*(ai*bi + 0.5*(ai*bii + bi*aii) + aii*bii);
103  double s = dz/3.*sin(a)*cos(a)*(ai + aii + 0.5*(ai+aii));
104  */
105  double z=dz/2.;
106 
107  double H1=(p_[i+2]-p_[i+1])*cos(a);
108  double Bl1=p_[i+1]*sin(a);
109  double Tl1=p_[i+2]*sin(a);
110 
111  double H2=(p_[i+5]-p_[i+4])*cos(a);
112  double Bl2=p_[i+4]*sin(a);
113  double Tl2=p_[i+5]*sin(a);
114 
115  double s = (2*H1*Bl1+2*H1*Tl1)*z+(H1*Bl2-2*H1*Bl1+H1*Tl2-2*H1*Tl1+H2*Bl1+H2*Tl1+H2*Tl2-H2*Tl1)*z+(2/3)*(H2*Bl2-H2*Bl1-H1*Bl2+H1*Bl1-H1*Tl2+H1*Tl1)*z;
116  s = s*p_[0];
117  sec += s;
118  i+=3;
119  }
120  volume=sec;
121  return volume;
122  }
123  int sides=int(p_[0]);
124  //double phiFrom=p_[1]/rad;
125  double phiDelta=p_[2]/rad;
126 
127  double zBegin=0;
128  double zEnd=0;
129  double rBegin=0;
130  double rEnd=0;
131  double z=0;
132  double alpha=0;
133  double beta=0;
134  unsigned int i=3;
135 
136  alpha=fabs(phiDelta);
137  beta=0.5*(alpha/sides);
138 
139  while(i<(p_.size()-2))
140  {
141  zBegin=p_[i];
142  zEnd=p_[i+2];
143  rBegin=p_[i+1];
144  rEnd=p_[i+3];
145  z=zBegin-zEnd;
146 
147  /* volume for 1 side (we multiplie by cos(beta)sin(beta)sides later*/
148  double volume1=(rEnd*rEnd+rBegin*rBegin+rBegin*rEnd)*z/3;
149 
150  volume=volume+volume1;
151 
152  i=i+2;
153  }
154 
155  /* last line (goes from last z/r value to first */
156 
157  i=p_.size()-2;
158  zBegin=p_[i];
159  zEnd=p_[3];
160  rBegin=p_[i+1];
161  rEnd=p_[4];
162  z=zBegin-zEnd;
163 
164  double volume2=(rEnd*rEnd+rBegin*rBegin+rBegin*rEnd)*z/3;
165 
166  volume=volume+volume2;
167 
168  volume=fabs(sides*cos(beta)*sin(beta)*volume);
169 
170  return volume;
171 }
float alpha
Definition: AMPTWrapper.h:95
double volume() const override
Definition: Polyhedra.cc:63
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
float float float z
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double a
Definition: hdecay.h:121
std::vector< double > p_
Definition: Solid.h:32
DDSolidShape shape() const
Definition: Solid.h:24