2#include <TRestDetectorReadoutPlane.h>
3#include <gtest/gtest.h>
7namespace fs = std::filesystem;
11const auto filesPath = fs::path(__FILE__).parent_path().parent_path() /
"files";
13constexpr double tolerance = 1E-6;
15bool AreEqual(
const TVector3& a,
const TVector3& b) {
return (a - b).Mag2() < tolerance; }
18 cout <<
"FrameworkCore test files path: " << filesPath << endl;
21 EXPECT_TRUE(fs::is_directory(filesPath));
23 EXPECT_TRUE(!fs::is_empty(filesPath));
32 EXPECT_TRUE(AreEqual(plane.
GetNormal(), {0, 0, 1}));
33 EXPECT_TRUE(AreEqual(plane.
GetAxisX(), {1, 0, 0}));
34 EXPECT_TRUE(AreEqual(plane.
GetAxisY(), {0, 1, 0}));
42 EXPECT_TRUE(AreEqual(plane.
GetNormal(), {0, 0, -1}));
43 EXPECT_TRUE(AreEqual(plane.
GetAxisX(), {0, -1, 0}));
44 EXPECT_TRUE(AreEqual(plane.
GetAxisY(), {-1, 0, 0}));
52 EXPECT_TRUE(AreEqual(plane.
GetNormal(), {0, 0.0099995, 0.99995}));
53 EXPECT_TRUE(AreEqual(plane.
GetAxisX(), {1, 0, 0}));
54 EXPECT_TRUE(AreEqual(plane.
GetAxisY(), {0, 0.99995, -0.0099995}));
62 plane.SetRotation(TMath::DegToRad() * 32.0);
68 const TVector3 newXAxis = {1.0, -2.0, 5.0};
70 plane.SetAxisX(newXAxis);
72 const TVector3 axisX = plane.
GetAxisX();
73 const TVector3 newXAxisProjected =
75 cout <<
"axisX: " << axisX.X() <<
", " << axisX.Y() <<
", " << axisX.Z() << endl;
76 cout <<
"axisXProjected: " << newXAxisProjected.X() <<
", " << newXAxisProjected.Y() <<
", "
77 << newXAxisProjected.Z() << endl;
78 EXPECT_TRUE(AreEqual(plane.
GetAxisX(), newXAxisProjected));
85 plane.SetRotation(TMath::DegToRad() * 90.0);
90 const TVector3 worldPoint = {0, 0, 100.0};
91 const TVector2 local = plane.GetPositionInPlane(worldPoint);
92 cout <<
"local: " << local.X() <<
", " << local.Y() << endl;
94 const auto distance = plane.GetDistanceToPlane(worldPoint);
95 cout <<
"distance: " << distance << endl;
void SetPosition(const TVector3 &position)
Sets the readout plane position.
void SetNormal(const TVector3 &normal)
It updates the value of the normal vector and recalculates the corresponding X and Y axis.
TVector3 GetNormal() const
Returns a TVector3 with a vector normal to the readout plane.
TVector3 GetAxisY() const
Returns a TVector3 with a vector that defines the Y-axis plane coordinate system.
void PrintMetadata()
Prints the readout plane description.
TVector3 GetAxisX() const
Returns a TVector3 with a vector that defines the X-axis plane coordinate system.
void SetHeight(Double_t d)
Used to define the height of the readout volume with sign crosscheck.
A metadata class to generate/store a readout description.