Public Member Functions | Private Member Functions | Private Attributes | List of all members
genie::GMCJMonitor Class Reference

Simple class to create & update MC job status files and env. vars. This is used to be able to keep track of an MC job status even when all output is suppressed or redirected to /dev/null. More...

#include <GMCJMonitor.h>

Public Member Functions

 GMCJMonitor (Long_t runnu)
 
 ~GMCJMonitor ()
 
void SetRefreshRate (int rate)
 
void Update (int iev, const EventRecord *event)
 
void CustomizeFilename (string filename)
 

Private Member Functions

void Init (void)
 

Private Attributes

Long_t fRunNu
 run number More...
 
string fStatusFile
 name of output status file More...
 
TStopwatch fWatch
 
double fCpuTime
 total cpu time so far More...
 
int fRefreshRate
 update output every so many events More...
 

Detailed Description

Simple class to create & update MC job status files and env. vars. This is used to be able to keep track of an MC job status even when all output is suppressed or redirected to /dev/null.

Author
Costas Andreopoulos <constantinos.andreopoulos cern.ch> University of Liverpool & STFC Rutherford Appleton Laboratory

July 13, 2005

Copyright (c) 2003-2020, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org

Definition at line 31 of file GMCJMonitor.h.

Constructor & Destructor Documentation

GMCJMonitor::GMCJMonitor ( Long_t  runnu)

Definition at line 32 of file GMCJMonitor.cxx.

32  :
33 fRunNu(runnu)
34 {
35  this->Init();
36 }
Long_t fRunNu
run number
Definition: GMCJMonitor.h:45
GMCJMonitor::~GMCJMonitor ( )

Definition at line 38 of file GMCJMonitor.cxx.

39 {
40 
41 }

Member Function Documentation

void GMCJMonitor::CustomizeFilename ( string  filename)

Definition at line 97 of file GMCJMonitor.cxx.

98 {
100 }
string filename
Definition: train.py:213
string fStatusFile
name of output status file
Definition: GMCJMonitor.h:46
void GMCJMonitor::Init ( void  )
private

Definition at line 76 of file GMCJMonitor.cxx.

77 {
78  // build the filename of the GENIE status file
79  ostringstream filename;
80  filename << "genie-mcjob-" << fRunNu << ".status";
81  fStatusFile = filename.str();
82 
83  // create a stopwatch
84  fWatch.Reset();
85  fWatch.Start();
86  fCpuTime = 0;
87 
88  // get rehreah rate of set default / protect from invalid refresh rates
89  if( gSystem->Getenv("GMCJMONREFRESH") ) {
90  fRefreshRate = atoi( gSystem->Getenv("GMCJMONREFRESH") );
91  } else fRefreshRate = 100;
92 
93  fRefreshRate = TMath::Max(1,fRefreshRate);
94 }
TStopwatch fWatch
Definition: GMCJMonitor.h:47
Long_t fRunNu
run number
Definition: GMCJMonitor.h:45
string filename
Definition: train.py:213
string fStatusFile
name of output status file
Definition: GMCJMonitor.h:46
double fCpuTime
total cpu time so far
Definition: GMCJMonitor.h:48
int fRefreshRate
update output every so many events
Definition: GMCJMonitor.h:49
void GMCJMonitor::SetRefreshRate ( int  rate)

Definition at line 43 of file GMCJMonitor.cxx.

44 {
45  fRefreshRate = TMath::Max(1,rate);
46 }
int fRefreshRate
update output every so many events
Definition: GMCJMonitor.h:49
void GMCJMonitor::Update ( int  iev,
const EventRecord event 
)

Definition at line 48 of file GMCJMonitor.cxx.

49 {
50  if(iev%fRefreshRate) return; // continue only every fRefreshRate events
51 
52  fWatch.Stop();
53  fCpuTime += (fWatch.CpuTime());
54 
55  ofstream out(fStatusFile.c_str(), ios::out);
56 
57  ostringstream status;
58 
59  status << endl;
60  status << "Current Event Number: " << iev << endl;
61 
62  status << "Approximate total processing time: "
63  << fCpuTime << " s" << endl;
64  status << "Approximate processing time/event: "
65  << fCpuTime/(iev+1) << " s" << endl;
66 
67  if(!event) status << "NULL" << endl;
68  else status << *event << endl;
69 
70  out << status.str();
71  out.close();
72 
73  fWatch.Start();
74 }
TStopwatch fWatch
Definition: GMCJMonitor.h:47
string fStatusFile
name of output status file
Definition: GMCJMonitor.h:46
double fCpuTime
total cpu time so far
Definition: GMCJMonitor.h:48
int fRefreshRate
update output every so many events
Definition: GMCJMonitor.h:49
QTextStream & endl(QTextStream &s)

Member Data Documentation

double genie::GMCJMonitor::fCpuTime
private

total cpu time so far

Definition at line 48 of file GMCJMonitor.h.

int genie::GMCJMonitor::fRefreshRate
private

update output every so many events

Definition at line 49 of file GMCJMonitor.h.

Long_t genie::GMCJMonitor::fRunNu
private

run number

Definition at line 45 of file GMCJMonitor.h.

string genie::GMCJMonitor::fStatusFile
private

name of output status file

Definition at line 46 of file GMCJMonitor.h.

TStopwatch genie::GMCJMonitor::fWatch
private

Definition at line 47 of file GMCJMonitor.h.


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