17#include "fairlogger/Logger.h"
25 const char* constraintsPath,
27 :
BmnAligner(measureModel, modelDetector, constraintsPath, nThreads)
30 LOG(state) <<
" > BmnAlignerTest : initialization started";
39 LOG(info) <<
" RAM required: " << ram_size / 1073741824.0 <<
" GB, ";
41 LOG(error) <<
"<!> required RAM size is too large for test:" << std::endl
42 <<
"<!> decrease number of tracks or detector planes" << std::endl
58 LOG(state) <<
" < BmnAlignerTest : initialization completed";
70 LOG(state) <<
" > BmnAlignerTest : data preparation started";
72 LOG(error) <<
" <!> BmnAlignerTest is not initialized";
76 Bool_t loadTracks{tracksPath && std::filesystem::exists(tracksPath)};
81 LOG(error) <<
" <!> failed to load tracks from file " << tracksPath;
85 LOG(info) <<
" Generating random tracks";
94 LOG(warning) <<
" failed to save tracks to file " << tracksPath;
98 SVect3 HitPoint, HitPointLocal;
100 Int_t iTrack, iHit{0};
109 HitPoint = {Track.
X(Z), Track.
Y(Z), Z};
113 <<
" <!> non-zero local z coordinate of test hit: " << HitPointLocal(2);
115 auto pHit =
new (
fpHits + iHit)
130 Double_t dX{lastHit.GetX() - firstHit.
GetX()}, dY{lastHit.GetY() - firstHit.
GetY()},
131 dZ{lastHit.GetZ() - firstHit.
GetZ()}, AlphaX1{dX / dZ}, AlphaY1{dY / dZ};
132 arrAlpha[iTrack] =
SVectLC(firstHit.
GetX() - AlphaX1 * firstHit.
GetZ(), AlphaX1,
133 firstHit.
GetY() - AlphaY1 * firstHit.
GetZ(), AlphaY1);
152 LOG(info) <<
" " <<
fTotalTracks <<
" tracks ready, total hits: " << iHit <<
", time spent: " << Timer.CpuTime()
154 LOG(state) <<
" < BmnAlignerTest : data preparation completed";
171 LOG(info) <<
" === average local parameters convergence:";
172 LOG(info) <<
" error by X = (" << delta(
iX0) <<
", " << delta(
iX1) <<
")";
173 LOG(info) <<
" error by Y = (" << delta(
iY0) <<
", " << delta(
iY1) <<
")";
180 LOG(info) <<
" Saving tracks data to " << path;
183 std::ofstream ofs(path);
185 LOG(error) <<
" <!> failed to open JSON file " << path;
191 j[
"alphas"] = nlohmann::json::array();
194 const auto& Alpha = tr.GetAlpha();
195 j[
"alphas"].push_back({Alpha(
iX0), Alpha(
iX1), Alpha(
iY0), Alpha(
iY1)});
204 LOG(info) <<
" Loading tracks data from " << path;
205 std::ifstream ifs(path);
207 LOG(error) <<
" <!> failed to open JSON file " << path;
221 const auto& arr = j[
"alphas"];
223 const auto& a = arr[
i];
224 SVectLC Alpha(a[
iX0].get<double>(), a[
iX1].get<double>(), a[
iY0].get<double>(), a[
iY1].get<double>());
237 fpPad3D->SetTitle(
"Some random tracks");
245 if (drawn_tracks.end() == std::find(drawn_tracks.begin(), drawn_tracks.end(), j) &&
fpTrackUsable->at(
i)) {
256 xValues[
i] =
static_cast<double>(
i + 1);
266 graphSolution->
SetTitle(
"Alignment values");
271 graphSolution->
Draw(
"AB");
278 graphTest->
Draw(
"*SAME");
319 Double_t beforeValue{0.0}, afterValue{0.0};
324 LOG(info) <<
" === distance to test A before/after alignment: " << std::sqrt(beforeValue) <<
" / "
325 << std::sqrt(afterValue);
#define BMN_DRAW_TRACKS_CNT
#define BMN_CLOSE_TO_ZERO
#define BMN_TEST_AVERAGE_DY
ROOT::Math::SVector< Double_t, BMN_GLOBAL_PARAMS_PD > SVectGL
#define BMN_TEST_ALPHA2_MAX
#define BMN_TEST_AVERAGE_DX
#define BMN_TEST_ALPHA1_SIGMA
#define BMN_TEST_ALPHA2_MIN
static constexpr Int_t BMN_GLPARAMS_TOTAL
ROOT::Math::SVector< Double_t, 3 > SVect3
ROOT::Math::SVector< Double_t, BMN_LOCAL_PARAMS_PT > SVectLC
#define BMN_MAX_HIT_RAM_SIZE
#define BMN_GLOBAL_PARAMS_PD
const SVect3 & GetNormal() const noexcept
const SVect3 & GetCrdShift() const noexcept
Double_t GetPosition() const noexcept
const SMatr3x3 & GetCrdInvRotation() const noexcept
Double_t GetConst() const noexcept
const SVect3 & GetVertex() const noexcept
Double_t Y(Double_t z) const noexcept
Double_t X(Double_t z) const noexcept
void Draw(Bool_t solid=kTRUE, Double_t maxZ=BMN_TEST_TRACK_DEF_MAX_Z) const
const SVect3 & GetDirection() const noexcept
void AddHit(BmnATestHit &hit)
VectorSVectLC_t & Alpha() noexcept
SVectGL & A(Int_t index) noexcept
virtual void ReportResults() const override
BmnATestTrack * fpTestTracks
virtual Double_t CalculateMSE(Bool_t withResiduals) override
virtual Bool_t PrepareData(const char *tracksPath=nullptr) override
virtual Bool_t IterateAlignment() override
virtual ~BmnAlignerTest()
const BmnATestDetector * fpDetectors
virtual void Draw() override
Bool_t LoadTracks(const char *path)
Byte_t * fpTestTracksData
Bool_t SaveTracks(const char *path) const
const BmnATestTrack & GetTestTrack(Int_t trackID) const noexcept
BmnAlignResult * fpResultCurrent
void StoreZeroSolution(const std::vector< SVectLC > &AlphaZero)
BmnDataIterator * fpIteratorMain
virtual Bool_t IterateAlignment()
std::vector< Bool_t > * fpTrackUsable
BmnRamIterator< BmnATestHit > * fpRamIterator
Double_t fOmegaScaleFactor
Int_t TotalTracks() const noexcept
BmnAligner(const BmnMeasureModel *measureModel, const BmnDetectorModel *modelDetector, const char *constraintsPath=nullptr, Int_t nThreads=1)
virtual void ReportResults() const
BmnAlignResult * GetResult(Bool_t last=kTRUE) const noexcept
Double_t GetY() const noexcept
Double_t GetX() const noexcept
Double_t GetZ() const noexcept
virtual void SetFillColor(Color_t fcolor)
virtual void SetLineColor(Color_t lcolor)
virtual void SetRangeUser(Double_t ufirst, Double_t ulast)
virtual void SetMaximum(Double_t maximum=-1111)
void Draw(Option_t *chopt="") override
void SetTitle(const char *title="") override
virtual void SetMinimum(Double_t minimum=-1111)
virtual Double_t Uniform(Double_t x1, Double_t x2)
T Mag2(const SVector< T, D > &rhs)
T Dot(const SVector< T, D > &lhs, const SVector< T, D > &rhs)
Expr< UnaryOp< Fabs< T >, Expr< A, T, D, D2, R >, T >, T, D, D2, R > fabs(const Expr< A, T, D, D2, R > &rhs)
basic_json<> json
default specialization