NtpMCJobEnv.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2019, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5  or see $GENIE/LICENSE
6 
7  Author: Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
8  University of Liverpool & STFC Rutherford Appleton Lab - October 01, 2004
9 
10  For the class documentation see the corresponding header file.
11 
12  Important revisions after version 2.0.0 :
13 
14 */
15 //____________________________________________________________________________
16 
17 #include <string>
18 #include <sstream>
19 #include <vector>
20 
21 #include <TROOT.h>
22 #include <TSystem.h>
23 #include <TFolder.h>
24 #include <TObjString.h>
25 
29 
30 using std::string;
31 using std::ostringstream;
32 using std::vector;
33 using namespace genie;
34 using namespace genie::controls;
35 
36 //____________________________________________________________________________
38 {
39  fEnv = 0;
40 }
41 //____________________________________________________________________________
43 {
44 
45 }
46 //____________________________________________________________________________
48 {
49  if (fEnv) delete fEnv;
50  fEnv = 0;
51 
52  LOG("Ntp", pNOTICE)
53  << "Taking environment snapshot and saving it in a TFolder";
54 
55  fEnv = gROOT->GetRootFolder()->AddFolder("genv","GENIE user environment");
56  gROOT->GetListOfBrowsables()->Add(fEnv,"genv");
57 
58  fEnv->SetOwner(true);
59 
60  vector<string> envvars;
61 
62  unsigned int ivar=0;
63  while(kMCEnv[ivar]) {
64  envvars.push_back(string(kMCEnv[ivar]));
65  ivar++;
66  }
67 
68  LOG("Ntp", pINFO) << "** MC Job Environment:";
69  vector<string>::iterator variter;
70  for(variter = envvars.begin(); variter != envvars.end(); ++variter) {
71 
72  ostringstream entry;
73  string var = *variter;
74  string value = (gSystem->Getenv(var.c_str()) ?
75  gSystem->Getenv(var.c_str()) : "UNDEFINED");
76 
77  LOG("Ntp", pINFO) << "$" << var << " ---> " << value;
78 
79  entry << "envv:" << var << ";value:" << value;
80  fEnv->Add(new TObjString(entry.str().c_str()));
81  }
82  return fEnv;
83 }
84 //____________________________________________________________________________
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
virtual ~NtpMCJobEnv()
Definition: NtpMCJobEnv.cxx:42
const XML_Char int const XML_Char * value
Definition: expat.h:331
static const char * kMCEnv[]
Definition: EnvSnapshot.h:25
#define pINFO
Definition: Messenger.h:63
Misc GENIE control constants.
#define pNOTICE
Definition: Messenger.h:62
def entry(str)
Definition: HTMLTools.py:26
TFolder * TakeSnapshot(void)
Definition: NtpMCJobEnv.cxx:47
enum BeamMode string