CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DetectorDescription/Core/src/Sphere.cc

Go to the documentation of this file.
00001 #include "DetectorDescription/Core/src/Sphere.h"
00002 #include <DataFormats/GeometryVector/interface/Pi.h>
00003 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00004 
00005 #include <cmath>
00006 #include <ostream>
00007 
00008 DDI::Sphere::Sphere(double innerRadius,
00009                     double outerRadius,
00010                     double startPhi,
00011                     double deltaPhi,
00012                     double startTheta,
00013                     double deltaTheta)
00014  : Solid(ddsphere)        
00015 {
00016   p_.push_back(innerRadius);
00017   p_.push_back(outerRadius);
00018   p_.push_back(startPhi);
00019   p_.push_back(deltaPhi);
00020   p_.push_back(startTheta);
00021   p_.push_back(deltaTheta);
00022 }        
00023 
00024 
00025 void DDI::Sphere::stream(std::ostream & os) const
00026 {
00027    os << " innerRadius=" << p_[0]/cm
00028       << " outerRadius=" << p_[1]/cm
00029       << " startPhi=" << p_[2]/deg
00030       << " deltaPhi=" << p_[3]/deg
00031       << " startTheta=" << p_[4]/deg
00032       << " deltaTheta=" << p_[5]/deg;
00033 }
00034 
00035 double DDI::Sphere::volume() const
00036 {
00037   double volume(0.);
00038   if ( std::fabs(p_[3]) <= 2.*Geom::pi() && std::fabs(p_[5]) <= Geom::pi() ) {
00039     volume = std::fabs((p_[1]*p_[1]*p_[1] - p_[0]*p_[0]*p_[0])/3. * (std::cos(p_[4]+p_[5]) - std::cos(p_[4]))*p_[3]);
00040   } else if (std::fabs(p_[3]) <= 2.*Geom::pi() && std::fabs(p_[5]) > Geom::pi() ) {
00041     volume = std::fabs((p_[1]*p_[1]*p_[1] - p_[0]*p_[0]*p_[0])/3. * (std::cos(p_[4]+p_[5]-180.*deg) - std::cos(p_[4]))*p_[3]);
00042   } else if (std::fabs(p_[3]) > 2.*Geom::pi() && std::fabs(p_[5]) <= Geom::pi() ) {
00043     volume = std::fabs((p_[1]*p_[1]*p_[1] - p_[0]*p_[0]*p_[0])/3. * (std::cos(p_[4]+p_[5]) - std::cos(p_[4]))*(p_[3]-p_[2]));
00044   }
00045   return volume;
00046 }
00047 
00048