CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
double volume () const
 
- 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 void stream (std::ostream &) const
 
virtual ~Solid ()
 

Additional Inherited Members

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

Detailed Description

Definition at line 8 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 12 of file Polyhedra.cc.

References edm::hlt::Exception, i, and DDI::Solid::p_.

16 {
17  p_.push_back(sides);
18  p_.push_back(startPhi);
19  p_.push_back(deltaPhi);
20  if((z.size()!=rmin.size()) || (z.size()!=rmax.size()) )
21  {
22  throw cms::Exception("DDException") << "Polyhedra(..): std::vectors z,rmin,rmax not of same length";
23  }
24  else
25  {
26  for(unsigned int i=0;i<z.size(); ++i)
27  {
28  p_.push_back(z[i]);
29  p_.push_back(rmin[i]);
30  p_.push_back(rmax[i]);
31  }
32  }
33 }
int i
Definition: DBlmapReader.cc:9
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 36 of file Polyhedra.cc.

References edm::hlt::Exception, i, and DDI::Solid::p_.

39 {
40  p_.push_back(sides);
41  p_.push_back(startPhi);
42  p_.push_back(deltaPhi);
43  if(z.size()!=r.size())
44  {
45  throw cms::Exception("DDException") << "Polyhedra(..): std::vectors z,rmin,rmax not of same length";
46  }
47  else
48  {
49  for(unsigned int i=0;i<z.size(); ++i)
50  {
51  p_.push_back(z[i]);
52  p_.push_back(r[i]);
53  }
54  }
55 }
int i
Definition: DBlmapReader.cc:9
float float float z
Solid()
Definition: Solid.h:14
std::vector< double > p_
Definition: Solid.h:32

Member Function Documentation

double Polyhedra::volume ( void  ) const
virtual

Reimplemented from DDI::Solid.

Definition at line 57 of file Polyhedra.cc.

References a, alpha, beta, funct::cos(), DCOUT, ddpolyhedra_rrz, HcalTopologyMode::H2, i, j, python.cmstools::loop(), m, DDI::Solid::p_, alignCSCRings::s, DDI::Solid::shape(), funct::sin(), and detailsBasic3DVector::z.

58 {
59  double volume=0;
60  /* 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 */
61 
62  /* 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 */
63 
64  //FIXME: rz, rrz !!
65  if (shape()==ddpolyhedra_rrz)
66  {
67  int loop = (p_.size()-3)/3 -1;
68  double sec=0;
69  double a = 0.5*fabs(p_[2]/rad / p_[0]);
70  DCOUT('V',"Polyhedra::volume(), loop=" << loop << " alph[deg]=" << a/deg);
71  int i=3;
72  for (int j=3; j<(loop+3); ++j)
73  {
74  double dz= fabs(p_[i]-p_[i+3]);
75  DCOUT('v', " dz[m] =" << dz/m);
76  /*
77  double ai, aii;
78  ai = (p_[i+2]*p_[i+2] - p_[i+1]*p_[i+1]);
79  aii = (p_[i+5]*p_[i+5] - p_[i+4]*p_[i+4]);
80  DCOUT('v', " rx_i[m] =" << p_[i+2]/m << " rm_i[m] =" << p_[i+1]/m);
81  DCOUT('v', " rx_ii[m]=" << p_[i+5]/m << " rm_ii[m]=" << p_[i+4]/m);
82  //double s = dz/3.*(ai*bi + 0.5*(ai*bii + bi*aii) + aii*bii);
83  double s = dz/3.*sin(a)*cos(a)*(ai + aii + 0.5*(ai+aii));
84  */
85  double z=dz/2.;
86 
87  double H1=(p_[i+2]-p_[i+1])*cos(a);
88  double Bl1=p_[i+1]*sin(a);
89  double Tl1=p_[i+2]*sin(a);
90 
91  double H2=(p_[i+5]-p_[i+4])*cos(a);
92  double Bl2=p_[i+4]*sin(a);
93  double Tl2=p_[i+5]*sin(a);
94 
95  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;
96  s = s*p_[0];
97  sec += s;
98  i+=3;
99  }
100  volume=sec;
101  return volume;
102  }
103  int sides=int(p_[0]);
104  //double phiFrom=p_[1]/rad;
105  double phiDelta=p_[2]/rad;
106 
107  double zBegin=0;
108  double zEnd=0;
109  double rBegin=0;
110  double rEnd=0;
111  double z=0;
112  double alpha=0;
113  double beta=0;
114  unsigned int i=3;
115 
116  alpha=fabs(phiDelta);
117  beta=0.5*(alpha/sides);
118 
119  while(i<(p_.size()-2))
120  {
121  zBegin=p_[i];
122  zEnd=p_[i+2];
123  rBegin=p_[i+1];
124  rEnd=p_[i+3];
125  z=zBegin-zEnd;
126 
127  /* volume for 1 side (we multiplie by cos(beta)sin(beta)sides later*/
128  double volume1=(rEnd*rEnd+rBegin*rBegin+rBegin*rEnd)*z/3;
129 
130  volume=volume+volume1;
131 
132  i=i+2;
133  }
134 
135  /* last line (goes from last z/r value to first */
136 
137  i=p_.size()-2;
138  zBegin=p_[i];
139  zEnd=p_[3];
140  rBegin=p_[i+1];
141  rEnd=p_[4];
142  z=zBegin-zEnd;
143 
144  double volume2=(rEnd*rEnd+rBegin*rBegin+rBegin*rEnd)*z/3;
145 
146  volume=volume+volume2;
147 
148  volume=fabs(sides*cos(beta)*sin(beta)*volume);
149 
150  return volume;
151 }
const double beta
int i
Definition: DBlmapReader.cc:9
float alpha
Definition: AMPTWrapper.h:95
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
float float float z
double volume() const
Definition: Polyhedra.cc:57
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
int j
Definition: DBlmapReader.cc:9
double a
Definition: hdecay.h:121
std::vector< double > p_
Definition: Solid.h:32
DDSolidShape shape() const
Definition: Solid.h:24
#define DCOUT(M_v_Y, M_v_S)
Definition: DDdebug.h:53