--- chewbacca/YodaProfiler/src/PamelaDBOperations.cpp 2010/02/01 13:27:28 1.32 +++ chewbacca/YodaProfiler/src/PamelaDBOperations.cpp 2014/04/04 14:11:24 1.37 @@ -226,7 +226,26 @@ 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 ABS(LAST_TIME_SYNC_INFO-"<< (float)chlastts <<")<50000 AND ABS(REAL_TIME_INIT-"<< atof(row2->GetField(10)) <<")<50000 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; // even more relaxed conditions... 091214 [9REDtest3: error -29] // 10RED MYSQL operators BUG: + /* + +mysql> select CAST(1322000646 AS UNSIGNED INTEGER)-1322017203.; ++--------------------------------------------------+ +| CAST(1322000646 AS UNSIGNED INTEGER)-1322017203. | ++--------------------------------------------------+ +| -16557 | ++--------------------------------------------------+ +1 row in set (0.06 sec) + +mysql> select CAST(1322000646 AS UNSIGNED INTEGER)-1322017203; ++-------------------------------------------------+ +| CAST(1322000646 AS UNSIGNED INTEGER)-1322017203 | ++-------------------------------------------------+ +| 18446744073709535059 | ++-------------------------------------------------+ +1 row in set (0.02 sec) + + */ if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); result3 = conn->Query(qu.str().c_str()); if ( result3 ){ @@ -1730,9 +1749,9 @@ TYPE = 0; TSYNC = 0; // - Double_t minimum = 0.; - Double_t maximum = 0.; - Double_t minimum2 = 0.; + // Double_t minimum = 0.; + // Double_t maximum = 0.; + //Double_t minimum2 = 0.; Double_t maximum2 = 0.; // // @@ -1740,9 +1759,9 @@ pamela::McmdRecord *mcrc = 0; TArrayC *mcmddata = 0; // - minimum = numeric_limits::max(); - maximum = numeric_limits::min(); - minimum2 = numeric_limits::max(); + // minimum = numeric_limits::max(); + // maximum = numeric_limits::min(); + // minimum2 = numeric_limits::max(); maximum2 = numeric_limits::min(); // T = (TTree*)file->Get("Mcmd"); @@ -2162,16 +2181,16 @@ UInt_t lowerts = tsync-(obt0/1000)-5; if ( chewbacca ){ oss.str(""); - oss << "select BOOT_NUMBER from ROOT_TABLE where LAST_TIME_SYNC_INFO-(OBT_TIME_SYNC)<" + oss << "select BOOT_NUMBER from ROOT_TABLE where CAST((LAST_TIME_SYNC_INFO-(OBT_TIME_SYNC)) AS SIGNED INT)<" // 10RED MYSQL OPERATORS BUG << upperts - << " AND LAST_TIME_SYNC_INFO-(OBT_TIME_SYNC)>" + << " AND CAST((LAST_TIME_SYNC_INFO-(OBT_TIME_SYNC)) AS SIGNED INT)>" // 10RED MYSQL OPERATORS BUG << lowerts << " AND BOOT_NUMBER>1;"; } else { oss.str(""); - oss << "select GL_RAW.BOOT_NUMBER from GL_TIMESYNC LEFT JOIN GL_RAW ON GL_RAW.ID = GL_TIMESYNC.ID_RAW where TIMESYNC-(OBT0/1000)<" + oss << "select GL_RAW.BOOT_NUMBER from GL_TIMESYNC LEFT JOIN GL_RAW ON GL_RAW.ID = GL_TIMESYNC.ID_RAW where CAST((TIMESYNC-(OBT0/1000)) AS SIGNED INT)<" // 10RED MYSQL OPERATORS BUG << upperts - << " AND TIMESYNC-(OBT0/1000)>" + << " AND CAST((TIMESYNC-(OBT0/1000)) AS SIGNED INT)>" // 10RED MYSQL OPERATORS BUG << lowerts << " AND GL_RAW.BOOT_NUMBER>0 GROUP BY GL_TIMESYNC.OBT0;"; }; @@ -2957,6 +2976,7 @@ if ( IsDebug() ) printf(" here firstev is %i lastev is %i \n",firstev,lastev); // glrun->SetEV_FROM(firstev); + glrun->SetEV_TO(lastev); // EM 10 RED ghost run bug glrun->SetNEVENTS(lastev-firstev+1); // glrun->SetRUNHEADER_TIME(glrun1->GetRUNHEADER_TIME()); @@ -3152,6 +3172,7 @@ }; if ( IsDebug() ) printf(" Check overlapping events done: %u %u %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev); // + glrun->SetEV_FROM(firstev); // EM 10RED ghost run bug glrun->SetEV_TO(lastev); glrun->SetNEVENTS(lastev-firstev+1); glrun->SetPKT_COUNTER(glrun1->GetPKT_COUNTER()); @@ -3598,7 +3619,7 @@ // EventCounter *code=0; // - UInt_t nevent = 0; + // UInt_t nevent = 0; UInt_t checkfirst = 0; UInt_t checklast = 0; UInt_t firstentry = 0; @@ -3620,7 +3641,7 @@ EventHeader *eh = 0; PscuHeader *ph = 0; T->SetBranchAddress("Header", &eh); - nevent = T->GetEntries(); + // nevent = T->GetEntries(); // // if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run! @@ -3994,6 +4015,7 @@ glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); // glrun->SetEV_FROM(firstev); + glrun->SetEV_TO(lastev); // 10 RED ghost run bug glrun->SetNEVENTS(lastev-firstev+1); // glrun->SetRUNHEADER_TIME(glrun1->GetRUNHEADER_TIME()); @@ -4141,7 +4163,7 @@ EventCounter *code=0; UInt_t firstev = 0; UInt_t lastev = 0; - UInt_t nevent = 0; + // UInt_t nevent = 0; UInt_t checkfirst = 0; UInt_t checklast = 0; UInt_t firstentry = 0; @@ -4166,7 +4188,7 @@ EventHeader *eh = 0; PscuHeader *ph = 0; T->SetBranchAddress("Header", &eh); - nevent = T->GetEntries(); + // nevent = T->GetEntries(); // codt = eht->GetCounter(); codh = ehh->GetCounter(); @@ -5449,7 +5471,8 @@ if ( IsDebug() ) cout << endl << ">>>> TRY TO RECOVER TRACKER CALIBRATIONS <<<<"<Query(oss.str().c_str()); + rresult = conn->Query(oss.str().c_str()); if ( !result ) throw -4;; if ( IsDebug() ) cout <<"Rows: "<GetRowCount()<Next(); + row = rresult->Next(); if(!row)break; UInt_t id = (UInt_t)atoll(row->GetField(0)); @@ -5527,9 +5550,9 @@ TString path = ""; TString name = ""; TString raw = ""; - UInt_t obt0 = 0; - UInt_t timesync = 0; - UInt_t boot_number = 0; + // UInt_t obt0 = 0; + // UInt_t timesync = 0; + // UInt_t boot_number = 0; bool FOUND = false; if ( IsDebug() ) cout << "------------------------------------------------------------" <GetField(0); name = (TString)row2->GetField(1); raw = (TString)row2->GetField(5); - obt0 = (UInt_t)atoll(row2->GetField(2)); - timesync = (UInt_t)atoll(row2->GetField(3)); - boot_number = (UInt_t)atoll(row2->GetField(4)); + // obt0 = (UInt_t)atoll(row2->GetField(2)); + // timesync = (UInt_t)atoll(row2->GetField(3)); + // boot_number = (UInt_t)atoll(row2->GetField(4)); if ( IsDebug() ) cout << "- - - - - - - - - - -" <AsSQLString(),oss.str().c_str()); nresult = conn->Query(oss.str().c_str()); // @@ -6154,7 +6178,7 @@ while ( anr ){ // oss.str(""); - oss << "SELECT ID,RUNTRAILER_TIME,RUNTRAILER_PKT,BOOT_NUMBER FROM GL_RUN_FRAGMENTS WHERE BOOT_NUMBER=" << mbo << " AND RUNHEADER_PKT=" << mrhp << "+1 AND ABS(RUNHEADER_TIME-"<< mrht <<")<=1 AND INSERT_TIME <= '" << clean_time->AsSQLString() << "' order BY RUNHEADER_TIME asc;"; + oss << "SELECT ID,RUNTRAILER_TIME,RUNTRAILER_PKT,BOOT_NUMBER FROM GL_RUN_FRAGMENTS WHERE BOOT_NUMBER=" << mbo << " AND RUNHEADER_PKT=" << mrhp << "+1 AND ABS(RUNHEADER_TIME-"<< (float)mrht <<")<=1 AND INSERT_TIME <= '" << clean_time->AsSQLString() << "' order BY RUNHEADER_TIME asc;"; // 10RED MYSQL OPERATOR BUG if ( IsDebug() ) printf(" In the loop searching for fragmented runs : query is \n %s \n",oss.str().c_str()); // nresult1 = conn->Query(oss.str().c_str());