From 63dd270a4b491d597a3a01a1eea240fdf98e94d0 Mon Sep 17 00:00:00 2001
From: scott snyder <sss@karma>
Date: Tue, 23 Mar 2021 11:18:24 -0400
Subject: [PATCH] TBRec: Fix cppcheck warnings.

Fix cppcheck warnings + some general cleanup.
---
 .../TBRec/src/CBNTAA_BeamInstrumentation.h    | 13 ++-
 TestBeam/TBRec/src/CBNTAA_TBADCRaw.cxx        |  9 +-
 TestBeam/TBRec/src/CBNTAA_TBADCRaw.h          | 15 ++--
 TestBeam/TBRec/src/CBNTAA_TBInfo.h            | 12 +--
 TestBeam/TBRec/src/CBNTAA_TBScint.h           | 13 ++-
 TestBeam/TBRec/src/CBNTAA_TBTDCRaw.cxx        |  9 +-
 TestBeam/TBRec/src/CBNTAA_TBTDCRaw.h          | 15 ++--
 TestBeam/TBRec/src/CBNTAA_TBTPValidation.cxx  | 24 ++---
 TestBeam/TBRec/src/CBNTAA_TBTPValidation.h    |  5 +-
 TestBeam/TBRec/src/CBNTAA_TBTrack.cxx         |  4 +-
 TestBeam/TBRec/src/CBNTAA_TBTrack.h           | 13 ++-
 TestBeam/TBRec/src/CBNT_BeamInstrumentation.h | 14 ++-
 TestBeam/TBRec/src/CBNT_CaloH6.h              |  2 -
 TestBeam/TBRec/src/CBNT_TBRecBase.h           | 20 ++---
 TestBeam/TBRec/src/CBNT_Timing.cxx            | 58 +++++-------
 TestBeam/TBRec/src/CBNT_Timing.h              | 17 ++--
 TestBeam/TBRec/src/CBNT_UpstreamMat.cxx       | 28 ++----
 TestBeam/TBRec/src/CBNT_UpstreamMat.h         | 12 ++-
 TestBeam/TBRec/src/TBAlgoSequencer.cxx        | 27 +++---
 TestBeam/TBRec/src/TBAlgoSequencer.h          | 10 +--
 TestBeam/TBRec/src/TBBPCRec.h                 | 10 +--
 TestBeam/TBRec/src/TBBeamQuality.cxx          | 39 ++++----
 TestBeam/TBRec/src/TBBeamQuality.h            |  8 +-
 .../TBRec/src/TBBeamQualityDoubleHitsTool.cxx | 82 +++++++----------
 .../TBRec/src/TBBeamQualityDoubleHitsTool.h   |  7 +-
 .../TBRec/src/TBBeamQualityEMFractionTool.cxx | 22 ++---
 .../TBRec/src/TBBeamQualityEMFractionTool.h   |  6 +-
 TestBeam/TBRec/src/TBBeamQualityMC.h          | 10 +--
 .../TBRec/src/TBBeamQualityMuonToolH6.cxx     | 76 +++++++---------
 TestBeam/TBRec/src/TBBeamQualityMuonToolH6.h  |  8 +-
 TestBeam/TBRec/src/TBBeamQualityTool.cxx      |  6 +-
 TestBeam/TBRec/src/TBBeamQualityTool.h        |  8 +-
 .../TBRec/src/TBBeamQualityTrackingTool.cxx   | 56 ++++--------
 .../TBRec/src/TBBeamQualityTrackingTool.h     |  8 +-
 .../TBRec/src/TBCellContainerFillerTool.cxx   |  4 +-
 TestBeam/TBRec/src/TBCellNoiseCorrection.cxx  | 42 +++++----
 TestBeam/TBRec/src/TBCellNoiseCorrection.h    |  3 +-
 TestBeam/TBRec/src/TBDMContainerSplitter.cxx  | 10 +--
 TestBeam/TBRec/src/TBDMContainerSplitter.h    |  8 +-
 .../TBRec/src/TBECLArRawChannelBuilder.cxx    | 12 ++-
 TestBeam/TBRec/src/TBECLArRawChannelBuilder.h |  8 +-
 TestBeam/TBRec/src/TBEMECXTalkToyModel.cxx    | 35 +++-----
 .../TBRec/src/TBEventInfoStreamerTool.cxx     |  8 +-
 TestBeam/TBRec/src/TBEventInfoStreamerTool.h  |  6 +-
 TestBeam/TBRec/src/TBEventStreamer.cxx        | 38 ++++----
 TestBeam/TBRec/src/TBEventStreamer.h          | 10 +--
 TestBeam/TBRec/src/TBEventStreamerTool.h      |  4 +-
 .../TBRec/src/TBExtrapolTrackToCaloTool.h     | 12 +--
 TestBeam/TBRec/src/TBLArRawChannelBuilder.h   | 11 +--
 TestBeam/TBRec/src/TBMWPCRec.cxx              |  7 +-
 TestBeam/TBRec/src/TBMWPCRec.h                | 11 ++-
 TestBeam/TBRec/src/TBNoiseWrite.cxx           |  6 +-
 TestBeam/TBRec/src/TBNoiseWrite.h             | 11 +--
 TestBeam/TBRec/src/TBPartIDCherenkovMuTag.cxx | 20 ++---
 TestBeam/TBRec/src/TBPartIDCherenkovMuTag.h   | 10 +--
 .../TBRec/src/TBPatternUnitStreamerTool.cxx   | 16 ++--
 .../TBRec/src/TBPatternUnitStreamerTool.h     |  6 +-
 .../TBRec/src/TBPatternUnitStreamerToolH8.cxx | 14 ++-
 .../TBRec/src/TBPatternUnitStreamerToolH8.h   |  6 +-
 TestBeam/TBRec/src/TBPhaseRec.cxx             |  5 +-
 TestBeam/TBRec/src/TBPhaseRec.h               | 10 +--
 TestBeam/TBRec/src/TBPhaseStreamerTool.cxx    | 10 +--
 TestBeam/TBRec/src/TBPhaseStreamerTool.h      | 10 +--
 TestBeam/TBRec/src/TBPlaneTrackingAlgo.cxx    | 54 ++++-------
 TestBeam/TBRec/src/TBPlaneTrackingAlgo.h      | 10 +--
 TestBeam/TBRec/src/TBPreScalerStreamerTool.h  |  6 +-
 TestBeam/TBRec/src/TBScintillatorRec.h        | 12 ++-
 TestBeam/TBRec/src/TBTailCatcherRec.h         | 11 ++-
 TestBeam/TBRec/src/TBTrackInfoFromTag.h       | 10 +--
 TestBeam/TBRec/src/TBTrackToCaloAlg.h         | 10 +--
 TestBeam/TBRec/src/TBTree_CaloClusterH6.h     |  6 +-
 TestBeam/TBRec/src/TBXCryYTableRead.h         |  8 +-
 .../TBRec/src/TBXMLCaloCellWriterTool.cxx     | 55 ++++++------
 TestBeam/TBRec/src/TBXMLWriter.cxx            | 90 +++----------------
 TestBeam/TBRec/src/TBXMLWriter.h              |  8 +-
 75 files changed, 508 insertions(+), 791 deletions(-)

diff --git a/TestBeam/TBRec/src/CBNTAA_BeamInstrumentation.h b/TestBeam/TBRec/src/CBNTAA_BeamInstrumentation.h
index bc824fbb86c3..777ecd95dac3 100644
--- a/TestBeam/TBRec/src/CBNTAA_BeamInstrumentation.h
+++ b/TestBeam/TBRec/src/CBNTAA_BeamInstrumentation.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_CBNTAA_BEAMINSTRUMENTATION_H
@@ -10,19 +10,18 @@
 #include <string>
 #include <vector>
 
-class StoreGateSvc;
 
 class CBNTAA_BeamInstrumentation : public CBNT_TBRecBase
 {
  public:
   CBNTAA_BeamInstrumentation(const std::string & name, ISvcLocator * pSvcLocator);
 
-  ~CBNTAA_BeamInstrumentation();
+  virtual ~CBNTAA_BeamInstrumentation();
 
   //standart algorithm methods
-  virtual StatusCode CBNT_initialize();
-  virtual StatusCode CBNT_execute();
-  virtual StatusCode CBNT_finalize();
+  virtual StatusCode CBNT_initialize() override;
+  virtual StatusCode CBNT_execute() override;
+  virtual StatusCode CBNT_finalize() override;
 
  private:
 
@@ -56,7 +55,7 @@ class CBNTAA_BeamInstrumentation : public CBNT_TBRecBase
   //but omitts characters that are problematic for root like -+:*/
   std::string add_name(const char* base, const std::string extension);
 
-  StatusCode CBNT_clear();
+  virtual StatusCode CBNT_clear() override;
 };
 
 #endif
diff --git a/TestBeam/TBRec/src/CBNTAA_TBADCRaw.cxx b/TestBeam/TBRec/src/CBNTAA_TBADCRaw.cxx
index 736f13869e74..89181ada463d 100644
--- a/TestBeam/TBRec/src/CBNTAA_TBADCRaw.cxx
+++ b/TestBeam/TBRec/src/CBNTAA_TBADCRaw.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "CBNTAA_TBADCRaw.h"
@@ -49,10 +49,7 @@ StatusCode CBNTAA_TBADCRaw::CBNT_execute()
       m_adc->resize(nADC);
 
       unsigned NtupleVectorIndex = 0;
-      TBADCRawCont::const_iterator it_adc = adcCont->begin();
-      TBADCRawCont::const_iterator last_adc = adcCont->end();
-      for(;it_adc!=last_adc;it_adc++,NtupleVectorIndex++) {
-        const TBADCRaw * adc = (*it_adc);
+      for (const TBADCRaw* adc : *adcCont) {
         (*m_adc)[NtupleVectorIndex] = adc->getADC();
       }
     }
@@ -74,7 +71,7 @@ StatusCode CBNTAA_TBADCRaw::CBNT_finalize()
   return StatusCode::SUCCESS;
 }
 
