MCParticle_test.cxx
Go to the documentation of this file.
1 /**
2  * @file MCParticle_test.cxx
3  * @brief Test for simb::MCParticle data product
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date November 21, 2017
6  *
7  * Current checks:
8  * * move constructor actially moves (see issue #12067)
9  *
10  * See http://www.boost.org/libs/test for the Boost test library home page.
11  *
12  */
13 
14 #define BOOST_TEST_MODULE ( mcparticle_test )
15 #include "cetlib/quiet_unit_test.hpp" // BOOST_AUTO_TEST_CASE()
16 #include <boost/test/test_tools.hpp> // BOOST_CHECK()
17 // #include <boost/test/floating_point_comparison.hpp> // BOOST_CHECK_CLOSE()
18 
19 // nutools libraries
22 
23 // ROOT libraries
24 #include "TLorentzVector.h"
25 
26 // C/C++ standard libraries
27 #include <vector>
28 
29 
30 //------------------------------------------------------------------------------
32 
33  simb::MCTrajectory traj;
34  traj.Add(TLorentzVector(), TLorentzVector(), "hadElastic");
35  traj.Add(TLorentzVector(), TLorentzVector(), "hadElastic");
36 
37  // if the object is moved, we'll find the process map data at the same place
38  auto const* pProcessMap = traj.TrajectoryProcesses().data();
39 
40  simb::MCTrajectory movedTraj(std::move(traj));
41 
42  BOOST_CHECK_EQUAL
43  ((void*) movedTraj.TrajectoryProcesses().data(), (void*) pProcessMap);
44  BOOST_CHECK_NE((void*) traj.TrajectoryProcesses().data(), (void*) pProcessMap);
45 
46 } // MCTrajectoryMoveTest()
47 
48 //------------------------------------------------------------------------------
50 
51  simb::MCParticle part;
52  part.AddTrajectoryPoint(TLorentzVector(), TLorentzVector(), "hadElastic");
53  part.AddTrajectoryPoint(TLorentzVector(), TLorentzVector(), "hadElastic");
54 
55  // if the object is moved, we'll find the process map data at the same place
56  auto const* pProcessMap = part.Trajectory().TrajectoryProcesses().data();
57 
58  simb::MCParticle movedPart(std::move(part));
59 
60  BOOST_CHECK_EQUAL(
61  (void*) movedPart.Trajectory().TrajectoryProcesses().data(),
62  (void*) pProcessMap
63  );
64  BOOST_CHECK_NE(
65  (void*) part.Trajectory().TrajectoryProcesses().data(),
66  (void*) pProcessMap
67  );
68 
69 
70 } // MCParticleMoveTest()
71 
72 //------------------------------------------------------------------------------
73 //--- registration of tests
74 //
75 
76 BOOST_AUTO_TEST_CASE(MCParticleTestCase) {
79 } // BOOST_AUTO_TEST_CASE(MCParticleTestCase)
80 
81 
82 //------------------------------------------------------------------------------
void Add(TLorentzVector const &p, TLorentzVector const &m)
Trajectory class.
void AddTrajectoryPoint(TLorentzVector const &position, TLorentzVector const &momentum)
Definition: MCParticle.h:257
const simb::MCTrajectory & Trajectory() const
Definition: MCParticle.h:253
void MCTrajectoryMoveTest()
Particle class.
void MCParticleMoveTest()
def move(depos, offset)
Definition: depos.py:107
ProcessMap const & TrajectoryProcesses() const
Definition: MCTrajectory.h:188
BOOST_AUTO_TEST_CASE(MCParticleTestCase)