ATLAS Offline Software
Loading...
Searching...
No Matches
CondAlgZ.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 "CondAlgZ.h"
8
9
11 ATH_MSG_DEBUG("initialize {}", name());
12
13 ATH_CHECK( m_rchk1.initialize() );
14 ATH_CHECK( m_rchk2.initialize() );
15 ATH_CHECK( m_rchk3.initialize() );
16
17 ATH_CHECK( m_wch.initialize() );
18
19 return StatusCode::SUCCESS;
20}
21
22StatusCode CondAlgZ::execute(const EventContext& ctx) const {
23 ATH_MSG_DEBUG("execute {}", name());
24 EventIDBase now(ctx.eventID());
25
29
30 const CondDataObj *cdo1 = *rch1;
31 const CondDataObjY *cdo2 = *rch2;
32 const CondDataObjY *cdo3 = *rch3;
33
34 ATH_MSG_DEBUG(" rh1: {} rh2: {} rh3: {}",
35 cdo1->val(), cdo2->val(), cdo3->val());
36
38
39 // do we have a valid m_wch for current time?
40 if ( wch.isValid(now) ) {
41 ATH_MSG_DEBUG("Found valid write handle for {}", wch.key());
42 return StatusCode::SUCCESS;
43 }
44
45 ATH_MSG_DEBUG(" CondHandle {} not valid.", wch.key() );
46
47 wch.addDependency(rch1);
48 wch.addDependency(rch2,rch3);
49
50 float val = rch1->val() + rch2->val() + rch3->val();
51
52 if (wch.record( std::make_unique<CondDataObjZ>
53 ( CondDataObjZ(val) ) ).isFailure()) {
54 ATH_MSG_ERROR("could not record CondDataObjZ {} val: {} with EventRange {}",
55 wch.key(), val, static_cast<std::string>(wch.getRange()));
56 return StatusCode::FAILURE;
57 }
58
59 ATH_MSG_INFO("recorded new CDO {} = {} with range {}",
60 wch.key(), val, static_cast<std::string>(wch.getRange()));
61
62 return StatusCode::SUCCESS;
63
64}
65
#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::ReadCondHandleKey< CondDataObjY > m_rchk2
Definition CondAlgZ.h:28
virtual StatusCode execute(const EventContext &ctx) const override
Definition CondAlgZ.cxx:22
SG::ReadCondHandleKey< CondDataObjY > m_rchk3
Definition CondAlgZ.h:29
virtual StatusCode initialize() override
Definition CondAlgZ.cxx:10
SG::ReadCondHandleKey< CondDataObj > m_rchk1
Definition CondAlgZ.h:27
SG::WriteCondHandleKey< CondDataObjZ > m_wch
Definition CondAlgZ.h:31
void val(float f)
void val(int i)
Definition CondDataObj.h:16
const std::string & key() const
void addDependency(const EventIDRange &range)
const EventIDRange & getRange() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED