ATLAS Offline Software
Classes | Namespaces | Macros | Functions
ToolWithConstants.h File Reference

Hold constants for a tool. More...

#include "CaloUtils/exceptions.h"
#include "CaloInterface/IToolWithConstants.h"
#include "CaloConditions/ToolConstants.h"
#include "AthenaBaseComps/AthCheckMacros.h"
#include "StoreGate/ReadCondHandleKey.h"
#include "StoreGate/ReadCondHandle.h"
#include "AthenaKernel/errorcheck.h"
#include "CxxUtils/concepts.h"
#include "Gaudi/Property.h"
#include <string>
#include <sstream>
#include <type_traits>
#include "CaloUtils/ToolWithConstants.icc"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  CaloUtils::ToolConstantsContext
 Context object for retrieving ToolConstant values. More...
 
class  CaloUtils::IToolConstant
 Internal interface for dealing with a collection of ToolConstants. More...
 
class  CaloUtils::ToolWithConstantsImpl
 Internal implementation object. More...
 
class  CaloUtils::ToolConstant< T >
 Constant of a ToolWithConstants. More...
 
class  CaloUtils::ToolConstant< T >::CProperty
 Internal wrapper for Gaudi::Property. More...
 
class  CaloUtils::ToolWithConstants< BASE >
 

Namespaces

 Gaudi
 =============================================================================
 
 Gaudi::Parsers
 
 CaloUtils
 

Macros

#define ATH_TWC_REQUIRES   ATH_REQUIRES( requires (BASE& b, Gaudi::Property<int>& p) { { b.declareProperty(p) }; } )
 Hold constants for a tool. More...
 

Functions

template<unsigned int N>
StatusCode Gaudi::Parsers::parse (CaloRec::Array< N > &, const std::string &)
 

Detailed Description

Hold constants for a tool.

Author
scott snyder snyde.nosp@m.r@bn.nosp@m.l.gov
Date
Apr, 2020 An extension to Gaudi components to manage a set of Constants, which are like properties but are set from COOL with the possibility of overriding them from job options.

See the class ToolWithConstants below for more information.

Definition in file ToolWithConstants.h.

Macro Definition Documentation

◆ ATH_TWC_REQUIRES

#define ATH_TWC_REQUIRES   ATH_REQUIRES( requires (BASE& b, Gaudi::Property<int>& p) { { b.declareProperty(p) }; } )

Hold constants for a tool.

Certain tools, such as correction tools, have a large number of constants associated with them. One does not want to hard-code these constants; instead, the tools should be able to get them either from job options or from a COOL database.

This class extends Gaudi components to manage a set of ‘Constants’, which are like properties but can be set either from job options or from COOL (or possibly defaulted). The constants may either be scalar arithmetic types (floating-point, integer, boolean) or an specialization of CxxUtils::Array<N>. (Note, however, that the values are always stored as single-precision floating-point.)

A Constant may be declared similarly to a Gaudi property. To retrieve its value, call context() and then pass that to the operator() method of the Constant.

This is probably best shown as an example.

class MyTool
: public CaloUtils::ToolWithConstants<AthAlgTool>
{
// Define a floating-point constant, with a default value.
Constant<float> m_cf
{ this, "FloatConst", 1.5, "A description" };
// Define an integer constant, with no default value.
Constant<int> m_ci
{ this, "IntConst", "A description" };
// Define a two-dimensional array constant.
// Array constants do not have defaults.
Constant<CxxUtils::Array<2> > m_ca
{ this, "ArrayConst", "A description" };
public:
// The constructor can be delegated to the base class.
using base_base::base_class;
// If you have an initialize() method, you must call the
// base class version.
virtual StatusCode initialize() override
{
return StatusCode::SUCCESS;
}
void doit (const EventContext& ctx) const
{
// Make a local context object.
Context myctx = context (ctx);
// Retrieve the constants.
float cf = m_cf (myctx);
int ci = m_ci (myctx);
CxxUtils::Array<2> ca = m_ca (myctx);

Constants that come from COOL are kept in a ToolConstants conditions object; the key of this object is set from the DBHandleKey property. Constants for multiple tools may be combined in a single ToolConstants object. Each tool has a string prefix (unique within such a group) that is added to the constant name when it is looked up in the ToolConstants object.

For data that are stored as inline COOL data, a conditions algorithm is used to populate a ToolConstants object from COOL.

Settings from COOL may be overridden with settings from job options. For values that are arrays, the value should be set as a string.

Definition at line 436 of file ToolWithConstants.h.

initialize
void initialize()
Definition: run_EoverP.cxx:894
CaloUtils::ToolWithConstants::initialize
virtual StatusCode initialize() override
Initialize method.
WriteCaloSwCorrections.ca
ca
Definition: WriteCaloSwCorrections.py:28
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CxxUtils::Array< 2 >
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloUtils::ToolWithConstants::context
Context context(const EventContext &ctx) const
Create a Context object.
CaloUtils::ToolWithConstants
Definition: ToolWithConstants.h:440