Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:27:43

0001 #include "GlobalDetRodRangeZPhi.h"
0002 #include "DataFormats/GeometrySurface/interface/Plane.h"
0003 #include "DataFormats/GeometrySurface/interface/Bounds.h"
0004 #include "DataFormats/GeometryVector/interface/VectorUtil.h"
0005 
0006 #include <array>
0007 
0008 GlobalDetRodRangeZPhi::GlobalDetRodRangeZPhi(const Plane& plane) {
0009   float dx = plane.bounds().width() / 2.;
0010   float dy = plane.bounds().length() / 2.;
0011   float dz = plane.bounds().thickness() / 2.;
0012 
0013   // rods may be inverted (actually are in every other layer), so have to find out the
0014   // orientation of the local frame
0015   float deltaZ =
0016       (plane.toGlobal(LocalPoint(0, 0, -dz)).perp() < plane.toGlobal(LocalPoint(0, 0, dz)).perp()) ? -dz : dz;
0017 
0018   const std::array<Surface::GlobalPoint, 4> corners{{plane.toGlobal(LocalPoint(-dx, -dy, deltaZ)),
0019                                                      plane.toGlobal(LocalPoint(-dx, dy, deltaZ)),
0020                                                      plane.toGlobal(LocalPoint(dx, -dy, deltaZ)),
0021                                                      plane.toGlobal(LocalPoint(dx, dy, deltaZ))}};
0022 
0023   float phimin = corners[0].phi();
0024   float phimax = phimin;
0025 
0026   float zmin = corners[0].z();
0027   float zmax = zmin;
0028 
0029   for (const auto& corner : corners) {
0030     float phi = corner.phi();
0031     if (Geom::phiLess(phi, phimin))
0032       phimin = phi;
0033     if (Geom::phiLess(phimax, phi))
0034       phimax = phi;
0035 
0036     float z = corner.z();
0037     zmin = std::min(zmin, z);
0038     zmax = std::max(zmax, z);
0039   }
0040 
0041   theZRange.first = zmin;
0042   theZRange.second = zmax;
0043   thePhiRange.first = phimin;
0044   thePhiRange.second = phimax;
0045 }