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