100 const size_t NPoints =
expected.positions.size();
101 BOOST_TEST(traj.NPoints() == NPoints);
102 BOOST_TEST(traj.NumberTrajectoryPoints() == NPoints);
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));
109 if (NPoints == 0)
return;
111 BOOST_TEST(traj.HasMomentum() ==
expected.hasMomenta);
115 std::set<size_t> validPoints;
116 for (
size_t i = 0; i < NPoints; ++i) {
119 validPoints.insert(i);
121 std::size_t
const firstValidPoint = validPoints.empty()
123 std::size_t
const lastValidPoint = validPoints.empty()
127 BOOST_TEST(traj.LastPoint() == NPoints - 1);
130 for (
size_t i = 0; i < NPoints; ++i) {
132 bool const isValid = (validPoints.count(i) > 0);
133 BOOST_TEST_MESSAGE(
"HasValidPoint() position #" << i);
134 BOOST_TEST(traj.HasValidPoint(i) == isValid);
137 BOOST_TEST(traj.NextValidPoint(i) == i);
138 BOOST_TEST(traj.PreviousValidPoint(i) == i);
142 auto iNext = validPoints.upper_bound(i);
143 if (iNext == validPoints.end()) {
144 BOOST_TEST(traj.PreviousValidPoint(i) == lastValidPoint);
147 else if (iNext == validPoints.begin()) {
149 BOOST_TEST(traj.NextValidPoint(i) == firstValidPoint);
152 BOOST_TEST(traj.PreviousValidPoint(i) == *(std::prev(iNext)));
153 BOOST_TEST(traj.NextValidPoint(i) == *iNext);
159 if (!validPoints.empty()) {
160 BOOST_TEST(traj.FirstValidPoint() == firstValidPoint);
161 BOOST_TEST(traj.LastValidPoint() == lastValidPoint);
164 BOOST_TEST(traj.CountValidPoints() == validPoints.size());
167 BOOST_TEST_MESSAGE(
"Vertex()");
170 BOOST_TEST_MESSAGE(
"Start()");
173 BOOST_TEST_MESSAGE(
"End()");
177 for (
size_t i = 0; i < NPoints; ++i) {
179 BOOST_TEST_MESSAGE(
"LocationAtPoint() position #" << i);
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());
197 std::tie(start, end) = traj.Extent();
198 BOOST_TEST_MESSAGE(
"Extent() start");
200 BOOST_TEST_MESSAGE(
"Extent() end");
205 BOOST_CHECK_CLOSE(traj.Length(),
expected.length, 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),
210 expected.positions[secondValidPoint]
211 -
expected.positions[firstValidPoint]
219 BOOST_TEST_MESSAGE(
"VertexDirection()");
221 (traj.VertexDirection(),
expected.momenta[firstValidPoint].Unit());
222 BOOST_CHECK_CLOSE(traj.VertexDirection().Mag2(), 1.0, 0.01);
224 BOOST_TEST_MESSAGE(
"StartDirection()");
226 (traj.StartDirection(),
expected.momenta[firstValidPoint].Unit());
227 BOOST_CHECK_CLOSE(traj.StartDirection().Mag2(), 1.0, 0.01);
229 BOOST_TEST_MESSAGE(
"EndDirection()");
231 (traj.EndDirection(),
expected.momenta[lastValidPoint].Unit());
232 BOOST_CHECK_CLOSE(traj.EndDirection().Mag2(), 1.0, 0.01);
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);
244 BOOST_TEST_MESSAGE(
"VertexMomentumVector()");
246 (traj.VertexMomentumVector(),
expected.momenta[firstValidPoint]);
248 BOOST_TEST_MESSAGE(
"StartMomentumVector()");
250 (traj.StartMomentumVector(),
expected.momenta[firstValidPoint]);
252 BOOST_TEST_MESSAGE(
"EndMomentumVector()");
257 BOOST_TEST_MESSAGE(
"VertexMomentum()");
259 (traj.VertexMomentum(),
expected.momenta[firstValidPoint].R(), 0.01);
261 BOOST_TEST_MESSAGE(
"StartMomentum()");
263 (traj.StartMomentum(),
expected.momenta[firstValidPoint].R(), 0.01);
265 BOOST_TEST_MESSAGE(
"EndMomentum()");
267 (traj.EndMomentum(),
expected.momenta[lastValidPoint].R(), 0.01);
271 for (
size_t i = 0; i < NPoints; ++i) {
273 BOOST_TEST_MESSAGE(
"DirectionAtPoint() position #" << i);
280 for (
size_t i = 0; i < NPoints; ++i) {
282 if (validPoints.count(i) == 0)
continue;
284 BOOST_TEST_MESSAGE(
"MomentumVectorAtPoint() position #" << i);
285 if (traj.HasMomentum())
289 (traj.MomentumVectorAtPoint(i),
expected.momenta[i].Unit());
292 BOOST_TEST_MESSAGE(
"MomentumAtPoint() position #" << i);
293 if (traj.HasMomentum()) {
295 (traj.MomentumAtPoint(i),
expected.momenta[i].R(), 0.01);
298 BOOST_CHECK_CLOSE(traj.MomentumAtPoint(i), 1.0, 0.01);
304 TVector3 AstartDir, AendDir;
305 std::tie(AstartDir, AendDir) = traj.Direction<TVector3>();
307 (AstartDir[0],
expected.momenta[firstValidPoint].Unit().X(), 0.01);
309 (AstartDir[1],
expected.momenta[firstValidPoint].Unit().Y(), 0.01);
311 (AstartDir[2],
expected.momenta[firstValidPoint].Unit().Z(), 0.01);
313 (AendDir[0],
expected.momenta[lastValidPoint].Unit().X(), 0.01);
315 (AendDir[1],
expected.momenta[lastValidPoint].Unit().Y(), 0.01);
317 (AendDir[2],
expected.momenta[lastValidPoint].Unit().Z(), 0.01);
320 std::tie(startDir, endDir) = traj.Direction();
321 BOOST_TEST_MESSAGE(
"Direction() start");
323 BOOST_TEST_MESSAGE(
"Direction() end");
329 for (
size_t i = 0; i < NPoints; ++i) {
331 if (validPoints.count(i) == 0)
continue;
336 BOOST_TEST_MESSAGE(
"Test transformation to local at point #" << i);
337 auto toLocal = traj.GlobalToLocalRotationAtPoint(i);
340 BOOST_TEST_MESSAGE(
"Test transformation to global at point #" << i);
341 auto toGlobal = traj.LocalToGlobalRotationAtPoint(i);
347 for (
size_t i = 0; i < NPoints; ++i) {
349 if (validPoints.count(i) == 0)
continue;
354 BOOST_TEST_MESSAGE(
"Test legacy transformation to local at point #" << i);
355 TMatrixD TtoLocal = traj.GlobalToLocalRotationAtPoint<TMatrixD>(i);
359 BOOST_TEST_MESSAGE(
"Test legacy transformation to global at point #" << i);
360 TMatrixD TtoGlobal = traj.LocalToGlobalRotationAtPoint<TMatrixD>(i);
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
static constexpr Flag_t NoPoint
The trajectory point is not defined.
recob::TrackTrajectory::Rotation_t makeRotationMatrix(TMatrixD const &Tm)
void CheckVectorsEqual(VectA const &v, VectB const &exp)
tracking::Vector_t Vector_t
Type for representation of momenta in 3D space.
static constexpr size_t InvalidIndex
Value returned on failed index queries.
tracking::Point_t Point_t
Type for representation of position in physical 3D space.
void CheckVectorsClose(VectA const &v, VectB const &exp, double tol=0.01)