From ad8679e6cb0078f84d30000bbd1c49ead4716bf2 Mon Sep 17 00:00:00 2001
From: Valentina <v.akishina@gsi.de>
Date: Thu, 6 Oct 2022 12:21:05 +0200
Subject: [PATCH] correction of extrapolation in time

---
 reco/L1/CbmL1.cxx                  |  3 ++-
 reco/L1/L1Algo/L1CATrackFinder.cxx | 10 ++++++----
 reco/L1/L1Algo/L1Extrapolation.h   |  2 +-
 reco/L1/L1Algo/L1TrackExtender.cxx |  6 +++---
 4 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx
index 4aeed635f..631e6dac3 100644
--- a/reco/L1/CbmL1.cxx
+++ b/reco/L1/CbmL1.cxx
@@ -997,6 +997,7 @@ void CbmL1::Reconstruct(CbmEvent* event)
 
     if ((fPerformance) && (fSTAPDataMode < 2)) { InputPerformance(); }
 
+
     //  FieldApproxCheck();
     //  FieldIntegralCheck();
 
@@ -1176,7 +1177,7 @@ void CbmL1::Reconstruct(CbmEvent* event)
   }
 
 
-  if ((fPerformance) && (fSTAPDataMode < 2)) { InputPerformance(); }
+//  if ((fPerformance) && (fSTAPDataMode < 2)) { InputPerformance(); }
 
   // TODO: Remove this code (S.Zharko)
   //  for (unsigned int iH = 0; iH < (*fpAlgo->vHits).size(); ++iH) {
diff --git a/reco/L1/L1Algo/L1CATrackFinder.cxx b/reco/L1/L1Algo/L1CATrackFinder.cxx
index 872c344ca..e5e6c53e5 100644
--- a/reco/L1/L1Algo/L1CATrackFinder.cxx
+++ b/reco/L1/L1Algo/L1CATrackFinder.cxx
@@ -357,7 +357,8 @@ inline void L1Algo::findSingletsStep1(  /// input 1st stage of singlet search
     //assert(T.IsConsistent(true, -1));
 
     fvec dz = stam.z - zl;
-    L1ExtrapolateTime(T, dz, stam.timeInfo);
+    L1ExtrapolateTime(T, dz, stam.timeInfo, fMaxInvMom);
+
 
     // extrapolate to the middle hit
     if (istam < fNfieldStations) { L1Extrapolate0(T, stam.z, fld0); }
@@ -643,7 +644,7 @@ inline void L1Algo::findTripletsStep0(  // input
 
     fvec dz = zPos_2 - T2.z;
 
-    L1ExtrapolateTime(T2, dz, stam.timeInfo);
+    L1ExtrapolateTime(T2, dz, stam.timeInfo, fMaxInvMom);
 
     // assert(T2.IsConsistent(true, n2_4));
 
@@ -798,13 +799,14 @@ inline void L1Algo::findTripletsStep0(  // input
         L1TrackPar T_cur = T2;
 
         fvec dz3 = zr - T_cur.z;
-        L1ExtrapolateTime(T_cur, dz3, star.timeInfo);
+        L1ExtrapolateTime(T_cur, dz3, star.timeInfo, fMaxInvMom);
 
         L1ExtrapolateLine(T_cur, zr);
 
         if ((star.timeInfo) && (stam.timeInfo))
           if (fabs(T_cur.t[i2_4] - hitr.time) > sqrt(T_cur.C55[i2_4] + hitr.timeEr) * 5) continue;
 
+
         // TODO: SG: hardcoded cut of 30 ns
         if ((star.timeInfo) && (stam.timeInfo))
           if (fabs(T_cur.t[i2_4] - hitr.time) > 30) continue;
@@ -940,8 +942,8 @@ inline void L1Algo::findTripletsStep1(  // input
     L1TrackPar& T3 = T_3[i3_V];
 
     // assert(T3.IsConsistent(true, -1));
+    L1ExtrapolateTime(T_3, dz, star.timeInfo, fMaxInvMom);
 
-    L1ExtrapolateTime(T3, dz, star.timeInfo);
 
     L1ExtrapolateLine(T3, z_Pos[i3_V]);
 
diff --git a/reco/L1/L1Algo/L1Extrapolation.h b/reco/L1/L1Algo/L1Extrapolation.h
index f4ec3a4b5..4887f7769 100644
--- a/reco/L1/L1Algo/L1Extrapolation.h
+++ b/reco/L1/L1Algo/L1Extrapolation.h
@@ -13,7 +13,7 @@ void L1Extrapolate  // extrapolates track parameters and returns jacobian for ex
   (L1TrackPar& T,   // input track parameters (x,y,tx,ty,Q/p) and cov.matrix
    fvec z_out,      // extrapolate to this z position
    fvec qp0,        // use Q/p linearisation at this value
-   const L1FieldRegion& F, const fvec* w = nullptr);
+   const L1FieldRegion& F, fvec* w = nullptr);
 
 void L1Extrapolate0(L1TrackPar& T,  // input track parameters (x,y,tx,ty,Q/p) and cov.matrix
                     fvec z_out,     // extrapolate to this z position
diff --git a/reco/L1/L1Algo/L1TrackExtender.cxx b/reco/L1/L1Algo/L1TrackExtender.cxx
index bfd01b3a6..500c0d862 100644
--- a/reco/L1/L1Algo/L1TrackExtender.cxx
+++ b/reco/L1/L1Algo/L1TrackExtender.cxx
@@ -134,7 +134,7 @@ void L1Algo::BranchFitterFast(const L1Branch& t, L1TrackPar& T, const bool dir,
 #else
     L1Extrapolate(T, hit.z, qp0, fld);
 #endif
-    L1ExtrapolateTime(T, dz);
+    L1ExtrapolateTime(T, dz, fMaxInvMom);
 
     fit.L1AddMaterial(T, sta.materialInfo, qp0, 1);
     if ((step * ista <= step * (fNstationsBeforePipe + (step + 1) / 2 - 1))
@@ -249,7 +249,7 @@ void L1Algo::FindMoreHits(L1Branch& t, L1TrackPar& T, const bool dir,
 
     fvec dz = sta.z - T.z;
 
-    L1ExtrapolateTime(T, dz);
+    L1ExtrapolateTime(T, dz, fMaxInvMom);
 
 #if defined(mCBM) || defined(GLOBAL)
     L1ExtrapolateLine(T, sta.z);
@@ -318,7 +318,7 @@ void L1Algo::FindMoreHits(L1Branch& t, L1TrackPar& T, const bool dir,
 
     fvec dz1 = z - T.z;
 
-    L1ExtrapolateTime(T, dz1);
+    L1ExtrapolateTime(T, dz1, fMaxInvMom);
 
     L1ExtrapolateLine(T, z);
     fit.L1AddMaterial(T, sta.materialInfo, qp0, 1);
-- 
GitLab