8 if (connDb ==
nullptr) {
9 cout <<
"ERROR: connection to the UniConDa database failed" << endl;
16 "set file_path = $1 || regexp_replace(file_path, '^.+[/\\\\]', '') "
17 "where period_number = $2 and run_number >= $3 and run_number <= $4");
27 stmt->
SetInt(1, period_number);
28 stmt->
SetInt(2, start_run);
33 cout <<
"ERROR: updating information on raw file paths failed" << endl;
48 if (connDb ==
nullptr) {
49 cout <<
"ERROR: connection to the UniConDa database failed" << endl;
56 "update run_period set "
57 "start_datetime = (select start_datetime from run_ where period_number = $1 and run_number = $2), "
58 "end_datetime = (select end_datetime from run_ where period_number = $3 and run_number = $4) "
59 "where period_number = $5");
63 stmt->
SetInt(0, period_number);
64 stmt->
SetInt(1, start_run);
65 stmt->
SetInt(2, period_number);
67 stmt->
SetInt(4, period_number);
71 cout <<
"ERROR: updating information on the start and end time of the run period failed" << endl;
90 int prev_start_run = -1,
91 int prev_end_run = -1,
92 bool delete_prev_runs =
false)
95 if (connDb ==
nullptr) {
96 cout <<
"ERROR: connection to the UniConDa database failed" << endl;
103 "set start_run = $1 "
104 "where start_period = $2 and ($3 = -1 or $3 = start_run)");
108 stmt->
SetInt(0, new_start_run);
109 stmt->
SetInt(1, period_number);
110 stmt->
SetInt(2, prev_start_run);
114 cout <<
"ERROR: updating information on the start number of the detector parameters failed" << endl;
123 "where end_period = $2 and ($3 = -1 or $3 = end_run)");
128 stmt->
SetInt(0, new_end_run);
129 stmt->
SetInt(1, period_number);
130 stmt->
SetInt(2, prev_end_run);
134 cout <<
"ERROR: updating information on the end number of the detector parameters failed" << endl;
141 if (delete_prev_runs) {
143 "where period_number = $1 and (run_number = $2 or run_number = $3)");
147 stmt->
SetInt(0, period_number);
148 stmt->
SetInt(1, prev_start_run);
149 stmt->
SetInt(2, prev_end_run);
153 cout <<
"ERROR: deleting previous runs failed" << endl;
175 cout <<
"run count = " << run_count << endl;
178 for (
int i = 0;
i < run_count;
i++) {
181 if (pCurrentRun ==
nullptr) {
182 cout <<
"The function encountered with errors: no experimental run was found ("
191 double* run_energy = pCurrentRun->
GetEnergy();
196 if ((run_beam ==
"") || (run_energy ==
nullptr) || (run_field ==
nullptr)) {
198 TString elog_beam =
"", elog_target =
"";
199 double* elog_energy =
nullptr;
200 int* elog_current =
nullptr;
208 TIter next(pRecords);
210 while ((curRecord = (
ElogRecord*)next()) !=
nullptr) {
212 if (tmp_elog_beam !=
"")
213 elog_beam = tmp_elog_beam;
215 if (tmp_elog_target !=
"")
219 if (curRecord->
GetSp41() !=
nullptr)
220 elog_current = curRecord->
GetSp41();
221 int tmp_elog_type = curRecord->
GetTypeId();
222 if ((elog_type == -1) && (tmp_elog_type >= 1) && (tmp_elog_type <= 3))
233 if ((run_beam ==
"") && (elog_beam !=
"")) {
235 <<
". Recording beam particle... new value = " << elog_beam <<
" (old value = " << run_beam <<
")"
239 <<
". Recording target particle... new value = " << elog_target
240 <<
" (old value = " << (run_target ==
"" ?
"-" : run_target) <<
")" << endl;
243 if ((run_energy ==
nullptr) && (elog_energy !=
nullptr)) {
245 <<
". Recording beam energy... new value = " << *elog_energy
246 <<
" (old value = " << (run_energy ==
nullptr ? 0 : (*run_energy)) <<
")" << endl;
249 if ((run_field ==
nullptr) && (elog_current !=
nullptr)) {
251 <<
". Recording field voltage... new value = " << ((*elog_current) / 900.0 * 55.87)
252 <<
" (old value = " << (run_field ==
nullptr ? 0 : (*run_field)) <<
")" << endl;
253 pCurrentRun->
SetFieldVoltage(
new double((*elog_current) / 900.0 * 55.87));
255 if ((elog_type != -1) && (run_type != elog_type)) {
257 <<
". Recording run type... new value = " << elog_type <<
" (old value = " << run_type <<
")"
270 int end_run = 100000,
271 bool isChangeRunType =
false,
272 bool isShowInfo =
false)
278 cout <<
"run count = " << run_count << endl;
281 for (
int i = 0;
i < run_count;
i++) {
284 if (pCurrentRun ==
nullptr) {
285 cout <<
"The function encountered with errors: no experimental run was found ("
294 double* uniconda_energy = pCurrentRun->
GetEnergy();
296 int uniconda_type = pCurrentRun->
GetRunType();
300 if (arrayRecords ==
nullptr) {
301 cout <<
"The function encountered with errors: no e-Log record was found (" << run_numbers[
i].
period_number
302 <<
":" << run_numbers[
i].
run_number <<
"). This run will be skipped!" << endl;
305 bool isElogRecord =
false;
306 TString elog_beam =
"", elog_target =
"";
307 double* elog_energy =
nullptr;
311 int tmp_elog_type = pRecord->
GetTypeId();
312 if ((tmp_elog_type < 1) || (tmp_elog_type > 3))
316 elog_beam = pRecord->
GetBeam();
318 if ((elog_energy ==
nullptr) && (pRecord->
GetEnergy() !=
nullptr))
325 cout <<
"ERROR: different beam info found for run " << run_numbers[
i].
period_number <<
":"
326 << run_numbers[
i].
run_number <<
" (" << uniconda_beam <<
" <> " << elog_beam <<
")" << endl;
328 cout <<
"ERROR: different target info found for run " << run_numbers[
i].
period_number <<
":"
329 << run_numbers[
i].
run_number <<
" (" << uniconda_target <<
" <> " << elog_target <<
")" << endl;
332 TString elog_previous_beam =
"", elog_previous_target =
"";
335 if (arrayPreviousRecords !=
nullptr) {
336 for (
int j = 0; j < arrayPreviousRecords->
GetEntriesFast(); j++) {
338 int tmp_elog_type = pRecord->
GetTypeId();
339 if ((tmp_elog_type < 1) || (tmp_elog_type > 3))
342 elog_previous_beam = pRecord->
GetBeam();
343 elog_previous_target = pRecord->
GetTarget();
348 cout <<
"WARNING: no previous e-Log record found for run " << run_numbers[
i].
period_number <<
":"
357 cout <<
"INFO: the same beam information found in the previous e-Log record for run "
361 <<
"ERROR: no beam information found in e-Log for run " << run_numbers[
i].
period_number <<
":"
367 cout <<
"INFO: the same target information found in the previous e-Log record for run "
370 cout <<
"ERROR: different target info found for run " << run_numbers[
i].
period_number <<
":"
371 << run_numbers[
i].
run_number <<
" (" << uniconda_target <<
" <> " << elog_previous_target <<
")"
376 if (elog_energy !=
nullptr) {
377 if (uniconda_energy ==
nullptr)
378 cout <<
"ERROR: no beam energy information found in UniConDa for run " << run_numbers[
i].
period_number
380 else if (((*uniconda_energy) - (*elog_energy)) > 0.000001)
381 cout <<
"ERROR: different beam energy found for run " << run_numbers[
i].
period_number <<
":"
382 << run_numbers[
i].
run_number <<
" (" << *uniconda_energy <<
" <> " << *elog_energy <<
")" << endl;
384 if (uniconda_energy ==
nullptr)
385 cout <<
"WARNING: no beam energy information found in e-Log and UniConDa for run "
389 double* elog_previous_energy =
nullptr;
392 if (arrayPreviousRecords !=
nullptr) {
393 for (
int j = 0; j < arrayPreviousRecords->
GetEntriesFast(); j++) {
396 elog_previous_energy = pRecord->
GetEnergy();
401 if ((elog_previous_energy !=
nullptr) and (((*uniconda_energy) - (*elog_previous_energy)) < 0.000001)) {
403 cout <<
"INFO: the same beam energy information found in the previous e-Log record for run "
406 cout <<
"ERROR: no beam energy information found in e-Log for run " << run_numbers[
i].
period_number
412 if (elog_type != -1) {
413 if (uniconda_type != elog_type) {
414 cout <<
"ERROR: different run type found for run " << run_numbers[
i].
period_number <<
":"
415 << run_numbers[
i].
run_number <<
" (" << uniconda_type <<
" <> " << elog_type <<
")" << endl;
422 int elog_previous_type = -1;
425 if (arrayPreviousRecords !=
nullptr) {
426 for (
int j = 0; j < arrayPreviousRecords->
GetEntriesFast(); j++) {
428 int tmp_previous_elog_type = pRecord->
GetTypeId();
429 if ((tmp_previous_elog_type >= 1) && (tmp_previous_elog_type <= 3))
430 elog_previous_type = pRecord->
GetTypeId();
433 if (elog_previous_type != -1)
434 if (uniconda_type == elog_previous_type) {
436 cout <<
"INFO: the run type found in the previous e-Log record for run "
439 cout <<
"ERROR: different run type found for run " << run_numbers[
i].
period_number <<
":"
440 << run_numbers[
i].
run_number <<
" (" << uniconda_type <<
" <> " << elog_previous_type <<
")"
447 cout <<
"ERROR: no run type is defined in e-Log for run " << run_numbers[
i].
period_number <<
":"
459 int start_run = 8968,
461 int prev_start_run = 1,
462 int prev_end_run = 100000)
ElogRecord.h Class for the table: record_.
int * GetSp41()
get sp 41 of the current record
double * GetEnergy()
get energy of the current record
TString GetBeam()
get beam of the current record
TString GetTarget()
get target of the current record
int GetTypeId()
get type id of the current record
static TObjArray * GetRecords(int period_number, int run_number, int findNeighbourRun=0)
get array of ElogRecord-s for a given or a neighbour run (the same period) from the database if findN...
Int_t GetEntriesFast() const
TObject * At(Int_t idx) const override
virtual TSQLStatement * Statement(const char *, Int_t=100)
virtual Bool_t NextIteration()=0
virtual Bool_t SetString(Int_t, const char *, Int_t=256)
virtual Bool_t Process()=0
virtual Bool_t SetInt(Int_t, Int_t)
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
TSubString Strip(EStripType s=kTrailing, char c=' ') const
static TString Format(const char *fmt,...)
static UniConnection * Open()
TSQLServer * GetSQLServer()
UniRun.h Class for the table: run_.
double * GetEnergy()
get energy of the current run
int GetRunType()
get run type of the current run
static UniRun * GetRun(int period_number, int run_number)
get run from the database
int SetTargetParticle(TString target_particle)
set target particle of the current run
int SetRunType(int run_type)
set run type of the current run
TString GetBeamParticle()
get beam particle of the current run
double * GetFieldVoltage()
get field voltage of the current run
static int GetRunNumbers(UniqueRunNumber *&run_numbers, int start_period, int start_run=0, int end_period=-1, int end_run=-1)
get numbers of runs stored in the Database for a selected range
int SetFieldVoltage(double *field_voltage)
set field voltage of the current run
int SetEnergy(double *energy)
set energy of the current run
int SetBeamParticle(TString beam_particle)
set beam particle of the current run
TString GetTargetParticle()
get target particle of the current run
int compare_uniconda_elog(int period=9, int start_run=1, int end_run=100000, bool isChangeRunType=false, bool isShowInfo=false)
int update_raw_file_path(const char *raw_file_directory="/eos/nica/bmn/exp/raw/run9/beam/", int period_number=9, int start_run=1, int end_run=100000)
int postrun_update(int period_number=9, int start_run=8968, int end_run=9094, int prev_start_run=1, int prev_end_run=100000)
Main post run procedure to correct|update obtained metadata parameters.
int update_detector_parameter_range(int period_number, int new_start_run, int new_end_run, int prev_start_run=-1, int prev_end_run=-1, bool delete_prev_runs=false)
int update_run_period_time(int period_number, int start_run, int end_run)
int update_run_metadata_from_elog(int period=9, int start_run=1, int end_run=100000)