GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NtpMCJobEnv.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2024, 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 <string>
12 #include <sstream>
13 #include <vector>
14 
15 #include <TROOT.h>
16 #include <TSystem.h>
17 #include <TFolder.h>
18 #include <TObjString.h>
19 
23 
24 using std::string;
25 using std::ostringstream;
26 using std::vector;
27 using namespace genie;
28 using namespace genie::controls;
29 
30 //____________________________________________________________________________
32 {
33  fEnv = 0;
34 }
35 //____________________________________________________________________________
37 {
38 
39 }
40 //____________________________________________________________________________
42 {
43  if (fEnv) delete fEnv;
44  fEnv = 0;
45 
46  LOG("Ntp", pNOTICE)
47  << "Taking environment snapshot and saving it in a TFolder";
48 
49  fEnv = gROOT->GetRootFolder()->AddFolder("genv","GENIE user environment");
50  gROOT->GetListOfBrowsables()->Add(fEnv,"genv");
51 
52  fEnv->SetOwner(true);
53 
54  vector<string> envvars;
55 
56  unsigned int ivar=0;
57  while(kMCEnv[ivar]) {
58  envvars.push_back(string(kMCEnv[ivar]));
59  ivar++;
60  }
61 
62  LOG("Ntp", pINFO) << "** MC Job Environment:";
63  vector<string>::iterator variter;
64  for(variter = envvars.begin(); variter != envvars.end(); ++variter) {
65 
66  ostringstream entry;
67  string var = *variter;
68  string value = (gSystem->Getenv(var.c_str()) ?
69  gSystem->Getenv(var.c_str()) : "UNDEFINED");
70 
71  LOG("Ntp", pINFO) << "$" << var << " ---> " << value;
72 
73  entry << "envv:" << var << ";value:" << value;
74  fEnv->Add(new TObjString(entry.str().c_str()));
75  }
76  return fEnv;
77 }
78 //____________________________________________________________________________
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
virtual ~NtpMCJobEnv()
Definition: NtpMCJobEnv.cxx:36
static const char * kMCEnv[]
Definition: EnvSnapshot.h:24
#define pINFO
Definition: Messenger.h:62
#define pNOTICE
Definition: Messenger.h:61
TFolder * TakeSnapshot(void)
Definition: NtpMCJobEnv.cxx:41