diff --git a/Simulation/G4Atlas/G4AtlasTests/src/MuonHitTestToolBase.cxx b/Simulation/G4Atlas/G4AtlasTests/src/MuonHitTestToolBase.cxx index d1163ff200f4354c22cab800bdb3cc5f437d98e0..bf58a8619e1149ad73dad831877557e44b354be0 100644 --- a/Simulation/G4Atlas/G4AtlasTests/src/MuonHitTestToolBase.cxx +++ b/Simulation/G4Atlas/G4AtlasTests/src/MuonHitTestToolBase.cxx @@ -6,7 +6,6 @@ #include "EventInfo/EventInfo.h" #include "EventInfo/EventID.h" -#include "GeneratorObjects/McEventCollection.h" #include "MuonReadoutGeometry/MuonDetectorManager.h" @@ -42,8 +41,11 @@ StatusCode MuonHitTestToolBase::executeCheckEventInfo() ATH_MSG_VERBOSE("Processing EventInfo event #"<< evt<< " run: " << numrun); m_muonevnt->Fill(evt); m_muonrun->Fill(numrun); - const DataHandle<McEventCollection> mcEvent; - CHECK(evtStore()->retrieve(mcEvent,m_key)); + SG::ReadHandle<McEventCollection> mcEvent( m_mcEventKey ); + if (!mcEvent.isValid()) { + ATH_MSG_ERROR( "Could not retrieve McEventCollection" ); + return StatusCode::FAILURE; + } // *AS* Why only if mcEvent ==1? when would there be more than one event? if (mcEvent->size()!=1) { @@ -109,6 +111,7 @@ StatusCode MuonHitTestToolBase::initialize() { all subalgorithms (MDT,RPC,CSC,TGC) For detailed description look in the .cxx code */ + ATH_CHECK( m_mcEventKey.initialize() ); m_path+="Muon/"; // will only create new if not already registered (uses m_path) diff --git a/Simulation/G4Atlas/G4AtlasTests/src/MuonHitTestToolBase.h b/Simulation/G4Atlas/G4AtlasTests/src/MuonHitTestToolBase.h index 2d8f5adf9d1fa6ffa7d4c62c27f3e26fc5c65cc0..0df534ce2d960d1b717871cbfcecff4abfd57318 100644 --- a/Simulation/G4Atlas/G4AtlasTests/src/MuonHitTestToolBase.h +++ b/Simulation/G4Atlas/G4AtlasTests/src/MuonHitTestToolBase.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef G4AT_MuonHitTestToolBase_h @@ -7,38 +7,37 @@ #include "SimTestToolBase.h" +#include "GeneratorObjects/McEventCollection.h" #include "GeoPrimitives/GeoPrimitives.h" -//#include "CLHEP/Geometry/Point3D.h" -//#include "CLHEP/Geometry/Vector3D.h" -#include "Identifier/Identifier.h" #include "HitManagement/HitIdHelper.h" +#include "Identifier/Identifier.h" +#include "StoreGate/ReadHandleKey.h" namespace MuonGM { - class MuonDetectorManager; +class MuonDetectorManager; } - -class MuonHitTestToolBase : public SimTestToolBase { - +class MuonHitTestToolBase : public SimTestToolBase { public: - MuonHitTestToolBase(const std::string& type, const std::string& name, const IInterface* parent); + MuonHitTestToolBase(const std::string &type, const std::string &name, + const IInterface *parent); - StatusCode initialize(); protected: StatusCode executeCheckEventInfo(); StatusCode executeFillHistos(const Amg::Vector3D &); - StatusCode executeFillHistosSectors_Wedge1(const Amg::Vector3D &, std::string); - StatusCode executeFillHistosSectors_Wedge2(const Amg::Vector3D &, std::string); - //StatusCode executeFillHistos_sTGc_Wedge1(const Amg::Vector3D &, std::string); + StatusCode executeFillHistosSectors_Wedge1(const Amg::Vector3D &, + std::string); + StatusCode executeFillHistosSectors_Wedge2(const Amg::Vector3D &, + std::string); StatusCode executeFillHistos_sTGc(const Amg::Vector3D &, std::string); protected: std::string m_detname; - const MuonGM::MuonDetectorManager* m_pMuonMgr; + const MuonGM::MuonDetectorManager *m_pMuonMgr; - /// MDT barrel eta cut, applicable to the MDT 2D cross section plot + /// MDT barrel eta cut, applicable to the MDT 2D cross section plot double m_BarrelEtaCut; // general @@ -50,10 +49,12 @@ class MuonHitTestToolBase : public SimTestToolBase { TH1 *m_eta, *m_theta, *m_phi; TH1 *m_zResid, *m_phiResid; TH2 *m_detBarrel, *m_longView; - - + // helper variables Amg::Vector3D m_direction; + + private: + SG::ReadHandleKey<McEventCollection> m_mcEventKey{"TruthEvent"}; }; -#endif // MuonHitTestToolBase_h +#endif // MuonHitTestToolBase_h