CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/DetectorDescription/Core/src/Cons.cc

Go to the documentation of this file.
00001 #include "DetectorDescription/Core/src/Cons.h"
00002 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00003 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00004 #include <cmath>
00005 #include <ostream>
00006 
00007 DDI::Cons::Cons(double zhalf,
00008          double rInMinusZ,
00009          double rOutMinusZ,
00010          double rInPlusZ,
00011          double rOutPlusZ,
00012          double startPhi,
00013          double deltaPhi)
00014  : Solid(ddcons)          
00015 {
00016   p_.push_back(zhalf);
00017   p_.push_back(rInMinusZ);
00018   p_.push_back(rOutMinusZ);
00019   p_.push_back(rInPlusZ);
00020   p_.push_back(rOutPlusZ);
00021   p_.push_back(startPhi);
00022   p_.push_back(deltaPhi);
00023 
00024 }        
00025 
00026 
00027 void DDI::Cons::stream(std::ostream & os) const
00028 {
00029    os << " zhalf=" << p_[0]/cm
00030       << " rIn-Z=" << p_[1]/cm
00031       << " rOut-Z=" << p_[2]/cm
00032       << " rIn+Z=" << p_[3]/cm
00033       << " rOut+Z=" << p_[4]/cm
00034       << " startPhi=" << p_[5]/deg
00035       << " deltaPhi=" << p_[6]/deg;
00036 }
00037 
00038 double DDI::Cons::volume() const
00039 {
00040   /* zhalf is the half length of the cone,
00041      phiTo is always clockwise rotated from phiFrom 
00042      rInMinusZ is always smaller than rOutMinusZ (same for r*PlusZ)
00043      They are the distances relative to the rotation axes */
00044 
00045   /* calculation normalize from 0 to z */
00046 
00047   /* The function f=rInMinusZ+((rInPlusZ-rInMinusZ)/z)*x defines
00048      the radius of the the rotation from 0 to z. Raised to the power
00049      of 2 integrated on x from 0 to z. Multiplied by pi, gives the
00050      volume that needs to substracted from the other volume */ 
00051      
00052   /* f^2=rInMinusZ*rInMinusZ+2*rInMinusZ*((rInPlusZ-rInMinusZ)/z)*x+((rInPlusZ-rInMinusZ)*(rInPlusZ-rInMinusZ)*x*x)/(z*z) */
00053 
00054   /* primitive of f^2 is: rInMinusZ*rInMinusZ*x+rInMinusZ*((rInPlusZ-rInMinusZ)/z)*(x*x)+(rInPlusZ-rInMinusZ)*(rInPlusZ-rInMinusZ)*(x*x*x)/(3*z*z) */
00055 
00056   /*integration from 0 to z yields: pi*( rInMinusZ*rInMinusZ*z+rInMinusZ*(rInPlusZ-rInMinusZ)*z+((rInPlusZ-rInMinusZ)*(rInPlusZ-rInMinusZ)*z)/(3) ) */
00057 
00058    double zhalf=p_[0]; 
00059    double rInMinusZ=p_[1]; 
00060    double rOutMinusZ=p_[2]; 
00061    double rInPlusZ=p_[3]; 
00062    double rOutPlusZ=p_[4];
00063    //double phiFrom=p_[5]/rad;
00064    double deltaPhi=fabs(p_[6]/rad); 
00065    double z=2*zhalf;
00066 
00067   double volume1=pi*(rInPlusZ*rInPlusZ+rInMinusZ*rInMinusZ+rInMinusZ*rInPlusZ)*z/3;
00068 
00069   double volume2=pi*(rOutPlusZ*rOutPlusZ+rOutMinusZ*rOutMinusZ+rOutMinusZ*rOutPlusZ)*z/3;
00070   
00071   double slice=deltaPhi/(2*pi);
00072   double volume=slice*(volume2-volume1);
00073 
00074   return volume;
00075 
00076 }
00077 
00078