The Gaudi Framework  v38r0 (2143aa4c)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
User.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #include <Gaudi/Algorithm.h>
13 
17  class UserAlg : public ConditionAccessorHolder<Algorithm> {
20 
22  ConditionAccessor<int> m_cond{ this, "MyCondition", "condition/key" };
23 
24  StatusCode initialize() override {
25  auto status = base_class::initialize();
26  if ( !status ) return status;
27 
28  info() << "initialize" << endmsg;
29 
30  return status;
31  }
32 
33  StatusCode execute( const EventContext& ctx ) const override {
34  // get the condition slot for the current event
35  const auto& condCtx = getConditionContext( ctx );
36  // get the condition value from the current condition slot.
37  const auto& cond = m_cond.get( condCtx );
38 
39  info() << "got condition value " << cond << endmsg;
40 
41  return StatusCode::SUCCESS;
42  }
43 
44  StatusCode finalize() override {
45  info() << "finalize" << endmsg;
46 
47  return base_class::finalize();
48  }
49  };
50  DECLARE_COMPONENT( UserAlg )
51 } // namespace Gaudi::Examples::Conditions
GaudiPython.Pythonizations.ctx
ctx
Definition: Pythonizations.py:578
StatusCode
Definition: StatusCode.h:65
Gaudi::Examples::Conditions::ConditionAccessorHolder< Algorithm >::initialize
StatusCode initialize() override
Definition: ConditionAccessorHolder.h:127
Gaudi::Examples::Conditions
Definition: ConditionAccessorHolder.h:21
Algorithm.h
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
Gaudi::Examples::Conditions::UserAlg::initialize
StatusCode initialize() override
Definition: User.cpp:24
Gaudi::Examples::Conditions::UserAlg::m_cond
ConditionAccessor< int > m_cond
Data member to access condition values for the current event.
Definition: User.cpp:22
Gaudi::Examples::Conditions::ConditionAccessorHolder< Algorithm >::base_class
ConditionAccessorHolder< Algorithm > base_class
Helper to expose this class to specializations without having to spell the whole name (see Gaudi::Exa...
Definition: ConditionAccessorHolder.h:84
Gaudi::Algorithm::finalize
StatusCode finalize() override
the default (empty) implementation of IStateful::finalize() method
Definition: Algorithm.h:184
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
Gaudi::Examples::Conditions::UserAlg
Example of a simple algorithm using conditions via the ConditionAccessorHolder pattern.
Definition: User.cpp:17
Gaudi::Examples::Conditions::UserAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition: User.cpp:33
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
ConditionAccessorHolder.h
EventContext
Definition: EventContext.h:34
Gaudi::Examples::Conditions::ConditionAccessorHolder
Example of a ConditionAccessorHolder implementation.
Definition: ConditionAccessorHolder.h:77
Gaudi::Examples::Conditions::ConditionAccessorHolder< Algorithm >::getConditionContext
const ConditionContext & getConditionContext(const EventContext &ctx) const
Helper to map the event being processed to the corresponding conditions slot.
Definition: ConditionAccessorHolder.h:141
Gaudi::Examples::Conditions::UserAlg::finalize
StatusCode finalize() override
Definition: User.cpp:44