GEMC  2.3
Geant4 Monte-Carlo Framework
utils.h
Go to the documentation of this file.
1 
6 #ifndef utils_H
7 #define utils_H
8 
9 // Qt headers
10 #include <QtSql>
11 #include <QtWidgets>
12 
13 // C++ headers
14 #include <iostream>
15 #include <string>
16 using namespace std;
17 
18 // G4 headers
19 #include "G4ThreeVector.hh"
20 #include "G4RotationMatrix.hh"
21 #include "G4Colour.hh"
22 
23 // gemc headers
24 #include "string_utilities.h"
25 #include "options.h"
26 
27 
29 {
30  public:
32 
33  bool qt;
34  double verbosity;
35  string header;
36 
37  QPixmap *splash_i ;
38  QSplashScreen *splash ;
39 
40 
41  public:
42  void message(string);
43 
44  ~gui_splash();
45 };
46 
47 // merging two <string, string>
48 void mergeMaps(map<string, string>& lhs, const map<string, string>& rhs);
49 
50 
51 // calculate rotation matrix from input string (MYSQL version)
52 G4RotationMatrix calc_rotation(string, string);
53 
54 // calculate shift from input string (MYSQL version)
55 G4ThreeVector calc_position(string);
56 
57 
58 // returns a G4Colour from a string
59 G4Colour gcol(string);
60 
61 
62 // utility class used as interface between the various factories
63 // and the gemc classes
64 // All leading and trailing spaces are removed
65 class gtable
66 {
67  public:
68  gtable(vector<string> d)
69  {
70  for(unsigned int i=0; i<d.size(); i++)
71  data.push_back(TrimSpaces(d[i]));
72  }
73  gtable(){data.clear();}
74  ~gtable(){;}
75 
76  vector<string> data;
77 
78  void add_data(QVariant input)
79  {
80  data.push_back(TrimSpaces(qv_tostring(input)));
81  }
82 
83  void add_data(string input)
84  {
85  data.push_back(TrimSpaces(input));
86  }
87 
88 
89  // Overloaded "<<" for gtable class. Dumps infos on screen.
90  friend ostream &operator<<(ostream &stream, gtable);
91 
92 };
93 
94 // gets last id from table, variation, run number
95 int getLastId(QSqlDatabase db, string t, string v, int r);
96 
97 // open and close gemc mysql database
98 QSqlDatabase openGdb(goptions);
99 void closeGdb(QSqlDatabase db);
100 
101 
102 // returns a map of files (name is key) and their types (value)
103 map<string, string> getFilesInDirectory(string);
104 
105 
106 // if an attributeNode exists, return its value
107 // otherwise assign a default value
108 string assignAttribute(QDomElement e, string attribute, string defaultValue);
109 
110 // attention: when using a default value of "0" instead of "0.0" it
111 // can return an integer.
112 int assignAttribute(QDomElement e, string attribute, int defaultValue);
113 double assignAttribute(QDomElement e, string attribute, double defaultValue);
114 
115 // returns a string with the current time
116 string timeStamp();
117 
118 // returns value + best units as a string
119 string bestValueUnits(double, string);
120 
121 // convert a vector of int into a vector of double
122 vector<double> convertVintVdouble(vector<int> input);
123 
124 #endif
125 
126 
127 
128 
129 
map< string, string > getFilesInDirectory(string)
Definition: utils.cc:262
QSplashScreen * splash
Definition: utils.h:38
double verbosity
Definition: utils.h:34
string bestValueUnits(double, string)
Definition: utils.cc:333
void add_data(string input)
Definition: utils.h:83
G4Colour gcol(string)
Definition: utils.cc:165
ostream & operator<<(ostream &stream, detector Detector)
Definition: detector.cc:1119
vector< string > data
Definition: utils.h:76
Definition: utils.h:65
STL namespace.
~gtable()
Definition: utils.h:74
string timeStamp()
Definition: utils.cc:318
string qv_tostring(QVariant input)
void add_data(QVariant input)
Definition: utils.h:78
int getLastId(QSqlDatabase db, string t, string v, int r)
Definition: utils.cc:188
void mergeMaps(map< string, string > &lhs, const map< string, string > &rhs)
Definition: utils.cc:75
G4RotationMatrix calc_rotation(string, string)
Definition: utils.cc:85
QSqlDatabase openGdb(goptions)
Definition: utils.cc:218
bool qt
Definition: utils.h:33
gtable(vector< string > d)
Definition: utils.h:68
void closeGdb(QSqlDatabase db)
Definition: utils.cc:252
string header
Definition: utils.h:35
string assignAttribute(QDomElement e, string attribute, string defaultValue)
Definition: utils.cc:294
vector< double > convertVintVdouble(vector< int > input)
Definition: utils.cc:362
string TrimSpaces(string in)
Removes leading and trailing spaces.
gtable()
Definition: utils.h:73
G4ThreeVector calc_position(string)
Definition: utils.cc:149
QPixmap * splash_i
Definition: utils.h:37