From 14ef716ac24b95b59b1d8d4d24da32356844c989 Mon Sep 17 00:00:00 2001
From: Vladimir Lyubushkin <Vladimir.Lyubushkin@cern.ch>
Date: Mon, 4 Oct 2021 15:48:28 +0200
Subject: [PATCH 1/4] initial commit

---
 .../python/TrigMultiTrkComboHypoConfig.py      | 11 ++++++++---
 .../src/TrigMultiTrkComboHypo.cxx              | 18 ++++++------------
 .../TrigBphysHypo/src/TrigMultiTrkComboHypo.h  |  2 +-
 .../Bphysics/BphysicsChainConfiguration.py     |  1 +
 .../python/HLTMenuConfig/Menu/LS2_v1.py        |  3 +++
 .../HLTMenuConfig/Menu/SignatureDicts.py       |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/Trigger/TrigHypothesis/TrigBphysHypo/python/TrigMultiTrkComboHypoConfig.py b/Trigger/TrigHypothesis/TrigBphysHypo/python/TrigMultiTrkComboHypoConfig.py
index 2d9e01ea32a3..49702a4a3125 100644
--- a/Trigger/TrigHypothesis/TrigBphysHypo/python/TrigMultiTrkComboHypoConfig.py
+++ b/Trigger/TrigHypothesis/TrigBphysHypo/python/TrigMultiTrkComboHypoConfig.py
@@ -18,6 +18,7 @@ trigMultiTrkComboHypoToolDict = {
     'bBmumu'     : { 'massRange' : (4000.,  8500.), 'chi2' : 20. },
     'bPhi'       : { 'massRange' : ( 940.,  1100.), 'chi2' : 10. },
     'bTau'       : { 'massRange' : (   0.,  2700.), 'chi2' : 50. },
+    'b3mu'       : { 'massRange' : ( 100., 10000.), 'chi2' : 30., 'nTrk' : 3, 'charge' : 1 },
     'bBeeM6000'  : { 'massRange' : ( 100.,  6000.), 'chi2' : 20. },
 }
 
@@ -63,6 +64,7 @@ def StreamerDimuEFComboHypoCfg(name):
         trigSequenceName = 'StreamerDimu',
         trigLevel = 'EF')
     hypo.chi2 = 20.
+    hypo.nTracks = [ 2 ]
     hypo.massRange = [ (100., 6000.) ]
     return hypo
 
@@ -126,6 +128,7 @@ def BmutrkComboHypoCfg(name):
         outputTrigBphysCollection = 'HLT_Bmutrk')
     hypo.isMuTrkMode = True
     hypo.chi2 = 20.
+    hypo.nTracks = [ 2 ]
     hypo.massRange = [ (2500., 4400.) ]
     hypo.trackPtThresholds = [ [ 10000., 3000. ] ]
     return hypo
@@ -184,8 +187,9 @@ class TrigMultiTrkComboHypoConfig(object):
             name = baseName+'ComboHypo',
             isStreamer = isStreamer,
             trigLevel = trigLevel,
-            nTracks = [ 2 ],
-            massRange = [ (100., 20000.) ],
+            nTracks = [ 2, 3 ],
+            massRange = [ (100., 20000.), (100., 11000.) ],
+            trackPtThresholds = [ [ 3650., 3650. ], [ 3650., 3650., 3650. ] ],
             TrackCollectionKey = trackCollection,
             TrigBphysCollectionKey = outputTrigBphysCollection,
             VertexFitter = VertexFitter,
@@ -204,7 +208,8 @@ class TrigMultiTrkComboHypoConfig(object):
             value = trigMultiTrkComboHypoToolDict[topo]
             tool.massRange = value['massRange']
             tool.chi2 = value['chi2']
-            tool.totalCharge = 0
+            tool.nTrk = value['nTrk'] if 'nTrk' in value else 2
+            tool.totalCharge = value['charge'] if 'charge' in value else 0
         except LookupError:
             raise Exception('TrigMultiTrkComboHypo misconfigured for \'%s\': topo \'%s\' is not supported.', chainDict['chainName'], topo)
 
