From 021e0b4db097b9d4676e20b4d3c4065a60559545 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 15 May 2023 16:19:09 +0100
Subject: [PATCH] Pass the minimum monentum cut to tracking algorithms. Used by
 ref. idex calibration to avoid creating and fitting tracks never actually
 used by the RICH calibration.

---
 Rich/Panoptes/options/RichRefIndexCalib-Online.py | 13 ++++++++++++-
 Rich/Panoptes/options/RichRefIndexCalib.py        | 13 +++++++++++--
 Rich/Panoptes/python/Panoptes/calibration.py      |  3 ++-
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/Rich/Panoptes/options/RichRefIndexCalib-Online.py b/Rich/Panoptes/options/RichRefIndexCalib-Online.py
index 2a1c06a2c..f95e0ce36 100755
--- a/Rich/Panoptes/options/RichRefIndexCalib-Online.py
+++ b/Rich/Panoptes/options/RichRefIndexCalib-Online.py
@@ -29,6 +29,8 @@ from Configurables import Online__AlgFlowManager as AlgFlowManager
 from Configurables import HLTControlFlowMgr, ExecutionReportsWriter
 from Configurables import LHCb__Det__LbDD4hep__DD4hepSvc as DD4hepSvc
 
+from GaudiKernel.SystemOfUnits import GeV
+
 from Moore import options, run_reconstruction
 
 LHCbApp().DataType = "Upgrade"
@@ -68,12 +70,20 @@ noUT = True
 
 from PyConf.Tools import TrackMasterFitter, Rich__Future__Rec__Calib__RefIndexCalibWriter as RefIndexCalibWriter
 from PyConf.Algorithms import Rich__Future__Rec__Calib__RefIndexCalib as RefIndexCalib
+from PyConf.Algorithms import PrMatchNN, PrForwardTrackingVelo, PrHybridSeeding
 from Panoptes.calibration import standalone_rich_ref_index_calib
 if noUT:
     from RecoConf.hlt2_tracking import make_hlt2_tracks_without_UT as track_maker
 else:
     from RecoConf.hlt2_tracking import make_hlt2_tracks as track_maker
 
+# Min Momentum cuts by radiator
+rad_min_p = (10 * GeV, 10 * GeV, 20 * GeV)
+min_p = min(rad_min_p)
+PrForwardTrackingVelo.global_bind(MinP=min_p)
+PrMatchNN.global_bind(MinP=min_p)
+PrHybridSeeding.global_bind(MinP=min_p)
+
 # PDF Writer options
 ckFitForm = ["AsymNormal:FreeNPol"]
 mywriter = RefIndexCalibWriter(
@@ -84,7 +94,8 @@ mywriter = RefIndexCalibWriter(
 
 with track_maker.bind(use_pr_kf=True, light_reco=True, fast_reco=True),\
      RefIndexCalib.bind(CalibWriter=mywriter),\
-     standalone_rich_ref_index_calib.bind(noUT=noUT,do_data_monitoring=False,\
+     standalone_rich_ref_index_calib.bind(noUT=noUT,min_p=rad_min_p,\
+                                          do_data_monitoring=False,\
                                           set_scale_factors_to_one=False) :
     run_reconstruction(options, standalone_rich_ref_index_calib)
 
diff --git a/Rich/Panoptes/options/RichRefIndexCalib.py b/Rich/Panoptes/options/RichRefIndexCalib.py
index 1a8653dd9..afab5e3fc 100644
--- a/Rich/Panoptes/options/RichRefIndexCalib.py
+++ b/Rich/Panoptes/options/RichRefIndexCalib.py
@@ -14,9 +14,10 @@ from Moore import options, run_reconstruction
 from Panoptes.calibration import standalone_rich_ref_index_calib
 from PyConf.Tools import TrackMasterFitter, Rich__Future__Rec__Calib__RefIndexCalibWriter as RefIndexCalibWriter
 from PyConf.Algorithms import Rich__Future__Rec__Calib__RefIndexCalib as RefIndexCalib
+from PyConf.Algorithms import PrMatchNN, PrForwardTrackingVelo, PrHybridSeeding
 from ROOT import gROOT
-
 from Gaudi.Configuration import DEBUG, INFO
+from GaudiKernel.SystemOfUnits import GeV
 
 options.output_level = INFO
 
@@ -64,6 +65,13 @@ run_by_run_histos = False
 # start scale factors at 1 ?
 set_scale_to_one = False
 
+# Min Momentum cuts by radiator
+rad_min_p = (10 * GeV, 10 * GeV, 20 * GeV)
+min_p = min(rad_min_p)
+PrForwardTrackingVelo.global_bind(MinP=min_p)
+PrMatchNN.global_bind(MinP=min_p)
+PrHybridSeeding.global_bind(MinP=min_p)
+
 if noUT:
     from RecoConf.hlt2_tracking import make_hlt2_tracks_without_UT as track_maker
 else:
@@ -72,6 +80,7 @@ else:
 with track_maker.bind(use_pr_kf=True, light_reco=True, fast_reco=True),\
      RefIndexCalib.bind(CalibWriter=mywriter,MinTimeBetweenCalibs=calibTime,\
                         RunByRunHists=run_by_run_histos),\
-     standalone_rich_ref_index_calib.bind(noUT=noUT,do_data_monitoring=do_moni,\
+     standalone_rich_ref_index_calib.bind(noUT=noUT,min_p=rad_min_p,\
+                                          do_data_monitoring=do_moni,\
                                           set_scale_factors_to_one=set_scale_to_one) :
     run_reconstruction(options, standalone_rich_ref_index_calib)
diff --git a/Rich/Panoptes/python/Panoptes/calibration.py b/Rich/Panoptes/python/Panoptes/calibration.py
index ee19eb22c..41f74141c 100644
--- a/Rich/Panoptes/python/Panoptes/calibration.py
+++ b/Rich/Panoptes/python/Panoptes/calibration.py
@@ -34,6 +34,7 @@ from GaudiKernel.SystemOfUnits import GeV
 
 @configurable
 def standalone_rich_ref_index_calib(noUT=False,
+                                    min_p=(10 * GeV, 10 * GeV, 20 * GeV),
                                     do_data_monitoring=False,
                                     set_scale_factors_to_one=False):
     """
@@ -63,7 +64,7 @@ def standalone_rich_ref_index_calib(noUT=False,
     reco_opts["PhotonSelection"] = "Online"
 
     # Tweak the momentum cuts used for the ref index calib
-    reco_opts["MinP"] = (0 * GeV, 10 * GeV, 20 * GeV)
+    reco_opts["MinP"] = min_p
 
     # As we aren't running PID, we do not need all hypos
     #reco_opts["Particles"] = ["muon","pion","kaon"]
-- 
GitLab