ATLAS Offline Software
Public Types | Public Member Functions | Public Attributes | List of all members
CaloUtils::ToolWithConstantsImpl Class Reference

Internal implementation object. More...

#include <ToolWithConstants.h>

Collaboration diagram for CaloUtils::ToolWithConstantsImpl:

Public Types

using Context = ToolConstantsContext
 

Public Member Functions

 ToolWithConstantsImpl (const std::string &toolName, const std::string &prefix, SG::ReadCondHandleKey< CaloRec::ToolConstants > &DBHandle)
 Constructor. More...
 
StatusCode initialize ()
 Initialize. More...
 
Context context (const EventContext &ctx) const
 Create a Context object. More...
 
void addConstant (IToolConstant *c)
 Add a new constant to the tool. More...
 
void writeConstants (std::ostream &stream, const std::string &name, const EventContext &ctx) const
 Dump method (for debugging) More...
 
StatusCode mergeConstants (const std::string &typeName, int toolVersion, Context &myctx, bool isDummy, CaloRec::ToolConstants &out) const
 Merge our constants into out with the proper prefix. More...
 

Public Attributes

std::string m_toolName
 Name of the owning tool. More...
 
const std::string & m_prefix
 The prefix of this constant in COOL. More...
 
CaloRec::ToolConstants m_constants
 For settings made from JO. More...
 
SG::ReadCondHandleKey< CaloRec::ToolConstants > & m_DBHandle
 Handle to a ToolConstants conditions object. More...
 
std::vector< IToolConstant * > m_declaredConstants
 All constants declared to this tool. More...
 

Detailed Description

Internal implementation object.

Allows factoring out code which doesn't depend on template parameters.

Definition at line 102 of file ToolWithConstants.h.

Member Typedef Documentation

◆ Context

Definition at line 105 of file ToolWithConstants.h.

Constructor & Destructor Documentation

◆ ToolWithConstantsImpl()

CaloUtils::ToolWithConstantsImpl::ToolWithConstantsImpl ( const std::string &  toolName,
const std::string &  prefix,
SG::ReadCondHandleKey< CaloRec::ToolConstants > &  DBHandle 
)

Constructor.

Parameters
toolNameName of the tool.
prefixConstant prefix in COOL.
DBHandleHandle key for the conditions object.

Definition at line 24 of file ToolWithConstants.cxx.

28  : m_toolName (toolName),
29  m_prefix (prefix),
30  m_DBHandle (DBHandle)
31 {
32 }

Member Function Documentation

◆ addConstant()

void CaloUtils::ToolWithConstantsImpl::addConstant ( IToolConstant c)

Add a new constant to the tool.

Parameters
cConstant to add.

Definition at line 66 of file ToolWithConstants.cxx.

67 {
68  m_declaredConstants.push_back (c);
69 }

◆ context()

ToolWithConstantsImpl::Context CaloUtils::ToolWithConstantsImpl::context ( const EventContext &  ctx) const

Create a Context object.

This can then be passed to Constant::operator().

Definition at line 51 of file ToolWithConstants.cxx.

52 {
53  const CaloRec::ToolConstants* constants = nullptr;
54  if (!m_DBHandle.empty()) {
56  constants = consts.retrieve();
57  }
58  return Context (constants, ctx);
59 }

◆ initialize()

StatusCode CaloUtils::ToolWithConstantsImpl::initialize ( )

Initialize.

Definition at line 38 of file ToolWithConstants.cxx.

39 {
41  return StatusCode::SUCCESS;
42 }

◆ mergeConstants()

StatusCode CaloUtils::ToolWithConstantsImpl::mergeConstants ( const std::string &  typeName,
int  toolVersion,
Context myctx,
bool  isDummy,
CaloRec::ToolConstants out 
) const

Merge our constants into out with the proper prefix.

Parameters
typeNameName of the type of the tool.
toolVersionVersion of the tool.
myctxInternal Context structure.
isDummyisDummy constant from the tool
[out]outObject to receive our constants.

Definition at line 101 of file ToolWithConstants.cxx.

