Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:42

0001 #ifndef DataFormats_Math_RectangularEtaPhiRegion_h
0002 #define DataFormats_Math_RectangularEtaPhiRegion_h
0003 
0004 #include "DataFormats/Math/interface/normalizedPhi.h"
0005 
0006 class RectangularEtaPhiRegion {
0007 public:
0008   RectangularEtaPhiRegion(float etaLow, float etaHigh, float phiLow, float phiHigh)
0009       : ceta(0.5f * (etaHigh + etaLow)), deta(0.5f * std::abs(etaHigh - etaLow)) {
0010     phiHigh = proxim(phiHigh, phiLow);
0011     constexpr float c1 = 2. * M_PI;
0012     if (phiHigh < phiLow)
0013       phiHigh += c1;
0014     dphi = 0.5f * (phiHigh - phiLow);
0015     cphi = phiLow + dphi;
0016   }
0017 
0018   bool inRegion(float eta, float phi) const {
0019     return std::abs(eta - ceta) < deta && std::abs(proxim(phi, cphi) - cphi) < dphi;
0020   }
0021 
0022   auto etaLow() const { return ceta - deta; }
0023   auto etaHigh() const { return ceta + deta; }
0024   auto phiLow() const { return cphi - dphi; }
0025   auto phiHigh() const { return cphi + dphi; }
0026 
0027 private:
0028   float ceta;
0029   float deta;
0030   float cphi;
0031   float dphi;
0032 };
0033 
0034 #endif