Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-04 02:02:27

0001 #include "DetectorDescription/Core/interface/Trap.h"
0002 #include "DataFormats/Math/interface/GeantUnits.h"
0003 
0004 #include <cmath>
0005 #include <vector>
0006 
0007 #include "DetectorDescription/Core/interface/DDSolidShapes.h"
0008 #include "DetectorDescription/Core/interface/Solid.h"
0009 
0010 using std::sqrt;
0011 using namespace geant_units::operators;
0012 
0013 DDI::Trap::Trap(double pDz,
0014                 double pTheta,
0015                 double pPhi,
0016                 double pDy1,
0017                 double pDx1,
0018                 double pDx2,
0019                 double pAlp1,
0020                 double pDy2,
0021                 double pDx3,
0022                 double pDx4,
0023                 double pAlp2)
0024     : Solid(DDSolidShape::ddtrap) {
0025   p_.emplace_back(pDz);     // ......... 0
0026   p_.emplace_back(pTheta);  // .. 1
0027   p_.emplace_back(pPhi);    // ....... 2
0028   p_.emplace_back(pDy1);    // ........ 3
0029   p_.emplace_back(pDx1);    // ........ 4
0030   p_.emplace_back(pDx2);    // ........ 5
0031   p_.emplace_back(pAlp1);   // ....... 6
0032   p_.emplace_back(pDy2);    // ........ 7
0033   p_.emplace_back(pDx3);    // ......... 8
0034   p_.emplace_back(pDx4);    // ........ 9
0035   p_.emplace_back(pAlp2);
0036 }
0037 
0038 void DDI::Trap::stream(std::ostream& os) const {
0039   os << " dz=" << convertMmToCm(p_[0]) << " theta=" << convertRadToDeg(p_[1]) << " phi=" << convertRadToDeg(p_[2])
0040      << " dy1=" << convertMmToCm(p_[3]) << " dx1=" << convertMmToCm(p_[4]) << " dx2=" << convertMmToCm(p_[5])
0041      << " alpha1=" << convertRadToDeg(p_[6]) << " dy2=" << convertMmToCm(p_[7]) << " dx3=" << convertMmToCm(p_[8])
0042      << " dx4=" << convertMmToCm(p_[9]) << " alpha2=" << convertRadToDeg(p_[10]);
0043 }
0044 
0045 double DDI::Trap::volume() const {
0046   double volume = 0;
0047 
0048   double dz = p_[0] * 2.;
0049   double dy1 = p_[3] * 2.;
0050   double dx1 = p_[4] * 2.;
0051   double dx2 = p_[5] * 2.;
0052   double dy2 = p_[7] * 2.;
0053   double dx3 = p_[8] * 2.;
0054   double dx4 = p_[9] * 2.;
0055 
0056   volume = ((dx1 + dx2 + dx3 + dx4) * (dy1 + dy2) + (dx4 + dx3 - dx2 - dx1) * (dy2 - dy1) / 3) * dz * 0.125;
0057 
0058   return volume;
0059 }