Light Taper Implementation in CalDigi - using Gaudi Tools

Introduction

Light taper is defined as the decay of light in the crystals from the energy deposition point to the end face (and the diode). There are multiple light taper functions that we envisage having available, so it would be nice to have them available on demand, configurable from the jobOptions file.

A way to do this is via Gaudi Tools. This example was built using the Gaudi Developer Guide (Chapter 12) and Johann Cohen-Tanugi's Vertex code as an example to fill in the details left out of the GDG.

The light taper takes as input the position and magnitude of the energy deposit. It can use parameters to then calculate the attenuation.

The initial taper models are: linear (simple, default so far) and linear+exponential, which empirically reproduces the drop-off of light collection observed near the end faces (yielding a slightly S-shaped light asymmetry curve).

Implementation

See the checklist on p 114 of the GDG for code necessary for setting up a Tool.

Abstract Interface Class - ITaper

 An interface class, ITaper, was defined to encapsulate the taper function behaviour  It inherits from IAlgTool.. 

class ITaper : virtual public IAlgTool

It has a standard default constructor and destructor, plus additional code for the Tool interface:

a global object:

static const InterfaceID IID_ITaper("ITaper", 1 , 0);

and in the public definition:

static const InterfaceID& interfaceID() { return IID_ITaper; }

So far, it's only function of physical interest is 

calculateSignals(double relativePosition, double energyDeposit)

which is set up as a pure virtual function.

Concrete Implementation - LinearTaper

The concrete implementation inherits from both AgTools and ITaper

class LinearTaper : public AlgTool, virtual public ITaper 

with special constructor

LinearTaper( const std::string& type, const std::string& name, const IInterface* parent);

and declaration of the to-be-overriden calculateSignals function:

virtual std::pair<double, double> calculateSignals(double relativePosition, double depositedEnergy);

In the implementation file, one has to implement the factories

#include "GaudiKernel/ToolFactory.h"


static ToolFactory<linearTaper> s_factory;
const IToolFactory& linearTaperFactory = s_factory;

LinearTaper::LinearTaper( const std::string& type, 
                                            const std::string& name,         
                                            const IInterface* parent)
                                        : AlgTool(type,name,parent)
        {
        // declare base interface for all consecutive concrete classes
        declareInterface<ITaper>(this);
        }

Note that the concrete implementations can override the initialize() function and can have their own extended private data, so they can be quite different in practical application (use of parameters, interal data, etc).

Declaring the Tool Name

As is required for Algorithms, it is necessary to tell the system about the name of the tool. This is done in CalDigi_load.cxx (note - this also includes the already existing declaration of the CalDigiAlg algorithm):

#include "GaudiKernel/DeclareFactoryEntries.h"
#include "GaudiKernel/IToolFactory.h"

#define DLL_DECL_TOOL(x) extern const IToolFactory& x##Factory; x##Factory.addRef();


DECLARE_FACTORY_ENTRIES(CalDigi) {
DECLARE_ALGORITHM( CalDigiAlg );
DLL_DECL_TOOL( LinearTaper );

Retrieving the Tool

The tool is currently used from CalDigiAlg. A pointer is maintained in the private data:

ITaper* m_taper;

referencing only the base class, as desired for interchangeability.

And the Tool is retrieved via the toolSvc function from CalDigiAlg's initialize() function:

sc = toolSvc()->retrieveTool("LinearTaper",m_taper);
if (sc.isFailure() ) {
log << MSG::ERROR << " Unable to create LinearTaper tool" << endreq;
return sc;
}

Note that one must include the IToolSvc.h file (not sure why since this is notionally in the Algorithm interface?):

#include "GaudiKernel/IToolSvc.h"

Accessing the Tool

The tool is used in the CalDigiAlg::execute() loop where McIntegratingHits are found and energy (and moments) are used to calculate the light attenuation:

std::pair<double,double> signals;
signals = m_taper->calculateSignals(relpos,ene);

// set up a XtalMap to act as key for the map - if there is no entry, add
// add one, otherwise add signal to existing map element.

xtalSignalRef.addSignal(signals.first,signals.second);

We have achieved the desired effect of being able to select the type of calculateSgnals function external to its use. It can now be set up via a jobOptions parameter to CalDigiAlg.


R.Dubois Last Modified: 2005-06-24 14:11:33 -0700