From 16263dc8511e2fe1cfd50b96d0e528ac7898e3c7 Mon Sep 17 00:00:00 2001
From: Takahiro Shiomi <takahiro.shiomi@cern.ch>
Date: Tue, 13 Oct 2020 06:05:06 +0200
Subject: [PATCH] Changed to a smart pointer and fixed wrong sentences

---
 .../TrigT1/TrigT1TGC/TrigT1TGC/TGCDatabaseManager.h  |  6 +++---
 Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCGoodMF.h       |  2 +-
 Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCSector.h       |  2 +-
 Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCSectorLogic.h  |  4 ++--
 Trigger/TrigT1/TrigT1TGC/src/TGCDatabaseManager.cxx  |  2 +-
 Trigger/TrigT1/TrigT1TGC/src/TGCGoodMF.cxx           | 12 +++---------
 Trigger/TrigT1/TrigT1TGC/src/TGCSector.cxx           |  4 ++--
 Trigger/TrigT1/TrigT1TGC/src/TGCSectorLogic.cxx      |  5 ++---
 8 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCDatabaseManager.h b/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCDatabaseManager.h
index caaf9db446a9..b98575446bac 100644
--- a/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCDatabaseManager.h
+++ b/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCDatabaseManager.h
@@ -51,7 +51,7 @@ class TGCDatabaseManager : public AthMessaging
   const TGCEIFICoincidenceMap* getEIFICoincidenceMap(int sideId) const;
   const TGCTileMuCoincidenceMap* getTileMuCoincidenceMap() const;
   std::shared_ptr<TGCNSWCoincidenceMap> getNSWCoincidenceMap(int sideId, int octantId, int moduleId) const;
-  TGCGoodMF* getGoodMFMap() const;
+  std::shared_ptr<TGCGoodMF> getGoodMFMap() const;
 
   TGCConnectionInPP* getConnectionInPP(TGCPatchPanel* patchPanel) const;
   void addConnectionInPP(const TGCPatchPanel* patchPanel, const TGCConnectionInPP* connectionInPP);
@@ -73,7 +73,7 @@ class TGCDatabaseManager : public AthMessaging
   std::array<std::array<std::array<std::shared_ptr<TGCNSWCoincidenceMap>, NumberOfModuleInBW>, NumberOfOctant>, NumberOfSide> m_mapNSW;
   TGCConnectionPPToSL* m_PPToSL[NumberOfRegionType];
   TGCConnectionASDToPP* m_ASDToPP[NumberOfRegionType][NumberOfPatchPanelType][TotalNumForwardBackwardType];
-  TGCGoodMF* m_mapGoodMF;
+  std::shared_ptr<TGCGoodMF> m_mapGoodMF;
 
   std::map<PatchPanelIDs, std::pair<const TGCConnectionInPP, PatchPanelPointers> > m_patchPanelToConnectionInPP;
   
@@ -105,7 +105,7 @@ std::shared_ptr<TGCNSWCoincidenceMap> TGCDatabaseManager::getNSWCoincidenceMap(i
 }
 
 inline
-TGCGoodMF* TGCDatabaseManager::getGoodMFMap() const
+std::shared_ptr<TGCGoodMF> TGCDatabaseManager::getGoodMFMap() const
 {
       return m_mapGoodMF;
 }
diff --git a/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCGoodMF.h b/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCGoodMF.h
index 22a89103a88e..51b5de3e592c 100644
--- a/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCGoodMF.h
+++ b/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCGoodMF.h
@@ -31,7 +31,7 @@ class TGCArguments;
 class TGCGoodMF {
 public:
   TGCGoodMF(TGCArguments*);
-  ~TGCGoodMF();
+  ~TGCGoodMF() = default;
 
   TGCGoodMF(const TGCGoodMF& right);
   const TGCGoodMF& operator=(const TGCGoodMF& right);
diff --git a/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCSector.h b/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCSector.h
index cf31717118ec..80b0a5d7b076 100644
--- a/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCSector.h
+++ b/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCSector.h
@@ -95,7 +95,7 @@ private:
 		  const TGCEIFICoincidenceMap* mapI=0);
   void setTileMuMap(const TGCTileMuCoincidenceMap* map);
   void setNSWMap(std::shared_ptr<const TGCNSWCoincidenceMap> mapNSW);
