ATLAS Offline Software
Loading...
Searching...
No Matches
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"
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: " << 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
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;
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(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