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::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)
 
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 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 16 of file Polycone.cc.

References i, DDI::Solid::p_, and asciidump::s.

21 {
22  p_.push_back(startPhi);
23  p_.push_back(deltaPhi);
24  if((z.size()!=rmin.size()) || (z.size()!=rmax.size()) )
25  {
26  std::string s=std::string("Polycone(..): std::vectors z,rmin,rmax not of same length");
27  throw DDException(s);
28  }
29  else
30  {
31  for(unsigned int i=0;i<z.size(); ++i)
32  {
33  p_.push_back(z[i]);
34  p_.push_back(rmin[i]);
35  p_.push_back(rmax[i]);
36  }
37  }
38 }
int i
Definition: DBlmapReader.cc:9
double deltaPhi(float phi1, float phi2)
Definition: VectorUtil.h:30
An exception for DDD errors.
Definition: DDException.h:23
double double double z
Solid()
Definition: Solid.h:20
std::vector< double > p_
Definition: Solid.h:41
string s
Definition: asciidump.py:422
Polycone::Polycone ( double  startPhi,
double  deltaPhi,
const std::vector< double > &  z,
const std::vector< double > &  r 
)

Definition at line 41 of file Polycone.cc.

References i, DDI::Solid::p_, and asciidump::s.

45 {
46  p_.push_back(startPhi);
47  p_.push_back(deltaPhi);
48  if(z.size()!=r.size())
49  {
50  std::string s=std::string("Polycone(..): std::vectors z,rmin,rmax not of same length");
51  throw DDException(s);
52  }
53  else
54  {
55  for(unsigned int i=0;i<z.size(); ++i)
56  {
57  p_.push_back(z[i]);
58  p_.push_back(r[i]);
59  }
60  }
61 }
int i
Definition: DBlmapReader.cc:9
double deltaPhi(float phi1, float phi2)
Definition: VectorUtil.h:30
An exception for DDD errors.
Definition: DDException.h:23
double double double z
Solid()
Definition: Solid.h:20
std::vector< double > p_
Definition: Solid.h:41
string s
Definition: asciidump.py:422

Member Function Documentation

double Polycone::volume ( ) const
virtual

Reimplemented from DDI::Solid.

Definition at line 64 of file Polycone.cc.

References DCOUT, ddpolycone_rrz, ddpolycone_rz, i, j, python.cmstools::loop(), DDI::Solid::p_, pi, query::result, asciidump::s, DDI::Solid::shape_, and detailsBasic3DVector::z.

65 {
66  double result = -1.;
67  if (shape_==ddpolycone_rrz) {
68  int loop = (p_.size()-2)/3 -1;
69  assert(loop>0);
70  double sec=0;
71  DCOUT('V',"Polycone::volume(), loop=" << loop);
72  int i=2;
73  for (int j=2; j<(loop+2); ++j) {
74  double dz= std::fabs(p_[i]-p_[i+3]);
75  DCOUT('v', " dz=" << dz/cm << "cm zi=" << p_[i] << " zii=" << p_[i+3] );
76  double v_min = dz * pi/3. *( p_[i+1]*p_[i+1] + p_[i+4]*p_[i+4]
77  + p_[i+1]*p_[i+4] );
78  DCOUT('v', " v_min" << v_min/cm3 << "cm3 rmi=" << p_[i+1]);
79  double v_max = dz * pi/3. *( p_[i+2]*p_[i+2] + p_[i+5]*p_[i+5]
80  + p_[i+2]*p_[i+5] );
81  DCOUT('v', " v_max" << v_max/cm3 << "cm3");
82  double s = v_max - v_min;
83  //assert(s>=0);
84  sec += s;
85  i += 3;
86  }
87  result = sec * std::fabs(p_[1])/rad/(2.*pi);
88  }
89 
90  if (shape_==ddpolycone_rz) {
91  double volume=0;
92  double phiFrom=p_[0]/rad;
93  double phiTo=(p_[0]+p_[1])/rad;
94  double slice=(std::fabs(phiFrom-phiTo))/(2*pi);
95  double zBegin=0;
96  double zEnd=0;
97  double rBegin=0;
98  double rEnd=0;
99  double z=0;
100  unsigned int i=2;
101 
102  while(i<(p_.size()-2))
103  {
104  zBegin=p_[i];
105  zEnd=p_[i+2];
106  rBegin=p_[i+1];
107  rEnd=p_[i+3];
108  z=zBegin-zEnd;
109 
110  /* 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 */
111 
112  double volume1=(rEnd*rEnd+rBegin*rBegin+rBegin*rEnd)*z/3;
113 
114  volume=volume+volume1;
115 
116  i=i+2;
117  }
118 
119  /* last line (goes from last z/r value to first */
120  i=p_.size()-2;
121  zBegin=p_[i];
122  zEnd=p_[2];
123  rBegin=p_[i+1];
124  rEnd=p_[3];
125  z=zBegin-zEnd;
126 
127  double volume2=(rEnd*rEnd+rBegin*rBegin+rBegin*rEnd)*z/3;
128 
129 
130  volume=volume+volume2;
131 
132  volume=std::fabs(slice*pi*volume);
133 
134  result = volume;
135 
136  }
137  return result;
138 }
int i
Definition: DBlmapReader.cc:9
double volume() const
Definition: Polycone.cc:64
DDSolidShape shape_
Definition: Solid.h:40
double double double z
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
std::vector< double > p_
Definition: Solid.h:41
string s
Definition: asciidump.py:422
double pi
#define DCOUT(M_v_Y, M_v_S)
Definition: DDdebug.h:53