The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
ContextEventCounter.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 "ContextEventCounter.h"
12
13// ----------------------------------------------------------------------------
14// Implementation file for class: ContextEventCounterPtr
15//
16// 27/10/2013: Marco Clemencic
17// ----------------------------------------------------------------------------
20
21// ============================================================================
22// Main execution
23// ============================================================================
25 if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Execute" << endmsg;
26
27 if ( !m_ctxtSpecCounter ) {
28 m_ctxtSpecCounter = new int( 1 );
29 } else {
30 ++( *m_ctxtSpecCounter );
31 }
32 debug() << "Context " << Gaudi::Hive::currentContextId() << " " << m_ctxtSpecCounter.get() << " -> "
34
36}
37
38// ============================================================================
39// Finalize
40// ============================================================================
42 if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Finalize" << endmsg;
43
44 debug() << "Partial counts:" << endmsg;
45
46 info() << "Total count of events: "
47 << m_ctxtSpecCounter.accumulate(
48 [this]( const int* p ) {
49 const int r = ( p ? *p : 0 );
50 // print partial counts
51 this->debug() << " " << p << " -> " << r << endmsg;
52 return r;
53 },
54 0 )
55 << endmsg;
56
57 m_ctxtSpecCounter.deleteAll();
58
59 return Algorithm::finalize(); // must be called after all other actions
60}
61
62// ============================================================================
63// Main execution
64// ============================================================================
66 if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Execute" << endmsg;
67
69 debug() << "Context " << Gaudi::Hive::currentContextId() << " " << m_ctxtSpecCounter << endmsg;
70
72}
73
74// ============================================================================
75// Finalize
76// ============================================================================
78 if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Finalize" << endmsg;
79
80 if ( msgLevel( MSG::DEBUG ) ) {
81 debug() << "Partial counts:" << endmsg;
82 m_ctxtSpecCounter.for_each( [this]( const int i ) { this->debug() << " " << i << endmsg; } );
83 }
84
85 info() << "Total count of events: " << m_ctxtSpecCounter.accumulate( 0 ) << endmsg;
86
87 return Algorithm::finalize(); // must be called after all other actions
88}
89
90// ============================================================================
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
#define DECLARE_COMPONENT(type)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Gaudi::Hive::ContextSpecificData< int > m_ctxtSpecCounter
StatusCode finalize() override
Algorithm finalization.
StatusCode execute() override
Standard constructor.
StatusCode finalize() override
Algorithm finalization.
StatusCode execute() override
Standard constructor.
Gaudi::Hive::ContextSpecificPtr< int > m_ctxtSpecCounter
StatusCode finalize() override
the default (empty) implementation of IStateful::finalize() method
Definition Algorithm.h:181
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
constexpr static const auto SUCCESS
Definition StatusCode.h:99
GAUDI_API ContextIdType currentContextId()
Return the current context id.
@ DEBUG
Definition IMessageSvc.h:22