Skip to content

Commit c406177

Browse files
committed
align
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent b3b9dd8 commit c406177

File tree

5 files changed

+112
-9
lines changed

5 files changed

+112
-9
lines changed

Detectors/Upgrades/ITS3/alignment/include/ITS3Align/AlignmentTypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct FrameInfoExt final {
4848
struct FitInfo final {
4949
float chi2Ndf{-1}; // Chi2/Ndf of track refit
5050
float chi2{-1}; // Chi2
51-
int ndf; // ndf
51+
int ndf{-1}; // ndf
5252
ClassDefNV(FitInfo, 1)
5353
};
5454

Detectors/Upgrades/ITS3/alignment/src/AlignmentSensors.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// or submit itself to any jurisdiction.
1111

1212
#include <numbers>
13+
#include <format>
1314

1415
#include <TGeoManager.h>
1516
#include <TGeoPhysicalNode.h>

Detectors/Upgrades/ITS3/alignment/src/AlignmentSpec.cxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,10 @@ void AlignmentSpec::process()
386386
if (mOutOpt[OutputOpt::MilleData]) {
387387
gblTrajSlot.push_back(traj);
388388
}
389-
FitInfo fit{.ndf = ndf, .chi2 = (float)chi2, .chi2Ndf = (float)chi2 / (float)ndf};
389+
FitInfo fit;
390+
fit.ndf = ndf;
391+
fit.chi2 = (float)chi2;
392+
fit.chi2Ndf = (float)chi2 / (float)ndf;
390393
resTrack.gblFit = fit;
391394
}
392395
} else {

Detectors/Upgrades/ITS3/study/macros/PlotMisalignment.C

Lines changed: 104 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,24 @@
1414
#include <TF1.h>
1515
#include <TH1F.h>
1616
#include <TH2F.h>
17+
#include <TProfile2D.h>
1718
#include <TCanvas.h>
1819
#include <TTree.h>
20+
#include <TStyle.h>
1921
#endif
2022

21-
void plotTreeVsX(TFile* f, const char* treeName, const char* xVar, const char* xTitle, int nBinsX, float xMin, float xMax)
23+
TString makeSel(int lay, const char* extraSel)
24+
{
25+
TString sel = Form("lay==%d", lay);
26+
if (extraSel && extraSel[0]) {
27+
sel += Form(" && %s", extraSel);
28+
}
29+
return sel;
30+
}
31+
32+
void plotTreeVsX(TFile* f, const char* treeName, const char* xVar, const char* xTitle,
33+
int nBinsX, float xMin, float xMax,
34+
const char* tag = "", const char* extraSel = "")
2235
{
2336
auto res = f->Get<TTree>(treeName);
2437
const int nVar = 2;
@@ -27,7 +40,7 @@ void plotTreeVsX(TFile* f, const char* treeName, const char* xVar, const char* x
2740

2841
TCanvas* canvs[nVar];
2942
for (int iv = 0; iv < nVar; iv++) {
30-
canvs[iv] = new TCanvas(Form("%s_%s_vs_%s", treeName, vars[iv], xVar), Form("%s vs %s", vars[iv], xVar), 800, 1600);
43+
canvs[iv] = new TCanvas(Form("%s_%s_vs_%s%s", treeName, vars[iv], xVar, tag), Form("%s vs %s %s", vars[iv], xVar, tag), 800, 1600);
3144
canvs[iv]->Divide(2, 4);
3245
}
3346

@@ -37,16 +50,16 @@ void plotTreeVsX(TFile* f, const char* treeName, const char* xVar, const char* x
3750
canvs[iv]->cd(lay + 2);
3851
gPad->SetRightMargin(0.13);
3952

40-
TString hname = Form("h_%s_%s_lay%d", vars[iv], xVar, lay + 1);
53+
TString hname = Form("h_%s_%s%s_lay%d", vars[iv], xVar, tag, lay + 1);
4154
TString expr = Form("%s*10000:%s>>%s(%d,%f,%f,100,-100,100)", vars[iv], xVar, hname.Data(), nBinsX, xMin, xMax);
42-
TString sel = Form("lay==%d", lay);
55+
TString sel = makeSel(lay, extraSel);
4356
res->Draw(expr, sel, "col");
4457

4558
auto* h = (TH2F*)gDirectory->Get(hname);
4659
if (!h) {
4760
continue;
4861
}
49-
h->SetTitle(Form("Layer %d ;%s;%s", lay, xTitle, titles[iv]));
62+
h->SetTitle(Form("Layer %d %s;%s;%s", lay, tag, xTitle, titles[iv]));
5063
h->GetZaxis()->SetLabelSize(0.035);
5164

5265
// fit y-slices with gaussian
@@ -69,11 +82,97 @@ void plotTreeVsX(TFile* f, const char* treeName, const char* xVar, const char* x
6982
}
7083
}
7184

85+
void plotProfile2D(TFile* f, const char* treeName,
86+
const char* tag = "", const char* extraSel = "")
87+
{
88+
auto res = f->Get<TTree>(treeName);
89+
const int nVar = 2;
90+
const char* vars[nVar] = {"dY", "dZ"};
91+
const char* titles[nVar] = {"#LTd_{Y}#GT (#mum)", "#LTd_{Z}#GT (#mum)"};
92+
93+
TCanvas* canvs[nVar];
94+
for (int iv = 0; iv < nVar; iv++) {
95+
canvs[iv] = new TCanvas(Form("%s_%s_prof2d%s", treeName, vars[iv], tag), Form("%s #phi vs #eta %s", vars[iv], tag), 800, 1600);
96+
canvs[iv]->Divide(2, 4);
97+
}
98+
99+
for (int iv = 0; iv < nVar; iv++) {
100+
canvs[iv]->cd(0);
101+
for (int lay = -1; lay <= 6; lay++) {
102+
canvs[iv]->cd(lay + 2);
103+
gPad->SetRightMargin(0.15);
104+
105+
TString hname = Form("hp_%s%s_lay%d", vars[iv], tag, lay + 1);
106+
TString expr = Form("%s*10000:eta:phi>>%s(50,0,%f,50,-1.,1.)", vars[iv], hname.Data(), 2 * TMath::Pi());
107+
TString sel = makeSel(lay, extraSel);
108+
res->Draw(expr, sel, "prof colz");
109+
110+
auto* h = (TProfile2D*)gDirectory->Get(hname);
111+
if (!h) {
112+
continue;
113+
}
114+
h->SetTitle(Form("Layer %d %s;#phi (rad);#eta;%s", lay, tag, titles[iv]));
115+
}
116+
canvs[iv]->SaveAs(Form("%s.png", canvs[iv]->GetName()));
117+
}
118+
}
119+
120+
void plotPulls(TFile* f, const char* treeName,
121+
const char* tag = "", const char* extraSel = "")
122+
{
123+
auto res = f->Get<TTree>(treeName);
124+
const int nPar = 5;
125+
const char* parNames[nPar] = {"Y", "Z", "Snp", "Tgl", "Q2Pt"};
126+
// diagonal covariance indices in mC[]: 0, 2, 5, 9, 14
127+
const int covIdx[nPar] = {0, 2, 5, 9, 14};
128+
129+
for (int lay = -1; lay <= 6; lay++) {
130+
auto* c = new TCanvas(Form("%s_pulls_lay%d%s", treeName, lay, tag), Form("Pulls layer %d %s", lay, tag), 1200, 800);
131+
c->Divide(3, 2);
132+
TString sel = makeSel(lay, extraSel);
133+
134+
for (int ip = 0; ip < nPar; ip++) {
135+
c->cd(ip + 1);
136+
TString hname = Form("hpull_%s%s_lay%d", parNames[ip], tag, lay + 1);
137+
TString expr = Form("(trk.mP[%d]-mcTrk.mP[%d])/sqrt(trk.mC[%d])>>%s(100,-5,5)", ip, ip, covIdx[ip], hname.Data());
138+
res->Draw(expr, sel);
139+
140+
auto* h = (TH1F*)gDirectory->Get(hname);
141+
if (!h) {
142+
continue;
143+
}
144+
h->SetTitle(Form("Layer %d %s;pull_{%s};counts", lay, tag, parNames[ip]));
145+
h->Fit("gaus", "Q");
146+
}
147+
c->SaveAs(Form("%s.png", c->GetName()));
148+
}
149+
}
150+
72151
void PlotMisalignment(const char* fname = "its3TrackStudy.root")
73152
{
74153
auto f = TFile::Open(fname);
154+
155+
const int nPtBins = 5;
156+
const float ptEdges[nPtBins + 1] = {0., 0.3, 0.8, 2., 5., 10.};
157+
75158
for (const char* tree : {"idealRes", "misRes"}) {
159+
// integrated plots
76160
plotTreeVsX(f, tree, "phi", "#phi (rad)", 100, 0, 2 * TMath::Pi());
77161
plotTreeVsX(f, tree, "eta", "#eta", 100, -1., 1.);
162+
plotProfile2D(f, tree);
163+
plotPulls(f, tree);
164+
165+
// pT-binned plots
166+
for (int ipt = 0; ipt < nPtBins; ipt++) {
167+
TString tag = Form("_pt%.0f_%.0f", ptEdges[ipt] * 10, ptEdges[ipt + 1] * 10);
168+
TString ptSel = Form("trk.getPt()>=%.2f&&trk.getPt()<%.2f", ptEdges[ipt], ptEdges[ipt + 1]);
169+
TString ptLabel = Form(" (%.1f<p_{T}<%.1f)", ptEdges[ipt], ptEdges[ipt + 1]);
170+
TString tagLabel = tag + ptLabel;
171+
172+
plotTreeVsX(f, tree, "phi", "#phi (rad)", 100, 0, 2 * TMath::Pi(), tag.Data(), ptSel.Data());
173+
plotTreeVsX(f, tree, "eta", "#eta", 100, -1., 1., tag.Data(), ptSel.Data());
174+
plotProfile2D(f, tree, tag.Data(), ptSel.Data());
175+
plotPulls(f, tree, tag.Data(), ptSel.Data());
176+
}
78177
}
79178
}

Detectors/Upgrades/ITS3/study/src/TrackingStudy.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,12 +1255,12 @@ void TrackingStudySpec::doMisalignmentStudy()
12551255
// propagate MC track to cluster's tracking frame to get true slopes
12561256
auto mcAtCl = mcPar;
12571257
if (!mcAtCl.rotate(orig.alpha) || !prop->PropagateToXBxByBz(mcAtCl, orig.getX())) {
1258-
clArrMis[1 + iLay] = nullptr; // can't compute slopes drop cluster
1258+
clArrMis[1 + iLay] = nullptr; // can't compute slopes -> drop cluster
12591259
continue;
12601260
}
12611261
const float snp = mcAtCl.getSnp();
12621262
const float tgl = mcAtCl.getTgl();
1263-
const float csci = 1.f / std::sqrt(1.f - (snp * snp)); // 1/cos(phi_local)
1263+
const float csci = 1.f / std::sqrt(1.f - (snp * snp));
12641264
const float dydx = snp * csci;
12651265
const float dzdx = tgl * csci;
12661266
const float dy = dydx * static_cast<float>(h);

0 commit comments

Comments
 (0)