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