-  void setGoodMFMap(const TGCGoodMF* mapGoodMF);
+  void setGoodMFMap(std::shared_ptr<const TGCGoodMF> mapGoodMF);
   void connectPPToSB(const TGCConnectionPPToSB* connection);
   void connectSBToHPB(const TGCConnectionSBToHPB* connection);
   void connectHPBToSL(const TGCConnectionHPBToSL* connection);
diff --git a/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCSectorLogic.h b/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCSectorLogic.h
index 00fe7a4f0236..47b9110ef11d 100644
--- a/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCSectorLogic.h
+++ b/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCSectorLogic.h
@@ -79,7 +79,7 @@ public:
 		    const TGCTileMuCoincidenceMap* mapTM);
   void setNSWMap(std::shared_ptr<const TGCNSW> nsw,
 		 std::shared_ptr<const TGCNSWCoincidenceMap> mapNSW);
-  void setGoodMFMap(const TGCGoodMF* mapGoodMF);
+  void setGoodMFMap(std::shared_ptr<const TGCGoodMF> mapGoodMF);
   void showResult(TGCSLSelectorOut* out);
  
   TGCSectorLogic(TGCArguments*, TGCRegionType regionIn, int id);
@@ -129,7 +129,7 @@ private:
   const TGCTMDB*            m_pTMDB;
   std::shared_ptr<const TGCNSW>             m_nsw;
   std::shared_ptr<const TGCNSWCoincidenceMap> m_mapNSW;
-  const TGCGoodMF*            m_mapGoodMF;
+  std::shared_ptr<const TGCGoodMF>          m_mapGoodMF;
 
   // for Run2
   TGCSLPreSelector m_preSelector; 
diff --git a/Trigger/TrigT1/TrigT1TGC/src/TGCDatabaseManager.cxx b/Trigger/TrigT1/TrigT1TGC/src/TGCDatabaseManager.cxx
index 1f773af7e557..98d8e17dbb01 100644
--- a/Trigger/TrigT1/TrigT1TGC/src/TGCDatabaseManager.cxx
+++ b/Trigger/TrigT1/TrigT1TGC/src/TGCDatabaseManager.cxx
@@ -170,7 +170,7 @@ TGCDatabaseManager::TGCDatabaseManager(TGCArguments* tgcargs,
 
   }
   if(tgcArgs()->useRun3Config()){
-    m_mapGoodMF = new TGCGoodMF(tgcArgs());
+    m_mapGoodMF.reset(new TGCGoodMF(tgcArgs()));
   }
 }
 
diff --git a/Trigger/TrigT1/TrigT1TGC/src/TGCGoodMF.cxx b/Trigger/TrigT1/TrigT1TGC/src/TGCGoodMF.cxx
index c620778d73c2..d4f87fcec116 100644
--- a/Trigger/TrigT1/TrigT1TGC/src/TGCGoodMF.cxx
+++ b/Trigger/TrigT1/TrigT1TGC/src/TGCGoodMF.cxx
@@ -42,10 +42,6 @@ TGCGoodMF::TGCGoodMF(TGCArguments* tgcargs)
   }
 }
 
-TGCGoodMF::~TGCGoodMF()
-{
-}
-
 TGCGoodMF::TGCGoodMF(const TGCGoodMF& right)
 {
   m_tgcArgs=right.m_tgcArgs;
@@ -85,14 +81,13 @@ bool TGCGoodMF::readBadMFList()
       // get BadMF list
       getline(file,buf,delimiter);
       std::istringstream cont(buf);
-      std::map<int,int> mapssc; // <SSCId,badMFId>
+      std::map<int,int> mapssc = m_mapisgoodMF[mod]; // mapssc = <SSCId,badMFId>, m_mapisgoodMF = <ModuleId,<~>>
       int badMFId;
       for(int i=0; i<=maxssc; i++) {
         cont>>badMFId;
         if(badMFId < 0) continue;
         mapssc[i] = badMFId;
       }
-      m_mapisgoodMF[mod] = mapssc; // <ModuleId,<~>>
     }
   }
   return true;
