ATLAS Offline Software
Loading...
Searching...
No Matches
EL::MetricsSvc Class Reference

#include <MetricsSvc.h>

Inheritance diagram for EL::MetricsSvc:
Collaboration diagram for EL::MetricsSvc:

Public Member Functions

void testInvariant () const
 effects: test the invariant of this object guarantee: no-fail
 MetricsSvc ()
 effects: standard constructor.
 ~MetricsSvc ()
 effects: standard destructor.
virtual const char * GetName () const override
 effects: return the name of this algorithm guarantee: no-fail
IWorkerwk () const
 description: the worker that is controlling us guarantee: no-fail
void book (const TH1 &hist)
 book the given histogram
TH1 * hist (const std::string &name) const
 get the histogram with the given name
asg::SgEventevtStore () const
 get the (main) event store for this algorithm
virtual const std::string & name () const
MsgStream & msg () const
 messaging interface
MsgStream & msg (int level) const
 the message stream for this object, configured for the given level
bool msgLvl (int lvl) const
 whether we are configured to print messages at the given level
void setMsgLevel (int level)
 set the message level for the message stream for this object

Static Public Attributes

static const std::string name
 description: the name of the service

Private Member Functions

virtual StatusCode fileExecute () override
 effects: do all the processing that needs to be done once per file guarantee: no-fail
virtual StatusCode endOfFile () override
 effects: do the post-processing for each input file guarantee: basic failures: out of memory failures: in/out trees or input file not available
virtual StatusCode histInitialize () override
 effects: create the output TTrees guarantee: basic failures: out of memory failures: output already exists
virtual StatusCode execute () override
 effects: process the next event guarantee: no-fail
virtual StatusCode histFinalize () override
 effects: do the job post-processing guarantee: basic failures: out of memory failures: in/out trees or input file not available
 ClassDef (MetricsSvc, 1)
virtual StatusCode setupJob (Job &job)
 effects: give the algorithm a chance to intialize the job with anything this algorithm needs.
virtual StatusCode changeInput (bool firstFile)
 effects: do all changes to work with a new input file, e.g.
virtual StatusCode initialize ()
 effects: do everything that needs to be done before running the algorithm, e.g.
virtual StatusCode postExecute ()
 effects: do the post-processing for the event guarantee: basic failures: algorithm dependent rationale: this is mainly used for specialized services that need to get input from subsequent algorithms before filling their event data
virtual StatusCode finalize ()
 effects: do everything that needs to be done after completing work on this worker guarantee: basic failures: algorithm dependent rationale: currently there is no use foreseen, but this routine is provided regardless
virtual bool hasName (const std::string &name) const
 returns: whether this algorithm has the given name guarantee: basic failures: algorithm dependent rationale: this is to allow an algorithm to be known by multiple names.
void sysSetupJob (Job &job)
 effects: give the algorithm a chance to intialize the job with anything this algorithm needs.

Private Attributes

TTree * m_fileMetrics
 description: the file cache metrics
TTree * m_jobMetrics
 description: the job metrics
Int_t m_filesRead
 description: the number of files processed
Int_t m_eventsRead
 description: the number of events processed
TBenchmark * m_benchmark
 description: the benchmark object used rationale: this is a pointer to avoid including the header in this file
Int_t m_nBranches = 0
 buffers for the per-file cache-stats branches
Int_t m_nLearn = 0
Double_t m_cacheEfficiency = 0
Double_t m_cacheEfficiencyRel = 0
Long64_t m_bytesRead = 0
Int_t m_readCalls = 0
Long64_t m_noCacheBytesRead = 0
Int_t m_noCacheReadCalls = 0
Int_t m_readaheadSize = 0
Long64_t m_bytesReadExtra = 0
IWorkerm_wk
asg::SgEventm_evtStorePtr = nullptr
 the value of evtStore
asg::SgEvent m_evtStore
 when configured, the object returned by evtStore
MsgStream * m_msg = nullptr
 the message stream, if it has been instantiated
std::string m_msgName
 the algorithm name for which the message stream has been instantiated
int m_msgLevel = 3
 the message level configured
std::string m_nameCache
 the cache for name

Detailed Description

Definition at line 18 of file MetricsSvc.h.

Constructor & Destructor Documentation

◆ MetricsSvc()

EL::MetricsSvc::MetricsSvc ( )

effects: standard constructor.

guarantee: no-fail

Definition at line 33 of file MetricsSvc.cxx.

