/[PAMELA software]/YodaProfiler/src/GLTables.cpp
ViewVC logotype

Diff of /YodaProfiler/src/GLTables.cpp

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

revision 1.21 by mocchiut, Tue Jan 23 17:04:11 2007 UTC revision 1.30 by mocchiut, Fri Sep 7 21:10:57 2007 UTC
# Line 17  Line 17 
17  #include <GLTables.h>  #include <GLTables.h>
18  #include <sgp4.h>  #include <sgp4.h>
19  //  //
20    ClassImp(GL_TABLES);
21  ClassImp(GL_TRK_CALIB);  ClassImp(GL_TRK_CALIB);
22  ClassImp(GL_RUN);  ClassImp(GL_RUN);
23  ClassImp(GL_ROOT);  ClassImp(GL_ROOT);
# Line 28  ClassImp(GL_TLE); Line 29  ClassImp(GL_TLE);
29  //  //
30  using namespace std;  using namespace std;
31    
32    GL_TABLES::GL_TABLES(){
33    };
34    
35    GL_TABLES::GL_TABLES(TString host, TString user, TString psw){
36      fHost = new TString(host.Data());
37      fUser = new TString(user.Data());
38      fPsw = new TString(psw.Data());
39      fSet = true;
40      fNquery = 0;
41    };
42    
43    
44    void GL_TABLES::Set(TString host, TString user, TString psw){
45      fHost = new TString(host.Data());
46      fUser = new TString(user.Data());
47      fPsw = new TString(psw.Data());
48      fSet = true;
49      fNquery = 0;
50    };
51    
52    Bool_t GL_TABLES::IsConnected(TSQLServer *&dbc){
53      //
54      //
55      //
56      if ( !fSet ){
57        return true;
58      };
59      //
60      //
61      //
62      //    printf(" host is %s \n",fHost->Data());
63      //
64      stringstream myquery;  
65      myquery.str("");
66      myquery << "show databases;";
67      if ( dbc ){
68        if ( dbc->IsConnected() ){
69          dbc->Query(myquery.str().c_str());
70          fNquery++;
71          if ( !(dbc->GetErrorCode()) ){
72            //      printf("ok\n");
73            //
74            //  if ( (dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006) ){
75            //    if ( !(dbc->GetErrorCode()) ){
76            // is connected
77            return true;
78            //    };
79          };
80        };
81      };
82      //  printf("porca di quella \n");
83      if ( true ) {
84        //
85        printf(" WARNING: Lost connection to DB! try to recover... \n");
86        //
87        TString host = fHost->Data();
88        TString user = fUser->Data();
89        TString psw = fPsw->Data();
90        delete dbc;
91        dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
92        //
93        myquery.str("");
94        myquery << "show databases;";
95        dbc->Query(myquery.str().c_str());
96        fNquery++;
97        //    printf(" e riporca di quella \n");
98        //
99        //    if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){
100        if ( !(dbc->GetErrorCode()) ){
101          //
102          printf(" ...connection recovered, I can continue! \n");
103          //
104          myquery.str("");
105          myquery << "SET time_zone='+0:00'";
106          dbc->Query(myquery.str().c_str());
107          fNquery++;
108          myquery.str("");
109          myquery << "SET wait_timeout=173000;";
110          dbc->Query(myquery.str().c_str());      
111          fNquery++;
112          return true;
113        };
114      };
115      //
116      printf(" GLTABLES: connection is gone away, query will fail\n");
117      //
118      return false;
119      //
120    };
121    
122    void GL_TABLES::ResetCounters(){
123      fNquery = 0;
124    };
125    
126    void GL_TABLES::AddQ(){
127      if ( fSet ) fNquery++;
128    };
129    
130    UInt_t GL_TABLES::GetNqueries(){
131       UInt_t rn = 0;
132       rn += (UInt_t&)fNquery;
133       return(rn);
134    };
135    
136  GL_RUN::GL_RUN() {  GL_RUN::GL_RUN() {
137    ID                         = 0;    ID                         = 0;
138    ID_RUN_FRAG                = 0;    ID_RUN_FRAG                = 0;
# Line 425  Int_t GL_RUN::DeleteRun(TSQLServer *dbc, Line 530  Int_t GL_RUN::DeleteRun(TSQLServer *dbc,
530    //    //
531    //  printf("1myquery is %s \n",myquery.str().c_str());    //  printf("1myquery is %s \n",myquery.str().c_str());
532    //    //
533      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
534      this->GetGLTABLES()->AddQ();
535    dbc->Query(myquery.str().c_str());    dbc->Query(myquery.str().c_str());
536    //    //
537    // retrieve this ID_TRASH    // retrieve this ID_TRASH
538    //    //
539    myquery.str("");    myquery.str("");
540    myquery << " SELECT ID_TRASH,ID_ROOT_L0,ID_ROOT_L2 FROM GL_RUN_TRASH ORDER BY ID_TRASH DESC LIMIT 1";      myquery << " SELECT ID_TRASH,ID_ROOT_L0,ID_ROOT_L2 FROM GL_RUN_TRASH ORDER BY ID_TRASH DESC LIMIT 1";  
541      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
542      this->GetGLTABLES()->AddQ();
543    pResult = dbc->Query(myquery.str().c_str());    pResult = dbc->Query(myquery.str().c_str());
544    //    //
545    UInt_t idtrash = 0;    UInt_t idtrash = 0;
# Line 452  Int_t GL_RUN::DeleteRun(TSQLServer *dbc, Line 561  Int_t GL_RUN::DeleteRun(TSQLServer *dbc,
561    //    //
562    //  printf("2myquery is %s \n",myquery.str().c_str());    //  printf("2myquery is %s \n",myquery.str().c_str());
563    //    //
564      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
565      this->GetGLTABLES()->AddQ();
566    pResult = dbc->Query(myquery.str().c_str());    pResult = dbc->Query(myquery.str().c_str());
567    //    //
568    Row = pResult->Next();          Row = pResult->Next();      
# Line 467  Int_t GL_RUN::DeleteRun(TSQLServer *dbc, Line 578  Int_t GL_RUN::DeleteRun(TSQLServer *dbc,
578    //    //
579    //  printf("3myquery is %s \n",myquery.str().c_str());    //  printf("3myquery is %s \n",myquery.str().c_str());
580    //    //
581      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
582      this->GetGLTABLES()->AddQ();
583    pResult = dbc->Query(myquery.str().c_str());    pResult = dbc->Query(myquery.str().c_str());
584    //    //
585    Row = pResult->Next();          Row = pResult->Next();      
# Line 483  Int_t GL_RUN::DeleteRun(TSQLServer *dbc, Line 596  Int_t GL_RUN::DeleteRun(TSQLServer *dbc,
596    //    //
597    //  printf("4myquery is %s \n",myquery.str().c_str());    //  printf("4myquery is %s \n",myquery.str().c_str());
598    //    //
599      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
600      this->GetGLTABLES()->AddQ();
601    dbc->Query(myquery.str().c_str());    dbc->Query(myquery.str().c_str());
602    //    //
603    myquery.str("");    myquery.str("");
# Line 492  Int_t GL_RUN::DeleteRun(TSQLServer *dbc, Line 607  Int_t GL_RUN::DeleteRun(TSQLServer *dbc,
607    //    //
608    //  printf("4myquery is %s \n",myquery.str().c_str());    //  printf("4myquery is %s \n",myquery.str().c_str());
609    //    //
610      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
611      this->GetGLTABLES()->AddQ();
612    dbc->Query(myquery.str().c_str());    dbc->Query(myquery.str().c_str());
613    //    //
614    myquery.str("");    myquery.str("");
# Line 502  Int_t GL_RUN::DeleteRun(TSQLServer *dbc, Line 619  Int_t GL_RUN::DeleteRun(TSQLServer *dbc,
619    //  printf("4myquery is %s \n",myquery.str().c_str());    //  printf("4myquery is %s \n",myquery.str().c_str());
620    //    //
621    //    //
622      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
623      this->GetGLTABLES()->AddQ();
624    dbc->Query(myquery.str().c_str());    dbc->Query(myquery.str().c_str());
625    //    //
626    myquery.str("");    myquery.str("");
# Line 512  Int_t GL_RUN::DeleteRun(TSQLServer *dbc, Line 631  Int_t GL_RUN::DeleteRun(TSQLServer *dbc,
631    //  printf("5myquery is %s \n",myquery.str().c_str());    //  printf("5myquery is %s \n",myquery.str().c_str());
632    //    //
633    //    //
634      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
635      this->GetGLTABLES()->AddQ();
636    dbc->Query(myquery.str().c_str());    dbc->Query(myquery.str().c_str());
637    //    //
638    return 0;    return 0;
# Line 543  Int_t GL_RUN::RestoreRun(TSQLServer *dbc Line 664  Int_t GL_RUN::RestoreRun(TSQLServer *dbc
664      //      //
665      printf(" qui? myquery is %s \n",myquery.str().c_str());      printf(" qui? myquery is %s \n",myquery.str().c_str());
666      //      //
667        if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
668        this->GetGLTABLES()->AddQ();
669      pResult = dbc->Query(myquery.str().c_str());      pResult = dbc->Query(myquery.str().c_str());
670      //      //
671      Row = pResult->Next();            Row = pResult->Next();      
# Line 626  Int_t GL_RUN::RestoreRun(TSQLServer *dbc Line 749  Int_t GL_RUN::RestoreRun(TSQLServer *dbc
749    //    //
750    //  printf("5myquery is %s \n",myquery.str().c_str());    //  printf("5myquery is %s \n",myquery.str().c_str());
751    //    //
752      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
753      this->GetGLTABLES()->AddQ();
754    dbc->Query(myquery.str().c_str());    dbc->Query(myquery.str().c_str());
755    //    //
756    //    //
# Line 633  Int_t GL_RUN::RestoreRun(TSQLServer *dbc Line 758  Int_t GL_RUN::RestoreRun(TSQLServer *dbc
758    myquery << " DELETE FROM GL_RUN_TRASH where BELONGED_TO='GL_RUN_FRAGMENTS' AND ID=";    myquery << " DELETE FROM GL_RUN_TRASH where BELONGED_TO='GL_RUN_FRAGMENTS' AND ID=";
759    myquery << IDRUN << ";";    myquery << IDRUN << ";";
760    //    //
761      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
762      this->GetGLTABLES()->AddQ();
763    dbc->Query(myquery.str().c_str());    dbc->Query(myquery.str().c_str());
764    //    //
765    return 0;    return 0;
# Line 715  Int_t GL_RUN::Fill_GL_RUN(TSQLServer *db Line 842  Int_t GL_RUN::Fill_GL_RUN(TSQLServer *db
842    //    //
843    //  printf("myquery is %s \n",myquery.str().c_str());    //  printf("myquery is %s \n",myquery.str().c_str());
844    //    //
845      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
846      this->GetGLTABLES()->AddQ();
847    dbc->Query(myquery.str().c_str());    dbc->Query(myquery.str().c_str());
848    //    //
849    return 0;    return 0;
# Line 791  Int_t GL_RUN::Fill_GL_RUN_FRAGMENTS(TSQL Line 920  Int_t GL_RUN::Fill_GL_RUN_FRAGMENTS(TSQL
920    //    //
921    // printf("myquery is %s \n",myquery.str().c_str());    // printf("myquery is %s \n",myquery.str().c_str());
922    //    //
923      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
924      this->GetGLTABLES()->AddQ();
925    dbc->Query(myquery.str().c_str());    dbc->Query(myquery.str().c_str());
926    //    //
927    return 0;    return 0;
# Line 848  Int_t GL_RUN::Query_GL_RUN(UInt_t run, T Line 979  Int_t GL_RUN::Query_GL_RUN(UInt_t run, T
979    myquery << " from GL_RUN where ID=" << run << ";";    myquery << " from GL_RUN where ID=" << run << ";";
980    //    //
981    //  printf(" myquery is %s \n",myquery.str().c_str());    //  printf(" myquery is %s \n",myquery.str().c_str());
982      if ( !this->IsConnected(dbc) ) return -57;  
983      this->AddQ();
984    pResult = dbc->Query(myquery.str().c_str());    pResult = dbc->Query(myquery.str().c_str());
985    //    //
986    //  printf(" getrowcount %i \n",pResult->GetRowCount());    //  printf(" getrowcount %i \n",pResult->GetRowCount());
# Line 946  Int_t GL_RUN::Query_GL_RUN_FRAGMENTS(TSt Line 1079  Int_t GL_RUN::Query_GL_RUN_FRAGMENTS(TSt
1079    //    //
1080    //  printf(" query is %s \n",myquery.str().c_str());    //  printf(" query is %s \n",myquery.str().c_str());
1081    //    //
1082      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
1083      this->GetGLTABLES()->AddQ();
1084    pResult = dbc->Query(myquery.str().c_str());    pResult = dbc->Query(myquery.str().c_str());
1085    if(!pResult->GetRowCount())return(-50);    if(!pResult->GetRowCount())return(-50);
1086    for( r=0; r < 1000; r++){    for( r=0; r < 1000; r++){
# Line 1011  Int_t GL_ROOT::Query_GL_ROOT(UInt_t id, Line 1146  Int_t GL_ROOT::Query_GL_ROOT(UInt_t id,
1146    myquery << ",NAME";    myquery << ",NAME";
1147    myquery << " from GL_ROOT where ID=" << id << ";";        myquery << " from GL_ROOT where ID=" << id << ";";    
1148    //    //
1149      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
1150      this->GetGLTABLES()->AddQ();
1151    pResult = dbc->Query(myquery.str().c_str());    pResult = dbc->Query(myquery.str().c_str());
1152    if(!pResult->GetRowCount())return (-51);    if(!pResult->GetRowCount())return (-51);
1153    for( r=0; r < 1000; r++){    for( r=0; r < 1000; r++){
# Line 1020  Int_t GL_ROOT::Query_GL_ROOT(UInt_t id, Line 1157  Int_t GL_ROOT::Query_GL_ROOT(UInt_t id,
1157            if(t==0) ID     = (UInt_t)atoll(Row->GetField(t));            if(t==0) ID     = (UInt_t)atoll(Row->GetField(t));
1158            if(t==1) ID_RAW = (UInt_t)atoll(Row->GetField(t));            if(t==1) ID_RAW = (UInt_t)atoll(Row->GetField(t));
1159            if(t==2) ID_TIMESYNC = (UInt_t)atoll(Row->GetField(t));            if(t==2) ID_TIMESYNC = (UInt_t)atoll(Row->GetField(t));
1160            if(t==3) PATH   = Row->GetField(t);            if(t==3) PATH   = (TString)gSystem->ExpandPathName(Row->GetField(t))+'/';
1161            if(t==4) NAME   = Row->GetField(t);            if(t==4) NAME   = Row->GetField(t);
1162        };        };
1163    };    };
# Line 1045  Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(U Line 1182  Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(U
1182    // ----------------    // ----------------
1183    myquery.str("");    myquery.str("");
1184    myquery << "select ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,OBT2,PKT1,PKT2,BOOT_NUMBER,VALIDATION from GL_TRK_CALIB where FROM_TIME <= "<< time;    myquery << "select ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,OBT2,PKT1,PKT2,BOOT_NUMBER,VALIDATION from GL_TRK_CALIB where FROM_TIME <= "<< time;
1185    myquery << " AND VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;";        //  myquery << " AND VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;";      // RIVEDERE LA VALIDAZIONE!!!
1186      myquery << " and EV_ROOT_CALIBTRK1>=0 and EV_ROOT_CALIBTRK2>=0 "; // EM! SE MANCA UN PACCHETTO DEI DUE IL PROCESSAMENTO CRASHA... DA RIVEDERE LA VALIDAZIONE      
1187      myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";      
1188    //  myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";          //  myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";      
1189      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
1190      this->GetGLTABLES()->AddQ();
1191    pResult = dbc->Query(myquery.str().c_str());    pResult = dbc->Query(myquery.str().c_str());
1192    if(!pResult->GetRowCount())return (-53);    if(!pResult->GetRowCount())return (-53);
1193    for( r=0; r < 1000; r++){    for( r=0; r < 1000; r++){
# Line 1104  Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB Line 1245  Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB
1245    myquery << " ;";    myquery << " ;";
1246    //myquery << " and VALIDATION=1;";    //myquery << " and VALIDATION=1;";
1247    //    //
1248      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
1249      this->GetGLTABLES()->AddQ();
1250    pResult = dbc->Query(myquery.str().c_str());    pResult = dbc->Query(myquery.str().c_str());
1251    //  printf(" mysquery is %s\n",myquery.str().c_str());    //  printf(" mysquery is %s\n",myquery.str().c_str());
1252    //    //
# Line 1123  Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB Line 1266  Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB
1266      myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section;      myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section;
1267      myquery << " and FROM_TIME <= " << time;      myquery << " and FROM_TIME <= " << time;
1268      myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;";      myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;";
1269        if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
1270        this->GetGLTABLES()->AddQ();
1271      pResult = dbc->Query(myquery.str().c_str());      pResult = dbc->Query(myquery.str().c_str());
1272      //    printf(" mysquery is %s\n",myquery.str().c_str());      //    printf(" mysquery is %s\n",myquery.str().c_str());
1273      //      //
# Line 1165  Int_t GL_S4_CALIB::Query_GL_S4_CALIB(UIn Line 1310  Int_t GL_S4_CALIB::Query_GL_S4_CALIB(UIn
1310    myquery << "select * from GL_S4_CALIB where FROM_TIME <= "<< time;    myquery << "select * from GL_S4_CALIB where FROM_TIME <= "<< time;
1311    myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";          myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";      
1312    //  myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";          //  myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";      
1313      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
1314      this->GetGLTABLES()->AddQ();
1315    pResult = dbc->Query(myquery.str().c_str());    pResult = dbc->Query(myquery.str().c_str());
1316    if(!pResult->GetRowCount())return (-55);//throw -55;    if(!pResult->GetRowCount())return (-55);//throw -55;
1317    for( r=0; r < 1000; r++){    for( r=0; r < 1000; r++){
# Line 1205  Int_t GL_PARAM::Query_GL_PARAM(UInt_t ti Line 1352  Int_t GL_PARAM::Query_GL_PARAM(UInt_t ti
1352    // ----------------        // ----------------    
1353    myquery.str("");    myquery.str("");
1354    myquery << " select ";    myquery << " select ";
1355    myquery << " ID, PATH, NAME, DESCR, TYPE, FROM_TIME,TO_TIME ";    myquery << " ID, PATH, NAME, DESCR, FROM_TIME,TO_TIME, TYPE ";
1356    myquery << " from GL_PARAM ";    myquery << " from GL_PARAM ";
1357    myquery << " where TYPE = '"<<type<<"' ";    myquery << " where TYPE = '"<<type<<"' ";
1358    myquery << " and FROM_TIME <= " << time;    myquery << " and FROM_TIME <= " << time;
1359    myquery << " ORDER BY TO_TIME DESC LIMIT 1;";      myquery << " ORDER BY TO_TIME DESC LIMIT 1;";  
1360    //    //
1361      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
1362      this->GetGLTABLES()->AddQ();
1363    pResult = dbc->Query(myquery.str().c_str());    pResult = dbc->Query(myquery.str().c_str());
1364    if(!pResult->GetRowCount())return (-52);    if(!pResult->GetRowCount())return (-52);
1365    for( r=0; r < 1000; r++){    for( r=0; r < 1000; r++){
# Line 1218  Int_t GL_PARAM::Query_GL_PARAM(UInt_t ti Line 1367  Int_t GL_PARAM::Query_GL_PARAM(UInt_t ti
1367        if( Row == NULL ) break;        if( Row == NULL ) break;
1368        for( t = 0; t < pResult->GetFieldCount(); t++){        for( t = 0; t < pResult->GetFieldCount(); t++){
1369          if (t==0) ID        = (UInt_t)atoll(Row->GetField(t));          if (t==0) ID        = (UInt_t)atoll(Row->GetField(t));
1370            if (t==1) PATH      = Row->GetField(t);// put in fpath the path to that file          if (t==1) PATH      = (TString)gSystem->ExpandPathName(Row->GetField(t))+'/';// put in fpath the path to that file
1371            if (t==2) NAME      = Row->GetField(t);            if (t==2) NAME      = Row->GetField(t);
1372            if (t==3) DESCR     = Row->GetField(t);            if (t==3) DESCR     = Row->GetField(t);
1373            if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t));            if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t));
# Line 1264  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr Line 1413  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr
1413    TSQLRow *Row;    TSQLRow *Row;
1414    stringstream myquery;    stringstream myquery;
1415    stringstream rname;    stringstream rname;
1416      //  pcksList packetsNames;
1417      //  pcksList::iterator Iter;
1418      //  getPacketsNames(packetsNames);
1419    rname.str("");    rname.str("");
1420    // ----------------    // ----------------
1421    myquery.str("");    myquery.str("");
# Line 1274  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr Line 1426  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr
1426    myquery << type.Data();    myquery << type.Data();
1427    myquery << "=" << id << ";";        myquery << "=" << id << ";";    
1428    //    //
1429      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return;  
1430      this->GetGLTABLES()->AddQ();
1431    pResult = dbc->Query(myquery.str().c_str());    pResult = dbc->Query(myquery.str().c_str());
1432    if( pResult->GetRowCount() ){    if( pResult->GetRowCount() ){
1433      Row = pResult->Next();            Row = pResult->Next();      
1434      if( Row ){      if( Row ){
1435        stringstream fname;        stringstream fname;
1436        fname.str("");        fname.str("");
1437        fname << Row->GetField(0) << "/" << Row->GetField(1);        fname << gSystem->ExpandPathName(Row->GetField(0)) << "/" << Row->GetField(1);
1438        rname << Row->GetField(1);        rname << Row->GetField(1);
1439        file = new TFile(fname.str().c_str(),"READ");        file = new TFile(fname.str().c_str(),"READ");
1440        idraw = (UInt_t)atoll(Row->GetField(2));        idraw = (UInt_t)atoll(Row->GetField(2));
# Line 1297  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr Line 1451  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr
1451      ph = eh->GetPscuHeader();      ph = eh->GetPscuHeader();
1452      pktfirst = ph->GetCounter();      pktfirst = ph->GetCounter();
1453      obtfirst = ph->GetOrbitalTime();        obtfirst = ph->GetOrbitalTime();  
1454        //
1455    //     code = eh->GetCounter();
1456    //     UInt_t en = 0;
1457    //     for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){
1458    //       en = code->Get(GetPacketType(*Iter));
1459    //       if ( !strcmp("CalibCalPed",*Iter) || !strcmp("CalibTrk1",*Iter) || !strcmp("CalibTrk2",*Iter) || !strcmp("CalibS4",*Iter) ){
1460    //      //
1461    //      TTree *TC = 0;
1462    //      TC = (TTree*)file->Get("CalibCalPed");
1463    //      if ( !TC || TC->IsZombie() ) return;
1464    //      EventHeader *ehc = 0;
1465    //      PscuHeader *phc = 0;
1466    //      TC->SetBranchAddress("Header", &ehc);
1467    //      TC->GetEntry(0);
1468    //      phc = ehc->GetPscuHeader();
1469    //      pktfirst = phc->GetCounter();
1470    //      obtfirst = phc->GetOrbitalTime();  
1471    //       //
1472    //       };
1473    //     };  
1474        //
1475    };    };
1476    //    //
1477    // look for Resurs offset    // look for Resurs offset
# Line 1305  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr Line 1480  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr
1480    //    //
1481    //    //
1482    stringstream oss;    stringstream oss;
1483      TString frn = rname.str().c_str();
1484      frn = frn.ReplaceAll(".root",5,".pam",4);
1485    oss.str("");    oss.str("");
1486    oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE) FROM GL_RESURS_OFFSET WHERE SPECIAL_FILE='"    oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE) FROM GL_RESURS_OFFSET WHERE SPECIAL_FILE='"
1487        << rname.str().c_str() << "';";        << frn.Data() << "';";
1488      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return;  
1489      this->GetGLTABLES()->AddQ();
1490    pResult = dbc->Query(oss.str().c_str());    pResult = dbc->Query(oss.str().c_str());
1491    Row = pResult->Next();    Row = pResult->Next();
1492    //    //
# Line 1326  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr Line 1505  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr
1505      for (Int_t i = 8; i<13; i++){      for (Int_t i = 8; i<13; i++){
1506        dwo.Append(name[i],1);        dwo.Append(name[i],1);
1507      };          };    
1508      if ( dwo.IsDigit() ) dworbit = (UInt_t)dwo.Atoi();      if ( dwo.IsDigit() ){
1509          dworbit = (UInt_t)dwo.Atoi();
1510        } else {
1511          dworbit = 1;
1512        };
1513    };    };
1514    //    //
1515      //
1516    if ( !Row ){    if ( !Row ){
1517      oss.str("");      oss.str("");
1518      oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE) FROM GL_RESURS_OFFSET WHERE FROM_ORBIT< "      oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE) FROM GL_RESURS_OFFSET WHERE FROM_ORBIT< "
1519          << dworbit << " order by FROM_ORBIT desc limit 1;";          << dworbit << " order by FROM_ORBIT desc limit 1;";
1520        if ( !this->GetGLTABLES()->IsConnected(dbc) ) return;  
1521        this->GetGLTABLES()->AddQ();
1522      pResult = dbc->Query(oss.str().c_str());      pResult = dbc->Query(oss.str().c_str());
1523      Row = pResult->Next();      Row = pResult->Next();
1524      if ( !Row ){      if ( !Row ){
# Line 1350  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr Line 1536  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr
1536    myquery << " SELECT OBT0,TIMESYNC,TYPE FROM GL_TIMESYNC "    myquery << " SELECT OBT0,TIMESYNC,TYPE FROM GL_TIMESYNC "
1537        << " WHERE ID_RAW = " << idraw        << " WHERE ID_RAW = " << idraw
1538        << ";";        << ";";
1539      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return;  
1540      this->GetGLTABLES()->AddQ();
1541    pResult = dbc->Query(myquery.str().c_str());    pResult = dbc->Query(myquery.str().c_str());
1542    if ( pResult ){    if ( pResult ){
1543      Row = pResult->Next();      Row = pResult->Next();
# Line 1632  Int_t GL_TLE::DoQuery(TString myquery, T Line 1820  Int_t GL_TLE::DoQuery(TString myquery, T
1820    TSQLRow *row;    TSQLRow *row;
1821    
1822    // Set the right time_zone (otherwise horrible things will occur! :)    // Set the right time_zone (otherwise horrible things will occur! :)
1823      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
1824    dbc->Query("SET time_zone = '+0:00'");    dbc->Query("SET time_zone = '+0:00'");
1825    
1826    // Do the query    // Do the query
1827      this->GetGLTABLES()->AddQ();
1828    result = dbc->Query(myquery.Data());    result = dbc->Query(myquery.Data());
1829    if(! result->GetRowCount() ) {    if(! result->GetRowCount() ) {
1830      cerr << "GL_TLE: query failed: " << myquery.Data() << endl;      cerr << "GL_TLE: query failed: " << myquery.Data() << endl;

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.30

  ViewVC Help
Powered by ViewVC 1.1.23