From ff7d91b7c97e60e8800c0ff8f39aa3f9a54db5a1 Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <frank.winklmeier@cern.ch>
Date: Fri, 21 Jan 2022 19:01:19 +0100
Subject: [PATCH] TrigDecisionTool: various const fixes

---
 .../TrigDecisionTool/Root/Combination.cxx     |  2 +-
 .../Root/FeatureContainer.cxx                 |  4 ++--
 .../TrigDecisionTool/Combination.h            |  6 ++---
 .../TrigDecisionTool/DecisionAccess.h         |  6 ++---
 .../TrigDecisionTool/DecisionAccess.icc       |  8 +++----
 .../TrigDecisionTool/FeatureContainer.h       | 23 +++++++------------
 6 files changed, 21 insertions(+), 28 deletions(-)

diff --git a/Trigger/TrigAnalysis/TrigDecisionTool/Root/Combination.cxx b/Trigger/TrigAnalysis/TrigDecisionTool/Root/Combination.cxx
index 0ebb1d54fdfe..bdb919fd4f02 100644
--- a/Trigger/TrigAnalysis/TrigDecisionTool/Root/Combination.cxx
+++ b/Trigger/TrigAnalysis/TrigDecisionTool/Root/Combination.cxx
@@ -37,7 +37,7 @@ HLT::TrigNavStructure* Trig::Combination::navigation() const
   return const_cast<HLT::TrigNavStructure*>(m_cgm->navigation());
 }
 
