ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::TrackingGeometrySvc Class Reference

This service builds and registers the TrackingGeometry in the detector store. More...

#include <TrackingGeometrySvc.h>

Inheritance diagram for Trk::TrackingGeometrySvc:
Collaboration diagram for Trk::TrackingGeometrySvc:

Public Member Functions

virtual StatusCode initialize () override
 Initialize Service.
virtual StatusCode finalize () override
 Finalize Service.
virtual void tagInfoUpdated () override final
StatusCode trackingGeometryInit (bool needsInit=true)
 Create the geometry.
virtual const Trk::TrackingGeometrytrackingGeometry () const override
 Provide the TrackingGeometry.
virtual const std::string & trackingGeometryName () const override

Private Member Functions

void trackingGeometryNotSet () const

Private Attributes

ToolHandle< Trk::IGeometryBuilderm_trackingGeometryBuilder {this, "GeometryBuilder", ""}
 the actual building tool
const Trk::TrackingGeometrym_trackingGeometry {nullptr}
 the cached TrackingGeometry
Gaudi::Property< std::string > m_trackingGeometryName {this, "TrackingGeometryName", "AtlasTrackingGeometry"}
 the name of the TrackingGeometry
ToolHandleArray< Trk::IGeometryProcessorm_geometryProcessors {this, "GeometryProcessors", {}, "Tools to process geometry"}
 processors to help
Gaudi::Property< bool > m_rerunOnCallback {this, "RerunOnCallback", false}
 enables the callback
Gaudi::Property< bool > m_buildGeometryFromTagInfo {this, "BuildGeometryFromTagInfo", true}

Friends

class SvcFactory< TrackingGeometrySvc >
 Standard Constructor.

Detailed Description

This service builds and registers the TrackingGeometry in the detector store.

It is called by an ordered callback after GeoModel was created.

Author
Andre.nosp@m.as.S.nosp@m.alzbu.nosp@m.rger.nosp@m.@cern.nosp@m..ch

Definition at line 44 of file TrkDetDescr/TrkDetDescrSvc/TrkDetDescrSvc/TrackingGeometrySvc.h.

Member Function Documentation

◆ finalize()

StatusCode Trk::TrackingGeometrySvc::finalize ( )
overridevirtual

Finalize Service.

Definition at line 174 of file TrkDetDescr/TrkDetDescrSvc/src/TrackingGeometrySvc.cxx.

175{
176#ifdef TRKDETDESCR_MEMUSAGE
177 ATH_MSG_INFO("[ memory usage ] Change in memory usage -------------------------------- ");
178 ATH_MSG_INFO("[ memory usage ] Virtual memory change (vsize) : " << m_changeVsize);
179 ATH_MSG_INFO("[ memory usage ] Real memory change (rss) : " << m_changeRss);
180 ATH_MSG_INFO("[ memory usage ] ---------------------------------------------------------");
181#endif
182 ATH_MSG_INFO("finalize() successful.");
183 return StatusCode::SUCCESS;
184}
#define ATH_MSG_INFO(x)

◆ initialize()

StatusCode Trk::TrackingGeometrySvc::initialize ( )
overridevirtual

Initialize Service.

Definition at line 30 of file TrkDetDescr/TrkDetDescrSvc/src/TrackingGeometrySvc.cxx.

31{
32
34 "!!! Initialization of TrackingGeometrySvc !!! The Service it to be "
35 "deprecated in favour of the relevant Condition Algorithm. !!!");
36 m_autoRetrieveTools = false;
37 m_checkToolDeps = false;
38
39 if (m_geometryProcessors.retrieve().isFailure()) {
40 ATH_MSG_FATAL("Could not retrieve " << m_geometryProcessors);
41 return StatusCode::FAILURE;
42 }
43
45 ATH_MSG_INFO("Building Geometry from TagInfo");
46 // register a callback on TagInfo updates
47 ServiceHandle<ITagInfoMgr> tagInfoMgr("TagInfoMgr", name());
48 ATH_CHECK(tagInfoMgr.retrieve());
49 tagInfoMgr->addListener(this);
50 } else {
51 ATH_MSG_INFO("Building Geometry at initialisation time.");
52 // build with no dependency on COOL
53 if (trackingGeometryInit(false).isFailure()) {
54 ATH_MSG_FATAL("Unable to build the TrackingGeometry!");
55 return StatusCode::FAILURE;
56 }
57 }
58 ATH_MSG_INFO("initialize() successful! ");
59 return StatusCode::SUCCESS;
60}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
StatusCode trackingGeometryInit(bool needsInit=true)
Create the geometry.
ToolHandleArray< Trk::IGeometryProcessor > m_geometryProcessors
processors to help

◆ tagInfoUpdated()

void Trk::TrackingGeometrySvc::tagInfoUpdated ( )
finaloverridevirtual

Implements ITagInfoMgr::Listener.

