/[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.7 by mocchiut, Thu Sep 7 09:17:32 2006 UTC revision 1.10 by mocchiut, Tue Sep 19 09:18:46 2006 UTC
# Line 58  GL_RUN::GL_RUN() { Line 58  GL_RUN::GL_RUN() {
58    VALIDATION                 = 0;    VALIDATION                 = 0;
59  }  }
60    
61    
62  void GL_RUN::Clear() {  void GL_RUN::Clear() {
63    ID                         = 0;    ID                         = 0;
64    ID_RUN_FRAG                = 0;    ID_RUN_FRAG                = 0;
# Line 122  GL_TRK_CALIB::GL_TRK_CALIB(){ Line 123  GL_TRK_CALIB::GL_TRK_CALIB(){
123    OBT2 = 0;    OBT2 = 0;
124    PKT1 = 0;    PKT1 = 0;
125    PKT2 = 0;    PKT2 = 0;
126      BOOT_NUMBER                = 0;
127      VALIDATION                 = 0;
128  }  }
129    
130  GL_CALO_CALIB::GL_CALO_CALIB(){  GL_CALO_CALIB::GL_CALO_CALIB(){
# Line 327  void GL_RUN::Set_GL_RUNH0(){ Line 330  void GL_RUN::Set_GL_RUNH0(){
330    CAL_DSP_MASK              = 0;    CAL_DSP_MASK              = 0;
331  };  };
332    
333    void GL_RUN::Set_GL_RUN(TSQLRow *Row){
334            for( Int_t t = 0; t < 30; t++){
335                    if (t== 0) ID                = (UInt_t)atoll(Row->GetField(t));
336                    if (t== 1) ID_RUN_FRAG       = (UInt_t)atoll(Row->GetField(t));
337                    if (t== 2) ID_ROOT_L0        = (UInt_t)atoll(Row->GetField(t));
338                    if (t== 3) ID_ROOT_L2        = (UInt_t)atoll(Row->GetField(t));
339                    if (t== 4) RUNHEADER_TIME    = (UInt_t)atoll(Row->GetField(t));
340                    if (t== 5) RUNTRAILER_TIME   = (UInt_t)atoll(Row->GetField(t));
341                    if (t== 6) RUNHEADER_OBT     = (UInt_t)atoll(Row->GetField(t));
342                    if (t== 7) RUNTRAILER_OBT    = (UInt_t)atoll(Row->GetField(t));
343                    if (t== 8) RUNHEADER_PKT     = (UInt_t)atoll(Row->GetField(t));
344                    if (t== 9) RUNTRAILER_PKT    = (UInt_t)atoll(Row->GetField(t));
345                    if (t==10) BOOT_NUMBER       = (UInt_t)atoll(Row->GetField(t));
346                    if (t==11) EV_FROM           = (UInt_t)atoll(Row->GetField(t));
347                    if (t==12) EV_TO             = (UInt_t)atoll(Row->GetField(t));
348                    if (t==13) NEVENTS           = (UInt_t)atoll(Row->GetField(t));
349                    if (t==14) PKT_COUNTER       = (UInt_t)atoll(Row->GetField(t));
350                    if (t==15) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t));
351                    if (t==16) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t));
352                    if (t==17) FAV_WRK_SCHEDULE  = (UInt_t)atoll(Row->GetField(t));
353                    if (t==18) EFF_WRK_SCHEDULE  = (UInt_t)atoll(Row->GetField(t));
354                    if (t==19) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t));
355                    if (t==20) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t));
356                    if (t==21) ACQ_BUILD_INFO    = (UInt_t)atoll(Row->GetField(t));
357                    if (t==22) ACQ_VAR_INFO      = (UInt_t)atoll(Row->GetField(t));
358                    if (t==23) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t));
359                    if (t==24) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t));
360                    if (t==25) TRK_CALIB_USED    = (UInt_t)atoll(Row->GetField(t));
361                    if (t==26) CAL_DSP_MASK      = (UInt_t)atoll(Row->GetField(t));
362                    if (t==27) LAST_TIMESYNC     = (UInt_t)atoll(Row->GetField(t));
363                    if (t==28) OBT_TIMESYNC      = (UInt_t)atoll(Row->GetField(t));
364                    if (t==29) VALIDATION        = (UInt_t)atoll(Row->GetField(t));
365            };
366    
367    }
368    
369    
370  /**  /**
371   * Function to fill the GL_RUN  table of the DB.   * Function to fill the GL_RUN  table of the DB.
# Line 547  Int_t GL_RUN::Query_GL_RUN(UInt_t run, T Line 586  Int_t GL_RUN::Query_GL_RUN(UInt_t run, T
586    for( r=0; r < 1000; r++){    for( r=0; r < 1000; r++){
587        Row = pResult->Next();              Row = pResult->Next();      
588        if( Row == NULL ) break;        if( Row == NULL ) break;
589    //        Set_GL_RUN(Row);
590        for( t = 0; t < pResult->GetFieldCount(); t++){        for( t = 0; t < pResult->GetFieldCount(); t++){
591            if (t== 0) ID                = (UInt_t)atoll(Row->GetField(t));                    if (t== 0) ID                = (UInt_t)atoll(Row->GetField(t));
592            if (t== 1) ID_RUN_FRAG       = (UInt_t)atoll(Row->GetField(t));                    if (t== 1) ID_RUN_FRAG       = (UInt_t)atoll(Row->GetField(t));
593            if (t== 2) ID_ROOT_L0        = (UInt_t)atoll(Row->GetField(t));                    if (t== 2) ID_ROOT_L0        = (UInt_t)atoll(Row->GetField(t));
594            if (t== 3) ID_ROOT_L2        = (UInt_t)atoll(Row->GetField(t));                    if (t== 3) ID_ROOT_L2        = (UInt_t)atoll(Row->GetField(t));
595            if (t== 4) RUNHEADER_TIME    = (UInt_t)atoll(Row->GetField(t));                    if (t== 4) RUNHEADER_TIME    = (UInt_t)atoll(Row->GetField(t));
596            if (t== 5) RUNTRAILER_TIME   = (UInt_t)atoll(Row->GetField(t));                    if (t== 5) RUNTRAILER_TIME   = (UInt_t)atoll(Row->GetField(t));
597            if (t== 6) RUNHEADER_OBT     = (UInt_t)atoll(Row->GetField(t));                    if (t== 6) RUNHEADER_OBT     = (UInt_t)atoll(Row->GetField(t));
598            if (t== 7) RUNTRAILER_OBT    = (UInt_t)atoll(Row->GetField(t));                    if (t== 7) RUNTRAILER_OBT    = (UInt_t)atoll(Row->GetField(t));
599            if (t== 8) RUNHEADER_PKT     = (UInt_t)atoll(Row->GetField(t));                    if (t== 8) RUNHEADER_PKT     = (UInt_t)atoll(Row->GetField(t));
600            if (t== 9) RUNTRAILER_PKT    = (UInt_t)atoll(Row->GetField(t));                    if (t== 9) RUNTRAILER_PKT    = (UInt_t)atoll(Row->GetField(t));
601            if (t==10) EV_FROM           = (UInt_t)atoll(Row->GetField(t));                    if (t==10) EV_FROM           = (UInt_t)atoll(Row->GetField(t));
602            if (t==11) EV_TO             = (UInt_t)atoll(Row->GetField(t));                    if (t==11) EV_TO             = (UInt_t)atoll(Row->GetField(t));
603            if (t==12) NEVENTS           = (UInt_t)atoll(Row->GetField(t));                    if (t==12) NEVENTS           = (UInt_t)atoll(Row->GetField(t));
604            if (t==13) LAST_TIMESYNC     = (UInt_t)atoll(Row->GetField(t));                    if (t==13) LAST_TIMESYNC     = (UInt_t)atoll(Row->GetField(t));
605            if (t==14) OBT_TIMESYNC      = (UInt_t)atoll(Row->GetField(t));                    if (t==14) OBT_TIMESYNC      = (UInt_t)atoll(Row->GetField(t));
606            if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t));                    if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t));
607            if (t==16) FAV_WRK_SCHEDULE  = (UInt_t)atoll(Row->GetField(t));                    if (t==16) FAV_WRK_SCHEDULE  = (UInt_t)atoll(Row->GetField(t));
608            if (t==17) EFF_WRK_SCHEDULE  = (UInt_t)atoll(Row->GetField(t));                    if (t==17) EFF_WRK_SCHEDULE  = (UInt_t)atoll(Row->GetField(t));
609            if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t));                    if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t));
610            if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t));                    if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t));
611            if (t==20) ACQ_BUILD_INFO    = (UInt_t)atoll(Row->GetField(t));                    if (t==20) ACQ_BUILD_INFO    = (UInt_t)atoll(Row->GetField(t));
612            if (t==21) ACQ_VAR_INFO      = (UInt_t)atoll(Row->GetField(t));                    if (t==21) ACQ_VAR_INFO      = (UInt_t)atoll(Row->GetField(t));
613            if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t));                    if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t));
614            if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t));                    if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t));
615            if (t==24) PKT_COUNTER       = (UInt_t)atoll(Row->GetField(t));                    if (t==24) PKT_COUNTER       = (UInt_t)atoll(Row->GetField(t));
616            if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t));                    if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t));
617            if (t==26) TRK_CALIB_USED    = (UInt_t)atoll(Row->GetField(t));                    if (t==26) TRK_CALIB_USED    = (UInt_t)atoll(Row->GetField(t));
618            if (t==27) CAL_DSP_MASK      = (UInt_t)atoll(Row->GetField(t));                    if (t==27) CAL_DSP_MASK      = (UInt_t)atoll(Row->GetField(t));
619            if (t==28) BOOT_NUMBER       = (UInt_t)atoll(Row->GetField(t));                    if (t==28) BOOT_NUMBER       = (UInt_t)atoll(Row->GetField(t));
620            if (t==29) VALIDATION        = (UInt_t)atoll(Row->GetField(t));                    if (t==29) VALIDATION        = (UInt_t)atoll(Row->GetField(t));
621        };        };
622    };    };
623    //  delete pResult;    //  delete pResult;
# Line 721  Int_t GL_ROOT::Query_GL_ROOT(UInt_t id, Line 761  Int_t GL_ROOT::Query_GL_ROOT(UInt_t id,
761   * Function to query the GL_TRK_CALIB table of the DB.   * Function to query the GL_TRK_CALIB table of the DB.
762   *   *
763   * \param  run starting time   * \param  run starting time
764     * \param  dbc DB server
765   * \return struct of type GL_TRK_CALIB_data, which stores the query result   * \return struct of type GL_TRK_CALIB_data, which stores the query result
766   */   */
767  Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(UInt_t time, TSQLServer *dbc){  Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(UInt_t time, TSQLServer *dbc){
# Line 732  Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(U Line 773  Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(U
773    stringstream myquery;    stringstream myquery;
774    // ----------------    // ----------------
775    myquery.str("");    myquery.str("");
776    myquery << "select ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,OBT2,PKT1,PKT2 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;
777    myquery << " AND VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;";          myquery << " AND VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;";      
778    //  myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";          //  myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";      
779    pResult = dbc->Query(myquery.str().c_str());    pResult = dbc->Query(myquery.str().c_str());
# Line 744  Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(U Line 785  Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(U
785            stringstream row;            stringstream row;
786            row.str("");            row.str("");
787            row << "0" << Row->GetField(t); // add leading 0 since we have two fields that could be "null" and we want to avoid crashes due to atoll            row << "0" << Row->GetField(t); // add leading 0 since we have two fields that could be "null" and we want to avoid crashes due to atoll
788            if (t==0) ID               = (UInt_t)atoll(Row->GetField(t));            if (t==0) ID                = (UInt_t)atoll(Row->GetField(t));
789            if (t==1) ID_ROOT_L0  = (UInt_t)atoll(Row->GetField(t));            if (t==1) ID_ROOT_L0        = (UInt_t)atoll(Row->GetField(t));
790            if (t==2) EV_ROOT_CALIBTRK1 = (UInt_t)atoll(row.str().c_str());            if (t==2) EV_ROOT_CALIBTRK1 = (UInt_t)atoll(row.str().c_str());
791            if (t==3) EV_ROOT_CALIBTRK2 = (UInt_t)atoll(row.str().c_str());            if (t==3) EV_ROOT_CALIBTRK2 = (UInt_t)atoll(row.str().c_str());
792            if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t));            if (t==4) FROM_TIME         = (UInt_t)atoll(Row->GetField(t));
793            if (t==5) TO_TIME   = (UInt_t)atoll(Row->GetField(t));                          if (t==5) TO_TIME           = (UInt_t)atoll(Row->GetField(t));
794            //            //
795            if (t==6) OBT1   = (UInt_t)atoll(Row->GetField(t));                    if (t==6) OBT1              = (UInt_t)atoll(Row->GetField(t));
796            if (t==7) OBT2   = (UInt_t)atoll(Row->GetField(t));                    if (t==7) OBT2              = (UInt_t)atoll(Row->GetField(t));
797            if (t==8) PKT1   = (UInt_t)atoll(Row->GetField(t));                    if (t==8) PKT1              = (UInt_t)atoll(Row->GetField(t));
798            if (t==9) PKT2   = (UInt_t)atoll(Row->GetField(t));                    if (t==9) PKT2              = (UInt_t)atoll(Row->GetField(t));
799        };            if (t==10) BOOT_NUMBER      = (UInt_t)atoll(Row->GetField(t));
800              if (t==11) VALIDATION       = (UInt_t)atoll(Row->GetField(t));
801              };
802    };    };
803    delete pResult;        delete pResult;
804      //
805    //  if ( TO_TIME < time ) return(51);
806    //    //
   if(TO_TIME < time)return(51);  