-const std::vector<Trig::TypelessFeature> Trig::Combination::typelessGet(HLT::class_id_type clid, const std::string& label, unsigned int condition, const std::string & /*teName*/) const {
+std::vector<Trig::TypelessFeature> Trig::Combination::typelessGet(HLT::class_id_type clid, const std::string& label, unsigned int condition, const std::string & /*teName*/) const {
   //we will query the navigation for all features of this CLID, starting from the TE's in the combination and going up the navigation recursively.
   std::vector<Trig::TypelessFeature> features;
   
diff --git a/Trigger/TrigAnalysis/TrigDecisionTool/Root/FeatureContainer.cxx b/Trigger/TrigAnalysis/TrigDecisionTool/Root/FeatureContainer.cxx
index 2cead21632ac..aa0c652478d9 100644
--- a/Trigger/TrigAnalysis/TrigDecisionTool/Root/FeatureContainer.cxx
+++ b/Trigger/TrigAnalysis/TrigDecisionTool/Root/FeatureContainer.cxx
@@ -41,8 +41,8 @@ Trig::FeatureContainer::navigation() const {
 
 
 bool 
-Trig::FeatureContainer::ordering_by_objects_attached2::weakOrder(const HLT::TriggerElement* a, const HLT::TriggerElement* b,
-                                                                 void* obj_a, void* obj_b) const {
+Trig::FeatureContainer::ordering_by_objects_attached::weakOrder(const HLT::TriggerElement* a, const HLT::TriggerElement* b,
+                                                                const void* obj_a, const void* obj_b) const {
   // returning False -> no insertion into set
   // returning True -> insertion into set
   // each pair of candidates is tested twice (if test returns False twice, then no insertion into set)
diff --git a/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/Combination.h b/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/Combination.h
index 27623d0a9094..73b4b1cfa8ce 100644
--- a/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/Combination.h
+++ b/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/Combination.h
@@ -68,7 +68,7 @@ namespace Trig {
      * @param clid must be clid of type as stored. No flattening supported
      */
 
-    const std::vector<Trig::TypelessFeature> typelessGet(HLT::class_id_type clid, const std::string& label = "", unsigned int condition = TrigDefs::Physics, const std::string & teName = "" ) const;
+    std::vector<Trig::TypelessFeature> typelessGet(HLT::class_id_type clid, const std::string& label = "", unsigned int condition = TrigDefs::Physics, const std::string & teName = "" ) const;
 
     /**
      * @brief Method used to get objects. 
@@ -78,7 +78,7 @@ namespace Trig {
      * @param teName to get features from TEs of specific TEs (it is to be used in combination with switch alsoDeactivateTEs or composite triggers) super-expert usecase
      **/
      template<class T>
-     const std::vector<Trig::Feature<T> > get(const std::string& label = "", unsigned int condition=TrigDefs::Physics, const std::string& teName = "") const;
+     std::vector<Trig::Feature<T> > get(const std::string& label = "", unsigned int condition=TrigDefs::Physics, const std::string& teName = "") const;
 
     
     template<typename CONTAINER> using ELEMENT_OF = typename CONTAINER::base_value_type;
@@ -167,7 +167,7 @@ namespace Trig {
 
 
 template <class T>
-const std::vector<Trig::Feature<T> > Trig::Combination::get(const std::string& label, unsigned int condition, const std::string& teName) const
+std::vector<Trig::Feature<T> > Trig::Combination::get(const std::string& label, unsigned int condition, const std::string& teName) const
 {
   std::vector<Feature<T> > data;
 
diff --git a/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/DecisionAccess.h b/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/DecisionAccess.h
index 0f9a919929bf..1ce848197feb 100644
--- a/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/DecisionAccess.h
+++ b/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/DecisionAccess.h
@@ -1,7 +1,7 @@
 // -*- c++ -*-
 
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TRIGGER_DECISION_TOOL_DecisionAccess_H
@@ -229,7 +229,7 @@ namespace Trig {
      * Feature object can be given here as well
      **/
     template<class T> 
-    const Feature<T> ancestor(const HLT::TriggerElement* te, std::string label = "") const;
+    Feature<T> ancestor(const HLT::TriggerElement* te, std::string label = "") const;
 
     /**
      * @brief gives back features matching (by seeding relation) - will also flatten
@@ -238,7 +238,7 @@ namespace Trig {
      * Feature object can be given here as well
      **/
     template<class T>
-    const std::vector<Trig::Feature<T> > ancestors(const HLT::TriggerElement* te, std::string label = "", unsigned int condition=TrigDefs::Physics, const std::string& teName = "") const;
+    std::vector<Trig::Feature<T> > ancestors(const HLT::TriggerElement* te, std::string label = "", unsigned int condition=TrigDefs::Physics, const std::string& teName = "") const;
 
   protected:
 
diff --git a/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/DecisionAccess.icc b/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/DecisionAccess.icc
index 2e9cfb9968fd..e0afad362ff4 100644
--- a/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/DecisionAccess.icc
+++ b/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/DecisionAccess.icc
@@ -1,7 +1,7 @@
 #if !defined(XAOD_STANDALONE) && !defined(XAOD_ANALYSIS) // Full athena
 
 template<class T> 
-const Trig::Feature<T> Trig::DecisionAccess::ancestor(const HLT::TriggerElement* te, std::string label) const {
+Trig::Feature<T> Trig::DecisionAccess::ancestor(const HLT::TriggerElement* te, std::string label) const {
   Trig::Feature<T> f;
   std::vector<Trig::Feature<T> > data;
   FeatureAccessImpl::collect<T>(te, data, label, TrigDefs::alsoDeactivateTEs, "", const_cast<HLT::TrigNavStructure*>(cgm()->navigation()));
@@ -19,7 +19,7 @@ const Trig::Feature<T> Trig::DecisionAccess::ancestor(const HLT::TriggerElement*
 
 
 template<class T>
-const std::vector<Trig::Feature<T> > Trig::DecisionAccess::ancestors(const HLT::TriggerElement* te, std::string label, unsigned int condition, const std::string& teName) const {
+std::vector<Trig::Feature<T> > Trig::DecisionAccess::ancestors(const HLT::TriggerElement* te, std::string label, unsigned int condition, const std::string& teName) const {
   std::vector<Trig::Feature<T> > data;
   FeatureAccessImpl::collect<T>(te, data, label, condition, teName, const_cast<HLT::TrigNavStructure*>(cgm()->navigation()));
   for( Feature<T>& f : data ) {
@@ -33,13 +33,13 @@ const std::vector<Trig::Feature<T> > Trig::DecisionAccess::ancestors(const HLT::
 #else // AnalysisBase
 
 template<class T> 
-const Trig::Feature<T> Trig::DecisionAccess::ancestor(const HLT::TriggerElement* /*te*/, std::string /*label*/) const {
+Trig::Feature<T> Trig::DecisionAccess::ancestor(const HLT::TriggerElement* /*te*/, std::string /*label*/) const {
   ATH_MSG_WARNING("DecisionAccess::ancestor not implemented in Standalone mode, since it needs compile-time type information. Returning empty Feature");  
   return Trig::Feature<T>();
 }
 
 template<class T>
-const std::vector<Trig::Feature<T> > Trig::DecisionAccess::ancestors(const HLT::TriggerElement* /*te*/, std::string /*label*/, unsigned int /*condition*/, const std::string& /*teName*/) const {
+std::vector<Trig::Feature<T> > Trig::DecisionAccess::ancestors(const HLT::TriggerElement* /*te*/, std::string /*label*/, unsigned int /*condition*/, const std::string& /*teName*/) const {
   ATH_MSG_WARNING("DecisionAccess::ancestor not implemented in Standalone mode, since it needs compile-time type information. Returning empty vector");  
   return  std::vector<Trig::Feature<T> >();
 }
diff --git a/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/FeatureContainer.h b/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/FeatureContainer.h
index 0471bb495d5e..119de6773ca0 100644
--- a/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/FeatureContainer.h
+++ b/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/FeatureContainer.h
@@ -127,18 +127,13 @@ namespace Trig {
 
     const Trig::CacheGlobalMemory*         m_cgm{nullptr};
 
-    // helper class to support ordered set of features
-    //      class ordering_by_objects_attached {
-    //      public:
-    //        bool operator()(const HLT::TriggerElement* a, const HLT::TriggerElement* b);
-    //      };
-
-    // helper function for
-    class ordering_by_objects_attached2 {
+    /// helper class to support ordered set of features
+    class ordering_by_objects_attached {
     public:
       template<class T>
-      bool operator()(Feature<T> a, Feature<T> b) const;
-      bool weakOrder(const HLT::TriggerElement* te_a, const HLT::TriggerElement* te_b, void* obj_a, void* obj_b) const;
+      bool operator()(const Feature<T>& a, const Feature<T>& b) const;
+      bool weakOrder(const HLT::TriggerElement* te_a, const HLT::TriggerElement* te_b,
+                     const void* obj_a, const void* obj_b) const;
     };
 
   };
@@ -148,10 +143,8 @@ namespace Trig {
 
 template<class T> 
 bool
-Trig::FeatureContainer::ordering_by_objects_attached2::operator()(Feature<T> a, Feature<T> b) const {
-  bool ret = weakOrder(a.te(), b.te(), (void*) a.cptr(), (void*) b.cptr());
-  //std::cout << " ==> " << (ret?"TRUE":"FALSE") << std::endl;
-  return ret;
+Trig::FeatureContainer::ordering_by_objects_attached::operator()(const Feature<T>& a, const Feature<T>& b) const {
+  return weakOrder(a.te(), b.te(), a.cptr(), b.cptr());
 }
 
 template<class T> const std::vector<Trig::Feature<T> >
@@ -163,7 +156,7 @@ Trig::FeatureContainer::get(const std::string& label, unsigned int condition, co
 
   //std::cout << " in FC::get, after call to getCombinations(), now looping over them" << std::endl;
 
-  std::set<Trig::Feature<T>, Trig::FeatureContainer::ordering_by_objects_attached2 > uniqnessHelper;
+  std::set<Trig::Feature<T>, Trig::FeatureContainer::ordering_by_objects_attached > uniqnessHelper;
 
   
   for(const Trig::Combination& comb : m_combinations ) {
-- 
GitLab