BmnRoot 26.10.0-210-gc52d34b0
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnATestTrack.h
Go to the documentation of this file.
1/*
2 BM@N alignment routine
3 BM@N experiment at NICA complex, JINR, 2025
4
5 Department: Math & Soft Group of HEP lab
6 Author: Igor Polev, polev@jinr.int
7
8 BmnATestTrack class header-only implementation
9 Minimalistic representation of random linear track
10 (for alignment algorithm test only)
11*/
12
13/*
14 === DEPRECATION NOTICE =========================================
15 Due to complex changes in BmnAligner, this class requires rework
16 ================================================================
17*/
18
19#ifndef BMNATESTTRACK_H
20#define BMNATESTTRACK_H
21
22#include "BmnATestHit.h"
23#include "BmnAlignDefines.h"
24#include "BmnAlignResult.h"
25#include "BmnAligner.h"
26#include "TPolyLine3D.h"
27
28#include <stdexcept>
29
30#define BMN_TEST_TRACK_SOLID_COLOR kBlack
31#define BMN_TEST_TRACK_NONSOLID_COLOR kMagenta
32#define BMN_TEST_TRACK_DEF_MAX_Z 500.0
33
35{
36 private:
37 // according to _VBCK_ line is defined as:
38 // x = AlphaX1 + AlphaX2 * z
39 // y = AlphaY1 + AlphaY2 * z
40 // see readme.md for details
45
46 protected:
48
49 public:
50 BmnATestTrack() = delete;
51 BmnATestTrack(SVectLC Alpha, Int_t nHits);
52 BmnATestTrack(Double_t Alpha1Sigma, Double_t Alpha2Min, Double_t Alpha2Max, Int_t nHits);
53 ~BmnATestTrack() { delete[] fpHits; }
54
55 const SVectLC& GetAlpha() const noexcept { return fAlpha; }
56 const SVect3& GetVertex() const noexcept { return fVertex; }
57 const SVect3& GetDirection() const noexcept { return fDirection; }
58
59 void AddHit(BmnATestHit& hit);
60 void AddMSE(BmnAlignerClass* pAligner, Bool_t withResiduals = kFALSE) const;
61
62 Double_t X(Double_t z) const noexcept { return fAlpha(iX0) + fAlpha(iX1) * z; }
63 Double_t Y(Double_t z) const noexcept { return fAlpha(iY0) + fAlpha(iY1) * z; }
64
65 // for ROOT macro mode only
66 void Draw(Bool_t solid = kTRUE, Double_t maxZ = BMN_TEST_TRACK_DEF_MAX_Z) const;
67};
68
70 : fAlpha(Alpha)
71 , fMaxHits(nHits)
72{
73 fVertex = SVect3({fAlpha(iX0), fAlpha(iY0), 0.0});
74 fDirection = SVect3({fAlpha(iX1), fAlpha(iY1), 1.0});
75
77 for (Int_t i = 0; i < fMaxHits; i++)
78 fpHits[i] = nullptr;
79}
80
81inline BmnATestTrack::BmnATestTrack(Double_t Alpha1Sigma, Double_t Alpha2Min, Double_t Alpha2Max, Int_t nHits)
82 : fMaxHits(nHits)
83{
84 fAlpha(iX0) = BMN_RND.Gaus(0.0, Alpha1Sigma);
85 fAlpha(iY0) = BMN_RND.Gaus(0.0, Alpha1Sigma);
86 fAlpha(iX1) = BMN_RND.Uniform(Alpha2Min, Alpha2Max);
87 fAlpha(iY1) = BMN_RND.Uniform(Alpha2Min, Alpha2Max);
88 fVertex = SVect3({fAlpha(iX0), fAlpha(iY0), 0.0});
89 fDirection = SVect3({fAlpha(iX1), fAlpha(iY1), 1.0});
90
92 for (Int_t i = 0; i < fMaxHits; i++)
93 fpHits[i] = nullptr;
94}
95
97{
98 if (fHitsCnt >= fMaxHits)
99 throw std::runtime_error("BmnATestTrack::AddHit: too many hits");
100 fpHits[fHitsCnt++] = &hit;
101}
102
103inline void BmnATestTrack::AddMSE(BmnAlignerClass* pAligner, Bool_t withResiduals) const
104{
105 if (!fpHits)
106 throw std::runtime_error("BmnATestTrack::AddResiduals: hits not registered");
107 Double_t z, delta, omega;
108 BmnAlignResult& result{*pAligner->GetCurrentResult()};
109
110 for (Int_t i = 0; i < fHitsCnt; i++) {
111 Int_t detectorIdx{static_cast<Int_t>(fpHits[i]->GetDetectorID())};
112 const SVectGL& A = result.A(detectorIdx);
113 z = fpHits[i]->GetZ() + A(iZ);
114
115 omega = pAligner->OmegaScaleFactor() * fpHits[i]->GetWx();
116 delta = fpHits[i]->GetX() + A(iX) - X(z);
117 result.AddValueMSE(detectorIdx, omega * delta * delta);
118 if (withResiduals)
119 result.ResidualsX().Fill(delta);
120
121 omega = pAligner->OmegaScaleFactor() * fpHits[i]->GetWy();
122 delta = fpHits[i]->GetY() + A(iY) - Y(z);
123 result.AddValueMSE(detectorIdx, omega * delta * delta);
124 if (withResiduals)
125 result.ResidualsY().Fill(delta);
126 }
127}
128
129// visualization works in ROOT macro mode only
130inline void BmnATestTrack::Draw(Bool_t solid, Double_t maxZ) const
131{
132 Double_t x[2]{X(0.0), X(maxZ)}, y[2]{Y(0.0), Y(maxZ)}, z[2]{0.0, maxZ};
133 // note: x and z axis are swapped
134 auto* line = new TPolyLine3D(2, z, y, x);
135 if (solid)
136 line->SetLineColor(BMN_TEST_TRACK_SOLID_COLOR);
137 else {
138 line->SetLineColor(BMN_TEST_TRACK_NONSOLID_COLOR);
139 line->SetLineStyle(2);
140 }
141 line->Draw();
142 // draw hits if known
143 if (fpHits)
144 for (Int_t i = 0; i < fHitsCnt; i++)
145 if (fpHits[i])
146 fpHits[i]->Draw();
147
148 // in macro mode we don't clean RAM, sorry
149}
150
151#endif // BMNATESTTRACK_H
#define BMN_TEST_TRACK_DEF_MAX_Z
#define BMN_TEST_TRACK_SOLID_COLOR
#define BMN_TEST_TRACK_NONSOLID_COLOR
@ iY1
@ iY0
@ iX1
@ iX0
RM::SVector< Double_t, 3 > SVect3
RM::SVector< Double_t, BMN_LOCAL_PARAMS_PT > SVectLC
RM::SVector< Double_t, BMN_GLOBAL_PARAMS_PD > SVectGL
@ iZ
@ iX
@ iY
int i
Definition P4_F32vec4.h:22
bool Bool_t
int Int_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
const SVect3 & GetVertex() const noexcept
const SVectLC & GetAlpha() const noexcept
void AddMSE(BmnAlignerClass *pAligner, Bool_t withResiduals=kFALSE) const
BmnATestTrack()=delete
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
BmnAligner< BmnATestHit > BmnAlignerClass
BmnATestHit ** fpHits
const SVect3 & GetDirection() const noexcept
void AddHit(BmnATestHit &hit)
SVectGL & A(Int_t index) noexcept
TH1D & ResidualsX() noexcept
void AddValueMSE(Double_t val) noexcept
TH1D & ResidualsY() noexcept
virtual Int_t Fill(const char *name, Double_t w)