ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaExamples
AthExHive
src
HiveAlgB.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
HiveAlgB.h
"
6
#include <thread>
7
#include <chrono>
8
#include <memory>
9
10
HiveAlgB::HiveAlgB
(
const
std::string& name,
11
ISvcLocator* pSvcLocator ) :
12
HiveAlgBase
( name, pSvcLocator ),
13
m_di(0) {}
14
15
HiveAlgB::~HiveAlgB
() =
default
;
16
17
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
18
19
StatusCode
HiveAlgB::initialize
() {
20
ATH_MSG_DEBUG
(
"initialize "
<< name());
21
22
ATH_MSG_INFO
(
" m_di was: "
<< m_di <<
" setting to -1 "
);
23
m_di = -1;
24
25
// dump out contents of context specific data
26
dump
();
27
28
ATH_CHECK
(
m_wrh1
.initialize() );
29
30
// initialize base class
31
return
HiveAlgBase::initialize
();
32
33
}
34
35
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
36
37
StatusCode
HiveAlgB::finalize
() {
38
ATH_MSG_DEBUG
(
"finalize "
<< name());
39
40
// dump out contents of context specific data
41
dump
();
42
43
return
StatusCode::SUCCESS;
44
}
45
46
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
47
48
StatusCode
HiveAlgB::execute
(
const
EventContext& ctx)
const
{
49
50
ATH_MSG_DEBUG
(
"execute "
<< name());
51
52
ATH_MSG_INFO
(
"context: "
<< ctx <<
" for "
<<
this
);
53
54
int
s =
sleep
(ctx);
55
56
ATH_MSG_INFO
(
"m_di was: "
<< m_di <<
" setting to "
<< s);
57
m_di = s;
58
59
SG::WriteHandle<HiveDataObj>
wrh1{
m_wrh1
, ctx} ;
60
ATH_CHECK
(wrh1.
record
(std::make_unique< HiveDataObj >(20000)));
61
62
ATH_MSG_INFO
(
" write: "
<< wrh1.
key
() <<
" = "
<< wrh1->val() );
63
64
return
StatusCode::SUCCESS;
65
66
}
67
68
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
69
70
void
71
HiveAlgB::dump
() {
72
73
std::ostringstream ost;
74
75
// use a lambda to access all constituents of context specific data
76
m_di.for_all([&ost] (
size_t
s,
const
int
i)
77
{ ost <<
" s: "
<< s <<
" v: "
<< i << std::endl; } );
78
79
ATH_MSG_INFO
(
"dumping m_di: \n"
<< ost.str());
80
81
}
82
83
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:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
HiveAlgB.h
Simple Algorithm that writes a single HiveDataObj to the store.
HiveAlgB::m_wrh1
SG::WriteHandleKey< HiveDataObj > m_wrh1
Definition
HiveAlgB.h:42
HiveAlgB::HiveAlgB
HiveAlgB(const std::string &name, ISvcLocator *pSvcLocator)
Definition
HiveAlgB.cxx:10
HiveAlgB::~HiveAlgB
~HiveAlgB()
HiveAlgB::initialize
virtual StatusCode initialize() override
Definition
HiveAlgB.cxx:19
HiveAlgB::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
HiveAlgB.cxx:48
HiveAlgB::finalize
virtual StatusCode finalize() override
Definition
HiveAlgB.cxx:37
HiveAlgB::dump
void dump()
Definition
HiveAlgB.cxx:71
HiveAlgBase::HiveAlgBase
HiveAlgBase(const std::string &name, ISvcLocator *pSvcLocator)
Definition
HiveAlgBase.cxx:12
HiveAlgBase::sleep
unsigned int sleep(const EventContext &ctx) const
Definition
HiveAlgBase.cxx:40
HiveAlgBase::initialize
virtual StatusCode initialize() override
Definition
HiveAlgBase.cxx:23
SG::VarHandleBase::key
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Definition
AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:64
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Generated on
for ATLAS Offline Software by
1.17.0