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

Algorithm used for testing ToolWithConstants. More...

#include <ToolWithConstantsTestTool.h>

Inheritance diagram for CaloUtils::ToolWithConstantsTestTool:
Collaboration diagram for CaloUtils::ToolWithConstantsTestTool:

Public Types

typedef ToolWithConstants base_class
 Shorthand for derived classes. More...
 
using Context = CaloUtils::ToolConstantsContext
 Convenient alias for the Context type. More...
 
using Constant = ToolConstant< T >
 Alias for the Constant type. More...
 

Public Member Functions

StatusCode initialize () override
 Gaudi initialize method. More...
 
StatusCode execute (const EventContext &ctx) const
 Gaudi execute method. More...
 
virtual int toolVersion () const override
 A non-default tool version, for testing. More...
 
void testWriteConstants (const EventContext &ctx) const
 For testing writeConstants(). More...
 
Context context (const EventContext &ctx) const
 Create a Context object. More...
 
virtual void writeConstants (std::ostream &stream, const std::string &name, const EventContext &ctx) const
 Dump method (for debugging) More...
 
virtual StatusCode mergeConstants (CaloRec::ToolConstants &out, const EventContext &ctx) const override
 Merge our constants into out with the proper prefix. More...
 
virtual int toolVersion () const
 Return the version number for this tool. More...
 
virtual const std::string & toolType () const
 Return the name of the type of this tool. More...
 

Private Attributes

StringProperty m_condKey { this, "CondKey", "", "" }
 
IntegerProperty m_runNumber { this, "RunNumber", 284500, "" }
 
Constant< float > m_cf1 { this, "cf1", 1.5, "cf1 doc" }
 
Constant< int > m_ci1 { this, "ci1", "ci1 doc" }
 
Constant< bool > m_cb1 { this, "cb1", "cb1 doc" }
 
Constant< CaloRec::Array< 1 > > m_ca1 { this, "ca1", "ca1 doc" }
 
Constant< CaloRec::Array< 2 > > m_ca2 { this, "ca2", "ca2 doc" }
 
SG::ReadCondHandleKey< CaloRec::ToolConstantsm_DBHandle
 Handle to a ToolConstants conditions object. More...
 
StringProperty m_prefix
 Prefix for finding our constants within the ToolConstants object. More...
 
ToolWithConstantsImpl m_impl
 Internal implementation object. More...
 
Constant< int > m_order
 Used to fix the ordering of tools when we're initializing from COOL based on a hierarchical tag. More...
 
Constant< bool > m_isdummy
 If true, then this is a dummy tool that should not be executed. More...
 

Detailed Description

Algorithm used for testing ToolWithConstants.

Definition at line 27 of file ToolWithConstantsTestTool.h.

Member Typedef Documentation

◆ base_class

Shorthand for derived classes.

Definition at line 443 of file ToolWithConstants.h.

◆ Constant

Alias for the Constant type.

Definition at line 456 of file ToolWithConstants.h.

◆ Context

Convenient alias for the Context type.

Definition at line 451 of file ToolWithConstants.h.

Member Function Documentation

◆ context()

Context CaloUtils::ToolWithConstants< AthAlgTool >::context ( const EventContext &  ctx) const
inherited

Create a Context object.

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

◆ execute()

StatusCode CaloUtils::ToolWithConstantsTestTool::execute ( const EventContext &  ctx) const

Gaudi execute method.

Dump out current values of the constants.

Definition at line 100 of file ToolWithConstantsTestTool.cxx.

