TrackTrajectory_test.cc
Go to the documentation of this file.
1 /**
2  * @file TrackTrajectory_test.cc
3  * @brief Simple test on a recob::TrackTrajectory object
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date January 3, 2016
6  * @version 1.0
7  *
8  * This test simply creates recob::TrackTrajectory objects and verifies that the
9  * values it can access are the right ones.
10  *
11  * See http://www.boost.org/libs/test for the Boost test library home page.
12  *
13  */
14 
15 
16 // Boost libraries
17 /*
18  * Boost: define the name of the module;
19  * and do that before the inclusion of Boost unit test headers
20  * because it will change what they provide.
21  * Among the those, there is a main() function and some wrapping catching
22  * unhandled exceptions and considering them test failures, and probably more.
23  * This also makes fairly complicate to receive parameters from the command line
24  * (for example, a random seed).
25  */
26 #define BOOST_TEST_MODULE ( tracktrajectory_test )
27 #include "boost/test/unit_test.hpp"
28 
29 
30 // LArSoft libraries
34 
35 // ROOT libraries (for the legacy interface)
36 #include "TVector3.h"
37 #include "TMatrixD.h"
38 
39 // C/C++ standard libraries
40 #include <set>
41 #include <iterator> // std::prev(), std::next()
42 #include <algorithm> // std::equal(), std::accumulate()
43 #include <tuple> // std::tie()
44 #include <iostream>
45 
46 
47 //------------------------------------------------------------------------------
48 //--- Test code
49 //
50 struct Expected_t {
51 
55  bool hasMomenta;
56  double length;
57  double theta;
58  double phi;
59  double zenith;
60  double azimuth;
61 
62 }; // struct Expected_t
63 
64 template <typename T>
65 void CheckValue(T v, T exp, T tol, std::string tag = "") {
66  if (!tag.empty()) BOOST_TEST_MESSAGE(tag);
67  if (std::abs(exp) < (tol / 100.)) BOOST_CHECK_SMALL(v, tol);
68  else BOOST_CHECK_CLOSE(v, exp, tol);
69 } // CheckValue()
70 
71 template <typename VectA, typename VectB>
72 void CheckVectorsEqual(VectA const& v, VectB const& exp) {
73  BOOST_TEST(v.X() == exp.X());
74  BOOST_TEST(v.Y() == exp.Y());
75  BOOST_TEST(v.Z() == exp.Z());
76 } // CheckVectorsEqual()
77 
78 template <typename VectA, typename VectB>
79 void CheckVectorsClose(VectA const& v, VectB const& exp, double tol = 0.01) {
80  CheckValue(v.X(), exp.X(), tol, " X()");
81  CheckValue(v.Y(), exp.Y(), tol, " Y()");
82  CheckValue(v.Z(), exp.Z(), tol, " Z()");
83 } // CheckVectorsClose()
84 
85 
88  m.SetRotationMatrix(Tm);
89  return m;
90 } // makeRotationMatrix()
91 
92 
94  recob::TrackTrajectory const& traj,
95  Expected_t const& expected
96  )
97 {
98 
99  //----------------------------------------------------------------------------
100  const size_t NPoints = expected.positions.size();
101  BOOST_TEST(traj.NPoints() == NPoints);
102  BOOST_TEST(traj.NumberTrajectoryPoints() == NPoints);
103 
104  for (size_t i = 0; i <= NPoints + 1; ++i) {
105  BOOST_TEST_MESSAGE("HasPoint() position #" << i);
106  BOOST_TEST(traj.HasPoint(i) == (i < NPoints));
107  } // for
108 
109  if (NPoints == 0) return; // nothing else is defined
110 
111  BOOST_TEST(traj.HasMomentum() == expected.hasMomenta);
112 
113  //----------------------------------------------------------------------------
114  // some preparation:
115  std::set<size_t> validPoints;
116  for (size_t i = 0; i < NPoints; ++i) {
117  if (expected.flags[i].isSet(recob::TrackTrajectory::flag::NoPoint))
118  continue;
119  validPoints.insert(i);
120  } // for
121  std::size_t const firstValidPoint = validPoints.empty()
122  ? recob::TrackTrajectory::InvalidIndex: *(validPoints.begin());
123  std::size_t const lastValidPoint = validPoints.empty()
124  ? recob::TrackTrajectory::InvalidIndex: *(validPoints.rbegin());
125 
126  //----------------------------------------------------------------------------
127  BOOST_TEST(traj.LastPoint() == NPoints - 1);
128 
129  //----------------------------------------------------------------------------
130  for (size_t i = 0; i < NPoints; ++i) {
131 
132  bool const isValid = (validPoints.count(i) > 0);
133  BOOST_TEST_MESSAGE("HasValidPoint() position #" << i);
134  BOOST_TEST(traj.HasValidPoint(i) == isValid);
135 
136  if (isValid) {
137  BOOST_TEST(traj.NextValidPoint(i) == i);
138  BOOST_TEST(traj.PreviousValidPoint(i) == i);
139  }
140  else { // if not a valid point
142  auto iNext = validPoints.upper_bound(i);
143  if (iNext == validPoints.end()) { // after last valid point
144  BOOST_TEST(traj.PreviousValidPoint(i) == lastValidPoint);
145  BOOST_TEST(traj.NextValidPoint(i) == InvalidIndex);
146  }
147  else if (iNext == validPoints.begin()) { // before first valid point
148  BOOST_TEST(traj.PreviousValidPoint(i) == InvalidIndex);
149  BOOST_TEST(traj.NextValidPoint(i) == firstValidPoint);
150  }
151  else { // in the middle of the trajectory
152  BOOST_TEST(traj.PreviousValidPoint(i) == *(std::prev(iNext)));
153  BOOST_TEST(traj.NextValidPoint(i) == *iNext);
154  }
155  }
156 
157  } // for
158 
159  if (!validPoints.empty()) {
160  BOOST_TEST(traj.FirstValidPoint() == firstValidPoint);
161  BOOST_TEST(traj.LastValidPoint() == lastValidPoint);
162  }
163 
164  BOOST_TEST(traj.CountValidPoints() == validPoints.size());
165 
166  //----------------------------------------------------------------------------
167  BOOST_TEST_MESSAGE("Vertex()");
168  CheckVectorsEqual(traj.Vertex(), expected.positions[firstValidPoint]);
169 
170  BOOST_TEST_MESSAGE("Start()");
171  CheckVectorsEqual(traj.Start(), expected.positions[firstValidPoint]);
172 
173  BOOST_TEST_MESSAGE("End()");
174  CheckVectorsEqual(traj.End(), expected.positions[lastValidPoint]);
175 
176  //----------------------------------------------------------------------------
177  for (size_t i = 0; i < NPoints; ++i) {
178 
179  BOOST_TEST_MESSAGE("LocationAtPoint() position #" << i);
180  CheckVectorsEqual(traj.LocationAtPoint(i), expected.positions[i]);
181 
182  } // for
183 
184 
185  //----------------------------------------------------------------------------
186  TVector3 Vstart, Vend;
187  std::tie(Vstart, Vend) = traj.Extent<TVector3>();
188  BOOST_TEST(Vstart[0] == expected.positions[firstValidPoint].X());
189  BOOST_TEST(Vstart[1] == expected.positions[firstValidPoint].Y());
190  BOOST_TEST(Vstart[2] == expected.positions[firstValidPoint].Z());
191  BOOST_TEST(Vend[0] == expected.positions[lastValidPoint].X());
192  BOOST_TEST(Vend[1] == expected.positions[lastValidPoint].Y());
193  BOOST_TEST(Vend[2] == expected.positions[lastValidPoint].Z());
194 
195 
197  std::tie(start, end) = traj.Extent(); // assign both start and end
198  BOOST_TEST_MESSAGE("Extent() start");
199  CheckVectorsEqual(start, expected.positions[firstValidPoint]);
200  BOOST_TEST_MESSAGE("Extent() end");
201  CheckVectorsEqual(end, expected.positions[lastValidPoint]);
202 
203 
204  //----------------------------------------------------------------------------
205  BOOST_CHECK_CLOSE(traj.Length(), expected.length, 0.01); // 0.01%
206  if (validPoints.size() >= 2) {
207  std::size_t const secondValidPoint = *(std::next(validPoints.begin()));
208  BOOST_CHECK_CLOSE(traj.Length(firstValidPoint + 1),
209  expected.length - (
210  expected.positions[secondValidPoint]
211  - expected.positions[firstValidPoint]
212  ).R(),
213  0.01
214  );
215  } // if
216 
217 
218  //----------------------------------------------------------------------------
219  BOOST_TEST_MESSAGE("VertexDirection()");
221  (traj.VertexDirection(), expected.momenta[firstValidPoint].Unit());
222  BOOST_CHECK_CLOSE(traj.VertexDirection().Mag2(), 1.0, 0.01);
223 
224  BOOST_TEST_MESSAGE("StartDirection()");
226  (traj.StartDirection(), expected.momenta[firstValidPoint].Unit());
227  BOOST_CHECK_CLOSE(traj.StartDirection().Mag2(), 1.0, 0.01);
228 
229  BOOST_TEST_MESSAGE("EndDirection()");
231  (traj.EndDirection(), expected.momenta[lastValidPoint].Unit());
232  BOOST_CHECK_CLOSE(traj.EndDirection().Mag2(), 1.0, 0.01);
233 
234 
235  //----------------------------------------------------------------------------
236  BOOST_CHECK_CLOSE(traj.Theta(), expected.theta, 0.01);
237  BOOST_CHECK_CLOSE(traj.Phi(), expected.phi, 0.01);
238  BOOST_CHECK_CLOSE(traj.ZenithAngle(), expected.zenith, 0.01);
239  BOOST_CHECK_CLOSE(traj.AzimuthAngle(), expected.azimuth, 0.01);
240 
241 
242  //----------------------------------------------------------------------------
243 
244  BOOST_TEST_MESSAGE("VertexMomentumVector()");
246  (traj.VertexMomentumVector(), expected.momenta[firstValidPoint]);
247 
248  BOOST_TEST_MESSAGE("StartMomentumVector()");
250  (traj.StartMomentumVector(), expected.momenta[firstValidPoint]);
251 
252  BOOST_TEST_MESSAGE("EndMomentumVector()");
253  CheckVectorsClose(traj.EndMomentumVector(), expected.momenta[lastValidPoint]);
254 
255 
256  //----------------------------------------------------------------------------
257  BOOST_TEST_MESSAGE("VertexMomentum()");
258  BOOST_CHECK_CLOSE
259  (traj.VertexMomentum(), expected.momenta[firstValidPoint].R(), 0.01);
260 
261  BOOST_TEST_MESSAGE("StartMomentum()");
262  BOOST_CHECK_CLOSE
263  (traj.StartMomentum(), expected.momenta[firstValidPoint].R(), 0.01);
264 
265  BOOST_TEST_MESSAGE("EndMomentum()");
266  BOOST_CHECK_CLOSE
267  (traj.EndMomentum(), expected.momenta[lastValidPoint].R(), 0.01);
268 
269 
270  //----------------------------------------------------------------------------
271  for (size_t i = 0; i < NPoints; ++i) {
272 
273  BOOST_TEST_MESSAGE("DirectionAtPoint() position #" << i);
274  CheckVectorsClose(traj.DirectionAtPoint(i), expected.momenta[i].Unit());
275 
276  } // for
277 
278 
279  //----------------------------------------------------------------------------
280  for (size_t i = 0; i < NPoints; ++i) {
281 
282  if (validPoints.count(i) == 0) continue; // invalid points can be whatever
283 
284  BOOST_TEST_MESSAGE("MomentumVectorAtPoint() position #" << i);
285  if (traj.HasMomentum())
286  CheckVectorsClose(traj.MomentumVectorAtPoint(i), expected.momenta[i]);
287  else {
289  (traj.MomentumVectorAtPoint(i), expected.momenta[i].Unit());
290  }
291 
292  BOOST_TEST_MESSAGE("MomentumAtPoint() position #" << i);
293  if (traj.HasMomentum()) {
294  BOOST_CHECK_CLOSE
295  (traj.MomentumAtPoint(i), expected.momenta[i].R(), 0.01);
296  }
297  else
298  BOOST_CHECK_CLOSE(traj.MomentumAtPoint(i), 1.0, 0.01);
299 
300  } // for
301 
302 
303  //----------------------------------------------------------------------------
304  TVector3 AstartDir, AendDir;
305  std::tie(AstartDir, AendDir) = traj.Direction<TVector3>();
306  BOOST_CHECK_CLOSE
307  (AstartDir[0], expected.momenta[firstValidPoint].Unit().X(), 0.01);
308  BOOST_CHECK_CLOSE
309  (AstartDir[1], expected.momenta[firstValidPoint].Unit().Y(), 0.01);
310  BOOST_CHECK_CLOSE
311  (AstartDir[2], expected.momenta[firstValidPoint].Unit().Z(), 0.01);
312  BOOST_CHECK_CLOSE
313  (AendDir[0], expected.momenta[lastValidPoint].Unit().X(), 0.01);
314  BOOST_CHECK_CLOSE
315  (AendDir[1], expected.momenta[lastValidPoint].Unit().Y(), 0.01);
316  BOOST_CHECK_CLOSE
317  (AendDir[2], expected.momenta[lastValidPoint].Unit().Z(), 0.01);
318 
319  recob::Trajectory::Vector_t startDir, endDir;
320  std::tie(startDir, endDir) = traj.Direction();
321  BOOST_TEST_MESSAGE("Direction() start");
322  CheckVectorsClose(startDir, expected.momenta[firstValidPoint].Unit());
323  BOOST_TEST_MESSAGE("Direction() end");
324  CheckVectorsClose(endDir, expected.momenta[lastValidPoint].Unit());
325 
326 
327  //----------------------------------------------------------------------------
328 
329  for (size_t i = 0; i < NPoints; ++i) {
330 
331  if (validPoints.count(i) == 0) continue; // invalid points can be whatever
332 
333  auto const& dir = expected.momenta[i];
334  recob::Trajectory::Vector_t localDir(0., 0., dir.R());
335 
336  BOOST_TEST_MESSAGE("Test transformation to local at point #" << i);
337  auto toLocal = traj.GlobalToLocalRotationAtPoint(i);
338  CheckVectorsClose(toLocal * dir, localDir);
339 
340  BOOST_TEST_MESSAGE("Test transformation to global at point #" << i);
341  auto toGlobal = traj.LocalToGlobalRotationAtPoint(i);
342  CheckVectorsClose(toGlobal * localDir, dir);
343 
344  } // for
345 
346  //----------------------------------------------------------------------------
347  for (size_t i = 0; i < NPoints; ++i) {
348 
349  if (validPoints.count(i) == 0) continue; // invalid points can be whatever
350 
351  auto const& dir = expected.momenta[i];
352  recob::Trajectory::Vector_t localDir(0., 0., dir.R());
353 
354  BOOST_TEST_MESSAGE("Test legacy transformation to local at point #" << i);
355  TMatrixD TtoLocal = traj.GlobalToLocalRotationAtPoint<TMatrixD>(i);
356  auto toLocal = makeRotationMatrix(TtoLocal);
357  CheckVectorsClose(toLocal * dir, localDir);
358 
359  BOOST_TEST_MESSAGE("Test legacy transformation to global at point #" << i);
360  TMatrixD TtoGlobal = traj.LocalToGlobalRotationAtPoint<TMatrixD>(i);
361  auto toGlobal = makeRotationMatrix(TtoGlobal);
362  CheckVectorsClose(toGlobal * localDir, dir);
363 
364  } // for
365 
366  //----------------------------------------------------------------------------
367 
368 } // TestTrackTrajectory()
369 
370 
371 //------------------------------------------------------------------------------
373 
374  BOOST_TEST_MESSAGE("Testing the default recob::TrackTrajectory constructor");
375 
376  //
377  // Part I: initialization of trajectory inputs
378  //
379  // these are the values expected for a default-constructed trajectory
381  expected.positions.clear();
382  expected.momenta.clear();
383  expected.flags.clear();
384  expected.hasMomenta = false;
385  expected.length = 0.0;
386 
387  //
388  // Part II: default constructor
389  //
390  // step II.1: create a trajectory with the default constructor
392 
393  for (unsigned int v = 0; v <= recob::TrackTrajectory::MaxDumpVerbosity; ++v) {
394  std::cout
395  << "Default-constructed track trajectory dump with verbosity level "
396  << v << ":" << std::endl;
397  traj.Dump(std::cout, v, " ", " ");
398  std::cout << std::endl;
399  } // for
400 
401  // step II.2: verify that the values are as expected
402  TestTrackTrajectory(traj, expected);
403 
404 } // TrackTrajectoryTestDefaultConstructor()
405 
406 
407 //------------------------------------------------------------------------------
409 
410  BOOST_TEST_MESSAGE("Testing the main recob::TrackTrajectory constructor");
411 
412  //
413  // Part I: initialization of trajectory inputs
414  //
415  const recob::TrackTrajectory::Coord_t V2_2 = std::sqrt(0.5);
417  // we describe a trajectory with uniform electric and magnetic fields aligned
418  // on z; curvature is 1 on the x/y plane.
419  expected.positions = {
420  recob::TrackTrajectory::Point_t( -1.0, 0.0, 0.0 ),
421  recob::TrackTrajectory::Point_t( -V2_2, +V2_2, 1.0 ),
422  recob::TrackTrajectory::Point_t( 0.0, +1.0, 2.0 ),
423  recob::TrackTrajectory::Point_t( +V2_2, +V2_2, 3.0 ),
424  recob::TrackTrajectory::Point_t( +1.0, 0.0, 4.0 ),
425  recob::TrackTrajectory::Point_t( +V2_2, -V2_2, 5.0 ),
426  recob::TrackTrajectory::Point_t( 0.0, -1.0, 6.0 ),
427  recob::TrackTrajectory::Point_t( -V2_2, -V2_2, 7.0 ),
428  recob::TrackTrajectory::Point_t( -1.0, 0.0, 8.0 ),
429  recob::TrackTrajectory::Point_t( -V2_2, +V2_2, 9.0 ),
430  recob::TrackTrajectory::Point_t( 0.0, +1.0, 10.0 ),
431  recob::TrackTrajectory::Point_t( +V2_2, +V2_2, 11.0 ),
432  recob::TrackTrajectory::Point_t( +1.0, 0.0, 12.0 ),
433  recob::TrackTrajectory::Point_t( +V2_2, -V2_2, 13.0 ),
434  recob::TrackTrajectory::Point_t( 0.0, -1.0, 14.0 ),
435  recob::TrackTrajectory::Point_t( -V2_2, -V2_2, 15.0 ),
436  recob::TrackTrajectory::Point_t( -1.0, 0.0, 16.0 ),
437  recob::TrackTrajectory::Point_t( -V2_2, +V2_2, 17.0 ),
438  recob::TrackTrajectory::Point_t( 0.0, +1.0, 18.0 ),
439  recob::TrackTrajectory::Point_t( +V2_2, +V2_2, 19.0 ),
440  recob::TrackTrajectory::Point_t( +1.0, 0.0, 20.0 ),
441  recob::TrackTrajectory::Point_t( +V2_2, -V2_2, 21.0 ),
442  recob::TrackTrajectory::Point_t( 0.0, -1.0, 22.0 ),
443  recob::TrackTrajectory::Point_t( -V2_2, -V2_2, 23.0 ),
444  recob::TrackTrajectory::Point_t( -1.0, 0.0, 24.0 )
445  };
446  expected.momenta = {
447  recob::TrackTrajectory::Vector_t( 0.0, +1.0, 1.0 ),
448  recob::TrackTrajectory::Vector_t( +V2_2, +V2_2, 1.0 ),
449  recob::TrackTrajectory::Vector_t( +1.0, 0.0, 1.0 ),
450  recob::TrackTrajectory::Vector_t( +V2_2, -V2_2, 1.0 ),
451  recob::TrackTrajectory::Vector_t( 0.0, -1.0, 1.0 ),
452  recob::TrackTrajectory::Vector_t( -V2_2, -V2_2, 1.0 ),
453  recob::TrackTrajectory::Vector_t( -1.0, 0.0, 1.0 ),
454  recob::TrackTrajectory::Vector_t( -V2_2, +V2_2, 1.0 ),
455  recob::TrackTrajectory::Vector_t( 0.0, +1.0, 1.0 ),
456  recob::TrackTrajectory::Vector_t( +V2_2, +V2_2, 1.0 ),
457  recob::TrackTrajectory::Vector_t( +1.0, 0.0, 1.0 ),
458  recob::TrackTrajectory::Vector_t( +V2_2, -V2_2, 1.0 ),
459  recob::TrackTrajectory::Vector_t( 0.0, -1.0, 1.0 ),
460  recob::TrackTrajectory::Vector_t( -V2_2, -V2_2, 1.0 ),
461  recob::TrackTrajectory::Vector_t( -1.0, 0.0, 1.0 ),
462  recob::TrackTrajectory::Vector_t( -V2_2, +V2_2, 1.0 ),
463  recob::TrackTrajectory::Vector_t( 0.0, +1.0, 1.0 ),
464  recob::TrackTrajectory::Vector_t( +V2_2, +V2_2, 1.0 ),
465  recob::TrackTrajectory::Vector_t( +1.0, 0.0, 1.0 ),
466  recob::TrackTrajectory::Vector_t( +V2_2, -V2_2, 1.0 ),
467  recob::TrackTrajectory::Vector_t( 0.0, -1.0, 1.0 ),
468  recob::TrackTrajectory::Vector_t( -V2_2, -V2_2, 1.0 ),
469  recob::TrackTrajectory::Vector_t( -1.0, 0.0, 1.0 ),
470  recob::TrackTrajectory::Vector_t( -V2_2, +V2_2, 1.0 ),
471  recob::TrackTrajectory::Vector_t( 0.0, +1.0, 1.0 )
472  };
473  using trkflag = recob::TrackTrajectory::flag;
474  expected.flags = {
500  };
501  expected.hasMomenta = true;
502  expected.length = 12. * std::sqrt(6);
503  expected.theta = util::pi() / 4.0;
504  expected.phi = util::pi() / 2.0;
505  expected.zenith = 0.75 * util::pi();
506  expected.azimuth = 0.0;
507 
508  //
509  // Part II: complete constructor
510  //
511  // step II.1: create a track with momentum information
512  auto positions = expected.positions;
513  auto momenta = expected.momenta;
514  auto flags = expected.flags;
517 
518  for (unsigned int v = 0; v <= recob::TrackTrajectory::MaxDumpVerbosity; ++v) {
519  std::cout << "Track trajectory dump with verbosity level "
520  << v << ":" << std::endl;
521  traj.Dump(std::cout, v, " ", " ");
522  std::cout << std::endl;
523  } // for
524 
525  // step II.2: verify that the values are as expected
526  TestTrackTrajectory(traj, expected);
527 
528  //
529  // Part III: complete constructor, no momentum
530  //
531 
532  // step III.1: amend the expectation for a momentumless track
533  std::transform(expected.momenta.begin(), expected.momenta.end(),
534  expected.momenta.begin(), [](auto const& v){ return v.unit(); });
535  expected.hasMomenta = false;
536 
537  // step III.2: create a track with no momentum information
538  positions = expected.positions; // copy again
539  recob::TrackTrajectory::Momenta_t directions = expected.momenta;
540  flags = expected.flags;
542  (std::move(positions), std::move(directions), std::move(flags), false);
543 
544  for (unsigned int v = 0; v <= recob::TrackTrajectory::MaxDumpVerbosity; ++v) {
545  std::cout << "Momentumless trajectory dump with verbosity level "
546  << v << ":" << std::endl;
547  mltraj.Dump(std::cout, v, " ", " ");
548  std::cout << std::endl;
549  } // for
550 
551  // step III.3: verify that the values are as expected
552  TestTrackTrajectory(mltraj, expected);
553 
554  //
555  // Part IV: complete constructor, less valid points
556  //
557 
558  // step IV.2: suppress the points
559  expected.flags = {
585  };
586  expected.hasMomenta = true;
587  expected.length = 2. * std::sqrt(20.0);
588 
589  // step IV.2: create the track
590  positions = expected.positions; // copy again
591  momenta = expected.momenta;
592  flags = expected.flags;
593  recob::TrackTrajectory shorttraj
595 
596  for (unsigned int v = 0; v <= recob::TrackTrajectory::MaxDumpVerbosity; ++v) {
597  std::cout << "Short trajectory dump with verbosity level "
598  << v << ":" << std::endl;
599  shorttraj.Dump(std::cout, v, " ", " ");
600  std::cout << std::endl;
601  } // for
602 
603  // step IV.3: verify that the values are as expected
604  TestTrackTrajectory(shorttraj, expected);
605 
606 } // TrackTrajectoryTestMainConstructor()
607 
608 
609 //------------------------------------------------------------------------------
610 //--- registration of tests
611 //
612 // Boost needs now to know which tests we want to run.
613 // Tests are "automatically" registered, hence the BOOST_AUTO_TEST_CASE()
614 // macro name. The argument is the name of the test; each step may have a
615 // number of checks and it will fail if any of them does.
616 //
617 
618 BOOST_AUTO_TEST_CASE(TrackTrajectoryTestDefaultConstructorTestCase) {
620 }
621 
622 BOOST_AUTO_TEST_CASE(TrackTrajectoryTestMainConstructorTestCase) {
624 }
625 
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
void Dump(Stream &&out, unsigned int verbosity, std::string indent, std::string indentFirst) const
Prints trajectory content into a stream.
bool HasPoint(size_t i) const
Returns whether the specified trajectory point is available.
Definition: Trajectory.h:183
recob::TrackTrajectory::Positions_t positions
BOOST_AUTO_TEST_CASE(TrackTrajectoryTestDefaultConstructorTestCase)
static constexpr Flag_t NoPoint
The trajectory point is not defined.
T DirectionAtPoint(unsigned int p) const
Direction at point p. Use e.g. as:
const char expected[]
Definition: Exception_t.cc:22
std::string string
Definition: nybbler.cc:12
auto const tol
Definition: SurfXYZTest.cc:16
size_t LastValidPoint() const
Returns the index of the last valid point in the trajectory.
T GlobalToLocalRotationAtPoint(unsigned int p) const
Returns a rotation matrix that brings trajectory direction along z. Use e.g. as:
tracking::Positions_t Positions_t
Type of trajectory point list.
double ZenithAngle(size_t p) const
"Zenith" angle of trajectory, with respect to the vertical axis.
void TrackTrajectoryTestMainConstructor()
Vector_t const & StartMomentumVector() const
Returns the momentum of the trajectory at the first valid point [GeV/c].
Vector_t const & VertexMomentumVector() const
Returns the momentum of the trajectory at the first valid point [GeV/c].
T LocalToGlobalRotationAtPoint(unsigned int p) const
Returns a rotation matrix bringing relative directions to global. Use e.g. as:
double EndMomentum() const
PointFlags_t::flag flag
Flag traits (including the definition of flag mnemonics).
string dir
recob::TrackTrajectory::Rotation_t makeRotationMatrix(TMatrixD const &Tm)
void CheckValue(T v, T exp, T tol, std::string tag="")
unsigned int CountValidPoints() const
Computes and returns the number of points with valid location.
tracking::Momenta_t Momenta_t
Type of momentum list.
std::pair< T, T > Extent() const
Fills the first and last valid point in the trajectory.
void CheckVectorsEqual(VectA const &v, VectB const &exp)
const Index InvalidIndex
tracking::Vector_t Vector_t
Type for representation of momenta in 3D space.
Definition: Trajectory.h:76
Vector_t VertexDirection() const
Returns the direction of the trajectory at the first point.
T abs(T value)
std::pair< T, T > Direction() const
Fills the starting and ending direction of the trajectory.
void TrackTrajectoryTestDefaultConstructor()
double Length(size_t startAt=0) const
Returns the approximate length of the trajectory.
size_t LastPoint() const
Returns the index of the last point in the trajectory.
Definition: Trajectory.h:175
size_t PreviousValidPoint(size_t index) const
Returns the index of the previous valid point in the trajectory.
size_t NPoints() const
Returns the number of stored trajectory points.
Definition: Trajectory.h:167
A trajectory in space reconstructed from hits.
T LocationAtPoint(unsigned int p) const
Position at point p. Use e.g. as:
def move(depos, offset)
Definition: depos.py:107
double MomentumAtPoint(size_t i) const
Computes and returns the modulus of the momentum at a point.
Definition: Trajectory.h:442
bool HasValidPoint(size_t i) const
Returns whether the specified point has NoPoint flag unset.
double StartMomentum() const
tracking::Rotation_t Rotation_t
Type for representation of space rotations.
recob::TrackTrajectory::Flags_t flags
tracking::Vector_t Vector_t
Type for representation of momenta in 3D space.
void TestTrackTrajectory(recob::TrackTrajectory const &traj, Expected_t const &expected)
std::vector< PointFlags_t > Flags_t
Type of point flag list.
size_t NumberTrajectoryPoints() const
Returns the number of stored trajectory points.
Definition: Trajectory.h:156
static constexpr HitIndex_t InvalidHitIndex
Value marking an invalid hit index.
Set of flags pertaining a point of the track.
recob::TrackTrajectory::Momenta_t momenta
double Phi(size_t p) const
Azimuthal angle at a point on the trajectory, with respect to z.
Point_t const & Vertex() const
Returns the position of the first valid point of the trajectory [cm].
Vector_t EndDirection() const
Returns the direction of the trajectory at the last point.
tracking::Coord_t Coord_t
Type used for coordinates and values in general.
double Theta(size_t p) const
Trajectory angle at point, with respect to positive z direction.
size_t FirstValidPoint() const
Returns the index of the first valid point in the trajectory.
static constexpr size_t InvalidIndex
Value returned on failed index queries.
bool HasMomentum() const
Returns whether information about the momentum is available.
Definition: Trajectory.h:425
Vector_t const & EndMomentumVector() const
Returns the momentum of the trajectory at the last valid point [GeV/c].
static constexpr unsigned int MaxDumpVerbosity
Largest verbosity level supported by Dump().
Point_t const & End() const
Returns the position of the last valid point of the trajectory [cm].
tracking::Point_t Point_t
Type for representation of position in physical 3D space.
Definition: Trajectory.h:73
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
size_t NextValidPoint(size_t index) const
Returns the index of the next valid point in the trajectory.
double AzimuthAngle(size_t p) const
"Azimuth" angle of trajectory, with respect to the sky.
tracking::Point_t Point_t
Type for representation of position in physical 3D space.
double VertexMomentum() const
T MomentumVectorAtPoint(unsigned int p) const
Momentum vector at point p. Use e.g. as:
Collection of Physical constants used in LArSoft.
Vector_t StartDirection() const
Returns the direction of the trajectory at the first point.
Point_t const & Start() const
Returns the position of the first valid point of the trajectory [cm].
QTextStream & endl(QTextStream &s)
void CheckVectorsClose(VectA const &v, VectB const &exp, double tol=0.01)