ATLAS Offline Software
Loading...
Searching...
No Matches
CondAlgZ.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 "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: " << cdo1->val() << " rh2: " << cdo2->val()
35 << " rh3: " << 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 " << wch.key()
46 << " not valid.");
47
48 wch.addDependency(rch1);
49 wch.addDependency(rch2,rch3);
50
51 float val = rch1->val() + rch2->val() + rch3->val();
52
53 if (wch.record( std::make_unique<CondDataObjZ>
54 ( CondDataObjZ(val) ) ).isFailure()) {
55 ATH_MSG_ERROR("could not record CondDataObjZ " << wch.key()
56 << " val: " << val
57 << " with EventRange " << wch.getRange() );
58 return StatusCode::FAILURE;
59 }
60
61 ATH_MSG_INFO("recorded new CDO " << wch.key() << " = " << val
62 << " with range " << wch.getRange() );
63
64 return StatusCode::SUCCESS;
65
66}
67
#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::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