From 1709cd11bec7b91372a81f58b0842535b7312e38 Mon Sep 17 00:00:00 2001
From: "se.gorbunov" <se.gorbunov@gsi.de>
Date: Wed, 23 Feb 2022 19:15:26 +0000
Subject: [PATCH] L1: bugfix for shifted origin

---
 reco/KF/CbmKFParticleInterface.cxx       | 1 +
 reco/L1/L1Algo/L1Algo.h                  | 7 ++++---
 reco/L1/ParticleFinder/CbmL1PFFitter.cxx | 4 ++--
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/reco/KF/CbmKFParticleInterface.cxx b/reco/KF/CbmKFParticleInterface.cxx
index bffd2116a5..b117af3b16 100644
--- a/reco/KF/CbmKFParticleInterface.cxx
+++ b/reco/KF/CbmKFParticleInterface.cxx
@@ -162,6 +162,7 @@ void CbmKFParticleInterface::ExtrapolateTrackToPV(const CbmStsTrack* track, CbmV
   CbmL1PFFitter fitter;
   vector<float> vChiToPrimVtx;
   CbmKFVertex kfVertex;
+  assert(pv);
   if (pv) kfVertex = CbmKFVertex(*pv);
 
   vector<L1FieldRegion> vField;
diff --git a/reco/L1/L1Algo/L1Algo.h b/reco/L1/L1Algo/L1Algo.h
index 86fd0dde61..03ac49f01d 100644
--- a/reco/L1/L1Algo/L1Algo.h
+++ b/reco/L1/L1Algo/L1Algo.h
@@ -214,8 +214,8 @@ public:
   alignas(16) std::array<L1Station, L1Parameters::kMaxNstations> fStationsNew;
   L1Vector<L1Material> fRadThick {"fRadThick"};        // material for each station
 
-  int NStsStrips {0};                   // number of strips
-  L1Vector<L1Hit>* vStsHits {nullptr};  // hits as a combination of front-, backstrips and z-position
+  int NStsStrips {0};                         // number of strips
+  L1Vector<L1Hit>* vStsHits {nullptr};        // hits as a combination of front-, backstrips and z-position
   L1Grid vGrid[L1Parameters::kMaxNstations];  // hits as a combination of front-, backstrips and z-position
   L1Grid vGridTime[L1Parameters::kMaxNstations];
 
@@ -368,6 +368,8 @@ public:
   //       the L1Algo instance. (S.Zh.)
   L1InitManager* GetL1InitManager() { return &fInitManager; }
 
+  fvec GetCbmTargetZ() const { return fCbmTargetZ; }
+
 private:
   /// Object containing L1Parameters. Default consturctor is used
   L1Parameters fL1Parameters;  ///< Object of L1Algo parameters class
@@ -568,7 +570,6 @@ private:
   void FilterFirstL(L1TrackParFit& track, fvec& x, fvec& y, fvec& t, fvec& t_er, L1Station& st, fvec& dx, fvec& dy,
                     fvec& dxy);
 
-
 #ifdef TBB
   enum
   {
diff --git a/reco/L1/ParticleFinder/CbmL1PFFitter.cxx b/reco/L1/ParticleFinder/CbmL1PFFitter.cxx
index 260217dd41..fac70237a7 100644
--- a/reco/L1/ParticleFinder/CbmL1PFFitter.cxx
+++ b/reco/L1/ParticleFinder/CbmL1PFFitter.cxx
@@ -483,7 +483,7 @@ void CbmL1PFFitter::GetChiToVertex(vector<CbmStsTrack>& Tracks, vector<L1FieldRe
     }
 
     fB[0]     = CbmL1::Instance()->algo->GetVtxFieldValue();
-    zField[0] = 0;
+    zField[0] = CbmL1::Instance()->algo->GetCbmTargetZ();
     fld.Set(fB[2], zField[2], fB[1], zField[1], fB[0], zField[0]);
     field.push_back(fld);
 
@@ -623,7 +623,7 @@ void CbmL1PFFitter::CalculateFieldRegion(vector<CbmStsTrack>& Tracks, vector<L1F
     }
 
     fB[0]     = CbmL1::Instance()->algo->GetVtxFieldValue();
-    zField[0] = 0;
+    zField[0] = CbmL1::Instance()->algo->GetCbmTargetZ();
     fld.Set(fB[2], zField[2], fB[1], zField[1], fB[0], zField[0]);
     field.push_back(fld);
   }
-- 
GitLab