-std::string CBNTAA_TBADCRaw::add_name(const char* base, const std::string extension) {
+std::string CBNTAA_TBADCRaw::add_name(const char* base, const std::string& extension) {
   std::string retval(base);
   for (unsigned i=0;i<extension.size();i++) {
     const char& ch=extension[i];
diff --git a/TestBeam/TBRec/src/CBNTAA_TBADCRaw.h b/TestBeam/TBRec/src/CBNTAA_TBADCRaw.h
index 836c4b894247..39ecc1142a78 100644
--- a/TestBeam/TBRec/src/CBNTAA_TBADCRaw.h
+++ b/TestBeam/TBRec/src/CBNTAA_TBADCRaw.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_CBNTAA_TBADCRAW_H
@@ -12,7 +12,6 @@
 #include <string>
 #include <vector>
 
-class StoreGateSvc;
 
 /** @class CBNTAA_TBADCRaw CBNTAA_TBADCRaw.h "TBRec/CBNTAA_TBADCRaw.h"
 ntpl-dumper for TBEvent/TBADCRaw.h.
@@ -24,12 +23,12 @@ class CBNTAA_TBADCRaw : public CBNT_TBRecBase
  public:
   CBNTAA_TBADCRaw(const std::string & name, ISvcLocator * pSvcLocator);
 
-  ~CBNTAA_TBADCRaw();
+  virtual ~CBNTAA_TBADCRaw();
 
   //standart algorithm methods
-  virtual StatusCode CBNT_initialize();
-  virtual StatusCode CBNT_execute();
-  virtual StatusCode CBNT_finalize();
+  virtual StatusCode CBNT_initialize() override;
+  virtual StatusCode CBNT_execute() override;
+  virtual StatusCode CBNT_finalize() override;
 
  private:
 
@@ -40,9 +39,9 @@ class CBNTAA_TBADCRaw : public CBNT_TBRecBase
 
   //Private function to build names for ntuple entries. Concatinates strings
   //but omits characters that are problematic for root like -+:*/
-  std::string add_name(const char* base, const std::string extension);
+  std::string add_name(const char* base, const std::string& extension);
 
-  StatusCode CBNT_clear();
+  virtual StatusCode CBNT_clear() override;
 };
 
 #endif
diff --git a/TestBeam/TBRec/src/CBNTAA_TBInfo.h b/TestBeam/TBRec/src/CBNTAA_TBInfo.h
index 3e06d50bcca4..cf6bd5505a00 100644
--- a/TestBeam/TBRec/src/CBNTAA_TBInfo.h
+++ b/TestBeam/TBRec/src/CBNTAA_TBInfo.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_CBNTAA_TBINFO_H
@@ -13,10 +13,10 @@ class TBCondRunParTool;
 class CBNTAA_TBInfo : public CBNT_TBRecBase {
 public:
 	CBNTAA_TBInfo(const std::string &name, ISvcLocator *pSvcLocator);
-        ~CBNTAA_TBInfo();
-	virtual StatusCode CBNT_initialize();
-	virtual StatusCode CBNT_execute();
-	virtual StatusCode CBNT_finalize();
+        virtual ~CBNTAA_TBInfo();
+	virtual StatusCode CBNT_initialize() override;
+	virtual StatusCode CBNT_execute() override;
+	virtual StatusCode CBNT_finalize() override;
 
 private:
 	float GetEnergy(float CurrB3, float CurrB4);
@@ -80,7 +80,7 @@ private:
 	float      m_sycLoss;
 	float      m_errSycLoss;
 
-        StatusCode CBNT_clear();
+        virtual StatusCode CBNT_clear() override;
 };
 
 #endif // CBNT_EVENTINFO_H
diff --git a/TestBeam/TBRec/src/CBNTAA_TBScint.h b/TestBeam/TBRec/src/CBNTAA_TBScint.h
index 730afc207fe7..6050745b63c3 100644
--- a/TestBeam/TBRec/src/CBNTAA_TBScint.h
+++ b/TestBeam/TBRec/src/CBNTAA_TBScint.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_CBNTAA_TBSCINT_H
@@ -12,18 +12,17 @@
 #include <string>
 #include <vector>
 
-class StoreGateSvc;
 
 class CBNTAA_TBScint : public CBNT_TBRecBase
 {
  public:
   CBNTAA_TBScint(const std::string & name, ISvcLocator * pSvcLocator);
 
-  ~CBNTAA_TBScint() {};
+  virtual ~CBNTAA_TBScint() {};
 
-  virtual StatusCode CBNT_initialize();
-  virtual StatusCode CBNT_execute();
-  virtual StatusCode CBNT_finalize();
+  virtual StatusCode CBNT_initialize() override;
+  virtual StatusCode CBNT_execute() override;
+  virtual StatusCode CBNT_finalize() override;
 
  private:
 
@@ -33,7 +32,7 @@ class CBNTAA_TBScint : public CBNT_TBRecBase
   std::vector<int> *m_scint_trackid; 
   std::vector<int> *m_scint_pdg; 
 
-  StatusCode CBNT_clear();
+  virtual StatusCode CBNT_clear() override;
 };
 
 #endif
diff --git a/TestBeam/TBRec/src/CBNTAA_TBTDCRaw.cxx b/TestBeam/TBRec/src/CBNTAA_TBTDCRaw.cxx
index c61cd95d7bdf..b01785532177 100644
--- a/TestBeam/TBRec/src/CBNTAA_TBTDCRaw.cxx
+++ b/TestBeam/TBRec/src/CBNTAA_TBTDCRaw.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "CBNTAA_TBTDCRaw.h"
@@ -55,10 +55,7 @@ StatusCode CBNTAA_TBTDCRaw::CBNT_execute()
       m_underThreshold->resize(nTDC);
 
       unsigned NtupleVectorIndex = 0;
-      TBTDCRawCont::const_iterator it_tdc = tdcCont->begin();
-      TBTDCRawCont::const_iterator last_tdc = tdcCont->end();
-      for(;it_tdc!=last_tdc;it_tdc++,NtupleVectorIndex++) {
-        const TBTDCRaw * tdc = (*it_tdc);
+      for (const TBTDCRaw* tdc : *tdcCont) {
         (*m_tdc)[NtupleVectorIndex] = tdc->getTDC();
         (*m_underThreshold)[NtupleVectorIndex] = tdc->isUnderThreshold();
       }
@@ -83,7 +80,7 @@ StatusCode CBNTAA_TBTDCRaw::CBNT_finalize()
   return StatusCode::SUCCESS;
 }
 
-std::string CBNTAA_TBTDCRaw::add_name(const char* base, const std::string extension) {
+std::string CBNTAA_TBTDCRaw::add_name(const char* base, const std::string& extension) {
   std::string retval(base);
   for (unsigned i=0;i<extension.size();i++) {
     const char& ch=extension[i];
diff --git a/TestBeam/TBRec/src/CBNTAA_TBTDCRaw.h b/TestBeam/TBRec/src/CBNTAA_TBTDCRaw.h
index 9e7d267d68a2..db38d9284ad2 100644
--- a/TestBeam/TBRec/src/CBNTAA_TBTDCRaw.h
+++ b/TestBeam/TBRec/src/CBNTAA_TBTDCRaw.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_CBNTAA_TBTDCRAW_H
@@ -12,7 +12,6 @@
 #include <string>
 #include <vector>
 
-class StoreGateSvc;
 
 /** @class CBNTAA_TBTDCRaw CBNTAA_TBTDCRaw.h "TBRec/CBNTAA_TBTDCRaw.h"
 ntpl-dumper for TBEvent/TBTDCRaw.h.
@@ -24,12 +23,12 @@ class CBNTAA_TBTDCRaw : public CBNT_TBRecBase
  public:
   CBNTAA_TBTDCRaw(const std::string & name, ISvcLocator * pSvcLocator);
 
-  ~CBNTAA_TBTDCRaw();
+  virtual ~CBNTAA_TBTDCRaw();
 
   //standart algorithm methods
-  virtual StatusCode CBNT_initialize();
-  virtual StatusCode CBNT_execute();
-  virtual StatusCode CBNT_finalize();
+  virtual StatusCode CBNT_initialize() override;
+  virtual StatusCode CBNT_execute() override;
+  virtual StatusCode CBNT_finalize() override;
 
  private:
 
@@ -41,9 +40,9 @@ class CBNTAA_TBTDCRaw : public CBNT_TBRecBase
 
   //Private function to build names for ntuple entries. Concatinates strings
   //but omits characters that are problematic for root like -+:*/
-  std::string add_name(const char* base, const std::string extension);
+  std::string add_name(const char* base, const std::string& extension);
 
-  StatusCode CBNT_clear();
+  virtual StatusCode CBNT_clear() override;
 };
 
 #endif
diff --git a/TestBeam/TBRec/src/CBNTAA_TBTPValidation.cxx b/TestBeam/TBRec/src/CBNTAA_TBTPValidation.cxx
index 2300e08b95f4..0be6ae39851e 100644
--- a/TestBeam/TBRec/src/CBNTAA_TBTPValidation.cxx
+++ b/TestBeam/TBRec/src/CBNTAA_TBTPValidation.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "CBNTAA_TBTPValidation.h"
@@ -342,10 +342,7 @@ StatusCode CBNTAA_TBTPValidation::CBNT_execute()
     m_overflow_TBADCRawCont->resize(nADC);
 
     unsigned NtupleVectorIndex = 0;
-    TBADCRawCont::const_iterator it_adc   = adcCont->begin();
-    TBADCRawCont::const_iterator last_adc = adcCont->end();
-    for(;it_adc!=last_adc;it_adc++,NtupleVectorIndex++) {
-      const TBADCRaw * adc = (*it_adc);
+    for (const TBADCRaw* adc : *adcCont) {
       (*m_adc)[NtupleVectorIndex]                          = adc-> getADC();
       (*m_tbDetectorName_TBADCRawCont)[NtupleVectorIndex]  = adc-> getDetectorName();	
       (*m_overflow_TBADCRawCont)[NtupleVectorIndex]        = adc-> isOverflow();
@@ -369,10 +366,7 @@ StatusCode CBNTAA_TBTPValidation::CBNT_execute()
     m_overflow_TBTDCRawCont->resize(nTDC);
 
     unsigned NtupleVectorIndex = 0;
-    TBTDCRawCont::const_iterator it_tdc   = tdcCont->begin();
-    TBTDCRawCont::const_iterator last_tdc = tdcCont->end();
-    for(;it_tdc!=last_tdc;it_tdc++,NtupleVectorIndex++) {
-      const TBTDCRaw * tdc = (*it_tdc);
+    for (const TBTDCRaw* tdc : *tdcCont) {
       (*m_tdc_raw)[NtupleVectorIndex]                      = tdc-> getTDC();
       (*m_underThreshold_raw)[NtupleVectorIndex]           = tdc-> isUnderThreshold();
       (*m_tbDetectorName_TBTDCRawCont)[NtupleVectorIndex]  = tdc-> getDetectorName();
@@ -458,10 +452,7 @@ StatusCode CBNTAA_TBTPValidation::CBNT_execute()
     m_overflow_TBBPCCont        ->resize(nBPCCont);
      
     unsigned NtupleVectorIndex = 0;
-    TBBPCCont::const_iterator it_TBBPCCont  = BPCCont->begin();
-    TBBPCCont::const_iterator last_BBPCCont = BPCCont->end();
-    for(;it_TBBPCCont!=last_BBPCCont;it_TBBPCCont++,NtupleVectorIndex++) {
-       const TBBPC * bpc = (*it_TBBPCCont);
+    for (const TBBPC* bpc : *BPCCont) {
      	(*m_xPos)[NtupleVectorIndex]                      = bpc-> getXPos();
      	(*m_yPos)[NtupleVectorIndex]                      = bpc-> getYPos();
      	(*m_xErr)[NtupleVectorIndex]                      = bpc-> getXErr();
@@ -498,10 +489,7 @@ StatusCode CBNTAA_TBTPValidation::CBNT_execute()
       m_samples->reserve( ( (*(LArDigitContainer->begin()))->nsamples() ) * nLArDigits);
 
     unsigned NtupleVectorIndex = 0;
-    TBLArDigitContainer::const_iterator it_LArDigitContainer   = LArDigitContainer->begin();
-    TBLArDigitContainer::const_iterator last_LArDigitContainer = LArDigitContainer->end();
-    for(;it_LArDigitContainer!=last_LArDigitContainer;it_LArDigitContainer++,NtupleVectorIndex++) {
-      const LArDigit * larDigit = (*it_LArDigitContainer);
+    for (const LArDigit* larDigit : *LArDigitContainer) {
       (*m_channelID)[NtupleVectorIndex] = larDigit->hardwareID().get_identifier32().get_compact() ;
       (*m_gain)[NtupleVectorIndex] = (unsigned char)larDigit->gain();
 
@@ -834,7 +822,7 @@ StatusCode CBNTAA_TBTPValidation::CBNT_finalize()
   return StatusCode::SUCCESS;
 }
 
-std::string CBNTAA_TBTPValidation::add_name(const char* base, const std::string extension) {
+std::string CBNTAA_TBTPValidation::add_name(const char* base, const std::string& extension) {
   std::string retval(base);
   for (unsigned i=0;i<extension.size();i++) {
     const char& ch=extension[i];
diff --git a/TestBeam/TBRec/src/CBNTAA_TBTPValidation.h b/TestBeam/TBRec/src/CBNTAA_TBTPValidation.h
index 0b620e90f3a9..592ae5454f28 100644
--- a/TestBeam/TBRec/src/CBNTAA_TBTPValidation.h
+++ b/TestBeam/TBRec/src/CBNTAA_TBTPValidation.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_CBNTAA_TBTPVALIDATION_H
@@ -12,7 +12,6 @@
 #include <string>
 #include <vector>
 
-class StoreGateSvc;
 
 /** @class CBNTAA_TBTPValidation CBNTAA_TBTPValidation.h "TBRec/CBNTAA_TBTPValidation.h"
 ntpl-dumper for all persistified TB classes.
@@ -126,7 +125,7 @@ class CBNTAA_TBTPValidation : public CBNT_TBRecBase
 
   //Private function to build names for ntuple entries. Concatinates strings
   //but omitts characters that are problematic for root like -+:*/
-  std::string add_name(const char* base, const std::string extension);
+  std::string add_name(const char* base, const std::string& extension);
 
   StatusCode CBNT_clear();
 };
diff --git a/TestBeam/TBRec/src/CBNTAA_TBTrack.cxx b/TestBeam/TBRec/src/CBNTAA_TBTrack.cxx
index c799eafd540b..366aad4234c3 100644
--- a/TestBeam/TBRec/src/CBNTAA_TBTrack.cxx
+++ b/TestBeam/TBRec/src/CBNTAA_TBTrack.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "CBNTAA_TBTrack.h"
@@ -101,7 +101,7 @@ StatusCode CBNTAA_TBTrack::CBNT_finalize() {
   return StatusCode::SUCCESS;
 }
 
-std::string CBNTAA_TBTrack::add_name(const char* base, const std::string extension) {
+std::string CBNTAA_TBTrack::add_name(const char* base, const std::string& extension) {
   std::string retval(base);
   for (unsigned i=0;i<extension.size();i++) {
     const char& ch=extension[i];
diff --git a/TestBeam/TBRec/src/CBNTAA_TBTrack.h b/TestBeam/TBRec/src/CBNTAA_TBTrack.h
index 6d46a2593869..b2628b22a5fc 100644
--- a/TestBeam/TBRec/src/CBNTAA_TBTrack.h
+++ b/TestBeam/TBRec/src/CBNTAA_TBTrack.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_CBNTAA_TBTRACK_H
@@ -11,18 +11,17 @@
 #include <fstream>
 #include <string>
 
-class StoreGateSvc;
 
 class CBNTAA_TBTrack : public CBNT_TBRecBase
 {
  public:
   CBNTAA_TBTrack(const std::string & name, ISvcLocator * pSvcLocator);
 
-  ~CBNTAA_TBTrack() {};
+  virtual ~CBNTAA_TBTrack() {};
 
-  virtual StatusCode CBNT_initialize();
-  virtual StatusCode CBNT_execute();
-  virtual StatusCode CBNT_finalize();
+  virtual StatusCode CBNT_initialize() override;
+  virtual StatusCode CBNT_execute() override;
+  virtual StatusCode CBNT_finalize() override;
 
  private:
   // by A. Mineanko
@@ -44,7 +43,7 @@ class CBNTAA_TBTrack : public CBNT_TBRecBase
   // taken from CBNTAA_BeamInstrumentation
   //Private function to build names for ntuple entries. Concatinates strings
   //but omitts characters that are problematic for root like -+:*/
-  std::string add_name(const char* base, const std::string extension);
+  std::string add_name(const char* base, const std::string& extension);
 };
 
 #endif
diff --git a/TestBeam/TBRec/src/CBNT_BeamInstrumentation.h b/TestBeam/TBRec/src/CBNT_BeamInstrumentation.h
index c44a17a89069..ca0f032b7ede 100644
--- a/TestBeam/TBRec/src/CBNT_BeamInstrumentation.h
+++ b/TestBeam/TBRec/src/CBNT_BeamInstrumentation.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_CBNT_BEAM_H
@@ -9,21 +9,19 @@
 #include <fstream>
 #include <string>
 
-class StoreGateSvc;
-
 class CBNT_BeamInstrumentation : public CBNT_TBRecBase
 {
  public:
   CBNT_BeamInstrumentation(const std::string & name, ISvcLocator * pSvcLocator);
 
-  ~CBNT_BeamInstrumentation();
+  virtual ~CBNT_BeamInstrumentation();
 
   //standart algorithm methods
-  virtual StatusCode CBNT_initialize();
-  virtual StatusCode CBNT_execute();
-  virtual StatusCode CBNT_finalize();
+  virtual StatusCode CBNT_initialize() override;
+  virtual StatusCode CBNT_execute() override;
+  virtual StatusCode CBNT_finalize() override;
 
-  virtual StatusCode CBNT_clear();
+  virtual StatusCode CBNT_clear() override;
  private:
 
   bool m_neverReturnFailure;   // controls when StatusCode::FAILURE can be issued in execute()
diff --git a/TestBeam/TBRec/src/CBNT_CaloH6.h b/TestBeam/TBRec/src/CBNT_CaloH6.h
index 631e2faae47f..def2a9cceaec 100644
--- a/TestBeam/TBRec/src/CBNT_CaloH6.h
+++ b/TestBeam/TBRec/src/CBNT_CaloH6.h
@@ -30,8 +30,6 @@
 #include <string>
 #include <vector>
 
-class StoreGateSvc;
-
 class CBNT_CaloH6 : public CBNT_TBRecBase
 {
  public:
diff --git a/TestBeam/TBRec/src/CBNT_TBRecBase.h b/TestBeam/TBRec/src/CBNT_TBRecBase.h
index 79986be6b88f..dfb4f645d3ea 100644
--- a/TestBeam/TBRec/src/CBNT_TBRecBase.h
+++ b/TestBeam/TBRec/src/CBNT_TBRecBase.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //Dear emacs, this is -*-c++-*-
@@ -22,19 +22,19 @@ class CBNT_TBRecBase : public AthAlgorithm {
 
  public:
   CBNT_TBRecBase(const std::string & name, ISvcLocator * pSvcLocator);
-  ~CBNT_TBRecBase();
+  virtual ~CBNT_TBRecBase();
 
   //Standard algo methods
-  StatusCode initialize();
-  StatusCode execute();
-  StatusCode finalize();
-  StatusCode pre_execute();
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
+  virtual StatusCode pre_execute();
 
   //These needs to be implemented by the deriving class
-  virtual StatusCode CBNT_initialize(){return StatusCode::SUCCESS;}
-  virtual StatusCode CBNT_execute(){return StatusCode::SUCCESS;}
-  virtual StatusCode CBNT_finalize(){return StatusCode::SUCCESS;}
-  virtual StatusCode CBNT_clear(){return StatusCode::SUCCESS;}
+  virtual StatusCode CBNT_initialize() {return StatusCode::SUCCESS;}
+  virtual StatusCode CBNT_execute() {return StatusCode::SUCCESS;}
+  virtual StatusCode CBNT_finalize() {return StatusCode::SUCCESS;}
+  virtual StatusCode CBNT_clear() {return StatusCode::SUCCESS;}
 
  private:
   bool m_initialized;
diff --git a/TestBeam/TBRec/src/CBNT_Timing.cxx b/TestBeam/TBRec/src/CBNT_Timing.cxx
index 439e7572b11f..d7abecec97d4 100644
--- a/TestBeam/TBRec/src/CBNT_Timing.cxx
+++ b/TestBeam/TBRec/src/CBNT_Timing.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "CBNT_Timing.h"
@@ -26,7 +26,6 @@ using Athena::Units::ns;
 CBNT_Timing::CBNT_Timing(const std::string & name, ISvcLocator * pSvcLocator)
   :CBNT_TBRecBase(name, pSvcLocator)
    , m_onlineHelper(0)
-   , m_emId(0)
    , m_energy_cut(2.*GeV)
    , m_first_event(true)
    , m_caloCellName("AllCalo")
@@ -64,10 +63,6 @@ StatusCode CBNT_Timing::CBNT_initialize() {
 
   ATH_MSG_DEBUG  ( "CBNT_Timing in initialize()" );
 
-  const CaloCell_ID* idHelper = nullptr;
-  ATH_CHECK( detStore()->retrieve (idHelper, "CaloCell_ID") );
-  m_emId=idHelper->em_idHelper();
-
   ATH_CHECK( m_cablingKey.initialize() );
   ATH_CHECK( detStore()->retrieve(m_onlineHelper, "LArOnlineID") );
 
@@ -95,20 +90,18 @@ StatusCode CBNT_Timing::CBNT_initialize() {
 
   // get calorimeter samplings ids for the requested samplings
   msg() << MSG::INFO << "Included calorimeter samplings: ";
-  for (std::vector<std::string>::const_iterator sampling = m_sampling_names.begin(); sampling != m_sampling_names.end(); sampling++) {
-    //    CaloSampling::CaloSample idSamp = CaloSamplingHelper::getSamplingId(*sampling);
-    CaloSampling::CaloSample idSamp = m_samplingFromNameLookup[*sampling];
+  for (const std::string& sampling : m_sampling_names) {
+    CaloSampling::CaloSample idSamp = m_samplingFromNameLookup[sampling];
     if (idSamp != CaloSampling::Unknown) {
       m_samplingIndices.push_back(idSamp);
-      msg() << MSG::INFO << "\042" << *sampling
+      msg() << MSG::INFO << "\042" << sampling
              << "\042 ";
     }
   }
   msg() << MSG::INFO << endmsg;
 
   // get an idCalo keyed map of vectors of idSample for the requested samplings
-  for (std::vector<CaloSampling::CaloSample>::iterator sample = m_samplingIndices.begin(); sample != m_samplingIndices.end(); sample++) {
-    CaloSampling::CaloSample idSample = *sample;
+  for (CaloSampling::CaloSample idSample : m_samplingIndices) {
     // find the idCalo 
     CaloCell_ID::SUBCALO idCalo = m_caloLookup[idSample];
     // build the vector of idSample
@@ -117,20 +110,17 @@ StatusCode CBNT_Timing::CBNT_initialize() {
     m_calosAndSamplings[idCalo] = samplingV;
   }
   // printout
-  std::map< CaloCell_ID::SUBCALO, std::vector<CaloSampling::CaloSample> >::iterator it = m_calosAndSamplings.begin();
-  for (; it != m_calosAndSamplings.end(); it++) {
-    CaloCell_ID::SUBCALO idCalo = it->first;
+  for (const auto& p : m_calosAndSamplings) {
+    CaloCell_ID::SUBCALO idCalo = p.first;
     msg() << MSG::INFO
            << "Included calorimeter : \042"
            << m_caloToNameLookup[idCalo]
            << "\042 samplings:";
-    std::vector<CaloSampling::CaloSample> samplingV = it->second;
-    std::vector<CaloSampling::CaloSample>::iterator sample     = samplingV.begin();
-    std::vector<CaloSampling::CaloSample>::iterator lastSample = samplingV.end();
-    for (; sample != lastSample; sample++) {
+    const std::vector<CaloSampling::CaloSample>& samplingV = p.second;
+    for (CaloSampling::CaloSample sample : samplingV) {
       msg() << MSG::INFO
              << " \042"
-             << m_samplingToNameLookup[*sample]
+             << m_samplingToNameLookup[sample]
              << "\042";
     }
     msg()  << MSG::INFO << endmsg;
@@ -174,14 +164,13 @@ StatusCode CBNT_Timing::CBNT_execute()
 
     // find all febID's related to the requested samplings
     // loop over desired calorimeter modules first, more efficient this way
-    std::map< CaloCell_ID::SUBCALO, std::vector<CaloSampling::CaloSample> >::iterator it = m_calosAndSamplings.begin();
-    for (; it != m_calosAndSamplings.end(); it++) {
-      CaloCell_ID::SUBCALO idCalo = it->first;
-      std::vector<CaloSampling::CaloSample> samplingV = it->second;
+    for (const auto& p : m_calosAndSamplings) {
+      CaloCell_ID::SUBCALO idCalo = p.first;
+      std::vector<CaloSampling::CaloSample> samplingV = p.second;
 
       // loop over the corresponding CaloCell's
       for (CaloCellContainer::const_iterator cell = cellContainer->beginConstCalo(idCalo);
-           cell != cellContainer->endConstCalo(idCalo); cell++) {
+           cell != cellContainer->endConstCalo(idCalo); ++cell) {
 
         // get the corresponding sample
         CaloSampling::CaloSample idSample;
@@ -209,9 +198,9 @@ StatusCode CBNT_Timing::CBNT_execute()
     }
     // print out
     msg() << MSG::INFO << "FEB IDs: ";
-    for (std::vector<HWIdentifier>::iterator it_febID = m_febIDs.begin(); it_febID != m_febIDs.end(); it_febID++) {
+    for (HWIdentifier febID : m_febIDs) {
       std::ostringstream os; 
-      os << std::hex << *it_febID;
+      os << std::hex << febID;
       msg() << MSG::INFO << " \042" << os.str() << "\042";
     }
     msg() << MSG::INFO << endmsg;
@@ -232,20 +221,19 @@ StatusCode CBNT_Timing::CBNT_execute()
 
   // fill energy weighted time stores
   // loop over desired calorimeter modules first, more efficient this way
-  std::map< CaloCell_ID::SUBCALO, std::vector<CaloSampling::CaloSample> >::iterator it = m_calosAndSamplings.begin();
   m_energy = 0;
 
-  for (; it != m_calosAndSamplings.end(); it++) {
-    CaloCell_ID::SUBCALO idCalo = it->first;
+  for (const auto& p : m_calosAndSamplings) {
+    CaloCell_ID::SUBCALO idCalo = p.first;
     ATH_MSG_DEBUG
       ( "Looping over CaloCells of calorimeter : \042"
         << m_caloToNameLookup[idCalo]
         << "\042" );
-    std::vector<CaloSampling::CaloSample> samplingV = it->second;
+    std::vector<CaloSampling::CaloSample> samplingV = p.second;
 
     // loop over the corresponding CaloCell's
     for (CaloCellContainer::const_iterator cell = cellContainer->beginConstCalo(idCalo);
-         cell != cellContainer->endConstCalo(idCalo); cell++) {
+         cell != cellContainer->endConstCalo(idCalo); ++cell) {
 
       // get the corresponding sample
       //CaloSampling::CaloSample idSample = CaloSampling::getSampling(**cell);
@@ -324,8 +312,7 @@ StatusCode CBNT_Timing::CBNT_execute()
   }
 
   // fill energy weighted cubic peaking time for each requested sampling
-  for (std::vector<CaloSampling::CaloSample>::iterator sample = m_samplingIndices.begin(); sample != m_samplingIndices.end(); sample++) {
-    CaloSampling::CaloSample idSample = *sample;
+  for (CaloSampling::CaloSample idSample : m_samplingIndices) {
     // go on only if there is data stored for this sample:
     //if (sumEPerSampling.find(idSample) != sumEPerSampling.end()) {
       double peakTime = (sumEPerSampling[idSample] > 0.) ? sumETimePerSampling[idSample]/sumEPerSampling[idSample] : NOTIME;
@@ -335,8 +322,7 @@ StatusCode CBNT_Timing::CBNT_execute()
   }
 
   // fill energy weighted cubic peaking time for each requested FEB
-  for (std::vector<HWIdentifier>::iterator it_febID = m_febIDs.begin(); it_febID != m_febIDs.end(); it_febID++) {
-      HWIdentifier febID = *it_febID;
+  for (HWIdentifier febID : m_febIDs) {
     // go on only if there is data stored for this febID
     //if (sumEPerFeb.find(febID) != sumEPerFeb.end()) {
       double peakTime = (sumEPerFeb[febID] > 0.) ? sumETimePerFeb[febID]/sumEPerFeb[febID] : NOTIME;
diff --git a/TestBeam/TBRec/src/CBNT_Timing.h b/TestBeam/TBRec/src/CBNT_Timing.h
index 069ce8ccac86..f5a4c9f0207e 100644
--- a/TestBeam/TBRec/src/CBNT_Timing.h
+++ b/TestBeam/TBRec/src/CBNT_Timing.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_CBNT_TIMING_H
@@ -13,26 +13,24 @@
 #include "CaloIdentifier/LArEM_ID.h"
  #include "LArCabling/LArOnOffIdMapping.h"
 
-class StoreGateSvc;
 class LArOnlineID;
 
 #include <fstream>
 #include <string>
 
-class StoreGateSvc;
 
 class CBNT_Timing : public CBNT_TBRecBase
 {
  public:
   CBNT_Timing(const std::string & name, ISvcLocator * pSvcLocator);
 
-  ~CBNT_Timing();
+  virtual ~CBNT_Timing();
 
-  //standart algorithm methods
-  virtual StatusCode CBNT_initialize();
-  virtual StatusCode CBNT_execute();
-  virtual StatusCode CBNT_finalize();
-  virtual StatusCode CBNT_clear();
+  //standard algorithm methods
+  virtual StatusCode CBNT_initialize() override;
+  virtual StatusCode CBNT_execute() override;
+  virtual StatusCode CBNT_finalize() override;
+  virtual StatusCode CBNT_clear() override;
 
  private: 
   static const int NOTIME = -999;
@@ -40,7 +38,6 @@ class CBNT_Timing : public CBNT_TBRecBase
 
   SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"};
   const LArOnlineID* m_onlineHelper;
-  const LArEM_ID* m_emId;
 
   double m_energy_cut;
   bool m_first_event;
diff --git a/TestBeam/TBRec/src/CBNT_UpstreamMat.cxx b/TestBeam/TBRec/src/CBNT_UpstreamMat.cxx
index d0539d0fee9a..9b5d9198a72b 100644
--- a/TestBeam/TBRec/src/CBNT_UpstreamMat.cxx
+++ b/TestBeam/TBRec/src/CBNT_UpstreamMat.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "CBNT_UpstreamMat.h"
@@ -14,8 +14,7 @@ using CLHEP::Hep3Vector;
 
 
 CBNT_UpstreamMat::CBNT_UpstreamMat(const std::string & name, ISvcLocator * pSvcLocator) :
-  CBNT_TBRecBase(name, pSvcLocator),
-  m_storeGate(0)
+  CBNT_TBRecBase(name, pSvcLocator)
 {
   declareProperty("CollectionName",m_key);
   m_notFound=false;
@@ -33,15 +32,8 @@ CBNT_UpstreamMat::~CBNT_UpstreamMat()
 
 
 StatusCode CBNT_UpstreamMat::CBNT_initialize() {
-  StatusCode sc;
   MsgStream log(msgSvc(), name());
   
-  sc = service( "StoreGateSvc", m_storeGate);
-  if( sc.isFailure() ){
-    log << MSG::FATAL << "Unable to locate the StoreGateSvc Service" <<endmsg;
-    return sc;
-  }
-
   addBranch("UPSTREAMMAT/up_nElec", m_nElec,"/l");
   addBranch("UPSTREAMMAT/up_nPhot", m_nPhot,"/l");
   
@@ -51,17 +43,16 @@ StatusCode CBNT_UpstreamMat::CBNT_initialize() {
   addBranch("UPSTREAMMAT/up_PhotEne", m_PhotEne);
   addBranch("UPSTREAMMAT/up_PhotAng", m_PhotAng);
 
-  return sc;
+  return StatusCode::SUCCESS;
 }
 
 StatusCode CBNT_UpstreamMat::CBNT_execute() {
-  StatusCode sc;
   MsgStream log(msgSvc(), name());
   //Set to zero:
   m_nElec=0;
   m_nPhot=0;
 
-  if (!m_storeGate->contains<TrackRecordCollection>(m_key)) {
+  if (!evtStore()->contains<TrackRecordCollection>(m_key)) {
     if (!m_notFound) {
       log << MSG::WARNING << "TrackRecordCollection with key " << m_key << " not found" << endmsg;
       m_notFound=true;
@@ -69,16 +60,9 @@ StatusCode CBNT_UpstreamMat::CBNT_execute() {
     return StatusCode::SUCCESS;
   }
   const TrackRecordCollection *trackRecordCollection(0);
-  sc = m_storeGate->retrieve(trackRecordCollection, m_key);
-  if ( sc.isFailure() ) {
-    log << MSG::ERROR  << "Error retrieving TrackRecordCollection with key " << m_key << " not found" << endmsg;
-    return sc;
-  }
+  ATH_CHECK( evtStore()->retrieve(trackRecordCollection, m_key) );
 
-  TrackRecordCollection::const_iterator it=trackRecordCollection->begin(); 
-  TrackRecordCollection::const_iterator it_e=trackRecordCollection->end(); 
-  for (;it!=it_e;it++) {
-    TrackRecord trackRecord=*it;
+  for (const TrackRecord& trackRecord : *trackRecordCollection) {
     const int pdgCode=trackRecord.GetPDGCode();
     Hep3Vector p=trackRecord.GetMomentum();
     double pr=sqrt(p.y()*p.y()+p.z()*p.z());
diff --git a/TestBeam/TBRec/src/CBNT_UpstreamMat.h b/TestBeam/TBRec/src/CBNT_UpstreamMat.h
index 74eba111a8ff..d9e243aa70a8 100644
--- a/TestBeam/TBRec/src/CBNT_UpstreamMat.h
+++ b/TestBeam/TBRec/src/CBNT_UpstreamMat.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_CBNT_UPSTREAMMAT_H
@@ -8,19 +8,17 @@
 #include "CBNT_TBRecBase.h"
 #include <string>
 
-class StoreGateSvc;
 
 class CBNT_UpstreamMat : public CBNT_TBRecBase {
 public:
 	CBNT_UpstreamMat(const std::string &name, ISvcLocator *pSvcLocator);
 	virtual ~CBNT_UpstreamMat();
-	virtual StatusCode CBNT_initialize();
-	virtual StatusCode CBNT_execute();
-	virtual StatusCode CBNT_finalize();
-	virtual StatusCode CBNT_clear();
+	virtual StatusCode CBNT_initialize() override;
+	virtual StatusCode CBNT_execute() override;
+	virtual StatusCode CBNT_finalize() override;
+	virtual StatusCode CBNT_clear() override;
 
 private:
-	StoreGateSvc * m_storeGate;
 	std::string m_key;
 	bool m_notFound;
    //Ntuple variables:
diff --git a/TestBeam/TBRec/src/TBAlgoSequencer.cxx b/TestBeam/TBRec/src/TBAlgoSequencer.cxx
index 2ebd155c0aef..9cb463f2d144 100644
--- a/TestBeam/TBRec/src/TBAlgoSequencer.cxx
+++ b/TestBeam/TBRec/src/TBAlgoSequencer.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 
@@ -84,7 +84,7 @@ TBAlgoSequencer::initialize()
 	  acceptedAlgos++;
 	}
       numberOfAlgorithms++;
-      subAlgos++;
+      ++subAlgos;
     }
 
   ////////////////////////
@@ -163,7 +163,7 @@ TBAlgoSequencer::execute()
 	}
       // iterator and counter increments
       algoIndex++;
-      algoCounter++;
+      ++algoCounter;
     }
   // this is the trick - catch it before the framework terminates the job!  
   return StatusCode::SUCCESS;
@@ -216,24 +216,19 @@ TBAlgoSequencer::finalize()
   ATH_MSG_INFO
     ( "-------------------------------------------------------- " );
   
-  std::map<std::string,unsigned int>::iterator 
-    firstReject = m_rejectPattern.begin();
-  std::map<std::string,unsigned int>::iterator
-    firstAccept = m_acceptPattern.begin();
-
-  for ( ; firstReject != m_rejectPattern.end() ; firstReject++ )
+  for (const std::pair<const std::string, unsigned int>& p : m_rejectPattern)
     {
       double percentReject = m_eventCounter > 0
-	? ((double)(*firstReject).second)/((double)m_eventCounter)*100.
+	? ((double)p.second)/((double)m_eventCounter)*100.
 	: 100;
       msg() << MSG::INFO
 	  << "Algorithm ";
       msg().width(20);
       msg() << MSG::INFO
-	  << (*firstReject).first
+	  << p.first
 	  << " rejected "
 	  << std::setw(6)
-	  << (*firstReject).second
+	  << p.second
 	  << " events (";
       msg() << MSG::INFO
 	  << std::setprecision(5)
@@ -247,19 +242,19 @@ TBAlgoSequencer::finalize()
     ( "Accept patterns: " );
   ATH_MSG_INFO
     ( "-------------------------------------------------------- " );
-  for ( ; firstAccept != m_acceptPattern.end() ; firstAccept++ )
+  for (const std::pair<const std::string, unsigned int>& p : m_acceptPattern)
     {
       double percentAccept = m_eventCounter > 0
-	? ((double)(*firstAccept).second)/((double)m_eventCounter)*100.
+	? ((double)p.second)/((double)m_eventCounter)*100.
 	: 100;
       msg() << MSG::INFO
 	  << "Algorithm ";
       msg().width(20);
       msg() << MSG::INFO
-	  << (*firstAccept).first
+	  << p.first
 	  << " accepted "
 	  << std::setw(6)
-	  << (*firstAccept).second
+	  << p.second
 	  << " events (";
       msg().setf(std::ios::fixed);
       msg() << MSG::INFO
diff --git a/TestBeam/TBRec/src/TBAlgoSequencer.h b/TestBeam/TBRec/src/TBAlgoSequencer.h
index 297b2aa60d0a..09335a9965dd 100755
--- a/TestBeam/TBRec/src/TBAlgoSequencer.h
+++ b/TestBeam/TBRec/src/TBAlgoSequencer.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBALGOSEQUENCER
@@ -28,11 +28,11 @@ class TBAlgoSequencer : public AthLegacySequence
  public:
 
   TBAlgoSequencer(const std::string& name, ISvcLocator* pSvcLocator);
-  ~TBAlgoSequencer();
+  virtual ~TBAlgoSequencer();
 
-  StatusCode initialize();
-  StatusCode execute();
-  StatusCode finalize();
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
 
  private:
 
diff --git a/TestBeam/TBRec/src/TBBPCRec.h b/TestBeam/TBRec/src/TBBPCRec.h
index d6a6f446c101..556bde81e07f 100644
--- a/TestBeam/TBRec/src/TBBPCRec.h
+++ b/TestBeam/TBRec/src/TBBPCRec.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBBPCREC_H
@@ -27,11 +27,11 @@ class TBBPCRec : public AthAlgorithm
  public:
 
   TBBPCRec(const std::string& name, ISvcLocator* pSvcLocator);
-  ~TBBPCRec();
+  virtual ~TBBPCRec();
 
-  StatusCode initialize();
-  StatusCode execute();
-  StatusCode finalize();
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
 
   StatusCode getnewcalib();
 
diff --git a/TestBeam/TBRec/src/TBBeamQuality.cxx b/TestBeam/TBRec/src/TBBeamQuality.cxx
index e3f49973828e..89f54da115f5 100644
--- a/TestBeam/TBRec/src/TBBeamQuality.cxx
+++ b/TestBeam/TBRec/src/TBBeamQuality.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //#####################################################
@@ -56,16 +56,14 @@ StatusCode TBBeamQuality::initialize()
   ATH_MSG_INFO  ("-----------------------------------");
   
   unsigned int toolCtr = 0;
-  ToolHandleArray<TBBeamQualityTool>::iterator first_tool = m_bqtools.begin();
-  ToolHandleArray<TBBeamQualityTool>::iterator last_tool = m_bqtools.end();
-  for ( ;first_tool != last_tool; first_tool++)
+  for (ToolHandle<TBBeamQualityTool>& tool : m_bqtools)
     { 
       toolCtr ++;
       ATH_MSG_INFO 
         (" Tool Name: "
-	 <<(*first_tool)->name()
+	 <<tool->name()
 	 <<" Tool Type: "
-	 <<(*first_tool)->type() );
+	 <<tool->type() );
     }
   return StatusCode::SUCCESS;
 }//init
@@ -89,24 +87,22 @@ StatusCode TBBeamQuality::execute()
   }
  
   // invoke tools
-  ToolHandleArray<TBBeamQualityTool>::iterator first_Tool = m_bqtools.begin();
-  ToolHandleArray<TBBeamQualityTool>::iterator last_Tool = m_bqtools.end();
   
   // setting event to success
   bool successFlag = true;
-  while ( successFlag && first_Tool != last_Tool )
+  for (ToolHandle<TBBeamQualityTool>& tool : m_bqtools)
     {
-      m_bqtotalCounter[*first_Tool]++;
-      successFlag = (*first_Tool)->accept(m_bqparticle) == StatusCode::SUCCESS;
-      if ( successFlag )
+      m_bqtotalCounter[tool]++;
+      if( tool->accept(m_bqparticle) == StatusCode::SUCCESS )
 	{
-	  m_bqacceptCounter[*first_Tool]++;
+	  m_bqacceptCounter[tool]++;
 	}
       else
 	{
-	  m_bqrejectCounter[*first_Tool]++;
+	  m_bqrejectCounter[tool]++;
+          successFlag = false;
+          break;
 	}
-      first_Tool++;
     }
   
   setFilterPassed(successFlag);
@@ -117,20 +113,17 @@ StatusCode TBBeamQuality::execute()
 StatusCode TBBeamQuality::finalize()
 { //finalize
   // print summary
-  ToolHandleArray<TBBeamQualityTool>::iterator first_Tool = m_bqtools.begin();
-  ToolHandleArray<TBBeamQualityTool>::iterator last_Tool = m_bqtools.end();
-  
   ATH_MSG_INFO
     ( "************ Beam Quality Tool ************" );
-  for (; first_Tool != last_Tool; first_Tool++ )
+  for (ToolHandle<TBBeamQualityTool>& tool : m_bqtools)
     {
       ATH_MSG_INFO
-        ((*first_Tool)->name() <<" : "
+        (tool->name() <<" : "
 	  << "(Total/Accept/Rejected)"
 	  << " ("
-	  << m_bqtotalCounter[*first_Tool]  << "/"
-	  << m_bqacceptCounter[*first_Tool] << "/"
-	  << m_bqrejectCounter[*first_Tool] 
+	  << m_bqtotalCounter[tool]  << "/"
+	  << m_bqacceptCounter[tool] << "/"
+	  << m_bqrejectCounter[tool] 
           << ")" );
     } 
   return StatusCode::SUCCESS;
diff --git a/TestBeam/TBRec/src/TBBeamQuality.h b/TestBeam/TBRec/src/TBBeamQuality.h
index 420997d2b89d..65b9c0396431 100755
--- a/TestBeam/TBRec/src/TBBeamQuality.h
+++ b/TestBeam/TBRec/src/TBBeamQuality.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //#####################################################
@@ -33,9 +33,9 @@ class TBBeamQuality : public AthAlgorithm
   
   virtual ~TBBeamQuality();
   
-  StatusCode initialize();
-  StatusCode execute();
-  StatusCode finalize();
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
   
  protected:
   /* Properties*/
diff --git a/TestBeam/TBRec/src/TBBeamQualityDoubleHitsTool.cxx b/TestBeam/TBRec/src/TBBeamQualityDoubleHitsTool.cxx
index ece802cfa872..298bf42016a5 100644
--- a/TestBeam/TBRec/src/TBBeamQualityDoubleHitsTool.cxx
+++ b/TestBeam/TBRec/src/TBBeamQualityDoubleHitsTool.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //#####################################################
@@ -22,11 +22,10 @@
 #include <ios>
 #include <algorithm>
 
-TBBeamQualityDoubleHitsTool::TBBeamQualityDoubleHitsTool(const std::string& name,
-							 const std::string& type,
+TBBeamQualityDoubleHitsTool::TBBeamQualityDoubleHitsTool(const std::string& type,
+							 const std::string& name,
 							 const IInterface* parent)
-  : TBBeamQualityTool(name,type,parent),
-    m_StoreGate(nullptr),
+  : TBBeamQualityTool(type,name,parent),
     m_Scint1ADC(0),
     m_Scint2ADC(0)
 {
@@ -54,7 +53,7 @@ StatusCode TBBeamQualityDoubleHitsTool::initializeTool()
   return StatusCode::SUCCESS;
 }//init
 
-StatusCode TBBeamQualityDoubleHitsTool::accept(std::vector<std::string> m_particles)
+StatusCode TBBeamQualityDoubleHitsTool::accept(const std::vector<std::string>& particles)
 {//accept
   MsgStream log(msgSvc(),name());
     
@@ -68,13 +67,13 @@ StatusCode TBBeamQualityDoubleHitsTool::accept(std::vector<std::string> m_partic
     // wide/narrow beam selection to be added
     
     // Hadrons
-    if (m_particles[0]=="pi+" || m_particles[0]=="pi-" || m_particles[0]=="p+" ) {
+    if (particles[0]=="pi+" || particles[0]=="pi-" || particles[0]=="p+" ) {
       m_ScintCut1ADC= 270;
       m_ScintCut2ADC = 265;
     }
     
     // Leptons
-    if (m_particles[0]=="e+" || m_particles[0]=="e-" || m_particles[0]=="mu+" || m_particles[0]=="mu-" ) {
+    if (particles[0]=="e+" || particles[0]=="e-" || particles[0]=="mu+" || particles[0]=="mu-" ) {
       m_ScintCut1ADC= 280;
       m_ScintCut2ADC = 275;
     }
@@ -86,56 +85,35 @@ StatusCode TBBeamQualityDoubleHitsTool::accept(std::vector<std::string> m_partic
       << "m_ScintCut2ADC: "<< m_ScintCut2ADC 
       <<endmsg;
   
-  // checking out StoreGateSvc
-  StatusCode sc = service("StoreGateSvc",m_StoreGate);
-  if ( sc.isFailure() )
-    {
-      log << MSG::ERROR
-	  << "Cannot alllocate StoreGate service!"
-	  << endmsg;
-    }
-  
-  TBScintillatorCont * scint;
-  
-  sc = m_StoreGate->retrieve(scint, m_SGScintkey);
-  
-    if (sc.isFailure()){
-      log << MSG::DEBUG
-	  << "Can't Retrieve "
-	  << m_SGScintkey
-	  <<" from SG"
-	  << endmsg;
-    }else { //else
-      
-      m_Scint1ADC = 0;
-      m_Scint2ADC = 0;    
-      
-      TBScintillatorCont::const_iterator it_scint   = scint->begin();
-      TBScintillatorCont::const_iterator last_scint   = scint->end();
-      
-      
-    for(;it_scint!=last_scint;it_scint++) {
-      
-      const TBScintillator * scint = (*it_scint);
+  TBScintillatorCont * scintCont = nullptr;
+  if (evtStore()->retrieve(scintCont, m_SGScintkey).isFailure()) {
+    log << MSG::DEBUG
+        << "Can't Retrieve "
+        << m_SGScintkey
+        <<" from SG"
+        << endmsg;
+  }
+  else {
       
+    m_Scint1ADC = 0;
+    m_Scint2ADC = 0;    
+
+    for (const TBScintillator* scint : *scintCont) {
       std::string detect = scint->getDetectorName();
-      
       if (detect==m_scint_names[m_ScintCut1]){
-	m_Scint1ADC = scint->getSignal();
+        m_Scint1ADC = scint->getSignal();
       }
       if (detect==m_scint_names[m_ScintCut2]){
-	m_Scint2ADC = scint->getSignal();
+        m_Scint2ADC = scint->getSignal();
       }
     }
-    
-    } //else   
-    
-    
-    if (m_Scint1ADC>m_ScintCut1ADC && m_Scint2ADC>m_ScintCut2ADC) {
-      return StatusCode::FAILURE;
-    }
-    else {
-      return StatusCode::SUCCESS;  
-    }
+  }
+
+  if (m_Scint1ADC>m_ScintCut1ADC && m_Scint2ADC>m_ScintCut2ADC) {
+    return StatusCode::FAILURE;
+  }
+  else {
+    return StatusCode::SUCCESS;  
+  }
     
 }//accept
diff --git a/TestBeam/TBRec/src/TBBeamQualityDoubleHitsTool.h b/TestBeam/TBRec/src/TBBeamQualityDoubleHitsTool.h
index b5a4492356a1..27193171e5d2 100644
--- a/TestBeam/TBRec/src/TBBeamQualityDoubleHitsTool.h
+++ b/TestBeam/TBRec/src/TBBeamQualityDoubleHitsTool.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //#####################################################
@@ -29,13 +29,12 @@ class TBBeamQualityDoubleHitsTool : public TBBeamQualityTool
   
   virtual ~TBBeamQualityDoubleHitsTool();
   
-  virtual StatusCode initializeTool();
+  virtual StatusCode initializeTool() override;
   
-  virtual StatusCode accept(std::vector<std::string>);
+  virtual StatusCode accept(const std::vector<std::string>&) override;
   
  protected:
   
-  StoreGateSvc* m_StoreGate;
   std::string m_SGScintkey;
   
   //Properties
diff --git a/TestBeam/TBRec/src/TBBeamQualityEMFractionTool.cxx b/TestBeam/TBRec/src/TBBeamQualityEMFractionTool.cxx
index e8c0142cc4d8..a91bb3af533b 100644
--- a/TestBeam/TBRec/src/TBBeamQualityEMFractionTool.cxx
+++ b/TestBeam/TBRec/src/TBBeamQualityEMFractionTool.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //#####################################################
@@ -19,10 +19,10 @@
 
 #include "Identifier/Identifier.h"
 
-TBBeamQualityEMFractionTool::TBBeamQualityEMFractionTool(const std::string& name,
-							 const std::string& type,
+TBBeamQualityEMFractionTool::TBBeamQualityEMFractionTool(const std::string& type,
+							 const std::string& name,
 							 const IInterface* parent)
-  : TBBeamQualityTool(name,type,parent),
+  : TBBeamQualityTool(type,name,parent),
     m_emecID_help(nullptr),
     m_hecID_help(nullptr),
     m_fcalID_help(nullptr),
@@ -139,7 +139,7 @@ StatusCode TBBeamQualityEMFractionTool::initializeTool()
   return StatusCode::SUCCESS;
 }//init
 
-StatusCode TBBeamQualityEMFractionTool::accept(std::vector<std::string> m_particles)
+StatusCode TBBeamQualityEMFractionTool::accept(const std::vector<std::string>& particles)
 {//accept
   
   MsgStream log(msgSvc(),name());
@@ -152,7 +152,7 @@ StatusCode TBBeamQualityEMFractionTool::accept(std::vector<std::string> m_partic
   
   log << MSG::DEBUG << "m_em_fracnumdet: "<<m_em_fracnumdet<<endmsg;
   log << MSG::DEBUG << "m_em_fracdendet: "<<m_em_fracdendet<<endmsg;
-  log << MSG::DEBUG << " called for:  "<<m_particles.size()<<" particles"<<endmsg;
+  log << MSG::DEBUG << " called for:  "<<particles.size()<<" particles"<<endmsg;
   
   // setting up layers (h6)
   
@@ -176,14 +176,8 @@ StatusCode TBBeamQualityEMFractionTool::accept(std::vector<std::string> m_partic
     return StatusCode::FAILURE;
   }
   
-  CaloCellContainer::const_iterator ifirst = cellContainer->begin();
-  CaloCellContainer::const_iterator ilast = cellContainer->end();
-  
-  for (; ifirst!=ilast; ifirst++){//iterating
-    
-    //obtaining cell pointer
-    const CaloCell* cell_ptr = *ifirst;
-    
+  for (const CaloCell* cell_ptr : *cellContainer) {
+
     //obtaining dde pointer
     const CaloDetDescrElement* caloDDE_ptr = cell_ptr->caloDDE();
     
diff --git a/TestBeam/TBRec/src/TBBeamQualityEMFractionTool.h b/TestBeam/TBRec/src/TBBeamQualityEMFractionTool.h
index b88e3f518330..af3357642d56 100644
--- a/TestBeam/TBRec/src/TBBeamQualityEMFractionTool.h
+++ b/TestBeam/TBRec/src/TBBeamQualityEMFractionTool.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //#####################################################
@@ -30,9 +30,9 @@ class TBBeamQualityEMFractionTool : public TBBeamQualityTool
   
   virtual ~TBBeamQualityEMFractionTool();
   
-  virtual StatusCode initializeTool();
+  virtual StatusCode initializeTool() override;
   
-  virtual StatusCode accept(std::vector<std::string>);
+  virtual StatusCode accept(const std::vector<std::string>&) override;
   
  protected:
   
diff --git a/TestBeam/TBRec/src/TBBeamQualityMC.h b/TestBeam/TBRec/src/TBBeamQualityMC.h
index 502074c324d7..d3c345636ce6 100644
--- a/TestBeam/TBRec/src/TBBeamQualityMC.h
+++ b/TestBeam/TBRec/src/TBBeamQualityMC.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBBEAMQUALITYMC_H
@@ -13,11 +13,11 @@ class TBBeamQualityMC : public AthAlgorithm
  public:
   TBBeamQualityMC(const std::string & name, ISvcLocator * pSvcLocator);
 
-  ~TBBeamQualityMC() {};
+  virtual ~TBBeamQualityMC() {};
 
-  virtual StatusCode initialize();
-  virtual StatusCode execute();
-  virtual StatusCode finalize();
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
 
  private:
   /** Get Xcryo and Ytable from a text file */
diff --git a/TestBeam/TBRec/src/TBBeamQualityMuonToolH6.cxx b/TestBeam/TBRec/src/TBBeamQualityMuonToolH6.cxx
index 1516c5b3f62f..49157bd8fe63 100644
--- a/TestBeam/TBRec/src/TBBeamQualityMuonToolH6.cxx
+++ b/TestBeam/TBRec/src/TBBeamQualityMuonToolH6.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //#####################################################
@@ -22,11 +22,10 @@
 #include <ios>
 #include <algorithm>
 
-TBBeamQualityMuonToolH6::TBBeamQualityMuonToolH6(const std::string& name,
-						 const std::string& type,
+TBBeamQualityMuonToolH6::TBBeamQualityMuonToolH6(const std::string& type,
+						 const std::string& name,
 						 const IInterface* parent)
-  : TBBeamQualityTool(name,type,parent),
-    m_StoreGate(nullptr),
+  : TBBeamQualityTool(type,name,parent),
     m_mu1(false),
     m_mu2(false),
     m_mu3(false),
@@ -78,54 +77,41 @@ StatusCode TBBeamQualityMuonToolH6::initializeTool()
   return StatusCode::SUCCESS;
 }
 
-StatusCode TBBeamQualityMuonToolH6::accept(std::vector<std::string> m_particles)
+StatusCode TBBeamQualityMuonToolH6::accept(const std::vector<std::string>& particles)
 {//accept
   
   MsgStream log(msgSvc(),name());
   
-  StatusCode sc = service("StoreGateSvc",m_StoreGate);
-  if ( sc.isFailure() )
-    {
-      log << MSG::ERROR
-          << "Cannot alllocate StoreGate service!"
-          << endmsg;
-    }
-  
   // Trigger Pattern Pointer
   TBTriggerPatternUnit * triggpat_object;
   
-  sc = m_StoreGate->retrieve(triggpat_object, m_SGTrigkey);
-  if (sc.isFailure()){
-    log << MSG::INFO << "TBCaloNtuple: Can't Retrieve "<<m_SGTrigkey<<" from SG"<< endmsg;
-    return sc;
-  }else{ // obtaining trigger word from storegate
-    
-    unsigned int word =triggpat_object->getTriggerWord();
+  ATH_CHECK( evtStore()->retrieve(triggpat_object, m_SGTrigkey) );
+
+  unsigned int word =triggpat_object->getTriggerWord();
     
-    m_mu1=false;
-    m_mu2=false;
-    m_mu3=false;
-    m_mu4=false;
+  m_mu1=false;
+  m_mu2=false;
+  m_mu3=false;
+  m_mu4=false;
     
-    // muon triggers are:
-    // Entry 8:  Mu 1 Left
-    // Entry 9:  Mu 2 Left
-    // Entry 10: Mu 2 Left
-    // Entry 16: Mu 2 Right
+  // muon triggers are:
+  // Entry 8:  Mu 1 Left
+  // Entry 9:  Mu 2 Left
+  // Entry 10: Mu 2 Left
+  // Entry 16: Mu 2 Right
     
-    if ((word & m_triggflag[8])!=0) {
-      m_mu1=true;
-    }
-    if ((word & m_triggflag[9])!=0) {
-      m_mu2=true;
-    }
-    if ((word & m_triggflag[10])!=0) {
-      m_mu3=true;
-    }
-    if ((word & m_triggflag[16])!=0) {
-      m_mu4=true;
-    }
-  } // trigg word from storegate
+  if ((word & m_triggflag[8])!=0) {
+    m_mu1=true;
+  }
+  if ((word & m_triggflag[9])!=0) {
+    m_mu2=true;
+  }
+  if ((word & m_triggflag[10])!=0) {
+    m_mu3=true;
+  }
+  if ((word & m_triggflag[16])!=0) {
+    m_mu4=true;
+  }
   
   //checking for muon coincidence:
   
@@ -133,10 +119,10 @@ StatusCode TBBeamQualityMuonToolH6::accept(std::vector<std::string> m_particles)
   
   //muons
   log<<MSG::DEBUG
-     <<m_particles[0]
+     <<particles[0]
      <<endmsg;
   
-  if(m_particles[0]=="mu+" || m_particles[0]=="mu-"){
+  if(particles[0]=="mu+" || particles[0]=="mu-"){
     m_successflag=false;
     
     if (((m_mu1==true)&(m_mu3==true))||((m_mu1==true)&(m_mu4==true))||((m_mu2==true)&(m_mu3==true))||((m_mu2==true)&(m_mu4==true))) {
diff --git a/TestBeam/TBRec/src/TBBeamQualityMuonToolH6.h b/TestBeam/TBRec/src/TBBeamQualityMuonToolH6.h
index a85f39c2b49f..feb2ff2b8bfd 100644
--- a/TestBeam/TBRec/src/TBBeamQualityMuonToolH6.h
+++ b/TestBeam/TBRec/src/TBBeamQualityMuonToolH6.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //#####################################################
@@ -29,14 +29,12 @@ class TBBeamQualityMuonToolH6 : public TBBeamQualityTool
   
   virtual ~TBBeamQualityMuonToolH6();
   
-  virtual StatusCode initializeTool();
+  virtual StatusCode initializeTool() override;
   
-  virtual StatusCode accept(std::vector<std::string>);
+  virtual StatusCode accept(const std::vector<std::string>&) override;
   
  protected:
   
-  StoreGateSvc* m_StoreGate;
-  
   // Keys
   std::string m_SGTrigkey;
   
diff --git a/TestBeam/TBRec/src/TBBeamQualityTool.cxx b/TestBeam/TBRec/src/TBBeamQualityTool.cxx
index 744c6d00fac1..05ecfc7d32e5 100644
--- a/TestBeam/TBRec/src/TBBeamQualityTool.cxx
+++ b/TestBeam/TBRec/src/TBBeamQualityTool.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //#####################################################
@@ -38,9 +38,9 @@ StatusCode TBBeamQualityTool::initializeTool()
   return StatusCode::SUCCESS;
 }
 
-StatusCode TBBeamQualityTool::reject(std::vector<std::string> m_particles)
+StatusCode TBBeamQualityTool::reject(const std::vector<std::string>& particles)
 {
-  return this->accept(m_particles).isFailure()
+  return this->accept(particles).isFailure()
     ? StatusCode::SUCCESS
     : StatusCode::FAILURE;
 }
diff --git a/TestBeam/TBRec/src/TBBeamQualityTool.h b/TestBeam/TBRec/src/TBBeamQualityTool.h
index a629ce23f10c..af32ded85602 100644
--- a/TestBeam/TBRec/src/TBBeamQualityTool.h
+++ b/TestBeam/TBRec/src/TBBeamQualityTool.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //#####################################################
@@ -32,10 +32,10 @@ class TBBeamQualityTool : public AthAlgTool
   
   virtual ~TBBeamQualityTool();
   
-  virtual StatusCode accept(std::vector<std::string>) = 0;
-  virtual StatusCode reject(std::vector<std::string>);
+  virtual StatusCode accept(const std::vector<std::string>&) = 0;
+  virtual StatusCode reject(const std::vector<std::string>&);
   
-  virtual StatusCode initialize();
+  virtual StatusCode initialize() override;
 
   virtual StatusCode initializeTool();
   
diff --git a/TestBeam/TBRec/src/TBBeamQualityTrackingTool.cxx b/TestBeam/TBRec/src/TBBeamQualityTrackingTool.cxx
index 2bd0968d5824..1e5c59b9826b 100644
--- a/TestBeam/TBRec/src/TBBeamQualityTrackingTool.cxx
+++ b/TestBeam/TBRec/src/TBBeamQualityTrackingTool.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //#####################################################
@@ -19,11 +19,10 @@
 #include <ios>
 #include <algorithm>
 
-TBBeamQualityTrackingTool::TBBeamQualityTrackingTool(const std::string& name,
-						       const std::string& type,
-						       const IInterface* parent)
-  : TBBeamQualityTool(name,type,parent),
-    m_StoreGate(nullptr)
+TBBeamQualityTrackingTool::TBBeamQualityTrackingTool(const std::string& type,
+                                                     const std::string& name,
+                                                     const IInterface* parent)
+  : TBBeamQualityTool(type,name,parent)
 {  
 
   // defaults are 0, which means no cut.
@@ -49,50 +48,29 @@ StatusCode TBBeamQualityTrackingTool::initializeTool()
   return StatusCode::SUCCESS;
 }
 
-StatusCode TBBeamQualityTrackingTool::accept(std::vector<std::string> m_particles)
+StatusCode TBBeamQualityTrackingTool::accept(const std::vector<std::string>& particles)
 {//accept
   
   MsgStream log(msgSvc(),name());
   
-  StatusCode sc = service("StoreGateSvc",m_StoreGate);
-  if ( sc.isFailure() )
-    {
-      log << MSG::ERROR
-          << "Cannot alllocate StoreGate service!"
-          << endmsg;
-    }
-   log << MSG::DEBUG << "Asked for : "<<m_particles.size()<<" particles"<<endmsg;
+   log << MSG::DEBUG << "Asked for : "<<particles.size()<<" particles"<<endmsg;
   
   // Retrieve Beam Track and select on chi2 values in x and y
 
   if (m_chi2cut_u>0. && m_chi2cut_v>0.) {
 
-    TBTrack *thisTBTrack;
-    sc = m_StoreGate->retrieve(thisTBTrack,"Track");
-    if (sc.isFailure()){
-      log << MSG::WARNING
-	  << "Retrieval of TBTrack failed"
-	  << endmsg;
+    TBTrack *thisTBTrack = nullptr;
+    ATH_CHECK( evtStore()->retrieve(thisTBTrack,"Track") );
+    if (thisTBTrack->getChi2_u() > m_chi2cut_u || thisTBTrack->getChi2_v() > m_chi2cut_v ) {
+      log << MSG::DEBUG
+          << "Rejecting event with chi2(u,v) = "
+          << thisTBTrack->getChi2_u()
+          << ", "
+          << thisTBTrack->getChi2_v()
+          << endmsg;
       return StatusCode::FAILURE;
     } else {
-      //          log << MSG::INFO
-      //    << "Retrieved track for quality check"
-      //    << "chi2(u,v) = "
-      //    << thisTBTrack->getChi2_u()
-      //    << ", "
-      //    << thisTBTrack->getChi2_v()
-      //    << endmsg;
-      if (thisTBTrack->getChi2_u() > m_chi2cut_u || thisTBTrack->getChi2_v() > m_chi2cut_v ) {
-	log << MSG::DEBUG
-	    << "Rejecting event with chi2(u,v) = "
-	    << thisTBTrack->getChi2_u()
-	    << ", "
-	    << thisTBTrack->getChi2_v()
-	    << endmsg;
-	return StatusCode::FAILURE;
-      } else {
-	return StatusCode::SUCCESS;
-      }
+      return StatusCode::SUCCESS;
     }
   } else { 	
     if (m_chi2cut_u==0. && m_chi2cut_v==0.) {
diff --git a/TestBeam/TBRec/src/TBBeamQualityTrackingTool.h b/TestBeam/TBRec/src/TBBeamQualityTrackingTool.h
index e3db4890befb..4bb0921db1f8 100644
--- a/TestBeam/TBRec/src/TBBeamQualityTrackingTool.h
+++ b/TestBeam/TBRec/src/TBBeamQualityTrackingTool.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //#####################################################
@@ -29,14 +29,12 @@ class TBBeamQualityTrackingTool : public TBBeamQualityTool
   
   virtual ~TBBeamQualityTrackingTool();
   
-  virtual StatusCode initializeTool();
+  virtual StatusCode initializeTool() override;
   
-  virtual StatusCode accept(std::vector<std::string>);
+  virtual StatusCode accept(const std::vector<std::string>&) override;
   
  protected:
   
-  StoreGateSvc* m_StoreGate;
-  
   // Keys
   std::string m_SGTrigkey;
   
diff --git a/TestBeam/TBRec/src/TBCellContainerFillerTool.cxx b/TestBeam/TBRec/src/TBCellContainerFillerTool.cxx
index e2047933fc52..d6f2fbee0c18 100644
--- a/TestBeam/TBRec/src/TBCellContainerFillerTool.cxx
+++ b/TestBeam/TBRec/src/TBCellContainerFillerTool.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "TBCellContainerFillerTool.h"
@@ -30,8 +30,6 @@ StatusCode TBCellContainerFillerTool::initialize()
   m_theCaloDDM = CaloDetDescrManager::instance() ;
   m_theCaloCCIDM   = m_theCaloDDM->getCaloCell_ID() ;
 
-  if(!m_theCaloDDM || !m_theCaloCCIDM) return StatusCode::FAILURE;
-
   m_hashMax = m_theCaloCCIDM->calo_cell_hash_max();
 
   ATH_CHECK( detStore()->retrieve(m_onlineHelper, "LArOnlineID") );
diff --git a/TestBeam/TBRec/src/TBCellNoiseCorrection.cxx b/TestBeam/TBRec/src/TBCellNoiseCorrection.cxx
index b0732dda36d2..1eb387f32019 100644
--- a/TestBeam/TBRec/src/TBCellNoiseCorrection.cxx
+++ b/TestBeam/TBRec/src/TBCellNoiseCorrection.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "TBCellNoiseCorrection.h"
@@ -24,7 +24,7 @@ TBCellNoiseCorrection::TBCellNoiseCorrection(const std::string& type,
 						 const IInterface* parent)
   : CaloCellCorrection(type, name, parent),
     m_noise_correction(false),m_noise_file(),
-    m_rndmSvc ("AtRanluxGenSvc", name), m_engine(0), m_log(0), 
+    m_rndmSvc ("AtRanluxGenSvc", name), m_engine(0),
     m_tree(0), m_xcryo(0.), m_ytable(0.), m_energy(-1.), m_cell_id(0), m_cell_energy(0),m_entries(0)
     //m_myevtnum(-1)
 { 
@@ -44,29 +44,27 @@ TBCellNoiseCorrection::~TBCellNoiseCorrection()
 
 StatusCode TBCellNoiseCorrection::initialize()
 {
-  m_log = new MsgStream(msgSvc(), name());
-
-  *m_log << MSG::DEBUG << " TBCellNoiseCorrection initialization " << endmsg ;
+  ATH_MSG_DEBUG( " TBCellNoiseCorrection initialization " );
 
   // RandomNumbers
   if (!m_rndmSvc.retrieve().isSuccess()) {
-     *m_log << MSG::FATAL << "Could not initialize find Random Number Service." <<endmsg;
+     ATH_MSG_FATAL( "Could not initialize find Random Number Service."  );
      return StatusCode::FAILURE; 
   } else {
      m_engine = m_rndmSvc->GetEngine("TB_NOISE");
      if(!m_engine) {
-        *m_log << MSG::FATAL << "Could not get the TB_NOISE engine..." <<endmsg;
+        ATH_MSG_FATAL( "Could not get the TB_NOISE engine..."  );
         return StatusCode::FAILURE; 
      }
   }
 
   if(m_energy > 0.) { // Do we have run parameters (x,y,energy) ?
-     *m_log << MSG::DEBUG << " Trying to patch the noise file name "<< endmsg;
+     ATH_MSG_DEBUG( " Trying to patch the noise file name " );
      std::string fname = PathResolver::find_file ("xcryo_ytable.txt", "DATAPATH");
      std::ifstream xfile;
      xfile.open(fname.c_str());
      if(!xfile.good()){
-        *m_log << MSG::FATAL << "Could not open file  xcryo_ytable.txt" << endmsg;
+        ATH_MSG_FATAL( "Could not open file  xcryo_ytable.txt"  );
 	return StatusCode::FAILURE;
      }
      int runnumber;
@@ -79,28 +77,28 @@ StatusCode TBCellNoiseCorrection::initialize()
         break;
      }
      if(en < 0.) {
-        *m_log << MSG::FATAL << " Do not have X: "<<m_xcryo<<" Y: "<<m_ytable<< " E: "<<m_energy<<" in 	xcryo_ytable.txt" << endmsg;
+        ATH_MSG_FATAL( " Do not have X: "<<m_xcryo<<" Y: "<<m_ytable<< " E: "<<m_energy<<" in 	xcryo_ytable.txt"  );
 	return StatusCode::FAILURE;
      }
      // we have run number - let's change the file name (and take only one):
-     *m_log << MSG::DEBUG << "Found run number: "<<runnumber <<endmsg;
+     ATH_MSG_DEBUG( "Found run number: "<<runnumber  );
      unsigned pos = m_noise_file[0].find_last_of("0123456789");
      std::ostringstream buf;
      buf<<runnumber;
      m_noise_file[0].replace(pos-3,4,buf.str());
-     *m_log << MSG::DEBUG << "patched name: "<<m_noise_file[0].c_str()<< endmsg;
+     ATH_MSG_DEBUG( "patched name: "<<m_noise_file[0].c_str() );
   }
 
   // Open file and get Tree
   /*
   m_root = new TFile(m_noise_file.c_str(),"READ"); 
   if(!m_root->IsOpen()){
-     *m_log << MSG::FATAL << "Could not open root file: "<<m_noise_file<<endmsg;
+     ATH_MSG_FATAL( "Could not open root file: "<<m_noise_file );
      return StatusCode::FAILURE; 
   }
   m_tree = (TTree*) m_root->Get("NoiseTree");
   if(!m_tree) {
-     *m_log << MSG::FATAL << "No NoiseTree in root file: "<<m_noise_file<<endmsg;
+     ATH_MSG_FATAL( "No NoiseTree in root file: "<<m_noise_file );
      return StatusCode::FAILURE; 
   }
   */
@@ -111,19 +109,19 @@ StatusCode TBCellNoiseCorrection::initialize()
   }
   m_entries = m_tree->GetEntries();
   if(m_entries < 100) {
-     *m_log << MSG::FATAL << "Noise chain has less then 100 events !!!!" <<endmsg;
+     ATH_MSG_FATAL( "Noise chain has less then 100 events !!!!"  );
      return StatusCode::FAILURE; 
   }
   m_tree->SetBranchAddress("cell_id", &m_cell_id);
   m_tree->SetBranchAddress("cell_ener", &m_cell_energy);
-  *m_log << MSG::DEBUG <<" Got NoiseTree with "<<m_entries<<" entries"<<endmsg;
+  ATH_MSG_DEBUG(" Got NoiseTree with "<<m_entries<<" entries" );
 
    /// Incident Service
   IIncidentSvc* pIncSvc(0);
 
   // set up the incident service:
   if (!(service("IncidentSvc", pIncSvc, true)).isSuccess()) {
-    *m_log << MSG::ERROR << "Could not locate IncidentSvc " << endmsg;
+    ATH_MSG_ERROR( "Could not locate IncidentSvc "  );
     return StatusCode::FAILURE;
   }
   
@@ -131,7 +129,7 @@ StatusCode TBCellNoiseCorrection::initialize()
   static const int PRIORITY = 100;
   pIncSvc->addListener(this, "BeginEvent", PRIORITY);
 
-  *m_log << MSG::DEBUG << " TBCellNoiseCorrection initialization finished" << endmsg ;
+  ATH_MSG_DEBUG( " TBCellNoiseCorrection initialization finished"  );
   
   return StatusCode::SUCCESS; 
 }
@@ -168,7 +166,7 @@ void TBCellNoiseCorrection::MakeCorrection (CaloCell* theCell,
        }
     }
     if(i == size) {
-       *m_log << MSG::ERROR << "Could not find a noise value for cell: "<<std::hex<<cid<<std::dec<<endmsg;
+      ATH_MSG_ERROR( "Could not find a noise value for cell: "<<std::hex<<cid<<std::dec );
     }
 
     theCell->setEnergy(e);
@@ -177,16 +175,16 @@ void TBCellNoiseCorrection::MakeCorrection (CaloCell* theCell,
 }  
 
 void TBCellNoiseCorrection::handle(const Incident &inc) {
-  *m_log << MSG::DEBUG << " Handle BeginEvent " << endmsg;
+  ATH_MSG_DEBUG( " Handle BeginEvent "  );
 
   if ( inc.type() == "BeginEvent") {
      unsigned int random = int(RandFlat::shoot(m_engine, 0., m_entries-1.));
-     *m_log << MSG::DEBUG << "Reading noise event: "<<random<<endmsg;
+     ATH_MSG_DEBUG( "Reading noise event: "<<random );
      m_tree->GetEntry(random);
      unsigned int size = m_cell_id->size();
      unsigned int sizee = m_cell_energy->size();
      if(size != sizee) {
-        *m_log << MSG::ERROR << "Not equal size of noise vectors !!!! Something wrong !!!" <<endmsg;
+       ATH_MSG_ERROR( "Not equal size of noise vectors !!!! Something wrong !!!"  );
      }
   }
 }
diff --git a/TestBeam/TBRec/src/TBCellNoiseCorrection.h b/TestBeam/TBRec/src/TBCellNoiseCorrection.h
index b5c053e1e9b4..f54435d94c55 100644
--- a/TestBeam/TBRec/src/TBCellNoiseCorrection.h
+++ b/TestBeam/TBRec/src/TBCellNoiseCorrection.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBCELLNOISECORRECTION_H
@@ -48,7 +48,6 @@ class TBCellNoiseCorrection : public CaloCellCorrection, virtual public IInciden
   // Data members:
   ServiceHandle <IAtRndmGenSvc> m_rndmSvc;
   CLHEP::HepRandomEngine * m_engine;
-  MsgStream *m_log;
   //TFile *m_root; // File with noise tree
   TChain *m_tree;
   float m_xcryo;  // if given, try to find run number from xcryo_ytable.txt file
diff --git a/TestBeam/TBRec/src/TBDMContainerSplitter.cxx b/TestBeam/TBRec/src/TBDMContainerSplitter.cxx
index efc9fe09836e..a4aef8d6fc5d 100644
--- a/TestBeam/TBRec/src/TBDMContainerSplitter.cxx
+++ b/TestBeam/TBRec/src/TBDMContainerSplitter.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "TBDMContainerSplitter.h"
@@ -61,13 +61,11 @@ StatusCode TBDMContainerSplitter::execute()
   CaloCalibrationHitContainer* outDMContLeak = new CaloCalibrationHitContainer();
 
   // Loop over original, and fill two new ones
-  CaloCalibrationHitContainer::const_iterator chIter  = inDMCont->begin();
-  CaloCalibrationHitContainer::const_iterator chIterE = inDMCont->end();
-  for(;chIter!=chIterE;chIter++)  {
-      Identifier myId = (*chIter)->cellID();
+  for (const CaloCalibrationHit* hit : *inDMCont) {
+      Identifier myId = hit->cellID();
       CaloDmDescrElement* myCDDE(0);
       myCDDE = m_caloDmDescrManager->get_element(myId);
-      CaloCalibrationHit *chit = new CaloCalibrationHit(myId, (*chIter)->energyEM(), (*chIter)->energyNonEM(), (*chIter)->energyInvisible(), (*chIter)->energyEscaped());
+      CaloCalibrationHit *chit = new CaloCalibrationHit(myId, hit->energyEM(), hit->energyNonEM(), hit->energyInvisible(), hit->energyEscaped());
       if ( myCDDE ) {
           if(myCDDE->eta()>2.5 && myCDDE->phi() > M_PI/2 && myCDDE->phi() < M_PI){ // Calo hit
              outDMContCalo->push_back(chit);
diff --git a/TestBeam/TBRec/src/TBDMContainerSplitter.h b/TestBeam/TBRec/src/TBDMContainerSplitter.h
index 50910cf4010e..2115421684b5 100644
--- a/TestBeam/TBRec/src/TBDMContainerSplitter.h
+++ b/TestBeam/TBRec/src/TBDMContainerSplitter.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBDMCONTAINERSPLITTER_H
@@ -19,9 +19,9 @@ class TBDMContainerSplitter: public AthAlgorithm {
   
   TBDMContainerSplitter(const std::string& name, ISvcLocator* pSvcLocator);
   virtual ~TBDMContainerSplitter();
-  StatusCode initialize();
-  StatusCode execute();
-  StatusCode finalize();
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
   
  private: 
   // Names and pointers
diff --git a/TestBeam/TBRec/src/TBECLArRawChannelBuilder.cxx b/TestBeam/TBRec/src/TBECLArRawChannelBuilder.cxx
index 4ac9cf8ce191..1ad0bfb3de5c 100644
--- a/TestBeam/TBRec/src/TBECLArRawChannelBuilder.cxx
+++ b/TestBeam/TBRec/src/TBECLArRawChannelBuilder.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "TBECLArRawChannelBuilder.h"
@@ -286,11 +286,9 @@ StatusCode TBECLArRawChannelBuilder::execute()
   if (msgLvl(MSG::DEBUG) ) debugPrint=true;
 
   // Now all data is available, start loop over Digit Container
-  LArDigitContainer::const_iterator cont_it=digitContainer->begin();
-  LArDigitContainer::const_iterator cont_it_e=digitContainer->end();
   int ntot_raw=0;
 
-  for (;cont_it!=cont_it_e;cont_it++) {
+  for (const LArDigit* digit : *(digitContainer)) {
 
     //Data that goes into RawChannel:
     float energy=0;
@@ -301,10 +299,10 @@ StatusCode TBECLArRawChannelBuilder::execute()
     int timeSampleShift=m_initialTimeSampleShift;
 
     //Get data from LArDigit
-    const std::vector<short>& samples=(*cont_it)->samples();
+    const std::vector<short>& samples=digit->samples();
     const unsigned nSamples=samples.size(); 
-    const HWIdentifier chid=(*cont_it)->channelID();
-    const CaloGain::CaloGain gain=(*cont_it)->gain();
+    const HWIdentifier chid=digit->channelID();
+    const CaloGain::CaloGain gain=digit->gain();
     
     // to be used in case of DEBUG output
     int layer  = -99999 ;
diff --git a/TestBeam/TBRec/src/TBECLArRawChannelBuilder.h b/TestBeam/TBRec/src/TBECLArRawChannelBuilder.h
index 0d304e86e255..32ea10c62679 100644
--- a/TestBeam/TBRec/src/TBECLArRawChannelBuilder.h
+++ b/TestBeam/TBRec/src/TBECLArRawChannelBuilder.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBECLARRAWCHANNELBUILDER_H
@@ -31,9 +31,9 @@ class TBECLArRawChannelBuilder : public AthAlgorithm
 {
 public:
   TBECLArRawChannelBuilder (const std::string& name, ISvcLocator* pSvcLocator);
-  StatusCode initialize();
-  StatusCode execute();
-  StatusCode finalize();
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
 
 private:
   //Services & Tools 
diff --git a/TestBeam/TBRec/src/TBEMECXTalkToyModel.cxx b/TestBeam/TBRec/src/TBEMECXTalkToyModel.cxx
index 2f34d0d86ba8..5cf583ff3f1d 100644
--- a/TestBeam/TBRec/src/TBEMECXTalkToyModel.cxx
+++ b/TestBeam/TBRec/src/TBEMECXTalkToyModel.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 /********************************************************************
@@ -140,16 +140,9 @@ StatusCode TBEMECXTalkToyModel::process (CaloCellContainer* theCont,
 StatusCode TBEMECXTalkToyModel::processOnCellIterators(const CaloCellContainer::iterator &  itrCellBeg,
                                                        const CaloCellContainer::iterator & itrCellEnd ) const
 {
-  unsigned int myCellHashOffset[CaloCell_ID::NSUBCALO];
-  std::set<int> m_validCalos;
-  m_validCalos.insert(CaloCell_ID::LAREM);
-  std::set<int>::const_iterator vCaloIter = m_validCalos.begin(); 
-  std::set<int>::const_iterator vCaloIterEnd = m_validCalos.end(); 
-  for(; vCaloIter!=vCaloIterEnd; vCaloIter++) {
-    IdentifierHash myHashMin,myHashMax;
-    m_calo_id->calo_cell_hash_range ((*vCaloIter),myHashMin,myHashMax);
-    myCellHashOffset[(*vCaloIter)] = myHashMin;
-  }
+  IdentifierHash myHashMin,myHashMax;
+  m_calo_id->calo_cell_hash_range (CaloCell_ID::LAREM,myHashMin,myHashMax);
+  unsigned int myCellHashOffset = myHashMin;
 
   CaloCellContainer::iterator itrCell;
   std::map<Identifier,CaloCell*> cellMap;
@@ -183,9 +176,9 @@ StatusCode TBEMECXTalkToyModel::processOnCellIterators(const CaloCellContainer::
 	IdentifierHash myHashId = m_calo_id->subcalo_cell_hash(myId,otherSubDet);
 
 	// longitudinal neighbor (N1)
-	m_calo_id->get_neighbours(myHashId+myCellHashOffset[mySubDet],LArNeighbours::nextInSamp,theNeighbors);
+	m_calo_id->get_neighbours(myHashId+myCellHashOffset,LArNeighbours::nextInSamp,theNeighbors);
         ATH_MSG_DEBUG ("N1 theNeighbors.size() = " << theNeighbors.size());
-	IdentifierHash nId = theNeighbors.at(0)-myCellHashOffset[mySubDet];
+	IdentifierHash nId = theNeighbors.at(0)-myCellHashOffset;
 	myId = m_calo_id->cell_id(mySubDet,nId);
 	std::map<Identifier,CaloCell*>::iterator cellIt = cellMap.find(myId);
 	if (cellIt==cellMap.end()) {
@@ -208,12 +201,12 @@ StatusCode TBEMECXTalkToyModel::processOnCellIterators(const CaloCellContainer::
 	int EMEC3neighbors = 0;
 	myHashId = m_calo_id->subcalo_cell_hash(theCellN1->ID(),otherSubDet);
 	//
-	m_calo_id->get_neighbours(myHashId+myCellHashOffset[mySubDet],LArNeighbours::nextInEta,theNeighbors);
+	m_calo_id->get_neighbours(myHashId+myCellHashOffset,LArNeighbours::nextInEta,theNeighbors);
 	ATH_MSG_DEBUG ( "N2 theNeighbors.size() = " << theNeighbors.size() );
 	CaloCell * theCellN2 = 0x0;
 	double eN2 = 0.;
 	if (theNeighbors.size()>0) {
-	  nId = theNeighbors.at(0)-myCellHashOffset[mySubDet];
+	  nId = theNeighbors.at(0)-myCellHashOffset;
 	  myId = m_calo_id->cell_id(mySubDet,nId);
 	  cellIt = cellMap.find(myId);
 	  theCellN2 = (*cellIt).second;
@@ -228,12 +221,12 @@ StatusCode TBEMECXTalkToyModel::processOnCellIterators(const CaloCellContainer::
 	  }
 	}
 	//
-	m_calo_id->get_neighbours(myHashId+myCellHashOffset[mySubDet],LArNeighbours::prevInEta,theNeighbors);
+	m_calo_id->get_neighbours(myHashId+myCellHashOffset,LArNeighbours::prevInEta,theNeighbors);
 	ATH_MSG_DEBUG ( "N3 theNeighbors.size() = " << theNeighbors.size() );
 	CaloCell * theCellN3 = 0x0;
 	double eN3 = 0.;
 	if (theNeighbors.size()>0) {
-	  nId = theNeighbors.at(0)-myCellHashOffset[mySubDet];
+	  nId = theNeighbors.at(0)-myCellHashOffset;
 	  myId = m_calo_id->cell_id(mySubDet,nId);
 	  cellIt = cellMap.find(myId);
 	  theCellN3 = (*cellIt).second;
@@ -252,12 +245,12 @@ StatusCode TBEMECXTalkToyModel::processOnCellIterators(const CaloCellContainer::
 	int EMEC2neighbors = 0;
 	myHashId = m_calo_id->subcalo_cell_hash(theCell->ID(),otherSubDet);
 	//
-	m_calo_id->get_neighbours(myHashId+myCellHashOffset[mySubDet],LArNeighbours::nextInEta,theNeighbors);
+	m_calo_id->get_neighbours(myHashId+myCellHashOffset,LArNeighbours::nextInEta,theNeighbors);
 	ATH_MSG_DEBUG ( "N4 theNeighbors.size() = " << theNeighbors.size() );
 	CaloCell * theCellN4 = 0x0;
 	double eN4 = 0.;
 	if (theNeighbors.size()>0) {
-	  nId = theNeighbors.at(0)-myCellHashOffset[mySubDet];
+	  nId = theNeighbors.at(0)-myCellHashOffset;
 	  myId = m_calo_id->cell_id(mySubDet,nId);
 	  cellIt = cellMap.find(myId);
 	  theCellN4 = (*cellIt).second;
@@ -272,12 +265,12 @@ StatusCode TBEMECXTalkToyModel::processOnCellIterators(const CaloCellContainer::
 	  }
 	}
 	//
-	m_calo_id->get_neighbours(myHashId+myCellHashOffset[mySubDet],LArNeighbours::prevInEta,theNeighbors);
+	m_calo_id->get_neighbours(myHashId+myCellHashOffset,LArNeighbours::prevInEta,theNeighbors);
 	ATH_MSG_DEBUG ( "N5 theNeighbors.size() = " << theNeighbors.size() );
 	CaloCell * theCellN5 = 0x0;
 	double eN5 = 0.;
 	if (theNeighbors.size()>0) {
-	  nId = theNeighbors.at(0)-myCellHashOffset[mySubDet];
+	  nId = theNeighbors.at(0)-myCellHashOffset;
 	  myId = m_calo_id->cell_id(mySubDet,nId);
 	  cellIt = cellMap.find(myId);
 	  theCellN5 = (*cellIt).second;
diff --git a/TestBeam/TBRec/src/TBEventInfoStreamerTool.cxx b/TestBeam/TBRec/src/TBEventInfoStreamerTool.cxx
index 7476e2799fe8..02cb29654056 100644
--- a/TestBeam/TBRec/src/TBEventInfoStreamerTool.cxx
+++ b/TestBeam/TBRec/src/TBEventInfoStreamerTool.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "TBEventInfoStreamerTool.h"
@@ -9,10 +9,10 @@
 #include <ios>
 #include <algorithm>
 
-TBEventInfoStreamerTool::TBEventInfoStreamerTool(const std::string& name,
-						 const std::string& type,
+TBEventInfoStreamerTool::TBEventInfoStreamerTool(const std::string& type,
+						 const std::string& name,
 					         const IInterface* parent)
-  : TBEventStreamerTool(name,type,parent),
+  : TBEventStreamerTool(type,name,parent),
     m_selected_events(0)
 {
    declareInterface<TBEventStreamerTool>(this);
diff --git a/TestBeam/TBRec/src/TBEventInfoStreamerTool.h b/TestBeam/TBRec/src/TBEventInfoStreamerTool.h
index 22a5590edd1a..ead1e39636b3 100644
--- a/TestBeam/TBRec/src/TBEventInfoStreamerTool.h
+++ b/TestBeam/TBRec/src/TBEventInfoStreamerTool.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBEVENTINFOSTREAMERTOOL_H
@@ -18,9 +18,9 @@ class TBEventInfoStreamerTool : public TBEventStreamerTool
 			    const IInterface* parent);
   virtual ~TBEventInfoStreamerTool();
 
-  virtual StatusCode initializeTool();
+  virtual StatusCode initializeTool() override;
 
-  virtual StatusCode accept();
+  virtual StatusCode accept() override;
 
  protected:
 
diff --git a/TestBeam/TBRec/src/TBEventStreamer.cxx b/TestBeam/TBRec/src/TBEventStreamer.cxx
index e2c7c22986e2..73a7844c5dcb 100644
--- a/TestBeam/TBRec/src/TBEventStreamer.cxx
+++ b/TestBeam/TBRec/src/TBEventStreamer.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 
@@ -41,9 +41,7 @@ StatusCode TBEventStreamer::initialize()
   ATH_MSG_INFO ( "------------------------------------" );
   ATH_MSG_INFO ( " " );
   unsigned int toolCtr = 0;
-  ToolHandleArray<TBEventStreamerTool>::iterator fTool = m_tools.begin();
-  ToolHandleArray<TBEventStreamerTool>::iterator lTool = m_tools.end();
-  for ( ; fTool != lTool; fTool++ ) {
+  for (ToolHandle<TBEventStreamerTool>& tool : m_tools) {
       toolCtr++;
       ATH_MSG_INFO (std::setw(2)
                     //<< std::setiosflags(std::ios_base::right)
@@ -52,9 +50,9 @@ StatusCode TBEventStreamer::initialize()
                     //<< std::setw(36)
                     //<< std::setfill('.')
                     //<< std::setiosflags(std::ios_base::left)
-                    << (*fTool)->type()
+                    << tool->type()
                     //<< std::setfill('.')
-                    << (*fTool)->name() );
+                    << tool->name() );
                     //<< std::setfill(' ')
     }
 
@@ -64,24 +62,20 @@ StatusCode TBEventStreamer::initialize()
 
 StatusCode TBEventStreamer::execute()
 {
-  // invoke tools
-  ToolHandleArray<TBEventStreamerTool>::iterator fTool = m_tools.begin();
-  ToolHandleArray<TBEventStreamerTool>::iterator lTool = m_tools.end();
-
   bool successFlag = true;
-  while ( successFlag && fTool != lTool )
+  for (ToolHandle<TBEventStreamerTool>& tool : m_tools)
     {
-      m_invokeCounter[*fTool]++;
-      successFlag = (*fTool)->accept() == StatusCode::SUCCESS;
+      m_invokeCounter[tool]++;
+      successFlag = tool->accept() == StatusCode::SUCCESS;
       if ( successFlag )
 	{
-	  m_acceptCounter[*fTool]++;
+	  m_acceptCounter[tool]++;
 	}
       else
 	{
-	  m_rejectCounter[*fTool]++;
+	  m_rejectCounter[tool]++;
+          break;
 	}
-      fTool++;
     }
 
    setFilterPassed(successFlag); 
@@ -91,15 +85,13 @@ StatusCode TBEventStreamer::execute()
 StatusCode TBEventStreamer::finalize()
 {
   // print summary
-  ToolHandleArray<TBEventStreamerTool>::iterator fTool = m_tools.begin();
-  ToolHandleArray<TBEventStreamerTool>::iterator lTool = m_tools.end();
-  for ( ; fTool != lTool; fTool++ ) {
+  for (ToolHandle<TBEventStreamerTool>& tool : m_tools) {
     ATH_MSG_INFO ( "Tool "
-                   << (*fTool)->name()
+                   << tool->name()
                    << " (invoked/accept/reject) "
-                   << "(" << m_invokeCounter[*fTool]
-                   << "/" << m_acceptCounter[*fTool]
-                   << "/" << m_rejectCounter[*fTool]
+                   << "(" << m_invokeCounter[tool]
+                   << "/" << m_acceptCounter[tool]
+                   << "/" << m_rejectCounter[tool]
                    << ")" );
     }
 
diff --git a/TestBeam/TBRec/src/TBEventStreamer.h b/TestBeam/TBRec/src/TBEventStreamer.h
index 41bad4f6074f..ca7c4364a640 100755
--- a/TestBeam/TBRec/src/TBEventStreamer.h
+++ b/TestBeam/TBRec/src/TBEventStreamer.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBEVENTSTREAMER_H
@@ -27,14 +27,12 @@ class TBEventStreamer : public AthAlgorithm
   TBEventStreamer(const std::string& name, ISvcLocator* pService);
   virtual ~TBEventStreamer();
 
-  virtual StatusCode initialize();
-  virtual StatusCode execute();
-  virtual StatusCode finalize();
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
 
  protected:
 
-//  std::vector<std::string> m_toolNames;
-//  std::vector<TBEventStreamerTool*> m_tools;
   ToolHandleArray<TBEventStreamerTool> m_tools;
 
   std::map<ToolHandle<TBEventStreamerTool>, unsigned int> m_acceptCounter;
diff --git a/TestBeam/TBRec/src/TBEventStreamerTool.h b/TestBeam/TBRec/src/TBEventStreamerTool.h
index bc06fe66c161..b5bbe14b9f4f 100755
--- a/TestBeam/TBRec/src/TBEventStreamerTool.h
+++ b/TestBeam/TBRec/src/TBEventStreamerTool.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBEVENTSTREAMERTOOL_H
@@ -23,7 +23,7 @@ class TBEventStreamerTool : public AthAlgTool
 
   virtual StatusCode reject();
 
-  virtual StatusCode initialize();
+  virtual StatusCode initialize() override;
 
   virtual StatusCode initializeTool();
 
diff --git a/TestBeam/TBRec/src/TBExtrapolTrackToCaloTool.h b/TestBeam/TBRec/src/TBExtrapolTrackToCaloTool.h
index 6da14524e866..c477152f3caa 100644
--- a/TestBeam/TBRec/src/TBExtrapolTrackToCaloTool.h
+++ b/TestBeam/TBRec/src/TBExtrapolTrackToCaloTool.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 // ***************************************************************************
@@ -93,10 +93,10 @@ public:
 		  const std::string& name, 
 		  const IInterface* parent); 
 
-  ~TBExtrapolTrackToCaloTool();
+  virtual ~TBExtrapolTrackToCaloTool();
 
-  StatusCode initialize();
-  StatusCode finalize();
+  virtual StatusCode initialize() override;
+  virtual StatusCode finalize() override;
 
 
   /** now return the variables needed to compare with CaloClusters: */
@@ -256,10 +256,6 @@ private:
 
   // Pre-configured extrapolator : will be choosen via jobOpt
   ToolHandle< Trk::IExtrapolator > m_extrapolator;
-  // Trk::IExtrapolator*  m_extrapolator;
-
-
-
 };
 
  
diff --git a/TestBeam/TBRec/src/TBLArRawChannelBuilder.h b/TestBeam/TBRec/src/TBLArRawChannelBuilder.h
index 142ba5d5ddfa..91c2cbd9d2c5 100644
--- a/TestBeam/TBRec/src/TBLArRawChannelBuilder.h
+++ b/TestBeam/TBRec/src/TBLArRawChannelBuilder.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBLARRAWCHANNELBUILDER_H
@@ -29,9 +29,9 @@ class TBLArRawChannelBuilder : public AthAlgorithm
 public:
 
   TBLArRawChannelBuilder (const std::string& name, ISvcLocator* pSvcLocator);
-  StatusCode initialize();
-  StatusCode execute();
-  StatusCode finalize();
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
 
 private:
   //Services & Tools 
@@ -57,9 +57,6 @@ private:
   float m_ADCtoMeVEMECOuter[2];
   float m_ADCtoMeVEMB[2];
   
-  //Private Member functions:
-  //void sortChannels(LArRawChannelContainer* container) ;
-
   unsigned int m_iPedestal;
 };
 
diff --git a/TestBeam/TBRec/src/TBMWPCRec.cxx b/TestBeam/TBRec/src/TBMWPCRec.cxx
index 105c2df2b596..b6294a202a6a 100644
--- a/TestBeam/TBRec/src/TBMWPCRec.cxx
+++ b/TestBeam/TBRec/src/TBMWPCRec.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 
@@ -52,12 +52,9 @@ TBMWPCRec::execute()
     ATH_MSG_DEBUG ( "TBMWPCRec : Retrieval of "<<m_SGkey<<" succeed : cont size=" << mwpcrawCont->size());
     
     TBMWPCCont * mwpcCont = new TBMWPCCont();
-    TBMWPCRawCont::const_iterator it_bc   = mwpcrawCont->begin();
-    TBMWPCRawCont::const_iterator last_bc   = mwpcrawCont->end();
 
     // Loop over MWPC
-    for(;it_bc != last_bc;it_bc++){
-      const TBMWPCRaw * mwpcraw= (*it_bc);
+    for (const TBMWPCRaw* mwpcraw : *mwpcrawCont) {
       std::string name = mwpcraw->getDetectorName();
       unsigned int ind=0;
       // Find calibration index for this MWPC
diff --git a/TestBeam/TBRec/src/TBMWPCRec.h b/TestBeam/TBRec/src/TBMWPCRec.h
index 4d37c1fe9dd9..da791efdee2f 100755
--- a/TestBeam/TBRec/src/TBMWPCRec.h
+++ b/TestBeam/TBRec/src/TBMWPCRec.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBMWPCREC
@@ -24,12 +24,11 @@ class TBMWPCRec : public AthAlgorithm
  public:
 
   TBMWPCRec(const std::string& name, ISvcLocator* pSvcLocator);
-  ~TBMWPCRec();
-
-  StatusCode initialize();
-  StatusCode execute();
-  StatusCode finalize();
+  virtual ~TBMWPCRec();
 
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
 
 
  private:
diff --git a/TestBeam/TBRec/src/TBNoiseWrite.cxx b/TestBeam/TBRec/src/TBNoiseWrite.cxx
index 74ffabe70c24..ef89114f5318 100644
--- a/TestBeam/TBRec/src/TBNoiseWrite.cxx
+++ b/TestBeam/TBRec/src/TBNoiseWrite.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 // class TBNoiseWrite // Write ROOT Tree with noise in randomly triggered 
@@ -136,9 +136,7 @@ StatusCode TBNoiseWrite::execute()
   ATH_CHECK( evtStore()->retrieve(cellContainer, m_caloCellContainerName) );
 
   // Cell loop
-  CaloCellContainer::const_iterator itc = cellContainer->begin();
-  for (;itc!=cellContainer->end(); itc++) {
-    const CaloCell* cell = (*itc);
+  for (const CaloCell* cell : *cellContainer) {
     unsigned int id = cell->ID().get_identifier32().get_compact();
     m_cell_id->push_back(id);
     m_cell_energy->push_back((float)cell->energy());
diff --git a/TestBeam/TBRec/src/TBNoiseWrite.h b/TestBeam/TBRec/src/TBNoiseWrite.h
index c78c78895f7c..4c5787f8e788 100644
--- a/TestBeam/TBRec/src/TBNoiseWrite.h
+++ b/TestBeam/TBRec/src/TBNoiseWrite.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBNOISEWRITE_H
@@ -23,9 +23,9 @@ class TBNoiseWrite: public AthAlgorithm {
   
   TBNoiseWrite(const std::string& name, ISvcLocator* pSvcLocator);
   virtual ~TBNoiseWrite();
-  StatusCode initialize();
-  StatusCode execute();
-  StatusCode finalize();
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
   
  private: 
   void clear();
@@ -61,9 +61,6 @@ class TBNoiseWrite: public AthAlgorithm {
   TTree* m_header_tree;                   // Header Tree pointer
   TTree* m_tree;                          // Noise Tree pointer
 
-  //const CaloCell_ID* m_calo_id;
-  //const CaloDetDescrManager* m_calo_dd_man; 
-
   /** Text file containing xCryo and yTable */
   std::string m_txtFileWithXY;
 };
diff --git a/TestBeam/TBRec/src/TBPartIDCherenkovMuTag.cxx b/TestBeam/TBRec/src/TBPartIDCherenkovMuTag.cxx
index 2f66c7aad7a7..02dc2e892bad 100644
--- a/TestBeam/TBRec/src/TBPartIDCherenkovMuTag.cxx
+++ b/TestBeam/TBRec/src/TBPartIDCherenkovMuTag.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "TBPartIDCherenkovMuTag.h"
@@ -38,24 +38,22 @@ StatusCode TBPartIDCherenkovMuTag::execute() {
     return StatusCode::SUCCESS;
   }
   TBIdentifiedParticle* myParticle = new TBIdentifiedParticle();
-  TBScintillatorCont::const_iterator it   = scintCont->begin();
-  TBScintillatorCont::const_iterator it_e = scintCont->end();
   //The following loop is broken as soon as the muon tag is found above the threshold
-  //Hence this can overwrite a preceeding electron/pion judgement by the chrenkov. 
-  for(;it!=it_e;it++) {
-    if((*it)->getDetectorName()==m_muonTagName) {
-      if ((*it)->getSignal()>m_muonADCcut) {
+  //Hence this can overwrite a preceeding electron/pion judgement by the chrenkov.
+  for (const TBScintillator* scint : *scintCont) {
+    if(scint->getDetectorName()==m_muonTagName) {
+      if (scint->getSignal()>m_muonADCcut) {
 	myParticle->setParticle(TBIdentifiedParticle::MUON);
-	ATH_MSG_DEBUG (" MuonTag=" << (*it)->getSignal() );
+	ATH_MSG_DEBUG (" MuonTag=" << scint->getSignal() );
 	break;
       }
     }
-    if ((*it)->getDetectorName()==m_CherenkovName) {
-      if((*it)->getSignal()>m_cherenkovADCcut)
+    if (scint->getDetectorName()==m_CherenkovName) {
+      if(scint->getSignal()>m_cherenkovADCcut)
 	myParticle->setParticle(TBIdentifiedParticle::ELECTRON);
       else 
 	myParticle->setParticle(TBIdentifiedParticle::PION);
-      ATH_MSG_DEBUG (" Cherenkov=" << (*it)->getSignal() );
+      ATH_MSG_DEBUG (" Cherenkov=" << scint->getSignal() );
     }
   }
     
diff --git a/TestBeam/TBRec/src/TBPartIDCherenkovMuTag.h b/TestBeam/TBRec/src/TBPartIDCherenkovMuTag.h
index af136d4cca5c..e858f725b7b7 100644
--- a/TestBeam/TBRec/src/TBPartIDCherenkovMuTag.h
+++ b/TestBeam/TBRec/src/TBPartIDCherenkovMuTag.h
@@ -1,7 +1,7 @@
 //Dear emacs, this is -*- c++ -*-
 
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBPARTICLEIDCHERENKOVMUTAG_H
@@ -13,10 +13,10 @@ class TBPartIDCherenkovMuTag : public AthAlgorithm
 {
  public:
   TBPartIDCherenkovMuTag(const std::string& name, ISvcLocator* pSvcLocator);
-  ~TBPartIDCherenkovMuTag();
-  StatusCode initialize();
-  StatusCode execute();
-  StatusCode finalize();
+  virtual ~TBPartIDCherenkovMuTag();
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
   
  private:
   std::string m_SGkeyscint,m_muonTagName,m_CherenkovName,m_particleKey;
diff --git a/TestBeam/TBRec/src/TBPatternUnitStreamerTool.cxx b/TestBeam/TBRec/src/TBPatternUnitStreamerTool.cxx
index b7865f70450d..9501446446c4 100644
--- a/TestBeam/TBRec/src/TBPatternUnitStreamerTool.cxx
+++ b/TestBeam/TBRec/src/TBPatternUnitStreamerTool.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "TBPatternUnitStreamerTool.h"
@@ -10,10 +10,10 @@
 #include <string>
 #include <ios>
 
-TBPatternUnitStreamerTool::TBPatternUnitStreamerTool(const std::string& name,
-						     const std::string& type,
+TBPatternUnitStreamerTool::TBPatternUnitStreamerTool(const std::string& type,
+						     const std::string& name,
 						     const IInterface* parent)
-  : TBEventStreamerTool(name,type,parent)
+  : TBEventStreamerTool(type,name,parent)
     , m_patternUnitKey("TBTrigPat")
     , m_acceptPattern()
     , m_rejectPattern()
@@ -220,12 +220,10 @@ StatusCode TBPatternUnitStreamerTool::findPattern(const pattern_store&
   MsgStream report(msgSvc(),name());
 
   // build pattern
-  pattern_store::const_iterator firstPattern = listOfPatterns.begin();
-  pattern_store::const_iterator lastPattern  = listOfPatterns.end();
-  for ( ; firstPattern != lastPattern; firstPattern++ )
+  for (const pattern& pat : listOfPatterns)
     {
       bit_mask_store::const_iterator findIter = 
-	definedPattern.find(*firstPattern);
+	definedPattern.find(pat);
       if ( findIter != definedPattern.end() )
 	{
 	  theMask = theMask | (*findIter).second;
@@ -234,7 +232,7 @@ StatusCode TBPatternUnitStreamerTool::findPattern(const pattern_store&
 	{
 	  report << MSG::WARNING
 		 << "requested pattern <"
-		 << *firstPattern
+		 << pat
 		 << "> unknown, ignore..."
 		 << endmsg;
 	}
diff --git a/TestBeam/TBRec/src/TBPatternUnitStreamerTool.h b/TestBeam/TBRec/src/TBPatternUnitStreamerTool.h
index d82e35f54959..43b584e72ffa 100644
--- a/TestBeam/TBRec/src/TBPatternUnitStreamerTool.h
+++ b/TestBeam/TBRec/src/TBPatternUnitStreamerTool.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBPATTERNUNITSTREAMERTOOL_H
@@ -44,9 +44,9 @@ class TBPatternUnitStreamerTool : public TBEventStreamerTool
 			    const IInterface* parent);
   virtual ~TBPatternUnitStreamerTool();
 
-  virtual StatusCode initializeTool();
+  virtual StatusCode initializeTool() override;
 
-  virtual StatusCode accept();
+  virtual StatusCode accept() override;
 
  protected:
 
diff --git a/TestBeam/TBRec/src/TBPatternUnitStreamerToolH8.cxx b/TestBeam/TBRec/src/TBPatternUnitStreamerToolH8.cxx
index 687b3e0be329..df5b12726940 100644
--- a/TestBeam/TBRec/src/TBPatternUnitStreamerToolH8.cxx
+++ b/TestBeam/TBRec/src/TBPatternUnitStreamerToolH8.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "TBPatternUnitStreamerToolH8.h"
@@ -9,10 +9,10 @@
 
 
 TBPatternUnitStreamerToolH8::TBPatternUnitStreamerToolH8(
-						     const std::string& name,
 						     const std::string& type,
+						     const std::string& name,
 						     const IInterface* parent)
-  : TBEventStreamerTool(name,type,parent)
+  : TBEventStreamerTool(type,name,parent)
     , m_patternUnitKey("TBTrigPat")
     , m_acceptPattern()
     , m_rejectPattern()
@@ -194,12 +194,10 @@ StatusCode TBPatternUnitStreamerToolH8::findPattern(const pattern_store&
   MsgStream report(msgSvc(),name());
 
   // build pattern
-  pattern_store::const_iterator firstPattern = listOfPatterns.begin();
-  pattern_store::const_iterator lastPattern  = listOfPatterns.end();
-  for ( ; firstPattern != lastPattern; firstPattern++ )
+  for (const pattern& pat : listOfPatterns)
     {
       bit_mask_store::const_iterator findIter = 
-	definedPattern.find(*firstPattern);
+	definedPattern.find(pat);
       if ( findIter != definedPattern.end() )
 	{
 	  theMask = theMask | (*findIter).second;
@@ -208,7 +206,7 @@ StatusCode TBPatternUnitStreamerToolH8::findPattern(const pattern_store&
 	{
 	  report << MSG::WARNING
 		 << "requested pattern <"
-		 << *firstPattern
+		 << pat
 		 << "> unknown, ignore..."
 		 << endmsg;
 	}
diff --git a/TestBeam/TBRec/src/TBPatternUnitStreamerToolH8.h b/TestBeam/TBRec/src/TBPatternUnitStreamerToolH8.h
index e3a2c04af8b4..3fd0d74587a4 100644
--- a/TestBeam/TBRec/src/TBPatternUnitStreamerToolH8.h
+++ b/TestBeam/TBRec/src/TBPatternUnitStreamerToolH8.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBPATTERNUNITSTREAMERTOOLH8_H
@@ -44,9 +44,9 @@ class TBPatternUnitStreamerToolH8 : public TBEventStreamerTool
 			    const IInterface* parent);
   virtual ~TBPatternUnitStreamerToolH8();
 
-  virtual StatusCode initializeTool();
+  virtual StatusCode initializeTool() override;
 
-  virtual StatusCode accept();
+  virtual StatusCode accept() override;
 
  protected:
 
diff --git a/TestBeam/TBRec/src/TBPhaseRec.cxx b/TestBeam/TBRec/src/TBPhaseRec.cxx
index f2c6cc12ac45..548204631039 100644
--- a/TestBeam/TBRec/src/TBPhaseRec.cxx
+++ b/TestBeam/TBRec/src/TBPhaseRec.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 
@@ -180,8 +180,7 @@ StatusCode TBPhaseRec::execute()
   // Loop over TDC's
   int tdcFound = 0;
   int tdcFoundAndOK = 0;
-  for (TBTDCRawCont::const_iterator it_tdc = tdcRawCont->begin(); it_tdc != tdcRawCont->end(); it_tdc++) {
-    const TBTDCRaw* tdcRaw = (*it_tdc);
+  for (const TBTDCRaw* tdcRaw : *tdcRawCont) {
     std::string tdcName = tdcRaw->getDetectorName();
     int tdcIndex = 0;
     for (; tdcIndex < m_nTDC; tdcIndex++) {
diff --git a/TestBeam/TBRec/src/TBPhaseRec.h b/TestBeam/TBRec/src/TBPhaseRec.h
index 91c499f3dcbc..cdbaafd257d9 100755
--- a/TestBeam/TBRec/src/TBPhaseRec.h
+++ b/TestBeam/TBRec/src/TBPhaseRec.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBPHASEREC
@@ -22,11 +22,11 @@ class TBPhaseRec : public AthAlgorithm
 {
  public:
   TBPhaseRec(const std::string& name, ISvcLocator* pSvcLocator);
-  ~TBPhaseRec();
+  virtual ~TBPhaseRec();
 
-  StatusCode initialize();
-  StatusCode execute();
-  StatusCode finalize();
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
   
   StatusCode getnewcalib();
   
diff --git a/TestBeam/TBRec/src/TBPhaseStreamerTool.cxx b/TestBeam/TBRec/src/TBPhaseStreamerTool.cxx
index 27f74eb3c3da..f217132a036d 100644
--- a/TestBeam/TBRec/src/TBPhaseStreamerTool.cxx
+++ b/TestBeam/TBRec/src/TBPhaseStreamerTool.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "TBPhaseStreamerTool.h"
@@ -7,10 +7,10 @@
 #include <string>
 #include <ios>
 
-TBPhaseStreamerTool::TBPhaseStreamerTool(const std::string& name,
-						     const std::string& type,
-						     const IInterface* parent)
-  : TBEventStreamerTool(name,type,parent)
+TBPhaseStreamerTool::TBPhaseStreamerTool(const std::string& type,
+                                         const std::string& name,
+                                         const IInterface* parent)
+  : TBEventStreamerTool(type,name,parent)
     , m_guardValue(11.)         // in TDC counts
     , m_TBPhaseKey("TBPhase")
 {
diff --git a/TestBeam/TBRec/src/TBPhaseStreamerTool.h b/TestBeam/TBRec/src/TBPhaseStreamerTool.h
index 728162d3e832..17b8b5f763f2 100644
--- a/TestBeam/TBRec/src/TBPhaseStreamerTool.h
+++ b/TestBeam/TBRec/src/TBPhaseStreamerTool.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBPHASESTREAMERTOOL_H
@@ -30,13 +30,13 @@ class TBPhaseStreamerTool : public TBEventStreamerTool
  public:
 
   TBPhaseStreamerTool(const std::string& type,
-			    const std::string& name,
-			    const IInterface* parent);
+                      const std::string& name,
+                      const IInterface* parent);
   virtual ~TBPhaseStreamerTool();
 
-  virtual StatusCode initializeTool();
+  virtual StatusCode initializeTool() override;
 
-  virtual StatusCode accept();
+  virtual StatusCode accept() override;
 
  protected:
 
diff --git a/TestBeam/TBRec/src/TBPlaneTrackingAlgo.cxx b/TestBeam/TBRec/src/TBPlaneTrackingAlgo.cxx
index b5de954e0d15..9d0ecdf80577 100644
--- a/TestBeam/TBRec/src/TBPlaneTrackingAlgo.cxx
+++ b/TestBeam/TBRec/src/TBPlaneTrackingAlgo.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "TBPlaneTrackingAlgo.h"
@@ -202,23 +202,20 @@ double &a1, double &a2,double &chi2, std::vector<double> &residual)
   
   ATH_MSG_DEBUG ("The hit plane container size is: " << hitPlaneNum);
   
-  TBHitPlaneCont::const_iterator it_hit = hitPlaneCont->begin();
-  TBHitPlaneCont::const_iterator last_hit = hitPlaneCont->end();
-  
   std::vector<double> vec_u;
   std::vector<double> vec_w;
   std::vector<double> err_vec_u;
   std::vector<double> err_vec_w;
 
-  for (; it_hit!=last_hit; it_hit++) { 
-    ATH_MSG_DEBUG ("Position in u: " << (*it_hit)->getPosu());
-    ATH_MSG_DEBUG ("Position in w: " << (*it_hit)->getPosw());
-    ATH_MSG_DEBUG ("Error in u: " << (*it_hit)->getErroru());
-    ATH_MSG_DEBUG ("Error in w: " << (*it_hit)->getErrorw());
-    vec_u.push_back((*it_hit)->getPosu());
-    vec_w.push_back((*it_hit)->getPosw());
-    err_vec_u.push_back((*it_hit)->getErroru());
-    err_vec_w.push_back((*it_hit)->getErrorw());
+  for (const TBHitPlane* hp : *hitPlaneCont) {
+    ATH_MSG_DEBUG ("Position in u: " << hp->getPosu());
+    ATH_MSG_DEBUG ("Position in w: " << hp->getPosw());
+    ATH_MSG_DEBUG ("Error in u: " << hp->getErroru());
+    ATH_MSG_DEBUG ("Error in w: " << hp->getErrorw());
+    vec_u.push_back(hp->getPosu());
+    vec_w.push_back(hp->getPosw());
+    err_vec_u.push_back(hp->getErroru());
+    err_vec_w.push_back(hp->getErrorw());
   }
   
   if(vec_u.size() != vec_w.size()){
@@ -371,33 +368,24 @@ void TBPlaneTrackingAlgo::FillRandomHit()
 StatusCode TBPlaneTrackingAlgo::buildHits()
 /////////////////////////////////////////
 {
-  StatusCode sc;
   ATH_MSG_DEBUG (" In buildHits() ");
   m_hitPlaneCont_u.clear();
   m_hitPlaneCont_v.clear();
 
-  TBBPCCont * bpcCont;
-  sc = evtStore()->retrieve(bpcCont, "BPCCont");
-  if (sc.isFailure()){
-    ATH_MSG_DEBUG ("Retrieval of BPCCont failed");
-    
-  }else {
-
-    TBBPCCont::const_iterator it_bc   = bpcCont->begin();
-    TBBPCCont::const_iterator last_bc   = bpcCont->end();
+  TBBPCCont * bpcCont = nullptr;
+  ATH_CHECK( evtStore()->retrieve(bpcCont, "BPCCont") );
 
   // Loop over BPC
-  for(;it_bc != last_bc;it_bc++){
-    const TBBPC * bpc = (*it_bc);
+  for (const TBBPC* bpc : *bpcCont) {
     std::string name = bpc->getDetectorName();
     ATH_MSG_DEBUG (" Hits in BPC "<< name);
     // Find calibration index for this BPC
     unsigned int ind=0;
     while(ind<m_bpc_names.size()) 
-	{
-	  if(name==m_bpc_names[ind]) break; 
-	  else ind++;
-	}
+    {
+      if(name==m_bpc_names[ind]) break; 
+      else ind++;
+    }
     if(ind==m_bpc_names.size()){
       ATH_MSG_ERROR ("No calibrations for BPC" << name);
       continue;
@@ -431,13 +419,9 @@ StatusCode TBPlaneTrackingAlgo::buildHits()
       hitv->setValidFlag(bpc->isXPosOverflow()&&bpc->isYPosOverflow());
       m_hitPlaneCont_v.push_back(hitv);
     }
+  }
 
-
-    }
-  } // BPC
-
-  return sc;
-
+  return StatusCode::SUCCESS;
 }
 
 
diff --git a/TestBeam/TBRec/src/TBPlaneTrackingAlgo.h b/TestBeam/TBRec/src/TBPlaneTrackingAlgo.h
index 711cb606a6b6..0d17367ea456 100644
--- a/TestBeam/TBRec/src/TBPlaneTrackingAlgo.h
+++ b/TestBeam/TBRec/src/TBPlaneTrackingAlgo.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBPLANETRACKINGALGO_H
@@ -24,12 +24,12 @@ class TBPlaneTrackingAlgo : public AthAlgorithm {
   // Contructor & Destructor //
   /////////////////////////////
   TBPlaneTrackingAlgo(const std::string& name, ISvcLocator* pSvcLocator);
-  ~TBPlaneTrackingAlgo(){};
+  virtual ~TBPlaneTrackingAlgo(){};
 
   // public methods //
-  StatusCode initialize();
-  StatusCode execute();
-  StatusCode finalize();
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
 
  private:
   void FillRandomHit();
diff --git a/TestBeam/TBRec/src/TBPreScalerStreamerTool.h b/TestBeam/TBRec/src/TBPreScalerStreamerTool.h
index 56a18444425e..bdb99d280df4 100644
--- a/TestBeam/TBRec/src/TBPreScalerStreamerTool.h
+++ b/TestBeam/TBRec/src/TBPreScalerStreamerTool.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBPRESCALERSTREAMERTOOL_H
@@ -27,9 +27,9 @@ class TBPreScalerStreamerTool : public TBEventStreamerTool
 			  const IInterface* parent);
   virtual ~TBPreScalerStreamerTool();
 
-  virtual StatusCode initializeTool();
+  virtual StatusCode initializeTool() override;
 
-  virtual StatusCode accept();
+  virtual StatusCode accept() override;
 
  protected:
 
diff --git a/TestBeam/TBRec/src/TBScintillatorRec.h b/TestBeam/TBRec/src/TBScintillatorRec.h
index b29176cae0d0..337e77edcfdd 100644
--- a/TestBeam/TBRec/src/TBScintillatorRec.h
+++ b/TestBeam/TBRec/src/TBScintillatorRec.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBSCINTREC_H
@@ -20,12 +20,11 @@ class TBScintillatorRec : public AthAlgorithm
 {
  public:
   TBScintillatorRec(const std::string& name, ISvcLocator* pSvcLocator);
-  ~TBScintillatorRec();
+  virtual ~TBScintillatorRec();
 
-  StatusCode initialize();
-  StatusCode execute();
-  StatusCode finalize();
-  
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
 
 
  private:
@@ -42,7 +41,6 @@ class TBScintillatorRec : public AthAlgorithm
 
   // Scintillators
   std::vector<std::string> m_scint_names;
-  //  std::vector<float> m_scint_calib;
   std::vector<float> m_scint_timecalib;
   std::vector<float> m_scint_ped;
 
diff --git a/TestBeam/TBRec/src/TBTailCatcherRec.h b/TestBeam/TBRec/src/TBTailCatcherRec.h
index 2d3e3be87371..706a01c99d9a 100644
--- a/TestBeam/TBRec/src/TBTailCatcherRec.h
+++ b/TestBeam/TBRec/src/TBTailCatcherRec.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBTAILCATCHERREC_H
@@ -24,12 +24,11 @@ class TBTailCatcherRec : public AthAlgorithm
  public:
 
   TBTailCatcherRec(const std::string& name, ISvcLocator* pSvcLocator);
-  ~TBTailCatcherRec();
-
-  StatusCode initialize();
-  StatusCode execute();
-  StatusCode finalize();
+  virtual ~TBTailCatcherRec();
 
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
 
 
  private:
diff --git a/TestBeam/TBRec/src/TBTrackInfoFromTag.h b/TestBeam/TBRec/src/TBTrackInfoFromTag.h
index fd09cf004a5e..963d4b5543cc 100644
--- a/TestBeam/TBRec/src/TBTrackInfoFromTag.h
+++ b/TestBeam/TBRec/src/TBTrackInfoFromTag.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBTRACKINFOFROMTAG_H
@@ -56,11 +56,11 @@ class TBTrackInfoFromTag : public AthAlgorithm
  public:
 
   TBTrackInfoFromTag(const std::string& name, ISvcLocator* pSvcLocator);
-  ~TBTrackInfoFromTag();
+  virtual ~TBTrackInfoFromTag();
 
-  StatusCode initialize();
-  StatusCode execute();
-  StatusCode finalize();
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
 
  private:
 
diff --git a/TestBeam/TBRec/src/TBTrackToCaloAlg.h b/TestBeam/TBRec/src/TBTrackToCaloAlg.h
index c8c1169bc94f..eeff8bdfa121 100644
--- a/TestBeam/TBRec/src/TBTrackToCaloAlg.h
+++ b/TestBeam/TBRec/src/TBTrackToCaloAlg.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 ///////////////////////////////////////////////////////////////////
@@ -16,7 +16,6 @@
 // Base class
 #include "AthenaBaseComps/AthAlgorithm.h"
 #include "GaudiKernel/ToolHandle.h"
-#include "StoreGate/DataHandle.h"
 //#include "TrkTrack/Track.h"
 #include "TrkTrack/TrackCollection.h"   // typedef
 //#include "Particle/TrackParticleContainer.h"
@@ -73,9 +72,9 @@ public:
   ///////////////////////////////////////////////////////////////////
 
   // Basic algorithm methods:
-  virtual StatusCode initialize();
-  virtual StatusCode execute();
-  virtual StatusCode finalize();
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
 
   // Loop on Trk::Tracks and create ImpactInCaloCollection
   bool CreateTrkImpactInCalo();
@@ -124,7 +123,6 @@ private:
 
   // Between the 2 :
   std::string m_ImpactInCalosOutputName;
-  //IExtrapolateToCaloTool* m_toCalo;
   TBExtrapolTrackToCaloTool* m_toCalo;
   CaloDepthTool* m_calodepth;
   CaloPhiRange m_phiRange;
diff --git a/TestBeam/TBRec/src/TBTree_CaloClusterH6.h b/TestBeam/TBRec/src/TBTree_CaloClusterH6.h
index 823a44b80588..aab7eda1892e 100644
--- a/TestBeam/TBRec/src/TBTree_CaloClusterH6.h
+++ b/TestBeam/TBRec/src/TBTree_CaloClusterH6.h
@@ -29,9 +29,9 @@ class TBTree_CaloClusterH6: public AthAlgorithm {
   
   TBTree_CaloClusterH6(const std::string& name, ISvcLocator* pSvcLocator);
   virtual ~TBTree_CaloClusterH6();
-  StatusCode initialize();
-  StatusCode execute();
-  StatusCode finalize();
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
   
  private: 
   void clear();
diff --git a/TestBeam/TBRec/src/TBXCryYTableRead.h b/TestBeam/TBRec/src/TBXCryYTableRead.h
index 2d778cae70aa..4391f005f99e 100644
--- a/TestBeam/TBRec/src/TBXCryYTableRead.h
+++ b/TestBeam/TBRec/src/TBXCryYTableRead.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBXCRYYTABLEREAD_H
@@ -17,9 +17,9 @@ class TBXCryYTableRead: public AthAlgorithm {
   
   TBXCryYTableRead(const std::string& name, ISvcLocator* pSvcLocator);
   virtual ~TBXCryYTableRead();
-  StatusCode initialize();
-  StatusCode execute();
-  StatusCode finalize();
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
   
  private: 
   void clear();
diff --git a/TestBeam/TBRec/src/TBXMLCaloCellWriterTool.cxx b/TestBeam/TBRec/src/TBXMLCaloCellWriterTool.cxx
index 8f5ae08e4423..755bb390adbf 100644
--- a/TestBeam/TBRec/src/TBXMLCaloCellWriterTool.cxx
+++ b/TestBeam/TBRec/src/TBXMLCaloCellWriterTool.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 
@@ -191,7 +191,7 @@ TBXMLCaloCellWriterTool::writeEvent(std::ostream& outStream,
 
       unsigned int theCtr = 0;
       bool isTerminated = false;
-      for ( ; firstCell != lastCell; firstCell++ )
+      for ( ; firstCell != lastCell; ++firstCell )
 	{  
 	  // check if cell in requested layer and range
 	  double eta = (*firstCell)->eta();
@@ -444,22 +444,22 @@ TBXMLCaloCellWriterTool::convertProperties()
       if ( *firstCalo == "LAREM" )
 	{
 	  m_caloIndices.push_back(CaloCell_ID::LAREM);
-	  firstCalo++;
+	  ++firstCalo;
 	}
       else if ( *firstCalo == "LARHEC" )
 	{
 	  m_caloIndices.push_back(CaloCell_ID::LARHEC);
-	  firstCalo++;
+	  ++firstCalo;
 	}
       else if ( *firstCalo == "LARFCAL" )
 	{
 	  m_caloIndices.push_back(CaloCell_ID::LARFCAL);
-	  firstCalo++;
+	  ++firstCalo;
 	}
       else if ( *firstCalo == "TILE" )
 	{
 	  m_caloIndices.push_back(CaloCell_ID::TILE);
-	  firstCalo++;
+	  ++firstCalo;
 	}
       else
 	{
@@ -471,52 +471,49 @@ TBXMLCaloCellWriterTool::convertProperties()
   // Get CaloSamplings //
   ///////////////////////
 
-  std::vector<std::string>::iterator firstSampl = m_includedSamplings.begin();
-  std::vector<std::string>::iterator lastSampl  = m_includedSamplings.end();
-
   // nasty (no switch on string types...)
-  for ( ; firstSampl != lastSampl; firstSampl++ )
+  for (const std::string& sample : m_includedSamplings)
     {
       // H8 calos
-      if ( *firstSampl == "PreSamplerB" ) 
+      if ( sample == "PreSamplerB" ) 
 	m_caloSamplings.push_back(CaloSampling::PreSamplerB);
-      if ( *firstSampl == "EMB0" )
+      if ( sample == "EMB0" )
 	m_caloSamplings.push_back(CaloSampling::EMB1);
-      if ( *firstSampl == "EMB1" )
+      if ( sample == "EMB1" )
 	m_caloSamplings.push_back(CaloSampling::EMB2);
-      if ( *firstSampl == "EMB2" )
+      if ( sample == "EMB2" )
 	m_caloSamplings.push_back(CaloSampling::EMB3);
-      if ( *firstSampl == "TileBar0" )
+      if ( sample == "TileBar0" )
 	m_caloSamplings.push_back(CaloSampling::TileBar0);
-      if ( *firstSampl == "TileBar1" )
+      if ( sample == "TileBar1" )
 	m_caloSamplings.push_back(CaloSampling::TileBar0);
-      if ( *firstSampl == "TileBar2" )
+      if ( sample == "TileBar2" )
 	m_caloSamplings.push_back(CaloSampling::TileBar0);
-      if ( *firstSampl == "TileExt0" )
+      if ( sample == "TileExt0" )
 	m_caloSamplings.push_back(CaloSampling::TileExt0);
-      if ( *firstSampl == "TileExt1" )
+      if ( sample == "TileExt1" )
 	m_caloSamplings.push_back(CaloSampling::TileExt1);
-      if ( *firstSampl == "TileExt2" )
+      if ( sample == "TileExt2" )
 	m_caloSamplings.push_back(CaloSampling::TileExt2);
 
       // H6 calos
-      if ( *firstSampl == "EME1" )
+      if ( sample == "EME1" )
 	m_caloSamplings.push_back(CaloSampling::EME1);
-      if ( *firstSampl == "EME2" )
+      if ( sample == "EME2" )
 	m_caloSamplings.push_back(CaloSampling::EME2);
-      if ( *firstSampl == "HEC0" )
+      if ( sample == "HEC0" )
 	m_caloSamplings.push_back(CaloSampling::HEC0);
-      if ( *firstSampl == "HEC1" )
+      if ( sample == "HEC1" )
 	m_caloSamplings.push_back(CaloSampling::HEC1);
-      if ( *firstSampl == "HEC2" )
+      if ( sample == "HEC2" )
 	m_caloSamplings.push_back(CaloSampling::HEC2);
-      if ( *firstSampl == "HEC3" )
+      if ( sample == "HEC3" )
 	m_caloSamplings.push_back(CaloSampling::HEC3);
-      if ( *firstSampl == "FCAL0" )
+      if ( sample == "FCAL0" )
 	m_caloSamplings.push_back(CaloSampling::FCAL0);
-      if ( *firstSampl == "FCAL1" )
+      if ( sample == "FCAL1" )
 	m_caloSamplings.push_back(CaloSampling::FCAL1);
-      if ( *firstSampl == "FCAL2" )
+      if ( sample == "FCAL2" )
 	m_caloSamplings.push_back(CaloSampling::FCAL2);
     }
 
diff --git a/TestBeam/TBRec/src/TBXMLWriter.cxx b/TestBeam/TBRec/src/TBXMLWriter.cxx
index 440bc5ea5587..40a645f851ec 100644
--- a/TestBeam/TBRec/src/TBXMLWriter.cxx
+++ b/TestBeam/TBRec/src/TBXMLWriter.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 
@@ -62,13 +62,11 @@ StatusCode TBXMLWriter::initialize()
   /////////////////////
 
   // loop all writers
-  std::vector<std::string>::iterator firstTool = m_writerToolNames.begin();
-  std::vector<std::string>::iterator lastTool  = m_writerToolNames.end(); 
 
-  for ( ; firstTool != lastTool; firstTool++ )
+  for (const std::string& toolName : m_writerToolNames)
     {
       IAlgTool* algToolPtr;
-      ListItem writerAlgoTool(*firstTool);
+      ListItem writerAlgoTool(toolName);
 
       // pick up tool
       StatusCode checkOut = toolSvcPtr->retrieveTool(writerAlgoTool.type(),
@@ -105,30 +103,12 @@ StatusCode TBXMLWriter::initialize()
       return StatusCode::FAILURE;
     }
 
-  // print out list of tools
-  ATH_MSG_INFO ( " " );
-  ATH_MSG_INFO ( "List of tools in execution sequence:" );
-  ATH_MSG_INFO ( "------------------------------------" );
-  ATH_MSG_INFO ( " " );
-  unsigned int toolCtr = 0;
-  std::vector<TBXMLWriterToolBase*>::iterator fTool = m_writerTools.begin();
-  std::vector<TBXMLWriterToolBase*>::iterator lTool = m_writerTools.end();
-  for ( ; fTool != lTool; fTool++ )
+  for (TBXMLWriterToolBase* tool : m_writerTools)
     {
-      toolCtr++;
-//       log << MSG::INFO 
-// 	  << std::setw(2)     << std::setiosflags(std::ios_base::right)
-// 	  << toolCtr << ".) " << std::resetiosflags(std::ios_base::right)
-// 	  << std::setw(36) << std::setfill('.') 
-// 	  << std::setiosflags(std::ios_base::left) << (*fTool)->type()
-// 	  << std::setfill('.')
-// 	  << (*fTool)->name()
-// 	  << std::setfill(' ')
-// 	  << endmsg;
       // reset statistics
-      m_toolInvoke[(*fTool)->name()] = 0;
-      m_toolReject[(*fTool)->name()] = 0;
-      m_toolAccept[(*fTool)->name()] = 0;
+      m_toolInvoke[tool->name()] = 0;
+      m_toolReject[tool->name()] = 0;
+      m_toolAccept[tool->name()] = 0;
     }
 
   return StatusCode::SUCCESS;
@@ -195,21 +175,17 @@ StatusCode TBXMLWriter::execute()
   // Loop Tools //
   ////////////////
 
-  std::vector<TBXMLWriterToolBase*>::const_iterator firstTool = 
-    m_writerTools.begin();
-  std::vector<TBXMLWriterToolBase*>::const_iterator lastTool =
-    m_writerTools.end();
-  for ( ; firstTool != lastTool; firstTool++ )
+  for (TBXMLWriterToolBase* tool : m_writerTools)
     {
-      StatusCode checkOut = (*firstTool)->writeOut(thisFileStream);
-      m_toolInvoke[(*firstTool)->name()]++;
+      StatusCode checkOut = tool->writeOut(thisFileStream);
+      m_toolInvoke[tool->name()]++;
       if ( checkOut.isFailure() )
 	{
-	  m_toolReject[(*firstTool)->name()]++;
+	  m_toolReject[tool->name()]++;
 	}
       else
 	{
-	  m_toolAccept[(*firstTool)->name()]++;
+	  m_toolAccept[tool->name()]++;
 	}
     }
 
@@ -223,48 +199,6 @@ StatusCode TBXMLWriter::execute()
 
 StatusCode TBXMLWriter::finalize()
 {
-  //////////////////////////
-  // Re-allocate Services //
-  //////////////////////////
-
-  ////////////////
-  // Tool Stats //
-  ////////////////
-
-  ATH_MSG_INFO
-    ( "\n"
-      << "Summary of Tool invocation: (invoked/success/failure)"
-      << "\n"
-      << "---------------------------"
-      );
-
-  std::map<std::string,unsigned int>::const_iterator 
-    firstName = m_toolInvoke.begin();
-  std::map<std::string,unsigned int>::const_iterator 
-    lastName  = m_toolInvoke.end();
-  unsigned int toolCtr = 0;
-  for ( ; firstName != lastName; firstName++ )
-    {
-      toolCtr++;
-//       log << MSG::INFO
-// 	  << std::setw(2)     << std::setiosflags(std::ios_base::right)
-// 	  << toolCtr << ".) " << std::resetiosflags(std::ios_base::right)
-// 	  << std::setw(36) << std::setfill('.') 
-// 	  << std::setiosflags(std::ios_base::left)
-// 	  << (*firstName).first << std::resetiosflags(std::ios_base::left)
-// 	  << std::setfill(' ')
-// 	  << " ("
-// 	  << std::setw(6) << std::setiosflags(std::ios_base::right)
-// 	  << (*firstName).second
-// 	  << "/"
-// 	  << std::setw(6) << std::setiosflags(std::ios_base::right)
-// 	  << m_toolAccept[(*firstName).first]
-// 	  << "/"
-// 	  << std::setw(6) << std::setiosflags(std::ios_base::right)
-// 	  << m_toolReject[(*firstName).first]
-// 	  << ")"
-// 	  << endmsg;
-    }
   return StatusCode::SUCCESS;
 }
 
diff --git a/TestBeam/TBRec/src/TBXMLWriter.h b/TestBeam/TBRec/src/TBXMLWriter.h
index 072a1fa91812..60d96ec6755f 100755
--- a/TestBeam/TBRec/src/TBXMLWriter.h
+++ b/TestBeam/TBRec/src/TBXMLWriter.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBXMLWRITER_H
@@ -36,9 +36,9 @@ class TBXMLWriter : public AthAlgorithm
   // Algorithm Methods //
   ///////////////////////
 
-  virtual StatusCode initialize();
-  virtual StatusCode execute();
-  virtual StatusCode finalize();
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
+  virtual StatusCode finalize() override;
 
   // tool support
   const std::string&  getFileDir() const { return m_topDirectory; }
-- 
GitLab