/[PAMELA software]/chewbacca/PamOffLineSW/PamOffLineSW_Main.cpp
ViewVC logotype

Diff of /chewbacca/PamOffLineSW/PamOffLineSW_Main.cpp

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

revision 1.9 by mocchiut, Tue Feb 2 15:26:09 2010 UTC revision 1.13 by mocchiut, Fri Feb 12 12:45:49 2010 UTC
# Line 1  Line 1 
1  //============================================================================  //============================================================================
2  // $Id: PamOffLineSW_Main.cpp,v 1.8 2009/12/24 10:31:13 mocchiut Exp $  // $Id: PamOffLineSW_Main.cpp,v 1.12 2010/02/12 05:22:04 mocchiut Exp $
3  // Description : Pamela Off-Line Software  // Description : Pamela Off-Line Software
4  //============================================================================  //============================================================================
5    
# Line 61  int old_route = 999; Line 61  int old_route = 999;
61    
62  Long64_t filelength = 0LL;  Long64_t filelength = 0LL;
63  Long64_t streamposi = 0LL;  Long64_t streamposi = 0LL;
64    Long64_t streamposisaved = 0LL;
65    Long64_t streamposiorig = 0LL;
66    Int_t numposi = 10;
67  Long64_t downcount = 1LL;  Long64_t downcount = 1LL;
68  TArrayL64 *dwin=new TArrayL64(12);  TArrayL64 *dwin=new TArrayL64(12);
69  Long64_t cadcount = 0LL;  Long64_t cadcount = 0LL;
70    Int_t horrorcount = 0;
71    Int_t hc = 0;
72    
73  bool skip_cadre = false;  bool skip_cadre = false;
74  long int iNumGoodCadres=0; //total number of good cadres  long int iNumGoodCadres=0; //total number of good cadres
# Line 902  void mainRead_RealData(char fni[]) Line 907  void mainRead_RealData(char fni[])
907           {                         {              
908                  isCadreGood = true;                              isCadreGood = true;            
909                  //start reading the file                  //start reading the file
910                    streamposi = (Long64_t)fin.tellg(); // stream position in the file before reading the vrl header
911                    if ( iNumCadres > 9 && numposi > 9 ){
912                            streamposisaved = streamposi;
913                            numposi = 0;                    
914                    };
915                    numposi++;
916                    //
917                  fin.read(ccHeader_VRL, LENGTH_HEADER_VRL);                                fin.read(ccHeader_VRL, LENGTH_HEADER_VRL);              
918                  streamposi = (Long64_t)fin.tellg(); // stream position in the file                  //              printf(" position in file is %llu \n",streamposi);
919                  //              printf(" position in file is %i \n",streamposi);                  stringstream ss;
920                    ss.str() = "";
921                    ss << " position in file is "<<streamposi;
922                    string sms = ss.str();
923                    //              mainLogUtil->logError(sms);
924                    //
925                  if (!fin.good())                  if (!fin.good())
926                  {                        {      
927                          //TODO: check here                          //TODO: check here
# Line 933  void mainRead_RealData(char fni[]) Line 949  void mainRead_RealData(char fni[])
949                          " This error occurred after byte: "<<iByte_tot<<" ... use the data carefully";                          " This error occurred after byte: "<<iByte_tot<<" ... use the data carefully";
950                          string msg = oss.str();                          string msg = oss.str();
951                          mainLogUtil->logWarning(msg);                          mainLogUtil->logWarning(msg);
952                            //                      printf(" streamposi %llu \n",streamposi);
953                  }                  }
954                                    
955                    //
956                    // we completely missed more than 10 VRL packets
957                    //
958                    if (  hc == 1100 ){
959                      fin.seekg(streamposiorig);
960                      stringstream os;                                              
961                      os<<" NEW (EM) UN-RECOVERABLE SYNC WITH VRL HEADERS, SIG! ";
962                      os<<" new position in file, go back to "<<streamposiorig;
963                      string ms = os.str();
964                      mainLogUtil->logAll(ms);
965                      hc++;
966                      continue;
967                    };
968                    if ( horrorcount > 10 && hc < 1100 ){
969                      hc++;
970                      //if ( horrorcount > 1 ){
971                      stringstream os;                                              
972                      os<<" NEW (EM) THIS IS TOO MUCH, LOST SYNC WITH VRL HEADERS! try to recover horrorcount = "<<horrorcount;
973                      os<<" new position in file "<<(streamposi-(10LL*1024LL)+1LL);
974                      //              os<<" new position in file "<<(streamposi-(1LL*1024LL)+1LL);
975                      string ms = os.str();
976                      mainLogUtil->logAll(ms);
977                      //              printf(" fin.(streamposi-10*1025-7) %llu \n",streamposi-(10LL*1025LL)-7LL);
978                      if ( (streamposi-(10LL*1024LL)+1LL) < streamposisaved ){
979                              fin.seekg(streamposisaved+1LL);
980                              stringstream oss;
981                            oss<<" Problems repositioning stream reader... streamposisaved "<<streamposisaved;
982                            string msg = oss.str();
983                            mainLogUtil->logWarning(msg);
984    
985                      } else {
986                              fin.seekg(streamposi-(10LL*1024LL)+1LL);
987                      };
988                      //              fin.seekg(streamposi-(1LL*1024LL)+1LL);
989                      horrorcount = 0;
990                      continue;
991                    };
992    
993    
994                  //we have read and analysed the header VRL of this cadre                  //we have read and analysed the header VRL of this cadre
995                  iByte_tot+=fin.gcount();                  iByte_tot+=fin.gcount();
996                                    
# Line 1106  bool VRL_Header_Check(char* headVRL, int Line 1162  bool VRL_Header_Check(char* headVRL, int
1162                  " This error occurred after byte: "<<iByte_tot<<" ... Route number unused= "<<(int)headVRL[3]<<" Resetting ROUTE to old value = "<<old_route<<" (download="<<download<<")";                  " This error occurred after byte: "<<iByte_tot<<" ... Route number unused= "<<(int)headVRL[3]<<" Resetting ROUTE to old value = "<<old_route<<" (download="<<download<<")";
1163                  string msg = oss.str();                  string msg = oss.str();
1164                  mainLogUtil->logAll(msg);                  mainLogUtil->logAll(msg);
1165    
1166                    if ( ((int)(unsigned char)headVRL[0]!=CODE_FF)&&((int)(unsigned char)headVRL[1]!=CODE_46)&& ((int)(unsigned char)headVRL[2]!=CODE_D5) ){
1167                      stringstream os;                                              
1168                      os<<" Horror movie, the cadre does not start with FF 46 D5 at all! "<<
1169                        " This error occurred after byte: "<<iByte_tot<<" ... Route number unused= "<<(int)headVRL[3]<<" Resetting ROUTE to old value = "<<old_route<<" (download="<<download<<")";
1170                      string ms = os.str();
1171                      mainLogUtil->logAll(ms);
1172                      if ( !hc && !horrorcount ) streamposiorig = streamposi;
1173                      horrorcount++;
1174                    };
1175    
1176                  return false;                  return false;
1177          }          }
1178    
1179            horrorcount = 0;
1180    
1181          // EM qui condizione su posizione file          // EM qui condizione su posizione file
1182          Bool_t downchangeallowed = false;                Bool_t downchangeallowed = false;      
1183          for (Int_t ee=0; ee<(-1+2+2*downcount); ee+=2){          for (Int_t ee=0; ee<(-1+2+2*downcount); ee+=2){

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.23