Crombie Tools
ProgressReporter.h
Go to the documentation of this file.
1
/**
2
@file ProgressReporter.h
3
Header file that defines ProgressReporter class.
4
@author Daniel Abercrombie <dabercro@mit.edu>
5
*/
6
7
#ifndef CROMBIETOOLS_COMMONTOOLS_PROGRESSREPORTER_H
8
#define CROMBIETOOLS_COMMONTOOLS_PROGRESSREPORTER_H
9
10
#include <iostream>
11
#include "TString.h"
12
#include "TTree.h"
13
14
/**
15
@ingroup commongroup
16
@class ProgressReporter
17
This class is used to report progress of various codes that run over every event in a file
18
*/
19
20
class
ProgressReporter
21
{
22
public
:
23
ProgressReporter
() {};
24
virtual
~ProgressReporter
() {};
25
26
/// Sets the frequency of reporting progress to terminal
27
void
SetReportFrequency
( Long64_t freq ) {
fReportFreq
= freq; }
28
29
protected
:
30
/// Sets the number of entries to process
31
void
SetNumberOfEntries
( Long64_t nentries ) {
fNumberOfEntries
= nentries; }
32
/// Sets the number of entries to process from a tree
33
Long64_t
SetNumberOfEntries
( TTree *tree ) {
fNumberOfEntries
= tree->GetEntries();
34
return
fNumberOfEntries
; }
35
/// Sets the name of the file to report to the terminal
36
void
SetReportFile
( TString name ) {
fReportFile
= name; }
37
38
/// Sends report to the terminal if needed
39
void
ReportProgress
( Long64_t entry ) {
40
if
(entry %
fReportFreq
== 0)
41
std::cout <<
"Processing "
<<
fReportFile
<<
" ... "
<< (float(entry)/
fNumberOfEntries
)*100 <<
"%"
<< std::endl;
42
}
43
44
Long64_t
fNumberOfEntries
= 0;
///< Number of entries being run over
45
46
private
:
47
Long64_t
fReportFreq
= 100000;
///< Number of events between each frequency report
48
TString
fReportFile
=
""
;
///< Name of the file being run on
49
};
50
51
#endif
old
CommonTools
interface
ProgressReporter.h
Generated on Tue Nov 3 2020 04:04:03 for Crombie Tools by
1.8.12