ATLAS Offline Software
Loading...
Searching...
No Matches
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.
using Context
 Convenient alias for the Context type.
using Constant
 Alias for the Constant type.

Public Member Functions

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

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.
StringProperty m_prefix
 Prefix for finding our constants within the ToolConstants object.
ToolWithConstantsImpl m_impl
 Internal implementation object.
Constant< int > m_order
 Used to fix the ordering of tools when we're initializing from COOL based on a hierarchical tag.
Constant< bool > m_isdummy
 If true, then this is a dummy tool that should not be executed.

Detailed Description

Algorithm used for testing ToolWithConstants.

Definition at line 27 of file ToolWithConstantsTestTool.h.

Member Typedef Documentation

◆ base_class

typedef ToolWithConstants CaloUtils::ToolWithConstants< BASE >::base_class
inherited

Shorthand for derived classes.

Definition at line 450 of file ToolWithConstants.h.

◆ Constant

using CaloUtils::ToolWithConstants< BASE >::Constant
inherited

Alias for the Constant type.

Definition at line 463 of file ToolWithConstants.h.

◆ Context

using CaloUtils::ToolWithConstants< BASE >::Context
inherited

Convenient alias for the Context type.

Definition at line 458 of file ToolWithConstants.h.

Member Function Documentation

◆ context()

Context CaloUtils::ToolWithConstants< BASE >::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)
118 return StatusCode::SUCCESS;
119}
#define CHECKCONST(V)
Context context(const EventContext &ctx) const
CaloUtils::ToolConstantsContext Context

◆ 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}
#define ATH_CHECK
Evaluate an expression and check for errors.
static Double_t tc
virtual StatusCode initialize() override
Initialize method.
l
Printing final latex table to .tex output file.

◆ mergeConstants()

virtual StatusCode CaloUtils::ToolWithConstants< BASE >::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}
#define ATH_MSG_INFO(x)
static Double_t ss
virtual void writeConstants(std::ostream &stream, const std::string &name, const EventContext &ctx) const

◆ toolType()

virtual const std::string & CaloUtils::ToolWithConstants< BASE >::toolType ( ) const
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()

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

A non-default tool version, for testing.

Reimplemented from CaloUtils::ToolWithConstants< AthAlgTool >.

Definition at line 125 of file ToolWithConstantsTestTool.cxx.

126{
127 return 2;
128}

◆ writeConstants()

virtual void CaloUtils::ToolWithConstants< BASE >::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.

61{ this, "ca1", "ca1 doc" };

◆ m_ca2

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

Definition at line 62 of file ToolWithConstantsTestTool.h.

62{ this, "ca2", "ca2 doc" };

◆ m_cb1

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

Definition at line 60 of file ToolWithConstantsTestTool.h.

60{ this, "cb1", "cb1 doc" };

◆ m_cf1

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

Definition at line 58 of file ToolWithConstantsTestTool.h.

58{ this, "cf1", 1.5, "cf1 doc" };

◆ m_ci1

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

Definition at line 59 of file ToolWithConstantsTestTool.h.

59{ this, "ci1", "ci1 doc" };

◆ m_condKey

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

Definition at line 52 of file ToolWithConstantsTestTool.h.

53{ this, "CondKey", "", "" };

◆ m_DBHandle

Handle to a ToolConstants conditions object.

Definition at line 534 of file ToolWithConstants.h.

535{ this, "DBHandleKey", "", "" };

◆ m_impl

ToolWithConstantsImpl CaloUtils::ToolWithConstants< BASE >::m_impl
privateinherited

Internal implementation object.

Definition at line 542 of file ToolWithConstants.h.

542{ this->name(), m_prefix, m_DBHandle };
Hold constants for a tool.

◆ m_isdummy

Constant<bool> CaloUtils::ToolWithConstants< BASE >::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 560 of file ToolWithConstants.h.

561{this, "isDummy", false };

◆ m_order

Constant<int> CaloUtils::ToolWithConstants< BASE >::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 547 of file ToolWithConstants.h.

548{ this, "order", 0 };

◆ m_prefix

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

Prefix for finding our constants within the ToolConstants object.

Definition at line 538 of file ToolWithConstants.h.

539{ this, "prefix", "", "" };

◆ m_runNumber

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

Definition at line 55 of file ToolWithConstantsTestTool.h.

56{ this, "RunNumber", 284500, "" };

The documentation for this class was generated from the following files: