273 |
oss << "SELECT ID FROM GL_RAW WHERE " |
oss << "SELECT ID FROM GL_RAW WHERE " |
274 |
<< " PATH = '" << this->GetRawPath().Data() << "' AND " |
<< " PATH = '" << this->GetRawPath().Data() << "' AND " |
275 |
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
276 |
|
|
277 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
278 |
if ( result == NULL ) throw -4; |
if ( result == NULL ) throw -4; |
279 |
row = result->Next(); |
row = result->Next(); |
779 |
if( !conn ) throw -1; |
if( !conn ) throw -1; |
780 |
bool connect = conn->IsConnected(); |
bool connect = conn->IsConnected(); |
781 |
if( !connect ) throw -1; |
if( !connect ) throw -1; |
782 |
|
// |
783 |
|
if ( IsDebug() ) printf("\n DB INFORMATIONS:\n SQL: %s Version: %s Host %s Port %i \n\n",conn->GetDBMS(),conn->ServerInfo(),conn->GetHost(),conn->GetPort()); |
784 |
|
// |
785 |
if ( !dworbit && strcmp(this->GetRootName().Data(),"") ) throw -27; |
if ( !dworbit && strcmp(this->GetRootName().Data(),"") ) throw -27; |
786 |
// |
// |
787 |
// set DB timezone to UTC |
// set DB timezone to UTC |
793 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
794 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
795 |
if ( !result ) throw -10; |
if ( !result ) throw -10; |
796 |
|
oss.str(""); |
797 |
|
oss << "SET wait_timeout=173000;"; |
798 |
|
conn->Query(oss.str().c_str()); |
799 |
// |
// |
800 |
}; |
}; |
801 |
|
|
4431 |
// |
// |
4432 |
}; |
}; |
4433 |
}; |
}; |
4434 |
|
|
4435 |
/** |
/** |
4436 |
* |
* |
4437 |
* Rearrange calibration tables |
* Rearrange calibration tables |
4549 |
return 1; // :-) |
return 1; // :-) |
4550 |
|
|
4551 |
} |
} |
4552 |
|
|
4553 |
|
/** |
4554 |
|
* |
4555 |
|
* Check the DB (only for overlapping runs at the moment) |
4556 |
|
* |
4557 |
|
**/ |
4558 |
|
UInt_t PamelaDBOperations::Check(){ |
4559 |
|
// |
4560 |
|
UInt_t test = 0; |
4561 |
|
// |
4562 |
|
UInt_t thisrht = 0; |
4563 |
|
UInt_t thisrtt = 0; |
4564 |
|
UInt_t thisid = 0; |
4565 |
|
UInt_t prevrht = 0; |
4566 |
|
UInt_t prevrtt = 0; |
4567 |
|
UInt_t previd = 0; |
4568 |
|
// |
4569 |
|
UInt_t prevl0id = 0; |
4570 |
|
UInt_t thisl0id = 0; |
4571 |
|
// |
4572 |
|
stringstream oss; |
4573 |
|
TSQLResult *result = 0; |
4574 |
|
TSQLRow *row = 0; |
4575 |
|
TSQLResult *result2 = 0; |
4576 |
|
TSQLRow *row2 = 0; |
4577 |
|
oss.str(""); |
4578 |
|
oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN order by RUNHEADER_TIME asc;"; |
4579 |
|
// oss << "SELECT ID,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN where ID>10170 and ID<10190 order by RUNHEADER_TIME asc;"; |
4580 |
|
result = conn->Query(oss.str().c_str()); |
4581 |
|
// |
4582 |
|
if ( !result ) throw -4;; |
4583 |
|
// |
4584 |
|
row = result->Next(); |
4585 |
|
// |
4586 |
|
while ( row ){ |
4587 |
|
thisid = (UInt_t)atoll(row->GetField(0)); |
4588 |
|
thisl0id = (UInt_t)atoll(row->GetField(1)); |
4589 |
|
thisrht = (UInt_t)atoll(row->GetField(2)); |
4590 |
|
thisrtt = (UInt_t)atoll(row->GetField(3)); |
4591 |
|
// |
4592 |
|
// if ( thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt && !(!prevrht && !prevrtt &&!previd) ){ |
4593 |
|
// if ( (thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt) && (thisrht != prevrht) ){ |
4594 |
|
if ( (thisrht < prevrtt) && (thisrht != prevrht) ){ |
4595 |
|
if ( IsDebug() ) printf(" IDprev %u ID %u prevrht %u prevrtt %u thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt); |
4596 |
|
printf(" CHECK n.1 TIME SCREW of %i s AROUND RUNs %u and %u \n",(thisrht-prevrtt),previd,thisid); |
4597 |
|
TString prevf = ""; |
4598 |
|
TString thisf = ""; |
4599 |
|
oss.str(""); |
4600 |
|
oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";"; |
4601 |
|
result2 = conn->Query(oss.str().c_str()); |
4602 |
|
if ( !result2 ) throw -4;; |
4603 |
|
row2 = result2->Next(); |
4604 |
|
prevf = (TString)row2->GetField(0); |
4605 |
|
oss.str(""); |
4606 |
|
oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)thisl0id <<";"; |
4607 |
|
result2 = conn->Query(oss.str().c_str()); |
4608 |
|
if ( !result2 ) throw -4;; |
4609 |
|
row2 = result2->Next(); |
4610 |
|
thisf = (TString)row2->GetField(0); |
4611 |
|
if ( IsDebug() ) printf(" ==> files %s and %s \n",prevf.Data(),thisf.Data()); |
4612 |
|
test = 1; |
4613 |
|
}; |
4614 |
|
// |
4615 |
|
if ( (thisrtt < prevrht) && (thisrht != prevrht) ){ |
4616 |
|
if ( IsDebug() ) printf(" IDprev %u ID %u prevrht %u prevrtt %u thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt); |
4617 |
|
printf(" CHECK n.2 TIME SCREW of %i s AROUND RUNs %u and %u \n",(thisrtt-prevrht),previd,thisid); |
4618 |
|
TString prevf = ""; |
4619 |
|
TString thisf = ""; |
4620 |
|
oss.str(""); |
4621 |
|
oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";"; |
4622 |
|
result2 = conn->Query(oss.str().c_str()); |
4623 |
|
if ( !result2 ) throw -4;; |
4624 |
|
row2 = result2->Next(); |
4625 |
|
prevf = (TString)row2->GetField(0); |
4626 |
|
oss.str(""); |
4627 |
|
oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)thisl0id <<";"; |
4628 |
|
result2 = conn->Query(oss.str().c_str()); |
4629 |
|
if ( !result2 ) throw -4;; |
4630 |
|
row2 = result2->Next(); |
4631 |
|
thisf = (TString)row2->GetField(0); |
4632 |
|
if ( IsDebug() ) printf(" ==> files %s and %s \n",prevf.Data(),thisf.Data()); |
4633 |
|
test = 1; |
4634 |
|
}; |
4635 |
|
// |
4636 |
|
if ( (thisrht > thisrtt) && (thisrht != prevrht) ){ |
4637 |
|
if ( IsDebug() ) printf(" IDprev %u ID %u prevrht %u prevrtt %u thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt); |
4638 |
|
printf(" CHECK n.3 TIME SCREW of %i s AROUND RUNs %u and %u \n",(thisrht-thisrtt),previd,thisid); |
4639 |
|
TString prevf = ""; |
4640 |
|
TString thisf = ""; |
4641 |
|
oss.str(""); |
4642 |
|
oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";"; |
4643 |
|
result2 = conn->Query(oss.str().c_str()); |
4644 |
|
if ( !result2 ) throw -4;; |
4645 |
|
row2 = result2->Next(); |
4646 |
|
prevf = (TString)row2->GetField(0); |
4647 |
|
oss.str(""); |
4648 |
|
oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)thisl0id <<";"; |
4649 |
|
result2 = conn->Query(oss.str().c_str()); |
4650 |
|
if ( !result2 ) throw -4;; |
4651 |
|
row2 = result2->Next(); |
4652 |
|
thisf = (TString)row2->GetField(0); |
4653 |
|
if ( IsDebug() ) printf(" ==> files %s and %s \n",prevf.Data(),thisf.Data()); |
4654 |
|
test = 1; |
4655 |
|
}; |
4656 |
|
|
4657 |
|
// |
4658 |
|
prevrht = thisrht; |
4659 |
|
prevrtt = thisrtt; |
4660 |
|
previd = thisid; |
4661 |
|
prevl0id = thisl0id; |
4662 |
|
row = result->Next(); |
4663 |
|
}; |
4664 |
|
// |
4665 |
|
return(test); |
4666 |
|
// |
4667 |
|
}; |