101 {
102  Context myctx = context (ctx);
103 #define CHECKCONST(V) \
104  do { \
105  try { \
106  auto val = V (myctx); \
107  ATH_MSG_INFO (#V << " " << val); \
108  } \
109  catch (const std::exception& e) { \
110  ATH_MSG_INFO (#V << " " << e.what()); \
111  } \
112  } while(0)
113  CHECKCONST (m_cf1);
114  CHECKCONST (m_ci1);
115  CHECKCONST (m_cb1);
116  CHECKCONST (m_ca1);
117  CHECKCONST (m_ca2);
118  return StatusCode::SUCCESS;
119 }

◆ initialize()

StatusCode CaloUtils::ToolWithConstantsTestTool::initialize ( )
overridevirtual

Gaudi initialize method.

Make some ToolConstants conditions objects for testing.

Reimplemented from CaloUtils::ToolWithConstants< AthAlgTool >.

Definition at line 28 of file ToolWithConstantsTestTool.cxx.

29 {
31  if (m_condKey.empty()) {
32  return StatusCode::SUCCESS;
33  }
34 
35  ServiceHandle<StoreGateSvc> condStore ("ConditionStore", name());
36  ATH_CHECK( condStore.retrieve() );
37 
38  ServiceHandle<Athena::IRCUSvc> rcusvc ("Athena::RCUSvc", name());
39  ATH_CHECK( rcusvc.retrieve() );
40 
41  using CondCont_t = CondCont<CaloRec::ToolConstants>;
43  auto cc = std::make_unique<CondCont_t> (*rcusvc.get(), id);
44 
45  auto lbn = [&](int l) { return EventIDBase (m_runNumber,
46  EventIDBase::UNDEFEVT,
47  EventIDBase::UNDEFNUM,
48  EventIDBase::UNDEFNUM,
49  l); };
50  auto range = [&](int l1, int l2) { return EventIDRange (lbn(l1), lbn(l2)); };
51 
52  {
53  auto tc = std::make_unique<CaloRec::ToolConstants>();
54  tc->version (2);
55  tc->clsname (name());
56  tc->newrep (name(), "test.cb1", "0");
57  tc->newrep (name(), "test.ca2", "[[4, 5], [10, 9], [2.5, 1]]");
58  ATH_CHECK( cc->insert (range(0, 1), std::move (tc)) );
59  }
60 
61  {
62  auto tc = std::make_unique<CaloRec::ToolConstants>();
63  tc->version (2);
64  tc->clsname (name());
65  tc->newrep (name(), "test.cb1", "1");
66  tc->newrep (name(), "test.ca1", "[10, 9, 8, 7]");
67  tc->newrep (name(), "test.ca2", "[[14, 15], [1, 19], [12.5, 11]]");
68  ATH_CHECK( cc->insert (range(1, 2), std::move (tc)) );
69  }
70 
71  {
72  auto tc = std::make_unique<CaloRec::ToolConstants>();
73  tc->version (3);
74  tc->clsname (name());
75  tc->newrep (name(), "test.cb1", "1");
76  tc->newrep (name(), "test.caa", "[10, 9, 8, 7]");
77  tc->newrep (name(), "test.ca2", "[[14, 15], [1, 19], [12.5, 11]]");
78  ATH_CHECK( cc->insert (range(2, 3), std::move (tc)) );
79  }
80 
81  {
82  auto tc = std::make_unique<CaloRec::ToolConstants>();
83  tc->version (2);
84  tc->clsname (name());
85  ATH_CHECK( cc->insert (range(3, 4), std::move (tc)) );
86  }
87 
88  ATH_CHECK( condStore->record (std::move (cc), m_condKey) );
89 
90  return StatusCode::SUCCESS;
91 }

◆ mergeConstants()

virtual StatusCode CaloUtils::ToolWithConstants< AthAlgTool >::mergeConstants ( CaloRec::ToolConstants out,
const EventContext &  ctx 
) const
overridevirtualinherited

Merge our constants into out with the proper prefix.

Parameters
[out]outObject to receive our constants.
ctxEvent context.

◆ testWriteConstants()

void CaloUtils::ToolWithConstantsTestTool::testWriteConstants ( const EventContext &  ctx) const

For testing writeConstants().

Definition at line 134 of file ToolWithConstantsTestTool.cxx.

135 {
136  std::ostringstream ss;
137  this->writeConstants (ss, name(), ctx);
138  ATH_MSG_INFO (ss.str());
139 }

◆ toolType()

virtual const std::string& CaloUtils::ToolWithConstants< AthAlgTool >::toolType
virtualinherited

Return the name of the type of this tool.

A saved set of constants includes both the C++ class name and a version number. Normally, the class name is taken from the Gaudi type() method, but that may be changed by overriding this method. This can be used, for example, when there are tools with distinct C++ classes but which are yet similar enough to combine together.

◆ toolVersion() [1/2]

virtual int CaloUtils::ToolWithConstants< AthAlgTool >::toolVersion
virtualinherited

Return the version number for this tool.

A saved set of constants includes both the C++ class name and a version number. The idea is that the version number can be bumped whenever there's a backwards-incompatible change; this gives some protection against trying to use an old version of a tool with an incompatible newer set of constants.

If you want a tool to have a version number, override this method. Otherwise, it will default to a version number of 0.

◆ toolVersion() [2/2]

int CaloUtils::ToolWithConstantsTestTool::toolVersion ( ) const
overridevirtual

A non-default tool version, for testing.

Definition at line 125 of file ToolWithConstantsTestTool.cxx.

126 {
127  return 2;
128 }

◆ writeConstants()

virtual void CaloUtils::ToolWithConstants< AthAlgTool >::writeConstants ( std::ostream &  stream,
const std::string &  name,
const EventContext &  ctx 
) const
virtualinherited

Dump method (for debugging)

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

Member Data Documentation

◆ m_ca1

Constant<CaloRec::Array<1> > CaloUtils::ToolWithConstantsTestTool::m_ca1 { this, "ca1", "ca1 doc" }
private

Definition at line 61 of file ToolWithConstantsTestTool.h.

◆ m_ca2

Constant<CaloRec::Array<2> > CaloUtils::ToolWithConstantsTestTool::m_ca2 { this, "ca2", "ca2 doc" }
private

Definition at line 62 of file ToolWithConstantsTestTool.h.

◆ m_cb1

Constant<bool> CaloUtils::ToolWithConstantsTestTool::m_cb1 { this, "cb1", "cb1 doc" }
private

Definition at line 60 of file ToolWithConstantsTestTool.h.

◆ m_cf1

Constant<float> CaloUtils::ToolWithConstantsTestTool::m_cf1 { this, "cf1", 1.5, "cf1 doc" }
private

Definition at line 58 of file ToolWithConstantsTestTool.h.

◆ m_ci1

Constant<int> CaloUtils::ToolWithConstantsTestTool::m_ci1 { this, "ci1", "ci1 doc" }
private

Definition at line 59 of file ToolWithConstantsTestTool.h.

◆ m_condKey

StringProperty CaloUtils::ToolWithConstantsTestTool::m_condKey { this, "CondKey", "", "" }
private

Definition at line 52 of file ToolWithConstantsTestTool.h.

◆ m_DBHandle

Handle to a ToolConstants conditions object.

Definition at line 527 of file ToolWithConstants.h.

◆ m_impl

Internal implementation object.

Definition at line 535 of file ToolWithConstants.h.

◆ m_isdummy

Constant<bool> CaloUtils::ToolWithConstants< AthAlgTool >::m_isdummy
privateinherited

If true, then this is a dummy tool that should not be executed.

This is used for the case of reading from COOL using hierarchical tags: we need to have such tags associated with some object in each folder, regardless of whether or not the correction from that folder is actually used. [Every folder that IOVDbSvc knows about at configuration time needs to have a valid object for the configured tag, else IOVDbSvc will raise a fatal error. But we don't know at configuration time which folders we're actually going to need, so we gotta configure all of them.]

Definition at line 553 of file ToolWithConstants.h.

◆ m_order

Constant<int> CaloUtils::ToolWithConstants< AthAlgTool >::m_order
privateinherited

Used to fix the ordering of tools when we're initializing from COOL based on a hierarchical tag.

Tools should be executed in order of increasing m_order.

Definition at line 540 of file ToolWithConstants.h.

◆ m_prefix

StringProperty CaloUtils::ToolWithConstants< AthAlgTool >::m_prefix
privateinherited

Prefix for finding our constants within the ToolConstants object.

Definition at line 531 of file ToolWithConstants.h.

◆ m_runNumber

IntegerProperty CaloUtils::ToolWithConstantsTestTool::m_runNumber { this, "RunNumber", 284500, "" }
private

Definition at line 55 of file ToolWithConstantsTestTool.h.


The documentation for this class was generated from the following files:
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloUtils::ToolWithConstantsTestTool::m_runNumber
IntegerProperty m_runNumber
Definition: ToolWithConstantsTestTool.h:56
CaloUtils::ToolWithConstants< AthAlgTool >::Context
CaloUtils::ToolConstantsContext Context
Convenient alias for the Context type.
Definition: ToolWithConstants.h:451
CaloUtils::ToolWithConstantsTestTool::m_cf1
Constant< float > m_cf1
Definition: ToolWithConstantsTestTool.h:58
CaloUtils::ToolWithConstantsTestTool::m_condKey
StringProperty m_condKey
Definition: ToolWithConstantsTestTool.h:53
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
CaloUtils::ToolWithConstants< AthAlgTool >::writeConstants
virtual void writeConstants(std::ostream &stream, const std::string &name, const EventContext &ctx) const
Dump method (for debugging)
CaloUtils::ToolWithConstantsTestTool::m_cb1
Constant< bool > m_cb1
Definition: ToolWithConstantsTestTool.h:60
CaloUtils::ToolWithConstants::initialize
virtual StatusCode initialize() override
Initialize method.
skel.l2
l2
Definition: skel.GENtoEVGEN.py:399
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
CaloUtils::ToolWithConstantsTestTool::m_ca1
Constant< CaloRec::Array< 1 > > m_ca1
Definition: ToolWithConstantsTestTool.h:61
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
CaloUtils::ToolWithConstants< AthAlgTool >::context
Context context(const EventContext &ctx) const
Create a Context object.
CHECKCONST
#define CHECKCONST(V)
CondCont< CaloRec::ToolConstants >
CaloUtils::ToolWithConstantsTestTool::m_ca2
Constant< CaloRec::Array< 2 > > m_ca2
Definition: ToolWithConstantsTestTool.h:62
skel.l1
l1
Definition: skel.GENtoEVGEN.py:398
python.handimod.cc
int cc
Definition: handimod.py:523
CaloUtils::ToolWithConstantsTestTool::m_ci1
Constant< int > m_ci1
Definition: ToolWithConstantsTestTool.h:59
LB_AnalMapSplitter.lbn
lbn
Definition: LB_AnalMapSplitter.py:28
ServiceHandle< StoreGateSvc >