From 5ef8ba0743d9b887ccafd44382fc356c87b5e9c0 Mon Sep 17 00:00:00 2001
From: Nick Styles <nicholas.styles@cern.ch>
Date: Tue, 13 Jun 2017 18:18:58 +0200
Subject: [PATCH] Migrating to use DataHandles. Made the read keys properties,
 but most likely these will always ude the defaults (since they retrieve the
 EventInfo)

Former-commit-id: d40da0e1464a190d477259e0359a3cbfa4541ecd
---
 .../TrkGaussianSumFilter/BremFind.h                  |  5 +++++
 .../TrkGaussianSumFilter/GaussianSumFitter.h         |  4 ++++
 .../TrkFitter/TrkGaussianSumFilter/src/BremFind.cxx  | 12 +++++++-----
 .../TrkGaussianSumFilter/src/GaussianSumFitter.cxx   |  8 +++++---
 4 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/Tracking/TrkFitter/TrkGaussianSumFilter/TrkGaussianSumFilter/BremFind.h b/Tracking/TrkFitter/TrkGaussianSumFilter/TrkGaussianSumFilter/BremFind.h
index 95139fe6de4..f29b2797cca 100644
--- a/Tracking/TrkFitter/TrkGaussianSumFilter/TrkGaussianSumFilter/BremFind.h
+++ b/Tracking/TrkFitter/TrkGaussianSumFilter/TrkGaussianSumFilter/BremFind.h
@@ -30,6 +30,9 @@ description : Class for finding brem points in the inner detector using the GSF
 
 #include "GeoPrimitives/GeoPrimitives.h"
 
+#include "StoreGate/ReadHandleKey.h"
+#include "xAODEventInfo/EventInfo.h"
+
 #include <vector>
 
 //class ITrackingGeometrySvc;
@@ -217,6 +220,8 @@ class BremFind : public AthAlgTool, virtual public IBremsstrahlungFinder{
     QoverPBremFit *m_forwardBremFit;
     QoverPBremFit *m_smoothedBremFit;
 
+    SG::ReadHandleKey<xAOD::EventInfo> m_readKey;
+
   };
 
 }
diff --git a/Tracking/TrkFitter/TrkGaussianSumFilter/TrkGaussianSumFilter/GaussianSumFitter.h b/Tracking/TrkFitter/TrkGaussianSumFilter/TrkGaussianSumFilter/GaussianSumFitter.h
index 67c949f4957..48f0a41ae5f 100755
--- a/Tracking/TrkFitter/TrkGaussianSumFilter/TrkGaussianSumFilter/GaussianSumFitter.h
+++ b/Tracking/TrkFitter/TrkGaussianSumFilter/TrkGaussianSumFilter/GaussianSumFitter.h
@@ -24,6 +24,7 @@ decription           : Class for fitting according to the Gaussian Sum Filter
 #include "GaudiKernel/ToolHandle.h"
 #include "GaudiKernel/ServiceHandle.h" 
 #include "GaudiKernel/IChronoStatSvc.h"
+#include "xAODEventInfo/EventInfo.h"
 
 #include "TTree.h"
 
@@ -213,6 +214,9 @@ class GaussianSumFitter : virtual public ITrackFitter, public AthAlgTool {
   mutable float                   m_surfaceErrPhiS[TRKFGSF_VALSURFACES][TRKGSF_VALSTATES];    //!< Track phi error on Surface
   mutable float                   m_surfaceErrQoverPS[TRKFGSF_VALSURFACES][TRKGSF_VALSTATES]; //!< Track q over p error on Surface
   mutable int                     m_event_ID;
+
+  SG::ReadHandleKey<xAOD::EventInfo> m_readKey;
+
 };
 
 } // end Trk namespace
diff --git a/Tracking/TrkFitter/TrkGaussianSumFilter/src/BremFind.cxx b/Tracking/TrkFitter/TrkGaussianSumFilter/src/BremFind.cxx
index 76c74ef8eca..88733889ac8 100644
--- a/Tracking/TrkFitter/TrkGaussianSumFilter/src/BremFind.cxx
+++ b/Tracking/TrkFitter/TrkGaussianSumFilter/src/BremFind.cxx
@@ -40,8 +40,6 @@ description : Class for finding brem points in the inner detector using the GSF
 
 #include "TTree.h"
 
