Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
Generator
src
Framework
EventGen
GMCJMonitor.cxx
Go to the documentation of this file.
1
//____________________________________________________________________________
2
/*
3
Copyright (c) 2003-2020, The GENIE Collaboration
4
For the full text of the license visit http://copyright.genie-mc.org
5
6
Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
7
University of Liverpool & STFC Rutherford Appleton Laboratory
8
*/
9
//____________________________________________________________________________
10
11
#include <sstream>
12
#include <fstream>
13
#include <cstdlib>
14
15
#include <TSystem.h>
16
#include <TMath.h>
17
18
#include "
Framework/EventGen/EventRecord.h
"
19
#include "
Framework/EventGen/GMCJMonitor.h
"
20
#include "
Framework/GHEP/GHepParticle.h
"
21
#include "
Framework/Messenger/Messenger.h
"
22
#include "
Framework/Utils/PrintUtils.h
"
23
24
using
std::ostringstream;
25
using
std::endl
;
26
using
std::ios;
27
using
std::ofstream;
28
29
using namespace
genie
;
30
31
//____________________________________________________________________________
32
GMCJMonitor::GMCJMonitor
(Long_t runnu) :
33
fRunNu(runnu)
34
{
35
this->
Init
();
36
}
37
//____________________________________________________________________________
38
GMCJMonitor::~GMCJMonitor
()
39
{
40
41
}
42
//____________________________________________________________________________
43
void
GMCJMonitor::SetRefreshRate
(
int
rate)
44
{
45
fRefreshRate
= TMath::Max(1,rate);
46
}
47
//____________________________________________________________________________
48
void
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
//____________________________________________________________________________
76
void
GMCJMonitor::Init
(
void
)
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
97
void
GMCJMonitor::CustomizeFilename
(
string
filename
)
98
{
99
fStatusFile
=
filename
;
100
}
101
//____________________________________________________________________________
genie::GMCJMonitor::fWatch
TStopwatch fWatch
Definition:
GMCJMonitor.h:47
genie
THE MAIN GENIE PROJECT NAMESPACE
Definition:
AlgCmp.h:25
genie::GMCJMonitor::Init
void Init(void)
Definition:
GMCJMonitor.cxx:76
genie::GMCJMonitor::Update
void Update(int iev, const EventRecord *event)
Definition:
GMCJMonitor.cxx:48
genie::GMCJMonitor::fRunNu
Long_t fRunNu
run number
Definition:
GMCJMonitor.h:45
genie::GMCJMonitor::CustomizeFilename
void CustomizeFilename(string filename)
Definition:
GMCJMonitor.cxx:97
train.filename
string filename
Definition:
train.py:213
genie::GMCJMonitor::SetRefreshRate
void SetRefreshRate(int rate)
Definition:
GMCJMonitor.cxx:43
genie::GMCJMonitor::~GMCJMonitor
~GMCJMonitor()
Definition:
GMCJMonitor.cxx:38
genie::GMCJMonitor::fStatusFile
string fStatusFile
name of output status file
Definition:
GMCJMonitor.h:46
genie::GMCJMonitor::fCpuTime
double fCpuTime
total cpu time so far
Definition:
GMCJMonitor.h:48
create_imaplist.status
int status
Definition:
create_imaplist.py:5
GHepParticle.h
Messenger.h
genie::EventRecord
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
Definition:
EventRecord.h:37
genie::GMCJMonitor::GMCJMonitor
GMCJMonitor(Long_t runnu)
Definition:
GMCJMonitor.cxx:32
EventRecord.h
genie::GMCJMonitor::fRefreshRate
int fRefreshRate
update output every so many events
Definition:
GMCJMonitor.h:49
PrintUtils.h
GMCJMonitor.h
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
event
Event finding and building.
Definition:
EventCheater_module.cc:32
Generated by
1.8.11