Go to the documentation of this file.00001 #include "DetectorDescription/Core/src/Ellipsoid.h"
00002 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00003 #include <iostream>
00004 #include <cmath>
00005
00006 void DDI::Ellipsoid::stream(std::ostream & os) const
00007 {
00008 os << " xSemiAxis[cm]=" << p_[0]/cm
00009 << " ySemiAxis[cm]=" << p_[1]/cm
00010 << " zSemiAxis" << p_[2]/cm
00011 << " zBottomCut" << p_[3]/cm
00012 << " zTopCut" << p_[4]/cm;
00013 }
00014
00015 double DDI::Ellipsoid::halfVol(double dz, double maxz) const {
00016 double volume(0.);
00017 double z(0.);
00018 double x(p_[0]), y(p_[1]);
00019 double c2 = p_[2] * p_[2];
00020 for (;z <= maxz; z=z+dz) {
00021
00022
00023
00024
00025
00026 if ( z*z / c2 > 1.0 ) {
00027 std::cout << "error!" << std::endl;
00028 exit(0);
00029 }
00030 x = p_[0] * sqrt( 1 - z*z/c2);
00031 y = p_[1] * sqrt( 1 - z*z/c2);
00032
00033
00034
00035 volume = volume + Geom::pi() * dz * x * y;
00036 }
00037
00038
00039
00040
00041 return volume;
00042 }
00043
00044 double DDI::Ellipsoid::volume() const {
00045 double volume(0.);
00046
00047 volume = 4./3. * Geom::pi() * p_[0] * p_[1] * p_[2];
00048 if ( p_[3] > 0.0 ) {
00049
00050 std::cout << "FAIL: p_[3] > 0.0" <<std::endl;
00051 } else if ( p_[4] < 0.0 ) {
00052
00053 std::cout << "FAIL: p_[4] < 0.0" <<std::endl;
00054 } else if ( p_[3] < 0. && p_[4] > 0. ) {
00055 volume = halfVol (p_[4]/100000., p_[4]) + halfVol (std::fabs(p_[3]/100000.), std::fabs(p_[3]));
00056 } else if ( p_[3] < 0. ) {
00057 volume = volume / 2 + halfVol(std::fabs(p_[3]/100000.), std::fabs(p_[3]));
00058 } else if ( p_[4] > 0. ) {
00059 volume = volume / 2 + halfVol (p_[4]/100000., p_[4]);
00060 }
00061 return volume;
00062
00063 }