--- chewbacca/YodaProfiler/src/PamelaDBOperations.cpp 2009/12/30 10:46:35 1.31 +++ chewbacca/YodaProfiler/src/PamelaDBOperations.cpp 2014/10/14 12:59:14 1.39 @@ -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 ){ @@ -1347,7 +1366,7 @@ stringstream oss; // oss.str(""); - oss << "SET time_zone='+0:00';"; + oss << "SET time_zone='+0:00'; SET sql_mode = 'NO_UNSIGNED_SUBTRACTION';"; TSQLResult *result = 0; result = conn->Query(oss.str().c_str()); if ( !result ) throw -10; @@ -1639,7 +1658,8 @@ Int_t PamelaDBOperations::insertPamelaGL_TIMESYNC(){ // Int_t signal = 0; - UInt_t idresof = 0; + // UInt_t idresof = 0; + idresof = 0; stringstream oss; TSQLResult *result = 0; TSQLRow *row = 0; @@ -1730,9 +1750,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 +1760,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"); @@ -1953,7 +1973,7 @@ // if ( chewbacca ){ oss.str(""); - oss << " SELECT ID FROM GL_TIMESYNC where TIMESYNC="<Query(oss.str().c_str()); // @@ -2162,16 +2182,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;"; }; @@ -2270,8 +2290,10 @@ // // no runtrailers in the file! // - if ( !rtev ){ - if ( !rhev ){ + if ( IsDebug() ) printf(" Start rtev %i rhev %i nrtev %i nrhev %i \n",rtev,rhev,nrtev,nrhev); + if ( !rtev || (chewbacca && !nrtev) ){ + if ( IsDebug() ) printf(" No runtrailers \n"); + if ( !rhev || (chewbacca && !nrhev) ){ if ( IsDebug() ) printf(" No runheaders nor runtrailers!! \n"); if ( !(upperentry-chminentry) ){ if ( IsDebug() ) printf(" No physics events nor runs in the file \n"); // di nuovo potrebbe esserci un runtrailer senza eventi (riempimento MM) @@ -2308,6 +2330,7 @@ // } else { // + if ( IsDebug() ) printf(" We have runtrailers \n"); Int_t conptt = -1; for (Int_t ptt=0; pttSetEV_FROM(firstev); + glrun->SetEV_TO(lastev); // EM 10 RED ghost run bug glrun->SetNEVENTS(lastev-firstev+1); // glrun->SetRUNHEADER_TIME(glrun1->GetRUNHEADER_TIME()); @@ -3149,6 +3173,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()); @@ -3595,7 +3620,7 @@ // EventCounter *code=0; // - UInt_t nevent = 0; + // UInt_t nevent = 0; UInt_t checkfirst = 0; UInt_t checklast = 0; UInt_t firstentry = 0; @@ -3617,7 +3642,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! @@ -3991,6 +4016,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()); @@ -4138,7 +4164,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; @@ -4163,7 +4189,7 @@ EventHeader *eh = 0; PscuHeader *ph = 0; T->SetBranchAddress("Header", &eh); - nevent = T->GetEntries(); + // nevent = T->GetEntries(); // codt = eht->GetCounter(); codh = ehh->GetCounter(); @@ -5446,7 +5472,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)); @@ -5524,9 +5551,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 << "- - - - - - - - - - -" <Query(oss.str().c_str()); if ( !result ) throw -3; @@ -5819,7 +5847,7 @@ }while(1);//end loop over calibrations - if( result )delete result; + if( rresult )delete rresult; // 10RED bug if( row )delete row; @@ -6120,7 +6148,7 @@ memset(myid,0,500*sizeof(UInt_t)); // oss.str(""); - oss << "SELECT ID,RUNTRAILER_TIME,RUNTRAILER_PKT,BOOT_NUMBER FROM GL_RUN_FRAGMENTS WHERE INSERT_TIME <= '" << clean_time->AsSQLString() << "'order BY RUNHEADER_TIME asc;"; + oss << "SELECT ID,RUNTRAILER_TIME,RUNTRAILER_PKT,BOOT_NUMBER FROM GL_RUN_FRAGMENTS WHERE INSERT_TIME <= '" << clean_time->AsSQLString() << "' order BY RUNHEADER_TIME asc;"; if ( IsDebug() ) printf(" Select from GL_RUN_FRAGMENTS runs older than %s : query is \n %s \n",clean_time->AsSQLString(),oss.str().c_str()); nresult = conn->Query(oss.str().c_str()); // @@ -6151,7 +6179,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());