373 |
|
|
374 |
} |
} |
375 |
|
|
376 |
|
/** |
377 |
|
* |
378 |
|
* |
379 |
|
* |
380 |
|
**/ |
381 |
|
Int_t GL_RUN::DeleteRun(TSQLServer *dbc,UInt_t IDRUN,TString FromTable){ |
382 |
|
// MySQL variables |
383 |
|
TSQLResult *pResult; |
384 |
|
TSQLRow *Row; |
385 |
|
stringstream myquery; |
386 |
|
// |
387 |
|
if ( !IDRUN ) IDRUN = ID; |
388 |
|
if ( !IDRUN ) return 1; |
389 |
|
// ---------------- |
390 |
|
myquery.str(""); |
391 |
|
myquery << " INSERT INTO GL_RUN_TRASH ("; |
392 |
|
myquery << "ID"; |
393 |
|
myquery << ",ID_RUN_FRAG"; |
394 |
|
myquery << ",ID_ROOT_L0"; |
395 |
|
myquery << ",ID_ROOT_L2"; |
396 |
|
myquery << ",RUNHEADER_TIME"; |
397 |
|
myquery << ",RUNTRAILER_TIME"; |
398 |
|
myquery << ",RUNHEADER_OBT"; |
399 |
|
myquery << ",RUNTRAILER_OBT"; |
400 |
|
myquery << ",RUNHEADER_PKT"; |
401 |
|
myquery << ",RUNTRAILER_PKT"; |
402 |
|
myquery << ",BOOT_NUMBER"; |
403 |
|
myquery << ",EV_FROM"; |
404 |
|
myquery << ",EV_TO"; |
405 |
|
myquery << ",NEVENTS"; |
406 |
|
myquery << ",PKT_COUNTER"; |
407 |
|
myquery << ",PKT_READY_COUNTER"; |
408 |
|
myquery << ",COMPILATIONTIMESTAMP"; |
409 |
|
myquery << ",FAV_WRK_SCHEDULE"; |
410 |
|
myquery << ",EFF_WRK_SCHEDULE"; |
411 |
|
myquery << ",PRH_VAR_TRG_MODE_A"; |
412 |
|
myquery << ",PRH_VAR_TRG_MODE_B"; |
413 |
|
myquery << ",ACQ_BUILD_INFO"; |
414 |
|
myquery << ",ACQ_VAR_INFO"; |
415 |
|
myquery << ",RM_ACQ_AFTER_CALIB"; |
416 |
|
myquery << ",RM_ACQ_SETTING_MODE"; |
417 |
|
myquery << ",TRK_CALIB_USED"; |
418 |
|
myquery << ",CAL_DSP_MASK"; |
419 |
|
myquery << ",LAST_TIMESYNC"; |
420 |
|
myquery << ",OBT_TIMESYNC"; |
421 |
|
myquery << ",VALIDATION"; |
422 |
|
myquery << ",INSERT_TIME"; |
423 |
|
myquery << ") SELECT * FROM "; |
424 |
|
myquery << FromTable.Data(); |
425 |
|
myquery << " WHERE ID="; |
426 |
|
myquery << (UInt_t)IDRUN << ";"; |
427 |
|
// |
428 |
|
// printf("1myquery is %s \n",myquery.str().c_str()); |
429 |
|
// |
430 |
|
dbc->Query(myquery.str().c_str()); |
431 |
|
// |
432 |
|
TString fileL0 = ""; |
433 |
|
TString fileL2 = ""; |
434 |
|
myquery.str(""); |
435 |
|
myquery << " SELECT NAME FROM GL_ROOT WHERE ID="; |
436 |
|
myquery << (UInt_t)ID_ROOT_L0 << ";"; |
437 |
|
// |
438 |
|
// printf("2myquery is %s \n",myquery.str().c_str()); |
439 |
|
// |
440 |
|
pResult = dbc->Query(myquery.str().c_str()); |
441 |
|
// |
442 |
|
Row = pResult->Next(); |
443 |
|
if( Row != NULL ){ |
444 |
|
fileL0 = (TString)Row->GetField(0); |
445 |
|
}; |
446 |
|
// |
447 |
|
// |
448 |
|
// |
449 |
|
myquery.str(""); |
450 |
|
myquery << " SELECT NAME FROM GL_ROOT WHERE ID="; |
451 |
|
myquery << (UInt_t)ID_ROOT_L2 << ";"; |
452 |
|
// |
453 |
|
// printf("3myquery is %s \n",myquery.str().c_str()); |
454 |
|
// |
455 |
|
pResult = dbc->Query(myquery.str().c_str()); |
456 |
|
// |
457 |
|
Row = pResult->Next(); |
458 |
|
if( Row != NULL ){ |
459 |
|
fileL2 = (TString)Row->GetField(0); |
460 |
|
}; |
461 |
|
// |
462 |
|
// |
463 |
|
// |
464 |
|
myquery.str(""); |
465 |
|
myquery << " UPDATE GL_RUN_TRASH SET FILENAMEL0='"; |
466 |
|
myquery << fileL0.Data() << "' where ID="; |
467 |
|
myquery << IDRUN << ";"; |
468 |
|
// |
469 |
|
// printf("4myquery is %s \n",myquery.str().c_str()); |
470 |
|
// |
471 |
|
dbc->Query(myquery.str().c_str()); |
472 |
|
// |
473 |
|
myquery.str(""); |
474 |
|
myquery << " UPDATE GL_RUN_TRASH SET FILENAMEL2='"; |
475 |
|
myquery << fileL2.Data() << "' where ID="; |
476 |
|
myquery << IDRUN << ";"; |
477 |
|
// |
478 |
|
// printf("4myquery is %s \n",myquery.str().c_str()); |
479 |
|
// |
480 |
|
dbc->Query(myquery.str().c_str()); |
481 |
|
// |
482 |
|
myquery.str(""); |
483 |
|
myquery << " UPDATE GL_RUN_TRASH SET BELONGED_TO='"; |
484 |
|
myquery << FromTable.Data() << "' where ID="; |
485 |
|
myquery << IDRUN << ";"; |
486 |
|
// |
487 |
|
// printf("4myquery is %s \n",myquery.str().c_str()); |
488 |
|
// |
489 |
|
// |
490 |
|
dbc->Query(myquery.str().c_str()); |
491 |
|
// |
492 |
|
myquery.str(""); |
493 |
|
myquery << " DELETE FROM "; |
494 |
|
myquery << FromTable.Data() << " where ID="; |
495 |
|
myquery << IDRUN << ";"; |
496 |
|
// |
497 |
|
// printf("5myquery is %s \n",myquery.str().c_str()); |
498 |
|
// |
499 |
|
// |
500 |
|
dbc->Query(myquery.str().c_str()); |
501 |
|
// |
502 |
|
return 0; |
503 |
|
}; |
504 |
|
|
505 |
|
|
506 |
|
|
507 |
|
/** |
508 |
|
* |
509 |
|
* |
510 |
|
* |
511 |
|
**/ |
512 |
|
Int_t GL_RUN::RestoreRun(TSQLServer *dbc,UInt_t ID,TString FromTable){ |
513 |
|
// insert into GL_RUN_FRAGMENTS select * FROM GL_RUN where ID=11; |
514 |
|
//insert into GL_RUN_TRASH VALUES (ID , ID_RUN_FRAG , ID_ROOT_L0 , ID_ROOT_L2 , RUNHEADER_TIME , RUNTRAILER_TIME , RUNHEADER_OBT , RUNTRAILER_OBT , RUNHEADER_PKT , RUNTRAILER_PKT , BOOT_NUMBER , EV_FROM , EV_TO , NEVENTS , PKT_COUNTER , PKT_READY_COUNTER , COMPILATIONTIMESTAMP , FAV_WRK_SCHEDULE , EFF_WRK_SCHEDULE , PRH_VAR_TRG_MODE_A , PRH_VAR_TRG_MODE_B , ACQ_BUILD_INFO , ACQ_VAR_INFO , RM_ACQ_AFTER_CALIB , RM_ACQ_SETTING_MODE, TRK_CALIB_USED,CAL_DSP_MASK, LAST_TIMESYNC, OBT_TIMESYNC, VALIDATION, INSERT_TIME) select * FROM GL_RUN where ID=11; |
515 |
|
return 0; |
516 |
|
}; |
517 |
|
|
518 |
/** |
/** |
519 |
* Function to fill the GL_RUN table of the DB. |
* Function to fill the GL_RUN table of the DB. |
1140 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1141 |
TSQLRow *Row; |
TSQLRow *Row; |
1142 |
stringstream myquery; |
stringstream myquery; |
1143 |
|
stringstream rname; |
1144 |
|
rname.str(""); |
1145 |
// ---------------- |
// ---------------- |
1146 |
myquery.str(""); |
myquery.str(""); |
1147 |
myquery << "select "; |
myquery << "select "; |
1158 |
stringstream fname; |
stringstream fname; |
1159 |
fname.str(""); |
fname.str(""); |
1160 |
fname << Row->GetField(0) << "/" << Row->GetField(1); |
fname << Row->GetField(0) << "/" << Row->GetField(1); |
1161 |
|
rname << Row->GetField(1); |
1162 |
file = new TFile(fname.str().c_str(),"READ"); |
file = new TFile(fname.str().c_str(),"READ"); |
1163 |
idraw = (UInt_t)atoll(Row->GetField(2)); |
idraw = (UInt_t)atoll(Row->GetField(2)); |
1164 |
}; |
}; |
1180 |
// |
// |
1181 |
UInt_t t0 = 0; |
UInt_t t0 = 0; |
1182 |
// |
// |
1183 |
myquery.str(""); |
// |
1184 |
myquery << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE FROM_ID_RAW<= " |
stringstream oss; |
1185 |
<< idraw << " AND TO_ID_RAW >= " |
oss.str(""); |
1186 |
<< idraw << ";"; |
oss << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE SPECIAL_FILE='" |
1187 |
pResult = dbc->Query(myquery.str().c_str()); |
<< rname.str().c_str() << "';"; |
1188 |
if ( pResult ){ |
// if ( IsDebug() ) printf(" %s \n",oss.str().c_str()); |
1189 |
|
pResult = dbc->Query(oss.str().c_str()); |
1190 |
|
Row = pResult->Next(); |
1191 |
|
// |
1192 |
|
TString name=rname.str().c_str(); |
1193 |
|
UInt_t dworbit = 0; |
1194 |
|
Int_t nlength = name.Length(); |
1195 |
|
if ( nlength < 5 ) return; |
1196 |
|
TString dwo = 0; |
1197 |
|
for (Int_t i = 0; i<5; i++){ |
1198 |
|
dwo.Append(name[i],1); |
1199 |
|
}; |
1200 |
|
if ( dwo.IsDigit() ){ |
1201 |
|
dworbit = (UInt_t)dwo.Atoi(); |
1202 |
|
} else { |
1203 |
|
dwo=""; |
1204 |
|
for (Int_t i = 8; i<13; i++){ |
1205 |
|
dwo.Append(name[i],1); |
1206 |
|
}; |
1207 |
|
if ( dwo.IsDigit() ) dworbit = (UInt_t)dwo.Atoi(); |
1208 |
|
}; |
1209 |
|
// if ( IsDebug() ) printf(" Downlink orbit is %i (dwo = %s) \n",dworbit,dwo.Data()); |
1210 |
|
// |
1211 |
|
if ( !Row ){ |
1212 |
|
oss.str(""); |
1213 |
|
oss << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE FROM_ORBIT< " |
1214 |
|
<< dworbit << " order by FROM_ORBIT desc limit 1;"; |
1215 |
|
// if ( IsDebug() ) printf(" %s \n",oss.str().c_str()); |
1216 |
|
pResult = dbc->Query(oss.str().c_str()); |
1217 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1218 |
if ( Row ){ |
if ( !Row ){ |
1219 |
// |
printf(" ERROR FROM GLTables! cannot determine Resurs offset \n"); |
1220 |
t0 = (UInt_t)TDatime(Row->GetField(0)).Convert(); |
return; |
|
// |
|
1221 |
}; |
}; |
1222 |
}; |
}; |
1223 |
// |
// |
1224 |
|
t0 = (UInt_t)TDatime(Row->GetField(0)).Convert(); |
1225 |
|
// |
1226 |
|
// myquery.str(""); |
1227 |
|
// myquery << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE FROM_ID_RAW<= " |
1228 |
|
// << idraw << " AND TO_ID_RAW >= " |
1229 |
|
// << idraw << ";"; |
1230 |
|
// pResult = dbc->Query(myquery.str().c_str()); |
1231 |
|
// if ( pResult ){ |
1232 |
|
// Row = pResult->Next(); |
1233 |
|
// if ( Row ){ |
1234 |
|
// // |
1235 |
|
// t0 = (UInt_t)TDatime(Row->GetField(0)).Convert(); |
1236 |
|
// // |
1237 |
|
// }; |
1238 |
|
// }; |
1239 |
|
// |
1240 |
// |
// |
1241 |
// look for the correct timesync entry |
// look for the correct timesync entry |
1242 |
// |
// |