4747#include < Math/MatrixRepresentationsStatic.h>
4848#include < Math/SMatrix.h>
4949#include < Math/SVector.h>
50+ #include < TGeoGlobalMagField.h>
5051#include < TTree.h>
5152
5253#include < RtypesCore.h>
@@ -279,6 +280,8 @@ struct mftMchMatcher { // o2-linter: disable=name/struct (keep temporarily)
279280
280281 o2::parameters::GRPMagField* fGrpMag = nullptr ;
281282
283+ double mBzAtMftCenter {0 };
284+
282285 std::uniform_real_distribution<double > mDistribution {0.0 , 1.0 };
283286 std::mt19937 mGenerator ;
284287
@@ -302,6 +305,7 @@ struct mftMchMatcher { // o2-linter: disable=name/struct (keep temporarily)
302305 o2::track::TrackParCovFwd trackparCov{track.z (), tpars, tcovs, chi2};
303306 o2::dataformats::GlobalFwdTrack fwdtrack;
304307 fwdtrack.setParameters (trackparCov.getParameters ());
308+ fwdtrack.setZ (trackparCov.getZ ());
305309 fwdtrack.setCovariances (trackparCov.getCovariances ());
306310 return fwdtrack;
307311 }
@@ -422,6 +426,12 @@ struct mftMchMatcher { // o2-linter: disable=name/struct (keep temporarily)
422426 o2::base::Propagator::initFieldFromGRP (fGrpMag );
423427 VarManager::SetMagneticField (fGrpMag ->getNominalL3Field ());
424428 VarManager::SetupMuonMagField ();
429+
430+ auto * fieldB = dynamic_cast <o2::field::MagneticField*>(TGeoGlobalMagField::Instance ()->GetField ());
431+ if (fieldB) {
432+ const std::array<double , 3 > centerMft{0 , 0 , -61.4 }; // Field at center of MFT
433+ mBzAtMftCenter = fieldB->getBz (centerMft.data ());
434+ }
425435 }
426436 mRunNumber = bc.runNumber ();
427437 }
@@ -647,6 +657,42 @@ struct mftMchMatcher { // o2-linter: disable=name/struct (keep temporarily)
647657 return attempts;
648658 }
649659
660+ void propagateToZ (o2::track::TrackParCovFwd& mft, o2::dataformats::GlobalFwdTrack& muon, const double z)
661+ {
662+ auto mchTrack = mExtrap .FwdtoMCH (muon);
663+
664+ // MCH track extrapolation
665+ // The multiple scattering effect is fully associated to the MCH track
666+ // independently of the position of the matching plane
667+ constexpr float absFront = -90 .f ;
668+ constexpr float absBack = -505 .f ;
669+ if (muon.getZ () < absBack) {
670+ // the track origin is downstream of the absorber
671+ if (z > absFront) {
672+ // the destination is upstream of the absorber
673+ // full extrapolation through the absorber in the upstream direction
674+ o2::mch::TrackExtrap::extrapToVertexWithoutBranson (mchTrack, z);
675+ } else {
676+ // the destination is inside or downstream of the absorber
677+ // 1. do a full extrapolation through the absorber to estimate the MS effect
678+ o2::mch::TrackExtrap::extrapToVertexWithoutBranson (mchTrack, absFront + 0 .1f );
679+ // 2. extrapolate from there back to the destination z
680+ o2::mch::TrackExtrap::extrapToZCov (mchTrack, z);
681+ }
682+ } else {
683+ // all other cases
684+ o2::mch::TrackExtrap::extrapToZCov (mchTrack, z);
685+ }
686+
687+ auto proptrack = mExtrap .MCHtoFwd (mchTrack);
688+ muon.setParameters (proptrack.getParameters ());
689+ muon.setZ (proptrack.getZ ());
690+ muon.setCovariances (proptrack.getCovariances ());
691+
692+ // MFT extrapolation without MS effects, as they are fully included in the MCH track extrapolation
693+ mft.propagateToZhelix (z, mBzAtMftCenter );
694+ }
695+
650696 template <bool isMc, class TCOLLS , class TBCS , class TMUONS , class TMFTS , class TCOVS >
651697 void fillTable (TCOLLS const & collisions,
652698 TBCS const & bcs,
@@ -707,8 +753,7 @@ struct mftMchMatcher { // o2-linter: disable=name/struct (keep temporarily)
707753 o2::track::TrackParCovFwd mftprop = VarManager::FwdToTrackPar (mfttrack, mfttrackcov);
708754 o2::dataformats::GlobalFwdTrack muonprop = trackToGlobalFwd (muontrack, muontrack);
709755 if (cfgzMatching.value < 0 .) {
710- mftprop = VarManager::PropagateFwd (mfttrack, mfttrackcov, cfgzMatching.value );
711- muonprop = VarManager::PropagateMuon (muontrack, collision, VarManager::kToMatching );
756+ propagateToZ (mftprop, muonprop, cfgzMatching.value );
712757 }
713758 auto muonpropCov = muonprop.getCovariances ();
714759 auto mftpropCov = mftprop.getCovariances ();
0 commit comments