The Gaudi Framework
master (9f3f8895)
Toggle main menu visibility
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
// ----------------------------------------------------------------------------
18
DECLARE_COMPONENT
(
ContextEventCounterPtr
)
19
DECLARE_COMPONENT
(
ContextEventCounterData
)
20
21
// ============================================================================
22
// Main execution
23
// ============================================================================
24
StatusCode
ContextEventCounterPtr
::
execute
() {
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() <<
" -> "
33
<< *
m_ctxtSpecCounter
<<
endmsg
;
34
35
return
StatusCode::SUCCESS
;
36
}
37
38
// ============================================================================
39
// Finalize
40
// ============================================================================
41
StatusCode
ContextEventCounterPtr::finalize
() {
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
// ============================================================================
65
StatusCode
ContextEventCounterData::execute
() {
66
if
(
msgLevel
(
MSG::DEBUG
) )
debug
() <<
"==> Execute"
<<
endmsg
;
67
68
++
m_ctxtSpecCounter
;
69
debug
() <<
"Context "
<<
Gaudi::Hive::currentContextId
() <<
" "
<<
m_ctxtSpecCounter
<<
endmsg
;
70
71
return
StatusCode::SUCCESS
;
72
}
73
74
// ============================================================================
75
// Finalize
76
// ============================================================================
77
StatusCode
ContextEventCounterData::finalize
() {
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
// ============================================================================
ContextEventCounter.h
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition
MsgStream.h:198
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition
PluginServiceV1.h:45
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition
CommonMessaging.h:118
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition
CommonMessaging.h:115
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition
CommonMessaging.h:127
ContextEventCounterData
Definition
ContextEventCounter.h:32
ContextEventCounterData::m_ctxtSpecCounter
Gaudi::Hive::ContextSpecificData< int > m_ctxtSpecCounter
Definition
ContextEventCounter.h:38
ContextEventCounterData::finalize
StatusCode finalize() override
Algorithm finalization.
Definition
ContextEventCounter.cpp:77
ContextEventCounterData::execute
StatusCode execute() override
Standard constructor.
Definition
ContextEventCounter.cpp:65
ContextEventCounterPtr
Definition
ContextEventCounter.h:23
ContextEventCounterPtr::finalize
StatusCode finalize() override
Algorithm finalization.
Definition
ContextEventCounter.cpp:41
ContextEventCounterPtr::execute
StatusCode execute() override
Standard constructor.
Definition
ContextEventCounter.cpp:24
ContextEventCounterPtr::m_ctxtSpecCounter
Gaudi::Hive::ContextSpecificPtr< int > m_ctxtSpecCounter
Definition
ContextEventCounter.h:29
Gaudi::Algorithm::finalize
StatusCode finalize() override
the default (empty) implementation of IStateful::finalize() method
Definition
Algorithm.h:181
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition
StatusCode.h:99
Gaudi::Hive::currentContextId
GAUDI_API ContextIdType currentContextId()
Return the current context id.
Definition
ThreadLocalContext.cpp:28
MSG::DEBUG
@ DEBUG
Definition
IMessageSvc.h:22
GaudiHive
src
ContextEventCounter.cpp
Generated on
for The Gaudi Framework by
1.17.0