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 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 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 155 of file Polyhedra.cc.

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

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