diff --git a/Tracking/TrkConditions/TrackingGeometryCondAlg/python/AtlasTrackingGeometryCondAlg.py b/Tracking/TrkConditions/TrackingGeometryCondAlg/python/AtlasTrackingGeometryCondAlg.py index b885d134f610fbf3da8009b852b7e7802b5507ac..453a162315b2b7532f37495bf047171a20330357 100644 --- a/Tracking/TrkConditions/TrackingGeometryCondAlg/python/AtlasTrackingGeometryCondAlg.py +++ b/Tracking/TrkConditions/TrackingGeometryCondAlg/python/AtlasTrackingGeometryCondAlg.py @@ -43,7 +43,7 @@ class ConfiguredTrackingGeometryCondAlg( Trk__TrackingGeometryCondAlg ) : # the geometry builder alg tool from TrkDetDescrTools.TrkDetDescrToolsConf import Trk__GeometryBuilderCond - AtlasGeometryBuilder = Trk__GeometryBuilderCond(name = 'AtlasGeometryBuilder') + AtlasGeometryBuilder = Trk__GeometryBuilderCond(name = 'AtlasGeometryBuilderCond') # switch the building outputlevel on AtlasGeometryBuilder.OutputLevel = TrkDetFlags.ConfigurationOutputLevel() @@ -67,7 +67,7 @@ class ConfiguredTrackingGeometryCondAlg( Trk__TrackingGeometryCondAlg ) : from InDetTrackingGeometry.ConfiguredInDetTrackingGeometryBuilderCond import ConfiguredInDetTrackingGeometryBuilderCond as IDGeometryBuilder else: from InDetTrackingGeometry.ConfiguredStagedTrackingGeometryBuilderCond import ConfiguredStagedTrackingGeometryBuilderCond as IDGeometryBuilder - InDetTrackingGeometryBuilder = IDGeometryBuilder(name ='InDetTrackingGeometryBuilder') + InDetTrackingGeometryBuilder = IDGeometryBuilder(name ='InDetTrackingGeometryBuilderCond') InDetTrackingGeometryBuilder.EnvelopeDefinitionSvc = AtlasEnvelopeSvc InDetTrackingGeometryBuilder.OutputLevel = TrkDetFlags.InDetBuildingOutputLevel() @@ -82,7 +82,7 @@ class ConfiguredTrackingGeometryCondAlg( Trk__TrackingGeometryCondAlg ) : ToolSvc += CaloVolumeCreator from CaloTrackingGeometry.ConfiguredCaloTrackingGeometryBuilderCond import ConfiguredCaloTrackingGeometryBuilderCond as ConfiguredCaloGeo - CaloTrackingGeometryBuilder = ConfiguredCaloGeo(name='CaloTrackingGeometryBuilder'); + CaloTrackingGeometryBuilder = ConfiguredCaloGeo(name='CaloTrackingGeometryBuilderCond'); CaloTrackingGeometryBuilder.TrackingVolumeCreator = CaloVolumeCreator CaloTrackingGeometryBuilder.EnvelopeDefinitionSvc = AtlasEnvelopeSvc CaloTrackingGeometryBuilder.OutputLevel = TrkDetFlags.CaloBuildingOutputLevel() diff --git a/Tracking/TrkConditions/TrkCondTest/TrkCondTest/TrackingGeometryCondAlgTest.h b/Tracking/TrkConditions/TrkCondTest/TrkCondTest/TrackingGeometryCondAlgTest.h index 8f3c5a1b562ab5f5f0386b4baf883b6dfbe9edc2..ad24370559b3b563adc5f6122172df3c6b727dfe 100644 --- a/Tracking/TrkConditions/TrkCondTest/TrkCondTest/TrackingGeometryCondAlgTest.h +++ b/Tracking/TrkConditions/TrkCondTest/TrkCondTest/TrackingGeometryCondAlgTest.h @@ -2,14 +2,15 @@ * Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -#ifndef TRACKINGGEOMETRYCONDALG_H -#define TRACKINGGEOMETRYCONDALG_H +#ifndef TRACKINGGEOMETRYCONDALGTEST_H +#define TRACKINGGEOMETRYCONDALGTEST_H #include "AthenaBaseComps/AthAlgorithm.h" #include "AthenaBaseComps/AthReentrantAlgorithm.h" #include "PersistentDataModel/AthenaAttributeList.h" #include "StoreGate/ReadCondHandleKey.h" #include "StoreGate/WriteCondHandleKey.h" +#include "GaudiKernel/ServiceHandle.h" #include "TrkGeometry/TrackingGeometry.h" #include "TrkDetDescrInterfaces/IGeometryBuilder.h" @@ -18,8 +19,11 @@ #include "GaudiKernel/ToolHandle.h" #include "AthenaKernel/CLASS_DEF.h" +#include "TrkDetDescrInterfaces/ITrackingGeometrySvc.h" + namespace Trk{ + class TrackingGeometryCondAlgTest : public AthReentrantAlgorithm { public: @@ -27,14 +31,17 @@ public: virtual ~TrackingGeometryCondAlgTest() override = default; virtual StatusCode initialize() override; - virtual StatusCode execute(const EventContext& ctx)const override; + virtual StatusCode execute(const EventContext& ctx) const override; virtual StatusCode finalize() override {return StatusCode::SUCCESS;} private: /// Input conditions object. - SG::ReadCondHandleKey<TrackingGeometry> m_trackingGeometryReadKey{this, "TrackingGeometryReadKey", "AlignedTrackingGeometry", "Key of input TrackingGeometry"}; - mutable std::vector<Amg::Vector3D> m_worldVolumeCenterCollection; + SG::ReadCondHandleKey<TrackingGeometry> m_trackingGeometryReadKey{this, "TrackingGeometryReadKey", "AlignedTrackingGeometry", "Key of input TrackingGeometry"}; + mutable const TrackingGeometry* m_trackingGeometry; //!< the tracking geometry + ServiceHandle<Trk::ITrackingGeometrySvc> m_trackingGeometrySvc; //!< ToolHandle to the TrackingGeometrySvc + ToolHandleArray<Trk::IGeometryProcessor> m_trackingGeometryProcessors; //!< Tool to write out a Display format for external viewers + }; } -#endif //TRACKINGGEOMETRYCONDALG_H +#endif //TRACKINGGEOMETRYCONDALGTEST_H diff --git a/Tracking/TrkConditions/TrkCondTest/share/TrackingGeometryTest_jobOptions.py b/Tracking/TrkConditions/TrkCondTest/share/TrackingGeometryTest_jobOptions.py index 7ac5625c8657a25c7a4c69cfccc26dcce601c5d7..6885c16636c85adbf016195cc9ca7104b4aba1b6 100644 --- a/Tracking/TrkConditions/TrkCondTest/share/TrackingGeometryTest_jobOptions.py +++ b/Tracking/TrkConditions/TrkCondTest/share/TrackingGeometryTest_jobOptions.py @@ -62,6 +62,8 @@ TrkDetFlags.TRT_BuildingOutputLevel = VERBOSE TrkDetFlags.InDetBuildingOutputLevel = VERBOSE TrkDetFlags.ConfigurationOutputLevel = VERBOSE +from TrkDetDescrSvc.AtlasTrackingGeometrySvc import AtlasTrackingGeometrySvc + # load the tracking geometry cond alg from TrackingGeometryCondAlg.AtlasTrackingGeometryCondAlg import ConfiguredTrackingGeometryCondAlg @@ -70,8 +72,16 @@ from AthenaCommon.AlgSequence import AthSequencer condSeq = AthSequencer("AthCondSeq") condSeq+= TrkGeoCondAlg + +# ---------------------- +from TrkDetDescrTestTools.TrkDetDescrTestToolsConf import Trk__GeometryAsciiDumper +GeometryAsciiDumper = Trk__GeometryAsciiDumper(name= 'GeometryAsciiDumper') +ToolSvc += GeometryAsciiDumper +GeometryProcessors = [ GeometryAsciiDumper ] + from TrkCondTest.TrackingGeometryCondAlgTestConf import Trk__TrackingGeometryCondAlgTest TrkGeomCondAlgTest = Trk__TrackingGeometryCondAlgTest(name = "TrkGeomTest") +TrkGeomCondAlgTest.GeometryProcessors = GeometryProcessors job += TrkGeomCondAlgTest #-------------------------------------------------------------- @@ -88,7 +98,8 @@ job += TrkGeomCondAlgTest # Event related parameters #-------------------------------------------------------------- -theApp.EvtMax = 22 + +theApp.EvtMax = 2 from AthenaCommon.AppMgr import ServiceMgr # output level diff --git a/Tracking/TrkConditions/TrkCondTest/src/TrackingGeometryCondAlgTest.cxx b/Tracking/TrkConditions/TrkCondTest/src/TrackingGeometryCondAlgTest.cxx index 364faa7072016d4b1248a87a1b74b86c611d6b8e..d3b48bc79ba3c35caf135889bda04e66a11faceb 100644 --- a/Tracking/TrkConditions/TrkCondTest/src/TrackingGeometryCondAlgTest.cxx +++ b/Tracking/TrkConditions/TrkCondTest/src/TrackingGeometryCondAlgTest.cxx @@ -2,15 +2,22 @@ * Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -// Trk includes +#include "GaudiKernel/ISvcLocator.h" + #include "AthenaKernel/IOVSvcDefs.h" +// Trk includes #include "TrkCondTest/TrackingGeometryCondAlgTest.h" +#include "TrkGeometry/Layer.h" Trk::TrackingGeometryCondAlgTest::TrackingGeometryCondAlgTest(const std::string& name, ISvcLocator* pSvcLocator) - : AthReentrantAlgorithm(name, pSvcLocator) + : AthReentrantAlgorithm(name, pSvcLocator), + m_trackingGeometry(nullptr), + m_trackingGeometrySvc("AtlasTrackingGeometrySvc", name), + m_trackingGeometryProcessors() { + declareProperty("GeometryProcessors", m_trackingGeometryProcessors); } StatusCode Trk::TrackingGeometryCondAlgTest::initialize() @@ -20,6 +27,19 @@ StatusCode Trk::TrackingGeometryCondAlgTest::initialize() // Read Handle Key ATH_CHECK(m_trackingGeometryReadKey.initialize()); + + if (m_trackingGeometrySvc.retrieve().isSuccess()) { + ATH_MSG_INFO("Successfully retrieved " << m_trackingGeometrySvc); + } else { + ATH_MSG_WARNING("Couldn't retrieve " << m_trackingGeometrySvc << ". "); + return StatusCode::FAILURE; + } + if ((m_trackingGeometryProcessors.retrieve()).isFailure()) { + ATH_MSG_FATAL( "Failed to retrieve tool(s) in " << m_trackingGeometryProcessors ); + return StatusCode::FAILURE; + } else{ + ATH_MSG_INFO( "Retrieved tools : " << m_trackingGeometryProcessors ); + } return StatusCode::SUCCESS; } @@ -33,15 +53,34 @@ StatusCode Trk::TrackingGeometryCondAlgTest::execute(const EventContext& ctx) co } const Trk::TrackingGeometry* trkGeom = *readHandle; ATH_MSG_INFO( "eventID: " << ctx.eventID()); + m_trackingGeometry = m_trackingGeometrySvc->trackingGeometry(); + if( m_trackingGeometry == nullptr){ + std::cout << "TRACKING GEOMETRY NOT FOUND IN SVC" << std::endl; + return StatusCode::FAILURE; + } - Amg::Vector3D center = trkGeom->highestTrackingVolume()->center(); - ATH_MSG_INFO("Center coordinates of highest tracking volume"); - ATH_MSG_INFO(center); - if(m_worldVolumeCenterCollection.size()>=1 && m_worldVolumeCenterCollection.back() != center){ - ATH_MSG_INFO("hooray, we have moved the world"); + for (ToolHandle<Trk::IGeometryProcessor> proc : m_trackingGeometryProcessors) { + std::cout << "PRINT SVC TG" << std::endl; + if(proc->process(*m_trackingGeometry).isFailure()){ + ATH_MSG_FATAL("Could not process the TrackingGeometry from SVC"); + return StatusCode::FAILURE; + } + std::cout << "PRINT COND TG" << std::endl; + if(proc->process(*trkGeom).isFailure()){ + ATH_MSG_FATAL("Could not process the TrackingGeometry from CONDALG"); + return StatusCode::FAILURE; + } } - m_worldVolumeCenterCollection.push_back(center); - ATH_MSG_INFO("TrackingGeometry retrieved"); +// const std::vector<const Trk::Layer*>* layersCond = trkGeom->highestTrackingVolume()->confinedArbitraryLayers(); +// const std::vector<const Trk::Layer*>* layersSvc = m_trackingGeometry->highestTrackingVolume()->confinedArbitraryLayers(); +// std::cout << "Layers in highestTrackingVolume from condAlg and svc:" << std::endl; +// if(layersCond != nullptr){ +// for (size_t i = 0; i<layersCond->size(); i++){ +// std::cout << "Layer subsurface from CondAlg at 0,0:" << std::endl<< layersCond->at(i)->subSurface(Amg::Vector2D(0.,0.)) << std::endl; +// std::cout << "Layer subsurface from Svc at 0,0:" << std::endl<< layersSvc->at(i)->subSurface(Amg::Vector2D(0.,0.)) << std::endl; +// } +// } +// ATH_MSG_INFO("TrackingGeometry retrieved"); return StatusCode::SUCCESS; }