ATLAS Offline Software
TrackingGeometryTest.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // TrackingGeometryTest.cxx, (c) ATLAS Detector software
8 
9 // Trk includes
12 #include "TrkGeometry/Layer.h"
15 
16 // monitor memory usage
17 #ifdef TRKDETDESCR_MEMUSAGE
18 #include <unistd.h>
19 #endif
20 
21 
22 Trk::TrackingGeometryTest::TrackingGeometryTest(const std::string& name, ISvcLocator* pSvcLocator) :
23  Trk::TrkDetDescrUnitTestBase(name, pSvcLocator),
24 #ifdef TRKDETDESCR_MEMUSAGE
25  m_memoryLogger(),
26 #endif
27  m_executed(false),
28  m_trackingGeometrySvc("TrackingGeometrySvc","AtlasTrackingGeometrySvc"),
29  m_trackingGeometry(nullptr),
30  m_trackingGeometryName("AtlasTrackingGeometry"),
31  m_trackingGeometryProcessors()
32  {
33  // get the service handle for the TrackingGeometry
34  declareProperty("TrackingGeometrySvc" , m_trackingGeometrySvc);
35  // get the tools for display and recording
36  declareProperty("TrackingGeometryProcessors" , m_trackingGeometryProcessors);
37  }
38 
40 {
41  #ifdef TRKDETDESCR_MEMUSAGE
42  m_memoryLogger.refresh(getpid());
43  ATH_MSG_INFO( "[ memory usage ] Memory monitoring activated through TRKDETDESCR_MEMUSAGE " );
44  ATH_MSG_INFO( "[ memory usage ] initialize (start) : " );
45  ATH_MSG_INFO( m_memoryLogger );
46  #endif
47 
48  // Get the TrackingGeometry from StoreGate
49  // initialize the TrackingGeometrySvc
50  if (m_trackingGeometrySvc.retrieve().isFailure()) {
51  ATH_MSG_FATAL( "Cannot retrieve TrackingGeometrySvc. Abort job. " );
52  return StatusCode::FAILURE;
53  }
54  m_trackingGeometryName = m_trackingGeometrySvc->trackingGeometryName();
55 
56  // The Processors -------------------------------------------------------------
57  if ( m_trackingGeometryProcessors.retrieve().isFailure())
58  {
59  ATH_MSG_FATAL( "Failed to retrieve tool(s) in " << m_trackingGeometryProcessors );
60  return StatusCode::FAILURE;
61  } else
62  ATH_MSG_INFO( "Retrieved tools : " << m_trackingGeometryProcessors );
63 
64  #ifdef TRKDETDESCR_MEMUSAGE
65  m_memoryLogger.refresh(getpid());
66  ATH_MSG_INFO( "[ memory usage ] initialize (end) : " );
67  ATH_MSG_INFO( m_memoryLogger );
68  #endif
69 
70  return StatusCode::SUCCESS;
71 }
72 
73 
75 {
76  ATH_MSG_VERBOSE("Running the TrackingGeometryTest Test");
77 
78  // ------------------------------- get the trackingGeometry at first place
79  if (!m_trackingGeometry) {
80  if ((detStore()->retrieve(m_trackingGeometry, m_trackingGeometryName)).isFailure())
81  ATH_MSG_FATAL( "Could not retrieve TrackingGeometry '" << m_trackingGeometryName << "' from DetectorStore." );
82  else
83  ATH_MSG_INFO( "TrackingGeometry '" << m_trackingGeometryName << "' successfully retrieved from DetectorStore." );
84  }
85  // only run if it didn't already run before
86  if (!m_executed && m_trackingGeometry){
87  // push the geometry through the different processors
88  for (ToolHandle<Trk::IGeometryProcessor> proc : m_trackingGeometryProcessors) {
89  ATH_MSG_INFO("Parse geometry with processor " << proc->name() );
90  //test so const_cast prb fine
91  if ((proc->process(const_cast<Trk::TrackingGeometry&>(*m_trackingGeometry))).isFailure()){
92  ATH_MSG_FATAL("Could not process the TrackingGeometry with '" << proc->name() <<"'. Aborting test.");
93  return StatusCode::FAILURE;
94  }
95  }
96  m_executed = true;
97  }
98  return StatusCode::SUCCESS;
99 
100 }
101 
102 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Trk::TrackingGeometryTest::m_trackingGeometrySvc
ServiceHandle< Trk::ITrackingGeometrySvc > m_trackingGeometrySvc
Service handle for retrieving the TrackingGeometry.
Definition: TrackingGeometryTest.h:56
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Trk::TrkDetDescrUnitTestBase
Definition: TrkDetDescrUnitTestBase.h:27
Layer.h
Trk::TrackingGeometryTest::TrackingGeometryTest
TrackingGeometryTest(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
Definition: TrackingGeometryTest.cxx:22
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Trk::TrackingGeometry
Definition: TrackingGeometry.h:67
Trk::TrackingGeometryTest::m_trackingGeometryProcessors
ToolHandleArray< Trk::IGeometryProcessor > m_trackingGeometryProcessors
Tool to write out a Display format for external viewers.
Definition: TrackingGeometryTest.h:59
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
IGeometryProcessor.h
mc.proc
proc
Definition: mc.PhPy8EG_A14NNPDF23_gg4l_example.py:22
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrackingGeometryTest.h
TrackingVolume.h
Trk::TrackingGeometryTest::runTest
StatusCode runTest()
Definition: TrackingGeometryTest.cxx:74
TrackingGeometry.h
Trk::TrackingGeometryTest::initializeTest
StatusCode initializeTest()
Definition: TrackingGeometryTest.cxx:39