Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v36r16 (ea80daf8)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 // ============================================================================
26 // ============================================================================
38 // ============================================================================
39 namespace GaudiExamples {
50  class StatSvcAlg : public GaudiAlgorithm {
51  public:
54 
56  StatusCode initialize() override {
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
68  };
69 } // end of namespace GaudiExamples
70 // ============================================================================
71 // the main execution method
72 // ============================================================================
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 // ============================================================================
96 // ============================================================================
97 // The END
98 // ============================================================================
GaudiAlgorithm::GaudiAlgorithm
GaudiAlgorithm(std::string name, ISvcLocator *pSvcLocator)
Standard constructor.
Definition: GaudiAlgorithm.cpp:45
GaudiExamples::StatSvcAlg::execute
StatusCode execute() override
the main execution method
Definition: StatSvcAlg.cpp:73
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
GaudiAlgorithm
Definition: GaudiAlgorithm.h:104
GaudiAlgorithm::initialize
StatusCode initialize() override
standard initialization method
Definition: GaudiAlgorithm.cpp:52
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
GaudiAlgorithm.h
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