CMS 3D CMS Logo

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

#include <Polycone.h>

Inheritance diagram for DDI::Polycone:
DDI::Solid

Public Member Functions

 Polycone (double startPhi, double deltaPhi, const std::vector< double > &z, const std::vector< double > &rmin, const std::vector< double > &rmax)
 
 Polycone (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 Polycone.h.

Constructor & Destructor Documentation

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

Definition at line 15 of file Polycone.cc.

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

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

Definition at line 40 of file Polycone.cc.

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

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

Member Function Documentation

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

Reimplemented from DDI::Solid.

Definition at line 128 of file Polycone.cc.

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

129 {
130  os << " startPhi[deg]=" << CONVERT_TO( p_[0], deg )
131  << " dPhi[deg]=" << CONVERT_TO( p_[1], deg )
132  << " Sizes[cm]=";
133  for (unsigned k=2; k<p_.size(); ++k)
134  os << CONVERT_TO( p_[k], cm ) << " ";
135 }
#define CONVERT_TO(_x, _y)
Definition: DDUnits.h:6
int k[5][pyjets_maxn]
std::vector< double > p_
Definition: Solid.h:32
double Polycone::volume ( void  ) const
overridevirtual

Reimplemented from DDI::Solid.

Definition at line 62 of file Polycone.cc.

References _pi(), CONVERT_TO, ddpolycone_rrz, ddpolycone_rz, PVValHelper::dz, mps_fire::i, heppy_loop::loop, DDI::Solid::p_, mps_fire::result, alignCSCRings::s, and DDI::Solid::shape_.

63 {
64  double result = -1.;
66  {
67  unsigned int loop = (p_.size()-2)/3 -1;
68  assert(loop>0);
69  double sec=0;
70  int i=2;
71  for (unsigned int j=2; j<(loop+2); ++j) {
72  double dz= std::fabs(p_[i]-p_[i+3]);
73  double v_min = dz * 1_pi/3. *( p_[i+1]*p_[i+1] + p_[i+4]*p_[i+4]
74  + p_[i+1]*p_[i+4] );
75  double v_max = dz * 1_pi/3. *( p_[i+2]*p_[i+2] + p_[i+5]*p_[i+5]
76  + p_[i+2]*p_[i+5] );
77  double s = v_max - v_min;
78  //assert(s>=0);
79  sec += s;
80  i += 3;
81  }
82  result = sec * CONVERT_TO( std::fabs(p_[1]), rad )/2._pi;
83  }
84 
86  {
87  double volume=0;
88  double phiFrom=CONVERT_TO( p_[0], rad );
89  double phiTo=CONVERT_TO( p_[0]+p_[1], rad );
90  double slice=(std::fabs(phiFrom-phiTo))/2_pi;
91  double zBegin=0;
92  double zEnd=0;
93  double rBegin=0;
94  double rEnd=0;
95  double z=0;
96  unsigned int i=2;
97 
98  while(i<(p_.size()-2))
99  {
100  zBegin=p_[i];
101  zEnd=p_[i+2];
102  rBegin=p_[i+1];
103  rEnd=p_[i+3];
104  z=zBegin-zEnd;
105 
106  /* 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 */
107  double volume1=(rEnd*rEnd+rBegin*rBegin+rBegin*rEnd)*z/3;
108  volume=volume+volume1;
109  i=i+2;
110  }
111 
112  /* last line (goes from last z/r value to first */
113  i=p_.size()-2;
114  zBegin=p_[i];
115  zEnd=p_[2];
116  rBegin=p_[i+1];
117  rEnd=p_[3];
118  z=zBegin-zEnd;
119 
120  double volume2=(rEnd*rEnd+rBegin*rBegin+rBegin*rEnd)*z/3;
121  volume=volume+volume2;
122  volume=std::fabs(slice*1_pi*volume);
123  result = volume;
124  }
125  return result;
126 }
DDSolidShape shape_
Definition: Solid.h:31
#define CONVERT_TO(_x, _y)
Definition: DDUnits.h:6
float float float z
double volume() const override
Definition: Polycone.cc:62
std::vector< double > p_
Definition: Solid.h:32
constexpr long double _pi(M_PI)