From 8711d0db14349075202fb760deed055bccc5e13e Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <frank.winklmeier@cern.ch>
Date: Wed, 27 Apr 2022 09:53:48 +0200
Subject: [PATCH 1/2] JetEvent: thread-checker fixes

Several fixes to get rid of thread-checker warnings (but several less
trivial-to-fix warnings still remain):

- make tagInfoStore non-mutable and methods modifying it non-const
- const/mutable fix for setConstituentSignalState
- make constant statics const
- JetMapBase: add const-correct accessors to pointer
- remove use of static in combinedLikelihood
---
 Reconstruction/Jet/JetEvent/JetEvent/Jet.h    | 20 ++++++++--------
 Reconstruction/Jet/JetEvent/JetEvent/Jet.icc  |  6 ++---
 .../Jet/JetEvent/JetEvent/JetKeyDescriptor.h  | 10 ++++----
 .../Jet/JetEvent/JetEvent/JetMapBase.h        | 15 +++++++-----
 .../Jet/JetEvent/JetEvent/JetMapBase.icc      |  4 ++--
 Reconstruction/Jet/JetEvent/src/Jet.cxx       | 24 +++++++++----------
 .../Jet/JetEvent/src/JetKeyDescriptor.cxx     | 12 +++++-----
 7 files changed, 46 insertions(+), 45 deletions(-)

diff --git a/Reconstruction/Jet/JetEvent/JetEvent/Jet.h b/Reconstruction/Jet/JetEvent/JetEvent/Jet.h
index be9793877151..0ed16112338d 100755
--- a/Reconstruction/Jet/JetEvent/JetEvent/Jet.h
+++ b/Reconstruction/Jet/JetEvent/JetEvent/Jet.h
@@ -1,7 +1,7 @@
 // emacs, this is -*- C++ -*-
 
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef JETEVENT_JET_H
@@ -484,7 +484,7 @@ public:
   
   /** @brief Set tag info object */
   void setTagInfo(const mkey_t& key,const taginfo_t* pTagInfo,
-		  bool useLink=false) const ;
+		  bool useLink=false);
   
   /** @brief @b (depreciated) Retrieve vector of tag infos */
   const tagstore_t jetTagInfoVector() const;
@@ -501,14 +501,14 @@ public:
   
   /** @brief Add tag info object */
   template<class TAGINFO>
-  void addInfo(const TAGINFO* tag) const;
+  void addInfo(const TAGINFO* tag);
   
   /** @brief @b (depreciated) Remove tag info object */ 
-  void removeInfo(const mkey_t& key) const;
+  void removeInfo(const mkey_t& key);
 
 private:
   /** @brief Remove tag info for object located at index (internal) */
-  void removeInfo(unsigned int index) const;
+  void removeInfo(unsigned int index);
       
 
 
@@ -527,7 +527,7 @@ public:
   signalstate_t constituentSignalState() const;
   
   /** Set the current Signal state of the jet constituents */
-  void setConstituentSignalState( signalstate_t s ) const;
+  void setConstituentSignalState( signalstate_t s );
 
   /** True if the jet constituent have a calibrated signal state*/
   bool has_calibrated_constit() const {return int(constituentSignalState())>0;};
@@ -617,7 +617,7 @@ public:
 private:
 
   /** @brief Maximum difference up to which weights are considered equal */
-  static double m_ignoreWeight;
+  static const double m_ignoreWeight;
 
   ///////////////////////////////////////////////
   // Protected Kinematics Recombination Scheme //
@@ -738,10 +738,10 @@ protected:
   mutable assostore_t* m_assocStore;
 
   /** @brief Tag info store */
-  mutable tagstore_t*  m_tagInfoStore;
+  tagstore_t*  m_tagInfoStore;
 
   /** @brief Constituent Signal State */
-  mutable signalstate_t m_constituentSigState;
+  signalstate_t m_constituentSigState;
 
   /////////////
   // Helpers //
@@ -834,7 +834,7 @@ private:
 public:
 
   /** @brief <b>(depreciated)</b> Likelihood store access */
-  const std::vector<double>& combinedLikelihood() const;
+  std::vector<double> combinedLikelihood() const;
   
   /** @brief <b>(depreciated)</b> Likelihood store setter */
   void setCombinedLikelihood(const std::vector<double>& combinedLikelihood);
