ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaExamples
AthExHive
src
condEx
CondAlgX.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 "
CondAlgX.h
"
6
#include "
AthExHive/IASCIICondDbSvc.h
"
7
8
#include "
StoreGate/WriteCondHandle.h
"
9
10
#include "GaudiKernel/ServiceHandle.h"
11
12
#include "GaudiKernel/EventIDBase.h"
13
#include "GaudiKernel/EventIDRange.h"
14
15
#include <chrono>
16
17
18
StatusCode
CondAlgX::initialize
() {
19
ATH_MSG_DEBUG
(
"initialize {}"
, name());
20
21
ATH_CHECK
(
m_evt
.initialize() );
22
23
ATH_CHECK
(
m_cds
.retrieve() );
24
25
m_wchk
.setDbKey(
m_dbKey
);
26
ATH_CHECK
(
m_wchk
.initialize() );
27
28
return
StatusCode::SUCCESS;
29
}
30
31
StatusCode
CondAlgX::execute
(
const
EventContext& ctx)
const
{
32
ATH_MSG_DEBUG
(
"execute {}"
, name());
33
34
SG::ReadHandle<xAOD::EventInfo>
evt(
m_evt
, ctx );
35
if
(!evt.isValid()) {
36
ATH_MSG_ERROR
(
"Could not retrieve EventInfo"
);
37
return
StatusCode::FAILURE;
38
}
39
40
ATH_MSG_DEBUG
(
" EventInfo: r: {} e: {}"
,
41
evt->runNumber(), evt->eventNumber() );
42
43
EventIDBase now(ctx.eventID());
44
if
(evt->eventNumber() == 10) {
45
std::this_thread::sleep_for(std::chrono::milliseconds( 500 ));
46
}
47
48
SG::WriteCondHandle<CondDataObj>
wch(
m_wchk
,ctx);
49
// do we have a valid m_wch for current time?
50
if
( wch.
isValid
(now) ) {
51
ATH_MSG_DEBUG
(
"CondHandle is already valid for "
<< now
52
<<
". In theory this should not be called, but may happen"
53
<<
" if multiple concurrent events are being processed out of order."
);
54
return
StatusCode::SUCCESS;
55
56
}
57
58
ATH_MSG_DEBUG
(
" CondHandle {} not valid. Getting new info for dbKey \"{}\" from CondDb"
,
59
wch.
key
(), wch.
dbKey
());
60
61
EventIDRange
r
;
62
IASCIICondDbSvc::dbData_t
val;
63
if
(
m_cds
->getRange(wch.
dbKey
(), ctx,
r
, val).isFailure()) {
64
ATH_MSG_ERROR
(
" could not find dbKey \"{}\" in CondSvc registry"
,
65
wch.
dbKey
() );
66
return
StatusCode::FAILURE;
67
}
68
69
CondDataObj
* cdo =
new
CondDataObj
( val );
70
if
(wch.
record
(
r
, cdo).isFailure()) {
71
ATH_MSG_ERROR
(
"could not record CondDataObj {} = {} with EventRange {}"
,
72
wch.
key
(), *cdo,
static_cast<
std::string
>
(
r
));
73
return
StatusCode::FAILURE;
74
}
75
76
ATH_MSG_INFO
(
"recorded new CDO {} = {} with range {}"
,
77
wch.
key
(), *cdo,
static_cast<
std::string
>
(
r
));
78
79
return
StatusCode::SUCCESS;
80
}
81
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
CondAlgX.h
IASCIICondDbSvc.h
WriteCondHandle.h
CondAlgX::m_cds
ServiceHandle< IASCIICondDbSvc > m_cds
Definition
CondAlgX.h:34
CondAlgX::m_dbKey
Gaudi::Property< std::string > m_dbKey
Definition
CondAlgX.h:32
CondAlgX::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
CondAlgX.cxx:31
CondAlgX::m_wchk
SG::WriteCondHandleKey< CondDataObj > m_wchk
Definition
CondAlgX.h:30
CondAlgX::initialize
virtual StatusCode initialize() override
Definition
CondAlgX.cxx:18
CondAlgX::m_evt
SG::ReadHandleKey< xAOD::EventInfo > m_evt
Definition
CondAlgX.h:28
CondDataObj
Definition
CondDataObj.h:8
IASCIICondDbSvc::dbData_t
float dbData_t
Definition
IASCIICondDbSvc.h:19
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:66
SG::WriteCondHandle
Definition
WriteCondHandle.h:26
SG::WriteCondHandle::key
const std::string & key() const
Definition
WriteCondHandle.h:44
SG::WriteCondHandle::dbKey
const std::string & dbKey() const
Definition
WriteCondHandle.h:91
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition
WriteCondHandle.h:161
SG::WriteCondHandle::isValid
bool isValid() const
Definition
WriteCondHandle.h:252
r
int r
Definition
globals.cxx:22
Generated on
for ATLAS Offline Software by
1.17.0