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 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().

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" }

Detailed Description

Algorithm used for testing ToolWithConstants.

Definition at line 27 of file ToolWithConstantsTestTool.h.

Member Function Documentation

◆ execute()

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

Gaudi execute method.

Dump out current values of the constants.

Definition at line 101 of file ToolWithConstantsTestTool.cxx.

102{
103 Context myctx = context (ctx);
104#define CHECKCONST(V) \
105 do { \
106 try { \
107 auto val = V (myctx); \
108 ATH_MSG_INFO (#V << " " << val); \
109 } \
110 catch (const std::exception& e) { \
111 ATH_MSG_INFO (#V << " " << e.what()); \
112 } \
113 } while(0)
119 return StatusCode::SUCCESS;
120}
#define CHECKCONST(V)
Context context(const EventContext &ctx) const
Create a Context object.

◆ initialize()

StatusCode CaloUtils::ToolWithConstantsTestTool::initialize ( )
override

Gaudi initialize method.

Make some ToolConstants conditions objects for testing.

Definition at line 28 of file ToolWithConstantsTestTool.cxx.

29{
30 ATH_CHECK( base_class::initialize() );
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 EventContext ctx;
52
53 {
54 auto tc = std::make_unique<CaloRec::ToolConstants>();
55 tc->version (2);
56 tc->clsname (name());
57 tc->newrep (name(), "test.cb1", "0");
58 tc->newrep (name(), "test.ca2", "[[4, 5], [10, 9], [2.5, 1]]");
59 ATH_CHECK( cc->insert (range(0, 1), std::move (tc), ctx) );
60 }
61
62 {
63 auto tc = std::make_unique<CaloRec::ToolConstants>();
64 tc->version (2);
65 tc->clsname (name());
66 tc->newrep (name(), "test.cb1", "1");
67 tc->newrep (name(), "test.ca1", "[10, 9, 8, 7]");
68 tc->newrep (name(), "test.ca2", "[[14, 15], [1, 19], [12.5, 11]]");
69 ATH_CHECK( cc->insert (range(1, 2), std::move (tc), ctx) );
70 }
71
72 {
73 auto tc = std::make_unique<CaloRec::ToolConstants>();
74 tc->version (3);
75 tc->clsname (name());
76 tc->newrep (name(), "test.cb1", "1");
77 tc->newrep (name(), "test.caa", "[10, 9, 8, 7]");
78 tc->newrep (name(), "test.ca2", "[[14, 15], [1, 19], [12.5, 11]]");
79 ATH_CHECK( cc->insert (range(2, 3), std::move (tc), ctx) );
80 }
81
82 {
83 auto tc = std::make_unique<CaloRec::ToolConstants>();
84 tc->version (2);
85 tc->clsname (name());
86 ATH_CHECK( cc->insert (range(3, 4), std::move (tc), ctx) );
87 }
88
89 ATH_CHECK( condStore->record (std::move (cc), m_condKey) );
90
91 return StatusCode::SUCCESS;
92}
#define ATH_CHECK
Evaluate an expression and check for errors.
static Double_t tc
l
Printing final latex table to .tex output file.

◆ testWriteConstants()

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

For testing writeConstants().

Definition at line 135 of file ToolWithConstantsTestTool.cxx.

136{
137 std::ostringstream ss;
138 this->writeConstants (ss, name(), ctx);
139 ATH_MSG_INFO (ss.str());
140}
#define ATH_MSG_INFO(x)
static Double_t ss
virtual void writeConstants(std::ostream &stream, const std::string &name, const EventContext &ctx) const
Dump method (for debugging).

◆ toolVersion()

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

A non-default tool version, for testing.

Definition at line 126 of file ToolWithConstantsTestTool.cxx.

127{
128 return 2;
129}

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_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: