ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloClusterCorrection
src
ToolWithConstantsTestTool.cxx
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration.
3
*/
10
11
12
#include "
CaloClusterCorrection/ToolWithConstantsTestTool.h
"
13
#include "
StoreGate/StoreGateSvc.h
"
14
#include "
AthenaKernel/IRCUSvc.h
"
15
#include "
AthenaKernel/ClassID_traits.h
"
16
#include "GaudiKernel/ServiceHandle.h"
17
18
19
namespace
CaloUtils
{
20
21
27
StatusCode
28
ToolWithConstantsTestTool::initialize
()
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>
;
42
DataObjID id (
ClassID_traits<CondCont_t>::ID
(),
m_condKey
);
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
}
93
94
100
StatusCode
101
ToolWithConstantsTestTool::execute
(
const
EventContext& ctx)
const
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)
114
CHECKCONST
(
m_cf1
);
115
CHECKCONST
(
m_ci1
);
116
CHECKCONST
(
m_cb1
);
117
CHECKCONST
(
m_ca1
);
118
CHECKCONST
(
m_ca2
);
119
return
StatusCode::SUCCESS;
120
}
121
122
126
int
ToolWithConstantsTestTool::toolVersion
()
const
127
{
128
return
2;
129
}
130
131
135
void
ToolWithConstantsTestTool::testWriteConstants
(
const
EventContext& ctx)
const
136
{
137
std::ostringstream
ss
;
138
this->
writeConstants
(ss, name(), ctx);
139
ATH_MSG_INFO
(
ss
.str());
140
}
141
142
143
}
// namespace CaloUtils
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
ClassID_traits.h
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
IRCUSvc.h
read-copy-update (RCU) style synchronization for Athena.
ss
static Double_t ss
Definition
LArPhysWaveHECTool.cxx:37
tc
static Double_t tc
Definition
LArPhysWaveHECTool.cxx:38
StoreGateSvc.h
CHECKCONST
#define CHECKCONST(V)
ToolWithConstantsTestTool.h
CaloUtils::ToolWithConstantsTestTool::m_cb1
Constant< bool > m_cb1
Definition
ToolWithConstantsTestTool.h:60
CaloUtils::ToolWithConstantsTestTool::m_ci1
Constant< int > m_ci1
Definition
ToolWithConstantsTestTool.h:59
CaloUtils::ToolWithConstantsTestTool::m_condKey
StringProperty m_condKey
Definition
ToolWithConstantsTestTool.h:53
CaloUtils::ToolWithConstantsTestTool::m_ca1
Constant< CaloRec::Array< 1 > > m_ca1
Definition
ToolWithConstantsTestTool.h:61
CaloUtils::ToolWithConstantsTestTool::m_ca2
Constant< CaloRec::Array< 2 > > m_ca2
Definition
ToolWithConstantsTestTool.h:62
CaloUtils::ToolWithConstantsTestTool::m_cf1
Constant< float > m_cf1
Definition
ToolWithConstantsTestTool.h:58
CaloUtils::ToolWithConstantsTestTool::m_runNumber
IntegerProperty m_runNumber
Definition
ToolWithConstantsTestTool.h:56
CaloUtils::ToolWithConstantsTestTool::execute
StatusCode execute(const EventContext &ctx) const
Gaudi execute method.
Definition
ToolWithConstantsTestTool.cxx:101
CaloUtils::ToolWithConstantsTestTool::testWriteConstants
void testWriteConstants(const EventContext &ctx) const
For testing writeConstants().
Definition
ToolWithConstantsTestTool.cxx:135
CaloUtils::ToolWithConstantsTestTool::toolVersion
virtual int toolVersion() const override
A non-default tool version, for testing.
Definition
ToolWithConstantsTestTool.cxx:126
CaloUtils::ToolWithConstantsTestTool::initialize
StatusCode initialize() override
Gaudi initialize method.
Definition
ToolWithConstantsTestTool.cxx:28
CondCont
Hold mapping of ranges to condition objects.
Definition
CondCont.h:889
ServiceHandle
Definition
ClusterMakerTool.h:36
CaloUtils
Definition
ToolWithConstantsTestTool.h:21
CaloUtils::writeConstants
virtual void writeConstants(std::ostream &stream, const std::string &name, const EventContext &ctx) const
Dump method (for debugging).
CaloUtils::context
Context context(const EventContext &ctx) const
Create a Context object.
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ClassID_traits::ID
static constexpr CLID ID()
Definition
Control/AthenaKernel/AthenaKernel/ClassID_traits.h:44
Generated on
for ATLAS Offline Software by
1.17.0