ATLAS Offline Software
Loading...
Searching...
No Matches
CondAlgY.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 "CondAlgY.h"
8
9
11 ATH_MSG_DEBUG("initialize {}", name());
12
13 ATH_CHECK( m_cds.retrieve() );
14
15 m_wch1.setDbKey(m_dbk1);
16 m_wch2.setDbKey(m_dbk2);
17
18 ATH_CHECK( m_wch1.initialize() );
19 ATH_CHECK( m_wch2.initialize() );
20
21 return StatusCode::SUCCESS;
22}
23
24StatusCode CondAlgY::execute(const EventContext& ctx) const {
25 ATH_MSG_DEBUG("execute {}", name());
26 EventIDBase now(ctx.eventID());
27
30
31 // do we have a valid m_wch for current time?
32 if ( wch1.isValid(now) ) {
33 ATH_MSG_DEBUG(" Found a valid write handle for {}", wch1.key());
34 }
35 else {
36
37 ATH_MSG_DEBUG(" CondHandle {} not valid. Getting new info for dbKey \"{}\" from CondDb",
38 wch1.key(), wch1.dbKey());
39
40 EventIDRange r;
42 if (m_cds->getRange(wch1.dbKey(), ctx, r, val).isFailure()) {
43 ATH_MSG_ERROR(" could not find dbKey \"{}\" in CondSvc registry",
44 wch1.dbKey());
45 return StatusCode::FAILURE;
46 }
47
48 CondDataObjY* cdo = new CondDataObjY( val );
49 if (wch1.record(r, cdo).isFailure()) {
50 ATH_MSG_ERROR("could not record CondDataObjY {} = {} with EventRange {}",
51 wch1.key(), *cdo, static_cast<std::string>(r));
52 return StatusCode::FAILURE;
53 }
54 ATH_MSG_INFO("recorded new CDO {} = {} with range {}",
55 wch1.key(), *cdo, static_cast<std::string>(r));
56 }
57
58 // do we have a valid wch for current time?
59 if ( wch2.isValid(now) ) {
60 ATH_MSG_DEBUG(" Found a valid write handle for {}", wch2.key());
61 }
62 else {
63
64 ATH_MSG_DEBUG(" CondHandle {} not valid. Getting new info for dbKey \"{}\" from CondDb",
65 wch2.key(), wch2.dbKey());
66
67 EventIDRange r;
69 if (m_cds->getRange(wch2.dbKey(), ctx, r, val).isFailure()) {
70 ATH_MSG_ERROR(" could not find dbKey \"{}\" in CondSvc registry",
71 wch2.dbKey());
72 return StatusCode::FAILURE;
73 }
74
75 CondDataObjY* cdo = new CondDataObjY( val );
76 if (wch2.record(r, cdo).isFailure()) {
77 ATH_MSG_ERROR("could not record CondDataObjY {} = {} with EventRange {}",
78 wch2.key(), *cdo, static_cast<std::string>(r));
79 return StatusCode::FAILURE;
80 }
81 ATH_MSG_INFO("recorded new CDO {} = {} with range {}",
82 wch2.key(), *cdo, static_cast<std::string>(r));
83 }
84
85 return StatusCode::SUCCESS;
86
87}
88
#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,...)
SG::WriteCondHandleKey< CondDataObjY > m_wch1
Definition CondAlgY.h:26
SG::WriteCondHandleKey< CondDataObjY > m_wch2
Definition CondAlgY.h:27
virtual StatusCode initialize() override
Definition CondAlgY.cxx:10
Gaudi::Property< std::string > m_dbk2
Definition CondAlgY.h:30
ServiceHandle< IASCIICondDbSvc > m_cds
Definition CondAlgY.h:32
Gaudi::Property< std::string > m_dbk1
Definition CondAlgY.h:29
virtual StatusCode execute(const EventContext &ctx) const override
Definition CondAlgY.cxx:24
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