1 |
//============================================================================ |
//============================================================================ |
2 |
// $Id: PamOffLineSW_Main.cpp,v 1.8 2009/12/24 10:31:13 mocchiut Exp $ |
// $Id: PamOffLineSW_Main.cpp,v 1.10 2010/02/11 09:02:10 mocchiut Exp $ |
3 |
// Description : Pamela Off-Line Software |
// Description : Pamela Off-Line Software |
4 |
//============================================================================ |
//============================================================================ |
5 |
|
|
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 |
|
Int_t numposi = 10; |
66 |
Long64_t downcount = 1LL; |
Long64_t downcount = 1LL; |
67 |
TArrayL64 *dwin=new TArrayL64(12); |
TArrayL64 *dwin=new TArrayL64(12); |
68 |
Long64_t cadcount = 0LL; |
Long64_t cadcount = 0LL; |
69 |
|
Int_t horrorcount = 0; |
70 |
|
Int_t hc = 0; |
71 |
|
|
72 |
bool skip_cadre = false; |
bool skip_cadre = false; |
73 |
long int iNumGoodCadres=0; //total number of good cadres |
long int iNumGoodCadres=0; //total number of good cadres |
906 |
{ |
{ |
907 |
isCadreGood = true; |
isCadreGood = true; |
908 |
//start reading the file |
//start reading the file |
909 |
|
streamposi = (Long64_t)fin.tellg(); // stream position in the file before reading the vrl header |
910 |
|
if ( iNumCadres > 9 && numposi > 9 ){ |
911 |
|
streamposisaved = streamposi; |
912 |
|
numposi = 0; |
913 |
|
}; |
914 |
|
numposi++; |
915 |
|
// |
916 |
fin.read(ccHeader_VRL, LENGTH_HEADER_VRL); |
fin.read(ccHeader_VRL, LENGTH_HEADER_VRL); |
917 |
streamposi = (Long64_t)fin.tellg(); // stream position in the file |
// printf(" position in file is %llu \n",streamposi); |
918 |
// printf(" position in file is %i \n",streamposi); |
stringstream ss; |
919 |
|
ss.str() = ""; |
920 |
|
ss << " position in file is "<<streamposi; |
921 |
|
string sms = ss.str(); |
922 |
|
// mainLogUtil->logError(sms); |
923 |
|
// |
924 |
if (!fin.good()) |
if (!fin.good()) |
925 |
{ |
{ |
926 |
//TODO: check here |
//TODO: check here |
948 |
" This error occurred after byte: "<<iByte_tot<<" ... use the data carefully"; |
" This error occurred after byte: "<<iByte_tot<<" ... use the data carefully"; |
949 |
string msg = oss.str(); |
string msg = oss.str(); |
950 |
mainLogUtil->logWarning(msg); |
mainLogUtil->logWarning(msg); |
951 |
|
// printf(" streamposi %llu \n",streamposi); |
952 |
} |
} |
953 |
|
|
954 |
|
// |
955 |
|
// we completely missed more than 10 VRL packets |
956 |
|
// |
957 |
|
if ( horrorcount > 10 && hc < 500 ){ |
958 |
|
hc++; |
959 |
|
//if ( horrorcount > 1 ){ |
960 |
|
stringstream os; |
961 |
|
os<<" NEW (EM) THIS IS TOO MUCH, LOST SYNC WITH VRL HEADERS! try to recover horrorcount = "<<horrorcount; |
962 |
|
os<<" new position in file "<<(streamposi-(10LL*1024LL)+1LL); |
963 |
|
// os<<" new position in file "<<(streamposi-(1LL*1024LL)+1LL); |
964 |
|
string ms = os.str(); |
965 |
|
mainLogUtil->logAll(ms); |
966 |
|
// printf(" fin.(streamposi-10*1025-7) %llu \n",streamposi-(10LL*1025LL)-7LL); |
967 |
|
if ( (streamposi-(10LL*1024LL)+1LL) < streamposisaved ){ |
968 |
|
fin.seekg(streamposisaved+1LL); |
969 |
|
stringstream oss; |
970 |
|
oss<<" Problems repositioning stream reader... streamposisaved "<<streamposisaved; |
971 |
|
string msg = oss.str(); |
972 |
|
mainLogUtil->logWarning(msg); |
973 |
|
|
974 |
|
} else { |
975 |
|
fin.seekg(streamposi-(10LL*1024LL)+1LL); |
976 |
|
}; |
977 |
|
// fin.seekg(streamposi-(1LL*1024LL)+1LL); |
978 |
|
horrorcount = 0; |
979 |
|
continue; |
980 |
|
}; |
981 |
|
|
982 |
|
|
983 |
//we have read and analysed the header VRL of this cadre |
//we have read and analysed the header VRL of this cadre |
984 |
iByte_tot+=fin.gcount(); |
iByte_tot+=fin.gcount(); |
985 |
|
|
1151 |
" 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<<")"; |
1152 |
string msg = oss.str(); |
string msg = oss.str(); |
1153 |
mainLogUtil->logAll(msg); |
mainLogUtil->logAll(msg); |
1154 |
|
|
1155 |
|
if ( ((int)(unsigned char)headVRL[0]!=CODE_FF)&&((int)(unsigned char)headVRL[1]!=CODE_46)&& ((int)(unsigned char)headVRL[2]!=CODE_D5) ){ |
1156 |
|
stringstream os; |
1157 |
|
os<<" Horror movie, the cadre does not start with FF 46 D5 at all! "<< |
1158 |
|
" This error occurred after byte: "<<iByte_tot<<" ... Route number unused= "<<(int)headVRL[3]<<" Resetting ROUTE to old value = "<<old_route<<" (download="<<download<<")"; |
1159 |
|
string ms = os.str(); |
1160 |
|
mainLogUtil->logAll(ms); |
1161 |
|
horrorcount++; |
1162 |
|
}; |
1163 |
|
|
1164 |
return false; |
return false; |
1165 |
} |
} |
1166 |
|
|
1167 |
|
horrorcount = 0; |
1168 |
|
|
1169 |
// EM qui condizione su posizione file |
// EM qui condizione su posizione file |
1170 |
Bool_t downchangeallowed = false; |
Bool_t downchangeallowed = false; |
1171 |
for (Int_t ee=0; ee<(-1+2+2*downcount); ee+=2){ |
for (Int_t ee=0; ee<(-1+2+2*downcount); ee+=2){ |