--- chewbacca/YodaProfiler/src/PamelaDBOperations.cpp 2009/12/14 13:20:37 1.28 +++ chewbacca/YodaProfiler/src/PamelaDBOperations.cpp 2009/12/28 08:39:24 1.30 @@ -88,12 +88,12 @@ // glrun = new GL_RUN(); // - if ( !chewbacca ){ - if ( !boot ) SetNOBOOT(false); - SetTsync(tsync,gpamela); - SetBOOTnumber(boot,gpamela); - SetObt0(obt0); - }; + // if ( !chewbacca ){ + // if ( !boot ) SetNOBOOT(false); + // SetTsync(tsync,gpamela); + // SetBOOTnumber(boot,gpamela); + // SetObt0(obt0); + // }; // SetTLEPath(tlefilename); // @@ -126,6 +126,12 @@ // // SETTERS // +void PamelaDBOperations::NotChewbacca(UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t gpamela){ + if ( !boot ) SetNOBOOT(false); + SetTsync(tsync,gpamela); + SetBOOTnumber(boot,gpamela); + SetObt0(obt0); +}; void PamelaDBOperations::OpenL0File(TString filerootname){ if( INSERT_ROOT ){ @@ -183,20 +189,55 @@ chboot = (UInt_t)atoll(row2->GetField(5)); // if ( !chboot ){ + if ( debug ) printf(" mmm... no BOOT number determined by chewbacca, try to find it looking at DB \n"); + // + // new feature: check in ROOT_TABLE (timewise) the previous and the next BOOT number != 0 , if it is the same we know this one! + // if it is different roll back to the old behaviour + // qu.str(""); - // qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<10000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<7200 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; - // qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<40000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<40000 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; // relax conditions... 090112 [8RED: error -29] - qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<50000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<50000 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; // even more relaxed conditions... 091214 [9REDtest3: error -29] + qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND REAL_TIME_INIT>"<< row2->GetField(10) <<" order by REAL_TIME_INIT asc limit 1;"; if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); + UInt_t chbootA = 0; + UInt_t chbootB = 1; result3 = conn->Query(qu.str().c_str()); if ( result3 ){ row3 = result3->Next(); - if ( row3 && result3->GetRowCount() == 1 ){ - chboot = (UInt_t)atoll(row3->GetField(0)); - if ( debug ) printf(" Found boot_number = %u \n",chboot); - } else { - if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n"); - throw -29; + if ( row3 ){ + chbootA = (UInt_t)atoll(row3->GetField(0)); + if ( debug ) printf(" Found boot_number A = %u \n",chbootA); + }; + }; + delete result3; + qu.str(""); + qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND REAL_TIME_INIT<"<< row2->GetField(10) <<" order by REAL_TIME_INIT desc limit 1;"; + if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); + result3 = conn->Query(qu.str().c_str()); + if ( result3 ){ + row3 = result3->Next(); + if ( row3 ){ + chbootB = (UInt_t)atoll(row3->GetField(0)); + if ( debug ) printf(" Found boot_number B = %u \n",chbootB); + }; + }; + if ( chbootA == chbootB ){ + chboot = chbootA; + if ( debug ) printf(" Found boot_number! it is %u \n",chboot); + } else { + qu.str(""); + // qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<10000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<7200 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; + // qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<40000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<40000 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; // relax conditions... 090112 [8RED: error -29] + qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<50000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<50000 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; // even more relaxed conditions... 091214 [9REDtest3: error -29] + if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); + result3 = conn->Query(qu.str().c_str()); + if ( result3 ){ + row3 = result3->Next(); + if ( row3 && result3->GetRowCount() == 1 ){ + chboot = (UInt_t)atoll(row3->GetField(0)); + if ( debug ) printf(" Found boot_number = %u \n",chboot); + } else { + if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n"); + throw -29; + }; }; }; };