]>
Commit | Line | Data |
---|---|---|
939ae4b2 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | ||
939ae4b2 | 17 | /// |
00e86732 | 18 | /// \class AliMUONPayloadTracker |
939ae4b2 | 19 | /// Decodes rawdata from buffer and stores in TClonesArray. |
939ae4b2 | 20 | /// First version implement for Tracker |
21 | /// | |
00e86732 | 22 | /// \author Christian Finck |
939ae4b2 | 23 | |
24 | #include "AliMUONPayloadTracker.h" | |
25 | ||
26 | #include "AliRawReader.h" | |
27 | #include "AliRawDataHeader.h" | |
77a606e8 | 28 | |
29 | #ifndef DATE_SYS | |
939ae4b2 | 30 | #include "AliLog.h" |
77a606e8 | 31 | #endif |
939ae4b2 | 32 | |
33 | #include "AliMUONDspHeader.h" | |
34 | #include "AliMUONBlockHeader.h" | |
35 | #include "AliMUONBusStruct.h" | |
36 | #include "AliMUONDDLTracker.h" | |
37 | ||
00e86732 | 38 | /// \cond CLASSIMP |
939ae4b2 | 39 | ClassImp(AliMUONPayloadTracker) |
00e86732 | 40 | /// \endcond |
939ae4b2 | 41 | |
42 | AliMUONPayloadTracker::AliMUONPayloadTracker() | |
43 | : TObject(), | |
9f5dcca3 | 44 | fBusPatchId(0), |
45 | fDspId(0), | |
46 | fBlkId(0), | |
47 | fMaxDDL(20), | |
939ae4b2 | 48 | fMaxBlock(2), |
49 | fMaxDsp(5), | |
9f5dcca3 | 50 | fMaxBus(5), |
51 | fDDLTracker(new AliMUONDDLTracker()), | |
52 | fBusStruct(new AliMUONBusStruct()), | |
53 | fBlockHeader(new AliMUONBlockHeader()), | |
54 | fDspHeader(new AliMUONDspHeader()) | |
939ae4b2 | 55 | { |
56 | // | |
84ceeb06 | 57 | // create an object to decode MUON payload |
939ae4b2 | 58 | // |
939ae4b2 | 59 | |
939ae4b2 | 60 | } |
61 | ||
939ae4b2 | 62 | //___________________________________ |
63 | AliMUONPayloadTracker::~AliMUONPayloadTracker() | |
64 | { | |
65 | // | |
66 | // clean up | |
67 | // | |
939ae4b2 | 68 | delete fDDLTracker; |
69 | delete fBusStruct; | |
70 | delete fBlockHeader; | |
71 | delete fDspHeader; | |
72 | } | |
73 | ||
74 | //______________________________________________________ | |
84ceeb06 | 75 | Bool_t AliMUONPayloadTracker::Decode(UInt_t* buffer, Int_t totalDDLSize) |
939ae4b2 | 76 | { |
84ceeb06 | 77 | |
78 | // Each DDL is made with 2 Blocks each of which consists of 5 DSP's at most | |
79 | // and each of DSP has at most 5 buspatches. | |
80 | // The different structures, Block (CRT), DSP (FRT) and Buspatch, | |
81 | // are identified by a key word 0xFC0000FC, 0xF000000F and 0xB000000B respectively. | |
82 | // (fBusPatchManager no more needed !) | |
939ae4b2 | 83 | |
84 | ||
85 | //Read Header Size of DDL,Block,DSP and BusPatch | |
8ecc5cf0 | 86 | static Int_t kBlockHeaderSize = fBlockHeader->GetHeaderLength(); |
87 | static Int_t kDspHeaderSize = fDspHeader->GetHeaderLength(); | |
88 | static Int_t kBusPatchHeaderSize = fBusStruct->GetHeaderLength(); | |
939ae4b2 | 89 | |
84ceeb06 | 90 | // size structures |
939ae4b2 | 91 | Int_t totalBlockSize; |
92 | Int_t totalDspSize; | |
93 | Int_t totalBusPatchSize; | |
94 | Int_t dataSize; | |
84ceeb06 | 95 | Int_t bufSize; |
939ae4b2 | 96 | |
84ceeb06 | 97 | // indexes |
98 | Int_t indexBlk; | |
99 | Int_t indexDsp; | |
100 | Int_t indexBusPatch; | |
101 | Int_t index = 0; | |
102 | Int_t iBlock = 0; | |
939ae4b2 | 103 | |
84ceeb06 | 104 | // CROCUS CRT |
105 | while (buffer[index] == fBlockHeader->GetDefaultDataKey()) { | |
939ae4b2 | 106 | |
84ceeb06 | 107 | if (iBlock > fMaxBlock) break; |
108 | ||
109 | // copy within padding words | |
110 | memcpy(fBlockHeader->GetHeader(),&buffer[index], (kBlockHeaderSize)*4); | |
939ae4b2 | 111 | |
84ceeb06 | 112 | totalBlockSize = fBlockHeader->GetTotalLength(); |
939ae4b2 | 113 | |
84ceeb06 | 114 | indexBlk = index; |
115 | index += kBlockHeaderSize; | |
939ae4b2 | 116 | |
84ceeb06 | 117 | // copy in TClonesArray |
118 | fDDLTracker->AddBlkHeader(*fBlockHeader); | |
939ae4b2 | 119 | |
84ceeb06 | 120 | // Crocus FRT |
121 | Int_t iDsp = 0; | |
122 | while (buffer[index] == fDspHeader->GetDefaultDataKey()) { | |
939ae4b2 | 123 | |
84ceeb06 | 124 | if (iDsp > fMaxDsp) break; // if ever... |
125 | ||
126 | memcpy(fDspHeader->GetHeader(),&buffer[index], kDspHeaderSize*4); | |
939ae4b2 | 127 | |
84ceeb06 | 128 | totalDspSize = fDspHeader->GetTotalLength(); |
129 | indexDsp = index; | |
130 | index += kDspHeaderSize; | |
939ae4b2 | 131 | |
86400e61 | 132 | // if (fDspHeader->GetPaddingWord() != fDspHeader->GetDefaultPaddingWord()) { |
133 | // // copy the field of Padding word into ErrorWord field | |
134 | // fDspHeader->SetErrorWord(fDspHeader->GetPaddingWord()); | |
135 | // index--; | |
136 | // } | |
939ae4b2 | 137 | |
84ceeb06 | 138 | // copy in TClonesArray |
139 | fDDLTracker->AddDspHeader(*fDspHeader, iBlock); | |
939ae4b2 | 140 | |
84ceeb06 | 141 | // buspatch structure |
142 | Int_t iBusPatch = 0; | |
143 | while (buffer[index] == fBusStruct->GetDefaultDataKey()) { | |
939ae4b2 | 144 | |
84ceeb06 | 145 | if (iBusPatch > fMaxBus) break; // if ever |
146 | ||
147 | //copy buffer into header structure | |
148 | memcpy(fBusStruct->GetHeader(), &buffer[index], kBusPatchHeaderSize*4); | |
939ae4b2 | 149 | |
84ceeb06 | 150 | totalBusPatchSize = fBusStruct->GetTotalLength(); |
151 | indexBusPatch = index; | |
939ae4b2 | 152 | |
84ceeb06 | 153 | //Check Buspatch header, not empty events |
154 | if(totalBusPatchSize > kBusPatchHeaderSize) { | |
155 | ||
156 | index += kBusPatchHeaderSize; | |
157 | dataSize = fBusStruct->GetLength(); | |
158 | bufSize = fBusStruct->GetBufSize(); | |
159 | ||
160 | if(dataSize > 0) { // check data present | |
161 | if (dataSize > bufSize) // check buffer size | |
162 | fBusStruct->SetAlloc(dataSize); | |
163 | ||
164 | //copy buffer into data structure | |
165 | memcpy(fBusStruct->GetData(), &buffer[index], dataSize*4); | |
166 | fBusStruct->SetBlockId(iBlock); // could be usefull in future applications ? | |
167 | fBusStruct->SetDspId(iDsp); | |
168 | ||
6dee95a7 | 169 | // check parity |
170 | CheckDataParity(); | |
171 | ||
84ceeb06 | 172 | // copy in TClonesArray |
173 | fDDLTracker->AddBusPatch(*fBusStruct, iBlock, iDsp); | |
174 | ||
175 | } // dataSize test | |
176 | ||
177 | } // testing buspatch | |
178 | ||
179 | index = indexBusPatch + totalBusPatchSize; | |
180 | if (index >= totalDDLSize) {// check the end of DDL | |
181 | index = totalDDLSize - 1; // point to the last element of buffer | |
182 | break; | |
183 | } | |
184 | iBusPatch++; | |
185 | } // buspatch loop | |
86400e61 | 186 | |
187 | // skipping additionnal word if padding | |
188 | if (fDspHeader->GetPaddingWord() == 1) { | |
189 | if (buffer[index++] != fDspHeader->GetDefaultPaddingWord()) | |
77a606e8 | 190 | |
191 | #ifndef DATE_SYS | |
86400e61 | 192 | AliWarning(Form("Error in padding word for iBlock %d, iDsp %d, iBus %d\n", |
193 | iBlock, iDsp, iBusPatch)); | |
77a606e8 | 194 | #else |
195 | printf("Error in padding word for iBlock %d, iDsp %d, iBus %d\n", iBlock, iDsp, iBusPatch); | |
196 | #endif | |
86400e61 | 197 | } |
198 | ||
84ceeb06 | 199 | index = indexDsp + totalDspSize; |
200 | if (index >= totalDDLSize) { | |
201 | index = totalDDLSize - 1; | |
202 | break; | |
203 | } | |
204 | iDsp++; | |
205 | } // dsp loop | |
206 | ||
207 | index = indexBlk + totalBlockSize; | |
208 | if (index >= totalDDLSize) { | |
209 | index = totalDDLSize - 1; | |
210 | break; | |
211 | } | |
212 | iBlock++; | |
213 | } // block loop | |
939ae4b2 | 214 | |
215 | return kTRUE; | |
216 | } | |
217 | ||
218 | //______________________________________________________ | |
219 | void AliMUONPayloadTracker::ResetDDL() | |
220 | { | |
221 | // reseting TClonesArray | |
222 | // after each DDL | |
223 | // | |
224 | fDDLTracker->GetBlkHeaderArray()->Delete(); | |
225 | } | |
226 | ||
227 | //______________________________________________________ | |
228 | void AliMUONPayloadTracker::SetMaxBlock(Int_t blk) | |
229 | { | |
230 | // set regional card number | |
231 | if (blk > 2) blk = 2; | |
232 | fMaxBlock = blk; | |
233 | } | |
607fb67b | 234 | |
6dee95a7 | 235 | //______________________________________________________ |
607fb67b | 236 | Bool_t AliMUONPayloadTracker::CheckDataParity() |
237 | { | |
238 | // parity check | |
239 | // taken from MuTrkBusPatch.cxx (sotfware test for CROCUS) | |
240 | // A. Baldisseri | |
241 | ||
6dee95a7 | 242 | Int_t parity; |
607fb67b | 243 | UInt_t data; |
244 | ||
245 | Int_t dataSize = fBusStruct->GetLength(); | |
246 | for (int idata = 0; idata < dataSize; idata++) { | |
247 | ||
248 | data = fBusStruct->GetData(idata); | |
607fb67b | 249 | |
6dee95a7 | 250 | // Compute the parity for each data word |
251 | parity = data & 0x1; | |
252 | for (Int_t i = 1; i <= 30; i++) | |
253 | parity ^= ((data >> i) & 0x1); | |
607fb67b | 254 | |
255 | // Check | |
256 | if (parity != fBusStruct->GetParity(idata)) { | |
77a606e8 | 257 | #ifndef DATE_SYS |
607fb67b | 258 | AliWarning(Form("Parity error in word %d for manuId %d and channel %d\n", |
259 | idata, fBusStruct->GetManuId(idata), fBusStruct->GetChannelId(idata))); | |
77a606e8 | 260 | #else |
261 | printf("Parity error in word %d for manuId %d and channel %d\n", | |
262 | idata, fBusStruct->GetManuId(idata), fBusStruct->GetChannelId(idata)); | |
263 | #endif | |
264 | ||
607fb67b | 265 | return kFALSE; |
266 | ||
267 | } | |
268 | } | |
269 | return kTRUE; | |
270 | } |