The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
StatSvcAlg.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2024 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// ============================================================================
21#include <GaudiKernel/Stat.h>
22
24// ============================================================================
36// ============================================================================
37namespace GaudiTestSuite {
48 class StatSvcAlg : public Algorithm {
49 public:
52
56 if ( sc.isFailure() ) return sc; // RETURN
57 m_stat = service( "ChronoStatSvc", true );
59 }
60
61 StatusCode execute() override;
62
63 private:
64 // pointer to Stat Service
66 };
67} // end of namespace GaudiTestSuite
68// ============================================================================
69// the main execution method
70// ============================================================================
72 Stat st1( m_stat, "counter1" );
73 Stat st2( m_stat, "counter2" );
74 Stat st3( m_stat, "counter3", 0.3 );
75
76 Stat eff( m_stat, "eff", 0 < sin( 10 * st1->flag() ) );
77 //
78 st1 += 0.1;
79 st1 -= 0.1000452;
80 st2 += st1;
81 ++st3;
82 st2--;
83
84 eff += 0 < cos( 20 * st2->flag() );
85
86 //
88}
89// ============================================================================
90// Factory:
91// ============================================================================
94// ============================================================================
95// The END
96// ============================================================================
#define DECLARE_COMPONENT(type)
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition Algorithm.h:98
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition Algorithm.h:175
SmartIF< IService > service(std::string_view name, const bool createIf=true, const bool quiet=false) const
Return a pointer to the service identified by name (or "type/name")
Simple algorithm to illustrate the statistical abilities of "Stat"-part of Chrono&Stat Service.
StatusCode initialize() override
initialize the algorithm
StatusCode execute() override
the main execution method
SmartIF< IStatSvc > m_stat
pointer to Stat Service
Small smart pointer class with automatic reference counting for IInterface.
Definition SmartIF.h:28
double flag() const
Definition StatEntity.h:96
Small wrapper class for easy manipulation with generic counters and IStatSvc interface.
Definition Stat.h:48
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
bool isFailure() const
Definition StatusCode.h:129
constexpr static const auto SUCCESS
Definition StatusCode.h:99