ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDTools
EventLoop
Root
MetricsSvc.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include <
EventLoop/Job.h
>
6
#include <
EventLoop/StatusCode.h
>
7
#include <
EventLoop/Worker.h
>
8
#include <
EventLoop/MetricsSvc.h
>
9
#include <
RootCoreUtils/Assert.h
>
10
#include <TBenchmark.h>
11
#include <TFile.h>
12
#include <TTree.h>
13
#include <TTreeCache.h>
14
15
ClassImp
(
EL::MetricsSvc
)
16
17
18
namespace
EL
19
{
20
const
std::string
MetricsSvc::name
=
"Metrics"
;
21
}
22
23
void
EL::MetricsSvc :: testInvariant ()
const
24
{
25
RCU_INVARIANT
(
this
!= 0);
26
}
27
28
const
char
*EL::MetricsSvc :: GetName()
const
29
{
30
RCU_READ_INVARIANT
(
this
);
31
return
name
.c_str();
32
}
33
34
35
EL::MetricsSvc :: MetricsSvc ()
36
:
m_fileMetrics
(0),
m_jobMetrics
(0),
m_filesRead
(0)
37
,
m_eventsRead
(0),
m_benchmark
(0)
38
{
39
RCU_NEW_INVARIANT
(
this
);
40
}
41
42
43
44
EL::MetricsSvc :: ~MetricsSvc ()
45
{
46
RCU_DESTROY_INVARIANT
(
this
);
47
if
(
m_benchmark
) {
delete
m_benchmark
; }
48
}
49
50
51
52
EL::StatusCode
EL::MetricsSvc :: histInitialize ()
53
{
54
RCU_CHANGE_INVARIANT
(
this
);
55
m_benchmark
=
new
TBenchmark;
56
m_benchmark
->Start(
"loopmetrics"
);
57
wk
()->addOutput (
m_fileMetrics
=
new
TTree (
"EventLoop_Metrics/cacheStats"
,
58
"TTree cache stats per file"
));
59
wk
()->addOutput (
m_jobMetrics
=
new
TTree (
"EventLoop_Metrics/jobs"
,
60
"event throughput per job"
));
61
return
EL::StatusCode::SUCCESS;
62
}
63
64
65
66
EL::StatusCode
EL::MetricsSvc :: fileExecute ()
67
{
68
RCU_CHANGE_INVARIANT
(
this
);
69
m_filesRead
++;
70
return
EL::StatusCode::SUCCESS;
71
}
72
73
74
75
EL::StatusCode
EL::MetricsSvc :: endOfFile ()
76
{
77
RCU_CHANGE_INVARIANT
(
this
);
78
RCU_ASSERT
(
m_fileMetrics
);
79
RCU_ASSERT
(
wk
()->inputFile());
80
RCU_ASSERT
(
wk
()->
tree
());
81
TTreeCache *
tc
= (TTreeCache*)
wk
()->inputFile()->GetCacheRead(
wk
()->
tree
());
82
if
(
tc
) {
83
Int_t nBranches =
tc
->GetCachedBranches()->GetEntries();
84
m_fileMetrics
->Branch (
"nBranches"
, &nBranches,
"nBranches/I"
);
85
Int_t nLearn =
tc
->GetLearnEntries();
86
m_fileMetrics
->Branch (
"learnEntries"
, &nLearn,
"learnEntries/I"
);
87
Double_t eff =
tc
->GetEfficiency ();
88
m_fileMetrics
->Branch (
"cacheEfficiency"
, &eff,
"cacheEfficiency/D"
);
89
Double_t effRel =
tc
->GetEfficiencyRel ();
90
m_fileMetrics
->Branch (
"cacheEfficiencyRel"
, &effRel,
"cacheEfficiencyRel/D"
);
91
Long64_t bytesRead =
tc
->GetBytesRead ();
92
m_fileMetrics
->Branch (
"bytesRead"
, &bytesRead,
"bytesRead/L"
);
93
Int_t readCalls =
tc
->GetReadCalls ();
94
m_fileMetrics
->Branch (
"readCalls"
, &readCalls,
"readCalls/I"
);
95
Long64_t ncBytesRead =
tc
->GetNoCacheBytesRead ();
96
m_fileMetrics
->Branch (
"noCacheBytesRead"
, &ncBytesRead,
"noCacheBytesRead/L"
);
97
Int_t ncReadCalls =
tc
->GetNoCacheReadCalls ();
98
m_fileMetrics
->Branch (
"noCacheReadCalls"
, &ncReadCalls,
"noCacheReadCalls/I"
);
99
Int_t readahead = TFile::GetReadaheadSize ();
100
m_fileMetrics
->Branch (
"readaheadSize"
, &readahead,
"readaheadSize/I"
);
101
Long64_t bytesReadExtra =
tc
->GetBytesReadExtra ();
102
m_fileMetrics
->Branch (
"bytesReadExtra"
, &bytesReadExtra,
"bytesReadExtra/L"
);
103
m_fileMetrics
->Fill ();
104
}
105
return
EL::StatusCode::SUCCESS;
106
}
107
108
109
110
EL::StatusCode
EL::MetricsSvc :: execute ()
111
{
112
RCU_CHANGE_INVARIANT
(
this
);
113
m_eventsRead
++;
114
return
EL::StatusCode::SUCCESS;
115
}
116
117
118
119
EL::StatusCode
EL::MetricsSvc :: histFinalize ()
120
{
121
RCU_CHANGE_INVARIANT
(
this
);
122
m_benchmark
->Stop(
"loopmetrics"
);
123
m_jobMetrics
->Branch(
"eventsRead"
, &
m_eventsRead
,
"eventsRead/I"
);
124
m_jobMetrics
->Branch(
"filesRead"
, &
m_filesRead
,
"filesRead/I"
);
125
Float_t realTime =
m_benchmark
->GetRealTime(
"loopmetrics"
);
126
m_jobMetrics
->Branch(
"loopWallTime"
, &realTime,
"loopWallTime/F"
);
127
Float_t cpuTime =
m_benchmark
->GetCpuTime(
"loopmetrics"
);
128
m_jobMetrics
->Branch(
"loopCpuTime"
, &cpuTime,
"loopCpuTime/F"
);
129
Float_t evtsWallSec =
m_eventsRead
/ (realTime != 0 ? realTime : 1.);
130
m_jobMetrics
->Branch(
"eventsPerWallSec"
, &evtsWallSec,
"eventsPerWallSec/F"
);
131
Float_t evtsCpuSec =
m_eventsRead
/ (cpuTime != 0 ? cpuTime : 1.);
132
m_jobMetrics
->Branch(
"eventsPerCpuSec"
, &evtsCpuSec,
"eventsPerCpuSec/F"
);
133
m_jobMetrics
->Fill();
134
return
EL::StatusCode::SUCCESS;
135
}
Assert.h
RCU_INVARIANT
#define RCU_INVARIANT(x)
Definition
Assert.h:196
RCU_ASSERT
#define RCU_ASSERT(x)
Definition
Assert.h:217
RCU_DESTROY_INVARIANT
#define RCU_DESTROY_INVARIANT(x)
Definition
Assert.h:230
RCU_CHANGE_INVARIANT
#define RCU_CHANGE_INVARIANT(x)
Definition
Assert.h:226
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition
Assert.h:228
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition
Assert.h:224
Job.h
tc
static Double_t tc
Definition
LArPhysWaveHECTool.cxx:38
ClassImp
ClassImp(EL::MetricsSvc) namespace EL
Definition
MetricsSvc.cxx:15
MetricsSvc.h
StatusCode.h
Worker.h
EL::Algorithm::wk
IWorker * wk() const
description: the worker that is controlling us guarantee: no-fail
EL::MetricsSvc
Definition
MetricsSvc.h:19
EL::MetricsSvc::m_filesRead
Int_t m_filesRead
description: the number of files processed
Definition
MetricsSvc.h:108
EL::MetricsSvc::m_eventsRead
Int_t m_eventsRead
description: the number of events processed
Definition
MetricsSvc.h:112
EL::MetricsSvc::m_fileMetrics
TTree * m_fileMetrics
description: the file cache metrics
Definition
MetricsSvc.h:100
EL::MetricsSvc::m_jobMetrics
TTree * m_jobMetrics
description: the job metrics
Definition
MetricsSvc.h:104
EL::MetricsSvc::m_benchmark
TBenchmark * m_benchmark
description: the benchmark object used rationale: this is a pointer to avoid including the header in ...
Definition
MetricsSvc.h:117
EL::MetricsSvc::name
static const std::string name
description: the name of the service
Definition
MetricsSvc.h:26
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition
AsgComponentFactories.h:16
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
tree
TChain * tree
Definition
tile_monitor.h:30
Generated on
for ATLAS Offline Software by
1.17.0