GEMC  2.2
Geant4 Monte-Carlo Framework
text_parameters.cc
Go to the documentation of this file.
1 // gemc headers
2 #include "parameter_factory.h"
3 #include "text_parameters.h"
4 #include "string_utilities.h"
5 #include "utils.h"
6 
7 
9 {
10  string hd_msg = opts.optMap["LOG_MSG"].args + " TEXT Parameters: >> ";
11  double verbosity = opts.optMap["PARAMETER_VERBOSITY"].arg;
12 
13  map<string, double> GParameters; // parameters maps
14  // first check if there's at least one detector with MYSQL factory
16  return GParameters;
17 
18  // Looping over detectorConditionsMap for detector names
19  // To each detector is associated a material table and an opt properties table
20  for(map<string, detectorCondition>::iterator it=RC.detectorConditionsMap.begin(); it != RC.detectorConditionsMap.end(); it++)
21  {
22  if(it->second.get_factory() != factoryType)
23  continue;
24 
25  string dname = it->first;
26  string fname = dname + "__parameters";
27  string variation = get_variation(it->second.get_variation());
28 
29  if(verbosity)
30  cout << hd_msg << " Importing Parameters for Detector: " << dname << " with " << factoryType << " factory, variation " << variation << endl;
31 
32  fname += "_" + variation + ".txt";
33  ifstream IN(fname.c_str());
34  if(!IN)
35  {
36  // file doesn't exist for this system.
37  if(verbosity > 1)
38  cout << hd_msg << " Warning: failed to open " << fname << " for system: " << dname << ". Maybe the filename doesn't exist?" << endl;
39  continue;
40  }
41 
42  while(!IN.eof())
43  {
44  string dbline;
45  getline(IN, dbline);
46 
47  if(!dbline.size())
48  continue;
49 
50  gtable gt(get_strings(dbline, "|"));
51 
52  GParameters[gt.data[0]] = get_par_value(gt);
53 
54  if(verbosity > 1)
56  }
57 
58  IN.close();
59  }
60 
61  return GParameters;
62 }
vector< string > get_strings(string input)
returns a vector of strings from a stringstream, space is delimiter
int check_if_factory_is_needed(map< string, detectorCondition > dcon, string factory)
double get_par_value(gtable gt)
vector< string > data
Definition: utils.h:76
Definition: utils.h:65
double verbosity
string get_variation(string var)
parse variation name from string
map< string, detectorCondition > detectorConditionsMap
map< string, aopt > optMap
Options map.
Definition: options.h:71
map< string, double > loadParameters(goptions, runConditions)
void log_value(gtable gt, string factory)