Definition at line 63 of file TrkDetDescr/TrkDetDescrSvc/src/TrackingGeometrySvc.cxx.

64{
65 ATH_MSG_INFO("tagInfoUpdated() callback trigerred");
66 trackingGeometryInit().ignore();
67}

◆ trackingGeometry()

const Trk::TrackingGeometry * Trk::TrackingGeometrySvc::trackingGeometry ( ) const
inlineoverridevirtual

Provide the TrackingGeometry.

Returns the name of the TrackingGeometry built with this Svc

Definition at line 95 of file TrkDetDescr/TrkDetDescrSvc/TrkDetDescrSvc/TrackingGeometrySvc.h.

◆ trackingGeometryInit()

StatusCode Trk::TrackingGeometrySvc::trackingGeometryInit ( bool needsInit = true)

Create the geometry.

Definition at line 70 of file TrkDetDescr/TrkDetDescrSvc/src/TrackingGeometrySvc.cxx.

71{
72 ATH_MSG_INFO("Trk::TrackingGeometrySvc::trackingGeometryInit");
73
74 SmartIF<StoreGateSvc> detStore{service("DetectorStore")};
75 ATH_CHECK( detStore.isValid() );
76
77 // Retrieve the tracking geometry builder tool
78 // ----------------------------------------------------
79 if (!m_trackingGeometryBuilder.empty() && m_trackingGeometryBuilder.retrieve().isFailure()) {
80 ATH_MSG_FATAL("Failed to retrieve tool '" << m_trackingGeometryBuilder << "'. Aborting.");
81 return StatusCode::FAILURE;
82 } else if (m_trackingGeometryBuilder.empty()) {
83 ATH_MSG_FATAL("TrackingGeometrySvc " << name()
84 << " not properly configured. No GeometryBuilder defined. Aborting.");
85 return StatusCode::FAILURE;
86 } else {
87 ATH_MSG_DEBUG("Retrieved tool " << m_trackingGeometryBuilder);
88 }
89
90 // nothing to do in this case since rerun is switched off
91 if (detStore->contains<Trk::TrackingGeometry>(m_trackingGeometryName) && !m_rerunOnCallback) {
92 return StatusCode::SUCCESS;
93 }
94
95 // only build if the callback string was true
96 // (MN: I set this to alwaus true if called on TagInfo update)
97 if (needsInit) {
98 ATH_MSG_INFO("trackingGeometryInit - initialize on TagInfoMgr callback");
99 // cleanup the geometry if you have one
100 // (will delete what is in detector store, because new one will overwrite old one)
101 m_trackingGeometry = nullptr;
102
103#ifdef TRKDETDESCR_MEMUSAGE
104 // memory monitoring
105 ATH_MSG_INFO("[ memory usage ] Start to monitor memory usage of PID: " << getpid());
106
107 m_memoryLogger.refresh(getpid());
108 ATH_MSG_INFO(m_memoryLogger);
109 // record the difference
110 m_changeVsize = (-1.) * m_memoryLogger.vmSize();
111 m_changeRss = (-1.) * m_memoryLogger.vmRss();
112#endif
113
114 // build the TrackingGeometry from the builder
115 m_trackingGeometry = m_trackingGeometryBuilder->trackingGeometry().release();
116
117#ifdef TRKDETDESCR_MEMUSAGE
118 ATH_MSG_INFO("[ memory usage ] TrackingGeometry retrieved: ");
119 m_memoryLogger.refresh(getpid());
120 ATH_MSG_INFO(m_memoryLogger);
121#endif
122
123 // cast constness away for StoreGate
124 Trk::TrackingGeometry* atlasTrackingGeometry = const_cast<Trk::TrackingGeometry*>(m_trackingGeometry);
125
126 // check if a second call back has occured
127 if (detStore->contains<Trk::TrackingGeometry>(m_trackingGeometryName)) {
128 ATH_MSG_VERBOSE("New Callback evoked remove of existing object!");
129 // you need to retrieve the object first to remove it
130 const Trk::TrackingGeometry* oldTrackingGeometry = nullptr;
131 if (detStore->retrieve(oldTrackingGeometry, m_trackingGeometryName).isFailure())
132 ATH_MSG_WARNING("Callback evoked remove of '" << m_trackingGeometryName << "'. But retrieve did not succeed! ");
133 if (oldTrackingGeometry && detStore->remove<Trk::TrackingGeometry>(oldTrackingGeometry).isFailure())
134 ATH_MSG_WARNING("Callback evoked remove of '" << m_trackingGeometryName << "'. But it did not succeed!");
135 // delete is safe
136 delete oldTrackingGeometry;
137 }
138
139 // loop over the recursive geometry processors
140 ToolHandleArray<Trk::IGeometryProcessor>::iterator gpIter = m_geometryProcessors.begin();
141 ToolHandleArray<Trk::IGeometryProcessor>::iterator gpIterE = m_geometryProcessors.end();
142 for (; gpIter != gpIterE; ++gpIter) {
143 if ((*gpIter)->process(*atlasTrackingGeometry).isFailure()) {
144 ATH_MSG_FATAL("Processing of TrackingGeometry did not succeed. Abort.");
145 return StatusCode::FAILURE;
146 } else {
147 ATH_MSG_VERBOSE("Successfully processed the TrackingGeometry with " << (*gpIter));
148#ifdef TRKDETDESCR_MEMUSAGE
149 ATH_MSG_INFO("[ memory usage ] After processing with " << (*gpIter));
150 m_memoryLogger.refresh(getpid());
151 ATH_MSG_INFO(m_memoryLogger);
152#endif
153 }
154 }
155 // record the resulting TrackingGeometry
156 if (detStore->record(atlasTrackingGeometry, m_trackingGeometryName, false).isFailure()) {
157 ATH_MSG_WARNING("Couldn't write TrackingGeometry to DetectorStore.");
158 } else {
159 ATH_MSG_DEBUG("initialize() successful: TrackingGeometry '" << m_trackingGeometryName
160 << "' built and written to DetectorStore.");
161 }
162 }
163 return StatusCode::SUCCESS;
164}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
ToolHandle< Trk::IGeometryBuilder > m_trackingGeometryBuilder
the actual building tool
Gaudi::Property< std::string > m_trackingGeometryName
the name of the TrackingGeometry