diff --git a/Reconstruction/Jet/JetEvent/JetEvent/Jet.icc b/Reconstruction/Jet/JetEvent/JetEvent/Jet.icc
index 81420740a996..1161641a5f27 100644
--- a/Reconstruction/Jet/JetEvent/JetEvent/Jet.icc
+++ b/Reconstruction/Jet/JetEvent/JetEvent/Jet.icc
@@ -1,7 +1,7 @@
 // emacs, this is -*- C++ -*-
 
 /*
-  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
 */
 
 ///////////                                                        /////////// 
@@ -278,7 +278,7 @@ const TAGINFO* Jet::tagInfo(const mkey_t& key) const
 }
 
 template<class TAGINFO>
-void Jet::addInfo(const TAGINFO* tag) const
+void Jet::addInfo(const TAGINFO* tag)
 {
   this->setTagInfo( tag->infoType(), tag );
 }
@@ -332,7 +332,7 @@ inline void Jet::removeAssociation (const size_t index) const
 /////////////////////////////////////////
 /// constituent and jet signal states ///
 /////////////////////////////////////////
-inline void Jet::setConstituentSignalState( Jet::signalstate_t s ) const
+inline void Jet::setConstituentSignalState( Jet::signalstate_t s )
 {
   m_constituentSigState = s;
 }
diff --git a/Reconstruction/Jet/JetEvent/JetEvent/JetKeyDescriptor.h b/Reconstruction/Jet/JetEvent/JetEvent/JetKeyDescriptor.h
index 621bc1f9ca1e..19f55ec17ba1 100644
--- a/Reconstruction/Jet/JetEvent/JetEvent/JetKeyDescriptor.h
+++ b/Reconstruction/Jet/JetEvent/JetEvent/JetKeyDescriptor.h
@@ -1,5 +1,5 @@
 /*
-  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 JETEVENT_JETKEYDESCRIPTOR_H
@@ -158,11 +158,11 @@ class JetKeyDescriptorInstance
  private:
   
 
-  static size_t                  m_invalid;
-  static std::string             m_notFound;
-  static std::vector<key_t>      m_invalidKeys;
+  static const size_t                  m_invalid;
+  static const std::string             m_notFound;
+  static const std::vector<key_t>      m_invalidKeys;
   
-  static bool                    m_persistified;
+  static const bool                    m_persistified;
 };
 
 inline bool JetKeyDescriptorInstance::isValid(size_t index) const
diff --git a/Reconstruction/Jet/JetEvent/JetEvent/JetMapBase.h b/Reconstruction/Jet/JetEvent/JetEvent/JetMapBase.h
index 46610be4b75f..a31778099e66 100644
--- a/Reconstruction/Jet/JetEvent/JetEvent/JetMapBase.h
+++ b/Reconstruction/Jet/JetEvent/JetEvent/JetMapBase.h
@@ -1,7 +1,7 @@
 // -*- C++ -*-
 
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef JETEVENT_JETMAPBASE_H
@@ -35,9 +35,12 @@ public:
   public:
     record_ptr_t(record_t* r=NULL) : m_ptr(r) {};
     bool isValid()const{return m_ptr !=NULL;}
-    record_t & operator*()const {return *m_ptr;}
-    record_t* operator->() const {return m_ptr;}
-    record_t* get() const {return m_ptr;}
+    const record_t& operator*() const {return *m_ptr;}
+    const record_t* operator->() const {return m_ptr;}
+    const record_t* get() const {return m_ptr;}
+    record_t& operator*() {return *m_ptr;}
+    record_t* operator->() {return m_ptr;}
+    record_t* get() {return m_ptr;}
     void destroy() {if (isValid()) delete m_ptr; m_ptr=NULL;}
     void set(record_t *r){m_ptr = r;}
   protected:
@@ -156,7 +159,7 @@ protected:
   /*! @brief Data store */
   mutable map_t  m_store;
   /*! @brief Null data reference */
-  static data_t m_nullData;
+  static const data_t m_nullData;
 
   typename map_t::iterator m_end;
 #endif
