From a9b9bdcbbc4cbbd8e732953922a7b63729a55205 Mon Sep 17 00:00:00 2001
From: "se.gorbunov" <se.gorbunov@gsi.de>
Date: Fri, 27 Oct 2023 16:31:13 +0000
Subject: [PATCH] CbmTrack & CbmGlobalTrack: Add Chi2 & Ndf of the time fit to
 track parameters

---
 core/data/CbmTrack.h                          | 10 +++++++-
 core/data/global/CbmGlobalTrack.cxx           |  3 ++-
 core/data/global/CbmGlobalTrack.h             | 24 +++++++++++++------
 .../CbmL1GlobalTrackFinder.cxx                |  2 ++
 .../OffLineInterface/CbmL1StsTrackFinder.cxx  |  2 ++
 5 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/core/data/CbmTrack.h b/core/data/CbmTrack.h
index fb8aa72377..43b4a35a69 100644
--- a/core/data/CbmTrack.h
+++ b/core/data/CbmTrack.h
@@ -62,6 +62,8 @@ public:
   int32_t GetFlag() const { return fFlag; }
   double GetChiSq() const { return fChiSq; }
   int32_t GetNDF() const { return fNDF; }
+  double GetChiSqTime() const { return fChiSqTime; }
+  int32_t GetNdfTime() const { return fNdfTime; }
   int32_t GetPreviousTrackId() const { return fPreviousTrackId; }
   const FairTrackParam* GetParamFirst() const { return &fParamFirst; }
   const FairTrackParam* GetParamLast() const { return &fParamLast; }
@@ -78,6 +80,8 @@ public:
   void SetFlag(int32_t flag) { fFlag = flag; }
   void SetChiSq(double chiSq) { fChiSq = chiSq; }
   void SetNDF(int32_t ndf) { fNDF = ndf; }
+  void SetChiSqTime(double chiSq) { fChiSqTime = chiSq; }
+  void SetNdfTime(int32_t ndf) { fNdfTime = ndf; }
   void SetPreviousTrackId(int32_t previousTrackId) { fPreviousTrackId = previousTrackId; }
   void SetParamFirst(const FairTrackParam* par) { fParamFirst = *par; }
   void SetParamLast(const FairTrackParam* par) { fParamLast = *par; }
@@ -132,7 +136,11 @@ protected:
   /** Monte-Carlo information **/
   CbmMatch* fMatch;
 
-  ClassDef(CbmTrack, 5);
+  /** Chi square and NDF of track fit in time **/
+  Double32_t fChiSqTime {0.};
+  int32_t fNdfTime {0};
+
+  ClassDef(CbmTrack, 6);
 };
 
 #endif
diff --git a/core/data/global/CbmGlobalTrack.cxx b/core/data/global/CbmGlobalTrack.cxx
index b1a6548345..3ab0c94226 100644
--- a/core/data/global/CbmGlobalTrack.cxx
+++ b/core/data/global/CbmGlobalTrack.cxx
@@ -32,7 +32,8 @@ void CbmGlobalTrack::Print(Option_t*) const
   //  fParamFirst.Print();
   //  LOG(info) << "Parameters at last plane: ";
   //  fParamLast.Print();
-  LOG(info) << "chi2 = " << fChi2 << ", NDF = " << fNDF << ", Quality flag " << fFlag;
+  LOG(info) << "chiSq = " << fChiSq << ", Ndf = " << fNdf << ", chiSqTime = " << fChiSqTime
+            << ", NdfTime = " << fNdfTime << ", PidHypo = " << fPidHypo << ", Quality flag " << fFlag;
   LOG(info) << "length = " << fLength;
 }
 // -------------------------------------------------------------------------
diff --git a/core/data/global/CbmGlobalTrack.h b/core/data/global/CbmGlobalTrack.h
index de58e76f19..aeca221ec8 100644
--- a/core/data/global/CbmGlobalTrack.h
+++ b/core/data/global/CbmGlobalTrack.h
@@ -51,8 +51,10 @@ public:
   const FairTrackParam* GetParamLast() const { return &fParamLast; }
   const CbmTrackParam* GetParamVertex() const { return &fParamPrimaryVertex; }
   int32_t GetPidHypo() const { return fPidHypo; }
