1919#include " Align/utils.h"
2020#include " Framework/Logger.h"
2121#include " Align/AlignmentPoint.h"
22+ #include " DetectorsBase/GeometryManager.h"
2223
2324namespace 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// ____________________________________________
3788void 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