Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:24:28

0001 // -*- C++ -*-
0002 //
0003 // utilitiesTestKinematics.h is a part of Herwig - A multi-purpose Monte Carlo event generator
0004 // Copyright (C) 2002-2019 The Herwig Collaboration, 2015 Marco A. Harrendorf
0005 //
0006 // Herwig is licenced under version 3 of the GPL, see COPYING for details.
0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
0008 //
0009 #ifndef HERWIG_Utilities_Test_Kinematics_H
0010 #define HERWIG_Utilities_Test_Kinematics_H
0011 
0012 #include <boost/test/unit_test.hpp>
0013 
0014 #include "Herwig/Utilities/Kinematics.h"
0015 
0016 #include "ThePEG/Config/Unitsystem.h"
0017 
0018 using namespace Herwig::Kinematics;
0019 using namespace ThePEG::Units;
0020 
0021 struct FixKinematics1 {
0022   FixKinematics1()  
0023   {BOOST_TEST_MESSAGE( "setup fixture for utilitiesKinematicsTestTest" );  }
0024   
0025   ~FixKinematics1()  { BOOST_TEST_MESSAGE( "teardown fixture for utilitiesKinematicsTest" ); }
0026 };
0027 
0028 /*
0029  * Start of boost unit tests for Kinematics.h
0030  *
0031  * @todo Implement unit test for threeBodyDecay
0032  */
0033 BOOST_AUTO_TEST_SUITE(utilitiesKinematicsTest)
0034 
0035 /*
0036  * Boost unit tests
0037  *
0038  */
0039 BOOST_AUTO_TEST_CASE(generateAnglesTest)
0040 {
0041   double flatMinusPiToPlusPi, flatNullToTwoPi;
0042   for(int i = 0; i < 100; ++i) {
0043     generateAngles(flatMinusPiToPlusPi, flatNullToTwoPi);
0044     BOOST_CHECK( -M_PI <= flatMinusPiToPlusPi );
0045     BOOST_CHECK( flatMinusPiToPlusPi <= M_PI);
0046     BOOST_CHECK( 0. <= flatNullToTwoPi);
0047     BOOST_CHECK(flatNullToTwoPi <= 2*M_PI);
0048   }
0049 }
0050     
0051 BOOST_AUTO_TEST_CASE(unitDirectionTest)
0052 {
0053   using namespace Herwig::Kinematics;
0054   BOOST_CHECK_EQUAL( unitDirection(1.1, -1), Axis() );
0055   BOOST_CHECK_EQUAL( unitDirection(-1.1, -1), Axis() );
0056   BOOST_CHECK_EQUAL( unitDirection(1.1, 0), Axis() );
0057   BOOST_CHECK_EQUAL( unitDirection(-1.1, -1), Axis() );
0058   
0059   BOOST_CHECK_EQUAL( unitDirection(1, 0), Axis(0, 0, 1) );
0060   BOOST_CHECK_EQUAL( unitDirection(1, M_PI/2.), Axis(0, 0, 1) );
0061   
0062   BOOST_CHECK(unitDirection(0, M_PI/2).almostEqual(Axis(0, 1, 0), 0.001) );
0063   BOOST_CHECK_EQUAL( unitDirection(0, 0), Axis(1, 0, 0) );
0064 }
0065     
0066 BOOST_AUTO_TEST_CASE(pstarTwoBodyDecayTest)
0067 {
0068   BOOST_CHECK_EQUAL(pstarTwoBodyDecay(Energy(-100*GeV), Energy(60*GeV), Energy(60*GeV))/GeV, Energy(0*GeV)/GeV);
0069   BOOST_CHECK_EQUAL(pstarTwoBodyDecay(Energy(100*GeV), Energy(-40*GeV), Energy(40*GeV))/GeV, Energy(0*GeV)/GeV);
0070   BOOST_CHECK_EQUAL(pstarTwoBodyDecay(Energy(100*GeV), Energy(-40*GeV), Energy(-40*GeV))/GeV, Energy(0*GeV)/GeV);
0071   
0072   BOOST_CHECK_EQUAL(pstarTwoBodyDecay(Energy(100*GeV), Energy(60*GeV), Energy(60*GeV))/GeV, Energy(0*GeV)/GeV);
0073   BOOST_CHECK_EQUAL(pstarTwoBodyDecay(Energy(100*GeV), Energy(50*GeV), Energy(50*GeV))/GeV, Energy(0*GeV)/GeV);
0074   
0075   BOOST_CHECK_EQUAL(pstarTwoBodyDecay(Energy(10*GeV), Energy(6*GeV), Energy(3*GeV))/GeV, Energy(std::sqrt(19*91)/20.*GeV)/GeV);
0076   BOOST_CHECK_EQUAL(pstarTwoBodyDecay(Energy(10*GeV), Energy(3*GeV), Energy(6*GeV))/GeV, Energy(std::sqrt(19*91)/20.*GeV)/GeV);
0077 }
0078     
0079 BOOST_AUTO_TEST_CASE(twoBodyDecayTest1)
0080 {
0081  Lorentz5Momentum decayProductOne(GeV);
0082  Lorentz5Momentum decayProductTwo(GeV);
0083  BOOST_CHECK(twoBodyDecay(Lorentz5Momentum(100*GeV), Energy(40*GeV), Energy(40*GeV), Axis(), decayProductOne, decayProductTwo));
0084  BOOST_CHECK(twoBodyDecay(Lorentz5Momentum(100*GeV), Energy(50*GeV), Energy(50*GeV), Axis(), decayProductOne, decayProductTwo));
0085  
0086  BOOST_CHECK(!(twoBodyDecay(Lorentz5Momentum(100*GeV), Energy(60*GeV), Energy(60*GeV), Axis(), decayProductOne, decayProductTwo))); 
0087  BOOST_CHECK(!(twoBodyDecay(Lorentz5Momentum(-100*GeV), Energy(40*GeV), Energy(40*GeV), Axis(), decayProductOne, decayProductTwo)));
0088  BOOST_CHECK(!(twoBodyDecay(Lorentz5Momentum(100*GeV), Energy(-40*GeV), Energy(40*GeV), Axis(), decayProductOne, decayProductTwo)));
0089  BOOST_CHECK(!(twoBodyDecay(Lorentz5Momentum(100*GeV), Energy(40*GeV), Energy(-40*GeV), Axis(), decayProductOne, decayProductTwo)));
0090  
0091  twoBodyDecay(Lorentz5Momentum(100*GeV), Energy(50*GeV), Energy(50*GeV), Axis(1,0,0), decayProductOne, decayProductTwo);
0092  BOOST_CHECK_EQUAL(decayProductOne/GeV, Lorentz5Momentum(50*GeV)/GeV);
0093  BOOST_CHECK_EQUAL(decayProductTwo/GeV, Lorentz5Momentum(50*GeV)/GeV); 
0094  
0095  twoBodyDecay(Lorentz5Momentum(10*GeV), Energy(6*GeV), Energy(3*GeV), Axis(1,0,0), decayProductOne, decayProductTwo);
0096  BOOST_CHECK_EQUAL(decayProductOne/GeV, Lorentz5Momentum(6*GeV, Momentum3(std::sqrt(19*91)/20.*GeV, ThePEG::ZERO, ThePEG::ZERO))/GeV);
0097  BOOST_CHECK_EQUAL(decayProductTwo/GeV, Lorentz5Momentum(3*GeV, Momentum3(-(std::sqrt(19*91)/20.*GeV), ThePEG::ZERO, ThePEG::ZERO))/GeV);
0098 }
0099 
0100 BOOST_AUTO_TEST_CASE(twoBodyDecayTest2)
0101 {
0102  Lorentz5Momentum decayProductOne(GeV);
0103  Lorentz5Momentum decayProductTwo(GeV);
0104  BOOST_CHECK(twoBodyDecay(Lorentz5Momentum(100*GeV), Energy(40*GeV), Energy(40*GeV), 1, M_PI/2., decayProductOne, decayProductTwo));
0105  BOOST_CHECK(twoBodyDecay(Lorentz5Momentum(100*GeV), Energy(50*GeV), Energy(50*GeV), 1, M_PI/2., decayProductOne, decayProductTwo));
0106  
0107  BOOST_CHECK(!(twoBodyDecay(Lorentz5Momentum(100*GeV), Energy(60*GeV), Energy(60*GeV), 1, M_PI/2., decayProductOne, decayProductTwo))); 
0108  BOOST_CHECK(!(twoBodyDecay(Lorentz5Momentum(-100*GeV), Energy(40*GeV), Energy(40*GeV), 1, M_PI/2., decayProductOne, decayProductTwo)));
0109  BOOST_CHECK(!(twoBodyDecay(Lorentz5Momentum(100*GeV), Energy(-40*GeV), Energy(40*GeV), 1, M_PI/2., decayProductOne, decayProductTwo)));
0110  BOOST_CHECK(!(twoBodyDecay(Lorentz5Momentum(100*GeV), Energy(40*GeV), Energy(-40*GeV), 1, M_PI/2., decayProductOne, decayProductTwo)));
0111  
0112  twoBodyDecay(Lorentz5Momentum(100*GeV), Energy(50*GeV), Energy(50*GeV), 1, M_PI/2., decayProductOne, decayProductTwo);
0113  BOOST_CHECK_EQUAL(decayProductOne/GeV, Lorentz5Momentum(50*GeV)/GeV);
0114  BOOST_CHECK_EQUAL(decayProductTwo/GeV, Lorentz5Momentum(50*GeV)/GeV); 
0115  
0116  twoBodyDecay(Lorentz5Momentum(10*GeV), Energy(6*GeV), Energy(3*GeV), 1, M_PI/2., decayProductOne, decayProductTwo);
0117  BOOST_CHECK_EQUAL(decayProductOne/GeV, Lorentz5Momentum(6*GeV, Momentum3(ThePEG::ZERO, ThePEG::ZERO,   std::sqrt(19*91)/20.*GeV))/GeV);
0118  BOOST_CHECK_EQUAL(decayProductTwo/GeV, Lorentz5Momentum(3*GeV, Momentum3(ThePEG::ZERO, ThePEG::ZERO, -(std::sqrt(19*91)/20.*GeV)))/GeV);
0119 }
0120 
0121 
0122 BOOST_AUTO_TEST_SUITE_END()
0123 
0124 #endif /* HERWIG_Utilities_Test_Kinematics_H */