-  double GetChi2() const { return fChi2; }
-  int32_t GetNDF() const { return fNDF; }
+  double GetChi2() const { return fChiSq; }
+  int32_t GetNDF() const { return fNdf; }
+  double GetChiSqTime() const { return fChiSqTime; }
+  int32_t GetNdfTime() const { return fNdfTime; }
   int32_t GetFlag() const { return fFlag; }
   double GetLength() const { return fLength; }
 
@@ -70,8 +72,10 @@ public:
   void SetParamLast(const FairTrackParam& parLast) { fParamLast = parLast; }
   void SetParamPrimaryVertex(const FairTrackParam* parPV) { fParamPrimaryVertex.Set(*parPV); }
   void SetPidHypo(int32_t iPid) { fPidHypo = iPid; }
-  void SetChi2(double chi2) { fChi2 = chi2; }
-  void SetNDF(int32_t ndf) { fNDF = ndf; }
+  void SetChi2(double chi2) { fChiSq = chi2; }
+  void SetNDF(int32_t ndf) { fNdf = ndf; }
+  void SetChiSqTime(double chi2) { fChiSqTime = chi2; }
+  void SetNdfTime(int32_t ndf) { fNdfTime = ndf; }
   void SetFlag(int32_t iFlag) { fFlag = iFlag; }
   void SetLength(double length) { fLength = length; }
 
@@ -98,10 +102,10 @@ private:
   int32_t fPidHypo = 0;
 
   /** Chi2 of global track fit **/
-  double fChi2 = 0.;
+  double fChiSq = 0.;
 
   /** NDF of global track fit **/
-  int32_t fNDF = 0;
+  int32_t fNdf = 0;
 
   /** Quality flag **/
   int32_t fFlag = 0;
@@ -109,7 +113,13 @@ private:
   /** Track length **/
   double fLength = 0.;
 
-  ClassDef(CbmGlobalTrack, 3);
+  /** Chi2 of time fit **/
+  double fChiSqTime = 0.;
+
+  /** NDF of time fit **/
+  int32_t fNdfTime = 0.;
+
+  ClassDef(CbmGlobalTrack, 4);
 };
 
 
diff --git a/reco/L1/OffLineInterface/CbmL1GlobalTrackFinder.cxx b/reco/L1/OffLineInterface/CbmL1GlobalTrackFinder.cxx
index de59be1823..0dee55b115 100644
--- a/reco/L1/OffLineInterface/CbmL1GlobalTrackFinder.cxx
+++ b/reco/L1/OffLineInterface/CbmL1GlobalTrackFinder.cxx
@@ -95,6 +95,8 @@ Int_t CbmL1GlobalTrackFinder::CopyL1Tracks(CbmEvent* event)
     t->SetChi2(T.GetChiSq());
     //   t->SetLength(T.length);
     t->SetNDF(T.GetNdf());
+    t->SetChiSqTime(T.GetChiSqTime());
+    t->SetNdfTime(T.GetNdfTime());
     t->SetPidHypo(T.GetQp() >= 0 ? 211 : -211);
     //     t->SetTime(T.Tpv[6]);
     //     t->SetTimeError(T.Cpv[20]);
diff --git a/reco/L1/OffLineInterface/CbmL1StsTrackFinder.cxx b/reco/L1/OffLineInterface/CbmL1StsTrackFinder.cxx
index c24827ea0a..eb4ca33d86 100644
--- a/reco/L1/OffLineInterface/CbmL1StsTrackFinder.cxx
+++ b/reco/L1/OffLineInterface/CbmL1StsTrackFinder.cxx
@@ -79,6 +79,8 @@ Int_t CbmL1StsTrackFinder::CopyL1Tracks(CbmEvent* event)
     t->SetParamLast(cbm::L1Util::ConvertTrackParam(T.TLast));
     t->SetChiSq(T.GetChiSq());
     t->SetNDF(T.GetNdf());
+    t->SetChiSqTime(T.GetChiSqTime());
+    t->SetNdfTime(T.GetNdfTime());
     t->SetPidHypo(T.GetQp() >= 0 ? 211 : -211);
     t->SetStartTime(T.Tpv.GetTime());
     t->SetStartTimeError(T.Tpv.GetTimeError());
-- 
GitLab