BmnRoot
Loading...
Searching...
No Matches
GeoSetup.h
Go to the documentation of this file.
1#ifndef _GEO_SETUP_INCLUDED
2#define _GEO_SETUP_INCLUDED
3
4#include "BmnFieldMap.h"
5#include "FairRunSim.h"
6#include "TFile.h"
7#include "TGeoVolume.h"
8#include "TSQLRow.h"
9#include "TSQLServer.h"
10#include "TString.h"
11#include "geo_db_settings.h"
12
13#include <map>
14#include <string>
15#include <utility>
16
17using namespace std;
18
19typedef struct SETUPMODULE
20{
21 TString type;
22 double xMove, yMove, zMove;
23 bool enable;
24 TString file_path="";
26
27typedef struct MODULEREVISION
28{
29 TString class_name{""};
30 int idmr{-1}, idm{-1}, rev{-1};
31 bool active{true};
32 TString args{""};
33 TString file_path="";
35
40{
41 public:
42 // default constructor
44 : m_db(nullptr)
45 , m_field(nullptr)
46 , m_fid(-1)
47 , m_sid(-1)
48 , m_tmpFolder("")
49 {}
50
54 ~GeoSetup();
55
62 int LoadSetupToGeoManager(string_view setup_tag);
63
71 int LoadSetupToFairRunSim(string_view setupTag, const char* localSettings = nullptr);
72
79 FairField* GetMagneticField(double scale = 0);
80
86 string_view GetParameterFile(string_view detector_name);
87
93 string_view GetLastApprovedSetupTag(string_view tag_prefix);
98 string_view GetSetupTag(){return m_setupTag;}
99
100 private:
101 map<int, TString> m_modules_table;
102 map<int, module_r_ptr> m_modules_revision_table;
103 map<int, TString> m_loadedModule;
104 map<TString, setup_module_ptr> m_moduleEdit;
105 vector<module_r_ptr> m_moduleAdd;
106
107 // connection to the Geometry Database
108 TSQLServer* m_db;
109 // magnetic field of the geometry setup
110 FairField* m_field;
111 // id of the current magnetic field
112 int m_fid;
113 // id of the current geometry setup
114 int m_sid;
115 // current tmp directory (/tmp/$USER/)
116 TString m_tmpFolder;
117 //tag name of setup
118 string_view m_setupTag="";
119
120 unsigned long int GetServerRevision(const char* url = GEO_SERVER_HOST);
121 std::pair<int, string_view> GetTagName4PatternServer(string_view pattern_tag, const char* url = GEO_SERVER_HOST);
122 std::pair<int, uint64_t> CheckTagOnServer(string_view setup_tag, const char* url = GEO_SERVER_HOST);
123 unsigned long int GetLocalRevision(TString& localDbPath);
124 std::pair<int, string_view> GetTagName4PatternLocal(string_view pattern_tag, TString& localDbPath);
125 int installLocalDB(string_view setup_tag, const char* url = GEO_SERVER_HOST);
126 void CloseDB();
127 bool AddModuleToFairRunSim(module_r_ptr module, FairRunSim* fRun);
128
129 // create connection to the Local Geometry Database and fill the tables with modules and their revisions
130 bool OpenLocalGeoDatabase();
131 bool IsEqlMatrix(const char* fileName, TSQLRow* row);
132 TGeoNode* ConstructRootGeometry(const char* fileName);
133 static bool exists_file(const char* name);
134 // get path to the location of the Local Geometry Database
135 string GetRootPath();
136 // get path to a temporary directory (/tmp/$USER/), and create if absent
137 TString& GetTmpPath();
138 // get root volume in the TFile object
139 TGeoVolume* GetRootVolume(TFile* f);
140
141 // get module name by index; return "Unknown" if not found
142 TString GetModuleName(int dbModuleUndex);
143 // get module index by name; return -1 if not found
144 int GetModuleIndex(TString& name);
145 // get module ID by revision number; return -1 if not found
146 int GetModuleId(int dbModuleRev);
147 // get module type by revision number
148 TString GetModuleType(int dbModuleRev);
149 // get module_r_ptr (pointer to the module revision) by revision number
150 module_r_ptr GetModuleRevision(int dbModuleRev);
151
152 // load local settings from the file for all setup modules
153 bool LoadLocalSettings(const char* fileName);
154
155 // load module from the Geometry Database and add to the FairRunSim instance
156 int LoadModuleToFairRunSim(int idsm, FairRunSim* fRun);
157 // add FairModule defined by revision number and geometry file path to the FairRunSim instance
158 bool AddModuleToFairRunSim(int dbModuleRev, const char* path, FairRunSim* fRun);
159
160 // fill map with modules from the Geometry Database
161 int PutModules();
162 // fill map with module revisions from the Geometry Database
163 int PutModuleRevisions();
164};
165
166#endif
float f
Definition P4_F32vec4.h:21
int LoadSetupToGeoManager(string_view setup_tag)
Definition GeoSetup.cxx:314
FairField * GetMagneticField(double scale=0)
Definition GeoSetup.cxx:639
string_view GetSetupTag()
Definition GeoSetup.h:98
GeoSetup()
Definition GeoSetup.h:43
string_view GetParameterFile(string_view detector_name)
Definition GeoSetup.cxx:702
string_view GetLastApprovedSetupTag(string_view tag_prefix)
Definition GeoSetup.cxx:55
int LoadSetupToFairRunSim(string_view setupTag, const char *localSettings=nullptr)
Definition GeoSetup.cxx:424
struct SETUPMODULE setup_module
struct SETUPMODULE * setup_module_ptr
struct MODULEREVISION module_r
struct MODULEREVISION * module_r_ptr
const char *const GEO_SERVER_HOST
STL namespace.
TString class_name
Definition GeoSetup.h:29
TString args
Definition GeoSetup.h:32
TString file_path
Definition GeoSetup.h:33
TString type
Definition GeoSetup.h:21
double zMove
Definition GeoSetup.h:22
TString file_path
Definition GeoSetup.h:24
double xMove
Definition GeoSetup.h:22
double yMove
Definition GeoSetup.h:22
bool enable
Definition GeoSetup.h:23