CMS 3D CMS Logo

Public Member Functions

DDI::Ellipsoid Class Reference

#include <Ellipsoid.h>

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

List of all members.

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
double volume () const
 Not as flexible and possibly less accurate than G4 volume.
 ~Ellipsoid ()

Detailed Description

Definition at line 10 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 13 of file Ellipsoid.h.

References DDI::Solid::p_.

      : Solid(ddellipsoid)
      { 
        p_.push_back(xSemiAxis);
        p_.push_back(ySemiAxis);
        p_.push_back(zSemiAxis);
        p_.push_back(zBottomCut);
        p_.push_back(zTopCut);
      }  
DDI::Ellipsoid::~Ellipsoid ( ) [inline]

Definition at line 27 of file Ellipsoid.h.

{ }

Member Function Documentation

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

Definition at line 15 of file Ellipsoid.cc.

References gather_cfg::cout, cmsRelvalreport::exit, pi, mathSSE::sqrt(), x, detailsBasic3DVector::y, and z.

                                                          {
  double volume(0.);
  double z(0.);
  double x(p_[0]), y(p_[1]);
  double c2 = p_[2] * p_[2];
  for (;z <= maxz; z=z+dz) {
    // what is x here? what is y?  This assumes a TRIANGLE approximation 
    // This assumes that I can estimate the decrease in x and y at current z
    // at current z, x is the projection down to the x axis.
    // x = a * sqrt(1-z^2 / c^2 )
    // unneccesary paranoia?
    if ( z*z / c2 >  1.0 ) {
      std::cout << "error!" << std::endl;
      exit(0);
    }
    x = p_[0] * sqrt( 1 - z*z/c2);
    y = p_[1] * sqrt( 1 - z*z/c2);
//     if (dispcount < 100)
//     std::cout << "x = " << x << " y = " << y << " z = " << z << std::endl;
//     ++dispcount;
    volume = volume + Geom::pi() * dz * x  * y;
  }
//   std::cout << " x = " << x;
//   std::cout << " y = " << y;
//   std::cout << " z = " << z;
//   std::cout << " vol = " << volume << std::endl;
  return volume;
}
void DDI::Ellipsoid::stream ( std::ostream &  os) const [virtual]

Reimplemented from DDI::Solid.

Definition at line 6 of file Ellipsoid.cc.

References DDI::Solid::p_.

{
   os << " xSemiAxis[cm]=" << p_[0]/cm
      << " ySemiAxis[cm]=" << p_[1]/cm
      << " zSemiAxis" << p_[2]/cm
      << " zBottomCut" << p_[3]/cm
      << " zTopCut" << p_[4]/cm;
}
double DDI::Ellipsoid::volume ( void  ) const [virtual]

Not as flexible and possibly less accurate than G4 volume.

Reimplemented from DDI::Solid.

Definition at line 44 of file Ellipsoid.cc.

References gather_cfg::cout, and pi.

                                  { 
  double volume(0.);
  // default if both p_[3] and p_[4] are 0
  volume = 4./3. * Geom::pi() * p_[0] * p_[1] * p_[2];
  if ( p_[3] > 0.0 ) {
    //fail
    std::cout << "FAIL: p_[3] > 0.0" <<std::endl;
  } else if ( p_[4] < 0.0 ) {
    //fail
    std::cout << "FAIL: p_[4] <  0.0" <<std::endl;
  } else if ( p_[3] < 0. && p_[4] > 0. ) {
    volume = halfVol (p_[4]/100000., p_[4]) + halfVol (std::fabs(p_[3]/100000.), std::fabs(p_[3]));
  } else if ( p_[3] < 0. ) {
    volume = volume / 2 + halfVol(std::fabs(p_[3]/100000.), std::fabs(p_[3]));
  } else if ( p_[4] > 0. ) {
    volume = volume / 2 + halfVol (p_[4]/100000., p_[4]);
  }
  return volume; 

}