807    if ( (!OBT1 && !PKT1 ) || (!OBT2 && !PKT2) ) return(52); // ONE CALIBRATION PACKET IS MISSING!    if ( (!OBT1 && !PKT1 ) || (!OBT2 && !PKT2) ) return(52); // ONE CALIBRATION PACKET IS MISSING!
808    //    //
809    return 0;    return 0;
# Line 1070  UInt_t GL_TIMESYNC::DBpkt(UInt_t pkt_num Line 1114  UInt_t GL_TIMESYNC::DBpkt(UInt_t pkt_num
1114   * @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK   * @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK
1115   *   *
1116   */   */
1117  TString GL_TIMESYNC::ConvertTime(TString tzone, UInt_t dbt){  TString GL_TIMESYNC::ConvertTime(TString &tzone, UInt_t dbt){
1118    //    //
1119    TDatime *time = new TDatime();    TDatime *time = new TDatime();
1120    TString rtime;    TString rtime;
1121      Bool_t found = false;
1122    //    //
1123    time->Set(dbt,false); // MSK = Moscow Winter Time    time->Set(dbt,false); // MSK = Moscow Winter Time
1124    //    //
# Line 1081  TString GL_TIMESYNC::ConvertTime(TString Line 1126  TString GL_TIMESYNC::ConvertTime(TString
1126      //      //
1127      UInt_t timeUTC = time->Convert() - 60*60*3; // UTC (Coordinated Universal Time) = Moscow Winter Time - 3 hs      UInt_t timeUTC = time->Convert() - 60*60*3; // UTC (Coordinated Universal Time) = Moscow Winter Time - 3 hs
1128      time->Set(timeUTC,false);      time->Set(timeUTC,false);
1129        found = true;
1130      //      //
1131    };    };
1132    //    //
# Line 1088  TString GL_TIMESYNC::ConvertTime(TString Line 1134  TString GL_TIMESYNC::ConvertTime(TString
1134      //      //
1135      UInt_t timeCET = time->Convert() - 60*60*2; // CET (Central European Time) = Moscow Winter Time - 2 hs      UInt_t timeCET = time->Convert() - 60*60*2; // CET (Central European Time) = Moscow Winter Time - 2 hs
1136      time->Set(timeCET,false);      time->Set(timeCET,false);
1137        found = true;
1138      //      //
1139    };    };
1140    //    //
# Line 1095  TString GL_TIMESYNC::ConvertTime(TString Line 1142  TString GL_TIMESYNC::ConvertTime(TString
1142      //      //
1143      UInt_t timeCEST = time->Convert() - 60*60*1; // CEST (Central European Summer Time) = Moscow Winter Time - 1 h      UInt_t timeCEST = time->Convert() - 60*60*1; // CEST (Central European Summer Time) = Moscow Winter Time - 1 h
1144      time->Set(timeCEST,false);      time->Set(timeCEST,false);
1145        found = true;
1146      //      //
1147    };    };
1148    //    //
# Line 1102  TString GL_TIMESYNC::ConvertTime(TString Line 1150  TString GL_TIMESYNC::ConvertTime(TString
1150      //      //
1151      UInt_t timeMSD = time->Convert() + 60*60*1; // MSD (Moscow Summer Time) = Moscow Winter Time + 1 h      UInt_t timeMSD = time->Convert() + 60*60*1; // MSD (Moscow Summer Time) = Moscow Winter Time + 1 h
1152      time->Set(timeMSD,false);      time->Set(timeMSD,false);
1153        found = true;
1154      //      //
1155    };    };
1156    //    //
1157      if ( !found && strcmp(tzone.Data(),"MSK") && strcmp(tzone.Data(),"") ){
1158        printf("\n Unknown time zone %s using MSK \n",tzone.Data());
1159        tzone = "MSK";
1160      };
1161      //
1162    rtime = time->AsSQLString();    rtime = time->AsSQLString();
1163    //    //
1164    return(rtime);    return(rtime);
# Line 1118  TString GL_TIMESYNC::ConvertTime(TString Line 1172  TString GL_TIMESYNC::ConvertTime(TString
1172   * @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK   * @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK
1173   *   *
1174   */   */
1175  TString GL_TIMESYNC::UnConvertTime(TString tzone, UInt_t dbt){  TString GL_TIMESYNC::UnConvertTime(TString &tzone, UInt_t dbt){
1176    //    //
1177    TDatime *time = new TDatime();    TDatime *time = new TDatime();
1178    TString rtime;    TString rtime;
1179    //    //
1180      Bool_t found = false;
1181      //
1182    time->Set(dbt,false); // MSK = Moscow Winter Time    time->Set(dbt,false); // MSK = Moscow Winter Time
1183    //    //
1184    if ( !strcmp(tzone.Data(),"UTC") || !strcmp(tzone.Data(),"GMT") ){    if ( !strcmp(tzone.Data(),"UTC") || !strcmp(tzone.Data(),"GMT") ){
1185      //      //
1186      UInt_t timeUTC = time->Convert() + 60*60*3; // UTC (Coordinated Universal Time) +3 hs = Moscow Winter Time      UInt_t timeUTC = time->Convert() + 60*60*3; // UTC (Coordinated Universal Time) +3 hs = Moscow Winter Time
1187      time->Set(timeUTC,false);      time->Set(timeUTC,false);
1188        found = true;
1189      //      //
1190    };    };
1191    //    //
# Line 1136  TString GL_TIMESYNC::UnConvertTime(TStri Line 1193  TString GL_TIMESYNC::UnConvertTime(TStri
1193      //      //
1194      UInt_t timeCET = time->Convert() + 60*60*2; // CET (Central European Time) + 2 hs = Moscow Winter Time        UInt_t timeCET = time->Convert() + 60*60*2; // CET (Central European Time) + 2 hs = Moscow Winter Time  
1195      time->Set(timeCET,false);      time->Set(timeCET,false);
1196        found = true;
1197      //      //
1198    };    };
1199    //    //
# Line 1143  TString GL_TIMESYNC::UnConvertTime(TStri Line 1201  TString GL_TIMESYNC::UnConvertTime(TStri
1201      //      //
1202      UInt_t timeCEST = time->Convert() + 60*60*1; // CEST (Central European Summer Time) + 1 h = Moscow Winter Time      UInt_t timeCEST = time->Convert() + 60*60*1; // CEST (Central European Summer Time) + 1 h = Moscow Winter Time
1203      time->Set(timeCEST,false);      time->Set(timeCEST,false);
1204        found = true;
1205      //      //
1206    };    };
1207    //    //
1208    if ( !strcmp(tzone.Data(),"MSD") ){    if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST") ){
1209      //      //
1210      UInt_t timeMSD = time->Convert() - 60*60*1; // MSD (Moscow Summer Time) - 1 h = Moscow Winter Time      UInt_t timeMSD = time->Convert() - 60*60*1; // MSD (Moscow Summer Time) - 1 h = Moscow Winter Time
1211      time->Set(timeMSD,false);      time->Set(timeMSD,false);
1212        found = true;
1213        //
1214      };
1215      //
1216      if ( !found && strcmp(tzone.Data(),"MSK") && strcmp(tzone.Data(),"") ){
1217      //      //
1218        printf("\n Unknown time zone %s using MSK \n",tzone.Data());
1219        tzone = "MSK";
1220    };    };
1221    //    //
1222    rtime = time->AsSQLString();    rtime = time->AsSQLString();

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.23