/[PAMELA software]/chewbacca/YodaProfiler/src/PamelaDBOperations.cpp
ViewVC logotype

Diff of /chewbacca/YodaProfiler/src/PamelaDBOperations.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.32 by mocchiut, Mon Feb 1 13:27:28 2010 UTC revision 1.37 by emocchiutti, Fri Apr 4 14:11:24 2014 UTC
# Line 226  void PamelaDBOperations::OpenL0File(TStr Line 226  void PamelaDBOperations::OpenL0File(TStr
226                qu.str("");                qu.str("");
227                //            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 <<")<10000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<7200 group by BOOT_NUMBER order by BOOT_NUMBER asc;";
228                //            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 <<")<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]
229                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:
230                  /*
231    
232    mysql> select CAST(1322000646 AS UNSIGNED INTEGER)-1322017203.;
233    +--------------------------------------------------+
234    | CAST(1322000646 AS UNSIGNED INTEGER)-1322017203. |
235    +--------------------------------------------------+
236    |                                           -16557 |
237    +--------------------------------------------------+
238    1 row in set (0.06 sec)
239    
240    mysql> select CAST(1322000646 AS UNSIGNED INTEGER)-1322017203;
241    +-------------------------------------------------+
242    | CAST(1322000646 AS UNSIGNED INTEGER)-1322017203 |
243    +-------------------------------------------------+
244    |                            18446744073709535059 |
245    +-------------------------------------------------+
246    1 row in set (0.02 sec)
247    
248                  */
249                if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str());                if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str());
250                result3 = conn->Query(qu.str().c_str());                result3 = conn->Query(qu.str().c_str());
251                if ( result3 ){                if ( result3 ){
# Line 1730  Int_t PamelaDBOperations::insertPamelaGL Line 1749  Int_t PamelaDBOperations::insertPamelaGL
1749      TYPE = 0;      TYPE = 0;
1750      TSYNC = 0;      TSYNC = 0;
1751      //      //
1752      Double_t minimum = 0.;      //    Double_t minimum = 0.;
1753      Double_t maximum = 0.;      // Double_t maximum = 0.;
1754      Double_t minimum2 = 0.;      //Double_t minimum2 = 0.;
1755      Double_t maximum2 = 0.;      Double_t maximum2 = 0.;
1756      //      //
1757      //      //
# Line 1740  Int_t PamelaDBOperations::insertPamelaGL Line 1759  Int_t PamelaDBOperations::insertPamelaGL
1759      pamela::McmdRecord *mcrc = 0;      pamela::McmdRecord *mcrc = 0;
1760      TArrayC *mcmddata = 0;      TArrayC *mcmddata = 0;
1761      //      //
1762      minimum = numeric_limits<Double_t>::max();      //    minimum = numeric_limits<Double_t>::max();
1763      maximum = numeric_limits<Double_t>::min();      //    maximum = numeric_limits<Double_t>::min();
1764      minimum2 = numeric_limits<Double_t>::max();      //    minimum2 = numeric_limits<Double_t>::max();
1765      maximum2 = numeric_limits<Double_t>::min();      maximum2 = numeric_limits<Double_t>::min();
1766      //      //
1767      T = (TTree*)file->Get("Mcmd");      T = (TTree*)file->Get("Mcmd");
# Line 2162  Int_t PamelaDBOperations::assignBOOT_NUM Line 2181  Int_t PamelaDBOperations::assignBOOT_NUM
2181      UInt_t lowerts = tsync-(obt0/1000)-5;      UInt_t lowerts = tsync-(obt0/1000)-5;
2182      if ( chewbacca ){      if ( chewbacca ){
2183        oss.str("");        oss.str("");
2184        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
2185            << upperts            << upperts
2186            << " AND LAST_TIME_SYNC_INFO-(OBT_TIME_SYNC)>"            << " AND CAST((LAST_TIME_SYNC_INFO-(OBT_TIME_SYNC)) AS SIGNED INT)>" // 10RED MYSQL OPERATORS BUG
2187            << lowerts            << lowerts
2188            << " AND BOOT_NUMBER>1;";            << " AND BOOT_NUMBER>1;";
2189      } else {      } else {
2190        oss.str("");        oss.str("");
2191        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
2192            << upperts            << upperts
2193            << " AND TIMESYNC-(OBT0/1000)>"            << " AND CAST((TIMESYNC-(OBT0/1000)) AS SIGNED INT)>" // 10RED MYSQL OPERATORS BUG
2194            << lowerts            << lowerts
2195            << " AND GL_RAW.BOOT_NUMBER>0 GROUP BY GL_TIMESYNC.OBT0;";            << " AND GL_RAW.BOOT_NUMBER>0 GROUP BY GL_TIMESYNC.OBT0;";
2196      };      };
# Line 2957  void PamelaDBOperations::HandleRunFragme Line 2976  void PamelaDBOperations::HandleRunFragme
2976          if ( IsDebug() ) printf(" here firstev is %i lastev is %i \n",firstev,lastev);          if ( IsDebug() ) printf(" here firstev is %i lastev is %i \n",firstev,lastev);
2977          //          //
2978          glrun->SetEV_FROM(firstev);          glrun->SetEV_FROM(firstev);
2979            glrun->SetEV_TO(lastev); // EM 10 RED ghost run bug
2980          glrun->SetNEVENTS(lastev-firstev+1);          glrun->SetNEVENTS(lastev-firstev+1);
2981          //          //
2982          glrun->SetRUNHEADER_TIME(glrun1->GetRUNHEADER_TIME());          glrun->SetRUNHEADER_TIME(glrun1->GetRUNHEADER_TIME());
# Line 3152  void PamelaDBOperations::HandleRunFragme Line 3172  void PamelaDBOperations::HandleRunFragme
3172          };          };
3173          if ( IsDebug() ) printf(" Check overlapping events done: %u %u %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev);          if ( IsDebug() ) printf(" Check overlapping events done: %u %u %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev);
3174          //          //
3175            glrun->SetEV_FROM(firstev); // EM 10RED ghost run bug
3176          glrun->SetEV_TO(lastev);          glrun->SetEV_TO(lastev);
3177          glrun->SetNEVENTS(lastev-firstev+1);          glrun->SetNEVENTS(lastev-firstev+1);
3178          glrun->SetPKT_COUNTER(glrun1->GetPKT_COUNTER());          glrun->SetPKT_COUNTER(glrun1->GetPKT_COUNTER());
# Line 3598  Bool_t PamelaDBOperations::IsRunConsiste Line 3619  Bool_t PamelaDBOperations::IsRunConsiste
3619    //      //  
3620    EventCounter *code=0;    EventCounter *code=0;
3621    //    //
3622    UInt_t nevent = 0;    //  UInt_t nevent = 0;
3623    UInt_t checkfirst = 0;    UInt_t checkfirst = 0;
3624    UInt_t checklast = 0;    UInt_t checklast = 0;
3625    UInt_t firstentry = 0;    UInt_t firstentry = 0;
# Line 3620  Bool_t PamelaDBOperations::IsRunConsiste Line 3641  Bool_t PamelaDBOperations::IsRunConsiste
3641    EventHeader *eh = 0;    EventHeader *eh = 0;
3642    PscuHeader *ph = 0;    PscuHeader *ph = 0;
3643    T->SetBranchAddress("Header", &eh);    T->SetBranchAddress("Header", &eh);
3644    nevent = T->GetEntries();    //  nevent = T->GetEntries();
3645    //    //
3646    //    //
3647    if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run!    if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run!
# Line 3994  Bool_t PamelaDBOperations::IsRunConsiste Line 4015  Bool_t PamelaDBOperations::IsRunConsiste
4015                  glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT());                  glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT());
4016                  //                  //
4017                  glrun->SetEV_FROM(firstev);                  glrun->SetEV_FROM(firstev);
4018                    glrun->SetEV_TO(lastev); // 10 RED ghost run bug
4019                  glrun->SetNEVENTS(lastev-firstev+1);                  glrun->SetNEVENTS(lastev-firstev+1);
4020                  //                  //
4021                  glrun->SetRUNHEADER_TIME(glrun1->GetRUNHEADER_TIME());                  glrun->SetRUNHEADER_TIME(glrun1->GetRUNHEADER_TIME());
# Line 4141  void PamelaDBOperations::HandleSuspiciou Line 4163  void PamelaDBOperations::HandleSuspiciou
4163    EventCounter *code=0;    EventCounter *code=0;
4164    UInt_t firstev = 0;    UInt_t firstev = 0;
4165    UInt_t lastev = 0;    UInt_t lastev = 0;
4166    UInt_t nevent = 0;    //  UInt_t nevent = 0;
4167    UInt_t checkfirst = 0;    UInt_t checkfirst = 0;
4168    UInt_t checklast = 0;    UInt_t checklast = 0;
4169    UInt_t firstentry = 0;    UInt_t firstentry = 0;
# Line 4166  void PamelaDBOperations::HandleSuspiciou Line 4188  void PamelaDBOperations::HandleSuspiciou
4188    EventHeader *eh = 0;    EventHeader *eh = 0;
4189    PscuHeader *ph = 0;    PscuHeader *ph = 0;
4190    T->SetBranchAddress("Header", &eh);    T->SetBranchAddress("Header", &eh);
4191    nevent = T->GetEntries();    //  nevent = T->GetEntries();
4192    //    //
4193    codt = eht->GetCounter();    codt = eht->GetCounter();
4194    codh = ehh->GetCounter();    codh = ehh->GetCounter();
# Line 5449  Int_t PamelaDBOperations::insertTRK_CALI Line 5471  Int_t PamelaDBOperations::insertTRK_CALI
5471    
5472          if ( IsDebug() ) cout << endl << ">>>> TRY TO RECOVER TRACKER CALIBRATIONS <<<<"<<endl;          if ( IsDebug() ) cout << endl << ">>>> TRY TO RECOVER TRACKER CALIBRATIONS <<<<"<<endl;
5473    
5474          TSQLResult *result = 0;          TSQLResult *rresult = 0; // 10RED bug, result is re-used inside result looop...
5475            TSQLResult *result = 0; // 10RED bug, result is re-used inside result looop...
5476          TSQLRow    *row    = 0;          TSQLRow    *row    = 0;
5477          //          //
5478          stringstream oss;          stringstream oss;
# Line 5479  Int_t PamelaDBOperations::insertTRK_CALI Line 5502  Int_t PamelaDBOperations::insertTRK_CALI
5502          oss << " ORDER BY ID DESC LIMIT "<<ncalib<<"; ";                  oss << " ORDER BY ID DESC LIMIT "<<ncalib<<"; ";        
5503          if ( IsDebug() ) cout << oss.str().c_str() << endl;          if ( IsDebug() ) cout << oss.str().c_str() << endl;
5504    
5505          result = conn->Query(oss.str().c_str());          rresult = conn->Query(oss.str().c_str());
5506          if ( !result ) throw -4;;          if ( !result ) throw -4;;
5507          if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl;          if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl;
5508                    
# Line 5488  Int_t PamelaDBOperations::insertTRK_CALI Line 5511  Int_t PamelaDBOperations::insertTRK_CALI
5511          // -----------------------------------          // -----------------------------------
5512          UInt_t nn=0;          UInt_t nn=0;
5513          do {          do {
5514              row = result->Next();              row = rresult->Next();
5515              if(!row)break;              if(!row)break;
5516                            
5517              UInt_t id       = (UInt_t)atoll(row->GetField(0));              UInt_t id       = (UInt_t)atoll(row->GetField(0));
# Line 5527  Int_t PamelaDBOperations::insertTRK_CALI Line 5550  Int_t PamelaDBOperations::insertTRK_CALI
5550              TString path       = "";              TString path       = "";
5551              TString name       = "";              TString name       = "";
5552              TString raw        = "";              TString raw        = "";
5553              UInt_t obt0        = 0;              //      UInt_t obt0        = 0;
5554              UInt_t timesync    = 0;              //      UInt_t timesync    = 0;
5555              UInt_t boot_number = 0;              //      UInt_t boot_number = 0;
5556              bool   FOUND       = false;              bool   FOUND       = false;
5557    
5558              if ( IsDebug() ) cout << "------------------------------------------------------------" <<endl;              if ( IsDebug() ) cout << "------------------------------------------------------------" <<endl;
# Line 5602  Int_t PamelaDBOperations::insertTRK_CALI Line 5625  Int_t PamelaDBOperations::insertTRK_CALI
5625                      path       = (TString)row2->GetField(0);                      path       = (TString)row2->GetField(0);
5626                      name       = (TString)row2->GetField(1);                      name       = (TString)row2->GetField(1);
5627                      raw        = (TString)row2->GetField(5);                      raw        = (TString)row2->GetField(5);
5628                      obt0        = (UInt_t)atoll(row2->GetField(2));                      //              obt0        = (UInt_t)atoll(row2->GetField(2));
5629                      timesync    = (UInt_t)atoll(row2->GetField(3));                      //              timesync    = (UInt_t)atoll(row2->GetField(3));
5630                      boot_number = (UInt_t)atoll(row2->GetField(4));                      //              boot_number = (UInt_t)atoll(row2->GetField(4));
5631                                    
5632                      if ( IsDebug() ) cout << "- - - - - - - - - - -" <<endl;                      if ( IsDebug() ) cout << "- - - - - - - - - - -" <<endl;
5633  //                  cout << path <<endl;  //                  cout << path <<endl;
# Line 5668  Int_t PamelaDBOperations::insertTRK_CALI Line 5691  Int_t PamelaDBOperations::insertTRK_CALI
5691                      if(FOUND)break;                      if(FOUND)break;
5692    
5693                  }while(1);//endl loop over root table entries                  }while(1);//endl loop over root table entries
5694                    
5695                    delete result2; // 10RED potential memory leak
5696                  if(FOUND)break;                  if(FOUND)break;
5697    
5698              }//end loop over tables              }//end loop over tables
# Line 5822  Int_t PamelaDBOperations::insertTRK_CALI Line 5846  Int_t PamelaDBOperations::insertTRK_CALI
5846          }while(1);//end loop over calibrations          }while(1);//end loop over calibrations
5847                    
5848                    
5849          if( result )delete result;          if( rresult )delete rresult; // 10RED bug
5850          if( row    )delete row;          if( row    )delete row;
5851                    
5852                    
# Line 6123  Int_t PamelaDBOperations::CleanGL_RUN_FR Line 6147  Int_t PamelaDBOperations::CleanGL_RUN_FR
6147      memset(myid,0,500*sizeof(UInt_t));      memset(myid,0,500*sizeof(UInt_t));
6148      //      //
6149      oss.str("");      oss.str("");
6150      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;";
6151      if ( IsDebug() ) printf(" Select from GL_RUN_FRAGMENTS runs older than %s : query is \n %s \n",clean_time->AsSQLString(),oss.str().c_str());      if ( IsDebug() ) printf(" Select from GL_RUN_FRAGMENTS runs older than %s : query is \n %s \n",clean_time->AsSQLString(),oss.str().c_str());
6152      nresult = conn->Query(oss.str().c_str());      nresult = conn->Query(oss.str().c_str());
6153      //      //
# Line 6154  Int_t PamelaDBOperations::CleanGL_RUN_FR Line 6178  Int_t PamelaDBOperations::CleanGL_RUN_FR
6178            while ( anr ){            while ( anr ){
6179              //              //
6180              oss.str("");              oss.str("");
6181              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
6182              if ( IsDebug() ) printf(" In the loop searching for fragmented runs : query is \n %s \n",oss.str().c_str());              if ( IsDebug() ) printf(" In the loop searching for fragmented runs : query is \n %s \n",oss.str().c_str());
6183              //              //
6184              nresult1 = conn->Query(oss.str().c_str());              nresult1 = conn->Query(oss.str().c_str());

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.37

  ViewVC Help
Powered by ViewVC 1.1.23