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-2025 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: "
<< evt->runNumber()
41
<<
" e: "
<< evt->eventNumber() );
42
43
44
EventIDBase now(ctx.eventID());
45
if
(evt->eventNumber() == 10) {
46
std::this_thread::sleep_for(std::chrono::milliseconds( 500 ));
47
}
48
49
SG::WriteCondHandle<CondDataObj>
wch(
m_wchk
,ctx);
50
// do we have a valid m_wch for current time?
51
if
( wch.
isValid
(now) ) {
52
ATH_MSG_DEBUG
(
"CondHandle is already valid for "
<< now
53
<<
". In theory this should not be called, but may happen"
54
<<
" if multiple concurrent events are being processed out of order."
);
55
return
StatusCode::SUCCESS;
56
57
}
58
59
ATH_MSG_DEBUG
(
" CondHandle "
<< wch.
key
()
60
<<
" not valid. Getting new info for dbKey \""
61
<< wch.
dbKey
() <<
"\" from CondDb"
);
62
63
EventIDRange
r
;
64
IASCIICondDbSvc::dbData_t
val;
65
if
(
m_cds
->getRange(wch.
dbKey
(), ctx,
r
, val).isFailure()) {
66
ATH_MSG_ERROR
(
" could not find dbKey \""
<< wch.
dbKey
()
67
<<
"\" in CondSvc registry"
);
68
return
StatusCode::FAILURE;
69
}
70
71
CondDataObj
* cdo =
new
CondDataObj
( val );
72
if
(wch.
record
(
r
, cdo).isFailure()) {
73
ATH_MSG_ERROR
(
"could not record CondDataObj "
<< wch.
key
()
74
<<
" = "
<< *cdo
75
<<
" with EventRange "
<<
r
);
76
return
StatusCode::FAILURE;
77
}
78
79
ATH_MSG_INFO
(
"recorded new CDO "
<< wch.
key
() <<
" = "
<< *cdo
80
<<
" with range "
<<
r
);
81
82
return
StatusCode::SUCCESS;
83
}
84
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
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:67
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