◆ trackingGeometryName()

const std::string & Trk::TrackingGeometrySvc::trackingGeometryName ( ) const
inlineoverridevirtual

◆ trackingGeometryNotSet()

void Trk::TrackingGeometrySvc::trackingGeometryNotSet ( ) const
private

Definition at line 167 of file TrkDetDescr/TrkDetDescrSvc/src/TrackingGeometrySvc.cxx.

168{
169 ATH_MSG_WARNING("TrackingGeometry not set ptr=" << static_cast<const void*>(m_trackingGeometry));
170}

◆ SvcFactory< TrackingGeometrySvc >

friend class SvcFactory< TrackingGeometrySvc >
friend

Standard Constructor.

Definition at line 62 of file TrkDetDescr/TrkDetDescrSvc/TrkDetDescrSvc/TrackingGeometrySvc.h.

Member Data Documentation

◆ m_buildGeometryFromTagInfo

Gaudi::Property<bool> Trk::TrackingGeometrySvc::m_buildGeometryFromTagInfo {this, "BuildGeometryFromTagInfo", true}
private

Definition at line 91 of file TrkDetDescr/TrkDetDescrSvc/TrkDetDescrSvc/TrackingGeometrySvc.h.

91{this, "BuildGeometryFromTagInfo", true};

◆ m_geometryProcessors

ToolHandleArray<Trk::IGeometryProcessor> Trk::TrackingGeometrySvc::m_geometryProcessors {this, "GeometryProcessors", {}, "Tools to process geometry"}
private

processors to help

Definition at line 80 of file TrkDetDescr/TrkDetDescrSvc/TrkDetDescrSvc/TrackingGeometrySvc.h.

80{this, "GeometryProcessors", {}, "Tools to process geometry"};

◆ m_rerunOnCallback

Gaudi::Property<bool> Trk::TrackingGeometrySvc::m_rerunOnCallback {this, "RerunOnCallback", false}
private

enables the callback

Definition at line 89 of file TrkDetDescr/TrkDetDescrSvc/TrkDetDescrSvc/TrackingGeometrySvc.h.

89{this, "RerunOnCallback", false};

◆ m_trackingGeometry

const Trk::TrackingGeometry* Trk::TrackingGeometrySvc::m_trackingGeometry {nullptr}
mutableprivate

the cached TrackingGeometry

Definition at line 75 of file TrkDetDescr/TrkDetDescrSvc/TrkDetDescrSvc/TrackingGeometrySvc.h.

75{nullptr};

◆ m_trackingGeometryBuilder

ToolHandle<Trk::IGeometryBuilder> Trk::TrackingGeometrySvc::m_trackingGeometryBuilder {this, "GeometryBuilder", ""}
private

the actual building tool

Definition at line 73 of file TrkDetDescr/TrkDetDescrSvc/TrkDetDescrSvc/TrackingGeometrySvc.h.

73{this, "GeometryBuilder", ""};

◆ m_trackingGeometryName

Gaudi::Property<std::string> Trk::TrackingGeometrySvc::m_trackingGeometryName {this, "TrackingGeometryName", "AtlasTrackingGeometry"}
private

the name of the TrackingGeometry

Definition at line 78 of file TrkDetDescr/TrkDetDescrSvc/TrkDetDescrSvc/TrackingGeometrySvc.h.

78{this, "TrackingGeometryName", "AtlasTrackingGeometry"};

The documentation for this class was generated from the following files: