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"

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 
)

Definition at line 258 of file gConfigDump.cxx.

259 {
260  LOG("gconfigdump", pINFO) << "Parsing command line arguments";
261 
262  // Common run options. Set defaults and read.
263  RunOpt::Instance()->EnableBareXSecPreCalc(true);
264  RunOpt::Instance()->ReadFromCommandLine(argc,argv);
265 
266  // Parse run options for this app
267 
268  CmdLnArgParser parser(argc,argv);
269 
270  // help?
271  bool help = parser.OptionExists('h');
272  if(help) {
273  PrintSyntax();
274  exit(0);
275  }
276 
277 
278  //
279  // print-out the command line options
280  //
281  LOG("gconfigdump", pNOTICE)
282  << "\n"
283  << utils::print::PrintFramedMesg("gconfigdump job configuration");
284  LOG("gconfigdump", pNOTICE) << "\n";
285 
286  LOG("gconfigdump", pNOTICE) << *RunOpt::Instance();
287 
288 }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pINFO
Definition: Messenger.h:62
void PrintSyntax(void)
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f='*')
Definition: PrintUtils.cxx:164
Command line argument parser.
#define pNOTICE
Definition: Messenger.h:61
void Initialize ( void  )

Definition at line 241 of file gConfigDump.cxx.

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.

95 {
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();
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 
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");
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 }
intermediate_table::iterator iterator
string GetXMLPathList(bool add_tune=true)
void GetCommandLineArgs(int argc, char **argv)
QList< Entry > entry
std::string string
Definition: nybbler.cc:12
A singleton class holding all configuration registries built while parsing all loaded XML configurati...
Definition: AlgConfigPool.h:40
intermediate_table::const_iterator const_iterator
Registry * CommonList(const string &file_id, const string &set_name) const
map< RgKey, RegistryItemI * >::const_iterator RgIMapConstIter
Definition: Registry.h:49
def key(type, name=None)
Definition: graph.py:13
static const char * kMCEnv[]
Definition: EnvSnapshot.h:24
string GetXMLFilePath(string basename)
void Initialize(void)
const vector< string > & ConfigKeyList(void) const
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
int var
Definition: 018_def.c:9
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
static QCString type
Definition: declinfo.cpp:672
Registry * FindRegistry(string key) const
QTextStream & endl(QTextStream &s)
void PrintSyntax ( void  )

Definition at line 290 of file gConfigDump.cxx.

291 {
292  LOG("gconfigdump", pNOTICE)
293  << "\n\n" << "Syntax:" << "\n"
294  << "\n gconfigdump [-h]"
295  << "\n [--event-generator-list list_name]"
296  << "\n [--tune G18_02a_00_000] (or your preferred tune identifier)"
297  << "\n";
298 }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pNOTICE
Definition: Messenger.h:61