The Gaudi Framework
v37r1 (a7f61348)
StatSvcAlg.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
// ============================================================================
12
// Include files
13
// ============================================================================
14
// STD & STL
15
// ============================================================================
16
#include <cmath>
17
// ============================================================================
18
// GaudiKernel
19
// ============================================================================
20
#include "
GaudiKernel/IStatSvc.h
"
21
#include "
GaudiKernel/Stat.h
"
22
// ============================================================================
23
// GaudiAlg
24
// ============================================================================
25
#include "
GaudiKernel/Algorithm.h
"
26
// ============================================================================
38
// ============================================================================
39
namespace
GaudiExamples
{
50
class
StatSvcAlg
:
public
Algorithm
{
51
public
:
53
using
Algorithm::Algorithm
;
54
56
StatusCode
initialize
()
override
{
57
StatusCode
sc =
Algorithm::initialize
();
58
if
( sc.
isFailure
() )
return
sc;
// RETURN
59
m_stat
=
service
(
"ChronoStatSvc"
,
true
);
60
return
StatusCode::SUCCESS
;
61
}
63
StatusCode
execute
()
override
;
64
65
private
:
66
// pointer to Stat Service
67
SmartIF<IStatSvc>
m_stat
;
68
};
69
}
// end of namespace GaudiExamples
70
// ============================================================================
71
// the main execution method
72
// ============================================================================
73
StatusCode
GaudiExamples::StatSvcAlg::execute
() {
74
Stat
st1(
m_stat
,
"counter1"
);
75
Stat
st2(
m_stat
,
"counter2"
);
76
Stat
st3(
m_stat
,
"counter3"
, 0.3 );
77
78
Stat
eff(
m_stat
,
"eff"
, 0 < sin( 10 * st1->
flag
() ) );
79
//
80
st1 += 0.1;
81
st1 -= 0.1000452;
82
st2 += st1;
83
++st3;
84
st2--;
85
86
eff += 0 < cos( 20 * st2->
flag
() );
87
88
//
89
return
StatusCode::SUCCESS
;
90
}
91
// ============================================================================
92
// Factory:
93
// ============================================================================
94
using
GaudiExamples::StatSvcAlg
;
95
DECLARE_COMPONENT
(
StatSvcAlg
)
96
// ============================================================================
97
// The END
98
// ============================================================================
Gaudi::Algorithm::initialize
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition:
Algorithm.h:178
GaudiExamples::StatSvcAlg::execute
StatusCode execute() override
the main execution method
Definition:
StatSvcAlg.cpp:73
Algorithm
Alias for backward compatibility.
Definition:
Algorithm.h:58
Algorithm.h
GaudiExamples
Definition:
__init__.py:1
StatEntity::flag
double flag() const
Definition:
StatEntity.h:96
GaudiExamples::StatSvcAlg::initialize
StatusCode initialize() override
initialize the algorithm
Definition:
StatSvcAlg.cpp:56
GaudiExamples::StatSvcAlg::m_stat
SmartIF< IStatSvc > m_stat
pointer to Stat Service
Definition:
StatSvcAlg.cpp:67
StatusCode
Definition:
StatusCode.h:65
SmartIF< IStatSvc >
IStatSvc.h
Stat.h
Stat
Definition:
Stat.h:56
StatusCode::isFailure
bool isFailure() const
Definition:
StatusCode.h:129
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition:
StatusCode.h:100
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition:
PluginServiceV1.h:46
Gaudi::Algorithm::service
StatusCode service(std::string_view name, T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
Definition:
Algorithm.h:205
GaudiExamples::StatSvcAlg
Definition:
StatSvcAlg.cpp:50
Gaudi::Algorithm::Algorithm
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition:
Algorithm.h:101
GaudiExamples
src
CounterEx
StatSvcAlg.cpp
Generated on Mon Oct 30 2023 11:39:51 for The Gaudi Framework by
1.8.18