CMS 3D CMS Logo

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

#include <Ellipsoid.h>

Inheritance diagram for DDI::Ellipsoid:
DDI::Solid

Public Member Functions

 Ellipsoid (double xSemiAxis, double ySemiAxis, double zSemiAxis, double zBottomCut=0, double zTopCut=0)
 
double halfVol (double dz, double maxz) const
 
void stream (std::ostream &os) const override
 
double volume () const override
 Not as flexible and possibly less accurate than G4 volume. More...
 
 ~Ellipsoid () 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 13 of file Ellipsoid.h.

Constructor & Destructor Documentation

DDI::Ellipsoid::Ellipsoid ( double  xSemiAxis,
double  ySemiAxis,
double  zSemiAxis,
double  zBottomCut = 0,
double  zTopCut = 0 
)
inline

Definition at line 16 of file Ellipsoid.h.

References DDI::Solid::p_.

23  {
24  p_.emplace_back(xSemiAxis);
25  p_.emplace_back(ySemiAxis);
26  p_.emplace_back(zSemiAxis);
27  p_.emplace_back(zBottomCut);
28  p_.emplace_back(zTopCut);
29  }
Solid()
Definition: Solid.h:14
std::vector< double > p_
Definition: Solid.h:32
DDI::Ellipsoid::~Ellipsoid ( )
inlineoverride

Definition at line 30 of file Ellipsoid.h.

References PVValHelper::dz, halfVol(), stream(), and volume().

30 { }

Member Function Documentation

double DDI::Ellipsoid::halfVol ( double  dz,
double  maxz 
) const

Definition at line 20 of file Ellipsoid.cc.

References gather_cfg::cout, PVValHelper::dz, cmsRelvalreport::exit, DDI::Solid::p_, Geom::pi(), mathSSE::sqrt(), and volume().

Referenced by volume(), and ~Ellipsoid().

20  {
21  double volume(0.);
22  double z(0.);
23  double x;
24  double y;
25  double c2 = p_[2] * p_[2];
26  for (;z <= maxz; z=z+dz) {
27  // what is x here? what is y? This assumes a TRIANGLE approximation
28  // This assumes that I can estimate the decrease in x and y at current z
29  // at current z, x is the projection down to the x axis.
30  // x = a * sqrt(1-z^2 / c^2 )
31  // unneccesary paranoia?
32  if ( z*z / c2 > 1.0 ) {
33  std::cout << "error!" << std::endl;
34  exit(0);
35  }
36  x = p_[0] * sqrt( 1 - z*z/c2);
37  y = p_[1] * sqrt( 1 - z*z/c2);
38 // if (dispcount < 100)
39 // std::cout << "x = " << x << " y = " << y << " z = " << z << std::endl;
40 // ++dispcount;
41  volume = volume + Geom::pi() * dz * x * y;
42  }
43 // std::cout << " x = " << x;
44 // std::cout << " y = " << y;
45 // std::cout << " z = " << z;
46 // std::cout << " vol = " << volume << std::endl;
47  return volume;
48 }
float float float z
T sqrt(T t)
Definition: SSEVec.h:18
std::vector< double > p_
Definition: Solid.h:32
double volume() const override
Not as flexible and possibly less accurate than G4 volume.
Definition: Ellipsoid.cc:50
constexpr double pi()
Definition: Pi.h:31
void DDI::Ellipsoid::stream ( std::ostream &  os) const
overridevirtual

Reimplemented from DDI::Solid.

Definition at line 11 of file Ellipsoid.cc.

References DDI::Solid::p_.

Referenced by ~Ellipsoid().

12 {
13  os << " xSemiAxis[cm]=" << p_[0]/cm
14  << " ySemiAxis[cm]=" << p_[1]/cm
15  << " zSemiAxis" << p_[2]/cm
16  << " zBottomCut" << p_[3]/cm
17  << " zTopCut" << p_[4]/cm;
18 }
std::vector< double > p_
Definition: Solid.h:32
double DDI::Ellipsoid::volume ( void  ) const
overridevirtual

Not as flexible and possibly less accurate than G4 volume.

Reimplemented from DDI::Solid.

Definition at line 50 of file Ellipsoid.cc.

References gather_cfg::cout, halfVol(), DDI::Solid::p_, and Geom::pi().

Referenced by halfVol(), and ~Ellipsoid().

50  {
51  double volume(0.);
52  // default if both p_[3] and p_[4] are 0
53  volume = 4./3. * Geom::pi() * p_[0] * p_[1] * p_[2];
54  if ( p_[3] > 0.0 ) {
55  //fail
56  std::cout << "FAIL: p_[3] > 0.0" <<std::endl;
57  } else if ( p_[4] < 0.0 ) {
58  //fail
59  std::cout << "FAIL: p_[4] < 0.0" <<std::endl;
60  } else if ( p_[3] < 0. && p_[4] > 0. ) {
61  volume = halfVol (p_[4]/100000., p_[4]) + halfVol (std::fabs(p_[3]/100000.), std::fabs(p_[3]));
62  } else if ( p_[3] < 0. ) {
63  volume = volume / 2 + halfVol(std::fabs(p_[3]/100000.), std::fabs(p_[3]));
64  } else if ( p_[4] > 0. ) {
65  volume = volume / 2 + halfVol (p_[4]/100000., p_[4]);
66  }
67  return volume;
68 
69 }
double halfVol(double dz, double maxz) const
Definition: Ellipsoid.cc:20
std::vector< double > p_
Definition: Solid.h:32
double volume() const override
Not as flexible and possibly less accurate than G4 volume.
Definition: Ellipsoid.cc:50
constexpr double pi()
Definition: Pi.h:31