GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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>

Collaboration diagram for genie::GMCJMonitor:
Collaboration graph
[legend]

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 <c.andreopoulos cern.ch> University of Liverpool
Created:
July 13, 2005
License:
Copyright (c) 2003-2024, 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.

References Init().

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.

References fStatusFile.

Referenced by GenerateEventsAtFixedInitState().

98 {
99  fStatusFile = filename;
100 }
string fStatusFile
name of output status file
Definition: GMCJMonitor.h:46
void GMCJMonitor::Init ( void  )
private

Definition at line 76 of file GMCJMonitor.cxx.

References fCpuTime, fRefreshRate, fRunNu, fStatusFile, and fWatch.

Referenced by GMCJMonitor().

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 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.

References fRefreshRate.

Referenced by GenerateEventsAtFixedInitState(), and main().

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.

References fCpuTime, fRefreshRate, fStatusFile, and fWatch.

Referenced by GenerateEventsAtFixedInitState(), and main().

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

Member Data Documentation

double genie::GMCJMonitor::fCpuTime
private

total cpu time so far

Definition at line 48 of file GMCJMonitor.h.

Referenced by Init(), and Update().

int genie::GMCJMonitor::fRefreshRate
private

update output every so many events

Definition at line 49 of file GMCJMonitor.h.

Referenced by Init(), SetRefreshRate(), and Update().

Long_t genie::GMCJMonitor::fRunNu
private

run number

Definition at line 45 of file GMCJMonitor.h.

Referenced by Init().

string genie::GMCJMonitor::fStatusFile
private

name of output status file

Definition at line 46 of file GMCJMonitor.h.

Referenced by CustomizeFilename(), Init(), and Update().

TStopwatch genie::GMCJMonitor::fWatch
private

Definition at line 47 of file GMCJMonitor.h.

Referenced by Init(), and Update().


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