| 58 |
VALIDATION = 0; |
VALIDATION = 0; |
| 59 |
} |
} |
| 60 |
|
|
| 61 |
|
|
| 62 |
void GL_RUN::Clear() { |
void GL_RUN::Clear() { |
| 63 |
ID = 0; |
ID = 0; |
| 64 |
ID_RUN_FRAG = 0; |
ID_RUN_FRAG = 0; |
| 123 |
OBT2 = 0; |
OBT2 = 0; |
| 124 |
PKT1 = 0; |
PKT1 = 0; |
| 125 |
PKT2 = 0; |
PKT2 = 0; |
| 126 |
|
BOOT_NUMBER = 0; |
| 127 |
|
VALIDATION = 0; |
| 128 |
} |
} |
| 129 |
|
|
| 130 |
GL_CALO_CALIB::GL_CALO_CALIB(){ |
GL_CALO_CALIB::GL_CALO_CALIB(){ |
| 330 |
CAL_DSP_MASK = 0; |
CAL_DSP_MASK = 0; |
| 331 |
}; |
}; |
| 332 |
|
|
| 333 |
|
void GL_RUN::Set_GL_RUN(TSQLRow *Row){ |
| 334 |
|
for( Int_t t = 0; t < 30; t++){ |
| 335 |
|
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
| 336 |
|
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
| 337 |
|
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
| 338 |
|
if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); |
| 339 |
|
if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 340 |
|
if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 341 |
|
if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); |
| 342 |
|
if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); |
| 343 |
|
if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); |
| 344 |
|
if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); |
| 345 |
|
if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
| 346 |
|
if (t==11) EV_FROM = (UInt_t)atoll(Row->GetField(t)); |
| 347 |
|
if (t==12) EV_TO = (UInt_t)atoll(Row->GetField(t)); |
| 348 |
|
if (t==13) NEVENTS = (UInt_t)atoll(Row->GetField(t)); |
| 349 |
|
if (t==14) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
| 350 |
|
if (t==15) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
| 351 |
|
if (t==16) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); |
| 352 |
|
if (t==17) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
| 353 |
|
if (t==18) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
| 354 |
|
if (t==19) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); |
| 355 |
|
if (t==20) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); |
| 356 |
|
if (t==21) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); |
| 357 |
|
if (t==22) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); |
| 358 |
|
if (t==23) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); |
| 359 |
|
if (t==24) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); |
| 360 |
|
if (t==25) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); |
| 361 |
|
if (t==26) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); |
| 362 |
|
if (t==27) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
| 363 |
|
if (t==28) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
| 364 |
|
if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
| 365 |
|
}; |
| 366 |
|
|
| 367 |
|
} |
| 368 |
|
|
| 369 |
|
|
| 370 |
/** |
/** |
| 371 |
* Function to fill the GL_RUN table of the DB. |
* Function to fill the GL_RUN table of the DB. |
| 442 |
myquery << (UInt_t)BOOT_NUMBER << "','"; |
myquery << (UInt_t)BOOT_NUMBER << "','"; |
| 443 |
myquery << (UInt_t)VALIDATION << "');"; |
myquery << (UInt_t)VALIDATION << "');"; |
| 444 |
// |
// |
| 445 |
//printf("myquery is %s \n",myquery.str().c_str()); |
// printf("myquery is %s \n",myquery.str().c_str()); |
| 446 |
// |
// |
| 447 |
dbc->Query(myquery.str().c_str()); |
dbc->Query(myquery.str().c_str()); |
| 448 |
// |
// |
| 576 |
myquery << ",VALIDATION"; |
myquery << ",VALIDATION"; |
| 577 |
myquery << " from GL_RUN where ID=" << run << ";"; |
myquery << " from GL_RUN where ID=" << run << ";"; |
| 578 |
// |
// |
| 579 |
|
// printf(" myquery is %s \n",myquery.str().c_str()); |
| 580 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
| 581 |
if(!pResult->GetRowCount())return(-50); |
// |
| 582 |
|
// printf(" getrowcount %i \n",pResult->GetRowCount()); |
| 583 |
|
// |
| 584 |
|
if( !pResult->GetRowCount() ) return(-50); |
| 585 |
|
// |
| 586 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
| 587 |
Row = pResult->Next(); |
Row = pResult->Next(); |
| 588 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
| 589 |
|
// Set_GL_RUN(Row); |
| 590 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
| 591 |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
| 592 |
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
| 593 |
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
| 594 |
if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); |
if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); |
| 595 |
if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 596 |
if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 597 |
if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); |
if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); |
| 598 |
if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); |
if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); |
| 599 |
if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); |
if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); |
| 600 |
if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); |
if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); |
| 601 |
if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t)); |
if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t)); |
| 602 |
if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t)); |
if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t)); |
| 603 |
if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t)); |
if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t)); |
| 604 |
if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
| 605 |
if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
| 606 |
if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); |
if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); |
| 607 |
if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
| 608 |
if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
| 609 |
if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); |
if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); |
| 610 |
if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); |
if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); |
| 611 |
if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); |
if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); |
| 612 |
if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); |
if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); |
| 613 |
if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); |
if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); |
| 614 |
if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); |
if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); |
| 615 |
if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
| 616 |
if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
| 617 |
if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); |
if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); |
| 618 |
if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); |
if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); |
| 619 |
if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
| 620 |
if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
| 621 |
}; |
}; |
| 622 |
}; |
}; |
| 623 |
delete pResult; |
// delete pResult; |
| 624 |
|
return(0); |
|
return 0; |
|
|
|
|
| 625 |
}; |
}; |
| 626 |
|
|
| 627 |
/** |
/** |
| 632 |
* |
* |
| 633 |
*/ |
*/ |
| 634 |
Int_t GL_RUN::Query_GL_RUN_FRAGMENTS(TString where, TSQLServer *dbc){ |
Int_t GL_RUN::Query_GL_RUN_FRAGMENTS(TString where, TSQLServer *dbc){ |
|
// Bool_t debug = 1; |
|
| 635 |
// MySQL variables |
// MySQL variables |
| 636 |
TSQLResult *pResult; |
TSQLResult *pResult; |
| 637 |
TSQLRow *Row; |
TSQLRow *Row; |
| 639 |
int r; |
int r; |
| 640 |
stringstream myquery; |
stringstream myquery; |
| 641 |
// ---------------- |
// ---------------- |
|
// NB! unsigned long long integers: when set to a number use ULL to store the correct number |
|
| 642 |
myquery.str(""); |
myquery.str(""); |
| 643 |
myquery << " select "; |
myquery << " select "; |
|
// myquery << " * "; |
|
| 644 |
myquery << "ID"; |
myquery << "ID"; |
| 645 |
|
myquery << ",ID_RUN_FRAG"; |
| 646 |
myquery << ",ID_ROOT_L0"; |
myquery << ",ID_ROOT_L0"; |
| 647 |
|
myquery << ",ID_ROOT_L2"; |
| 648 |
myquery << ",RUNHEADER_TIME"; |
myquery << ",RUNHEADER_TIME"; |
| 649 |
myquery << ",RUNTRAILER_TIME"; |
myquery << ",RUNTRAILER_TIME"; |
| 650 |
myquery << ",RUNHEADER_OBT"; |
myquery << ",RUNHEADER_OBT"; |
| 670 |
myquery << ",TRK_CALIB_USED"; |
myquery << ",TRK_CALIB_USED"; |
| 671 |
myquery << ",CAL_DSP_MASK"; |
myquery << ",CAL_DSP_MASK"; |
| 672 |
myquery << ",BOOT_NUMBER"; |
myquery << ",BOOT_NUMBER"; |
| 673 |
|
myquery << ",VALIDATION"; |
| 674 |
myquery << " from GL_RUN_FRAGMENTS where " << where.Data() << ";"; |
myquery << " from GL_RUN_FRAGMENTS where " << where.Data() << ";"; |
| 675 |
// |
// |
| 676 |
|
// printf(" query is %s \n",myquery.str().c_str()); |
| 677 |
|
// |
| 678 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
| 679 |
if(!pResult->GetRowCount())return(-50); |
if(!pResult->GetRowCount())return(-50); |
| 680 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
| 681 |
Row = pResult->Next(); |
Row = pResult->Next(); |
| 682 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
| 683 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
| 684 |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
| 685 |
if (t== 1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
| 686 |
if (t== 2) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
| 687 |
if (t== 3) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); |
| 688 |
if (t== 4) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); |
if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 689 |
if (t== 5) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); |
if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 690 |
if (t== 6) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); |
if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); |
| 691 |
if (t== 7) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); |
if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); |
| 692 |
if (t== 8) EV_FROM = (UInt_t)atoll(Row->GetField(t)); |
if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); |
| 693 |
if (t== 9) EV_TO = (UInt_t)atoll(Row->GetField(t)); |
if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); |
| 694 |
if (t==10) NEVENTS = (UInt_t)atoll(Row->GetField(t)); |
if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t)); |
| 695 |
if (t==11) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t)); |
| 696 |
if (t==12) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t)); |
| 697 |
if (t==13) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); |
if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
| 698 |
if (t==14) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
| 699 |
if (t==15) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); |
| 700 |
if (t==16) PRH_VAR_TRG_MODE_A = (UInt_t)atoll(Row->GetField(t)); |
if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
| 701 |
if (t==17) PRH_VAR_TRG_MODE_B = (UInt_t)atoll(Row->GetField(t)); |
if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
| 702 |
if (t==18) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); |
if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); |
| 703 |
if (t==19) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); |
if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); |
| 704 |
if (t==20) RM_ACQ_AFTER_CALIB = (UInt_t)atoll(Row->GetField(t)); |
if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); |
| 705 |
if (t==21) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); |
if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); |
| 706 |
if (t==22) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); |
| 707 |
if (t==23) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); |
| 708 |
if (t==24) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); |
if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
| 709 |
if (t==25) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); |
if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
| 710 |
if (t==26) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); |
| 711 |
}; |
if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); |
| 712 |
|
if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
| 713 |
|
if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
| 714 |
|
}; |
| 715 |
}; |
}; |
| 716 |
delete pResult; |
// delete pResult; |
| 717 |
|
return(0); |
|
return 0; |
|
|
|
|
| 718 |
};// **************************************************** |
};// **************************************************** |
| 719 |
|
|
| 720 |
/** |
/** |
| 721 |
* Function to query the GL_ROOT table of the DB. |
* Function to query the GL_ROOT table of the DB. |
| 722 |
* |
* |
| 761 |
* Function to query the GL_TRK_CALIB table of the DB. |
* Function to query the GL_TRK_CALIB table of the DB. |
| 762 |
* |
* |
| 763 |
* \param run starting time |
* \param run starting time |
| 764 |
|
* \param dbc DB server |
| 765 |
* \return struct of type GL_TRK_CALIB_data, which stores the query result |
* \return struct of type GL_TRK_CALIB_data, which stores the query result |
| 766 |
*/ |
*/ |
| 767 |
Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(UInt_t time, TSQLServer *dbc){ |
Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(UInt_t time, TSQLServer *dbc){ |
| 773 |
stringstream myquery; |
stringstream myquery; |
| 774 |
// ---------------- |
// ---------------- |
| 775 |
myquery.str(""); |
myquery.str(""); |
| 776 |
myquery << "select ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,OBT2,PKT1,PKT2 from GL_TRK_CALIB where FROM_TIME <= "<< time; |
myquery << "select ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,OBT2,PKT1,PKT2,BOOT_NUMBER,VALIDATION from GL_TRK_CALIB where FROM_TIME <= "<< time; |
| 777 |
myquery << " AND VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
myquery << " AND VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
| 778 |
// myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; |
// myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; |
| 779 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
| 782 |
Row = pResult->Next(); |
Row = pResult->Next(); |
| 783 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
| 784 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
| 785 |
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
stringstream row; |
| 786 |
if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
row.str(""); |
| 787 |
if (t==2) EV_ROOT_CALIBTRK1 = (UInt_t)atoll(Row->GetField(t)); |
row << "0" << Row->GetField(t); // add leading 0 since we have two fields that could be "null" and we want to avoid crashes due to atoll |
| 788 |
if (t==3) EV_ROOT_CALIBTRK2 = (UInt_t)atoll(Row->GetField(t)); |
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
| 789 |
if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
| 790 |
if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==2) EV_ROOT_CALIBTRK1 = (UInt_t)atoll(row.str().c_str()); |
| 791 |
|
if (t==3) EV_ROOT_CALIBTRK2 = (UInt_t)atoll(row.str().c_str()); |
| 792 |
|
if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 793 |
|
if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 794 |
// |
// |
| 795 |
if (t==6) OBT1 = (UInt_t)atoll(Row->GetField(t)); |
if (t==6) OBT1 = (UInt_t)atoll(Row->GetField(t)); |
| 796 |
if (t==7) OBT2 = (UInt_t)atoll(Row->GetField(t)); |
if (t==7) OBT2 = (UInt_t)atoll(Row->GetField(t)); |
| 797 |
if (t==8) PKT1 = (UInt_t)atoll(Row->GetField(t)); |
if (t==8) PKT1 = (UInt_t)atoll(Row->GetField(t)); |
| 798 |
if (t==9) PKT2 = (UInt_t)atoll(Row->GetField(t)); |
if (t==9) PKT2 = (UInt_t)atoll(Row->GetField(t)); |
| 799 |
}; |
if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
| 800 |
|
if (t==11) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
| 801 |
|
}; |
| 802 |
}; |
}; |
| 803 |
delete pResult; |
delete pResult; |
| 804 |
|
// |
| 805 |
|
// if ( TO_TIME < time ) return(51); |
| 806 |
// |
// |
|
if(TO_TIME < time)return(51); |
|
| 807 |
if ( (!OBT1 && !PKT1 ) || (!OBT2 && !PKT2) ) return(52); // ONE CALIBRATION PACKET IS MISSING! |
if ( (!OBT1 && !PKT1 ) || (!OBT2 && !PKT2) ) return(52); // ONE CALIBRATION PACKET IS MISSING! |
| 808 |
// |
// |
| 809 |
return 0; |
return 0; |
| 816 |
* \param run starting time |
* \param run starting time |
| 817 |
* \return struct of type GL_CALO_CALIB_data, which stores the query result |
* \return struct of type GL_CALO_CALIB_data, which stores the query result |
| 818 |
*/ |
*/ |
| 819 |
Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB(UInt_t time, UInt_t section, TSQLServer *dbc){ |
Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB(UInt_t time, UInt_t &uptime, UInt_t section, TSQLServer *dbc){ |
| 820 |
// MySQL variables |
// MySQL variables |
| 821 |
TSQLResult *pResult; |
TSQLResult *pResult; |
| 822 |
TSQLRow *Row; |
TSQLRow *Row; |
| 823 |
int t; |
int t; |
| 824 |
stringstream myquery; |
stringstream myquery; |
| 825 |
|
uptime = 0; |
| 826 |
// |
// |
| 827 |
// select the correct calibration |
// select the correct calibration |
| 828 |
// |
// |
| 830 |
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section; |
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section; |
| 831 |
myquery << " and FROM_TIME <= " << time; |
myquery << " and FROM_TIME <= " << time; |
| 832 |
myquery << " and TO_TIME > " << time; |
myquery << " and TO_TIME > " << time; |
| 833 |
myquery << " and VALIDATION=1;"; |
myquery << " ;"; |
| 834 |
|
//myquery << " and VALIDATION=1;"; |
| 835 |
// |
// |
| 836 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
| 837 |
|
// printf(" mysquery is %s\n",myquery.str().c_str()); |
| 838 |
|
// |
| 839 |
|
if( !pResult->GetRowCount() ) return(-54); |
| 840 |
|
Row = pResult->Next(); |
| 841 |
|
if( Row == NULL ) return (-54); |
| 842 |
|
// |
| 843 |
|
uptime = (UInt_t)atoll(Row->GetField(2)); |
| 844 |
// |
// |
| 845 |
// if it is corrupted validation is 0 and we have no results from the query... |
// if it is corrupted validation is 0 and we have no results from the query... |
| 846 |
// |
// |
| 847 |
if( !pResult->GetRowCount() ){ |
if( atoi(Row->GetField(4)) == 0 ){ // if validation = 0 |
|
// pResult->Delete(); |
|
| 848 |
// |
// |
| 849 |
// in this case take relax the conditions and take the valid calibration that preceed the correct one |
// in this case take relax the conditions and take the valid calibration that preceed the correct one |
| 850 |
// |
// |
| 853 |
myquery << " and FROM_TIME <= " << time; |
myquery << " and FROM_TIME <= " << time; |
| 854 |
myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
| 855 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
| 856 |
|
// printf(" mysquery is %s\n",myquery.str().c_str()); |
| 857 |
// |
// |
| 858 |
// if no results yet quit with error |
// if no results yet quit with error |
| 859 |
// |
// |
| 860 |
if( !pResult->GetRowCount() ) return (-54); |
if( !pResult->GetRowCount() ) return (-54); |
| 861 |
|
// |
| 862 |
|
Row = pResult->Next(); |
| 863 |
|
// |
| 864 |
}; |
}; |
| 865 |
// |
// |
| 866 |
// store infos and exit |
// store infos and exit |
| 867 |
// |
// |
|
Row = pResult->Next(); |
|
| 868 |
if( Row == NULL ) return (-54); |
if( Row == NULL ) return (-54); |
| 869 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
| 870 |
if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
| 892 |
// ---------------- |
// ---------------- |
| 893 |
myquery.str(""); |
myquery.str(""); |
| 894 |
myquery << "select * from GL_S4_CALIB where FROM_TIME <= "<< time; |
myquery << "select * from GL_S4_CALIB where FROM_TIME <= "<< time; |
| 895 |
myquery << " AND VALIDATION = 1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; |
| 896 |
// myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; |
// myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; |
| 897 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
| 898 |
if(!pResult->GetRowCount())return (-55);//throw -55; |
if(!pResult->GetRowCount())return (-55);//throw -55; |
| 1057 |
toffset = (UInt_t)atoll(Row->GetField(1)) - (UInt_t)(this->DBobt((UInt_t)atoll(Row->GetField(0)))/1000) + t0; |
toffset = (UInt_t)atoll(Row->GetField(1)) - (UInt_t)(this->DBobt((UInt_t)atoll(Row->GetField(0)))/1000) + t0; |
| 1058 |
}; |
}; |
| 1059 |
}; |
}; |
| 1060 |
|
// |
| 1061 |
|
file->Close(); |
| 1062 |
delete pResult; |
delete pResult; |
| 1063 |
}; |
}; |
| 1064 |
|
|
| 1105 |
return(pkt_num); |
return(pkt_num); |
| 1106 |
// |
// |
| 1107 |
}; |
}; |
| 1108 |
|
|
| 1109 |
|
/* |
| 1110 |
|
* |
| 1111 |
|
* Convert the time in the DB from UInt_t to a string |
| 1112 |
|
* |
| 1113 |
|
* @param dbt time in the DB |
| 1114 |
|
* @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK |
| 1115 |
|
* |
| 1116 |
|
*/ |
| 1117 |
|
TString GL_TIMESYNC::ConvertTime(TString &tzone, UInt_t dbt){ |
| 1118 |
|
// |
| 1119 |
|
TDatime *time = new TDatime(); |
| 1120 |
|
TString rtime; |
| 1121 |
|
Bool_t found = false; |
| 1122 |
|
// |
| 1123 |
|
time->Set(dbt,false); // UTC (Coordinated Universal Time) |
| 1124 |
|
// |
| 1125 |
|
if ( !strcmp(tzone.Data(),"MSK") || !strcmp(tzone.Data(),"MWT") ){ |
| 1126 |
|
// |
| 1127 |
|
UInt_t timeMSK = time->Convert() + 60*60*3; // UTC (Coordinated Universal Time) + 3hs = Moscow Winter Time |
| 1128 |
|
time->Set(timeMSK,false); |
| 1129 |
|
found = true; |
| 1130 |
|
// |
| 1131 |
|
}; |
| 1132 |
|
// |
| 1133 |
|
if ( !strcmp(tzone.Data(),"CET") ){ |
| 1134 |
|
// |
| 1135 |
|
UInt_t timeCET = time->Convert() + 60*60*1; // CET (Central European Time) = UTC + 1 hs |
| 1136 |
|
time->Set(timeCET,false); |
| 1137 |
|
found = true; |
| 1138 |
|
// |
| 1139 |
|
}; |
| 1140 |
|
// |
| 1141 |
|
if ( !strcmp(tzone.Data(),"CEST") ){ |
| 1142 |
|
// |
| 1143 |
|
UInt_t timeCEST = time->Convert() + 60*60*2; // CEST (Central European Summer Time) = UTC + 2 h |
| 1144 |
|
time->Set(timeCEST,false); |
| 1145 |
|
found = true; |
| 1146 |
|
// |
| 1147 |
|
}; |
| 1148 |
|
// |
| 1149 |
|
if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST")){ |
| 1150 |
|
// |
| 1151 |
|
UInt_t timeMSD = time->Convert() + 60*60*4; // MSD (Moscow Summer Time) = UTC + 4 h |
| 1152 |
|
time->Set(timeMSD,false); |
| 1153 |
|
found = true; |
| 1154 |
|
// |
| 1155 |
|
}; |
| 1156 |
|
// |
| 1157 |
|
if ( !found && strcmp(tzone.Data(),"UTC") && strcmp(tzone.Data(),"GMT") && strcmp(tzone.Data(),"") ){ |
| 1158 |
|
printf("\n Unknown time zone %s using UTC \n",tzone.Data()); |
| 1159 |
|
tzone = "UTC"; |
| 1160 |
|
}; |
| 1161 |
|
// |
| 1162 |
|
rtime = time->AsSQLString(); |
| 1163 |
|
// |
| 1164 |
|
return(rtime); |
| 1165 |
|
} |
| 1166 |
|
|
| 1167 |
|
/* |
| 1168 |
|
* |
| 1169 |
|
* Convert the time in the DB from UInt_t to a string |
| 1170 |
|
* |
| 1171 |
|
* @param dbt time in the DB |
| 1172 |
|
* @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK |
| 1173 |
|
* |
| 1174 |
|
*/ |
| 1175 |
|
TString GL_TIMESYNC::UnConvertTime(TString &tzone, UInt_t dbt){ |
| 1176 |
|
// |
| 1177 |
|
TDatime *time = new TDatime(); |
| 1178 |
|
TString rtime; |
| 1179 |
|
// |
| 1180 |
|
Bool_t found = false; |
| 1181 |
|
// |
| 1182 |
|
time->Set(dbt,false); // tzone |
| 1183 |
|
// |
| 1184 |
|
if ( !strcmp(tzone.Data(),"MSK") || !strcmp(tzone.Data(),"MWT") ){ |
| 1185 |
|
// |
| 1186 |
|
UInt_t timeUTC = time->Convert() - 60*60*3; // UTC (Coordinated Universal Time) = Moscow Winter Time - 3hs |
| 1187 |
|
time->Set(timeUTC,false); |
| 1188 |
|
found = true; |
| 1189 |
|
// |
| 1190 |
|
}; |
| 1191 |
|
// |
| 1192 |
|
if ( !strcmp(tzone.Data(),"CET") ){ |
| 1193 |
|
// |
| 1194 |
|
UInt_t timeCET = time->Convert() - 60*60*1; // CET (Central European Time) - 1 hs = UTC |
| 1195 |
|
time->Set(timeCET,false); |
| 1196 |
|
found = true; |
| 1197 |
|
// |
| 1198 |
|
}; |
| 1199 |
|
// |
| 1200 |
|
if ( !strcmp(tzone.Data(),"CEST") ){ |
| 1201 |
|
// |
| 1202 |
|
UInt_t timeCEST = time->Convert() - 60*60*2; // CEST (Central European Summer Time) - 2 h = UTC |
| 1203 |
|
time->Set(timeCEST,false); |
| 1204 |
|
found = true; |
| 1205 |
|
// |
| 1206 |
|
}; |
| 1207 |
|
// |
| 1208 |
|
if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST") ){ |
| 1209 |
|
// |
| 1210 |
|
UInt_t timeMSD = time->Convert() - 60*60*4; // MSD (Moscow Summer Time) - 4 h = UTC |
| 1211 |
|
time->Set(timeMSD,false); |
| 1212 |
|
found = true; |
| 1213 |
|
// |
| 1214 |
|
}; |
| 1215 |
|
// |
| 1216 |
|
if ( !found && strcmp(tzone.Data(),"UTC") && strcmp(tzone.Data(),"GMT") && strcmp(tzone.Data(),"") ){ |
| 1217 |
|
// |
| 1218 |
|
printf("\n Unknown time zone %s using UTC \n",tzone.Data()); |
| 1219 |
|
tzone = "UTC"; |
| 1220 |
|
}; |
| 1221 |
|
// |
| 1222 |
|
rtime = time->AsSQLString(); |
| 1223 |
|
// |
| 1224 |
|
return(rtime); |
| 1225 |
|
} |