From c55e9169bf2e6ef493901edd614eb70b3c2a70d8 Mon Sep 17 00:00:00 2001
From: John Baines <john.baines@stfc.ac.uk>
Date: Thu, 22 Apr 2021 16:57:24 +0000
Subject: [PATCH] Add muon LRT physics chains with EF step

---
 .../python/TrigMuonHypoMTConfig.py            | 29 +++++-------------
 .../TrigMuonHypoMT/src/TrigMuonEFHypoTool.cxx | 24 ++++++++++++---
 .../TrigMuonHypoMT/src/TrigMuonEFHypoTool.h   |  3 ++
 .../share/ref_RDOtoRDOTrig_v1Dev_build.ref    | 30 +++++++++++++++++++
 .../share/ref_data_v1Dev_build.ref            | 18 +++++++++++
 .../TrigEDMConfig/python/TriggerEDMRun3.py    |  3 ++
 .../python/HLTMenuConfig/Menu/LS2_v1.py       |  3 ++
 .../HLTMenuConfig/Muon/MuonMenuSequences.py   |  4 +--
 .../HLTMenuConfig/Muon/MuonRecoSequences.py   |  7 ++++-
 9 files changed, 93 insertions(+), 28 deletions(-)

diff --git a/Trigger/TrigHypothesis/TrigMuonHypoMT/python/TrigMuonHypoMTConfig.py b/Trigger/TrigHypothesis/TrigMuonHypoMT/python/TrigMuonHypoMTConfig.py
index c725fa2dbc16..c5b651f1c3d2 100755
--- a/Trigger/TrigHypothesis/TrigMuonHypoMT/python/TrigMuonHypoMTConfig.py
+++ b/Trigger/TrigHypothesis/TrigMuonHypoMT/python/TrigMuonHypoMTConfig.py
@@ -397,27 +397,6 @@ def TrigmuCombHypoToolFromDict( chainDict ):
 
     tool=config.ConfigurationHypoTool( chainDict['chainName'], thresholds, tight, acceptAll )
 
-    addMonitoring( tool, TrigmuCombHypoMonitoring, "TrigmuCombHypoTool", chainDict['chainName'] )
-
-    return tool
-
-def TrigmuCombLrtHypoToolFromDict( chainDict ):
-
-    if 'idperf' in chainDict['chainParts'][0]['addInfo']:
-       thresholds = ['passthrough']
-    else:
-       thresholds = getThresholdsFromDict( chainDict )
-
-    config = TrigmuCombHypoConfig()
-
-    tight = False # can be probably decoded from some of the proprties of the chain, expert work
-
-    acceptAll = False
-    if chainDict['chainParts'][0]['signature'] == 'Bphysics':
-        acceptAll = True
-
-    tool=config.ConfigurationHypoTool( chainDict['chainName'], thresholds, tight, acceptAll )
-
     d0cut=0.
     if 'd0loose' in chainDict['chainParts'][0]['lrtInfo']:
         d0cut=trigMuonLrtd0Cut['d0loose']
@@ -651,6 +630,14 @@ def TrigMuonEFCombinerHypoToolFromDict( chainDict ) :
 
     config = TrigMuonEFCombinerHypoConfig()
     tool = config.ConfigurationHypoTool( chainDict['chainName'], thresholds , muonquality, narrowscan)
+    d0cut=0.
+    if 'd0loose' in chainDict['chainParts'][0]['lrtInfo']:
+        d0cut=trigMuonLrtd0Cut['d0loose']
+    elif 'd0medium' in chainDict['chainParts'][0]['lrtInfo']:
+        d0cut=trigMuonLrtd0Cut['d0medium']
+    elif 'd0tight' in chainDict['chainParts'][0]['lrtInfo']:
+        d0cut=trigMuonLrtd0Cut['d0tight']
+    tool.MinimumD0=d0cut  
     addMonitoring( tool, TrigMuonEFHypoMonitoring, "TrigMuonEFCombinerHypoTool", chainDict['chainName'] )
     return tool
 
diff --git a/Trigger/TrigHypothesis/TrigMuonHypoMT/src/TrigMuonEFHypoTool.cxx b/Trigger/TrigHypothesis/TrigMuonHypoMT/src/TrigMuonEFHypoTool.cxx
index 675f9bcb7dd2..578997f8a4aa 100644
--- a/Trigger/TrigHypothesis/TrigMuonHypoMT/src/TrigMuonEFHypoTool.cxx
+++ b/Trigger/TrigHypothesis/TrigMuonHypoMT/src/TrigMuonEFHypoTool.cxx
@@ -44,6 +44,9 @@ StatusCode TrigMuonEFHypoTool::initialize(){
       }
     }
   }
+  // minimum d0 cut for displaced muon triggers
+  if (m_d0min>0.) ATH_MSG_DEBUG( " Rejecting muons with abs(d0) < "<<m_d0min<<" mm");
+  
   if ( not m_monTool.name().empty() ) {
     ATH_CHECK( m_monTool.retrieve() );
     ATH_MSG_DEBUG("MonTool name: " << m_monTool);
@@ -112,16 +115,29 @@ bool TrigMuonEFHypoTool::decideOnSingleObject(TrigMuonEFHypoTool::MuonEFInfo& in
 	    result=false;
 	  }
 	}
