23.05.2014 Views

Athena Developer Guide

Athena Developer Guide

Athena Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Athena</strong> Chapter 13 Framework services Version/Issue: 2.0.0<br />

ParticlePropertySvc, ChronoStatSvc, AuditorSvc, RndmGenSvc,<br />

IncidentSvc, ToolSvc).<br />

Additional services can be requested via the job options file, using the property<br />

ApplicationMgr.ExtSvc. In the example below this option is used to create a specific type of<br />

persistency service.:<br />

Listing 13.1 Job Option to create additional services<br />

ApplicationMgr.ExtSvc += { "DbEventCnvSvc/RootEvtCnvSvc" };<br />

Once created, services must be accessed via their interface. The Algorithm base class provides a<br />

number of accessor methods for the standard framework services, listed on lines 25 to 35 of Listing 5.1<br />

on page 24. Other services can be located using the templated service function. In the example<br />

below we use this function to return the IParticlePropertySvc interface of the Particle<br />

Properties Service:<br />

Listing 13.2 Code to access the IParticlePropertySvc interface from an Algorithm<br />

#include "GaudiKernel/IParticlePropertySvc.h"<br />

...<br />

IParticlePropertySvc* m_ppSvc;<br />

StatusCode sc = service( "ParticlePropertySvc", m_ppSvc );<br />

if ( sc.isFailure) {<br />

...<br />

In components other than Algorithms, which do not provide the service function, you can locate a<br />

service using the serviceLocator function:<br />

Listing 13.3<br />

#include "GaudiKernel/IParticlePropertySvc.h"<br />

...<br />

IParticlePropertySvc* m_ppSvc;<br />

StatusCode sc = serviceLocator()->getService(<br />

"ParticlePropertySvc",<br />

IID_IParticlePropertySvc,<br />

reinterpret_cast(m_ppSvc));<br />

if ( sc.isFailure) {<br />

...<br />

page 96

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!