From 7d5c50ce2229570422e8237017641112b9e33d92 Mon Sep 17 00:00:00 2001
From: abarton <Adam.Edward.Barton@cern.ch>
Date: Tue, 24 Oct 2023 13:39:55 +0100
Subject: [PATCH 1/2] Use FastFit for initial position

---
 .../DerivationFrameworkBPhys/python/BPHY10.py     |  1 -
 .../DerivationFrameworkBPhys/python/BPHY5.py      |  4 ----
 .../JpsiUpsilonTools/JpsiPlus1Track.h             |  1 -
 .../JpsiUpsilonTools/JpsiPlus2Tracks.h            |  1 -
 .../JpsiUpsilonTools/src/JpsiPlus1Track.cxx       | 15 +++++----------
 .../JpsiUpsilonTools/src/JpsiPlus2Tracks.cxx      | 15 +++++----------
 6 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/python/BPHY10.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/python/BPHY10.py
index 97cfa67d4037..6290a5876fa1 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/python/BPHY10.py
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/python/BPHY10.py
@@ -86,7 +86,6 @@ def BPHY10Cfg(flags):
                              ExcludeCrossJpsiTracks  = False,   #setting this to False rejects the muons from J/psi candidate
                              TrkVertexFitterTool     = vkalvrt,
                              TrackSelectorTool       = trackselect,
-                             VertexPointEstimator    = vpest,
                              UseMassConstraint       = True,
                              Chi2Cut                 = 10.0,
                              DiTrackPt               = 500.,
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/python/BPHY5.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/python/BPHY5.py
index 0df05bdd36e8..cc2885fedfe7 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/python/BPHY5.py
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/python/BPHY5.py
@@ -120,7 +120,6 @@ def BPHY5Kernel(flags, Decays="BsB+BdKstBpipiX"):
          MuonsUsedInJpsi             = mainMuonInput,
          TrkVertexFitterTool         = vkalvrt,
          TrackSelectorTool           = trackselect,
