GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
gConfigDump.cxx File Reference
#include <cstdlib>
#include <cassert>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <TFile.h>
#include <TTree.h>
#include <TSystem.h>
#include <TFolder.h>
#include <TObjString.h>
#include <TROOT.h>
#include "Framework/Conventions/XmlParserStatus.h"
#include "Framework/Utils/XmlParserUtils.h"
#include "Framework/Conventions/GBuild.h"
#include "Framework/Conventions/Controls.h"
#include "Framework/Conventions/EnvSnapshot.h"
#include "Framework/Messenger/Messenger.h"
#include "Framework/Utils/AppInit.h"
#include "Framework/Utils/RunOpt.h"
#include "Framework/Utils/StringUtils.h"
#include "Framework/Utils/PrintUtils.h"
#include "Framework/Utils/SystemUtils.h"
#include "Framework/Utils/CmdLnArgParser.h"
#include "Framework/Algorithm/AlgConfigPool.h"
#include "Framework/Ntuple/NtpMCJobConfig.h"
#include "Framework/Registry/Registry.h"
Include dependency graph for gConfigDump.cxx:

Go to the source code of this file.

Functions

void GetCommandLineArgs (int argc, char **argv)
 
void Initialize (void)
 
void PrintSyntax (void)
 
int main (int argc, char **argv)
 

Function Documentation

void GetCommandLineArgs ( int  argc,
char **  argv 
)
void Initialize ( void  )

Definition at line 241 of file gConfigDump.cxx.

References genie::RunOpt::BuildTune(), genie::utils::app_init::CacheFile(), genie::RunOpt::Instance(), LOG, genie::utils::app_init::MesgThresholds(), and pFATAL.

Referenced by genie::Algorithm::Algorithm(), genie::flux::GAstroFlux::GAstroFlux(), genie::flux::GBGLRSAtmoFlux::GBGLRSAtmoFlux(), genie::flux::GCylindTH1Flux::GCylindTH1Flux(), genie::flux::GFLUKAAtmoFlux::GFLUKAAtmoFlux(), genie::flux::GHAKKMAtmoFlux::GHAKKMAtmoFlux(), genie::flux::GJPARCNuFlux::GJPARCNuFlux(), genie::flux::GNuMIFlux::GNuMIFlux(), genie::flux::GSimpleNtpFlux::GSimpleNtpFlux(), and main().

242 {
243 
244  if ( ! RunOpt::Instance()->Tune() ) {
245  LOG("gconfigdump", pFATAL) << " No TuneId in RunOption";
246  exit(-1);
247  }
248  RunOpt::Instance()->BuildTune();
249 
250  // Initialization of random number generators, cross-section table,
251  // messenger thresholds, cache file
252  utils::app_init::MesgThresholds(RunOpt::Instance()->MesgThresholdFiles());
253  utils::app_init::CacheFile(RunOpt::Instance()->CacheFile());
254 
255 }
#define pFATAL
Definition: Messenger.h:56
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
void MesgThresholds(string inpfile)
Definition: AppInit.cxx:99
void CacheFile(string inpfile)
Definition: AppInit.cxx:117
int main ( int  argc,
char **  argv 
)

Definition at line 94 of file gConfigDump.cxx.

References genie::AlgConfigPool::CommonList(), genie::AlgConfigPool::ConfigKeyList(), genie::AlgConfigPool::FindRegistry(), GetCommandLineArgs(), genie::Registry::GetStringDef(), genie::utils::xml::GetXMLFilePath(), genie::utils::xml::GetXMLPathList(), Initialize(), genie::AlgConfigPool::Instance(), genie::controls::kMCEnv, and genie::utils::str::Split().

