11 #include "G4Element.hh" 12 #include "G4NistManager.hh" 13 #include "G4OpBoundaryProcess.hh" 19 string hd_msg = opts.
optMap[
"LOG_MSG"].args +
" MYSQL Materials Factory: >> ";
22 map<string, material> mymats;
29 QSqlDatabase db =
openGdb(opts);
36 if(it->second.get_factory() !=
"MYSQL")
40 cout << hd_msg <<
" Initializing " << it->second.get_factory() <<
" for detector " << it->first << endl;
43 string dname = it->first ;
44 string tname = dname +
"__materials";
49 string dbexecute =
"select name, description, density, ncomponents, components from " + tname;
50 dbexecute +=
" where variation ='" + variation +
"'";
54 if(!q.exec(dbexecute.c_str()))
56 cout << hd_msg <<
" Failed to execute MYSQL query " << dbexecute <<
". This is a fatal error. Exiting." << endl;
57 qDebug() << q.lastError();
63 cout <<
" ** WARNING: material for system \"" << dname <<
"\" not found with variation \"" << variation << endl << endl;
70 thisMat.density = q.value(2).toDouble();
71 thisMat.ncomponents = q.value(3).toInt();
72 thisMat.componentsFromString(
qv_tostring(q.value(4)));
73 thisMat.opticalsFromString(
qv_tostring( q.value(5)),
"photonEnergy");
74 thisMat.opticalsFromString(
qv_tostring( q.value(6)),
"indexOfRefraction");
75 thisMat.opticalsFromString(
qv_tostring( q.value(7)),
"absorptionLength");
76 thisMat.opticalsFromString(
qv_tostring( q.value(8)),
"reflectivity");
77 thisMat.opticalsFromString(
qv_tostring( q.value(9)),
"efficiency");
79 mymats[thisMat.name] = thisMat;
int check_if_factory_is_needed(map< string, detectorCondition > dcon, string factory)
void closeGdb(QSqlDatabase db)
QSqlDatabase openGdb(goptions gemcOpt)
map< string, G4Material * > materialsFromMap(map< string, material >)
string get_variation(string var)
parse variation name from string
string qv_tostring(QVariant input)
map< string, detectorCondition > detectorConditionsMap
void printMaterials(map< string, G4Material * > matMap)
map< string, aopt > optMap
Options map.
bool is_main_variation(string var)
returns 1 if the string "main:" is found on the input
map< string, G4Material * > initMaterials(runConditions, goptions)
string TrimSpaces(string in)
Removes leading and trailing spaces.