Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32:21

0001 #include <cppunit/extensions/HelperMacros.h>
0002 #include "DataFormats/Candidate/interface/LeafCandidate.h"
0003 #include "PhysicsTools/CandUtils/interface/Thrust.h"
0004 using namespace reco;
0005 
0006 class testThrust : public CppUnit::TestFixture {
0007   CPPUNIT_TEST_SUITE(testThrust);
0008   CPPUNIT_TEST(checkAll);
0009   CPPUNIT_TEST_SUITE_END();
0010 
0011 public:
0012   void setUp() {}
0013   void tearDown() {}
0014   void checkAll();
0015 };
0016 
0017 CPPUNIT_TEST_SUITE_REGISTRATION(testThrust);
0018 
0019 void testThrust::checkAll() {
0020   {
0021     std::vector<LeafCandidate> cands;
0022     cands.push_back(LeafCandidate(+1, Particle::LorentzVector(1, 1, 0, 1)));
0023     cands.push_back(LeafCandidate(+1, Particle::LorentzVector(-1, -1, 0, 1)));
0024     Thrust t(cands.begin(), cands.end());
0025     CPPUNIT_ASSERT(fabs(t.thrust() - 1.0) < 1.e-6);
0026   }
0027   {
0028     std::vector<LeafCandidate> cands;
0029     cands.push_back(LeafCandidate(+1, Particle::LorentzVector(0.7, 0.5, 0, 1)));
0030     cands.push_back(LeafCandidate(+1, Particle::LorentzVector(-0.7, -0.5, 0, 1)));
0031     Thrust t(cands.begin(), cands.end());
0032     CPPUNIT_ASSERT(fabs(t.thrust() - 1.0) < 1.e-6);
0033   }
0034   {
0035     std::vector<LeafCandidate> cands;
0036     cands.push_back(LeafCandidate(+1, Particle::LorentzVector(1, 0, 0, 1)));
0037     cands.push_back(LeafCandidate(+1, Particle::LorentzVector(0, 1, 0, 1)));
0038     Thrust t(cands.begin(), cands.end());
0039     CPPUNIT_ASSERT(fabs(t.thrust() - sqrt(2.0) / 2) < 1.e-6);
0040   }
0041   {
0042     std::vector<LeafCandidate> cands;
0043     cands.push_back(LeafCandidate(+1, Particle::LorentzVector(1, 0, 0, 1)));
0044     cands.push_back(LeafCandidate(+1, Particle::LorentzVector(0, 1, 0, 1)));
0045     cands.push_back(LeafCandidate(+1, Particle::LorentzVector(1, 1, 0, 1)));
0046     Thrust t(cands.begin(), cands.end());
0047     CPPUNIT_ASSERT(t.thrust() > 0.5);
0048     CPPUNIT_ASSERT(fabs(t.axis().z()) < 1.e-4);
0049   }
0050 }