@@ -103,7 +98,7 @@ bool TGCGoodMF::test_GoodMF(int moduleId,int sscId,int RoI) const
   std::map<int, std::map<int, int> >::const_iterator itModule=m_mapisgoodMF.find(moduleId);
   if (itModule==m_mapisgoodMF.end()) return true;
 
-  std::map<int, int> mapssc = itModule->second;
+  const std::map<int, int> &mapssc = itModule->second;
   std::map<int, int>::const_iterator itSSC=mapssc.find(sscId);
   if (itSSC==mapssc.end()) return true;
 
@@ -117,8 +112,7 @@ bool TGCGoodMF::test_GoodMF(int moduleId,int sscId,int RoI) const
   if(RoI%N_RoIofSSC >= 4){ RoIId = RoI%N_RoIofSSC-4; }
   else{ RoIId = RoI%N_RoIofSSC+4; }
   
-  if(bs[RoIId]){return false;}
-  else return true;
+  return !bs[RoIId];
 }
 
 
diff --git a/Trigger/TrigT1/TrigT1TGC/src/TGCSector.cxx b/Trigger/TrigT1/TrigT1TGC/src/TGCSector.cxx
index 0cdeb71c77ba..25d5317b0088 100644
--- a/Trigger/TrigT1/TrigT1TGC/src/TGCSector.cxx
+++ b/Trigger/TrigT1/TrigT1TGC/src/TGCSector.cxx
@@ -147,7 +147,7 @@ TGCSector::TGCSector(TGCArguments* tgcargs)
     std::shared_ptr<const TGCNSWCoincidenceMap> mapNSW = db->getNSWCoincidenceMap(m_sideId, m_octantId,m_moduleId);
     setNSWMap(mapNSW);
 
-    const TGCGoodMF* mapGoodMF = db->getGoodMFMap();
+    std::shared_ptr<const TGCGoodMF> mapGoodMF = db->getGoodMFMap();
     setGoodMFMap(mapGoodMF);
 
   }
@@ -309,7 +309,7 @@ void TGCSector::setNSWMap(std::shared_ptr<const TGCNSWCoincidenceMap>  mapNSW)
   if (m_SL) m_SL->setNSWMap(m_NSW, mapNSW);
 }
 
-void TGCSector::setGoodMFMap(const TGCGoodMF* mapGoodMF)
+void TGCSector::setGoodMFMap(std::shared_ptr<const TGCGoodMF> mapGoodMF)
 {
   if (m_SL) m_SL->setGoodMFMap(mapGoodMF);
 }
diff --git a/Trigger/TrigT1/TrigT1TGC/src/TGCSectorLogic.cxx b/Trigger/TrigT1/TrigT1TGC/src/TGCSectorLogic.cxx
index 35efb8d71b41..f0d9bcaeeb20 100644
--- a/Trigger/TrigT1/TrigT1TGC/src/TGCSectorLogic.cxx
+++ b/Trigger/TrigT1/TrigT1TGC/src/TGCSectorLogic.cxx
@@ -111,11 +111,10 @@ void TGCSectorLogic::setTileMuMap(const TGCTMDB* tmdb,
   if( m_nsw == 0 || m_mapNSW == 0){tgcArgs()->set_USE_NSW(false);}
 }
 
-void TGCSectorLogic::setGoodMFMap(const TGCGoodMF* mapGoodMF)
+void TGCSectorLogic::setGoodMFMap(std::shared_ptr<const TGCGoodMF> mapGoodMF)
 {
   m_mapGoodMF = mapGoodMF;
-  if (m_mapGoodMF !=0){m_useGoodMF = true;}
-  else{m_useGoodMF = false;}
+  m_useGoodMF = m_mapGoodMF != nullptr;
 }
 
 void TGCSectorLogic::setWireHighPtBoard(int port, TGCHighPtBoard* highPtBoard)
-- 
GitLab