ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Trk::TrackingGeometrySvc Class Reference

#include <TrackingGeometrySvc.h>

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

Public Member Functions

virtual StatusCode initialize () override
 Initialize Service. More...
 
virtual StatusCode finalize () override
 Finalize Service. More...
 
virtual void tagInfoUpdated () override final
 
StatusCode trackingGeometryInit (bool needsInit=true)
 Create the geometry. More...
 
virtual const Trk::TrackingGeometrytrackingGeometry () const override
 Provide the TrackingGeometry. More...
 
virtual const std::string & trackingGeometryName () const override
 
 TrackingGeometrySvc (const std::string &name, ISvcLocator *svc)
 Standard Destructor. More...
 
virtual ~TrackingGeometrySvc ()
 Destructor. More...
 

Private Member Functions

void trackingGeometryNotSet () const
 cached pointers: More...
 

Private Attributes

ISvcLocator * m_pSvcLocator {nullptr}
 
StoreGateSvcm_pDetStore {nullptr}
 
ToolHandle< Trk::IGeometryBuilderm_trackingGeometryBuilder {this, "GeometryBuilder", ""}
 the actual building tool More...
 
const Trk::TrackingGeometrym_trackingGeometry {nullptr}
 the cached TrackingGeometry More...
 
Gaudi::Property< std::string > m_trackingGeometryName {this, "TrackingGeometryName", "AtlasTrackingGeometry"}
 the name of the TrackingGeometry More...
 
ToolHandleArray< Trk::IGeometryProcessorm_geometryProcessors
 
Gaudi::Property< bool > m_rerunOnCallback {this, "RerunOnCallback", false}
 < processors to help More...
 
Gaudi::Property< bool > m_buildGeometryFromTagInfo {this, "BuildGeometryFromTagInfo", true}
 

Friends

class SvcFactory< TrackingGeometrySvc >
 Standard Constructor. More...
 

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)
31  , m_geometryProcessors(this)
32 {
33  // geometry processors to validation / distort the TrackingGeometry ------------
34  declareProperty("GeometryProcessors", m_geometryProcessors);
35 }

◆ ~TrackingGeometrySvc()

Trk::TrackingGeometrySvc::~TrackingGeometrySvc ( )
virtualdefault

Destructor.

Member Function Documentation

◆ finalize()

StatusCode Trk::TrackingGeometrySvc::finalize ( )
overridevirtual

Finalize Service.

Definition at line 185 of file TrackingGeometrySvc.cxx.

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

◆ 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  // get the DetectorStore
52  ATH_CHECK(service("DetectorStore", m_pDetStore));
53 
54  if (m_geometryProcessors.retrieve().isFailure()) {
55  ATH_MSG_FATAL("Could not retrieve " << m_geometryProcessors);
56  return StatusCode::FAILURE;
57  }
58 
60  ATH_MSG_INFO("Building Geometry from TagInfo");
61  // register a callback on TagInfo updates
62  ServiceHandle<ITagInfoMgr> tagInfoMgr("TagInfoMgr", name());
63  ATH_CHECK(tagInfoMgr.retrieve());
64  tagInfoMgr->addListener(this);
65  } else {
66  ATH_MSG_INFO("Building Geometry at initialisation time.");
67  // build with no dependency on COOL
68  if (trackingGeometryInit(false).isFailure()) {
69  ATH_MSG_FATAL("Unable to build the TrackingGeometry!");
70  return StatusCode::FAILURE;
71  }
72  }
73  ATH_MSG_INFO("initialize() successful! ");
74  return StatusCode::SUCCESS;
75 }

◆ tagInfoUpdated()

void Trk::TrackingGeometrySvc::tagInfoUpdated ( )
finaloverridevirtual

Implements ITagInfoMgr::Listener.

Definition at line 78 of file TrackingGeometrySvc.cxx.

79 {
80  ATH_MSG_INFO("tagInfoUpdated() callback trigerred");
81  trackingGeometryInit().ignore();
82 }

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

104  return m_trackingGeometry; }

◆ trackingGeometryInit()

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

Create the geometry.

Definition at line 85 of file TrackingGeometrySvc.cxx.

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

◆ trackingGeometryName()

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

Definition at line 106 of file TrackingGeometrySvc.h.

107  { return m_trackingGeometryName; }

◆ trackingGeometryNotSet()

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

cached pointers:

Definition at line 178 of file TrackingGeometrySvc.cxx.

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

Friends And Related Function Documentation

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

◆ m_geometryProcessors

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

Definition at line 87 of file TrackingGeometrySvc.h.

◆ m_pDetStore

StoreGateSvc* Trk::TrackingGeometrySvc::m_pDetStore {nullptr}
private

Definition at line 78 of file TrackingGeometrySvc.h.

◆ m_pSvcLocator

ISvcLocator* Trk::TrackingGeometrySvc::m_pSvcLocator {nullptr}
private

Definition at line 77 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 96 of file TrackingGeometrySvc.h.

◆ m_trackingGeometry

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

the cached TrackingGeometry

Definition at line 82 of file TrackingGeometrySvc.h.

◆ m_trackingGeometryBuilder

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

the actual building tool

Definition at line 80 of file TrackingGeometrySvc.h.

◆ m_trackingGeometryName

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

the name of the TrackingGeometry

Definition at line 85 of file TrackingGeometrySvc.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
StoreGateSvc::record
StatusCode record(T *p2BRegistered, const TKEY &key)
Record an object with a key.
Trk::TrackingGeometrySvc::m_buildGeometryFromTagInfo
Gaudi::Property< bool > m_buildGeometryFromTagInfo
Definition: TrackingGeometrySvc.h:98
StoreGateSvc::contains
bool contains(const TKEY &key) const
Look up a keyed object in TDS (compare also tryRetrieve) returns false if object not available in TDS...
Trk::TrackingGeometrySvc::m_trackingGeometry
const Trk::TrackingGeometry * m_trackingGeometry
the cached TrackingGeometry
Definition: TrackingGeometrySvc.h:82
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::TrackingGeometrySvc::m_geometryProcessors
ToolHandleArray< Trk::IGeometryProcessor > m_geometryProcessors
Definition: TrackingGeometrySvc.h:87
Trk::TrackingGeometrySvc::m_trackingGeometryBuilder
ToolHandle< Trk::IGeometryBuilder > m_trackingGeometryBuilder
the actual building tool
Definition: TrackingGeometrySvc.h:80
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
StoreGateSvc::retrieve
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
Trk::TrackingGeometrySvc::trackingGeometryInit
StatusCode trackingGeometryInit(bool needsInit=true)
Create the geometry.
Definition: TrackingGeometrySvc.cxx:85
Trk::TrackingGeometry
Definition: TrackingGeometry.h:67
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::TrackingGeometrySvc::m_pDetStore
StoreGateSvc * m_pDetStore
Definition: TrackingGeometrySvc.h:78
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
Trk::TrackingGeometrySvc::trackingGeometryNotSet
void trackingGeometryNotSet() const
cached pointers:
Definition: TrackingGeometrySvc.cxx:178
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
Trk::TrackingGeometrySvc::m_rerunOnCallback
Gaudi::Property< bool > m_rerunOnCallback
< processors to help
Definition: TrackingGeometrySvc.h:96
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::TrackingGeometrySvc::m_trackingGeometryName
Gaudi::Property< std::string > m_trackingGeometryName
the name of the TrackingGeometry
Definition: TrackingGeometrySvc.h:85
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
StoreGateSvc::remove
StatusCode remove(const T *pObject)
Remove pObject, will remove its proxy if not reset only.
ServiceHandle< ITagInfoMgr >