23.05.2014 Views

Athena Developer Guide

Athena Developer Guide

Athena Developer Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Athena</strong> Chapter 5 Writing algorithms Version/Issue: 2.0.0<br />

5.3.1 Creation (and algorithm factories)<br />

As mentioned before, a concrete algorithm class must specify a single constructor with the same<br />

parameter signature as the constructor of the base class.<br />

In addition to this a concrete algorithm factory must be provided. This is a technical matter which<br />

permits the application manager to create new algorithm objects without having to include all of the<br />

concrete algorithm header files. From the point of view of an algorithm developer it implies adding two<br />

lines into the implementation file, of the form:<br />

static const AlgFactory s_factory;<br />

const IAlgFactory& ConcreteAlgorithmFactory = s_factory;<br />

where “ConcreteAlgorithm” should be replaced by the name of the derived algorithm class (see<br />

for example lines 10 and 11 in Listing 5.2 below).<br />

5.3.2 Declaring properties<br />

In general a concrete algorithm class will have several data members which are used in the execution of<br />

the algorithm proper. These data members should of course be initialized in the constructor, but if this<br />

was the only mechanism available to set their value it would be necessary to recompile the code every<br />

time you wanted to run with different settings. In order to avoid this, the framework provides a<br />

mechanism for setting the values of member variables at run time.<br />

The mechanism comes in two parts: the declaration of properties and the setting of their values. As an<br />

example consider the class TriggerDecision in Listing 5.2 which has a number of variables whose<br />

value we would like to set at run time.<br />

The default values for the variables are set within the constructor (within an initialiser list) as per<br />

normal. To declare them as properties it suffices to call the declareProperty() method. This<br />

method is overloaded to take an std::string as the first parameter and a variety of different types<br />

for the second parameter. The first parameter is the name by which this member variable shall be<br />

referred to, and the second parameter is a reference to the member variable itself.<br />

page 26<br />

In the example we associate the name “PassAllMode” to the member variable m_passAllMode,<br />

and the name “MuonCandidateCut” to m_muonCandidateCut. The first is of type boolean and<br />

the second an integer. If the job options service (described in Chapter 13) finds an option in the job<br />

options file belonging to this algorithm and whose name matches one of the names associated with a<br />

member variable, then that member variable will be set to the value specified in the job options file.

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

Saved successfully!

Ooh no, something went wrong!