ATLAS Offline Software
Loading...
Searching...
No Matches
CondAlgY.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 "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 " << wch1.key()
38 << " not valid. Getting new info for dbKey \""
39 << wch1.dbKey() << "\" from CondDb");
40
41 EventIDRange r;
43 if (m_cds->getRange(wch1.dbKey(), ctx, r, val).isFailure()) {
44 ATH_MSG_ERROR(" could not find dbKey \"" << wch1.dbKey()
45 << "\" in CondSvc registry");
46 return StatusCode::FAILURE;
47 }
48
49 CondDataObjY* cdo = new CondDataObjY( val );
50 if (wch1.record(r, cdo).isFailure()) {
51 ATH_MSG_ERROR("could not record CondDataObjY " << wch1.key()
52 << " = " << *cdo
53 << " with EventRange " << r);
54 return StatusCode::FAILURE;
55 }
56 ATH_MSG_INFO("recorded new CDO " << wch1.key() << " = " << *cdo
57 << " with range " << r);
58 }
59
60 // do we have a valid wch for current time?
61 if ( wch2.isValid(now) ) {
62 ATH_MSG_DEBUG(" Found a valid write handle for " << wch2.key());
63 }
64 else {
65
66 ATH_MSG_DEBUG(" CondHandle " << wch2.key()
67 << " not valid. Getting new info for dbKey \""
68 << wch2.dbKey() << "\" from CondDb");
69
70 EventIDRange r;
72 if (m_cds->getRange(wch2.dbKey(), ctx, r, val).isFailure()) {
73 ATH_MSG_ERROR(" could not find dbKey \"" << wch2.dbKey()
74 << "\" in CondSvc registry");
75 return StatusCode::FAILURE;
76 }
77
78 CondDataObjY* cdo = new CondDataObjY( val );
79 if (wch2.record(r, cdo).isFailure()) {
80 ATH_MSG_ERROR("could not record CondDataObjY " << wch2.key()
81 << " = " << *cdo
82 << " with EventRange " << r);
83 return StatusCode::FAILURE;
84 }
85 ATH_MSG_INFO("recorded new CDO " << wch2.key() << " = " << *cdo
86 << " with range " << r);
87 }
88
89 return StatusCode::SUCCESS;
90
91}
92
#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)
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