ATLAS Offline Software
Loading...
Searching...
No Matches
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"
7
9
10#include "GaudiKernel/ServiceHandle.h"
11
12#include "GaudiKernel/EventIDBase.h"
13#include "GaudiKernel/EventIDRange.h"
14
15#include <chrono>
16
17
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
31StatusCode CondAlgX::execute(const EventContext& ctx) const {
32 ATH_MSG_DEBUG("execute {}", name());
33
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
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;
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_INFO(x,...)
ServiceHandle< IASCIICondDbSvc > m_cds
Definition CondAlgX.h:34
Gaudi::Property< std::string > m_dbKey
Definition CondAlgX.h:32
virtual StatusCode execute(const EventContext &ctx) const override
Definition CondAlgX.cxx:31
SG::WriteCondHandleKey< CondDataObj > m_wchk
Definition CondAlgX.h:30
virtual StatusCode initialize() override
Definition CondAlgX.cxx:18
SG::ReadHandleKey< xAOD::EventInfo > m_evt
Definition CondAlgX.h:28
const std::string & key() const
const std::string & dbKey() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
int r
Definition globals.cxx:22