From 569c170d0347d59a478019f6b6a115ff2aa4e531 Mon Sep 17 00:00:00 2001
From: Teng Jian Khoo <teng.jian.khoo@cern.ch>
Date: Tue, 26 May 2020 15:06:04 +0000
Subject: [PATCH] Translate from leg ID to chain ID when checking active HLT
 jet chains

---
 .../python/chainDict2jetLabel.py              | 16 ++++++++----
 .../TrigHLTJetHypo/src/TrigJetHypoAlgMT.cxx   | 25 ++++++++++++++++++-
 .../TrigHLTJetHypo/src/TrigJetHypoToolMT.cxx  |  5 ++--
 .../share/ref_RDOtoRDOTrig_mt1_build.ref      | 10 ++++++--
 .../share/ref_data_v1Dev_build.ref            |  6 +++++
 .../HLTMenuConfig/Menu/Physics_pp_run3_v1.py  |  4 ++-
 6 files changed, 55 insertions(+), 11 deletions(-)

diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/chainDict2jetLabel.py b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/chainDict2jetLabel.py
index 3fb405fe03b..4f05f4f100b 100644
--- a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/chainDict2jetLabel.py
+++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/chainDict2jetLabel.py
@@ -371,18 +371,24 @@ def _tests():
 
     from TriggerMenuMT.HLTMenuConfig.Menu import DictFromChainName
     from TrigHLTJetHypo.ChainLabelParser import ChainLabelParser
+    from TriggerMenuMT.HLTMenuConfig.Menu.ChainDefInMenu import ChainProp
+    from TriggerMenuMT.HLTMenuConfig.Menu.Physics_pp_run3_v1 import MultiJetGroup
 