@@ -167,7 +170,7 @@ protected:
 
 class OrphanJetCounter {
 public:
-  size_t getNewId(){m_counter++;return m_counter;};
+  size_t getNewId() {m_counter++;return m_counter;};
   
 protected:
   void reset(){m_counter=0;}
diff --git a/Reconstruction/Jet/JetEvent/JetEvent/JetMapBase.icc b/Reconstruction/Jet/JetEvent/JetEvent/JetMapBase.icc
index 64bd15002e4d..398cd3b15a17 100644
--- a/Reconstruction/Jet/JetEvent/JetEvent/JetMapBase.icc
+++ b/Reconstruction/Jet/JetEvent/JetEvent/JetMapBase.icc
@@ -1,7 +1,7 @@
 // -*- C++ -*-
 
 /*
-  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
 */
 
 
@@ -12,7 +12,7 @@
 
 // -*- C++ -*-
 template<class P>
-typename JetMapBase<P>::data_t JetMapBase<P>::m_nullData = data_t();
+const typename JetMapBase<P>::data_t JetMapBase<P>::m_nullData = data_t();
 
 template<class P>
 inline 
diff --git a/Reconstruction/Jet/JetEvent/src/Jet.cxx b/Reconstruction/Jet/JetEvent/src/Jet.cxx
index 391f54757fb5..706787cb2397 100755
--- a/Reconstruction/Jet/JetEvent/src/Jet.cxx
+++ b/Reconstruction/Jet/JetEvent/src/Jet.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
 */
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -67,7 +67,7 @@ const size_t Jet::s_defaultJetAuthor = 0 ;
 
 
 
-double Jet::m_ignoreWeight = 1.0e-06;
+const double Jet::m_ignoreWeight = 1.0e-06;
 
 // Little helper function
 bool jet_component_identity(double p1, double p2, double epsilon = 0.1){
@@ -872,7 +872,7 @@ Jet::shape_t Jet::getShape(const mkey_t& shapeName,bool addIfMissing) const
 
 void Jet::setTagInfo(const mkey_t& key,
 		     const taginfo_t* pTagInfo,
-		     bool /* useLink */ ) const
+		     bool /* useLink */ )
 {
   // use check function
   size_t aInd;
@@ -889,13 +889,13 @@ void Jet::setTagInfo(const mkey_t& key,
     }
 }
 
-void Jet::removeInfo (unsigned int index) const
+void Jet::removeInfo (unsigned int index)
 {
   delete (m_tagInfoStore->operator[])(index);
   (m_tagInfoStore->operator[])(index) = 0;
 }
 
-void Jet::removeInfo(const mkey_t& key ) const
+void Jet::removeInfo(const mkey_t& key )
 {
   if ( bool(m_tagInfoStore) ) {
     size_t aInd;
@@ -983,14 +983,13 @@ bool Jet::finalScaleEqualsEMScale() const {
 ///////////                                                        ///////////
 
 
-const std::vector<double>& Jet::combinedLikelihood() const
+std::vector<double> Jet::combinedLikelihood() const
 { 
-  static std::vector<double> combinedLikelihood;
+  std::vector<double> combinedLikelihood;
   combinedLikelihood.resize(m_num_combinedLikelihood);
-  std::string base="LikeLihood_";
+  const std::string base="LikeLihood_";
   for(unsigned int i=0; i<m_num_combinedLikelihood; i++){
-    std::stringstream s; s<< i; 
-    combinedLikelihood[i] = getShape(base+s.str()) ;
+    combinedLikelihood[i] = getShape(base+std::to_string(i)) ;
   }
 
   return combinedLikelihood;
@@ -999,10 +998,9 @@ const std::vector<double>& Jet::combinedLikelihood() const
 void Jet::setCombinedLikelihood(const std::vector<double>& 
 				       combinedLikelihood)
 { 
-  std::string base="LikeLihood_";
+  const std::string base="LikeLihood_";
   for(unsigned int i=0; i<combinedLikelihood.size(); i++){
-    std::stringstream s; s<< i; 
-    setShape(base+s.str(), combinedLikelihood[i] );
+    setShape(base+std::to_string(i), combinedLikelihood[i] );
   }	
   m_num_combinedLikelihood = combinedLikelihood.size();
 }
diff --git a/Reconstruction/Jet/JetEvent/src/JetKeyDescriptor.cxx b/Reconstruction/Jet/JetEvent/src/JetKeyDescriptor.cxx
index ba273b0262cd..76f535b757e6 100644
--- a/Reconstruction/Jet/JetEvent/src/JetKeyDescriptor.cxx
+++ b/Reconstruction/Jet/JetEvent/src/JetKeyDescriptor.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
 */
 
 
@@ -15,11 +15,11 @@ const JetKeyConstants::key_t JetKeyConstants::AssoCat = "JetAssociations";
 const JetKeyConstants::key_t JetKeyConstants::TagCat = "JetTags";
 const JetKeyConstants::key_t JetKeyConstants::InfoCat = "JetInfo";
 
-JetKeyDescriptorInstance                        JetKeyDescriptorInstance::s_instance;
-size_t                                          JetKeyDescriptorInstance::m_invalid  = size_t(-1);
-std::string                                     JetKeyDescriptorInstance::m_notFound = "unknown";
-std::vector<JetKeyDescriptorInstance::key_t>    JetKeyDescriptorInstance::m_invalidKeys;
-bool                                            JetKeyDescriptorInstance::m_persistified = false;
+JetKeyDescriptorInstance                              JetKeyDescriptorInstance::s_instance;
+const size_t                                          JetKeyDescriptorInstance::m_invalid  = size_t(-1);
+const std::string                                     JetKeyDescriptorInstance::m_notFound = "unknown";
+const std::vector<JetKeyDescriptorInstance::key_t>    JetKeyDescriptorInstance::m_invalidKeys;
+const bool                                            JetKeyDescriptorInstance::m_persistified = false;
 
 JetKeyDescriptorInstance::JetKeyDescriptorInstance(bool create) : m_Stores(0)
 {
-- 
GitLab


From de7377622d282a4d3b2896588b1ee6ce3afa7812 Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <frank.winklmeier@cern.ch>
Date: Wed, 27 Apr 2022 10:45:58 +0200
Subject: [PATCH 2/2] JetEvent: remove unused GhostJet class

---
 .../Jet/JetEvent/JetEvent/GhostJet.h          | 48 -------------------
 Reconstruction/Jet/JetEvent/src/GhostJet.cxx  |  9 ----
 2 files changed, 57 deletions(-)
 delete mode 100755 Reconstruction/Jet/JetEvent/JetEvent/GhostJet.h
 delete mode 100755 Reconstruction/Jet/JetEvent/src/GhostJet.cxx

diff --git a/Reconstruction/Jet/JetEvent/JetEvent/GhostJet.h b/Reconstruction/Jet/JetEvent/JetEvent/GhostJet.h
deleted file mode 100755
index f78e9b7c32ca..000000000000
--- a/Reconstruction/Jet/JetEvent/JetEvent/GhostJet.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-#ifndef JETEVENT_GHOSTJET_H
-#define JETEVENT_GHOSTJET_H
-///////////////////////////////////////////////////////////////////////////////
-/// \brief basic GhostJet data class
-///
-///  The purpose of GhostJets is only to compute Jet 'areas'
-///  By adding lots of proto-jets of energy ~0 (GhostJet) to 
-///  the input of a jet finder. 
-///  This class is here to be able to distinguish a GhostJet than a signal 
-///  Jet and to hold the size of the ghost jets grid
-///
-/// \author P.A. Delsart
-/// \date   March 2007
-///
-///////////////////////////////////////////////////////////////////////////////
-
-
-#include "JetEvent/Jet.h"
-
-class I4Momentum;
-
-class GhostJet :   public Jet
-{
-  
- public:
-  GhostJet(const I4Momentum& pFourVector) : Jet(pFourVector) {};
-
-  static double get_delta_eta(){return s_delta_eta;}
-  static double get_delta_phi(){return s_delta_phi;}
-
-  static void set_delta_eta(double eta){s_delta_eta = eta;}
-  static void set_delta_phi(double phi){s_delta_phi = phi;}
- protected:
-  static double s_delta_eta ;
-  static double s_delta_phi ;
-};
-
-#endif //JETEVENT_GHOSTJET_H
-
-
-
-
-
-
diff --git a/Reconstruction/Jet/JetEvent/src/GhostJet.cxx b/Reconstruction/Jet/JetEvent/src/GhostJet.cxx
deleted file mode 100755
index b12c5cd506b6..000000000000
--- a/Reconstruction/Jet/JetEvent/src/GhostJet.cxx
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-#include "JetEvent/GhostJet.h"
-
-double GhostJet::s_delta_eta = 0.05;
-double GhostJet::s_delta_phi = 0.05;
-
-- 
GitLab