95 {
96  GetCommandLineArgs(argc,argv);
97  Initialize();
98 
99  // throw on NaNs and Infs...
100 //#if defined(HAVE_FENV_H) && defined(HAVE_FEENABLEEXCEPT)
101 // feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
102 //#endif
103 
104 /*
105  Registry* rsub = new Registry;
106  rsub->Set("xyz",1234.);
107 
108  RgAlg ralg("Name","Config");
109 
110  Registry* rtop = new Registry;
111  rtop->Set("abc",9876.);
112  //rtop->Set("rsub",rsub);
113  rtop->Set("ralg",ralg);
114 
115  std::cout << *rtop << std::endl;
116  return 0;
117 */
118 
119  const string common_key_root = "Common";
120  // key,file
121  std::map<std::string,std::string> common_list; // e.g. CKM,Param
122  std::set<std::string> common_files;
123 
124 
125  // taken from NtpMCJobConfig
126  AlgConfigPool * algconf = AlgConfigPool::Instance();
127 
128  //TFolder* fConfig =
129  // gROOT->GetRootFolder()->AddFolder("gconfig","GENIE configs");
130 
131  const vector<string> & vconfkeys = algconf->ConfigKeyList();
132  vector<string>::const_iterator keyiter;
133 
134  for(keyiter = vconfkeys.begin(); keyiter != vconfkeys.end(); ++keyiter) {
135 
136  string key = *keyiter;
137  std::cout << "Registry key: " << key << std::endl;
138 
139  vector<string> vkey = utils::str::Split(key,"/");
140  assert(vkey.size()==2);
141  string alg_name = vkey[0];
142  string param_set = vkey[1];
143 
144  std::cout
145  << "alg_name: " << alg_name << ", param_set: " << param_set; // << std::endl;
146 
147  //if( !(fConfig->FindObject(alg_name.c_str())) ) {
148  // LOG("gconfigdump",pDEBUG) << "Adding new folder for alg: " << alg_name;
149  // fConfig->AddFolder(alg_name.c_str(), "");
150  //}
151  //TFolder * alg_folder = (TFolder *) fConfig->FindObject(alg_name.c_str());
152 
153  //LOG("gconfigdump",pDEBUG) << "Adding folder for param set: " << param_set;
154  //TFolder * config_folder = alg_folder->AddFolder(param_set.c_str(), "");
155 
156  //LOG("gconfigdump",pDEBUG) << "Accessing Registry & converting it to TFolder";
157  Registry * config_registry = algconf->FindRegistry(key);
158  //config_registry->CopyToFolder(config_folder);
159  std::cout << *config_registry;
160 
161  // pick out items that start with Common
162  for ( RgIMapConstIter it = config_registry->GetItemMap().begin();
163  it != config_registry->GetItemMap().end() ; ++it ) {
164  std::string keynm = it->first;
165  if ( keynm.find(common_key_root) == 0 ) {
166  // strip "Common" off key ... leave Param or Decay
167  std::string type = keynm.substr( common_key_root.size() );
168  //
169  std::string cpstr = config_registry->GetStringDef(keynm,"not-found",false);
170  if ( cpstr != "not-found") {
171  vector<std::string> cps = utils::str::Split(cpstr,",");
172  for (size_t i=0; i<cps.size(); ++i) {
173  common_list[cps[i]] = type;
174  common_files.insert(type);
175  }
176  }
177  }
178  }
179 
180  std::cout << std::endl;
181  }
182 
183  std::string xmlpaths = genie::utils::xml::GetXMLPathList();
184  std::cout << "GetXMLPathList returns: "; // << xmlpaths << std::endl;
185  vector<string> xmlpathlist = utils::str::Split(xmlpaths,":");
186  auto xmlpathitr = xmlpathlist.begin();
187  for ( ; xmlpathitr != xmlpathlist.end(); ++xmlpathitr) {
188  std::cout << std::endl << " " << *xmlpathitr;
189  }
190  std::cout << std::endl << std::endl;
191 
192 
193  Registry* common;
194 
195  std::set<std::string>::iterator typeitr = common_files.begin();
196  for ( ; typeitr != common_files.end(); ++typeitr ) {
197  std::string fname = std::string("Common") + *typeitr + std::string(".xml");
198  std::string commonpath = genie::utils::xml::GetXMLFilePath(fname);
199  std::cout << "using file " << commonpath << std::endl;
200 
201 
202  std::map<std::string,std::string>::iterator cpitr = common_list.begin();
203  for ( ; cpitr != common_list.end(); ++cpitr) {
204  if ( cpitr->second != *typeitr ) continue;
205  std::cout << "Common" << cpitr->second << " \"" << cpitr->first << "\"";
206 
207  common = algconf->CommonList(cpitr->second,cpitr->first);
208  if ( ! common ) {
209  std::cout << "\n\tno Common" << cpitr->second << " \"" << cpitr->first << "\"" << std::endl;
210  } else {
211  std::cout << *common;
212  }
213  }
214  std::cout << std::endl;
215  }
216 
217  common = algconf->CommonList("Param","Tunable");
218  if ( ! common ) {
219  std::cout << "no CommonParam \"Tunable\"" << std::endl;
220  } else {
221  std::cout << *common;
222  }
223 
224  std::cout << std::endl << std::endl;
225 
226  // taken from NtpMCJobEnv
227  unsigned int ivar = 0;
228  while ( kMCEnv[ivar] ) {
229  ostringstream entry;
230  string var = kMCEnv[ivar];
231  string value = (gSystem->Getenv(var.c_str()) ?
232  gSystem->Getenv(var.c_str()) : "UNDEFINED");
233 
234  std::cout << "$" << var << " ---> " << value << std::endl;
235  ivar++;
236  }
237 
238 
239 }
string GetXMLPathList(bool add_tune=true)
A singleton class holding all configuration registries built while parsing all loaded XML configurati...
Definition: AlgConfigPool.h:40
Registry * CommonList(const string &file_id, const string &set_name) const
map< RgKey, RegistryItemI * >::const_iterator RgIMapConstIter
Definition: Registry.h:49
static const char * kMCEnv[]
Definition: EnvSnapshot.h:24
string GetXMLFilePath(string basename)
void Initialize(void)
const vector< string > & ConfigKeyList(void) const
RgStr GetStringDef(RgKey key, RgStr def_opt, bool set_def=true)
Definition: Registry.cxx:540
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
Registry * FindRegistry(string key) const
void GetCommandLineArgs(int argc, char **argv)
Definition: gAtmoEvGen.cxx:563
void PrintSyntax ( void  )