102 "mean of X-residual",
103 "mean of Y-residual",
104 "slope of X-res vs track x-slope",
105 "slope of X-res vs (x-slope * y)",
106 "slope of X-res vs (x-slope * x)",
107 "slope of X-res vs y"};
109 "mean of X-residual",
110 "mean of Y-residual",
111 "slope of Y-res vs track y-slope",
112 "slope of Y-res vs (y-slope * y)",
113 "slope of Y-res vs (y-slope * x)",
114 "slope of Y-res vs x"};
117 "track x-slope #beta_{x}",
118 "#beta_{x} #upoint y_{bar}, cm",
119 "#beta_{x} #upoint x_{bar}, cm",
123 "track y-slope #beta_{y}",
124 "#beta_{y} #upoint y_{bar}, cm",
125 "#beta_{y} #upoint x_{bar}, cm",
149#define RESIDUAL_RANGE_X 0.02
150#define RESIDUAL_RANGE_Y 0.4
151#define RESIDUAL_BINS 201
152#define PROFILE_BINS 201
153#define PAVE_TEXT_SIZE 0.04
158#define EVO_DENSE_HEAD 200
159#define EVO_TAIL_POINTS 600
172 if (!(std::abs(
line.Det()) > 0.0) ||
line.N() < 3)
176 return s2 > 0.0 ? std::sqrt(s2 *
line.SlopeVar()) : 0.0;
186 std::array<LinAcc, PARAM_CNT>
x,
y;
204 n.push_back(
static_cast<Double_t>(tracks));
207 errX[p].push_back(a.
x[p].Error(p));
209 errY[p].push_back(a.
y[p].Error(p));
219 tcgetattr(STDIN_FILENO, saved);
220 struct termios raw{*saved};
221 raw.c_lflag &= ~(ICANON | ECHO);
224 tcsetattr(STDIN_FILENO, TCSANOW, &raw);
226 tcsetattr(STDIN_FILENO, TCSANOW, saved);
260int histoGL(
const char* fileListPath =
"/home/igor/bmnroot/align_new/cfg/run8/7466.noa_rlerr.list",
263 const char* pdfPath =
nullptr)
268 if (selParam < 0 || selParam >=
PARAM_CNT) {
269 std::cerr <<
" <!> histoGL: selParam " << selParam <<
" out of range [0, " <<
PARAM_CNT <<
")" << std::endl;
272 if (drawMode < DM_PROFILE || drawMode >
DM_MIX) {
273 std::cerr <<
" <!> histoGL: drawMode " << drawMode <<
" out of range [" <<
DM_PROFILE <<
", " <<
DM_MIX <<
"]"
280 std::cerr <<
" <!> histoGL: failed to initialize iterator on " << fileListPath << std::endl;
284 std::cout <<
"\nInitializing ROOT reader for " << fileListPath <<
"\n";
295 std::cout <<
"Reading data...\n";
296 Long64_t usedTracks{0}, usedHits{0};
308 if (!(lineX.
Det() > 0.0) || !(lineY.
Det() > 0.0)) {
318 Double_t z{itr.
HitZ()}, xBar{alphaX + betaX * z}, yBar{alphaY + betaY * z}, rx{itr.
HitX() - xBar},
319 ry{itr.
HitY() - yBar};
322 acc.
x[
P_dX].Add(0.0, rx);
323 acc.
x[
P_dZ].Add(betaX, rx);
324 acc.
x[
P_phi].Add(betaX * yBar, rx);
325 acc.
x[
P_theta].Add(betaX * xBar, rx);
326 acc.
x[
P_psi].Add(yBar, rx);
328 acc.
y[
P_dY].Add(0.0, ry);
329 acc.
y[
P_dZ].Add(betaY, ry);
330 acc.
y[
P_phi].Add(betaY * yBar, ry);
331 acc.
y[
P_theta].Add(betaY * xBar, ry);
332 acc.
y[
P_psi].Add(xBar, ry);
334 draw.
rx.push_back(rx);
335 draw.
ry.push_back(ry);
336 draw.
betaX.push_back(betaX);
337 draw.
betaXY.push_back(betaX * yBar);
338 draw.
betaXX.push_back(betaX * xBar);
339 draw.
yBar.push_back(yBar);
340 draw.
betaY.push_back(betaY);
341 draw.
betaYY.push_back(betaY * yBar);
342 draw.
betaYX.push_back(betaY * xBar);
343 draw.
xBar.push_back(xBar);
350 evo.
Sample(usedTracks, acc);
355 if (usedTracks == 0) {
356 std::cerr <<
" <!> histoGL: no usable tracks found" << std::endl;
360 if (evo.
n.empty() || evo.
n.back() !=
static_cast<Double_t>(usedTracks))
361 evo.
Sample(usedTracks, acc);
366 cout <<
"\nWhole-detector histogramming: ensemble first-order corrections\n";
367 cout << usedTracks <<
" tracks, " << usedHits <<
" hits\n\n";
369 cout << fixed << setprecision(6);
370 cout <<
" " << left << setw(7) <<
"dX" <<
" = " << right << setw(11) << acc.
x[
P_dX].Value(
P_dX,
PARAM_SIGN_X)
372 cout <<
" " << left << setw(7) <<
"dY" <<
" = " << right << setw(11) << acc.
y[
P_dY].Value(
P_dY,
PARAM_SIGN_Y)
375 cout <<
" " << left << setw(7) <<
PARAM_NAMES[p] << right <<
" X: " << setw(11)
376 << acc.
x[p].Value(p,
PARAM_SIGN_X) <<
" +/- " << setw(9) << acc.
x[p].Error(p) <<
" Y: " << setw(11)
377 << acc.
y[p].Value(p,
PARAM_SIGN_Y) <<
" +/- " << setw(9) << acc.
y[p].Error(p) <<
"\n";
378 cout <<
" RMS(rx) = " << acc.
x[
P_dX].RmsY() <<
" RMS(ry) = " << acc.
y[
P_dY].RmsY() <<
"\n" << flush;
384 gStyle->SetOptStat(
"emr");
387 "canvas",
"BM@N histogramming (whole detector)",
RES_X,
RES_Y);
398 pPads[
i][j] =
new TPad(
Form(
"pad%u%u",
i, j),
Form(
"pad%u%u",
i, j), padW * j, padH *
i, padW * (j + 1),
413 std::vector<Panel> panels;
414 panels.push_back({0, 0,
P_dX,
kTRUE,
kFALSE,
kFALSE, &draw.
rx,
nullptr,
RESIDUAL_RANGE_X,
PARAM_DIAG[
P_dX],
416 panels.push_back({0, 1,
P_dY,
kTRUE,
kTRUE,
kFALSE, &draw.
ry,
nullptr,
RESIDUAL_RANGE_Y,
PARAM_DIAG[
P_dY],
418 for (
Int_t c = 0; c < 4; c++) {
426 panels.push_back({2, c, p,
kFALSE,
kFALSE,
kTRUE, &draw.
rx, covX[c],
RESIDUAL_RANGE_X,
PARAM_DIAG[p],
433 for (
const Panel& pn : panels) {
434 pPads[
PADS_Y - 1 - pn.row][pn.col]->
cd();
435 const char* tag{pn.isShift ?
"" : (pn.isY ?
" (Y)" :
" (X)")};
436 const char* suff{pn.isY ?
"y" :
"x"};
437 const char* axis{pn.isY ?
"Y" :
"X"};
445 Form(
"%s%s = %+.5f #pm %.5f",
PARAM_NAMES[pn.p], tag, pn.a->Value(pn.p, pn.sign), pn.a->Error(pn.p)));
450 -pn.resRange, pn.resRange);
485 lo - margin, hi + margin,
RESIDUAL_BINS, -pn.resRange, pn.resRange);
487 for (std::size_t
i = 0;
i < cov.size();
i++)
489 h2->
Fit(
"pol1",
"Q");
491 fit->SetLineColor(
kRed);
492 fit->SetLineWidth(2);
499 Form(
"%s;%s;#LT %s residual #GT, cm", pn.diag, pn.covTitle, axis),
502 for (std::size_t
i = 0;
i < cov.size();
i++)
507 pr->
Fit(
"pol1",
"Q");
524 const LinAcc& a{useY ? acc.
y[p] : acc.
x[p]};
525 const char* sol{useY ?
"Y-solution" :
"X-solution"};
530 if (a.
line.
N() <= 0 || vv.empty()) {
552 const Double_t vFinal{vv.back()}, eFinal{ve.back()};
558 ylo = std::min(ylo, vv[
i] - ve[
i]);
559 yhi = std::max(yhi, vv[
i] + ve[
i]);
565 const Double_t span{0.25 * (yhi - ylo)};
579 line->
Draw(
"L SAME");
582 TLine* ref =
new TLine(evo.
n.front(), vFinal, evo.
n.back(), vFinal);
601 auto showEvo = [&](
Int_t p) {
602 drawEvo(pEvoX, p,
kFALSE);
603 drawEvo(pEvoY, p,
kTRUE);
609 if (pdfPath && pdfPath[0])
616 if (!
gROOT->IsBatch() && isatty(STDIN_FILENO)) {
617 cout <<
"\n[ Right / Left arrows: next / previous correction"
618 " (evolution panels) | q: quit ]\n"
620 struct termios saved;
626 if (!
gROOT->GetListOfCanvases()->FindObject(pCnv))
629 if (read(STDIN_FILENO, &c, 1) <= 0) {
633 if (c ==
'q' || c ==
'Q') {
635 }
else if (c == 27) {
636 unsigned char a{0}, b{0};
638 if (read(STDIN_FILENO, &a, 1) <= 0) {
642 read(STDIN_FILENO, &b, 1);
643 if (a ==
'[' && b ==
'C')
645 else if (a ==
'[' && b ==
'D')
649 cout <<
" selected correction: " <<
PARAM_NAMES[selParam] <<
"\n" << flush;
std::vector< Double_t > VecDouble_t
TrackFilter_t BmnDefaultTrackFilter(Bool_t wholeTrackOnly=kTRUE)
HitFilter_t BmnDefaultHitFilter(const BmnDetectorModel &model)
char * Form(const char *fmt,...)
R__EXTERN TStyle * gStyle
R__EXTERN TSystem * gSystem
Bool_t EndOfTracks() const noexcept
Bool_t EndOfHits() const noexcept
Bool_t Initialized() const noexcept
Bool_t Init(const char *targetGeoFile=nullptr)
virtual Double_t HitY() const override
virtual void ResetAll() override
virtual Double_t HitWy() const override
virtual Double_t HitZ() const override
virtual Double_t HitX() const override
Int_t GetTotalTracks() const noexcept
virtual Double_t HitWx() const override
virtual void ResetHits() override
virtual void NextTrack() override
virtual void NextHit() override
Double_t Det() const noexcept
Double_t At0() const noexcept
void Add(Double_t z, Double_t v, Double_t w=1.0) noexcept
Double_t Slope() const noexcept
virtual void SetFillColor(Color_t fcolor)
virtual void SetFillColorAlpha(Color_t fcolor, Float_t falpha)
virtual void SetLineStyle(Style_t lstyle)
virtual void SetLineWidth(Width_t lwidth)
virtual void SetLineColor(Color_t lcolor)
virtual void SetMarkerColor(Color_t mcolor=1)
virtual void SetMarkerStyle(Style_t mstyle=1)
virtual void SetTextSize(Float_t tsize=1)
virtual void SetLimits(Double_t xmin, Double_t xmax)
TVirtualPad * cd(Int_t subpadnumber=0) override
void SetCanvasSize(UInt_t ww, UInt_t wh) override
virtual void SetPointError(Double_t ex, Double_t ey)
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
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 GetMean(Int_t axis=1) const
static void AddDirectory(Bool_t add=kTRUE)
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
void Draw(Option_t *option="") override
virtual Int_t Fill(const char *name, Double_t w)
virtual TF1 * GetFunction(const char *name) const
virtual void SetStats(Bool_t stats=kTRUE)
virtual Int_t Fill(const char *namex, const char *namey, Double_t w)
virtual void Draw(Option_t *option="")
void SetGridx(Int_t value=1) override
void Clear(Option_t *option="") override
void Modified(Bool_t flag=true) override
void SetGridy(Int_t value=1) override
void SaveAs(const char *filename="", Option_t *option="") const override
TVirtualPad * cd(Int_t subpadnumber=0) override
void Draw(Option_t *option="") override
void SetLogx(Int_t value=1) override
virtual TText * AddText(const char *label)
void Draw(Option_t *option="") override
Int_t Fill(const char *namex, Double_t y) override
static constexpr const char * PARAM_NAMES[PARAM_CNT]
static constexpr const Double_t PARAM_SIGN_X[PARAM_CNT]
static constexpr const char * PARAM_UNIT[PARAM_CNT]
static void histoGLSetRawMode(bool on, struct termios *saved)
int histoGL(const char *fileListPath="/home/igor/bmnroot/align_new/cfg/run8/7466.noa_rlerr.list", Int_t selParam=P_dZ, Int_t drawMode=DM_MIX, const char *pdfPath=nullptr)
Whole-detector histogramming estimate of the alignment corrections.
static constexpr const Double_t PARAM_SIGN_Y[PARAM_CNT]
static constexpr const Bool_t PARAM_IS_SHIFT[PARAM_CNT]
static constexpr const char * PARAM_DIAG_Y[PARAM_CNT]
static constexpr const char * COV_TITLE_Y[PARAM_CNT]
static constexpr const char * PARAM_DIAG[PARAM_CNT]
static constexpr const char * COV_TITLE_X[PARAM_CNT]
std::array< LinAcc, PARAM_CNT > y
std::array< LinAcc, PARAM_CNT > x
std::array< VecDouble_t, PARAM_CNT > errX
std::array< VecDouble_t, PARAM_CNT > valY
std::array< VecDouble_t, PARAM_CNT > errY
std::array< VecDouble_t, PARAM_CNT > valX
void Sample(Long64_t tracks, const DetAcc &a)
Double_t SlopeErr() const
Double_t Value(Int_t p, const Double_t *sign) const
Double_t MeanYErr() const
Double_t Error(Int_t p) const
void Add(Double_t x, Double_t y)