35 , m_eventsRead (0), m_benchmark (0)
36{
37 RCU_NEW_INVARIANT (this);
38}
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:221
Int_t m_filesRead
description: the number of files processed
Definition MetricsSvc.h:108
Int_t m_eventsRead
description: the number of events processed
Definition MetricsSvc.h:112
TTree * m_fileMetrics
description: the file cache metrics
Definition MetricsSvc.h:100
TTree * m_jobMetrics
description: the job metrics
Definition MetricsSvc.h:104
TBenchmark * m_benchmark
description: the benchmark object used rationale: this is a pointer to avoid including the header in ...
Definition MetricsSvc.h:117

◆ ~MetricsSvc()

EL::MetricsSvc::~MetricsSvc ( )

effects: standard destructor.

guarantee: no-fail

Definition at line 42 of file MetricsSvc.cxx.

43{
45 if (m_benchmark) { delete m_benchmark; }
46}
#define RCU_DESTROY_INVARIANT(x)
Definition Assert.h:223

Member Function Documentation

◆ book()

void EL::Algorithm::book ( const TH1 & hist)
inherited

book the given histogram

Guarantee
strong
Failures
histogram booking error

◆ changeInput()

virtual StatusCode EL::Algorithm::changeInput ( bool firstFile)
privatevirtualinherited

effects: do all changes to work with a new input file, e.g.

set new branch addresses. if firstFile is set, this method is called just before init() is called

Warning: If a file is split across multiple jobs this will be called more than once. This only happens for specific batch drivers and/or if it is explicitly configured by the user. With PROOF it could even happen multiple times within the same job, and while PROOF is no longer supported that behavior may come back if support for a similar framework is added in the future. As such, this method should not be used for accounting that relies to be called exactly once per file, take a look at fileExecute() if you want something that is guaranteed to be executed exactly once per input file.

Warning: The execution order of changeInput and fileExecute is currently unspecified.

guarantee: basic failures: algorithm dependent

Reimplemented in EL::DuplicateChecker, EL::NTupleSvc, EL::UnitTestAlg1, EL::UnitTestAlg, EL::UnitTestAlgXAOD, EL::UnitTestSkim, and MD::FormulaSvc.

◆ ClassDef()

EL::MetricsSvc::ClassDef ( MetricsSvc ,
1  )
private

◆ endOfFile()

EL::StatusCode EL::MetricsSvc::endOfFile ( )
overrideprivatevirtual

effects: do the post-processing for each input file guarantee: basic failures: out of memory failures: in/out trees or input file not available

Reimplemented from EL::Algorithm.

Definition at line 86 of file MetricsSvc.cxx.

87{
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}
#define RCU_ASSERT(x)
Definition Assert.h:210
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:219
static Double_t tc
IWorker * wk() const
description: the worker that is controlling us guarantee: no-fail
virtual TFile * inputFile() const =0
description: the file we are reading the current tree from guarantee: no-fail
Int_t m_noCacheReadCalls
Definition MetricsSvc.h:132
Long64_t m_noCacheBytesRead
Definition MetricsSvc.h:131
Double_t m_cacheEfficiency
Definition MetricsSvc.h:127
Long64_t m_bytesRead
Definition MetricsSvc.h:129
Int_t m_nBranches
buffers for the per-file cache-stats branches
Definition MetricsSvc.h:125
Int_t m_readaheadSize
Definition MetricsSvc.h:133
Long64_t m_bytesReadExtra
Definition MetricsSvc.h:134
Double_t m_cacheEfficiencyRel
Definition MetricsSvc.h:128
TChain * tree

◆ evtStore()

asg::SgEvent * EL::Algorithm::evtStore ( ) const
inherited

get the (main) event store for this algorithm

This is mostly to mirror the method of the same name in AthAlgorithm, allowing to make the tutorial instructions more dual-use.

Guarantee
strong
Failures
out of memory I
job not configured for xAODs

◆ execute()

EL::StatusCode EL::MetricsSvc::execute ( )
overrideprivatevirtual

effects: process the next event guarantee: no-fail

Reimplemented from EL::Algorithm.

Definition at line 112 of file MetricsSvc.cxx.

113{
115 m_eventsRead ++;
116 return EL::StatusCode::SUCCESS;
117}

◆ fileExecute()

EL::StatusCode EL::MetricsSvc::fileExecute ( )
overrideprivatevirtual

effects: do all the processing that needs to be done once per file guarantee: no-fail

Reimplemented from EL::Algorithm.

Definition at line 77 of file MetricsSvc.cxx.

78{
80 m_filesRead ++;
81 return EL::StatusCode::SUCCESS;
82}

◆ finalize()

virtual StatusCode EL::Algorithm::finalize ( )
privatevirtualinherited

effects: do everything that needs to be done after completing work on this worker guarantee: basic failures: algorithm dependent rationale: currently there is no use foreseen, but this routine is provided regardless

