File indexing completed on 2024-04-06 12:21:00
0001 #include "Utilities/Testing/interface/CppUnit_testdriver.icpp"
0002 #include "cppunit/extensions/HelperMacros.h"
0003
0004 #include "L1Trigger/L1TMuonEndCap/interface/TrackTools.h"
0005
0006 class TestTrackTools : public CppUnit::TestFixture {
0007 CPPUNIT_TEST_SUITE(TestTrackTools);
0008 CPPUNIT_TEST(test_pt);
0009 CPPUNIT_TEST(test_eta);
0010 CPPUNIT_TEST(test_theta);
0011 CPPUNIT_TEST(test_phi);
0012 CPPUNIT_TEST_SUITE_END();
0013
0014 public:
0015 TestTrackTools() {}
0016 ~TestTrackTools() {}
0017 void setUp() {}
0018 void tearDown() {}
0019
0020 void test_pt();
0021 void test_eta();
0022 void test_theta();
0023 void test_phi();
0024 };
0025
0026
0027 CPPUNIT_TEST_SUITE_REGISTRATION(TestTrackTools);
0028
0029 using namespace emtf;
0030
0031 void TestTrackTools::test_pt() {
0032 for (int i = 0; i < 2048; ++i) {
0033 double pt = 0.5 * static_cast<double>(i);
0034 double eps = 0.5;
0035 CPPUNIT_ASSERT_DOUBLES_EQUAL(std::min(pt, 255.), calc_pt(calc_pt_GMT(pt)), eps);
0036 }
0037 }
0038
0039 void TestTrackTools::test_eta() {
0040 for (int i = 0; i < 501; ++i) {
0041 double eta = -2.5 + 0.01 * static_cast<double>(i);
0042 double eps = 0.010875;
0043 CPPUNIT_ASSERT_DOUBLES_EQUAL(eta, calc_eta(calc_eta_GMT(eta)), eps);
0044 }
0045 }
0046
0047 void TestTrackTools::test_theta() {
0048 for (int i = 0; i < 1801; ++i) {
0049 double theta = 0. + 0.1 * static_cast<double>(i);
0050 int endcap = (theta >= 90.) ? -1 : 1;
0051 double eps = 0.28515625;
0052 CPPUNIT_ASSERT_DOUBLES_EQUAL(
0053 (endcap == -1 ? (180. - theta) : theta), calc_theta_deg_from_int(calc_theta_int(theta, endcap)), eps);
0054 }
0055 }
0056
0057 void TestTrackTools::test_phi() {
0058 for (int i = 0; i < 3600; ++i) {
0059 double phi = -180. + 0.1 * static_cast<double>(i);
0060 int sector = (phi - 15. < 0.) ? int((phi - 15. + 360.) / 60.) + 1 : int((phi - 15.) / 60.) + 1;
0061 int neigh_sector =
0062 (phi - 15. + 22. < 0.) ? int((phi - 15. + 22. + 360.) / 60.) + 1 : int((phi - 15. + 22.) / 60.) + 1;
0063 double eps = 360. / 576;
0064 CPPUNIT_ASSERT_DOUBLES_EQUAL(phi, calc_phi_GMT_deg(calc_phi_GMT_int(phi)), eps);
0065 CPPUNIT_ASSERT_DOUBLES_EQUAL(phi, calc_phi_GMT_deg(calc_phi_GMT_int(phi + 360.)), eps);
0066 CPPUNIT_ASSERT_DOUBLES_EQUAL(phi, calc_phi_GMT_deg(calc_phi_GMT_int(phi - 360.)), eps);
0067
0068 eps = 1. / 60;
0069 CPPUNIT_ASSERT_DOUBLES_EQUAL(phi, calc_phi_glob_deg(calc_phi_loc_deg(calc_phi_loc_int(phi, sector)), sector), eps);
0070 CPPUNIT_ASSERT_DOUBLES_EQUAL(
0071 phi, calc_phi_glob_deg(calc_phi_loc_deg(calc_phi_loc_int(phi + 360., sector)), sector), eps);
0072 CPPUNIT_ASSERT_DOUBLES_EQUAL(
0073 phi, calc_phi_glob_deg(calc_phi_loc_deg(calc_phi_loc_int(phi - 360., sector)), sector), eps);
0074 if ((sector == 6 && neigh_sector == 1) || (sector != 6 && neigh_sector == sector + 1)) {
0075 CPPUNIT_ASSERT_DOUBLES_EQUAL(
0076 phi, calc_phi_glob_deg(calc_phi_loc_deg(calc_phi_loc_int(phi, neigh_sector)), neigh_sector), eps);
0077 CPPUNIT_ASSERT_DOUBLES_EQUAL(
0078 phi, calc_phi_glob_deg(calc_phi_loc_deg(calc_phi_loc_int(phi + 360., neigh_sector)), neigh_sector), eps);
0079 CPPUNIT_ASSERT_DOUBLES_EQUAL(
0080 phi, calc_phi_glob_deg(calc_phi_loc_deg(calc_phi_loc_int(phi - 360., neigh_sector)), neigh_sector), eps);
0081 }
0082 }
0083 }