GVldContext.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 <algorithm>
12 
18 
19 using std::count;
20 
21 using namespace genie;
22 
23 //___________________________________________________________________________
24 namespace genie {
25  ostream & operator<< (ostream& stream, const GVldContext & vldc)
26  {
27  vldc.Print(stream);
28  return stream;
29  }
30 }
31 //___________________________________________________________________________
33 {
34  this->Init();
35 }
36 //___________________________________________________________________________
38 {
39 
40 }
41 //___________________________________________________________________________
42 void GVldContext::Decode(string encoded_vld_context)
43 {
44 //Example:
45 // energy:0-100;
46 
47  string vldc = utils::str::ToUpper(encoded_vld_context);
48 
49  // set defauts for missing entries
51  const Registry * gc = confp->CommonList("Param", "Validation");
52 
53  if(vldc.find("ENERGY") == string::npos) {
54  fEmin = gc->GetDouble("GVLD-Emin");
55  fEmax = gc->GetDouble("GVLD-Emax");
56  }
57 
58  LOG("VldContext", pDEBUG) << "Validity context: " << vldc;
59 
60  vector<string> fields = utils::str::Split(vldc, ";");
61  if(fields.size()==0) return;
62 
64 
65  for(field_iter = fields.begin(); field_iter != fields.end(); ++field_iter){
66 
67  string curr_field = *field_iter;
68  SLOG("VldContext", pINFO) << " ************ " << curr_field;
69  if(curr_field.size()==0) continue;
70 
71  vector<string> curr_fieldv = utils::str::Split(curr_field, ":");
72  assert(curr_fieldv.size() == 2);
73 
74  string name = curr_fieldv[0];
75  string values = curr_fieldv[1];
76 
77  //-- send the string to an appropriate decoder
78  if (name.find("ENERGY") != string::npos) DecodeENERGY (values);
79  else {
80  SLOG("VldContext", pWARN)
81  << "**** Unknown field named: " << name << " in vld context";
82  }
83  }
84 }
85 //___________________________________________________________________________
86 void GVldContext::DecodeENERGY(string encoded_energy)
87 {
88  SLOG("VldContext", pDEBUG) << "Decoding energy range: " << encoded_energy;
89 
90  vector<string> energy = utils::str::Split(encoded_energy, "-");
91  assert (energy.size() == 2);
92  fEmin = atof( energy[0].c_str() );
93  fEmax = atof( energy[1].c_str() );
94 }
95 //___________________________________________________________________________
97 {
98  fEmin = -1.0;
99  fEmax = -1.0;
100 }
101 //___________________________________________________________________________
102 void GVldContext::Print(ostream & stream) const
103 {
104  stream << "Energy range:..." << "[" << fEmin << ", " << fEmax << "]";
105  stream << "\n";
106 }
107 //___________________________________________________________________________
static QCString name
Definition: declinfo.cpp:673
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
A singleton class holding all configuration registries built while parsing all loaded XML configurati...
Definition: AlgConfigPool.h:40
void Print(ostream &stream) const
intermediate_table::const_iterator const_iterator
RgDbl GetDouble(RgKey key) const
Definition: Registry.cxx:474
Registry * CommonList(const string &file_id, const string &set_name) const
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
void DecodeENERGY(string encoded_values)
Definition: GVldContext.cxx:86
#define pINFO
Definition: Messenger.h:62
Q_UINT16 values[128]
#define pWARN
Definition: Messenger.h:60
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
string ToUpper(string input)
Definition: StringUtils.cxx:92
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
Validity Context for an Event Generator.
Definition: GVldContext.h:37
static AlgConfigPool * Instance()
#define pDEBUG
Definition: Messenger.h:63
void Decode(string encoded_values)
Definition: GVldContext.cxx:42