00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #include "L3_Banks.hh"
00046 #include <assert.h>
00047
00048 using namespace OLDEVP;
00049
00050 int Bank_L3_SUMD::swap()
00051 {
00052
00053 int words = header.BankLength;
00054 int iret = swap_raw(header.ByteOrder,&words,1);
00055
00056
00057 if(!iret) return(0);
00058
00059 if(iret < 0) return iret;
00060
00061
00062 iret = swap_raw(header.ByteOrder, (INT32 *)&nProcessed, 3);
00063 assert(iret > 0);
00064
00065
00066 for (int i=0; i<nAlg; i++) {
00067 iret = swap_raw(header.ByteOrder, (INT32 *)&alg[i].algId, 1);
00068 iret = swap_raw(header.ByteOrder, (INT32 *)&alg[i].nProcessed, 13);
00069 }
00070
00071
00072 iret = header.swap();
00073
00074 return iret;
00075 }
00076
00077
00078 int Bank_L3_GTD::swap()
00079 {
00080
00081 int words = header.BankLength;
00082 int iret = swap_raw(header.ByteOrder,&words,1);
00083
00084
00085 if(!iret) return(0);
00086
00087 if(iret < 0) return iret;
00088
00089
00090 iret = swap_raw(header.ByteOrder, (INT32 *)&nHits, 5);
00091 assert(iret > 0);
00092
00093
00094 for (unsigned int i=0; i<nTracks; i++) {
00095 iret = swap_raw(header.ByteOrder, (int *)&track[i].id, 1);
00096 iret = l3Swap_short((short *)&track[i].flag, (short) 1);
00097 iret = swap_raw(header.ByteOrder, (int *)&track[i].chi2, 13);
00098 }
00099
00100
00101 iret = header.swap();
00102
00103 return iret;
00104 }
00105
00106
00107 int Bank_L3_LTD::swap()
00108 {
00109
00110 int words = header.BankLength;
00111 int iret = swap_raw(header.ByteOrder,&words,1);
00112
00113
00114 if(!iret) return(0);
00115
00116 if(iret < 0) return iret;
00117
00118 int nTracks = (int) (words * 4 - sizeof(Bank_Header)) / sizeof(localTrack);
00119
00120
00121 for (int i=0; i<nTracks; i++) {
00122 iret = l3Swap_short((short *)&track[i].id, 1);
00123 iret = l3Swap_short((short *)&track[i].innerMostRow, (short) 4);
00124 iret = swap_raw(header.ByteOrder, (INT32 *)&track[i].dedx, 8);
00125 iret = l3Swap_short((short *)&track[i].dpt, 4);
00126 }
00127
00128
00129 iret = header.swap();
00130
00131 return iret;
00132 }
00133
00134
00135 int Bank_L3_SECCD::swap()
00136 {
00137
00138 int words = header.BankLength;
00139 int iret = swap_raw(header.ByteOrder,&words,1);
00140
00141
00142 if(!iret) return(0);
00143
00144 if(iret < 0) return iret;
00145
00146
00147 iret = swap_raw(header.ByteOrder, (INT32 *)&nrClusters_in_sector, 1);
00148 assert(iret > 0);
00149
00150
00151 for (unsigned int i=0; i<nrClusters_in_sector; i++) {
00152 iret = l3Swap_short((short *)&cluster[i].pad, (short) 5);
00153 }
00154
00155
00156 iret = header.swap();
00157
00158 return iret;
00159 }
00160
00161
00162
00163 int Bank_TPCMZCLD::swap()
00164 {
00165 int iret = swap_raw(header.ByteOrder, &numberOfRows, 1);
00166 if(iret <= 0) return iret;
00167
00168 int nsp = 0;
00169 int *word = &numberOfRows;
00170 word++;
00171 for (int i=0; i<numberOfRows; i++) {
00172 swap_raw(header.ByteOrder, word, 2);
00173 nsp = word[1];
00174 word += 2;
00175 swap_short(header.ByteOrder, word, 2*nsp);
00176 word += 2 * nsp;
00177 }
00178
00179 return header.swap();
00180 }
00181
00182
00183
00184 int l3Swap_short (short* data, short size)
00185 {
00186 char *curr = (char *)data;
00187 for (int i=0; i<size; i++) {
00188 char temp = curr[0];
00189 curr[0] = curr[1];
00190 curr[1] = temp;
00191 curr += 2;
00192 }
00193 return 1;
00194 };