NtpMCJobConfig.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 <cassert>
18 #include <vector>
19 #include <string>
20 
21 #include <TROOT.h>
22 #include <TFolder.h>
23 #include <TObjString.h>
24 
30 
31 using std::vector;
32 using std::string;
33 using namespace genie;
34 
36 
37 //____________________________________________________________________________
39 {
40  fConfig = 0;
41 }
42 //____________________________________________________________________________
44 {
45 
46 }
47 //____________________________________________________________________________
48 TFolder * NtpMCJobConfig::Load(void)
49 {
50  if (fConfig) delete fConfig;
51  fConfig = 0;
52 
53  LOG("Ntp", pNOTICE)
54  << "Converting configuration registries to TFolders";
55 
56  fConfig = gROOT->GetRootFolder()->AddFolder("gconfig","GENIE configs");
57  gROOT->GetListOfBrowsables()->Add(fConfig,"gconfig");
58 
60 
61  const vector<string> & vconfkeys = algconf->ConfigKeyList();
62  vector<string>::const_iterator keyiter;
63 
64  for(keyiter = vconfkeys.begin(); keyiter != vconfkeys.end(); ++keyiter) {
65 
66  string key = *keyiter;
67 
68  LOG("Ntp",pDEBUG) << "Current configuration registry key" << key;
69 
70  vector<string> vkey = utils::str::Split(key,"/");
71  assert(vkey.size()==2);
72  string alg_name = vkey[0];
73  string param_set = vkey[1];
74 
75  LOG("Ntp",pDEBUG)
76  << "alg_name: " << alg_name << ", param_set: " << param_set;
77 
78  if( !(fConfig->FindObject(alg_name.c_str())) ) {
79  LOG("Ntp",pDEBUG) << "Adding new folder for alg: " << alg_name;
80  fConfig->AddFolder(alg_name.c_str(), "");
81  }
82  TFolder * alg_folder = (TFolder *) fConfig->FindObject(alg_name.c_str());
83 
84  LOG("Ntp",pDEBUG) << "Adding folder for param set: " << param_set;
85  TFolder * config_folder = alg_folder->AddFolder(param_set.c_str(), "");
86 
87  LOG("Ntp",pDEBUG) << "Accessing Registry & converting it to TFolder";
88  Registry * config_registry = algconf->FindRegistry(key);
89  config_registry->CopyToFolder(config_folder);
90  }
91 
92  return fConfig;
93 }
94 //____________________________________________________________________________
Stores the GENIE configuration in ROOT TFolders along with the output event tree. ...
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
A singleton class holding all configuration registries built while parsing all loaded XML configurati...
Definition: AlgConfigPool.h:41
ClassImp(NtpMCJobConfig) NtpMCJobConfig
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
const vector< string > & ConfigKeyList(void) const
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:42
TFolder * Load(void)
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:66
assert(nhit_max >=nhit_nbins)
Registry * FindRegistry(string key) const
#define pNOTICE
Definition: Messenger.h:62
void CopyToFolder(TFolder *folder) const
Definition: Registry.cxx:641
static AlgConfigPool * Instance()
#define pDEBUG
Definition: Messenger.h:64