3#include "BmnNewFieldMap.h"
33 return (access(name, F_OK) != -1);
38 return std::tolower(
static_cast<unsigned char>(a)) == std::tolower(
static_cast<unsigned char>(b));
43static int FieldToInt(
const char* field,
int defaultValue = 0)
48 long value = strtol(field, &end, 10);
49 return (end == field) ? defaultValue :
static_cast<int>(value);
52static uint64_t
FieldToUInt64(
const char* field, uint64_t defaultValue = 0)
57 unsigned long long value = strtoull(field, &end, 10);
58 return (end == field) ? defaultValue :
static_cast<uint64_t
>(value);
66 double value = strtod(field, &end);
67 return (end == field) ? defaultValue : value;
76 if (!std::isalnum(
static_cast<unsigned char>(c)) && c !=
'_' && c !=
'.' && c !=
'-')
86 escaped.reserve(value.size());
87 for (
char c : value) {
104 unsigned long int serverRev = 0;
108 std::ifstream myFile_Handler;
110 myFile_Handler.open(fileName.
Data());
111 if (myFile_Handler.is_open()) {
113 while (getline(myFile_Handler, myLine)) {
114 serverRev = strtoul(myLine.c_str(), &ptr, 10);
117 myFile_Handler.close();
118 std::remove(fileName.
Data());
133 string message =
"Setup not found for pattern: " + std::string(pattern);
134 LOG(error) << message;
135 throw std::invalid_argument(message);
139 std::pair<int, string> res = std::make_pair<int, string>(0,
"");
142 std::string pattern(pattern_tag);
144 LOG(error) <<
"ERROR: the setup tag pattern contains forbidden characters: `" << pattern <<
"`";
149 std::remove(fileName.
Data());
151 url, pattern.c_str());
153 std::ifstream myFile_Handler;
155 myFile_Handler.open(fileName.
Data());
156 if (myFile_Handler.is_open()) {
157 getline(myFile_Handler, myLine);
158 myFile_Handler.close();
160 std::remove(fileName.
Data());
161 std::size_t found = myLine.find(
";");
162 if (found == std::string::npos) {
165 vector<string> results;
166 istringstream f(myLine);
168 while (getline(f, token,
':')) {
169 results.push_back(token);
171 if (results.size() != 3)
173 res = std::make_pair<int, string>(1, results[0].c_str());
184 std::ifstream myFile_Handler;
186 std::string sTag(setup_tag);
187 myFile_Handler.open(fileName.
Data());
188 if (myFile_Handler.is_open()) {
189 while (getline(myFile_Handler, myLine)) {
190 istringstream f(myLine);
192 while (getline(f, s,
';')) {
193 vector<string> results;
195 std::istringstream input;
197 while (getline(input, token,
':')) {
198 results.push_back(token);
200 if (results.size() < 2)
202 std::string tag = results[0];
203 std::string status = results[1];
205 if (results.size() > 2) {
209 bool bb = std::equal(tag.begin(), tag.end(), sTag.begin(), sTag.end(),
ichar_equals);
210 if (tag.size() == sTag.size() && bb) {
211 myFile_Handler.close();
212 std::remove(fileName.
Data());
213 return std::make_pair(
FieldToInt(status.c_str(), -1), upTime);
218 myFile_Handler.close();
219 std::remove(fileName.
Data());
221 return std::make_pair(retval, 0);
226 std::pair<int, string> res = std::make_pair<int, string>(0,
"");
228 std::ostringstream stringStream;
229 stringStream <<
"sqlite://" << localDbPath;
231 stringStream.str(
"");
233 stringStream <<
"SELECT setup_tag, status, creation_date FROM setup where status=1 and setup_tag like '"
234 <<
SqlEscape(pattern_tag) <<
"%' order by creation_date DESC limit 1;";
239 const char* name = row->
GetField(0);
241 res = std::make_pair<int, string>(1, name);
250 unsigned long int localRev = 0;
253 std::ostringstream stringStream;
254 stringStream <<
"sqlite://" << localDbPath;
256 stringStream.str(
"");
258 stringStream <<
"select value_field from config where key_field='config_time';";
264 const char* ch_time = row->
GetField(0);
267 localRev = strtoul(ch_time, &ptr, 10);
278 return (access(path, W_OK | X_OK) == 0);
303 const char* env_p = getenv(
"DBL_CACHE_PATH");
304 if (env_p !=
nullptr) {
306 if (
gSystem->ExpandPathName(baseDir)) {
307 LOG(error) <<
"Cannot expand the DBL_CACHE_PATH value: " << env_p;
311 const char* tmp_p = getenv(
"TMPDIR");
320 LOG(error) <<
"ERROR: cannot create the folder for the geometry database: " << dirName;
324 LOG(error) <<
"ERROR: the folder for the geometry database is not writable: " << dirName;
335 if (localDbPath ==
"") {
337 <<
"DBL_FILE_PATH is not set. Please, set DBL_FILE_PATH as a path to the local database file (default, "
343 gSystem->GetPathInfo(localDbPath.
Data(), file_stat);
346 <<
"DBL_FILE_PATH is a path to a folder. Please, set DBL_FILE_PATH as a path to the local database file "
347 "(default, 'local.db')"
355 bool isMovedDb =
false;
357 if (
gSystem->mkdir(dirName,
true) != 0) {
358 LOG(error) <<
"ERROR: cannot create folder: " << dirName << endl;
364 LOG(info) <<
"The directory of the Local Geometry Database is read-only: " << dirName
365 <<
". The database will be installed to a writable directory";
367 if (writableDir.
Length() == 0)
375 dirName = writableDir;
376 fileName =
"local.db";
377 localDbPath = dirName +
"/" + fileName;
383 if (setup_tag.size() == 0)
384 command =
TString::Format(
"wget -O %s \"%s/download_file.php?type=all&tag=all\" > /dev/null 2>&1",
385 tarName.
Data(), url);
387 std::string tag(setup_tag);
389 LOG(error) <<
"ERROR: the setup tag contains forbidden characters: `" << tag <<
"`";
392 command =
TString::Format(
"wget -O %s \"%s/download_file.php?type=s&tag=%s&rev=1\" > /dev/null 2>&1",
393 tarName.
Data(), url, tag.c_str());
397 LOG(error) <<
"ERROR: downloading the geometry database file failed, please, check url: " << url << endl;
401 if (file_stat.
fSize == 0) {
402 LOG(error) <<
"ERROR: downloaded geometry database file has 0 size, please, check url: " << url << endl;
411 if (tarResult != 0) {
412 LOG(error) <<
"ERROR: cannot unpack the geometry database archive to the directory: " << dirName << endl;
415 if (fileName !=
"local.db") {
422 LOG(error) <<
"ERROR: no database file found after unpacking the archive: " << localDbPath << endl;
430 gSystem->Setenv(
"DBL_FILE_PATH", localDbPath.
Data());
434 gSystem->Setenv(
"DBL_FILE_PATH", previousDbPath.
Data());
437 LOG(info) <<
"The Local Geometry Database was successfully installed to the directory: " << dirName << endl;
445 if (
m_db !=
nullptr) {
464 if (fPath.size() == 0) {
465 LOG(error) <<
"Please, set DBL_FILE_PATH environment variable before using the Geometry Database";
469 LOG(error) <<
"No Database found in " << fPath;
472 ostringstream stringStream;
473 stringStream <<
"sqlite://" << fPath;
475 LOG(debug1) <<
"Connecting the Local Geometry Database at path: " << stringStream.str().c_str();
479 LOG(error) <<
"Cannot load detector geometry, please, check DBL_FILE_PATH environment variable";
483 LOG(error) <<
"Cannot load detector geometry, please, check DBL_FILE_PATH environment variable";
496 int removedCount = 0;
498 if (volume->IsAssembly() && shapes->
Remove(volume->GetShape()) !=
nullptr)
502 if (removedCount > 0) {
504 LOG(info) << removedCount <<
" assembly shapes were removed from the list of shapes of the geometry";
515 LOG(error) <<
"Please, set DBL_FILE_PATH environment variable before using the Geometry Database";
523 ostringstream stringStream;
526 stringStream <<
"select setup_id,status,material_id,field_id,file_name,modified_date from setup where "
527 "lower(setup_tag)=lower('"
528 << tag <<
"') order by creation_date desc;";
530 uint64_t sUpTime = 0;
531 std::pair<int, uint64_t> status;
536 resQ =
m_db->Query(stringStream.str().c_str());
537 if (resQ ==
nullptr) {
539 stringStream.str(
"");
540 stringStream <<
"select setup_id,status,material_id,field_id,file_name, creation_date from setup where "
541 "lower(setup_tag)=lower('"
542 << tag <<
"') order by creation_date desc;";
543 resQ =
m_db->Query(stringStream.str().c_str());
545 LOG(error) <<
"SQL query was failed while searching the given tag: `" << setup_tag
546 <<
"`. Setup will download from server.";
552 if (row !=
nullptr) {
559 if (row ==
nullptr || (sStatus == 0 && status.second > sUpTime)) {
560 LOG(error) <<
"No geometry setup found in the local database for `" << setup_tag <<
"` tag.";
563 if (row !=
nullptr) {
567 if (status.first >= 0) {
569 if (status.first == 1) {
570 LOG(info) <<
"Approved geometry setup found on the geometry server:`" <<
GEO_SERVER_HOST
571 <<
"`. Downloading...";
574 LOG(info) <<
"Not approved geometry setup found on the geometry server:`" <<
GEO_SERVER_HOST
580 stringStream.str(
"");
582 <<
"select setup_id,status,material_id,field_id,file_name from setup where lower(setup_tag)=lower('"
583 << tag <<
"') order by creation_date desc;";
584 resQ =
m_db->Query(stringStream.str().c_str());
586 LOG(error) <<
"SQL query was failed while searching the given tag: `" << setup_tag <<
"`";
590 LOG(error) <<
"Cannot download the geometry setup from the server:`" <<
GEO_SERVER_HOST <<
"`.";
594 LOG(error) <<
"No geometry setup found on the geometry server:`" <<
GEO_SERVER_HOST <<
"`.";
595 if (row ==
nullptr) {
596 LOG(error) <<
"The geometry setup `" << setup_tag <<
"` is absent in the Geometry Database";
611 if (geoFileField.
IsNull()) {
612 LOG(error) <<
"The geometry setup `" << setup_tag
613 <<
"` has no ROOT file with the full geometry in the Geometry Database";
618 TFile* geoFile =
new TFile(geoFileName,
"READ");
620 LOG(error) <<
"ERROR: could not open ROOT file with geometry: " + geoFileName;
628 LOG(error) <<
"ERROR: TGeoManager is not top element in geometry file " + geoFileName;
645 if (localSettings !=
nullptr) {
647 TString localSettingsPath(localSettings);
648 gSystem->ExpandPathName(localSettingsPath);
691 ostringstream stringStream;
695 <<
"select setup_id,status,material_id,field_id,modified_date from setup where lower(setup_tag)=lower('" << tag
696 <<
"') order by creation_date desc;";
701 LOG(debug1) << stringStream.str().c_str();
703 uint64_t sUpTime = 0;
704 std::pair<int, uint64_t> status;
706 resQ =
m_db->Query(stringStream.str().c_str());
707 if (resQ ==
nullptr) {
709 stringStream.str(
"");
711 <<
"select setup_id,status,material_id,field_id,creation_date from setup where lower(setup_tag)=lower('"
712 << tag <<
"') order by creation_date desc;";
713 resQ =
m_db->Query(stringStream.str().c_str());
715 LOG(error) <<
"SQL query was failed while searching the given tag: `" << setup_tag
716 <<
"`. Setup will download from server.";
723 if (row !=
nullptr) {
730 if (row ==
nullptr || (sStatus == 0 && status.second > sUpTime)) {
731 LOG(error) <<
"No geometry setup found in the local database for `" << setup_tag <<
"` tag." << status.first;
734 if (status.first >= 0) {
736 if (status.first == 1) {
737 LOG(info) <<
"Approved geometry setup found on the geometry server:`" <<
GEO_SERVER_HOST
738 <<
"`. Downloading...";
741 LOG(info) <<
"Not approved geometry setup found on the geometry server:`" <<
GEO_SERVER_HOST
742 <<
"`. Downloading...";
747 stringStream.str(
"");
749 <<
"select setup_id,status,material_id,field_id,file_name from setup where lower(setup_tag)=lower('"
750 << tag <<
"') order by creation_date desc;";
752 resQ =
m_db->Query(stringStream.str().c_str());
754 LOG(error) <<
"SQL query was failed while searching the given tag: `" << setup_tag <<
"`";
758 LOG(error) <<
"Cannot download the geometry setup from the server:`" <<
GEO_SERVER_HOST <<
"`.";
762 LOG(error) <<
"No geometry setup found on the geometry server:`" <<
GEO_SERVER_HOST <<
"`.";
763 if (row ==
nullptr) {
764 LOG(error) <<
"The geometry setup `" << setup_tag <<
"` is absent in the Geometry Database";
770 if (fRun ==
nullptr) {
772 LOG(info) <<
"New FairRunSim instance has been created";
782 stringStream.str(
"");
783 stringStream <<
"select matag,file_name from material where material_id=" << idma <<
";";
784 resQ =
m_db->Query(stringStream.str().c_str());
787 LOG(info) <<
"Materials were not found";
817 LOG(info) <<
"Materials were not found";
819 const char* materialFile = row->
GetField(1);
820 TString in = (materialFile !=
nullptr ? materialFile :
"");
821 fRun->SetMaterials(in.
Data());
832 LOG(info) <<
"Load geometry with tag=" << setup_tag <<
" from database";
833 LOG(debug1) <<
"setup_id = " <<
m_sid <<
"; material_id = " << idma <<
"; filed_id = " <<
m_fid << endl;
834 stringStream.str(
"");
835 stringStream <<
"select setup_module_id from sms where setup_id=" <<
m_sid <<
";";
836 resQ =
m_db->Query(stringStream.str().c_str());
838 LOG(error) <<
"ERROR: no modules found";
841 while ((row = resQ->
Next()) !=
nullptr) {
842 stringStream.str(
"");
843 const char* idsm = row->
GetField(0);
845 LOG(debug1) <<
"module=" << idsmI << std::endl;
849 LOG(error) <<
"ERROR: no file for the setup module " << idsmI <<
" was found";
883 if (
m_db ==
nullptr) {
884 LOG(error) <<
"Geometry Database is not loaded";
888 LOG(debug1) <<
"Selected Geometry Database has no magnetic field";
893 ostringstream stringStream;
894 stringStream <<
"select file_name,scale,x,y,z from field where field_id=" <<
m_fid <<
";";
896 if (resQ ==
nullptr) {
897 LOG(error) <<
"SQL query was failed while searching magnetic field for id: `" <<
m_fid <<
"`";
901 LOG(error) <<
"ERROR: no selected magnetic field in the Geometry Database for id=" <<
m_fid;
907 if (row ==
nullptr) {
908 LOG(error) <<
"ERROR: no selected magnetic field in the Geometry Database for id=" <<
m_fid;
913 stringStream.str(
"");
921 pBmnNewFieldMap->
SetFileName(stringStream.str().c_str());
936 LOG(error) <<
"Detector name for the parameter file is not set";
939 if (
m_db ==
nullptr) {
940 LOG(error) <<
"The Geometry Database is not connected";
947 LOG(error) <<
"The detector name \'" << sname <<
"\'does not exist in the Geometry Database";
950 LOG(debug1) <<
"The detector name \'" << sname <<
"\'exists in the Geometry Database";
952 ostringstream stringStream;
954 <<
"select sm.fpar from sms s INNER JOIN setup_module sm on s.idsm=sm.idsm INNER JOIN file f on sm.idf=f.idf "
955 "INNER JOIN module_revision mr on f.idm=mr.idmr where idsd="
956 <<
m_sid <<
" and mr.idm=" << index <<
";";
957 LOG(debug1) <<
"Request \'" << stringStream.str().c_str() <<
"\'.";
959 if (resQ ==
nullptr) {
960 LOG(info) <<
"SQL query was failed while searching parameter file for detector `" << sname <<
"`";
964 if (row ==
nullptr) {
965 LOG(info) <<
"Parameter file for detector `" << sname <<
"` not found";
971 const char* file = row->
GetField(0);
972 string parameterFile = (file !=
nullptr ? file :
"");
976 if (parameterFile.empty()) {
977 LOG(info) <<
"Parameter file for detector `" << sname <<
"` does not exist in the Geometry Database";
981 return parameterFile;
993 LOG(error) <<
"The geometry setup is not loaded";
996 if (
m_db ==
nullptr) {
997 LOG(error) <<
"The Geometry Database is not connected";
1001 ostringstream stringStream;
1002 stringStream <<
"select m.file_name from setup s INNER JOIN material m on m.material_id=s.material_id where "
1006 if (resQ ==
nullptr) {
1007 LOG(info) <<
"SQL query was failed while searching the material file of the setup";
1011 if (row ==
nullptr) {
1012 LOG(info) <<
"Material file of the setup was not found in the Geometry Database";
1018 const char* file = row->
GetField(0);
1029 const char* env_p = getenv(
"DBL_FILE_PATH");
1030 if (env_p ==
nullptr) {
1031 LOG(debug1) <<
"DBL_FILE_PATH environment variable is not set";
1037 if (
gSystem->ExpandPathName(path)) {
1038 LOG(error) <<
"Cannot expand the DBL_FILE_PATH value: " << env_p;
1042 return string(path.Data());
1049 if (rootPath.empty())
1053 if (stat(rootPath.c_str(), &st) == 0)
1054 if (!S_ISDIR(st.st_mode)) {
1056 rootPath = dirName.
Data();
1059 rootPath +=
"/storage/";
1067 if (rootPath.empty())
1071 if (stat(rootPath.c_str(), &st) == 0)
1072 if (!S_ISDIR(st.st_mode)) {
1076 rootPath +=
"/local.db";
1097 LOG(info) <<
"Load local settings of geometry DB from '" << fileName <<
"'";
1101 LOG(error) <<
"Selected file has not XML format: " << fileName;
1110 while (child != 0) {
1112 if (chName.
CompareTo(
"editSetupModule") == 0) {
1126 sNode->
type = aValue;
1127 }
else if (aName.
CompareTo(
"moveX") == 0) {
1129 }
else if (aName.
CompareTo(
"moveY") == 0) {
1131 }
else if (aName.
CompareTo(
"moveZ") == 0) {
1133 }
else if (aName.
CompareTo(
"file_path") == 0) {
1134 gSystem->ExpandPathName(aValue);
1136 }
else if ((aName.
CompareTo(
"enable") == 0)
1150 }
else if (chName.
CompareTo(
"addSetupModule") == 0) {
1157 module->class_name = aValue;
1158 else if (aName.
CompareTo(
"file_path") == 0) {
1159 gSystem->ExpandPathName(aValue);
1160 module->file_path = aValue;
1161 }
else if (aName.
CompareTo(
"args") == 0)
1162 module->args = aValue;
1166 module->active = false;
1186 LOG(error) <<
"Unknown module type with id=" << dbModuleUndex;
1194 map<int, TString>::iterator it;
1196 if ((it->second).CompareTo(name, TString::ECaseCompare::kIgnoreCase) == 0)
1218 return it->second->idm;
1234 TList* l = f->GetListOfKeys();
1236 while ((key = (
TKey*)next())) {
1237 if (strcmp(key->GetClassName(),
"TGeoManager") != 0)
1243 LOG(error) <<
"ERROR: geometry in the file " << f->GetName() <<
" has no daughter volume";
1251 if (key ==
nullptr) {
1252 LOG(error) <<
"ERROR: no keys found in the geometry file " << f->GetName();
1264 if (mr ==
nullptr) {
1265 LOG(error) <<
"ERROR: no module revision with id=" << dbModuleRev <<
" in the Geometry Database";
1275 type_name = mr->
args;
1284 command +=
",kTRUE)";
1287 LOG(debug1) <<
"command:" << command;
1290 if (obj ==
nullptr) {
1291 LOG(error) <<
"ERROR: cannot create the detector module by the command: " << command;
1294 obj->SetGeometryFileName(path);
1295 fRun->AddModule(obj);
1302 if (module ==
nullptr)
1304 TString command =
"new " +
module->class_name + "(\"" + module->args + "\"";
1306 command +=
",kTRUE)";
1310 if (obj ==
nullptr) {
1311 LOG(error) <<
"ERROR: cannot create the detector module by the command: " << command;
1314 obj->SetGeometryFileName(module->
file_path);
1315 fRun->AddModule(obj);
1316 LOG(info) <<
"\033[0;32mAdded external detector: file_path=" <<
module->file_path
1317 << " class_name=" << module->class_name << " isActive=" << module->active << "\033[0m";
1327 if (f->IsZombie() || !f->IsOpen()) {
1328 LOG(error) <<
"ERROR: could not open ROOT file with geometry: " << fileName;
1332 TList* l = f->GetListOfKeys();
1337 while ((key = (
TKey*)next())) {
1338 if (strcmp(key->GetClassName(),
"TGeoManager") != 0) {
1352 if (key ==
nullptr) {
1353 LOG(error) <<
"ERROR: no keys found in the geometry file " << fileName;
1358 volume =
dynamic_cast<TGeoVolume*
>(key->ReadObj());
1372 if (row == NULL || fileName == NULL)
1384 for (
i = 0;
i < 3;
i++) {
1387 LOG(debug1) <<
" for i=" <<
i <<
" tran[i]=" << tran[
i] <<
" t=" << t << endl;
1391 for (
i = 0;
i < 9;
i++) {
1394 LOG(debug1) <<
" for i=" <<
i <<
" rot[i]=" << rot[
i] <<
" t=" << t << endl;
1412 LOG(debug1) <<
"Start load setup_module_id=" << idsm;
1413 ostringstream stringStream;
1414 stringStream <<
"select "
1415 "f.module_id,f.file_name,sm.parent_id,sm.tx,sm.ty,sm.tz,r11,r12,r13,r21,r22,r23,r31,r32,r33,sm."
1417 "from setup_module sm INNER JOIN geometry_file f ON f.file_id=sm.file_id where sm.setup_module_id="
1422 LOG(error) <<
"ERROR: no file for the setup module (" << idsm <<
") was found";
1428 if (row ==
nullptr) {
1429 LOG(error) <<
"ERROR: no file for the setup module (" << idsm <<
") was found";
1435 LOG(debug1) <<
"idP=" << idP;
1445 stringStream.str(
"");
1451 bool isEnable =
true;
1453 TString file_path = stringStream.str().c_str();
1457 map<TString, setup_module_ptr>::iterator itr =
m_moduleEdit.find(smTag);
1459 LOG(debug1) <<
"detector was found";
1460 isEnable = itr->second->enable;
1464 bool isDuplicateCave =
false;
1465 if (mName ==
TString(
"CAVE")) {
1466 TIter nextModule(fRun->GetListOfModules());
1467 while (
TObject* module = nextModule())
1468 if (module->InheritsFrom(
"FairCave")) {
1469 isDuplicateCave =
true;
1473 if (isDuplicateCave)
1474 LOG(warning) <<
"The cave has been already added, so the duplicate cave module with tag=" << smTag
1475 <<
" is skipped. Please, remove it from the setup in the Geometry Database";
1477 LOG(info) <<
"Loading module with tag=" << smTag;
1481 LOG(info) <<
"\033[0;31mDisable module with tag=" << smTag <<
" use local settings.\033[0m";
1483 double mx = 0, my = 0, mz = 0;
1484 map<TString, setup_module_ptr>::iterator itr =
m_moduleEdit.find(smTag);
1485 LOG(debug1) <<
"detector " << dbModuleIndex;
1487 LOG(debug1) <<
"detector was found";
1488 isEnable = itr->second->enable;
1490 mx = itr->second->xMove;
1491 my = itr->second->yMove;
1492 mz = itr->second->zMove;
1493 if (itr->second->file_path.Length() > 0)
1494 file_path = itr->second->file_path;
1495 LOG(debug1) <<
"Move detector " << dbModuleIndex <<
" to x:" << mx <<
" to y:" << my <<
" to z:" << mz;
1498 if (isEnable && mx == 0 && my == 0 && mz == 0 &&
IsEqlMatrix(stringStream.str().c_str(), row)) {
1499 LOG(debug1) <<
"The same matrix for file=" << stringStream.str().c_str() << endl;
1500 LOG(info) <<
"Loading module with tag=" << smTag;
1502 }
else if (isEnable) {
1504 LOG(debug1) <<
"import file" << file_path << endl;
1506 if (f->IsZombie() || !f->IsOpen()) {
1507 LOG(error) <<
"ERROR: could not open ROOT file with the module geometry: " << file_path;
1515 if (root_volume ==
nullptr || root_volume->
GetNode(0) ==
nullptr) {
1516 LOG(error) <<
"ERROR: no geometry volume found in the file: " << file_path;
1531 v->SetMatrix(newMatrix);
1535 root_volume->
Export(out.Data());
1536 LOG(info) <<
"Loading module with tag=" << smTag;
1538 LOG(debug1) <<
"Exporting geometry to ROOT file: " << out;
1544 LOG(info) <<
"\033[0;31mDisable module with tag=" << smTag <<
" use local settings.\033[0m";
1556 TSQLResult* resQ =
m_db->Query(
"select module_id,module_name from module;");
1557 if (resQ ==
nullptr) {
1558 LOG(error) <<
"ERROR: SQL query was failed. Please, check connection to the Geometry Database and "
1559 "DBL_FILE_PATH variable is correct";
1563 LOG(error) <<
"ERROR: no modules in the Geometry Database";
1569 while ((row = resQ->
Next()) != 0) {
1583 TSQLResult* resQ =
m_db->Query(
"select module_class_id,mc.module_id,class_name,revision,active,object_name from "
1584 "module_class as mc INNER JOIN module as m ON mc.module_id=m.module_id;");
1585 if (resQ ==
nullptr) {
1586 LOG(error) <<
"ERROR: SQL query was failed. Please, check connection to the Geometry Database and "
1587 "DBL_FILE_PATH variable is correct";
1591 LOG(error) <<
"ERROR: no module revisions in the geometry database";
1597 while ((row = resQ->
Next()) != 0) {
bool ichar_equals(char a, char b)
static pid_t gWritableDbPid
static int FieldToInt(const char *field, int defaultValue=0)
static void RemoveWritableDbDir()
static uint64_t FieldToUInt64(const char *field, uint64_t defaultValue=0)
static string SqlEscape(string_view value)
static void RemoveAssemblyShapes(TGeoManager *geoManager)
static double FieldToDouble(const char *field, double defaultValue=0.)
static string gWritableDbDir
static bool IsSafeTag(const string &tag)
R__EXTERN TGeoManager * gGeoManager
Bool_t R_ISDIR(Int_t mode)
R__EXTERN TSystem * gSystem
void SetFileName(const char *map_file_name)
Set field map file path.
void SetScale(Double_t factor)
Set a global field scaling factor.
Field Map does not have any symmetries w.r.t coordinate axises.
int GetModuleId(int dbModuleRev)
TGeoNode * ConstructRootGeometry(const char *fileName)
string GetParameterFile(string_view detector_name)
Get path to parameter file for the given detector name of the current setup.
bool OpenLocalGeoDatabase()
string ExpandDbFilePath()
TString GetModuleName(int dbModuleUndex)
int LoadModuleToFairRunSim(int idsm, FairRunSim *fRun)
TString GetTmpFileName(const char *baseName)
int LoadSetupToGeoManager(string_view setup_tag)
Load selected geometry setup from the Local Geometry Database and create gGeoManager instance.
bool LoadLocalSettings(const char *fileName)
string GetMaterialFile()
Get the material file of the current setup, which defines the media of the setup geometry.
map< int, TString > m_modules_table
map< TString, setup_module_ptr > m_moduleEdit
std::pair< int, uint64_t > CheckTagOnServer(string_view setup_tag, const char *url=GEO_SERVER_HOST)
TGeoVolume * GetRootVolume(TFile *f)
int installLocalDB(string_view setup_tag, const char *url=GEO_SERVER_HOST)
unsigned long int GetServerRevision(const char *url=GEO_SERVER_HOST)
vector< module_r_ptr > m_moduleAdd
map< int, module_r_ptr > m_modules_revision_table
TString GetModuleType(int dbModuleRev)
TString PrepareWritableDbDir()
module_r_ptr GetModuleRevision(int dbModuleRev)
static bool exists_file(const char *name)
static bool IsWritableDir(const char *path)
map< int, TString > m_loadedModule
int GetModuleIndex(TString &name)
FairField * GetMagneticField(double scale=-1)
Get magnetic field of the current setup geometry.
bool IsEqlMatrix(const char *fileName, TSQLRow *row)
~GeoSetup()
Destructor method.
unsigned long int GetLocalRevision(TString &localDbPath)
std::pair< int, string > GetTagName4PatternLocal(string_view pattern_tag, TString &localDbPath)
bool AddModuleToFairRunSim(module_r_ptr module, FairRunSim *fRun)
std::pair< int, string > GetTagName4PatternServer(string_view pattern_tag, const char *url=GEO_SERVER_HOST)
string GetLastApprovedSetupTag(string_view tag_prefix)
Get tag for the last approved setup corresponding to the pattern.
int LoadSetupToFairRunSim(string_view setupTag, const char *localSettings=nullptr)
Load selected geometry setup from the Local or Central (defined by url) Geometry Database and add it ...
TList * GetListOfKeys() const override
virtual Bool_t IsOpen() const
TObjArray * GetListOfVolumes() const
virtual Bool_t cd(const char *path="")
TGeoNode * GetNode(Int_t level) const
TObjArray * GetListOfShapes() const
virtual const Double_t * GetTranslation() const=0
virtual const Double_t * GetRotationMatrix() const=0
TGeoVolume * GetVolume() const
Int_t GetNdaughters() const
TGeoNode * GetDaughter(Int_t ind) const
virtual TGeoMatrix * GetMatrix() const=0
TGeoNode * GetNode(const char *name) const
Int_t Export(const char *filename, const char *name="", Option_t *option="")
TObject * At(Int_t idx) const override
TObject * Remove(TObject *obj) override
virtual const char * ClassName() const
R__ALWAYS_INLINE Bool_t IsZombie() const
virtual Int_t GetRowCount() const
virtual TSQLRow * Next()=0
virtual const char * GetField(Int_t field)=0
virtual Bool_t IsConnected() const
TSQLResult * Query(const char *sql) final
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
TSubString Strip(EStripType s=kTrailing, char c=' ') const
const char * Data() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
static TString Format(const char *fmt,...)
XMLNodePointer_t GetChild(XMLNodePointer_t xmlnode, Bool_t realnode=kTRUE)
void FreeDoc(XMLDocPointer_t xmldoc)
XMLNodePointer_t DocGetRootElement(XMLDocPointer_t xmldoc)
XMLAttrPointer_t GetNextAttr(XMLAttrPointer_t xmlattr)
const char * GetAttrName(XMLAttrPointer_t xmlattr)
XMLAttrPointer_t GetFirstAttr(XMLNodePointer_t xmlnode)
const char * GetNodeName(XMLNodePointer_t xmlnode)
XMLDocPointer_t ParseFile(const char *filename, Int_t maxbuf=100000)
const char * GetAttrValue(XMLAttrPointer_t xmlattr)
XMLNodePointer_t GetNext(XMLNodePointer_t xmlnode, Bool_t realnode=kTRUE)
struct SETUPMODULE * setup_module_ptr
struct MODULEREVISION * module_r_ptr
const char *const GEO_SERVER_HOST
struct SETUPMODULE setup_module
struct MODULEREVISION module_r
*brief user defined string literal for JSON values *sa std::size_t n