-#include "xAODEventInfo/EventInfo.h"
-
 
 
 Trk::BremFind::BremFind(const std::string& type, const std::string& name, const IInterface* parent):
@@ -116,6 +114,7 @@ Trk::BremFind::BremFind(const std::string& type, const std::string& name, const
   declareProperty("UseSurfacePropagation", m_usePropagate=false);
   declareProperty("TreeFolderName", m_validationTreeFolder);
   declareProperty("TreeFolderName2", m_validationTreeFolder2);
+  declareProperty("EventInfoKey", m_readKey = "EventInfo");
 }
 
 
@@ -248,6 +247,9 @@ StatusCode Trk::BremFind::initialize()
 
   //---------------------------- end of validation mode ------------------------------------
 
+ 
+  ATH_CHECK( m_readKey.initialize() );
+
   ATH_MSG_DEBUG( "Initialisation of " << name() << " was successful" );
   
   return StatusCode::SUCCESS;
@@ -414,11 +416,11 @@ void Trk::BremFind::BremFinder(const Trk::ForwardTrajectory& forwardTrajectory,
     
   
   //* Retrieve the event info for later syncrinization
-  const xAOD::EventInfo*   eventInfo;
-  if ((evtStore()->retrieve(eventInfo)).isFailure()) {
+  SG::ReadHandle< xAOD::EventInfo>  eventInfo (m_readKey);
+  if (!eventInfo.isValid()) {
     msg(MSG::ERROR) << "Could not retrieve event info" << endmsg;
   }
-       
+  
   m_event_ID            =  eventInfo->eventNumber();
 
   //Fill the TanH coefficients and graph values
diff --git a/Tracking/TrkFitter/TrkGaussianSumFilter/src/GaussianSumFitter.cxx b/Tracking/TrkFitter/TrkGaussianSumFilter/src/GaussianSumFitter.cxx
index c5a5f110212..90ccf045011 100755
--- a/Tracking/TrkFitter/TrkGaussianSumFilter/src/GaussianSumFitter.cxx
+++ b/Tracking/TrkFitter/TrkGaussianSumFilter/src/GaussianSumFitter.cxx
@@ -42,7 +42,6 @@ decription           : Implementation code for Gaussian Sum Fitter class
 #include "GaudiKernel/ToolFactory.h"
 
 #include <vector>
-#include "xAODEventInfo/EventInfo.h"
 
 // Validation mode - TTree includes
 #include "GaudiKernel/ITHistSvc.h" 
@@ -139,6 +138,7 @@ Trk::GaussianSumFitter::GaussianSumFitter(const std::string& type, const std::st
   declareProperty("runBremFinder",            m_runBremFinder             );
   declareProperty("GsfSmoother",m_gsfSmoother);  
   declareProperty("ForwardGsfFitter",m_forwardGsfFitter);
+  declareProperty("EventInfoKey", m_readKey="EventInfo");
 
   // Estrablish reference point as origin
   m_sortingReferencePoint.push_back(0.);
@@ -286,6 +286,8 @@ StatusCode Trk::GaussianSumFitter::initialize()
   
   m_inputPreparator = new TrackFitInputPreparator();
 
+  ATH_CHECK( m_readKey.initialize() ); 
+
   msg(MSG::INFO) << "Initialisation of " << name() << " was successful" << endmsg;
 
   return StatusCode::SUCCESS;
@@ -1023,8 +1025,8 @@ void Trk::GaussianSumFitter::SaveMCSOSF(const Trk::ForwardTrajectory& forwardTra
   m_surfaceCounterF = 0;
 
   //* Retrieve the event info for later syncrinization
-  const xAOD::EventInfo*   eventInfo;
-  if ((evtStore()->retrieve(eventInfo)).isFailure()) {
+  SG::ReadHandle<xAOD::EventInfo>  eventInfo (m_readKey);
+  if (!eventInfo.isValid()) {
     msg(MSG::ERROR) << "Could not retrieve event info" << endmsg;
   }
        
-- 
GitLab