Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:54

0001 #include <cppunit/extensions/HelperMacros.h>
0002 #include "DataFormats/VertexReco/interface/Vertex.h"
0003 
0004 class testVertex : public CppUnit::TestFixture {
0005   CPPUNIT_TEST_SUITE(testVertex);
0006   CPPUNIT_TEST(checkAll);
0007   CPPUNIT_TEST_SUITE_END();
0008 
0009 public:
0010   void setUp() {}
0011   void tearDown() {}
0012   void checkAll();
0013 };
0014 
0015 CPPUNIT_TEST_SUITE_REGISTRATION(testVertex);
0016 
0017 void testVertex::checkAll() {
0018   const double chi2 = 20.0;
0019   const double ndof = 10;
0020   const size_t size = 0;  // can't test refs at the moment

0021   const double x = 1.0, y = 2.0, z = 3.0;
0022   const float ee[reco::Vertex::Error::kSize] = {1.1, 1.2, 1.3, 2.2, 2.3, 3.3};
0023   reco::Vertex::Error err;
0024   int k = 0;
0025   for (int i = 0; i < reco::Vertex::Error::kRows; ++i)
0026     for (int j = i; j < reco::Vertex::Error::kCols; ++j)
0027       err(i, j) = ee[k++];
0028 
0029   reco::Vertex t(reco::Vertex::Point(x, y, z), err, chi2, ndof, size);
0030   CPPUNIT_ASSERT(t.tracksSize() == 0);
0031   CPPUNIT_ASSERT(t.chi2() == chi2);
0032   CPPUNIT_ASSERT(t.ndof() == ndof);
0033   CPPUNIT_ASSERT(t.normalizedChi2() == chi2 / ndof);
0034   CPPUNIT_ASSERT(t.x() == x);
0035   CPPUNIT_ASSERT(t.y() == y);
0036   CPPUNIT_ASSERT(t.z() == z);
0037   const reco::Vertex::Error e = t.covariance();
0038   const float e00 = e(0, 0), e01 = e(0, 1), e02 = e(0, 2), e10 = e(1, 0), e11 = e(1, 1), e12 = e(1, 2), e20 = e(2, 0),
0039               e21 = e(2, 1), e22 = e(2, 2);
0040 
0041   CPPUNIT_ASSERT(e00 == ee[0]);
0042   CPPUNIT_ASSERT(e01 == ee[1]);
0043   CPPUNIT_ASSERT(e02 == ee[2]);
0044 
0045   CPPUNIT_ASSERT(e10 == ee[1]);
0046   CPPUNIT_ASSERT(e11 == ee[3]);
0047   CPPUNIT_ASSERT(e12 == ee[4]);
0048 
0049   CPPUNIT_ASSERT(e20 == ee[2]);
0050   CPPUNIT_ASSERT(e21 == ee[4]);
0051   CPPUNIT_ASSERT(e22 == ee[5]);
0052 }