diff --git a/Trigger/TrigHypothesis/TrigBphysHypo/src/TrigMultiTrkComboHypo.cxx b/Trigger/TrigHypothesis/TrigBphysHypo/src/TrigMultiTrkComboHypo.cxx
index 9293fe9c9e5d..57758bbdc174 100644
--- a/Trigger/TrigHypothesis/TrigBphysHypo/src/TrigMultiTrkComboHypo.cxx
+++ b/Trigger/TrigHypothesis/TrigBphysHypo/src/TrigMultiTrkComboHypo.cxx
@@ -492,7 +492,7 @@ StatusCode TrigMultiTrkComboHypo::filterTrackCombinations(TrigMultiTrkStateBase&
       auto mass = (std::accumulate(p.begin(), p.end(), xAOD::TrackParticle::GenVecFourMom_t())).M();
       ATH_MSG_DEBUG( "invariant mass: " << mass );
 
-      if (!isInMassRange(mass)) continue;
+      if (!isInMassRange(mass, iTrk)) continue;
 
       auto fitterState = m_vertexFitter->makeState(state.context());
       auto vertex = fit(tracklist, m_trkMass[iTrk], *fitterState);
@@ -610,7 +610,7 @@ StatusCode TrigMultiTrkComboHypo::findMultiLeptonCandidates(TrigMultiTrkState<T>
 
       mon_nCombination++;
       trkMassBeforeFit.push_back(mass * 0.001);
-      if (!isInMassRange(mass)) continue;
+      if (!isInMassRange(mass, iTrk)) continue;
 
       mon_nCombinationBeforeFit++;
       auto fitterState = m_vertexFitter->makeState(state.context());
@@ -740,7 +740,7 @@ StatusCode TrigMultiTrkComboHypo::findMuTrkCandidates(TrigMultiTrkState<xAOD::Mu
       if (track->pt() < m_trkPt[0][1] || isIdenticalTracks(track, muonInDetTrack)) continue;
       auto trackMomentum = track->genvecP4();
       trackMomentum.SetM(PDG::mMuon);
-      if (!isInMassRange((muonMomentum + trackMomentum).M())) continue;
+      if (!isInMassRange((muonMomentum + trackMomentum).M(), 0)) continue;
 
       tracklist[1] = ViewHelper::makeLink<xAOD::TrackParticleContainer>(view, tracksHandle, idx);
 
@@ -969,14 +969,8 @@ float TrigMultiTrkComboHypo::Lxy(const xAOD::TrigBphys& vertex, const Amg::Vecto
 }
 
 
-bool TrigMultiTrkComboHypo::isInMassRange(double mass) const {
+bool TrigMultiTrkComboHypo::isInMassRange(double mass, size_t idx) const {
 
-  bool result = false;
-  for (const auto& range : m_massRange) {
-    if (mass > range.first && mass < range.second) {
-      result = true;
-      break;
-    }
-  }
-  return result;
+  const auto& range = m_massRange[idx];
+  return (mass > range.first && mass < range.second);
 }
diff --git a/Trigger/TrigHypothesis/TrigBphysHypo/src/TrigMultiTrkComboHypo.h b/Trigger/TrigHypothesis/TrigBphysHypo/src/TrigMultiTrkComboHypo.h
index 8e3f6af88340..15512ef162d9 100644
--- a/Trigger/TrigHypothesis/TrigBphysHypo/src/TrigMultiTrkComboHypo.h
+++ b/Trigger/TrigHypothesis/TrigBphysHypo/src/TrigMultiTrkComboHypo.h
@@ -215,7 +215,7 @@ class TrigMultiTrkComboHypo: public ::ComboHypo {
   bool isIdenticalTracks(const xAOD::TrackParticle* lhs, const xAOD::TrackParticle* rhs) const;
   bool isIdenticalTracks(const xAOD::Muon* lhs, const xAOD::Muon* rhs) const;
   bool isIdenticalTracks(const xAOD::Electron* lhs, const xAOD::Electron* rhs) const;
-  bool isInMassRange(double mass) const;
+  bool isInMassRange(double mass, size_t idx) const;
   float Lxy(const xAOD::TrigBphys& vertex, const Amg::Vector3D& beamSpot) const;
 
   SG::ReadHandleKey<xAOD::TrackParticleContainer>
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Bphysics/BphysicsChainConfiguration.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Bphysics/BphysicsChainConfiguration.py
index 7e10d8a504d8..4143fb33a814 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Bphysics/BphysicsChainConfiguration.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Bphysics/BphysicsChainConfiguration.py
@@ -86,6 +86,7 @@ class BphysicsChainConfiguration(MuonChainConfiguration):
             'bDimu6000'  : 'dimu',
             'bPhi'       : 'dimu',
             'bTau'       : 'dimu',
+            'b3mu'       : 'dimu',
             'bBmumux'    : 'bmumux'
         }
 
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py
index 24fa7bfbc0f5..9928288ea7ab 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py
@@ -989,6 +989,9 @@ def setupMenu():
         ChainProp(name='HLT_mu6_mu4_bJpsimumu_Lxy0_L1BPH-2M9-0DR15-C-MU5VFMU3V', l1SeedThresholds=['MU5VF','MU3V'], stream=["BphysDelayed"], groups=BphysicsGroup),
         ChainProp(name='HLT_mu6_mu4_bBmumu_Lxy0_L1BPH-2M9-0DR15-C-MU5VFMU3V', l1SeedThresholds=['MU5VF','MU3V'], stream=["BphysDelayed"], groups=BphysicsGroup),
 
+        # 3mu inv mass (ATR-19355, ATR-19638), TODO: HLT invm to be added and moved to BLS signature
+        ChainProp(name='HLT_3mu4_b3mu_noos_Lxy0_L1BPH-0M10-3MU3V', l1SeedThresholds=['MU3V'], stream=["BphysDelayed"], groups=BphysicsGroup),
+        ChainProp(name='HLT_3mu4_b3mu_L1BPH-0M10C-3MU3V', l1SeedThresholds=['MU3V'], stream=["BphysDelayed"], groups=BphysicsGroup),
     ]
 
     TriggerFlags.CombinedSlice.signatures = TriggerFlags.CombinedSlice.signatures() + [
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/SignatureDicts.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/SignatureDicts.py
index f7e26949bbce..02ea01597783 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/SignatureDicts.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/SignatureDicts.py
@@ -354,8 +354,8 @@ MuonChainParts_Default = {
 # Bphysics
 #==========================================================
 AllowedTopos_Bphysics = [
-    'bJpsimumu','bJpsi','bJpsimutrk','bUpsimumu','bUpsi','bBmumu','bDimu','bDimu2700','bDimu6000','bPhi','bTau',
-    'Lxy0',
+    'bJpsimumu','bJpsi','bJpsimutrk','bUpsimumu','bUpsi','bBmumu','bDimu','bDimu2700','bDimu6000','bPhi','bTau','b3mu',
+    'Lxy0','noos','nocut',
     'bBmumux','BpmumuKp','BcmumuPi','BsmumuPhi','BdmumuKst','LbPqKm', 'BcmumuDsloose', 'BcmumuDploose'
 ]
 
-- 
GitLab


From 48edf3ac3cf144347b58b63a26104ff4dfc8f8b2 Mon Sep 17 00:00:00 2001
From: Vladimir Lyubushkin <Vladimir.Lyubushkin@cern.ch>
Date: Tue, 5 Oct 2021 08:23:17 +0200
Subject: [PATCH 2/4] bug fix

---
 .../TrigBphysHypo/python/TrigMultiTrkComboHypoConfig.py         | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Trigger/TrigHypothesis/TrigBphysHypo/python/TrigMultiTrkComboHypoConfig.py b/Trigger/TrigHypothesis/TrigBphysHypo/python/TrigMultiTrkComboHypoConfig.py
index 92f72e5302fc..3890c3d0b543 100644
--- a/Trigger/TrigHypothesis/TrigBphysHypo/python/TrigMultiTrkComboHypoConfig.py
+++ b/Trigger/TrigHypothesis/TrigBphysHypo/python/TrigMultiTrkComboHypoConfig.py
@@ -67,6 +67,8 @@ def StreamerDimuEFComboHypoCfg(name):
     hypo.chi2 = 20.
     hypo.nTracks = [ 2 ]
     hypo.massRange = [ (100., 6000.) ]
+    hypo.trackPtThresholds = [ [ 100., 100. ] ]
+
     return hypo
 
 def StreamerDiElecFastComboHypoCfg(name):
-- 
GitLab


From c105c45f58c4902f871491ea2c8e6cafbc237132 Mon Sep 17 00:00:00 2001
From: Vladimir Lyubushkin <Vladimir.Lyubushkin@cern.ch>
Date: Tue, 5 Oct 2021 08:25:26 +0200
Subject: [PATCH 3/4] update ref

---
 .../TrigAnalysisTest/share/ref_RDOtoRDOTrig_v1Dev_build.ref   | 4 ++--
 .../TrigP1Test/share/ref_v1Dev_decodeBS_build.ref             | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_v1Dev_build.ref b/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_v1Dev_build.ref
index dd2d5b9501e7..371b5ef82833 100644
--- a/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_v1Dev_build.ref
+++ b/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_v1Dev_build.ref
@@ -1082,9 +1082,9 @@ HLT_3j65_0eta290_020jvt_pf_ftf_bdl1r85_L1J45p0ETA21_3J15p0ETA25:
     0: 12
     1: 20
     2: 7
-HLT_3mu4_L1BPH-0M10-3MU3V:
+HLT_3mu4_b3mu_L1BPH-0M10C-3MU3V:
   eventCount: 0
-HLT_3mu4_L1BPH-0M10C-3MU3V:
+HLT_3mu4_b3mu_noos_L1BPH-0M10-3MU3V:
   eventCount: 0
 HLT_3mu4_bDimu2700_L13MU3V:
   eventCount: 0
diff --git a/Trigger/TrigValidation/TrigP1Test/share/ref_v1Dev_decodeBS_build.ref b/Trigger/TrigValidation/TrigP1Test/share/ref_v1Dev_decodeBS_build.ref
index bf81dd553759..64693e261e3d 100644
--- a/Trigger/TrigValidation/TrigP1Test/share/ref_v1Dev_decodeBS_build.ref
+++ b/Trigger/TrigValidation/TrigP1Test/share/ref_v1Dev_decodeBS_build.ref
@@ -442,9 +442,9 @@ HLT_3j65_0eta290_020jvt_pf_ftf_bdl1r77_L1J45p0ETA21_3J15p0ETA25:
   eventCount: 0
 HLT_3j65_0eta290_020jvt_pf_ftf_bdl1r85_L1J45p0ETA21_3J15p0ETA25:
   eventCount: 0
-HLT_3mu4_L1BPH-0M10-3MU3V:
+HLT_3mu4_b3mu_L1BPH-0M10C-3MU3V:
   eventCount: 0
-HLT_3mu4_L1BPH-0M10C-3MU3V:
+HLT_3mu4_b3mu_noos_L1BPH-0M10-3MU3V:
   eventCount: 0
 HLT_3mu4_bDimu2700_L13MU3V:
   eventCount: 0
-- 
GitLab


From b5647c5467ab20c6ff0dde3b73f26ac06890be27 Mon Sep 17 00:00:00 2001
From: Vladimir Lyubushkin <Vladimir.Lyubushkin@cern.ch>
Date: Tue, 5 Oct 2021 08:43:04 +0200
Subject: [PATCH 4/4] fix empty line

---
 .../TrigBphysHypo/python/TrigMultiTrkComboHypoConfig.py          | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Trigger/TrigHypothesis/TrigBphysHypo/python/TrigMultiTrkComboHypoConfig.py b/Trigger/TrigHypothesis/TrigBphysHypo/python/TrigMultiTrkComboHypoConfig.py
index 3890c3d0b543..2eaa15627f28 100644
--- a/Trigger/TrigHypothesis/TrigBphysHypo/python/TrigMultiTrkComboHypoConfig.py
+++ b/Trigger/TrigHypothesis/TrigBphysHypo/python/TrigMultiTrkComboHypoConfig.py
@@ -68,7 +68,6 @@ def StreamerDimuEFComboHypoCfg(name):
     hypo.nTracks = [ 2 ]
     hypo.massRange = [ (100., 6000.) ]
     hypo.trackPtThresholds = [ [ 100., 100. ] ]
-
     return hypo
 
 def StreamerDiElecFastComboHypoCfg(name):
-- 
GitLab