-         VertexPointEstimator        = vpest,
          UseMassConstraint           = True)
    acc.addPublicTool(BPHY5BsJpsiKK )
    BPHY5BdJpsiKst = CompFactory.Analysis.JpsiPlus2Tracks(
@@ -139,7 +138,6 @@ def BPHY5Kernel(flags, Decays="BsB+BdKstBpipiX"):
          ExcludeCrossJpsiTracks  = False,   #setting this to False rejects the muons from J/psi candidate
          TrkVertexFitterTool     = vkalvrt,
          TrackSelectorTool     = trackselect,
-         VertexPointEstimator        = vpest,
          UseMassConstraint     = True,
          Chi2Cut                 = 15.0,
          TrkQuadrupletMassLower  = 3500.0,
@@ -160,7 +158,6 @@ def BPHY5Kernel(flags, Decays="BsB+BdKstBpipiX"):
          JpsiContainerKey        = JpsiContainerName,
          TrackParticleCollection         = mainIDInput,
          MuonsUsedInJpsi         = mainMuonInput,
-         VertexPointEstimator        = vpest,
          TrkVertexFitterTool     = vkalvrt,
          TrackSelectorTool       = trackselect,
          UseMassConstraint       = True,
@@ -183,7 +180,6 @@ def BPHY5Kernel(flags, Decays="BsB+BdKstBpipiX"):
          JpsiContainerKey            = JpsiContainerName,
          TrackParticleCollection     = mainIDInput,
          MuonsUsedInJpsi             = mainMuonInput,
-         VertexPointEstimator        = vpest,
          TrkVertexFitterTool     = vkalvrt,
          TrackSelectorTool       = trackselect,
          UseMassConstraint       = True,
diff --git a/PhysicsAnalysis/JpsiUpsilonTools/JpsiUpsilonTools/JpsiPlus1Track.h b/PhysicsAnalysis/JpsiUpsilonTools/JpsiUpsilonTools/JpsiPlus1Track.h
index ea9efb857dcd..5b37f2f468c9 100644
--- a/PhysicsAnalysis/JpsiUpsilonTools/JpsiUpsilonTools/JpsiPlus1Track.h
+++ b/PhysicsAnalysis/JpsiUpsilonTools/JpsiUpsilonTools/JpsiPlus1Track.h
@@ -73,7 +73,6 @@ namespace Analysis {
         bool m_excludeCrossJpsiTracks; //Added by Matteo Bedognetti
         ToolHandle < Trk::IVertexFitter > m_iVertexFitter;
         ToolHandle < Trk::ITrackSelectorTool > m_trkSelector;
-        ToolHandle < InDet::VertexPointEstimator > m_vertexEstimator;
         Trk::TrkVKalVrtFitter* m_VKVFitter;
         bool m_useMassConst;
         double m_altMassConst;
diff --git a/PhysicsAnalysis/JpsiUpsilonTools/JpsiUpsilonTools/JpsiPlus2Tracks.h b/PhysicsAnalysis/JpsiUpsilonTools/JpsiUpsilonTools/JpsiPlus2Tracks.h
index 5cf513e40b92..1c85c17bb291 100644
--- a/PhysicsAnalysis/JpsiUpsilonTools/JpsiUpsilonTools/JpsiPlus2Tracks.h
+++ b/PhysicsAnalysis/JpsiUpsilonTools/JpsiUpsilonTools/JpsiPlus2Tracks.h
@@ -85,7 +85,6 @@ namespace Analysis {
         bool m_excludeCrossJpsiTracks; //Added by Matteo Bedognetti
         ToolHandle < Trk::IVertexFitter > m_iVertexFitter;
         ToolHandle < Trk::ITrackSelectorTool > m_trkSelector;
-        ToolHandle < InDet::VertexPointEstimator > m_vertexEstimator;
         Trk::TrkVKalVrtFitter* m_VKVFitter;
         bool m_useMassConst;
         double m_altMassConst;
diff --git a/PhysicsAnalysis/JpsiUpsilonTools/src/JpsiPlus1Track.cxx b/PhysicsAnalysis/JpsiUpsilonTools/src/JpsiPlus1Track.cxx
index cefc80ebf008..c920a90b86ff 100644
--- a/PhysicsAnalysis/JpsiUpsilonTools/src/JpsiPlus1Track.cxx
+++ b/PhysicsAnalysis/JpsiUpsilonTools/src/JpsiPlus1Track.cxx
@@ -43,7 +43,6 @@ namespace Analysis {
         ATH_CHECK( m_trkSelector.retrieve());
         
         // Get the vertex point estimator tool from ToolSvc
-        ATH_CHECK(m_vertexEstimator.retrieve());
         ATH_CHECK(m_jpsiCollectionKey.initialize());
         ATH_CHECK(m_TrkParticleCollection.initialize());
         if(m_MuonsUsedInJpsi.key() == "NONE") m_MuonsUsedInJpsi = "";//for backwards compatability
@@ -86,7 +85,6 @@ namespace Analysis {
     m_excludeCrossJpsiTracks(false),
     m_iVertexFitter("Trk::TrkVKalVrtFitter"),
     m_trkSelector("InDet::TrackSelectorTool"),
-    m_vertexEstimator("InDet::VertexPointEstimator"),
     m_useMassConst(true),
     m_altMassConst(-1.0),
     m_chi2cut(-1.0),
@@ -116,7 +114,6 @@ namespace Analysis {
         declareProperty("TrackSelectorTool", m_trkSelector);
         declareProperty("UseMassConstraint", m_useMassConst);
         declareProperty("AlternativeMassConstraint",m_altMassConst);
-        declareProperty("VertexPointEstimator", m_vertexEstimator);
 
         // additional cuts by Daniel Scheirich copied from 2Tracks by Adam Barton
         declareProperty("Chi2Cut",m_chi2cut);
@@ -439,13 +436,11 @@ namespace Analysis {
         }
         
         // Do the fit itself.......
-        // Starting point (use the J/psi position)
-        const Trk::Perigee& aPerigee1 = inputTracks[0]->perigeeParameters();
-        const Trk::Perigee& aPerigee2 = inputTracks[1]->perigeeParameters();
-        int sflag = 0;
-        int errorcode = 0;
-        Amg::Vector3D startingPoint = m_vertexEstimator->getCirclesIntersectionPoint(&aPerigee1,&aPerigee2,sflag,errorcode);
-        if (errorcode != 0) {startingPoint(0) = 0.0; startingPoint(1) = 0.0; startingPoint(2) = 0.0;}
+        Amg::Vector3D startingPoint(0,0,0);
+        StatusCode sc=m_VKVFitter->VKalVrtFitFast(inputTracks, startingPoint, state);
+        if(sc.isFailure()){
+            startingPoint = Amg::Vector3D(0,0,0);
+        }
         xAOD::Vertex* theResult = m_VKVFitter->fit(inputTracks, startingPoint, *state);
 
         // Added by ASC
diff --git a/PhysicsAnalysis/JpsiUpsilonTools/src/JpsiPlus2Tracks.cxx b/PhysicsAnalysis/JpsiUpsilonTools/src/JpsiPlus2Tracks.cxx
index dc15d54659f7..56e94dad2fb4 100644
--- a/PhysicsAnalysis/JpsiUpsilonTools/src/JpsiPlus2Tracks.cxx
+++ b/PhysicsAnalysis/JpsiUpsilonTools/src/JpsiPlus2Tracks.cxx
@@ -40,8 +40,6 @@ namespace Analysis {
         // Get the track selector tool from ToolSvc
         ATH_CHECK(m_trkSelector.retrieve());
 
-        // Get the vertex point estimator tool from ToolSvc
-        ATH_CHECK(m_vertexEstimator.retrieve());
 
         ATH_CHECK(m_jpsiCollectionKey.initialize());
         ATH_CHECK(m_TrkParticleCollection.initialize());
@@ -107,7 +105,6 @@ namespace Analysis {
     m_excludeCrossJpsiTracks(false),
     m_iVertexFitter("Trk::TrkVKalVrtFitter"),
     m_trkSelector("InDet::TrackSelectorTool"),
-    m_vertexEstimator("InDet::VertexPointEstimator"),
     m_useMassConst(true),
     m_altMassConst(-1.0),
     m_diTrackMassUpper(-1.0),
@@ -148,7 +145,6 @@ namespace Analysis {
         declareProperty("AlternativeMassConstraint",m_altMassConst);
         declareProperty("DiTrackMassUpper",m_diTrackMassUpper);
         declareProperty("DiTrackMassLower",m_diTrackMassLower);
-        declareProperty("VertexPointEstimator", m_vertexEstimator);
         // additional cuts by Daniel Scheirich
         declareProperty("Chi2Cut",m_chi2cut);
         declareProperty("DiTrackPt",m_diTrackPt);
@@ -452,12 +448,11 @@ namespace Analysis {
 
         // Do the fit itself.......
         // Starting point (use the J/psi position)
-        const Trk::Perigee& aPerigee1 = inputTracks[0]->perigeeParameters();
-        const Trk::Perigee& aPerigee2 = inputTracks[1]->perigeeParameters();
-        int sflag = 0;
-        int errorcode = 0;
-        Amg::Vector3D startingPoint = m_vertexEstimator->getCirclesIntersectionPoint(&aPerigee1,&aPerigee2,sflag,errorcode);
-        if (errorcode != 0) {startingPoint(0) = 0.0; startingPoint(1) = 0.0; startingPoint(2) = 0.0;}
+        Amg::Vector3D startingPoint(0,0,0);
+        StatusCode sc=m_VKVFitter->VKalVrtFitFast(inputTracks, startingPoint, state);
+        if(sc.isFailure()){
+            startingPoint = Amg::Vector3D(0,0,0);
+        }
         xAOD::Vertex* theResult = m_VKVFitter->fit(inputTracks, startingPoint, *state);
 
         // Added by ASC
-- 
GitLab


From 558803841b4981d7496e5b9b5fbc7c4298f8e28d Mon Sep 17 00:00:00 2001
From: abarton <Adam.Edward.Barton@cern.ch>
Date: Tue, 24 Oct 2023 13:41:30 +0100
Subject: [PATCH 2/2] fix

---
 PhysicsAnalysis/JpsiUpsilonTools/src/JpsiPlus1Track.cxx  | 2 +-
 PhysicsAnalysis/JpsiUpsilonTools/src/JpsiPlus2Tracks.cxx | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/PhysicsAnalysis/JpsiUpsilonTools/src/JpsiPlus1Track.cxx b/PhysicsAnalysis/JpsiUpsilonTools/src/JpsiPlus1Track.cxx
index c920a90b86ff..990e66c6a487 100644
--- a/PhysicsAnalysis/JpsiUpsilonTools/src/JpsiPlus1Track.cxx
+++ b/PhysicsAnalysis/JpsiUpsilonTools/src/JpsiPlus1Track.cxx
@@ -437,7 +437,7 @@ namespace Analysis {
         
         // Do the fit itself.......
         Amg::Vector3D startingPoint(0,0,0);
-        StatusCode sc=m_VKVFitter->VKalVrtFitFast(inputTracks, startingPoint, state);
+        StatusCode sc=m_VKVFitter->VKalVrtFitFast(inputTracks, startingPoint, *state);
         if(sc.isFailure()){
             startingPoint = Amg::Vector3D(0,0,0);
         }
diff --git a/PhysicsAnalysis/JpsiUpsilonTools/src/JpsiPlus2Tracks.cxx b/PhysicsAnalysis/JpsiUpsilonTools/src/JpsiPlus2Tracks.cxx
index 56e94dad2fb4..d8a5009b06e2 100644
--- a/PhysicsAnalysis/JpsiUpsilonTools/src/JpsiPlus2Tracks.cxx
+++ b/PhysicsAnalysis/JpsiUpsilonTools/src/JpsiPlus2Tracks.cxx
@@ -449,7 +449,7 @@ namespace Analysis {
         // Do the fit itself.......
         // Starting point (use the J/psi position)
         Amg::Vector3D startingPoint(0,0,0);
-        StatusCode sc=m_VKVFitter->VKalVrtFitFast(inputTracks, startingPoint, state);
+        StatusCode sc=m_VKVFitter->VKalVrtFitFast(inputTracks, startingPoint, *state);
         if(sc.isFailure()){
             startingPoint = Amg::Vector3D(0,0,0);
         }
-- 
GitLab