Skip to content

Commit 78f6192

Browse files
committed
Fix TRD matrices definition and pad shift accounting
1 parent 9a1c156 commit 78f6192

File tree

3 files changed

+65
-23
lines changed

3 files changed

+65
-23
lines changed

Detectors/Align/include/Align/AlignableSensorTRD.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ class AlignableSensorTRD final : public AlignableSensor
3535
int getSector() const { return mSector; }
3636
void setSector(int sc) { mSector = (uint8_t)sc; }
3737
void dPosTraDParCalib(const AlignmentPoint* pnt, double* deriv, int calibID, const AlignableVolume* parent = nullptr) const final;
38+
39+
void prepareMatrixL2G(bool reco = false) final;
40+
void prepareMatrixL2GIdeal() final;
3841
void prepareMatrixT2L() final;
42+
void prepareMatrixClAlg() final;
43+
void prepareMatrixClAlgReco() final;
3944

4045
protected:
4146
uint8_t mSector = 0; // sector ID

Detectors/Align/src/AlignableDetectorTRD.cxx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ int AlignableDetectorTRD::processPoints(GIndex gid, int npntCut, bool inv)
192192
}
193193
int trkltId = trk.getTrackletIndex(il);
194194
const auto& trackletRaw = trackletsRaw[trkltId];
195-
const auto trackletCalibLoc = transformer->transformTracklet(trackletRaw, true); // calibrated tracket in local frame !!!
195+
const auto trackletCalibLoc = transformer->transformTracklet(trackletRaw, false); // calibrated tracket in local frame !!!
196196
int trkltDet = trackletRaw.getDetector();
197197
auto* sensor = (AlignableSensorTRD*)getSensor(trkltDet);
198198
if (sensor->isDummy()) {
@@ -201,23 +201,10 @@ int AlignableDetectorTRD::processPoints(GIndex gid, int npntCut, bool inv)
201201
continue;
202202
}
203203
double locXYZ[3] = {trackletCalibLoc.getX(), trackletCalibLoc.getY(), trackletCalibLoc.getZ()}, locXYZC[3], traXYZ[3];
204-
/*
205204
const auto& matAlg = sensor->getMatrixClAlg(); // local alignment matrix
206205
matAlg.LocalToMaster(locXYZ, locXYZC); // aligned point in the local frame
207206
const auto& mat = sensor->getMatrixT2L(); // RS FIXME check if correct
208207
mat.MasterToLocal(locXYZC, traXYZ);
209-
*/
210-
traXYZ[0] = trackletCalibLoc.getX();
211-
traXYZ[1] = trackletCalibLoc.getY();
212-
traXYZ[2] = trackletCalibLoc.getZ();
213-
214-
/*
215-
// This is a hack until TRD T2L matrix problem will be solved
216-
const auto trackletCalib = recoData->getTRDCalibratedTracklets()[trkltId];
217-
traXYZ[0] = trackletCalib.getX();
218-
traXYZ[1] = trackletCalib.getY();
219-
traXYZ[2] = trackletCalib.getZ();
220-
*/
221208
int trkltSec = sensor->getSector(); // trkltDet / (o2::trd::constants::NLAYER * o2::trd::constants::NSTACK);
222209
float alpSens = sensor->getAlpTracking(); // o2::math_utils::sector2Angle(trkltSec);
223210
if (trkltSec != o2::math_utils::angle2Sector(trkParam.getAlpha()) ||

Detectors/Align/src/AlignableSensorTRD.cxx

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "Align/utils.h"
2020
#include "Framework/Logger.h"
2121
#include "Align/AlignmentPoint.h"
22+
#include "DetectorsBase/GeometryManager.h"
2223

2324
namespace o2
2425
{
@@ -33,22 +34,71 @@ AlignableSensorTRD::AlignableSensorTRD(const char* name, int vid, int iid, int i
3334
// def c-tor
3435
}
3536

37+
//____________________________________________
38+
void AlignableSensorTRD::prepareMatrixClAlg()
39+
{
40+
// prepare alignment matrix in the pseudo-LOCAL frame of TRD (account that the chamber has extra X,Y rotations
41+
TGeoHMatrix ma = getMatrixL2GIdeal().Inverse();
42+
ma *= getMatrixL2G();
43+
setMatrixClAlg(ma);
44+
//
45+
}
46+
47+
//____________________________________________
48+
void AlignableSensorTRD::prepareMatrixClAlgReco()
49+
{
50+
// prepare alignment matrix in the pseudo-LOCAL frame of TRD (account that the chamber has extra X,Y rotations
51+
TGeoHMatrix ma = getMatrixL2GIdeal().Inverse();
52+
ma *= getMatrixL2G();
53+
setMatrixClAlgReco(ma);
54+
//
55+
}
56+
57+
//____________________________________________
58+
void AlignableSensorTRD::prepareMatrixL2GIdeal()
59+
{
60+
TGeoHMatrix Rxy;
61+
Rxy.RotateX(-90);
62+
Rxy.RotateY(-90);
63+
TGeoHMatrix mtmp;
64+
if (!base::GeometryManager::getOriginalMatrix(getSymName(), mtmp)) {
65+
LOG(fatal) << "Failed to find ideal L2G matrix for " << getSymName();
66+
}
67+
mtmp *= Rxy;
68+
setMatrixL2GIdeal(mtmp);
69+
}
70+
71+
//____________________________________________
72+
void AlignableSensorTRD::prepareMatrixL2G(bool reco)
73+
{
74+
TGeoHMatrix Rxy;
75+
Rxy.RotateX(-90);
76+
Rxy.RotateY(-90);
77+
const char* path = getSymName();
78+
const TGeoHMatrix* l2g = nullptr;
79+
if (!gGeoManager->GetAlignableEntry(path) || !(l2g = base::GeometryManager::getMatrix(path))) {
80+
LOGP(fatal, "Failed to find L2G matrix for {}alignable {} -> {}", gGeoManager->GetAlignableEntry(path) ? "" : "non-", path, (void*)l2g);
81+
}
82+
TGeoHMatrix mtmp = *l2g;
83+
mtmp *= Rxy;
84+
reco ? setMatrixL2GReco(mtmp) : setMatrixL2G(mtmp);
85+
}
86+
3687
//____________________________________________
3788
void AlignableSensorTRD::prepareMatrixT2L()
3889
{
3990
// extract from geometry T2L matrix
4091
double alp = math_utils::detail::sector2Angle<float>(mSector);
4192
mAlp = alp;
42-
double loc[3] = {0, 0, 0}, glo[3];
43-
getMatrixL2GIdeal().LocalToMaster(loc, glo);
44-
mX = Sqrt(glo[0] * glo[0] + glo[1] * glo[1]);
45-
TGeoHMatrix t2l;
46-
// t2l.SetDx(mX); // to remove when T2L will be clarified
47-
t2l.RotateZ(alp * RadToDeg());
48-
const TGeoHMatrix l2gi = getMatrixL2GIdeal().Inverse();
49-
t2l.MultiplyLeft(&l2gi);
50-
93+
TGeoHMatrix Rs;
94+
Rs.RotateZ(-alp * TMath::RadToDeg());
95+
TGeoHMatrix m0 = getMatrixL2GIdeal();
96+
m0.MultiplyLeft(Rs);
97+
TGeoHMatrix t2l = m0.Inverse();
5198
setMatrixT2L(t2l);
99+
double loc[3] = {0, 0, 0}, glo[3];
100+
t2l.MasterToLocal(loc, glo);
101+
mX = glo[0];
52102
//
53103
}
54104

0 commit comments

Comments
 (0)