Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:31

0001 #include "DataFormats/GeometrySurface/interface/BoundSpan.h"
0002 #include "DataFormats/GeometrySurface/interface/Surface.h"
0003 #include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h"
0004 #include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h"
0005 
0006 #include "DataFormats/GeometryVector/interface/VectorUtil.h"
0007 
0008 void BoundSpan::compute(Surface const& plane) {
0009   const TrapezoidalPlaneBounds* trapezoidalBounds(dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
0010   const RectangularPlaneBounds* rectangularBounds(dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
0011 
0012   Surface::GlobalPoint corners[8];
0013 
0014   if (trapezoidalBounds) {
0015     std::array<const float, 4> const& parameters = (*trapezoidalBounds).parameters();
0016 
0017     auto hbotedge = parameters[0];
0018     auto htopedge = parameters[1];
0019     auto hapothem = parameters[3];
0020     auto thickness = (*trapezoidalBounds).thickness();
0021 
0022     corners[0] = plane.toGlobal(LocalPoint(-htopedge, hapothem, thickness / 2));
0023     corners[1] = plane.toGlobal(LocalPoint(htopedge, hapothem, thickness / 2));
0024     corners[2] = plane.toGlobal(LocalPoint(hbotedge, -hapothem, thickness / 2));
0025     corners[3] = plane.toGlobal(LocalPoint(-hbotedge, -hapothem, thickness / 2));
0026     corners[4] = plane.toGlobal(LocalPoint(-htopedge, hapothem, -thickness / 2));
0027     corners[5] = plane.toGlobal(LocalPoint(htopedge, hapothem, -thickness / 2));
0028     corners[6] = plane.toGlobal(LocalPoint(hbotedge, -hapothem, -thickness / 2));
0029     corners[7] = plane.toGlobal(LocalPoint(-hbotedge, -hapothem, -thickness / 2));
0030 
0031   } else if (rectangularBounds) {
0032     auto length = rectangularBounds->length();
0033     auto width = rectangularBounds->width();
0034     auto thickness = (*rectangularBounds).thickness();
0035 
0036     corners[0] = plane.toGlobal(LocalPoint(-width / 2, -length / 2, thickness / 2));
0037     corners[1] = plane.toGlobal(LocalPoint(-width / 2, +length / 2, thickness / 2));
0038     corners[2] = plane.toGlobal(LocalPoint(+width / 2, -length / 2, thickness / 2));
0039     corners[3] = plane.toGlobal(LocalPoint(+width / 2, +length / 2, thickness / 2));
0040     corners[4] = plane.toGlobal(LocalPoint(-width / 2, -length / 2, -thickness / 2));
0041     corners[5] = plane.toGlobal(LocalPoint(-width / 2, +length / 2, -thickness / 2));
0042     corners[6] = plane.toGlobal(LocalPoint(+width / 2, -length / 2, -thickness / 2));
0043     corners[7] = plane.toGlobal(LocalPoint(+width / 2, +length / 2, -thickness / 2));
0044   } else {
0045   }
0046 
0047   float phimin = corners[0].barePhi();
0048   float phimax = phimin;
0049   float zmin = corners[0].z();
0050   float zmax = zmin;
0051   float rmin = corners[0].perp2();
0052   float rmax = rmin;
0053   for (int i = 1; i < 8; i++) {
0054     auto cPhi = corners[i].barePhi();
0055     if (Geom::phiLess(cPhi, phimin)) {
0056       phimin = cPhi;
0057     }
0058     if (Geom::phiLess(phimax, cPhi)) {
0059       phimax = cPhi;
0060     }
0061     auto z = corners[i].z();
0062     if (z < zmin)
0063       zmin = z;
0064     if (z > zmax)
0065       zmax = z;
0066     auto r = corners[i].perp2();
0067     if (r < rmin)
0068       rmin = r;
0069     if (r > rmax)
0070       rmax = r;
0071   }
0072   m_zSpan.first = zmin;
0073   m_zSpan.second = zmax;
0074   m_rSpan.first = std::sqrt(rmin);
0075   m_rSpan.second = std::sqrt(rmax);
0076   m_phiSpan.first = phimin;
0077   m_phiSpan.second = phimax;
0078 }