+	if (m_d0min>0.) {
+	  ATH_MSG_DEBUG("Muon has d0 less than "<<m_d0min<<"mm; not passing hypo");
+	  if (std::abs(tr->d0())<m_d0min) result = false;
+	}
       }
       if(result == true){
         selPt.push_back(tr->pt()/Gaudi::Units::GeV);
         selEta.push_back(tr->eta());
         selPhi.push_back(tr->phi());
       }
-      ATH_MSG_DEBUG(" REGTEST muon pt is " << tr->pt()/Gaudi::Units::GeV << " GeV "
-      	      << " with Charge " << tr->charge()
-      	      << " and threshold cut is " << threshold/Gaudi::Units::GeV << " GeV"
-      	      << " so hypothesis is " << (result?"true":"false"));
+      if (m_d0min>0.) {
+	ATH_MSG_DEBUG(" REGTEST muon pt is " << tr->pt()/Gaudi::Units::GeV << " GeV "
+		      << " with Charge " << tr->charge()
+		      << " and threshold cut is " << threshold/Gaudi::Units::GeV << " GeV"
+		      << " so hypothesis is " << (result?"true":"false"));
+      } else {
+	ATH_MSG_DEBUG(" REGTEST muon pt is " << tr->pt()/Gaudi::Units::GeV << " GeV "
+		      << " with Charge " << tr->charge()
+		      << " and with d0 " << tr->d0()
+		      << " the threshold cut is " << threshold/Gaudi::Units::GeV << " GeV"
+		      << " and d0min cut is " << m_d0min<<" mm"
+		      << " so hypothesis is " << (result?"true":"false"));
+      }
     }
   }
   return result;	
diff --git a/Trigger/TrigHypothesis/TrigMuonHypoMT/src/TrigMuonEFHypoTool.h b/Trigger/TrigHypothesis/TrigMuonHypoMT/src/TrigMuonEFHypoTool.h
index 9abe2d4f0adb..7d6348ad782a 100644
--- a/Trigger/TrigHypothesis/TrigMuonHypoMT/src/TrigMuonEFHypoTool.h
+++ b/Trigger/TrigHypothesis/TrigMuonHypoMT/src/TrigMuonEFHypoTool.h
@@ -63,6 +63,9 @@ class TrigMuonEFHypoTool: public ::AthAlgTool {
     this, "RequireThreeStations", false, "Apply cut on N GoodPrecisionLayers in endcaps"};
   Gaudi::Property<bool> m_doSA{
     this, "RequireSAMuons", false, "Apply cut on SA muons (otherwise require combined muons)"};
+   Gaudi::Property< float > m_d0min {
+        this, "MinimumD0", 0., "lower d0 cut (mm)"};
+
   // Other members:   
   std::vector<size_t> m_bins={0};
   ToolHandle< GenericMonitoringTool > m_monTool { this, "MonTool", "", "Monitoring tool" };
diff --git a/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_v1Dev_build.ref b/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_v1Dev_build.ref
index 036c3e221b47..ccf88fd69305 100644
--- a/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_v1Dev_build.ref
+++ b/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_v1Dev_build.ref
@@ -4213,6 +4213,36 @@ HLT_mu24_L1MU20:
     1: 7
     2: 6
     3: 6
+HLT_mu24_LRT_d0loose_L1MU20:
+  eventCount: 0
+  stepCounts:
+    0: 8
+    1: 1
+    2: 1
+  stepFeatures:
+    0: 10
+    1: 1
+    2: 1
+HLT_mu24_LRT_d0medium_L1MU20:
+  eventCount: 0
+  stepCounts:
+    0: 8
+    1: 1
+    2: 1
+  stepFeatures:
+    0: 10
+    1: 1
+    2: 1
+HLT_mu24_LRT_d0tight_L1MU20:
+  eventCount: 0
+  stepCounts:
+    0: 8
+    1: 1
+    2: 1
+  stepFeatures:
+    0: 10
+    1: 1
+    2: 1
 HLT_mu24_LRT_l2lrt_d0loose_L1MU20:
   eventCount: 1
   stepCounts:
diff --git a/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref b/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref
index 7e37c3546bb4..5b418e251dda 100644
--- a/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref
+++ b/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref
@@ -2563,6 +2563,24 @@ HLT_mu24_L1MU20:
   stepFeatures:
     0: 1
     1: 1
+HLT_mu24_LRT_d0loose_L1MU20:
+  eventCount: 0
+  stepCounts:
+    0: 1
+  stepFeatures:
+    0: 1
+HLT_mu24_LRT_d0medium_L1MU20:
+  eventCount: 0
+  stepCounts:
+    0: 1
+  stepFeatures:
+    0: 1
+HLT_mu24_LRT_d0tight_L1MU20:
+  eventCount: 0
+  stepCounts:
+    0: 1
+  stepFeatures:
+    0: 1
 HLT_mu24_LRT_l2lrt_d0loose_L1MU20:
   eventCount: 0
   stepCounts:
