GENIEGenerator
Loading...
Searching...
No Matches
NtpMCJobEnv.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 <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
24using std::string;
25using std::ostringstream;
26using std::vector;
27using namespace genie;
28using namespace genie::controls;
29
30//____________________________________________________________________________
35//____________________________________________________________________________
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 pNOTICE
Definition Messenger.h:61
#define pINFO
Definition Messenger.h:62
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
TFolder * TakeSnapshot(void)
Misc GENIE control constants.
static const char * kMCEnv[]
Definition EnvSnapshot.h:24
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25