GENIEGenerator
Loading...
Searching...
No Matches
GMCJMonitor.cxx
Go to the documentation of this file.
1//____________________________________________________________________________
2/*
3 Copyright (c) 2003-2025, The GENIE Collaboration
4 For the full text of the license visit http://copyright.genie-mc.org
5
6 Costas Andreopoulos <c.andreopoulos \at cern.ch>
7 University of Liverpool
8*/
9//____________________________________________________________________________
10
11#include <sstream>
12#include <fstream>
13#include <cstdlib>
14
15#include <TSystem.h>
16#include <TMath.h>
17
23
24using std::ostringstream;
25using std::endl;
26using std::ios;
27using std::ofstream;
28
29using namespace genie;
30
31//____________________________________________________________________________
33fRunNu(runnu)
34{
35 this->Init();
36}
37//____________________________________________________________________________
42//____________________________________________________________________________
44{
45 fRefreshRate = TMath::Max(1,rate);
46}
47//____________________________________________________________________________
48void GMCJMonitor::Update(int iev, const EventRecord * event)
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}
75//____________________________________________________________________________
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}
95//____________________________________________________________________________
96
97void GMCJMonitor::CustomizeFilename(string filename)
98{
99 fStatusFile = filename;
100}
101//____________________________________________________________________________
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
Definition EventRecord.h:37
void CustomizeFilename(string filename)
TStopwatch fWatch
Definition GMCJMonitor.h:47
int fRefreshRate
update output every so many events
Definition GMCJMonitor.h:49
void Update(int iev, const EventRecord *event)
Long_t fRunNu
run number
Definition GMCJMonitor.h:45
double fCpuTime
total cpu time so far
Definition GMCJMonitor.h:48
void SetRefreshRate(int rate)
GMCJMonitor(Long_t runnu)
string fStatusFile
name of output status file
Definition GMCJMonitor.h:46
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25