Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DataFormats/GeometryVector/interface/PhiInterval.h"
0002 #include "DataFormats/GeometryVector/interface/EtaInterval.h"
0003 
0004 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0005 
0006 #include "DataFormats/Math/interface/PtEtaPhiMass.h"
0007 
0008 #include <cassert>
0009 
0010 int main() {
0011   assert(!checkPhiInRange(-0.9f, 1.f, -1.f));
0012   assert(!checkPhiInRange(0.9f, 1.f, -1.f));
0013   assert(checkPhiInRange(-1.1f, 1.f, -1.f));
0014   assert(checkPhiInRange(1.1f, 1.f, -1.f));
0015 
0016   assert(checkPhiInRange(-0.9f, -1.f, 1.f));
0017   assert(checkPhiInRange(0.9f, -1.f, 1.f));
0018   assert(!checkPhiInRange(-1.1f, -1.f, 1.f));
0019   assert(!checkPhiInRange(1.1f, -1.f, 1.f));
0020 
0021   assert(checkPhiInRange(-2.9f, -3.f, 3.f));
0022   assert(checkPhiInRange(2.9f, -3.f, 3.f));
0023   assert(!checkPhiInRange(-3.1f, -3.f, 3.f));
0024   assert(!checkPhiInRange(3.1f, -3.f, 3.f));
0025 
0026   assert(!checkPhiInRange(-2.9f, 3.f, -3.f));
0027   assert(!checkPhiInRange(2.9f, 3.f, -3.f));
0028   assert(checkPhiInRange(-3.1f, 3.f, -3.f));
0029   assert(checkPhiInRange(3.1f, 3.f, -3.f));
0030 
0031   for (float x = -10; x < 10; x += 1.)
0032     for (float y = -10; y < 10; y += 1.)
0033       for (float z = -10; z < 10; z += 1.) {
0034         if (x == 0 && y == 0)
0035           continue;
0036         GlobalPoint p(x, y, z);
0037 
0038         // eta
0039         for (float eta = -4; eta < 3.5; eta += 0.2)
0040           for (float deta = 0.1; deta < 2.; deta += 0.2) {
0041             EtaInterval ei(eta, eta + deta);
0042             auto in = ei.inside(p.basicVector());
0043             auto e = etaFromXYZ(x, y, z);
0044             auto in2 = (e > eta) & (e < eta + deta);
0045             assert(in == in2);
0046           }
0047 
0048         //phi
0049         for (float phi = -6.001; phi < 6.5; phi += 0.2)
0050           for (float dphi = -3.1; dphi < 3.15; dphi += 0.2) {
0051             PhiInterval pi(phi, phi + dphi);
0052             auto in = pi.inside(p.basicVector());
0053             auto ph = p.barePhi();
0054             auto in2 = checkPhiInRange(ph, phi, phi + dphi);
0055             assert(in == in2);
0056           }
0057         {
0058           PhiInterval pi(3.f, -3.f);
0059           auto in = pi.inside(p.basicVector());
0060           auto ph = p.barePhi();
0061           auto it = ph > 3.f || ph < -3.f;
0062           assert(in == it);
0063           auto in2 = checkPhiInRange(ph, 3.f, -3.f);
0064           assert(in2 == it);
0065         }
0066         {
0067           PhiInterval pi(3.f, 4.f);
0068           auto in = pi.inside(p.basicVector());
0069           auto ph = p.barePhi();
0070           auto it = ph > 3.f || ph < 4 - 2 * M_PI;
0071           ;
0072           assert(in == it);
0073           auto in2 = checkPhiInRange(ph, 3.f, 4.f);
0074           assert(in2 == it);
0075         }
0076 
0077         {
0078           PhiInterval pi(-1.f, 1.f);
0079           auto in = pi.inside(p.basicVector());
0080           auto ph = p.barePhi();
0081           auto it = std::abs(ph) < 1;
0082           assert(in == it);
0083           auto in2 = checkPhiInRange(ph, -1.f, 1.f);
0084           assert(in2 == it);
0085         }
0086       }
0087   return 0;
0088 }