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
 TrackingGeometrySvc (const std::string &name, ISvcLocator *svc)
 Standard Destructor.
virtual ~TrackingGeometrySvc ()
 Destructor.

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
Gaudi::Property< bool > m_rerunOnCallback {this, "RerunOnCallback", false}
 < processors to help
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 45 of file TrackingGeometrySvc.h.

Constructor & Destructor Documentation

◆ TrackingGeometrySvc()

Trk::TrackingGeometrySvc::TrackingGeometrySvc ( const std::string & name,
ISvcLocator * svc )

Standard Destructor.

Constructor.

Definition at line 29 of file TrackingGeometrySvc.cxx.

30 : base_class(name, svc)
32{
33 // geometry processors to validation / distort the TrackingGeometry ------------
34 declareProperty("GeometryProcessors", m_geometryProcessors);
35}
ToolHandleArray< Trk::IGeometryProcessor > m_geometryProcessors

◆ ~TrackingGeometrySvc()

Trk::TrackingGeometrySvc::~TrackingGeometrySvc ( )
virtualdefault

Destructor.

Member Function Documentation

◆ finalize()

StatusCode Trk::TrackingGeometrySvc::finalize ( )
overridevirtual

Finalize Service.

Definition at line 186 of file TrackingGeometrySvc.cxx.

187{
188#ifdef TRKDETDESCR_MEMUSAGE
189 ATH_MSG_INFO("[ memory usage ] Change in memory usage -------------------------------- ");
190 ATH_MSG_INFO("[ memory usage ] Virtual memory change (vsize) : " << m_changeVsize);
191 ATH_MSG_INFO("[ memory usage ] Real memory change (rss) : " << m_changeRss);
192 ATH_MSG_INFO("[ memory usage ] ---------------------------------------------------------");
193#endif
194 ATH_MSG_INFO("finalize() successful.");
195 return StatusCode::SUCCESS;
196}
#define ATH_MSG_INFO(x)

◆ initialize()

StatusCode Trk::TrackingGeometrySvc::initialize ( )
overridevirtual

Initialize Service.

Definition at line 42 of file TrackingGeometrySvc.cxx.

43{
44
46 "!!! Initialization of TrackingGeometrySvc !!! The Service it to be "
47 "deprecated in favour of the relevant Condition Algorithm. !!!");
48 m_autoRetrieveTools = false;
49 m_checkToolDeps = false;
50
51 if (m_geometryProcessors.retrieve().isFailure()) {
52 ATH_MSG_FATAL("Could not retrieve " << m_geometryProcessors);
53 return StatusCode::FAILURE;
54 }
55
57 ATH_MSG_INFO("Building Geometry from TagInfo");
58 // register a callback on TagInfo updates
59 ServiceHandle<ITagInfoMgr> tagInfoMgr("TagInfoMgr", name());
60 ATH_CHECK(tagInfoMgr.retrieve());
61 tagInfoMgr->addListener(this);
62 } else {
63 ATH_MSG_INFO("Building Geometry at initialisation time.");
64 // build with no dependency on COOL
65 if (trackingGeometryInit(false).isFailure()) {
66 ATH_MSG_FATAL("Unable to build the TrackingGeometry!");
67 return StatusCode::FAILURE;
68 }
69 }
70 ATH_MSG_INFO("initialize() successful! ");
71 return StatusCode::SUCCESS;
72}
#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.
Gaudi::Property< bool > m_buildGeometryFromTagInfo

◆ tagInfoUpdated()

void Trk::TrackingGeometrySvc::tagInfoUpdated ( )
finaloverridevirtual

Implements ITagInfoMgr::Listener.

Definition at line 75 of file TrackingGeometrySvc.cxx.

76{
77 ATH_MSG_INFO("tagInfoUpdated() callback trigerred");
78 trackingGeometryInit().ignore();
79}

◆ 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 99 of file TrackingGeometrySvc.h.

101 return m_trackingGeometry; }
const Trk::TrackingGeometry * m_trackingGeometry
the cached TrackingGeometry

◆ trackingGeometryInit()

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

Create the geometry.

Definition at line 82 of file TrackingGeometrySvc.cxx.

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

Definition at line 103 of file TrackingGeometrySvc.h.

104 { return m_trackingGeometryName; }

◆ trackingGeometryNotSet()

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

Definition at line 179 of file TrackingGeometrySvc.cxx.

180{
181 ATH_MSG_WARNING("TrackingGeometry not set ptr=" << static_cast<const void*>(m_trackingGeometry));
182}

◆ SvcFactory< TrackingGeometrySvc >

friend class SvcFactory< TrackingGeometrySvc >
friend

Standard Constructor.

Definition at line 63 of file TrackingGeometrySvc.h.

Member Data Documentation

◆ m_buildGeometryFromTagInfo

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

Definition at line 95 of file TrackingGeometrySvc.h.

95{this, "BuildGeometryFromTagInfo", true};

◆ m_geometryProcessors

ToolHandleArray<Trk::IGeometryProcessor> Trk::TrackingGeometrySvc::m_geometryProcessors
private

Definition at line 84 of file TrackingGeometrySvc.h.

◆ m_rerunOnCallback

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

< processors to help

enables the callback

Definition at line 93 of file TrackingGeometrySvc.h.

93{this, "RerunOnCallback", false};

◆ m_trackingGeometry

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

the cached TrackingGeometry

Definition at line 79 of file TrackingGeometrySvc.h.

79{nullptr};

◆ m_trackingGeometryBuilder

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

the actual building tool

Definition at line 77 of file TrackingGeometrySvc.h.

77{this, "GeometryBuilder", ""};

◆ m_trackingGeometryName

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

the name of the TrackingGeometry

Definition at line 82 of file TrackingGeometrySvc.h.

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

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