BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
loadSetup.C
Go to the documentation of this file.
1#include <cstring>
2#include <fcntl.h> // open
3#include <fstream>
4#include <iostream>
5#include <map>
6#include <sstream>
7#include <stdio.h>
8#include <stdlib.h>
9#include <string>
10#include <sys/sendfile.h> // sendfile
11#include <sys/stat.h> // fstat
12#include <sys/types.h> // fstat
13#include <time.h> /* time */
14#include <unistd.h> // close
15#include <unistd.h>
16typedef std::pair<int, TString> moduleP;
17
18#include "TXMLEngine.h"
19
20struct SETUPMODULE
21{
22 TString type;
23 double xMove;
24 double yMove;
25 double zMove;
26 bool enable;
28
29struct MODULEREVISION
30{
31 TString class_name;
32 int idmr;
33 int idm;
34 int rev;
35 bool active;
36 TString args;
38
39std::map<int, TString> m_modules_table;
40std::map<int, MODULEREVISION> m_modules_revision_table;
41
42std::string getRootPath()
43{
44 // return getenv("DBL_ROOT_PATH");
45 std::string rootPath = getenv("DBL_FILE_PATH");
46 struct stat st;
47 if (stat(rootPath.c_str(), &st) == 0)
48 if ((st.st_mode & S_IFDIR) != 0) {
49 std::cerr << "Error: DBL_FILE_PATH variable points to the folder. Please, set DBL_FILE_PATH to file path "
50 "with local geometry database"
51 << std::endl;
52 std::exit(-1);
53 }
54 int last = -1;
55 last = rootPath.find_last_of("/\\");
56 std::string fileName;
57 if (last == -1) {
58 fileName = rootPath;
59 rootPath = ".";
60 } else {
61 fileName = rootPath.substr(last + 1);
62 rootPath = rootPath.substr(0, last);
63 }
64 rootPath += "/storage/";
65 // std::cerr<<"rootPath="<<rootPath<<std::endl;
66 return rootPath;
67}
68
69bool exists_file(const char* name)
70{
71 return (access(name, F_OK) != -1);
72}
73
74TString getModuleName(int dbNoduleUndex)
75{
76 std::map<int, TString>::iterator it = m_modules_table.find(dbNoduleUndex);
77 if (it != m_modules_table.end())
78 return it->second;
79 else {
80 std::cerr << "Unknown module type with id=" << dbNoduleUndex << std::endl;
81 return TString("Unknown");
82 }
83}
84
86{
87 std::map<int, TString>::iterator it;
88 for (it = m_modules_table.begin(); it != m_modules_table.end(); ++it)
89 if (it->second == name)
90 return it->first;
91
92 return -1;
93}
94
96{
97 std::map<int, MODULEREVISION>::iterator it = m_modules_revision_table.find(dbModuleRev);
98 if (it != m_modules_revision_table.end())
99 return it->second; //.class_name;
100
102 return mr;
103}
104
105int getModuleId(int dbModuleRev)
106{
107 std::map<int, MODULEREVISION>::iterator it = m_modules_revision_table.find(dbModuleRev);
108 if (it != m_modules_revision_table.end())
109 return it->second.idm;
110
111 return -1;
112}
113
114TString getModuleType(int dbModuleRev)
115{
116 return getModuleName(getModuleId(dbModuleRev));
117}
118
120 int dbModuleRev,
121 const char* path,
122 double psdx,
123 double psdz,
124 int iVerbose = 0) // KG psdx и psdz не используются?
125{
126 MODULEREVISION mr = getModuleRevision(dbModuleRev);
127 int dbNoduleUndex = mr.idm;
128 TString mName = getModuleType(dbModuleRev);
129 mName.ToUpper();
130
131 TString type_name;
133 // std::cout<<"TClass:"<<cl<<std::endl;
134 FairModule* f_cl = (FairModule*)cl->New();
135 if (mr.args.Length() > 0) {
136 type_name = mr.args;
137 // f_cl->SetName(mr.args);
138 } else {
139 // f_cl->SetName(getModuleType(dbModuleRev));
140 type_name = getModuleType(dbModuleRev);
141 }
142 TString command = "new " + mr.class_name + "(\"" + type_name + "\""; //,kTrue)";
143 if (mr.active)
144 command += ",kTRUE)";
145 else
146 command += ")";
147 if (iVerbose > 0)
148 std::cerr << "command:" << command << std::endl;
149 FairModule* obj = (FairModule*)gInterpreter->Calc(command);
150
151 // std::cerr<<"OBJ="<<obj<<std::endl;
152 obj->SetGeometryFileName(path);
153 fRun->AddModule(obj);
154
155 // obj->Dump();
156 // std::cerr<<"dbModuleRev="<<dbModuleRev<<" idmr="<<mr.idmr<<" idm="<<mr.idm<<"
157 // class_name="<<typeid(f_cl).name()<<std::endl; f_cl->Dump();
158 return true;
159}
160
162{
163 std::ostringstream stringStream;
164 stringStream << "select idmr,idm,class_name,revision,active,args from module_revision;";
165 TSQLResult* resQ2 = db.Query(stringStream.str().c_str());
166 if (resQ2 == 0) {
167 std::cout << "Error: SQL query was failed. "
168 "Please, check connection to the geometry database and that DBL_FILE_PATH variable is correct"
169 << std::endl;
170 return -1;
171 }
172 if (resQ2->GetRowCount() == 0) {
173 std::cout << "Error: no module revisions in the geometry database" << std::endl;
174 return -2;
175 }
176
177 TSQLRow* row;
178 while ((row = resQ2->Next()) != 0) {
179 int idmr = atoi(row->GetField(0));
180 int idm = atoi(row->GetField(1));
181 int rev = atoi(row->GetField(3));
182 int act = atoi(row->GetField(4));
183 TString class_name(row->GetField(2));
184 TString args(row->GetField(5));
185
187 mr.idmr = idmr;
188 mr.rev = rev;
189 mr.idm = idm;
190 mr.class_name = class_name;
191 mr.args = args;
192 if (act == 0)
193 mr.active = false;
194 else
195 mr.active = true;
196 m_modules_revision_table.insert(make_pair(idmr, mr));
197 }
198
199 return 0;
200}
201
203{
204 std::ostringstream stringStream;
205 stringStream << "select idm,mname from module;";
206 TSQLResult* resQ2 = db.Query(stringStream.str().c_str());
207 if (resQ2 == 0) {
208 std::cout << "Error: SQL query was failed. "
209 "Please, check connection to the geometry database and that DBL_FILE_PATH variable is correct"
210 << std::endl;
211 return -1;
212 }
213 if (resQ2->GetRowCount() == 0) {
214 std::cout << "Error: no modules in the geometry database" << std::endl;
215 return -2;
216 }
217
218 TSQLRow* row;
219 while ((row = resQ2->Next()) != 0) {
220 int id = atoi(row->GetField(0));
221 TString name(row->GetField(1));
222 m_modules_table.insert(make_pair(id, name));
223 }
224
225 return 0;
226}
227
228/*
229CbmFieldMap* CreateFieldMap(TString& fieldTag) {
230 TString mapName = "";//"field_";
231 mapName += fieldTag;
232 TString fileName = gSystem->Getenv("VMCWORKDIR");
233 fileName = fileName + "/input/" + mapName + ".root";
234 TFile mapFile(fileName);
235 if ( ! mapFile.IsOpen() ) {
236 LOG(ERROR) << "Could not open field map file " << fileName
237 << FairLogger::endl;
238 return NULL;
239 }
240 CbmFieldMapData* data = NULL;
241 mapFile.GetObject(mapName, data);
242 if ( ! data ) {
243 LOG(ERROR) << "Could not find CbmFieldMapData object " << mapName << " in file "
244 << fileName << FairLogger::endl;
245 return NULL;
246 }
247 Int_t fieldType = data->GetType();
248
249 CbmFieldMap* field = NULL;
250 switch (fieldType) {
251 case 2: field = new CbmFieldMapSym2(mapName); break;
252 case 3: field = new CbmFieldMapSym3(mapName); break;
253 default: LOG(ERROR) << "Unknown field type " << fieldType
254 << FairLogger::endl; break;
255 }
256 if ( field ) {
257 field->SetScale(fFieldScale);
258 field->SetPosition(fFieldPosition.X(),
259 fFieldPosition.Y(),
260 fFieldPosition.Z());
261 }
262
263 return field;
264}
265*/
266
267// TFile* f=new TFile(fileName);
269{
270 // TGeoManager* OldGeo=geoManeger;
271 TGeoManager* NewGeo = 0;
272 TGeoVolume* volume = 0;
273 ;
274 // TFile* f=new TFile(fileName);
275 TList* l = f->GetListOfKeys();
276 TKey* key;
277 TIter next(l);
278 TGeoNode* n = 0;
279 TGeoVolume* v1 = 0;
280 while ((key = (TKey*)next())) {
281 if (strcmp(key->GetClassName(), "TGeoManager") != 0)
282 continue;
283 // gGeoManager = 0;
284 NewGeo = (TGeoManager*)key->ReadObj();
285 break;
286 }
287
288 if (NewGeo != 0) {
289 NewGeo->cd();
290 // return NewGeo->GetNode(0);
291 return (TGeoVolume*)NewGeo->GetNode(0)->GetDaughter(0)->GetVolume();
292 // v1=volume->MakeCopyVolume(volume->GetShape());
293 // n=v1->GetNode(0);
294 } else {
295 key = (TKey*)l->At(0); // Get the first key in the list
296 volume = dynamic_cast<TGeoVolume*>(key->ReadObj());
297 return volume;
298 // if(volume!=0) { return volume->GetNode(0);}//n=volume->GetNode(0); }
299 // if(n!=0) { v1=n->GetVolume(); }
300 // return NULL;
301 }
302
303 // if(v1==0) {
304 // std::cerr<<"ConstructRootGeometry: could not find any geometry in File!!"<<fileName<<std::endl;
305 // }
306 // gGeoManager=OldGeo;
307 // gGeoManager->cd();
308 // TGeoVolume* Cave=NULL;
309 // if(NULL == Cave)
310 // return v1;
311 // else
312 // return Cave;
313}
314
315void copyFile(TString& in, TString& out)
316{
317 int source = open(in.Data(), O_RDONLY, 0);
318 int dest = open(out.Data(), O_WRONLY | O_CREAT /*| O_TRUNC*/, 0644);
319
320 // struct required, rationale: function stat() exists also
321 struct stat stat_source;
322 fstat(source, &stat_source);
323 sendfile(dest, source, 0, stat_source.st_size);
324 close(source);
325 close(dest);
326}
327
328bool hasEnding(std::string const& fullString, std::string const& ending)
329{
330 if (fullString.length() >= ending.length())
331 return (0 == fullString.compare(fullString.length() - ending.length(), ending.length(), ending));
332 else
333 return false;
334}
335
336int downloadModule(std::map<int, TString>* loadedModule,
337 TString& rootDir,
338 TSQLiteServer& db,
339 int idsm,
340 FairRunSim* fRun,
341 std::map<int, SETUPMODULE>& moduleMove,
342 int iVerbose = 0)
343{
344 int res = -1;
345 std::map<int, TString>::iterator it = loadedModule->find(idsm);
346 if (it != loadedModule->end())
347 return 0;
348
349 std::ostringstream stringStream;
350 stringStream << "select f.idm,f.url,sm.idp,sm.tx,sm.ty,sm.tz from setupmodule sm INNER JOIN file f ON f.idf=sm.idf "
351 "where sm.idsm="
352 << idsm << ";";
353 // std::cerr<<stringStream<<std::endl;
354 TSQLResult* resQ2 = db.Query(stringStream.str().c_str());
355 if (resQ2 == 0 || resQ2->GetRowCount() == 0) {
356 std::cout << "Error: no file for the module was found" << std::endl;
357 return res;
358 }
359
360 // std::cerr<<"rows="<<resQ2->GetRowCount()<<std::endl;
361 TSQLRow* row2 = resQ2->Next();
362 // const char* ccc = row2->GetField(1);
363 int idP = atoi(row2->GetField(2));
364 if (iVerbose > 1)
365 std::cerr << "idP=" << idP << std::endl;
366 if (idP != -1) {
367 res = downloadModule(loadedModule, rootDir, db, idP, fRun, moduleMove, iVerbose);
368 if (res < 0)
369 return res;
370 }
371 if (iVerbose > 1)
372 std::cerr << row2->GetField(1) << std::endl;
373 int dbModuleIndex = atoi(row2->GetField(0));
374 stringStream.str("");
375 stringStream << getRootPath().c_str() << row2->GetField(1);
376 std::string ends = ".geo";
377 // std::cerr<<"getRootPath()="<<getRootPath().c_str()<<std::endl;
378 // std::cerr<<"File path="<<stringStream.str().c_str()<<std::endl;
379
380 TString mName = getModuleType(dbModuleIndex), out;
381 mName.ToUpper();
382 if (mName == TString("CAVE") || hasEnding(stringStream.str(), ends))
383 loadFairModule(fRun, dbModuleIndex, stringStream.str().c_str(), atof(row2->GetField(3)),
384 atof(row2->GetField(5)));
385 else {
386 double mx = 0, my = 0, mz = 0;
387 std::map<int, SETUPMODULE>::iterator itr = moduleMove.find(dbModuleIndex);
388 if (iVerbose > 1)
389 std::cerr << "detector " << dbModuleIndex << std::endl;
390 if (itr != moduleMove.end()) {
391 if (iVerbose > 1)
392 std::cerr << "detector was found" << std::endl;
393 if (itr->second.enable) {
394 mx = itr->second.xMove;
395 my = itr->second.yMove;
396 mz = itr->second.zMove;
397 if (iVerbose > 1)
398 std::cerr << "Move detector " << dbModuleIndex << " to x:" << mx << " to y:" << my << " to z:" << mz
399 << std::endl;
400 }
401 }
402
403 TGeoManager* geom = new TGeoManager(mName, TString::Format("Geometry of the %s module", mName.Data()));
404 // std::cerr<<"import file"<<stringStream.str().c_str()<<std::endl;
405 // TGeoManager::Import(stringStream.str().c_str());
406 TFile* f = new TFile(stringStream.str().c_str());
408 double tx = (double)atoi(row2->GetField(3)) + mx;
409 double ty = (double)atoi(row2->GetField(4)) + my;
410 double tz = (double)atoi(row2->GetField(5)) + mz;
411 TGeoRotation rotM;
412 TGeoGenTrans* newMatrix = new TGeoGenTrans(tx, ty, tz, 1, 1, 1, &rotM);
413 if (std::strcmp(node->GetNode(0)->ClassName(), "TGeoNodeMatrix") == 0) {
414 TGeoNodeMatrix* v = (TGeoNodeMatrix*)(node->GetNode(0));
415 // std::cerr<<"Matrix changed"<<std::endl;
416 v->SetMatrix(newMatrix);
417 }
418 // geom->CloseGeometry();
419 out = rootDir + getModuleName(getModuleId(dbModuleIndex)) + ".root";
420 node->Export(out.Data());
421 // gGeoManager->Export(out.Data());
422 loadFairModule(fRun, dbModuleIndex, out.Data(), atof(row2->GetField(3)), atof(row2->GetField(5)), iVerbose);
423 if (iVerbose > 0)
424 std::cerr << "Exporting geometry to ROOT file: " << out << std::endl;
425 delete geom;
426 f->Close();
427 delete f;
428 // gGeoManager->Export(out.Data());
429 }
430 loadedModule->insert(std::pair<int, TString>(idsm, out));
431
432 row2->Delete();
433 resQ2->Delete();
434 return 0;
435}
436
437int loadSetup(const char* setupTag, int subSetup, const char* fileName = NULL, int iVerbose = 0)
438{
439 std::map<int, SETUPMODULE> moduleMove;
440 TString tag(setupTag);
441 if (fileName != NULL) {
442 TXMLEngine* xml = new TXMLEngine;
443 XMLDocPointer_t xmldoc = xml->ParseFile(fileName);
444 if (xmldoc == 0) {
445 std::cerr << "Selected file has not XML format: " << fileName << std::endl;
446 delete xml;
447 return -1;
448 }
449
450 XMLNodePointer_t mainnode = xml->DocGetRootElement(xmldoc);
451 // display attributes
452 /* XMLAttrPointer_t attr = xml->GetFirstAttr(mainnode);
453 while (attr!=0) {
454 printf(" attr: %s value: %s\n", xml->GetAttrName(attr), xml->GetAttrValue(attr));
455 TString aName = xml->GetAttrName(attr);
456 TString aValue = xml->GetAttrValue(attr);
457 if(aName.CompareTo("tag")==0){
458 tag=aValue;
459 break;
460 }
461 attr = xml->GetNextAttr(attr);
462 }
463 if(tag.Length()==0){
464 std::cerr<<"No tag attribute in root element in selected file"<<std::endl;
465 xml->FreeDoc(xmldoc);
466 delete xml;
467 return -1;
468 }
469 */
470 XMLAttrPointer_t attr;
471 XMLNodePointer_t child = xml->GetChild(mainnode);
472 while (child != 0) {
473 TString chName = xml->GetNodeName(child);
474 if (chName.CompareTo("setupModule") == 0) {
475 attr = xml->GetFirstAttr(child);
476
477 SETUPMODULE sNode;
478 sNode.xMove = 0;
479 sNode.yMove = 0;
480 sNode.zMove = 0;
481 sNode.enable = true;
482 sNode.type = TString("");
483 while (attr != 0) {
484 TString aName = xml->GetAttrName(attr);
485 TString aValue = xml->GetAttrValue(attr);
486
487 if (aName.CompareTo("type") == 0)
488 sNode.type = aValue;
489 else if (aName.CompareTo("moveX") == 0) {
490 sNode.xMove = aValue.Atof();
491 } else if (aName.CompareTo("moveY") == 0) {
492 sNode.yMove = aValue.Atof();
493 } else if (aName.CompareTo("moveZ") == 0) {
494 sNode.zMove = aValue.Atof();
495 }
496 if ((aName.CompareTo("enable") == 0)
497 && (aValue.CompareTo("false") == 0 || aValue.CompareTo("False") == 0
498 || aValue.CompareTo("FALSE") == 0))
499 sNode.enable = false;
500 printf(" attr: %s value: %s\n", xml->GetAttrName(attr), xml->GetAttrValue(attr));
501 attr = xml->GetNextAttr(attr);
502 }
503 int ii = getModuleIndex(sNode.type);
504 if (ii != -1)
505 moduleMove.insert(std::pair<int, SETUPMODULE>(ii, sNode));
506 }
507 child = xml->GetNext(child);
508 }
509 xml->FreeDoc(xmldoc);
510 delete xml;
511 }
512
513 FairRunSim* fRun = FairRunSim::Instance();
514 if (fRun == NULL) {
515 fRun = new FairRunSim();
516 std::cout << "Created new FairRunSim" << std::endl;
517 }
518 TString rootPath = getenv("TMP_PATH");
519 if (rootPath.Length() == 0) {
520 UserGroup_t* user = gSystem->GetUserInfo();
521 string login(user->fUser.Data());
522 rootPath = "/tmp/" + login + "/";
523 system("mkdir -p " + rootPath);
524 }
525
526 std::ostringstream stringStream;
527 stringStream << "sqlite://"
528 << getenv("DBL_FILE_PATH"); // KG если переменная пустая, то все отрабатывает, но неверно?
529 TSQLiteServer db(stringStream.str().c_str());
530 if (iVerbose > 0)
531 std::cerr << "Geometry Database Path: " << stringStream.str().c_str() << std::endl;
532 stringStream.str("");
533
534 if (putMudules4SQLite(db) != 0)
535 return -1;
536 if (putMudulesRevision4SQLite(db) != 0)
537 return -1;
538
539 stringStream
540 << "select idsd,status,idma,idfi from setup where stag='" << tag
541 << "' order by revision desc;"; // KG если я правильно понял, то нужно брать по-умолчанию, самый новый релиз?
542 TSQLResult* resQ = db.Query(stringStream.str().c_str());
543 if (resQ == 0) {
544 std::cerr << "SQL query was failed while searching the given tag: `" << tag << "`" << std::endl;
545 return -1;
546 }
547 TSQLRow* row = resQ->Next();
548 if (row == NULL) {
549 std::cerr << "No geometry setup found for the given tag: `" << tag << "`" << std::endl;
550 return -1;
551 }
552
553 const char* idsd = row->GetField(0);
554 int idma = atoi(row->GetField(2));
555 int idfi = atoi(row->GetField(3));
556 // cout<<"idsd = "<<idsd<<"; idma = "<<idma<<"; idfi = "<<idfi<<endl;
557 stringStream.str("");
558 stringStream << "select idsm from sms where idsd=" << idsd << ";";
559 row->Delete();
560 resQ->Delete();
561
562 resQ = db.Query(stringStream.str().c_str());
563 if (resQ == 0 || resQ->GetRowCount() == 0) {
564 std::cout << "Error: no modules found" << std::endl;
565 return -1;
566 }
567 std::map<int, TString>* loadedModule = new std::map<int, TString>();
568 while ((row = resQ->Next()) != 0) {
569 stringStream.str("");
570 const char* idsm = row->GetField(0);
571 int idsmI = atoi(idsm);
572 if (subSetup < 0 || subSetup == idsmI) { // check subset
573 int res = downloadModule(loadedModule, rootPath, db, idsmI, fRun, moduleMove, iVerbose);
574 if (res == -1) {
575 std::cout << "Error: no file for the module was found " << std::endl;
576 return -1;
577 }
578 }
579 row->Delete();
580 }
581 /* if(idfi>0){
582 stringStream.str("");
583 //stringStream.clear();
584 stringStream<<"select tag,scale,z from field where idfi="<<idfi<<";";
585 resQ = db.Query(stringStream.str().c_str());
586 if(resQ==0 || resQ->GetRowCount()==0){
587 std::cout <<"Field did not find"<<std::endl;
588 }else{
589 row= resQ->Next();
590 double fieldZ = atof(row->GetField(2));
591 double fieldScale = atof(row->GetField(1));
592 TString tagF="field_";
593 tagF+=(row->GetField(0));
594 //std::ofstream dest(rootPath+"field.txt", std::ofstream::out|std::ofstream::trunc);
595 //dest<<"field="<<row->GetField(0)<<std::endl<<"Position=(0.,
596 0.,"<<fieldZ<<")"<<std::endl<<"scale="<<fieldScale;
597 //dest.close();
598 CbmFieldMap* magField = CreateFieldMap(tagF);//new CbmFieldMapSym3(row->GetField(0));
599 magField->SetPosition(0., 0., fieldZ);
600 magField->SetScale(fieldScale);
601 fRun->SetField(magField);
602 //CbmFieldMap* CreateFieldMap
603 row->Delete();
604 resQ->Delete();
605 }
606 }*/
607
608 if (idma > 0) {
609 stringStream.str("");
610 stringStream << "select matag,url from material where idma=" << idma << ";";
611 resQ = db.Query(stringStream.str().c_str());
612 if (resQ == 0 || resQ->GetRowCount() == 0)
613 std::cout << "Materials did not find" << std::endl;
614 else {
615 row = resQ->Next();
616 const char* url = row->GetField(1);
617 stringStream.str("");
618 stringStream << url;
619 TString in(""); //("/../../..");
620 TString work = getenv("GEOMPATH");
621 TString Mat = "";
622 work.ReplaceAll("//", "/");
623 if (work.IsNull()) {
624 work = getenv("VMCWORKDIR");
625 Mat = work + "/geometry/";
626 Mat.ReplaceAll("//", "/");
627 } else {
628 Mat = work;
629 if (!Mat.EndsWith("/"))
630 Mat += "/";
631 }
632 std::string workP(Mat.Data());
633 if (iVerbose > 0)
634 std::cout << "Working geometry directory: " << workP << std::endl;
635 std::size_t found = workP.find('/');
636 if (found != std::string::npos) {
637 while ((found = workP.find('/', found + 1)) != std::string::npos) {
638 if (iVerbose > 1)
639 std::cout << "found:" << found << std::endl;
640 in += "../";
641 }
642 }
643 in += getRootPath() + stringStream.str();
644 fRun->SetMaterials(
645 in.Data()); // KG
646 // /home/soul/bmnroot/geometry/../../../..//home/soul/bmnroot/database/geo_db/storage/07022020_085550_media.geo?
647 resQ->Delete();
648 row->Delete();
649 }
650 }
651
652 db.Close();
653 if (iVerbose > 0)
654 std::cout << "The setup geometry was successfully loaded" << std::endl;
655 return 0;
656}
657
658int loadSetup(const char* setupTag, const char* url)
659{
660 if (url == NULL)
661 return loadSetup(setupTag, -1);
662
663 std::srand(time(NULL));
664 int random_variable = std::rand();
665 std::cout << random_variable << std::endl;
666 std::ostringstream stringStream;
667 // stringStream<<"wget -O test2.tar \""<<url<<"?type=s&tag="<<setupTag<<"&dirname="<<random_variable<<"\"";
668 // http://cbmdb.jinr.ru/geometry8/download_file.php?type=all&tag=all
669 stringStream << "wget -O test2.tar \"" << url << "/download_file.php?type=all&tag=all&dirname=" << random_variable
670 << "\" >/dev/null ";
671 system(stringStream.str().c_str());
672 stringStream.str("");
673 stringStream << "tar -xf test2.tar >/dev/null";
674 system(stringStream.str().c_str());
675 stringStream.str("");
676 stringStream << "rm test2.tar";
677 system(stringStream.str().c_str());
678 stringStream.str("");
679 stringStream << gSystem->pwd() << "/" << random_variable << "/storage/";
680 gSystem->Setenv("DBL_ROOT_PATH", stringStream.str().c_str());
681 stringStream.str("");
682 stringStream << gSystem->pwd() << "/" << random_variable << "/local.db";
683 gSystem->Setenv("DBL_FILE_PATH", stringStream.str().c_str());
684
685 loadSetup(setupTag, -1);
686
687 stringStream.str("");
688 stringStream << "rm -rf " << random_variable << "/local.db";
689 system(stringStream.str().c_str());
690 stringStream.str("");
691 stringStream << "rm -rf " << random_variable;
692 system(stringStream.str().c_str());
693 std::cout << "DBL_ROOT_PATH=" << getRootPath() << std::endl;
694
695 return 0;
696}
697
698int loadSetup(const char* tag)
699{
700 return loadSetup(tag, -1, NULL, 0);
701}
702
703/*
704int main(int argc, char** argv)
705{
706 downloadSetup("test2.db","sis100_electron");
707}
708*/
__m128 v
Definition P4_F32vec4.h:1
#define gInterpreter
R__EXTERN TSystem * gSystem
void * XMLNodePointer_t
void * XMLDocPointer_t
void * XMLAttrPointer_t
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
static TClass * GetClass(Bool_t load=kTRUE, Bool_t silent=kFALSE)
virtual Bool_t cd(const char *path="")
TGeoNode * GetNode(Int_t level) const
TGeoVolume * GetVolume() const
TGeoNode * GetDaughter(Int_t ind) const
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
virtual const char * ClassName() const
virtual void Delete(Option_t *option="")
virtual Int_t GetRowCount() const
virtual TSQLRow * Next()=0
virtual const char * GetField(Int_t field)=0
TSQLResult * Query(const char *sql) final
void Close(Option_t *opt="") final
Ssiz_t Length() const
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Double_t Atof() const
const char * Data() const
void ToUpper()
Bool_t IsNull() const
static TString Format(const char *fmt,...)
TString & ReplaceAll(const char *s1, const char *s2)
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
struct SETUPMODULE * setup_module_ptr
struct MODULEREVISION module_r
struct MODULEREVISION * module_r_ptr
int downloadModule(std::map< int, TString > *loadedModule, TString &rootDir, TSQLiteServer &db, int idsm, FairRunSim *fRun, std::map< int, SETUPMODULE > &moduleMove, int iVerbose=0)
Definition loadSetup.C:336
TString getModuleType(int dbModuleRev)
Definition loadSetup.C:114
void copyFile(TString &in, TString &out)
Definition loadSetup.C:315
int getModuleIndex(TString &name)
Definition loadSetup.C:85
int loadSetup(const char *setupTag, int subSetup, const char *fileName=NULL, int iVerbose=0)
Definition loadSetup.C:437
std::pair< int, TString > moduleP
Definition loadSetup.C:16
MODULEREVISION getModuleRevision(int dbModuleRev)
Definition loadSetup.C:95
std::map< int, MODULEREVISION > m_modules_revision_table
Definition loadSetup.C:40
bool hasEnding(std::string const &fullString, std::string const &ending)
Definition loadSetup.C:328
std::map< int, TString > m_modules_table
Definition loadSetup.C:39
bool loadFairModule(FairRunSim *fRun, int dbModuleRev, const char *path, double psdx, double psdz, int iVerbose=0)
Definition loadSetup.C:119
TGeoVolume * constructRootGeometry(TFile *f)
Definition loadSetup.C:268
bool exists_file(const char *name)
Definition loadSetup.C:69
TString getModuleName(int dbNoduleUndex)
Definition loadSetup.C:74
int putMudules4SQLite(TSQLiteServer &db)
Definition loadSetup.C:202
int putMudulesRevision4SQLite(TSQLiteServer &db)
Definition loadSetup.C:161
int getModuleId(int dbModuleRev)
Definition loadSetup.C:105
std::string getRootPath()
Definition loadSetup.C:42
*brief user defined string literal for JSON values *sa std::size_t n
Definition json.hpp:20362
TString class_name
Definition GeoSetup.h:29
TString args
Definition GeoSetup.h:32
TString type
Definition GeoSetup.h:21
double zMove
Definition GeoSetup.h:22
double xMove
Definition GeoSetup.h:22
double yMove
Definition GeoSetup.h:22
bool enable
Definition GeoSetup.h:23
TString fUser