Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:26

0001 #include "DetectorDescription/Core/interface/Tubs.h"
0002 
0003 #include <cmath>
0004 #include <vector>
0005 
0006 #include "DetectorDescription/Core/interface/DDSolidShapes.h"
0007 #include "DataFormats/Math/interface/GeantUnits.h"
0008 #include "DetectorDescription/Core/interface/Solid.h"
0009 
0010 using std::fabs;
0011 using namespace geant_units::operators;
0012 
0013 DDI::Tubs::Tubs(double zhalf, double rIn, double rOut, double startPhi, double deltaPhi) : Solid(DDSolidShape::ddtubs) {
0014   p_.emplace_back(zhalf);
0015   p_.emplace_back(rIn);
0016   p_.emplace_back(rOut);
0017   p_.emplace_back(startPhi);
0018   p_.emplace_back(deltaPhi);
0019 }
0020 
0021 void DDI::Tubs::stream(std::ostream& os) const {
0022   os << " zhalf=" << convertMmToCm(p_[0]) << " rIn=" << convertMmToCm(p_[1]) << " rOut=" << convertMmToCm(p_[2])
0023      << " startPhi=" << convertRadToDeg(p_[3]) << " deltaPhi=" << convertRadToDeg(p_[4]);
0024 }
0025 
0026 double DDI::Tubs::volume() const {
0027   double volume = 0;
0028   double z = 2. * p_[0];
0029   double rIn = p_[1];
0030   double rOut = p_[2];
0031   double phi = p_[4];
0032 
0033   double volume1 = 1_pi * rIn * rIn * z;
0034   double volume2 = 1_pi * rOut * rOut * z;
0035 
0036   double slice = fabs(phi / (2_pi));
0037 
0038   volume = slice * (volume2 - volume1);
0039 
0040   return volume;
0041 }