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::SgTEventevtStore () 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
IWorkerm_wk
asg::SgTEventm_evtStorePtr = nullptr
 the value of evtStore
asg::SgTEvent 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 35 of file MetricsSvc.cxx.

37 , m_eventsRead (0), m_benchmark (0)
38{
39 RCU_NEW_INVARIANT (this);
40}
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:233
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 44 of file MetricsSvc.cxx.

45{
47 if (m_benchmark) { delete m_benchmark; }
48}
#define RCU_DESTROY_INVARIANT(x)
Definition Assert.h:235

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 75 of file MetricsSvc.cxx.

76{
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}
#define RCU_ASSERT(x)
Definition Assert.h:222
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:231
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
TChain * tree

◆ evtStore()

asg::SgTEvent * 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 110 of file MetricsSvc.cxx.

111{
113 m_eventsRead ++;
114 return EL::StatusCode::SUCCESS;
115}

◆ 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 66 of file MetricsSvc.cxx.

67{
69 m_filesRead ++;
70 return EL::StatusCode::SUCCESS;
71}

◆ 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 28 of file MetricsSvc.cxx.

29{
30 RCU_READ_INVARIANT (this);
31 return name.c_str();
32}
#define RCU_READ_INVARIANT(x)
Definition Assert.h:229
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 119 of file MetricsSvc.cxx.

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

◆ 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 52 of file MetricsSvc.cxx.

53{
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}
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{
25 RCU_INVARIANT (this != 0);
26}
#define RCU_INVARIANT(x)
Definition Assert.h:201

◆ 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_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::SgTEvent EL::Algorithm::m_evtStore
mutableprivateinherited

when configured, the object returned by evtStore

Definition at line 329 of file Algorithm.h.

◆ m_evtStorePtr

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

the value of evtStore

Definition at line 325 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 333 of file Algorithm.h.

◆ m_msgLevel

int EL::Algorithm::m_msgLevel = 3
privateinherited

the message level configured

Definition at line 342 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 338 of file Algorithm.h.

◆ m_nameCache

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

the cache for name

Definition at line 346 of file Algorithm.h.

◆ m_wk

IWorker* EL::Algorithm::m_wk
privateinherited

Definition at line 321 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: