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, photonEnergy, indexOfRefraction, ";
50 dbexecute +=
"absorptionLength, reflectivity, efficiency, fastcomponent, slowcomponent, ";
51 dbexecute +=
"scintillationyield, resolutionscale, fasttimeconstant, slowtimeconstant, yieldratio from " + tname;
52 dbexecute +=
" where variation ='" + variation +
"'";
56 if(!q.exec(dbexecute.c_str()))
58 cout << hd_msg <<
" Failed to execute MYSQL query " << dbexecute <<
". This is a fatal error. Exiting." << endl;
59 qDebug() << q.lastError();
65 cout <<
" ** WARNING: material for system \"" << dname <<
"\" not found with variation \"" << variation << endl << endl;
72 thisMat.density = q.value(2).toDouble();
73 thisMat.ncomponents = q.value(3).toInt();
74 thisMat.componentsFromString(
qv_tostring(q.value(4)));
75 thisMat.opticalsFromString(
qv_tostring( q.value(5)),
"photonEnergy");
76 thisMat.opticalsFromString(
qv_tostring( q.value(6)),
"indexOfRefraction");
77 thisMat.opticalsFromString(
qv_tostring( q.value(7)),
"absorptionLength");
78 thisMat.opticalsFromString(
qv_tostring( q.value(8)),
"reflectivity");
79 thisMat.opticalsFromString(
qv_tostring( q.value(9)),
"efficiency");
82 thisMat.opticalsFromString(
qv_tostring( q.value(10)),
"fastcomponent");
83 thisMat.opticalsFromString(
qv_tostring( q.value(11)),
"slowcomponent");
84 thisMat.scintillationyield = q.value(12).toDouble();
85 thisMat.resolutionscale = q.value(13).toDouble();
86 thisMat.fasttimeconstant = q.value(14).toDouble();
87 thisMat.slowtimeconstant = q.value(15).toDouble();
88 thisMat.yieldratio = q.value(16).toDouble();
89 thisMat.opticalsFromString(
qv_tostring( q.value(17)),
"rayleigh");
91 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.