/[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.5 by mocchiut, Wed Sep 6 11:04:39 2006 UTC revision 1.8 by mocchiut, Fri Sep 8 08:48:04 2006 UTC
# Line 759  Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(U Line 759  Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(U
759    };    };
760    delete pResult;        delete pResult;    
761    //    //
762    if(TO_TIME < time)return(51);    if ( TO_TIME < time ) return(51);
763      //
764    if ( (!OBT1 && !PKT1 ) || (!OBT2 && !PKT2) ) return(52); // ONE CALIBRATION PACKET IS MISSING!    if ( (!OBT1 && !PKT1 ) || (!OBT2 && !PKT2) ) return(52); // ONE CALIBRATION PACKET IS MISSING!
765    //    //
766    return 0;    return 0;
# Line 772  Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(U Line 773  Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(U
773   * \param  run starting time   * \param  run starting time
774   * \return struct of type GL_CALO_CALIB_data, which stores the query result   * \return struct of type GL_CALO_CALIB_data, which stores the query result
775   */   */
776  Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB(UInt_t time, UInt_t section, TSQLServer *dbc){  Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB(UInt_t time, UInt_t &uptime,  UInt_t section, TSQLServer *dbc){
777    // MySQL variables    // MySQL variables
778    TSQLResult *pResult;    TSQLResult *pResult;
779    TSQLRow *Row;    TSQLRow *Row;
780    int t;    int t;
781    stringstream myquery;    stringstream myquery;
782      uptime = 0;
783    //    //
784    // select the correct calibration    // select the correct calibration
785    //    //
# Line 785  Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB Line 787  Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB
787    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;
788    myquery << " and FROM_TIME <= " << time;    myquery << " and FROM_TIME <= " << time;
789    myquery << " and TO_TIME > " << time;    myquery << " and TO_TIME > " << time;
790    myquery << " and VALIDATION=1;";    myquery << " ;";
791      //myquery << " and VALIDATION=1;";
792    //    //
793    pResult = dbc->Query(myquery.str().c_str());    pResult = dbc->Query(myquery.str().c_str());
794      //  printf(" mysquery is %s\n",myquery.str().c_str());
795      //
796      if( !pResult->GetRowCount() ) return(-54);
797      Row = pResult->Next();
798      if( Row == NULL ) return (-54);
799      //
800      uptime = (UInt_t)atoll(Row->GetField(2));
801    //    //
802    // if it is corrupted validation is 0 and we have no results from the query...    // if it is corrupted validation is 0 and we have no results from the query...
803    //    //
804    if( !pResult->GetRowCount() ){    if( atoi(Row->GetField(4)) == 0 ){ // if validation = 0
     //    pResult->Delete();  
805      //      //
806      // in this case take relax the conditions and take the valid calibration that preceed the correct one      // in this case take relax the conditions and take the valid calibration that preceed the correct one
807      //      //
# Line 801  Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB Line 810  Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB
810      myquery << " and FROM_TIME <= " << time;      myquery << " and FROM_TIME <= " << time;
811      myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;";      myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;";
812      pResult = dbc->Query(myquery.str().c_str());      pResult = dbc->Query(myquery.str().c_str());
813        //    printf(" mysquery is %s\n",myquery.str().c_str());
814      //      //
815      // if no results yet quit with error      // if no results yet quit with error
816      //      //
817      if( !pResult->GetRowCount() ) return (-54);      if( !pResult->GetRowCount() ) return (-54);
818        //
819        Row = pResult->Next();
820        //
821    };    };
822    //    //
823    // store infos and exit    // store infos and exit
824    //    //
   Row = pResult->Next();  
825    if( Row == NULL ) return (-54);    if( Row == NULL ) return (-54);
826    for( t = 0; t < pResult->GetFieldCount(); t++){    for( t = 0; t < pResult->GetFieldCount(); t++){
827      if (t==0) ID_ROOT_L0  = (UInt_t)atoll(Row->GetField(t));      if (t==0) ID_ROOT_L0  = (UInt_t)atoll(Row->GetField(t));
# Line 1098  TString GL_TIMESYNC::ConvertTime(TString Line 1110  TString GL_TIMESYNC::ConvertTime(TString
1110    //    //
1111    return(rtime);    return(rtime);
1112  }  }
1113    
1114    /*
1115     *
1116     * Convert the time in the DB from UInt_t to a string
1117     *
1118     * @param dbt time in the DB
1119     * @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK
1120     *
1121     */
1122    TString GL_TIMESYNC::UnConvertTime(TString tzone, UInt_t dbt){
1123      //
1124      TDatime *time = new TDatime();
1125      TString rtime;
1126      //
1127      time->Set(dbt,false); // MSK = Moscow Winter Time
1128      //
1129      if ( !strcmp(tzone.Data(),"UTC") || !strcmp(tzone.Data(),"GMT") ){
1130        //
1131        UInt_t timeUTC = time->Convert() + 60*60*3; // UTC (Coordinated Universal Time) +3 hs = Moscow Winter Time
1132        time->Set(timeUTC,false);
1133        //
1134      };
1135      //
1136      if ( !strcmp(tzone.Data(),"CET") ){
1137        //
1138        UInt_t timeCET = time->Convert() + 60*60*2; // CET (Central European Time) + 2 hs = Moscow Winter Time  
1139        time->Set(timeCET,false);
1140        //
1141      };
1142      //
1143      if ( !strcmp(tzone.Data(),"CEST") ){
1144        //
1145        UInt_t timeCEST = time->Convert() + 60*60*1; // CEST (Central European Summer Time) + 1 h = Moscow Winter Time
1146        time->Set(timeCEST,false);
1147        //
1148      };
1149      //
1150      if ( !strcmp(tzone.Data(),"MSD") ){
1151        //
1152        UInt_t timeMSD = time->Convert() - 60*60*1; // MSD (Moscow Summer Time) - 1 h = Moscow Winter Time
1153        time->Set(timeMSD,false);
1154        //
1155      };
1156      //
1157      rtime = time->AsSQLString();
1158      //
1159      return(rtime);
1160    }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.23