106 {
107  if (out.clsname().empty()) {
108  out.clsname (typeName);
109  out.version (toolVersion);
110  }
111  else if (out.clsname() != typeName) {
112  REPORT_ERROR_WITH_CONTEXT(StatusCode::FAILURE, m_toolName)
113  << "Trying to write to ToolConstants for tools of differing types: "
114  << out.clsname() << " and " << typeName;
115  return StatusCode::FAILURE;
116  }
117  else if (out.version() != toolVersion) {
118  REPORT_ERROR_WITH_CONTEXT(StatusCode::FAILURE, m_toolName)
119  << "Trying to write to ToolConstants for differing versions of tool "
120  << out.clsname() << ": " << out.version() << " and " << toolVersion;
121  return StatusCode::FAILURE;
122  }
123 
124  for (IToolConstant* c : m_declaredConstants) {
125  std::string cname = c->name();
126  std::string prefname = this->m_prefix + cname;
127  const CaloRec::Arrayrep* rep = nullptr;
128  if (m_constants.hasrep (cname)) {
129  rep = &m_constants.getrep (m_toolName, cname);
130  }
131  if (!c->setFromJO() &&
132  myctx.m_constants &&
133  myctx.m_constants->hasrep (prefname))
134  {
135  rep = &myctx.m_constants->getrep (m_toolName, prefname);
136  }
137  if (!rep) {
138  throw ExcConstantNotSet (m_toolName, cname);
139  }
140 
141  if (!isDummy || cname == "isDummy")
142  out.setrep (this->m_prefix + cname, *rep);
143  }
144  return StatusCode::SUCCESS;
145 }

◆ writeConstants()

void CaloUtils::ToolWithConstantsImpl::writeConstants ( std::ostream &  stream,
const std::string &  name,
const EventContext &  ctx 
) const

Dump method (for debugging)

Parameters
streamOstream to which to write.
nameName to go in output
ctxEvent context.

Definition at line 78 of file ToolWithConstants.cxx.

81 {
82  stream << "Member: m_constants" << std::endl;
84  if (!m_DBHandle.empty()) {
86  stream << "Member: m_DBconstants" << std::endl;
87  consts->writeConstants (stream,name);
88  }
89 }

Member Data Documentation

◆ m_constants

CaloRec::ToolConstants CaloUtils::ToolWithConstantsImpl::m_constants

For settings made from JO.

Definition at line 177 of file ToolWithConstants.h.

◆ m_DBHandle

SG::ReadCondHandleKey<CaloRec::ToolConstants>& CaloUtils::ToolWithConstantsImpl::m_DBHandle

Handle to a ToolConstants conditions object.

Definition at line 180 of file ToolWithConstants.h.

◆ m_declaredConstants

std::vector<IToolConstant*> CaloUtils::ToolWithConstantsImpl::m_declaredConstants

All constants declared to this tool.

Definition at line 183 of file ToolWithConstants.h.

◆ m_prefix

const std::string& CaloUtils::ToolWithConstantsImpl::m_prefix

The prefix of this constant in COOL.

Definition at line 174 of file ToolWithConstants.h.

◆ m_toolName

std::string CaloUtils::ToolWithConstantsImpl::m_toolName

Name of the owning tool.

Definition at line 168 of file ToolWithConstants.h.


The documentation for this class was generated from the following files:
CaloUtils::ToolWithConstantsImpl::m_constants
CaloRec::ToolConstants m_constants
For settings made from JO.
Definition: ToolWithConstants.h:177
CaloRec::ToolConstants::writeConstants
void writeConstants(std::ostream &stream, const std::string &name) const
Writes out constants in a python-like format.
Definition: ToolConstants.cxx:126
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
make_hlt_rep.rep
rep
Definition: make_hlt_rep.py:32
CaloUtils::ToolWithConstantsImpl::m_toolName
std::string m_toolName
Name of the owning tool.
Definition: ToolWithConstants.h:168
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
CaloRec::ToolConstants::hasrep
bool hasrep(const std::string &key) const
Test to see if a given key is present.
Definition: ToolConstants.cxx:101
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
CaloUtils::ToolWithConstantsImpl::Context
ToolConstantsContext Context
Definition: ToolWithConstants.h:105
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloUtils::ToolWithConstantsImpl::m_declaredConstants
std::vector< IToolConstant * > m_declaredConstants
All constants declared to this tool.
Definition: ToolWithConstants.h:183
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloRec::ToolConstants
Container for the tool constants managed by ToolWithConstants.
Definition: ToolConstants.h:32
constants
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:1
CaloRec::Arrayrep
Representation class for Array's.
Definition: Control/CxxUtils/CxxUtils/Arrayrep.h:62
ReadCalibFromCool.typeName
typeName
Definition: ReadCalibFromCool.py:477
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
CaloUtils::ToolWithConstantsImpl::m_DBHandle
SG::ReadCondHandleKey< CaloRec::ToolConstants > & m_DBHandle
Handle to a ToolConstants conditions object.
Definition: ToolWithConstants.h:180
python.compressB64.c
def c
Definition: compressB64.py:93
REPORT_ERROR_WITH_CONTEXT
#define REPORT_ERROR_WITH_CONTEXT(SC, CONTEXT_NAME)
Report an error, with an explicitly specified context name.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:333
CaloRec::ToolConstants::getrep
const CxxUtils::Arrayrep & getrep(const std::string &context, const std::string &key) const
Look up an entry.
Definition: ToolConstants.cxx:59
CaloUtils::ToolWithConstantsImpl::m_prefix
const std::string & m_prefix
The prefix of this constant in COOL.
Definition: ToolWithConstants.h:174