diff --git a/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun3.py b/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun3.py
index d808aabac127..80d75217de41 100644
--- a/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun3.py
+++ b/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun3.py
@@ -330,6 +330,9 @@ TriggerHLTListRun3 = [
     ('xAOD::L2CombinedMuonContainer#HLT_MuonL2CBInfo',          'BS ESD AODFULL', 'Muon', 'inViews:MUCombViewRoIs'),
     ('xAOD::L2CombinedMuonAuxContainer#HLT_MuonL2CBInfoAux.',   'BS ESD AODFULL', 'Muon'),
 
+    ('xAOD::L2CombinedMuonContainer#HLT_MuonL2CBInfoLRT',          'BS ESD AODFULL', 'Muon', 'inViews:MUCombLRTViewRoIs'),
+    ('xAOD::L2CombinedMuonAuxContainer#HLT_MuonL2CBInfoLRTAux.',   'BS ESD AODFULL', 'Muon'),
+
     ('xAOD::L2CombinedMuonContainer#HLT_MuonL2CBInfoIOmode',          'BS ESD AODFULL', 'Muon', 'inViews:MUCombViewRoIs'),
     ('xAOD::L2CombinedMuonAuxContainer#HLT_MuonL2CBInfoIOmodeAux.',   'BS ESD AODFULL', 'Muon'),
 
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py
index cd569758f26b..05922dfdf76c 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py
@@ -46,6 +46,9 @@ def setupMenu():
         ChainProp(name='HLT_mu24_LRT_l2lrt_d0loose_L1MU20',     groups=SingleMuonGroup),
         ChainProp(name='HLT_mu24_LRT_l2lrt_d0medium_L1MU20',     groups=SingleMuonGroup),
         ChainProp(name='HLT_mu24_LRT_l2lrt_d0tight_L1MU20',     groups=SingleMuonGroup),
+        ChainProp(name='HLT_mu24_LRT_d0loose_L1MU20',     groups=SingleMuonGroup),
+        ChainProp(name='HLT_mu24_LRT_d0medium_L1MU20',     groups=SingleMuonGroup),
+        ChainProp(name='HLT_mu24_LRT_d0tight_L1MU20',     groups=SingleMuonGroup),
 
         ChainProp(name='HLT_mu6_ivarmedium_L1MU6', groups=SingleMuonGroup),
 
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonMenuSequences.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonMenuSequences.py
index 6bb739644acd..7496cf3fb747 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonMenuSequences.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonMenuSequences.py
@@ -293,12 +293,12 @@ def muCombLRTSequence():
     trigmuCombHypo = TrigmuCombHypoAlg("TrigL2MuCBHypoAlg_LRT")
     trigmuCombHypo.MuonL2CBInfoFromMuCombAlg = sequenceOut
 
-    from TrigMuonHypoMT.TrigMuonHypoMTConfig import TrigmuCombLrtHypoToolFromDict
+    from TrigMuonHypoMT.TrigMuonHypoMTConfig import TrigmuCombHypoToolFromDict
 
     return MenuSequence( Sequence    = l2muCombLRTSequence,
                          Maker       = l2muCombLRTViewsMaker,
                          Hypo        = trigmuCombHypo,
-                         HypoToolGen = TrigmuCombLrtHypoToolFromDict )
+                         HypoToolGen = TrigmuCombHypoToolFromDict )
   
 
 def muCombOvlpRmSequence():
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonRecoSequences.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonRecoSequences.py
index 059105ecdd06..4e767dc44f2f 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonRecoSequences.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonRecoSequences.py
@@ -53,6 +53,7 @@ class muonNames(object):
       self.EFSAName = recordable("HLT_Muons_RoI")
       self.EFCBName = recordable("HLT_MuonsCB_RoI")
     if "LRT" in name:
+      self.L2CBName = recordable("HLT_MuonL2CBInfoLRT")
       self.EFSAName = recordable("HLT_Muons_RoI")
       self.EFCBName = recordable("HLT_MuonsCB_LRT")
     return self
@@ -596,7 +597,11 @@ def muCombRecoSequence( RoIs, name, l2mtmode=False ):
   from TrigmuComb.TrigmuCombMTConfig import TrigmuCombMTConfig
   muCombAlg = TrigmuCombMTConfig("Muon"+postFix,name)
   muCombAlg.L2StandAloneMuonContainerName = muNames.L2SAName+postFix
-  muCombAlg.L2CombinedMuonContainerName   = muNames.L2CBName+postFix
+  if ('LRT' in name):
+    muCombAlg.L2CombinedMuonContainerName   = muNamesLRT.L2CBName
+  else:
+    muCombAlg.L2CombinedMuonContainerName   = muNames.L2CBName+postFix
+    
   if l2mtmode:
     muCombAlg.TrackParticlesContainerName   = getIDTracks()
   else:
-- 
GitLab