Reimplemented in EL::UnitTestAlg1, EL::UnitTestAlg, and EL::UnitTestAlgXAOD.

◆ GetName()

const char * EL::MetricsSvc::GetName ( ) const
overridevirtual

effects: return the name of this algorithm guarantee: no-fail

Definition at line 26 of file MetricsSvc.cxx.

27{
28 RCU_READ_INVARIANT (this);
29 return name.c_str();
30}
#define RCU_READ_INVARIANT(x)
Definition Assert.h:217
static const std::string name
description: the name of the service
Definition MetricsSvc.h:26

◆ hasName()

virtual bool EL::Algorithm::hasName ( const std::string & name) const
privatevirtualinherited

returns: whether this algorithm has the given name guarantee: basic failures: algorithm dependent rationale: this is to allow an algorithm to be known by multiple names.

this is needed for NTupleSvc, so that it can be located with and without the output tree name.

Reimplemented in EL::NTupleSvc.

◆ hist()

TH1 * EL::Algorithm::hist ( const std::string & name) const
inherited

get the histogram with the given name

Guarantee
strong
Failures
histogram not found

◆ histFinalize()

EL::StatusCode EL::MetricsSvc::histFinalize ( )
overrideprivatevirtual

effects: do the job post-processing guarantee: basic failures: out of memory failures: in/out trees or input file not available

Reimplemented from EL::Algorithm.

Definition at line 121 of file MetricsSvc.cxx.

122{
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}

◆ histInitialize()

EL::StatusCode EL::MetricsSvc::histInitialize ( )
overrideprivatevirtual

effects: create the output TTrees guarantee: basic failures: out of memory failures: output already exists

Reimplemented from EL::Algorithm.

Definition at line 50 of file MetricsSvc.cxx.

51{
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}
virtual void addOutput(TObject *output_swallow)=0
effects: add an object to the output.

◆ initialize()

virtual StatusCode EL::Algorithm::initialize ( )
privatevirtualinherited

effects: do everything that needs to be done before running the algorithm, e.g.

create output n-tuples and histograms. this method is called only once right after changeInput(true) is called guarantee: basic failures: algorithm dependent rationale: in principle all this work could be done on changeInput(true). However, providing this method should make it easier for the user to set up all his outputs and to do so only once.

Reimplemented in EL::AlgSelect, EL::DuplicateChecker, EL::NTupleSvc, EL::UnitTestAlg1, EL::UnitTestAlg, EL::UnitTestAlgXAOD, EL::UnitTestSkim, MD::AlgCFlow, and MD::AlgHist.

◆ msg() [1/2]

MsgStream & EL::Algorithm::msg ( ) const
inherited

messaging interface

this is the interface to work with the standard messaging macros from AsgTools. Instead of enums I pass ints, so that I can avoid the include dependency (forward declarations are only allowed for enum classes AFAIK).

the standard message stream for this object

Guarantee
strong
Failures
code not compiled with AsgTools support

◆ msg() [2/2]

MsgStream & EL::Algorithm::msg ( int level) const
inherited

the message stream for this object, configured for the given level

Guarantee
strong
Failures
code not compiled with AsgTools support

◆ msgLvl()

bool EL::Algorithm::msgLvl ( int lvl) const
inherited

whether we are configured to print messages at the given level

Guarantee
no-fail

◆ name()

virtual const std::string & EL::Algorithm::name ( ) const
virtualinherited

◆ postExecute()

virtual StatusCode EL::Algorithm::postExecute ( )
privatevirtualinherited

effects: do the post-processing for the event guarantee: basic failures: algorithm dependent rationale: this is mainly used for specialized services that need to get input from subsequent algorithms before filling their event data

Reimplemented in EL::NTupleSvc.

◆ setMsgLevel()

void EL::Algorithm::setMsgLevel ( int level)
inherited

set the message level for the message stream for this object

Guarantee
no-fail

◆ setupJob()

virtual StatusCode EL::Algorithm::setupJob ( Job & job)
privatevirtualinherited

effects: give the algorithm a chance to intialize the job with anything this algorithm needs.

this method is automatically called before the algorithm is actually added to the job. guarantee: basic failures: algorithm dependent rationale: this is currently used to give algorithms a chance to register their output datasets, but can also be used for other stuff.

Reimplemented in EL::AlgSelect, EL::DuplicateChecker, EL::NTupleSvc, EL::UnitTestAlg1, EL::UnitTestAlg, EL::UnitTestAlgXAOD, EL::VomsProxySvc, MD::AlgCFlow, and MD::AlgHist.

◆ sysSetupJob()

void EL::Algorithm::sysSetupJob ( Job & job)
privateinherited

