NtpMCJobConfig.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2020, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5 
6  Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
7  University of Liverpool & STFC Rutherford Appleton Laboratory
8 */
9 //____________________________________________________________________________
10 
11 #include <cassert>
12 #include <vector>
13 #include <string>
14 
15 #include <TROOT.h>
16 #include <TFolder.h>
17 #include <TObjString.h>
18 
24 
25 using std::vector;
26 using std::string;
27 using namespace genie;
28 
30 
31 //____________________________________________________________________________
33 {
34  fConfig = 0;
35 }
36 //____________________________________________________________________________
38 {
39 
40 }
41 //____________________________________________________________________________
42 TFolder * NtpMCJobConfig::Load(void)
43 {
44  if (fConfig) delete fConfig;
45  fConfig = 0;
46 
47  LOG("Ntp", pNOTICE)
48  << "Converting configuration registries to TFolders";
49 
50  fConfig = gROOT->GetRootFolder()->AddFolder("gconfig","GENIE configs");
51  gROOT->GetListOfBrowsables()->Add(fConfig,"gconfig");
52 
54 
55  const vector<string> & vconfkeys = algconf->ConfigKeyList();
57 
58  for(keyiter = vconfkeys.begin(); keyiter != vconfkeys.end(); ++keyiter) {
59 
60  string key = *keyiter;
61 
62  LOG("Ntp",pDEBUG) << "Current configuration registry key" << key;
63 
64  vector<string> vkey = utils::str::Split(key,"/");
65  assert(vkey.size()==2);
66  string alg_name = vkey[0];
67  string param_set = vkey[1];
68 
69  LOG("Ntp",pDEBUG)
70  << "alg_name: " << alg_name << ", param_set: " << param_set;
71 
72  if( !(fConfig->FindObject(alg_name.c_str())) ) {
73  LOG("Ntp",pDEBUG) << "Adding new folder for alg: " << alg_name;
74  fConfig->AddFolder(alg_name.c_str(), "");
75  }
76  TFolder * alg_folder = (TFolder *) fConfig->FindObject(alg_name.c_str());
77 
78  LOG("Ntp",pDEBUG) << "Adding folder for param set: " << param_set;
79  TFolder * config_folder = alg_folder->AddFolder(param_set.c_str(), "");
80 
81  LOG("Ntp",pDEBUG) << "Accessing Registry & converting it to TFolder";
82  Registry * config_registry = algconf->FindRegistry(key);
83  config_registry->CopyToFolder(config_folder);
84  }
85 
86  return fConfig;
87 }
88 //____________________________________________________________________________
Stores the GENIE configuration in ROOT TFolders along with the output event tree. ...
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
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
struct vector vector
intermediate_table::const_iterator const_iterator
ClassImp(NtpMCJobConfig) NtpMCJobConfig
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
def key(type, name=None)
Definition: graph.py:13
const vector< string > & ConfigKeyList(void) const
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
TFolder * Load(void)
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
Registry * FindRegistry(string key) const
#define pNOTICE
Definition: Messenger.h:61
void CopyToFolder(TFolder *folder) const
Definition: Registry.cxx:626
static AlgConfigPool * Instance()
#define pDEBUG
Definition: Messenger.h:63