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
26
const
char
*EL::MetricsSvc :: GetName()
const
27
{
28
RCU_READ_INVARIANT
(
this
);
29
return
name
.c_str();
30
}
31
32
33
EL::MetricsSvc :: MetricsSvc ()
34
:
m_fileMetrics
(0),
m_jobMetrics
(0),
m_filesRead
(0)
35
,
m_eventsRead
(0),
m_benchmark
(0)
36
{
37
RCU_NEW_INVARIANT
(
this
);
38
}
39
40
41
42
EL::MetricsSvc :: ~MetricsSvc ()
43
{
44
RCU_DESTROY_INVARIANT
(
this
);
45
if
(
m_benchmark
) {
delete
m_benchmark
; }
46
}
47
48
49
50
EL::StatusCode
EL::MetricsSvc :: histInitialize ()
51
{
52
RCU_CHANGE_INVARIANT
(
this
);
53
m_benchmark
=
new
TBenchmark;
54
m_benchmark
->Start(
"loopmetrics"
);
55
wk
()->addOutput (
m_fileMetrics
=
new
TTree (
"EventLoop_Metrics/cacheStats"
,
56
"TTree cache stats per file"
));
57
wk
()->addOutput (
m_jobMetrics
=
new
TTree (
"EventLoop_Metrics/jobs"
,
58
"event throughput per job"
));
59
60
// Create the per-file branches once, pointing at the member buffers, so
61
// that the branch addresses stay valid across every per-file Fill().
62
m_fileMetrics
->Branch (
"nBranches"
, &
m_nBranches
,
"nBranches/I"
);
63
m_fileMetrics
->Branch (
"learnEntries"
, &
m_nLearn
,
"learnEntries/I"
);
64
m_fileMetrics
->Branch (
"cacheEfficiency"
, &
m_cacheEfficiency
,
"cacheEfficiency/D"
);
65
m_fileMetrics
->Branch (
"cacheEfficiencyRel"
, &
m_cacheEfficiencyRel
,
"cacheEfficiencyRel/D"
);
66
m_fileMetrics
->Branch (
"bytesRead"
, &
m_bytesRead
,
"bytesRead/L"
);
67
m_fileMetrics
->Branch (
"readCalls"
, &
m_readCalls
,
"readCalls/I"
);
68
m_fileMetrics
->Branch (
"noCacheBytesRead"
, &
m_noCacheBytesRead
,
"noCacheBytesRead/L"
);
69
m_fileMetrics
->Branch (
"noCacheReadCalls"
, &
m_noCacheReadCalls
,
"noCacheReadCalls/I"
);
70
m_fileMetrics
->Branch (
"readaheadSize"
, &
m_readaheadSize
,
"readaheadSize/I"
);
71
m_fileMetrics
->Branch (
"bytesReadExtra"
, &
m_bytesReadExtra
,
"bytesReadExtra/L"
);
72
return
EL::StatusCode::SUCCESS;
73
}
74
75
76
77
EL::StatusCode
EL::MetricsSvc :: fileExecute ()
78
{
79
RCU_CHANGE_INVARIANT
(
this
);
80
m_filesRead
++;
81
return
EL::StatusCode::SUCCESS;
82
}
83
84
85
86
EL::StatusCode
EL::MetricsSvc :: endOfFile ()
87
{
88
RCU_CHANGE_INVARIANT
(
this
);
89
RCU_ASSERT
(
m_fileMetrics
);
90
RCU_ASSERT
(
wk
()->inputFile());
91
RCU_ASSERT
(
wk
()->
tree
());
92
TTreeCache *
tc
= (TTreeCache*)
wk
()->inputFile()->GetCacheRead(
wk
()->
tree
());
93
if
(
tc
) {
94
// update the member buffers wired to the branches in histInitialize
95
m_nBranches
=
tc
->GetCachedBranches()->GetEntries();
96
m_nLearn
=
tc
->GetLearnEntries();
97
m_cacheEfficiency
=
tc
->GetEfficiency ();
98
m_cacheEfficiencyRel
=
tc
->GetEfficiencyRel ();
99
m_bytesRead
=
tc
->GetBytesRead ();
100
m_readCalls
=
tc
->GetReadCalls ();
101
m_noCacheBytesRead
=
tc
->GetNoCacheBytesRead ();
102
m_noCacheReadCalls
=
tc
->GetNoCacheReadCalls ();
103
m_readaheadSize
= TFile::GetReadaheadSize ();
104
m_bytesReadExtra
=
tc
->GetBytesReadExtra ();
105
m_fileMetrics
->Fill ();
106
}
107
return
EL::StatusCode::SUCCESS;
108
}
109
110
111
112
EL::StatusCode
EL::MetricsSvc :: execute ()
113
{
114
RCU_CHANGE_INVARIANT
(
this
);
115
m_eventsRead
++;
116
return
EL::StatusCode::SUCCESS;
117
}
118
119
120
121
EL::StatusCode
EL::MetricsSvc :: histFinalize ()
122
{
123
RCU_CHANGE_INVARIANT
(
this
);
124
m_benchmark
->Stop(
"loopmetrics"
);
125
m_jobMetrics
->Branch(
"eventsRead"
, &
m_eventsRead
,
"eventsRead/I"
);
126
m_jobMetrics
->Branch(
"filesRead"
, &
m_filesRead
,
"filesRead/I"
);
127
Float_t realTime =
m_benchmark
->GetRealTime(
"loopmetrics"
);
128
m_jobMetrics
->Branch(
"loopWallTime"
, &realTime,
"loopWallTime/F"
);
129
Float_t cpuTime =
m_benchmark
->GetCpuTime(
"loopmetrics"
);
130
m_jobMetrics
->Branch(
"loopCpuTime"
, &cpuTime,
"loopCpuTime/F"
);
131
Float_t evtsWallSec =
m_eventsRead
/ (realTime != 0 ? realTime : 1.);
132
m_jobMetrics
->Branch(
"eventsPerWallSec"
, &evtsWallSec,
"eventsPerWallSec/F"
);
133
Float_t evtsCpuSec =
m_eventsRead
/ (cpuTime != 0 ? cpuTime : 1.);
134
m_jobMetrics
->Branch(
"eventsPerCpuSec"
, &evtsCpuSec,
"eventsPerCpuSec/F"
);
135
m_jobMetrics
->Fill();
136
return
EL::StatusCode::SUCCESS;
137
}
Assert.h
RCU_ASSERT
#define RCU_ASSERT(x)
Definition
Assert.h:210
RCU_DESTROY_INVARIANT
#define RCU_DESTROY_INVARIANT(x)
Definition
Assert.h:223
RCU_CHANGE_INVARIANT
#define RCU_CHANGE_INVARIANT(x)
Definition
Assert.h:219
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition
Assert.h:221
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition
Assert.h:217
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_nLearn
Int_t m_nLearn
Definition
MetricsSvc.h:126
EL::MetricsSvc::m_eventsRead
Int_t m_eventsRead
description: the number of events processed
Definition
MetricsSvc.h:112
EL::MetricsSvc::m_noCacheReadCalls
Int_t m_noCacheReadCalls
Definition
MetricsSvc.h:132
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_noCacheBytesRead
Long64_t m_noCacheBytesRead
Definition
MetricsSvc.h:131
EL::MetricsSvc::m_cacheEfficiency
Double_t m_cacheEfficiency
Definition
MetricsSvc.h:127
EL::MetricsSvc::m_bytesRead
Long64_t m_bytesRead
Definition
MetricsSvc.h:129
EL::MetricsSvc::m_nBranches
Int_t m_nBranches
buffers for the per-file cache-stats branches
Definition
MetricsSvc.h:125
EL::MetricsSvc::m_readaheadSize
Int_t m_readaheadSize
Definition
MetricsSvc.h:133
EL::MetricsSvc::m_bytesReadExtra
Long64_t m_bytesReadExtra
Definition
MetricsSvc.h:134
EL::MetricsSvc::m_cacheEfficiencyRel
Double_t m_cacheEfficiencyRel
Definition
MetricsSvc.h:128
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::MetricsSvc::m_readCalls
Int_t m_readCalls
Definition
MetricsSvc.h:130
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