effects: give the algorithm a chance to intialize the job with anything this algorithm needs.

this method is automatically called before the algorithm is actually added to the job. guarantee: basic failures: algorithm dependent rationale: this is currently used to give algorithms a chance to register their output datasets, but can also be used for other stuff.

◆ testInvariant()

void EL::MetricsSvc::testInvariant ( ) const

effects: test the invariant of this object guarantee: no-fail

Definition at line 23 of file MetricsSvc.cxx.

24{}

◆ wk()

IWorker * EL::Algorithm::wk ( ) const
inherited

description: the worker that is controlling us guarantee: no-fail

Member Data Documentation

◆ m_benchmark

TBenchmark* EL::MetricsSvc::m_benchmark
private

description: the benchmark object used rationale: this is a pointer to avoid including the header in this file

Definition at line 117 of file MetricsSvc.h.

◆ m_bytesRead

Long64_t EL::MetricsSvc::m_bytesRead = 0
private

Definition at line 129 of file MetricsSvc.h.

◆ m_bytesReadExtra

Long64_t EL::MetricsSvc::m_bytesReadExtra = 0
private

Definition at line 134 of file MetricsSvc.h.

◆ m_cacheEfficiency

Double_t EL::MetricsSvc::m_cacheEfficiency = 0
private

Definition at line 127 of file MetricsSvc.h.

◆ m_cacheEfficiencyRel

Double_t EL::MetricsSvc::m_cacheEfficiencyRel = 0
private

Definition at line 128 of file MetricsSvc.h.

◆ m_eventsRead

Int_t EL::MetricsSvc::m_eventsRead
private

description: the number of events processed

Definition at line 112 of file MetricsSvc.h.

◆ m_evtStore

asg::SgEvent EL::Algorithm::m_evtStore
mutableprivateinherited

when configured, the object returned by evtStore

Definition at line 326 of file Algorithm.h.

◆ m_evtStorePtr

asg::SgEvent* EL::Algorithm::m_evtStorePtr = nullptr
mutableprivateinherited

the value of evtStore

Definition at line 322 of file Algorithm.h.

◆ m_fileMetrics

TTree* EL::MetricsSvc::m_fileMetrics
private

description: the file cache metrics

Definition at line 100 of file MetricsSvc.h.

◆ m_filesRead

Int_t EL::MetricsSvc::m_filesRead
private

description: the number of files processed

Definition at line 108 of file MetricsSvc.h.

◆ m_jobMetrics

TTree* EL::MetricsSvc::m_jobMetrics
private

description: the job metrics

Definition at line 104 of file MetricsSvc.h.

◆ m_msg

MsgStream* EL::Algorithm::m_msg = nullptr
mutableprivateinherited

the message stream, if it has been instantiated

Definition at line 330 of file Algorithm.h.

◆ m_msgLevel

int EL::Algorithm::m_msgLevel = 3
privateinherited

the message level configured

Definition at line 339 of file Algorithm.h.

◆ m_msgName

std::string EL::Algorithm::m_msgName
mutableprivateinherited

the algorithm name for which the message stream has been instantiated

Definition at line 335 of file Algorithm.h.

◆ m_nameCache

std::string EL::Algorithm::m_nameCache
mutableprivateinherited

the cache for name

Definition at line 343 of file Algorithm.h.

◆ m_nBranches

Int_t EL::MetricsSvc::m_nBranches = 0
private

buffers for the per-file cache-stats branches

These are members (not locals in endOfFile) so that the branches can be created once and their addresses stay valid across all the per-file Fill() calls.

Definition at line 125 of file MetricsSvc.h.

◆ m_nLearn

Int_t EL::MetricsSvc::m_nLearn = 0
private

Definition at line 126 of file MetricsSvc.h.

◆ m_noCacheBytesRead

Long64_t EL::MetricsSvc::m_noCacheBytesRead = 0
private

Definition at line 131 of file MetricsSvc.h.

◆ m_noCacheReadCalls

Int_t EL::MetricsSvc::m_noCacheReadCalls = 0
private

Definition at line 132 of file MetricsSvc.h.

◆ m_readaheadSize

Int_t EL::MetricsSvc::m_readaheadSize = 0
private

Definition at line 133 of file MetricsSvc.h.

◆ m_readCalls

Int_t EL::MetricsSvc::m_readCalls = 0
private

Definition at line 130 of file MetricsSvc.h.

◆ m_wk

IWorker* EL::Algorithm::m_wk
privateinherited

Definition at line 318 of file Algorithm.h.

◆ name

const std::string EL::MetricsSvc::name
static

description: the name of the service

Definition at line 26 of file MetricsSvc.h.


The documentation for this class was generated from the following files: