ATLAS Offline Software
Trigger
TrigEvent
TrigMonitoringEvent
src
TrigMonTimer.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// C/C++
6
#include <cassert>
7
#include <iostream>
8
#include <sstream>
9
10
#include "
AthenaKernel/errorcheck.h
"
11
#include "
TrigMonitoringEvent/TrigMonTimer.h
"
12
13
namespace
TimerBits
14
{
15
const
uint32_t
maskSec
= 0xfff00000;
16
const
uint32_t
maskUSec
= 0x000fffff;
17
18
const
uint32_t
shiftSec
= 20;
19
const
uint32_t
shiftUSec
= 0;
20
21
const
uint32_t
moduloSec
= 3600;
22
}
23
24
//--------------------------------------------------------------------------------------
25
TrigMonTimer::TrigMonTimer
()
26
:m_encoded(0x0)
27
{
28
}
29
30
//--------------------------------------------------------------------------------------
31
TrigMonTimer::TrigMonTimer
(
long
int
tv_sec,
32
long
int
tv_usec)
33
:m_encoded(0x0)
34
{
35
if
(!(tv_sec < 0.0) && !(tv_usec < 0.0)) {
36
const
uint32_t
sec =
static_cast<
uint32_t
>
(tv_sec %
TimerBits::moduloSec
);
37
const
uint32_t
usec =
static_cast<
uint32_t
>
(tv_usec);
38
39
// Yes, these are redundant checks.
40
if
(sec >=
TimerBits::moduloSec
) {
41
REPORT_MESSAGE_WITH_CONTEXT
(MSG::ERROR,
"TrigMonTimer"
)
42
<<
"ctor error! sec="
<< sec <<
", "
<< tv_sec;
43
}
44
if
(usec >= 1000000) {
45
REPORT_MESSAGE_WITH_CONTEXT
(MSG::ERROR,
"TrigMonTimer"
)
46
<<
"ctor error! usec="
<< usec <<
", "
<< tv_usec;
47
}
48
49
m_encoded
|= (sec <<
TimerBits::shiftSec
);
50
m_encoded
|= usec;
51
}
52
}
53
54
//--------------------------------------------------------------------------------------
55
TrigMonTimer::TrigMonTimer
(
uint32_t
encoded)
56
:m_encoded(encoded)
57
{
58
}
59
60
//--------------------------------------------------------------------------------------
61
uint32_t
TrigMonTimer::getSec
()
const
62
{
63
// return value in seconds
64
return
static_cast<
uint32_t
>
((
m_encoded
&
TimerBits::maskSec
) >>
TimerBits::shiftSec
);
65
}
66
67
//--------------------------------------------------------------------------------------
68
uint32_t
TrigMonTimer::getMicroSec
()
const
69
{
70
// return value in seconds
71
return
static_cast<
uint32_t
>
((
m_encoded
&
TimerBits::maskUSec
) >>
TimerBits::shiftUSec
);
72
}
73
74
//--------------------------------------------------------------------------------------
75
double
TrigMonTimer::getElapsed
(
const
TrigMonTimer
&start_time)
const
76
{
77
// return elapsed time - assume time period is less than moduloSec seconds
78
79
// get time difference in seconds
80
int
secs =
getSec
() - start_time.
getSec
();
81
if
(
getSec
() < start_time.
getSec
()) secs =
TimerBits::moduloSec
+
getSec
()-start_time.
getSec
();
82
83
// get time difference in microseconds
84
int
usecs =
getMicroSec
() - start_time.
getMicroSec
();
85
86
return
static_cast<
double
>
(secs)*1000.0 +
static_cast<
double
>
(usecs)/1000.0;
87
}
xAOD::uint32_t
setEventNumber uint32_t
Definition:
EventInfo_v1.cxx:127
TimerBits::maskUSec
const uint32_t maskUSec
Definition:
TrigMonTimer.cxx:16
TrigMonTimer
Definition:
TrigMonTimer.h:27
TimerBits::shiftSec
const uint32_t shiftSec
Definition:
TrigMonTimer.cxx:18
TrigMonTimer::getSec
uint32_t getSec() const
Definition:
TrigMonTimer.cxx:61
TrigMonTimer::getElapsed
double getElapsed(const TrigMonTimer &start) const
Definition:
TrigMonTimer.cxx:75
TrigMonTimer::m_encoded
uint32_t m_encoded
Definition:
TrigMonTimer.h:45
TrigMonTimer::getMicroSec
uint32_t getMicroSec() const
Definition:
TrigMonTimer.cxx:68
TimerBits::maskSec
const uint32_t maskSec
Definition:
TrigMonTimer.cxx:15
REPORT_MESSAGE_WITH_CONTEXT
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
Definition:
Control/AthenaKernel/AthenaKernel/errorcheck.h:345
errorcheck.h
Helpers for checking error return status codes and reporting errors.
TrigMonTimer.h
TimerBits::moduloSec
const uint32_t moduloSec
Definition:
TrigMonTimer.cxx:21
TimerBits::shiftUSec
const uint32_t shiftUSec
Definition:
TrigMonTimer.cxx:19
TimerBits
Definition:
TrigMonTimer.cxx:14
TrigMonTimer::TrigMonTimer
TrigMonTimer()
Definition:
TrigMonTimer.cxx:25
Generated on Thu Nov 7 2024 21:29:58 for ATLAS Offline Software by
1.8.18