ATLAS Offline Software
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
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 More...
 
 MetricsSvc ()
 effects: standard constructor. More...
 
 ~MetricsSvc ()
 effects: standard destructor. More...
 
virtual const char * GetName () const override
 effects: return the name of this algorithm guarantee: no-fail More...
 
IWorkerwk () const
 description: the worker that is controlling us guarantee: no-fail More...
 
void book (const TH1 &hist)
 book the given histogram More...
 
TH1hist (const std::string &name) const
 get the histogram with the given name More...
 
asg::SgTEventevtStore () const
 get the (main) event store for this algorithm More...
 
virtual const std::string & name () const
 

Static Public Attributes

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

Private Member Functions

virtual StatusCode fileExecute () override
 effects: do all the processing that needs to be done once per file guarantee: no-fail More...
 
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 More...
 
virtual StatusCode histInitialize () override
 effects: create the output TTrees guarantee: basic failures: out of memory failures: output already exists More...
 
virtual StatusCode execute () override
 effects: process the next event guarantee: no-fail More...
 
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 More...
 
 ClassDef (MetricsSvc, 1)
 
virtual StatusCode setupJob (Job &job)
 effects: give the algorithm a chance to intialize the job with anything this algorithm needs. More...
 
virtual StatusCode changeInput (bool firstFile)
 effects: do all changes to work with a new input file, e.g. More...
 
virtual StatusCode initialize ()
 effects: do everything that needs to be done before running the algorithm, e.g. More...
 
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 More...
 
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 More...
 
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. More...
 
void sysSetupJob (Job &job)
 effects: give the algorithm a chance to intialize the job with anything this algorithm needs. More...
 

Private Attributes

TTree * m_fileMetrics
 description: the file cache metrics More...
 
TTree * m_jobMetrics
 description: the job metrics More...
 
Int_t m_filesRead
 description: the number of files processed More...
 
Int_t m_eventsRead
 description: the number of events processed More...
 
TBenchmark * m_benchmark
 description: the benchmark object used rationale: this is a pointer to avoid including the header in this file More...
 
IWorkerm_wk
 
asg::SgTEventm_evtStorePtr = nullptr
 the value of evtStore More...
 
asg::SgTEvent m_evtStore
 when configured, the object returned by evtStore More...
 
MsgStream * m_msg = nullptr
 the message stream, if it has been instantiated More...
 
std::string m_msgName
 the algorithm name for which the message stream has been instantiated More...
 
int m_msgLevel = 3
 the message level configured More...
 
std::string m_nameCache
 the cache for name More...
 

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.

36  : m_fileMetrics (0), m_jobMetrics (0), m_filesRead (0)
37  , m_eventsRead (0), m_benchmark (0)
38 {
39  RCU_NEW_INVARIANT (this);
40 }

◆ ~MetricsSvc()

EL::MetricsSvc::~MetricsSvc ( )

effects: standard destructor.

guarantee: no-fail

Definition at line 44 of file MetricsSvc.cxx.

45 {
46  RCU_DESTROY_INVARIANT (this);
47  if (m_benchmark) { delete m_benchmark; }
48 }

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::UnitTestAlg1, EL::UnitTestAlg, EL::UnitTestAlgXAOD, EL::NTupleSvc, MD::FormulaSvc, and EL::UnitTestSkim.

◆ ClassDef()

EL::MetricsSvc::ClassDef ( MetricsSvc  ,
 
)
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 {
77  RCU_CHANGE_INVARIANT (this);
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 }

◆ 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 {
112  RCU_CHANGE_INVARIANT (this);
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 {
68  RCU_CHANGE_INVARIANT (this);
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 }

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

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

◆ 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::DuplicateChecker, EL::UnitTestAlg1, EL::UnitTestAlg, EL::UnitTestAlgXAOD, EL::NTupleSvc, EL::AlgSelect, MD::AlgHist, MD::AlgCFlow, and EL::UnitTestSkim.

◆ 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::DuplicateChecker, EL::UnitTestAlg1, EL::UnitTestAlg, EL::UnitTestAlgXAOD, EL::VomsProxySvc, EL::NTupleSvc, EL::AlgSelect, MD::AlgHist, and MD::AlgCFlow.

◆ 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 }

◆ 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:
EL::MetricsSvc::name
static const std::string name
description: the name of the service
Definition: MetricsSvc.h:26
tree
TChain * tree
Definition: tile_monitor.h:30
EL::IHistogramWorker::addOutput
virtual void addOutput(TObject *output_swallow)=0
effects: add an object to the output.
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::m_eventsRead
Int_t m_eventsRead
description: the number of events processed
Definition: MetricsSvc.h:112
EL::IWorker::inputFile
virtual TFile * inputFile() const =0
description: the file we are reading the current tree from guarantee: no-fail
CaloCondBlobAlgs_fillNoiseFromASCII.inputFile
string inputFile
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:17
EL::MetricsSvc::m_filesRead
Int_t m_filesRead
description: the number of files processed
Definition: MetricsSvc.h:108
EL::Algorithm::wk
IWorker * wk() const
description: the worker that is controlling us guarantee: no-fail
RCU_INVARIANT
#define RCU_INVARIANT(x)
Definition: Assert.h:201
RCU_DESTROY_INVARIANT
#define RCU_DESTROY_INVARIANT(x)
Definition: Assert.h:235
EL::MetricsSvc::m_jobMetrics
TTree * m_jobMetrics
description: the job metrics
Definition: MetricsSvc.h:104
RCU_CHANGE_INVARIANT
#define RCU_CHANGE_INVARIANT(x)
Definition: Assert.h:231
dqt_zlumi_alleff_HIST.eff
int eff
Definition: dqt_zlumi_alleff_HIST.py:113
EL::MetricsSvc::m_fileMetrics
TTree * m_fileMetrics
description: the file cache metrics
Definition: MetricsSvc.h:100
RCU_ASSERT
#define RCU_ASSERT(x)
Definition: Assert.h:222
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition: Assert.h:229
EL::IWorker::tree
virtual TTree * tree() const =0
description: the tree we are running on guarantee: no-fail
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition: Assert.h:233