GENIEGenerator
Loading...
Searching...
No Matches
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
string fStatusFile
 name of output status file
TStopwatch fWatch
double fCpuTime
 total cpu time so far
int fRefreshRate
 update output every so many events

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 \at cern.ch> University of Liverpool
Created:\n July 13, 2005
License:\n Copyright (c) 2003-2025, 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::GMCJMonitor ( Long_t runnu)

Definition at line 32 of file GMCJMonitor.cxx.

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

References fRunNu, and Init().

◆ ~GMCJMonitor()

GMCJMonitor::~GMCJMonitor ( )

Definition at line 38 of file GMCJMonitor.cxx.

39{
40
41}

Member Function Documentation

◆ CustomizeFilename()

void GMCJMonitor::CustomizeFilename ( string filename)

Definition at line 97 of file GMCJMonitor.cxx.

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

References fStatusFile.

Referenced by GenerateEventsAtFixedInitState().

◆ Init()

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
int fRefreshRate
update output every so many events
Definition GMCJMonitor.h:49
double fCpuTime
total cpu time so far
Definition GMCJMonitor.h:48

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

Referenced by GMCJMonitor().

◆ SetRefreshRate()

void GMCJMonitor::SetRefreshRate ( int rate)

Definition at line 43 of file GMCJMonitor.cxx.

44{
45 fRefreshRate = TMath::Max(1,rate);
46}

References fRefreshRate.

Referenced by GenerateEventsAtFixedInitState(), and main().

◆ Update()

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}

References fCpuTime, fRefreshRate, fStatusFile, and fWatch.

Referenced by GenerateEventsAtFixedInitState(), and main().

Member Data Documentation

◆ fCpuTime

double genie::GMCJMonitor::fCpuTime
private

total cpu time so far

Definition at line 48 of file GMCJMonitor.h.

Referenced by Init(), and Update().

◆ fRefreshRate

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

◆ fRunNu

Long_t genie::GMCJMonitor::fRunNu
private

run number

Definition at line 45 of file GMCJMonitor.h.

Referenced by GMCJMonitor(), and Init().

◆ fStatusFile

string genie::GMCJMonitor::fStatusFile
private

name of output status file

Definition at line 46 of file GMCJMonitor.h.

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

◆ fWatch

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: