BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
UniDetectorParameter.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------
2// UniDetectorParameter header file
3// ----------------------------------------------------------------------
4
5/** UniDetectorParameter.h
6 ** Class for the table: detector_parameter
7 **/
8
9#ifndef UniDetectorPARAMETER_H
10#define UniDetectorPARAMETER_H 1
11
12#include "TDatime.h"
13#include "TObjArray.h"
14#include "TString.h"
15#include "UniConnection.h"
16#include "UniParameter.h"
17#include "UniSearchCondition.h"
18
19#include <iostream>
20using namespace std;
21
23{
24 private:
25 /* GENERATED PRIVATE MEMBERS (SHOULD NOT BE CHANGED MANUALLY) */
26 /// connection to the database
28
29 /// value id
31 /// detector name
33 /// parameter id
35 /// start period
37 /// start run
39 /// end period
41 /// end run
43 /// value key
45 /// parameter value
46 unsigned char* blob_parameter_value;
47 /// size of parameter value
49 /// expiry date
51
52 // Constructor
54 int value_id,
55 TString detector_name,
56 int parameter_id,
57 int start_period,
58 int start_run,
59 int end_period,
60 int end_run,
61 int value_key,
62 unsigned char* parameter_value,
63 Long_t size_parameter_value,
64 TDatime* expiry_date);
65 /* END OF PRIVATE GENERATED PART (SHOULD NOT BE CHANGED MANUALLY) */
66
67 public:
68 /* GENERATED PUBLIC MEMBERS (SHOULD NOT BE CHANGED MANUALLY) */
69 virtual ~UniDetectorParameter(); // Destructor
70
71 // static class functions
72 /// add new detector parameter to the database
74 int parameter_id,
75 int start_period,
76 int start_run,
77 int end_period,
78 int end_run,
79 int value_key,
80 unsigned char* parameter_value,
81 Long_t size_parameter_value,
82 TDatime* expiry_date);
83 /// get detector parameter from the database
84 static UniDetectorParameter* GetDetectorParameter(int value_id);
85 /// check detector parameter exists in the database: 1- true, 0 - false, <0 - database operation error
86 static int CheckDetectorParameterExists(int value_id);
87 /// delete detector parameter from the database
88 static int DeleteDetectorParameter(int value_id);
89 /// print all detector parameters
90 static int PrintAll();
91
92 // Getters
93 /// get value id of the current detector parameter
94 int GetValueId() { return i_value_id; }
95 /// get detector name of the current detector parameter
97 /// get parameter id of the current detector parameter
99 /// get start period of the current detector parameter
101 /// get start run of the current detector parameter
102 int GetStartRun() { return i_start_run; }
103 /// get end period of the current detector parameter
104 int GetEndPeriod() { return i_end_period; }
105 /// get end run of the current detector parameter
106 int GetEndRun() { return i_end_run; }
107 /// get value key of the current detector parameter
108 int GetValueKey() { return i_value_key; }
109 /// get parameter value of the current detector parameter
110 unsigned char* GetParameterValue()
111 {
112 unsigned char* tmp_parameter_value = new unsigned char[sz_parameter_value];
113 memcpy(tmp_parameter_value, blob_parameter_value, sz_parameter_value);
114 return tmp_parameter_value;
115 }
116 /// get size of parameter value of the current detector parameter
118 /// get expiry date of the current detector parameter
120 {
121 if (ts_expiry_date == nullptr)
122 return nullptr;
123 else
124 return new TDatime(*ts_expiry_date);
125 }
126
127 // Setters
128 /// set detector name of the current detector parameter
129 int SetDetectorName(TString detector_name);
130 /// set parameter id of the current detector parameter
131 int SetParameterId(int parameter_id);
132 /// set start period of the current detector parameter
133 int SetStartPeriod(int start_period);
134 /// set start run of the current detector parameter
135 int SetStartRun(int start_run);
136 /// set end period of the current detector parameter
137 int SetEndPeriod(int end_period);
138 /// set end run of the current detector parameter
139 int SetEndRun(int end_run);
140 /// set value key of the current detector parameter
141 int SetValueKey(int value_key);
142 /// set parameter value of the current detector parameter
143 int SetParameterValue(unsigned char* parameter_value, Long_t size_parameter_value);
144 /// set expiry date of the current detector parameter
145 int SetExpiryDate(TDatime* expiry_date);
146
147 /// print information about current detector parameter
148 void Print();
149 /* END OF PUBLIC GENERATED PART (SHOULD NOT BE CHANGED MANUALLY) */
150
151 /// write detector parameter value presented by an array (integer value key is optional, default, 0)
153 TString parameter_name,
154 int start_period,
155 int start_run,
156 int end_period,
157 int end_run,
158 vector<UniValue*> parameter_value,
159 int value_key = 0);
160 /// write detector parameter value presented by a single value (integer value key is optional, default, 0)
162 TString parameter_name,
163 int start_period,
164 int start_run,
165 int end_period,
166 int end_run,
167 UniValue* parameter_value,
168 int value_key = 0);
169
170 /// get detector parameter value (integer value key is optional, default, 0)
172 TString parameter_name,
173 int period_number,
174 int run_number,
175 TDatime* usage_time = nullptr,
176 int value_key = 0);
177
178 /// delete detector parameter value (integer value key is optional, default, 0)
179 static int DeleteDetectorParameter(TString detector_name,
180 TString parameter_name,
181 int start_period,
182 int start_run,
183 int end_period,
184 int end_run,
185 TDatime* usage_time,
186 int value_key = 0);
187
188 /// get value of detector parameter presented by an array
189 int GetValue(vector<UniValue*>& parameter_value);
190 /// get value of detector parameter presented by a single value
192 /// set value to detector parameter presented by an array
193 int SetValue(vector<UniValue*> parameter_value);
194 /// set value to detector parameter presented by a single value
195 int SetValue(UniValue* parameter_value);
196
197 /// write ROOT object as a binary parameter to the Database from start run to end one
198 static int WriteObjectBinary(const char* detector_name,
199 const char* parameter_name,
200 int start_period,
201 int start_run,
202 int end_period,
203 int end_run,
204 TObject* ptr_object);
205 /// read ROOT object as a binary parameter from from the Database for the selected run
206 static int ReadObjectBinary(const char* detector_name,
207 const char* parameter_name,
208 int period_number,
209 int run_number,
210 TObject*& ptr_object);
211 /// write ROOT object as a JSON parameter to the Database from start run to end one
212 static int WriteObjectJSON(const char* detector_name,
213 const char* parameter_name,
214 int start_period,
215 int start_run,
216 int end_period,
217 int end_run,
218 TObject* ptr_object);
219 /// read ROOT object as a JSON parameter from from the Database for the selected run
220 static int ReadObjectJSON(const char* detector_name,
221 const char* parameter_name,
222 int period_number,
223 int run_number,
224 TObject*& ptr_object);
225
226 /// write a whole file with parameter value (with given detector and parameter names)
227 /// to the Database from start run to end one
228 static int WriteFile(const char* detector_name,
229 const char* parameter_name,
230 int start_period,
231 int start_run,
232 int end_period,
233 int end_run,
234 const char* file_path);
235 /// read a whole file with parameter value (with given detector and parameter names)
236 /// from the Database for the selected run
237 static int ReadFile(const char* detector_name,
238 const char* parameter_name,
239 int period_number,
240 int run_number,
241 const char* file_path);
242
243 /// get parameters' values corresponding to the specified single condition
244 /// and set owner for search_condition to kTRUE
245 static TObjArray* Search(UniSearchCondition& search_condition);
246 /// get parameters' values corresponding to the specified (vector) conditions
247 /// and set owner for search_condition to kTRUE
248 static TObjArray* Search(TObjArray& search_conditions);
249
250 /// get parameter name of the current parameter value
252 /// get parameter type of the current parameter value
254
255 /// get start period and run of the current parameter value
256 void GetStart(int& start_period, int& start_run);
257 /// get end period and run of the current parameter value
258 void GetEnd(int& end_period, int& end_run);
259 /// set start period and run of the current parameter value
260 int SetStart(int start_period, int start_run);
261 /// set end period and run of the current parameter value
262 int SetEnd(int end_period, int end_run);
263
264 /// print all detector parameters, except expired if the flag is true
265 static int PrintAll(bool isNonExpiredOnly);
266
267 /// Parse detector parameter's values and write them to the database:
268 /// txtFile - path to the text file with parameter values separated by spaces or tabs, e.g.: "value1 value2..."
269 /// if line is started with '#' symbol - it will be skipped (as comments)
270 /// detector_name - detector corresponding to the parameter values
271 /// parameter name - parameter filled by values
272 /// start_period - start period of validity range for the parameter values
273 /// start_run - start run of validity range for the parameter values
274 /// end_period - end period of validity range for the parameter values
275 /// end_run - end run of validity range for the parameter values.
276 /// Function returns row count added to the database.
277 // static int ParseTxt(TString text_file, TString detector_name, TString parameter_name, int start_period, int
278 // start_run, int end_period, int end_run);
279
280 protected:
281 // non-user function for getting parameter value as a binary (char) array
282 unsigned char* GetUNC(enumValueType enum_parameter_type = UndefinedType);
283
284 // non-user function for setting parameter value as a binary (char) array
285 int SetUNC(unsigned char* p_parameter_value, Long_t size_parameter_value);
286
287 // non-user function for writing parameter value (integer value key is optional, default, 0)
289 TString parameter_name,
290 int start_period,
291 int start_run,
292 int end_period,
293 int end_run,
294 unsigned char* parameter_value,
295 Long_t size_parameter_value,
296 enumValueType enum_parameter_type,
297 int value_key = 0);
298
300};
301
302#endif
long Long_t
#define ClassDef(name, id)
Long_t GetParameterValueSize()
get size of parameter value of the current detector parameter
int SetStart(int start_period, int start_run)
set start period and run of the current parameter value
int SetValue(vector< UniValue * > parameter_value)
set value to detector parameter presented by an array
static int WriteObjectBinary(const char *detector_name, const char *parameter_name, int start_period, int start_run, int end_period, int end_run, TObject *ptr_object)
write ROOT object as a binary parameter to the Database from start run to end one
static int WriteObjectJSON(const char *detector_name, const char *parameter_name, int start_period, int start_run, int end_period, int end_run, TObject *ptr_object)
write ROOT object as a JSON parameter to the Database from start run to end one
TDatime * ts_expiry_date
expiry date
enumValueType GetParameterType()
get parameter type of the current parameter value
int SetValueKey(int value_key)
set value key of the current detector parameter
int SetDetectorName(TString detector_name)
set detector name of the current detector parameter
void GetStart(int &start_period, int &start_run)
get start period and run of the current parameter value
static int ReadObjectBinary(const char *detector_name, const char *parameter_name, int period_number, int run_number, TObject *&ptr_object)
read ROOT object as a binary parameter from from the Database for the selected run
int GetStartPeriod()
get start period of the current detector parameter
Long_t sz_parameter_value
size of parameter value
int SetExpiryDate(TDatime *expiry_date)
set expiry date of the current detector parameter
TString GetParameterName()
get parameter name of the current parameter value
void GetEnd(int &end_period, int &end_run)
get end period and run of the current parameter value
UniValue * GetValue()
get value of detector parameter presented by a single value
int SetEnd(int end_period, int end_run)
set end period and run of the current parameter value
unsigned char * GetParameterValue()
get parameter value of the current detector parameter
TDatime * GetExpiryDate()
get expiry date of the current detector parameter
static int DeleteDetectorParameter(int value_id)
delete detector parameter from the database
UniConnection * connectionDB
connection to the database
int SetParameterId(int parameter_id)
set parameter id of the current detector parameter
static TObjArray * Search(UniSearchCondition &search_condition)
get parameters' values corresponding to the specified single condition and set owner for search_condi...
unsigned char * blob_parameter_value
parameter value
int SetEndPeriod(int end_period)
set end period of the current detector parameter
static int WriteFile(const char *detector_name, const char *parameter_name, int start_period, int start_run, int end_period, int end_run, const char *file_path)
write a whole file with parameter value (with given detector and parameter names) to the Database fro...
TString GetDetectorName()
get detector name of the current detector parameter
TString str_detector_name
detector name
int GetParameterId()
get parameter id of the current detector parameter
int SetEndRun(int end_run)
set end run of the current detector parameter
int SetStartRun(int start_run)
set start run of the current detector parameter
int GetEndPeriod()
get end period of the current detector parameter
void Print()
print information about current detector parameter
int SetUNC(unsigned char *p_parameter_value, Long_t size_parameter_value)
int i_parameter_id
parameter id
int GetEndRun()
get end run of the current detector parameter
static int PrintAll()
print all detector parameters
int GetValueId()
get value id of the current detector parameter
UniDetectorParameter(UniConnection *db_connect, int value_id, TString detector_name, int parameter_id, int start_period, int start_run, int end_period, int end_run, int value_key, unsigned char *parameter_value, Long_t size_parameter_value, TDatime *expiry_date)
int SetStartPeriod(int start_period)
set start period of the current detector parameter
static UniDetectorParameter * GetDetectorParameter(int value_id)
get detector parameter from the database
static int CheckDetectorParameterExists(int value_id)
check detector parameter exists in the database: 1- true, 0 - false, <0 - database operation error
static int ReadFile(const char *detector_name, const char *parameter_name, int period_number, int run_number, const char *file_path)
read a whole file with parameter value (with given detector and parameter names) from the Database fo...
int GetValueKey()
get value key of the current detector parameter
int GetStartRun()
get start run of the current detector parameter
static UniDetectorParameter * CreateDetectorParameter(TString detector_name, int parameter_id, int start_period, int start_run, int end_period, int end_run, int value_key, unsigned char *parameter_value, Long_t size_parameter_value, TDatime *expiry_date)
add new detector parameter to the database
int SetParameterValue(unsigned char *parameter_value, Long_t size_parameter_value)
set parameter value of the current detector parameter
unsigned char * GetUNC(enumValueType enum_parameter_type=UndefinedType)
Parse detector parameter's values and write them to the database: txtFile - path to the text file wit...
int i_start_period
start period
static int ReadObjectJSON(const char *detector_name, const char *parameter_name, int period_number, int run_number, TObject *&ptr_object)
read ROOT object as a JSON parameter from from the Database for the selected run
enumValueType
@ UndefinedType
Definition json.hpp:4446