-    chain_names = (
+    chains = (
         'HLT_j85_L1J20',
-        # 'HLT_j80_0eta240_2j60_320eta490_L1J20',
-        # ``'HLT_j85_j70_L1J20',
+        ChainProp(name='HLT_j85_j70_L1J20', l1SeedThresholds=['FSNOSEED']*2, groups=MultiJetGroup),
+        ChainProp(name='HLT_j80_0eta240_2j60_320eta490_L1J20', l1SeedThresholds=['FSNOSEED']*2, groups=MultiJetGroup),
         'HLT_j0_vbenfSEP30etSEP34mass35SEP50fbet_L1J20',
-        'HLT_j80_0eta240_2j60_320eta490_j0_dijetSEP80j1etSEP0j1eta240SEP80j2etSEP0j2eta240SEP700djmass_L1J20',
+        ChainProp(name='HLT_j80_0eta240_2j60_320eta490_j0_dijetSEP80j1etSEP0j1eta240SEP80j2etSEP0j2eta240SEP700djmass_L1J20', l1SeedThresholds=['FSNOSEED']*3, groups=MultiJetGroup),
         
     )
     
 
-    for cn in chain_names:
+    for cn in chains:
+        # Contrary to the function name, this requires a ChainProp
+        # though it will generate a basic one if a string is given
+        # Needs the ChainProp when we have multiple chainParts
+        # to avoid mismatch in L1 threshold multiplicity
         chain_dict = DictFromChainName.dictFromChainName(cn)
 
         label = chainDict2jetLabel(chain_dict)
diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoAlgMT.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoAlgMT.cxx
index b6de4a16af9..a7bddb80d57 100644
--- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoAlgMT.cxx
+++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoAlgMT.cxx
@@ -2,6 +2,7 @@
   Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
 */
 
+#include <algorithm>
 #include "GaudiKernel/Property.h"
 #include "TrigJetHypoAlgMT.h"
 #include "TrigCompositeUtils/HLTIdentifier.h"
@@ -33,6 +34,7 @@ StatusCode TrigJetHypoAlgMT::execute( const EventContext& context ) const {
   // The container should have only one such Decision (for L1) as deding
   // on jets is a one step process.
 
+  ATH_MSG_DEBUG("Retrieving L1 decision \"" << decisionInput().key() << "\"");
   auto h_prevDecisions = SG::makeHandle(decisionInput(), context );
 
   if( not h_prevDecisions.isValid() || h_prevDecisions->size() ==0) {//implicit
@@ -107,9 +109,30 @@ TrigJetHypoAlgMT::decide(const xAOD::JetContainer* jets,
     TrigCompositeUtils::decisionIDs(previousDecision).begin(),
       TrigCompositeUtils::decisionIDs(previousDecision).end()
       };
+
+  if (msgLvl(MSG::DEBUG)) {
+    msg() << "IDs of active legs:" << endmsg;
+    for(auto decisionID: previousDecisionIDs) {
+      msg() << "    " << decisionID << endmsg;
+    }
+  }
+  // Some of these may be leg IDs, convert those to the chain ID
+  TrigCompositeUtils::DecisionIDContainer leglessPreviousDecisionIDs;
+  std::transform(previousDecisionIDs.begin(), previousDecisionIDs.end(),
+		 std::inserter(leglessPreviousDecisionIDs,leglessPreviousDecisionIDs.begin()),
+		 [] (TrigCompositeUtils::DecisionID id) -> TrigCompositeUtils::DecisionID
+		 {return TrigCompositeUtils::getIDFromLeg(HLT::Identifier(id)).numeric();}
+		 );
+  if (msgLvl(MSG::DEBUG)) {
+    msg() << "IDs of active chains:" << endmsg;
+    for(auto decisionID: leglessPreviousDecisionIDs) {
+      msg() << "    " << decisionID << endmsg;
+    }
+  }
   
   for (const auto& tool: m_hypoTools) {
-    CHECK(tool->decide(jets, previousDecisionIDs, jetHypoInputs));
+    ATH_MSG_DEBUG("Now computing decision for " << tool->name());
+    CHECK(tool->decide(jets, leglessPreviousDecisionIDs, jetHypoInputs));
   }
   
   return StatusCode::SUCCESS;
diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolMT.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolMT.cxx
index 67646021c72..63ab69cb60f 100644
--- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolMT.cxx
+++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolMT.cxx
@@ -66,7 +66,8 @@ TrigJetHypoToolMT::decide(const xAOD::JetContainer* jets,
   if (not TrigCompositeUtils::passed(getId().numeric(), previousDecisionIDs)) {
     // This HypoTool's chain is not active -
     // we must not check this tool's logic.
-    
+    ATH_MSG_DEBUG("Previous decisionID not found for " << getId().numeric() << " - exiting.");
+
     return StatusCode::SUCCESS;
   }
 
@@ -126,7 +127,7 @@ TrigJetHypoToolMT::decide(const xAOD::JetContainer* jets,
                           participating_jets.end(),
                           pair.first);
       if (it != participating_jets.end()) {
-
+	ATH_MSG_VERBOSE("Passing jet: pt " << (*it)->pt() << ", eta " << (*it)->eta() );
 	// This jet particpated in passing the event.
         // Add this HypoTool's ID to this Decision object. 
 
diff --git a/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_mt1_build.ref b/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_mt1_build.ref
index 85b974530e6..c41c2ee7def 100644
--- a/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_mt1_build.ref
+++ b/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_mt1_build.ref
@@ -22,6 +22,9 @@ TrigSignatureMoniMT                                INFO -- #3965466087 Features
 TrigSignatureMoniMT                                INFO HLT_2j330_a10t_lcw_jes_35smcINF_L1J100 #1295975955
 TrigSignatureMoniMT                                INFO -- #1295975955 Events         3          3          0          -          -          -          -          -          0
 TrigSignatureMoniMT                                INFO -- #1295975955 Features                             0          -          -          -          -          -
+TrigSignatureMoniMT                                INFO HLT_2j60_L1J15 #927735533
+TrigSignatureMoniMT                                INFO -- #927735533 Events          20         20         10         -          -          -          -          -          10
+TrigSignatureMoniMT                                INFO -- #927735533 Features                              28         -          -          -          -          -
 TrigSignatureMoniMT                                INFO HLT_2mu14_L12MU10 #2619091790
 TrigSignatureMoniMT                                INFO -- #2619091790 Events         3          3          3          1          1          1          -          -          1
 TrigSignatureMoniMT                                INFO -- #2619091790 Features                             12         4          4          4          -          -
@@ -268,9 +271,12 @@ TrigSignatureMoniMT                                INFO -- #436385969 Features
 TrigSignatureMoniMT                                INFO HLT_j80_0eta240_2j60_320eta490_j0_dijetSEP80j1etSEP0j1eta240SEP80j2etSEP0j2eta240SEP700djmass_L1J20 #3634067472
 TrigSignatureMoniMT                                INFO -- #3634067472 Events         19         19         0          -          -          -          -          -          0
 TrigSignatureMoniMT                                INFO -- #3634067472 Features                             0          -          -          -          -          -
+TrigSignatureMoniMT                                INFO HLT_j80_L1J15 #2440872308
+TrigSignatureMoniMT                                INFO -- #2440872308 Events         20         20         13         -          -          -          -          -          13
+TrigSignatureMoniMT                                INFO -- #2440872308 Features                             23         -          -          -          -          -
 TrigSignatureMoniMT                                INFO HLT_j80_j60_L1J15 #582699527
-TrigSignatureMoniMT                                INFO -- #582699527 Events          20         20         0          -          -          -          -          -          0
-TrigSignatureMoniMT                                INFO -- #582699527 Features                              0          -          -          -          -          -
+TrigSignatureMoniMT                                INFO -- #582699527 Events          20         20         8          -          -          -          -          -          8
+TrigSignatureMoniMT                                INFO -- #582699527 Features                              23         -          -          -          -          -
 TrigSignatureMoniMT                                INFO HLT_j85_L1J20 #510475538
 TrigSignatureMoniMT                                INFO -- #510475538 Events          19         19         13         -          -          -          -          -          13
 TrigSignatureMoniMT                                INFO -- #510475538 Features                              21         -          -          -          -          -
diff --git a/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref b/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref
index 5c6dd4680bf..b1dadbd58aa 100644
--- a/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref
+++ b/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref
@@ -22,6 +22,9 @@ TrigSignatureMoniMT                                 INFO -- #3965466087 Features
 TrigSignatureMoniMT                                 INFO HLT_2j330_a10t_lcw_jes_35smcINF_L1J100 #1295975955
 TrigSignatureMoniMT                                 INFO -- #1295975955 Events         20         20         0          -          -          -          -          -          0          
 TrigSignatureMoniMT                                 INFO -- #1295975955 Features                             0          -          -          -          -          -          
+TrigSignatureMoniMT                                 INFO HLT_2j60_L1J15 #927735533
+TrigSignatureMoniMT                                 INFO -- #927735533 Events          20         20         0          -          -          -          -          -          0          
+TrigSignatureMoniMT                                 INFO -- #927735533 Features                              0          -          -          -          -          -          
 TrigSignatureMoniMT                                 INFO HLT_2mu14_L12MU10 #2619091790
 TrigSignatureMoniMT                                 INFO -- #2619091790 Events         20         20         0          0          0          0          -          -          0          
 TrigSignatureMoniMT                                 INFO -- #2619091790 Features                             0          0          0          0          -          -          
@@ -277,6 +280,9 @@ TrigSignatureMoniMT                                 INFO -- #436385969 Features
 TrigSignatureMoniMT                                 INFO HLT_j80_0eta240_2j60_320eta490_j0_dijetSEP80j1etSEP0j1eta240SEP80j2etSEP0j2eta240SEP700djmass_L1J20 #3634067472
 TrigSignatureMoniMT                                 INFO -- #3634067472 Events         20         20         0          -          -          -          -          -          0          
 TrigSignatureMoniMT                                 INFO -- #3634067472 Features                             0          -          -          -          -          -          
+TrigSignatureMoniMT                                 INFO HLT_j80_L1J15 #2440872308
+TrigSignatureMoniMT                                 INFO -- #2440872308 Events         20         20         3          -          -          -          -          -          3          
+TrigSignatureMoniMT                                 INFO -- #2440872308 Features                             3          -          -          -          -          -          
 TrigSignatureMoniMT                                 INFO HLT_j80_j60_L1J15 #582699527
 TrigSignatureMoniMT                                 INFO -- #582699527 Events          20         20         0          -          -          -          -          -          0          
 TrigSignatureMoniMT                                 INFO -- #582699527 Features                              0          -          -          -          -          -          
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/Physics_pp_run3_v1.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/Physics_pp_run3_v1.py
index 8669608d456..e2295d335d6 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/Physics_pp_run3_v1.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/Physics_pp_run3_v1.py
@@ -89,7 +89,9 @@ def setupMenu():
         ChainProp(name='HLT_5j70_0eta240_L14J20', groups=MultiJetGroup), # this chain is supposed to be seeded off L1_4J15 in principle, needs CF fix
         ChainProp(name='HLT_3j200_L1J100', groups=MultiJetGroup),
         # FP: workaround tmp for l1SeedThresholds
-        ChainProp(name='HLT_j80_j60_L1J15', l1SeedThresholds=['FSNOSEED']*2, groups=MultiJetGroup),
+        ChainProp(name='HLT_j80_L1J15', groups=SingleJetGroup),
+        ChainProp(name='HLT_2j60_L1J15', groups=MultiJetGroup),
+        ChainProp(name='HLT_j80_j60_L1J15', l1SeedThresholds=2*['FSNOSEED'], groups=MultiJetGroup),
         # FP: workaround tmp for l1SeedThresholds
         ChainProp(name='HLT_j80_0eta240_2j60_320eta490_j0_dijetSEP80j1etSEP0j1eta240SEP80j2etSEP0j2eta240SEP700djmass_L1J20', l1SeedThresholds=['FSNOSEED']*3, groups=MultiJetGroup),
     ]
-- 
GitLab