@@ -42,6 +42,7 @@ enum class propagationPoint : int {
4242 kToRabs = 2 ,
4343};
4444using SMatrix55 = ROOT::Math::SMatrix<double , 5 , 5 , ROOT::Math::MatRepSym<double , 5 >>;
45+ using SMatrix55Std = ROOT::Math::SMatrix<double , 5 >;
4546using SMatrix5 = ROOT::Math::SVector<double , 5 >;
4647
4748// / propagate fwdtrack to a certain point.
@@ -98,6 +99,48 @@ o2::dataformats::GlobalFwdTrack propagateMuon(TFwdTrack const& muon, TCollision
9899
99100 return propmuon;
100101}
102+
103+ template <typename TFwdTrack, typename TMFTTrack>
104+ o2::dataformats::GlobalFwdTrack refitGlobalMuonCov (TFwdTrack const & muon, TMFTTrack const & mft)
105+ {
106+ auto muonCov = muon.getCovariances ();
107+ auto mftCov = mft.getCovariances ();
108+
109+ SMatrix55Std jacob = ROOT::Math::SMatrixIdentity ();
110+ auto tl = muon.getTgl ();
111+ auto invQPt = muon.getInvQPt ();
112+ jacob (4 , 3 ) = tl / (invQPt * std::sqrt (1 + tl * tl));
113+ jacob (4 , 4 ) = -std::sqrt (1 + tl * tl) / (invQPt * invQPt);
114+
115+ auto covQP = ROOT::Math::Similarity (jacob, muonCov);
116+ mftCov (4 , 0 ) = 0 ;
117+ mftCov (4 , 1 ) = 0 ;
118+ mftCov (4 , 2 ) = 0 ;
119+ mftCov (4 , 3 ) = 0 ;
120+
121+ mftCov (0 , 4 ) = 0 ;
122+ mftCov (1 , 4 ) = 0 ;
123+ mftCov (2 , 4 ) = 0 ;
124+ mftCov (3 , 4 ) = 0 ;
125+ mftCov (4 , 4 ) = covQP (4 , 4 );
126+
127+ SMatrix55Std jacobInv = ROOT::Math::SMatrixIdentity ();
128+ auto qp = std::sqrt (1 + tl * tl) / invQPt;
129+ auto tlMFT = mft.getTgl ();
130+ jacobInv (4 , 3 ) = tlMFT / (qp * std::sqrt (1 + tlMFT * tlMFT));
131+ jacobInv (4 , 4 ) = -std::sqrt (1 + tlMFT * tlMFT) / (qp * qp);
132+ auto globalCov = ROOT::Math::Similarity (jacobInv, mftCov);
133+
134+ auto invQPtGlob = std::sqrt (1 + tlMFT * tlMFT) / qp;
135+
136+ o2::dataformats::GlobalFwdTrack globalTrack;
137+ globalTrack.setParameters (mft.getParameters ());
138+ globalTrack.setInvQPt (invQPtGlob);
139+ globalTrack.setCovariances (globalCov);
140+
141+ return globalTrack;
142+ }
143+
101144} // namespace fwdtrackutils
102145} // namespace o2::aod
103146
0 commit comments