From b4d9fc5745e152ca2dd168012a9c68f9a63a8873 Mon Sep 17 00:00:00 2001
From: Christopher John Mcnicol <christopher.john.mcnicol@cern.ch>
Date: Wed, 25 Jan 2017 14:17:01 +0100
Subject: [PATCH] 'Updated caching of algorithm names'
 (TrigCostMonitor-01-20-19)

	* Add caching for Algorithm names
	* Tag TrigCostMonitor-01-20-19


Former-commit-id: bde2683199868e3dd8fff094dc0fa45852f0983c
---
 .../TrigCostMonitor/TrigNtRobsTool.h          |  4 ++--
 .../TrigCostMonitor/src/TrigNtRobsTool.cxx    | 19 +++++++++++++------
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/Trigger/TrigMonitoring/TrigCostMonitor/TrigCostMonitor/TrigNtRobsTool.h b/Trigger/TrigMonitoring/TrigCostMonitor/TrigCostMonitor/TrigNtRobsTool.h
index 2167f972ca9..34f91dec8e6 100644
--- a/Trigger/TrigMonitoring/TrigCostMonitor/TrigCostMonitor/TrigNtRobsTool.h
+++ b/Trigger/TrigMonitoring/TrigCostMonitor/TrigCostMonitor/TrigNtRobsTool.h
@@ -60,8 +60,8 @@ namespace Trig
 
     // Tool variables
     TrigMonConfig               *m_config;
-
-    std::set<uint32_t>           m_algIds;
+    std::map<std::string, uint32_t> m_algNameToIDMap; //Algorithm Name to ID caching
+    std::set<uint32_t>           m_algIds;  
   };
 }
 
diff --git a/Trigger/TrigMonitoring/TrigCostMonitor/src/TrigNtRobsTool.cxx b/Trigger/TrigMonitoring/TrigCostMonitor/src/TrigNtRobsTool.cxx
index e82c491b3ea..32384fc3a98 100644
--- a/Trigger/TrigMonitoring/TrigCostMonitor/src/TrigNtRobsTool.cxx
+++ b/Trigger/TrigMonitoring/TrigCostMonitor/src/TrigNtRobsTool.cxx
@@ -135,8 +135,9 @@ bool Trig::TrigNtRobsTool::Fill(TrigMonEvent &event)
     //
     bool found_id = 0;
     uint32_t alg_id = 0;
-    
-    for(unsigned int i = 0; i < m_config->size<TrigConfSeq>(); ++i) {
+
+    if (m_algNameToIDMap.size() == 0) {
+for(unsigned int i = 0; i < m_config->size<TrigConfSeq>(); ++i) {
       const TrigConfSeq &seq = m_config->at<TrigConfSeq>(i);
       const std::vector<TrigConfAlg> &avec = seq.getAlg();
       
@@ -144,13 +145,19 @@ bool Trig::TrigNtRobsTool::Fill(TrigMonEvent &event)
       for(unsigned int j = 0; j < avec.size(); ++j) {
         const TrigConfAlg &alg = avec[j];
         
-        if(alg.getName() == rob->requestor_name) { 
-          alg_id   = alg.getNameId();
-          found_id = true;
-          break;
+          m_algNameToIDMap[alg.getName()] = alg.getNameId();
+          
         }
       }
+}
+    std::map<std::string, uint32_t>::const_iterator algFinder = m_algNameToIDMap.find(rob->requestor_name);
+
+    if (algFinder != m_algNameToIDMap.end() ){
+      alg_id = algFinder->second;
+      found_id = true;
     }
+    
+    
 
     if(!found_id) {
       alg_id = TrigConf::HLTUtils::string2hash(rob->requestor_name, "ALG");
-- 
GitLab