]>
Commit | Line | Data |
---|---|---|
c0751163 | 1 | /************************************************************************** |
33434f31 | 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 | **************************************************************************/ | |
c0751163 | 15 | |
c4ee792d | 16 | /* $Id $ */ |
17 | ||
c0751163 | 18 | |
19 | /////////////////////////////////////////////////////////////////////////////// | |
20 | /// | |
c4ee792d | 21 | /// \class AliMUONRawStreamTracker |
c0751163 | 22 | /// This class provides access to MUON digits in raw data. |
23 | /// | |
24 | /// It loops over all MUON digits in the raw data given by the AliRawReader. | |
25 | /// The Next method goes to the next digit. If there are no digits left | |
26 | /// it returns kFALSE (under develpment) | |
313a427d | 27 | /// It can loop also over DDL and store the decoded rawdata in TClonesArray |
28 | /// in Payload class. | |
c0751163 | 29 | /// |
30 | /// First version implement for Tracker | |
31 | /// | |
c4ee792d | 32 | /// \author Christian Finck |
c0751163 | 33 | /////////////////////////////////////////////////////////////////////////////// |
34 | ||
35 | #include "AliMUONRawStreamTracker.h" | |
36 | ||
37 | #include "AliRawReader.h" | |
38 | #include "AliRawDataHeader.h" | |
9e378ff4 | 39 | #include "AliDAQ.h" |
c0751163 | 40 | #include "AliLog.h" |
33434f31 | 41 | #include "AliMUONPayloadTracker.h" |
42 | #include "AliMUONBlockHeader.h" | |
43 | #include "AliMUONDspHeader.h" | |
44 | #include "AliMUONBusStruct.h" | |
45 | #include "AliMUONDDLTracker.h" | |
46 | #include "Riostream.h" | |
c0751163 | 47 | |
00e86732 | 48 | /// \cond CLASSIMP |
c0751163 | 49 | ClassImp(AliMUONRawStreamTracker) |
00e86732 | 50 | /// \endcond |
c0751163 | 51 | |
52 | AliMUONRawStreamTracker::AliMUONRawStreamTracker() | |
33434f31 | 53 | : TObject(), |
54 | fRawReader(0x0), | |
55 | fDDL(0), | |
56 | fMaxDDL(20), | |
57 | fPayload(new AliMUONPayloadTracker()), | |
58 | fCurrentDDL(0), | |
59 | fCurrentDDLIndex(fMaxDDL), | |
60 | fCurrentBlockHeader(0), | |
61 | fCurrentBlockHeaderIndex(0), | |
62 | fCurrentDspHeader(0), | |
63 | fCurrentDspHeaderIndex(0), | |
64 | fCurrentBusStruct(0), | |
65 | fCurrentBusStructIndex(0), | |
66 | fCurrentDataIndex(0) | |
c0751163 | 67 | { |
00e86732 | 68 | /// |
69 | /// create an object to read MUON raw digits | |
70 | /// Default ctor for monitoring purposes | |
71 | /// | |
33434f31 | 72 | |
73 | ||
c0751163 | 74 | } |
75 | ||
76 | //_________________________________________________________________ | |
77 | AliMUONRawStreamTracker::AliMUONRawStreamTracker(AliRawReader* rawReader) | |
33434f31 | 78 | : TObject(), |
79 | fRawReader(rawReader), | |
80 | fDDL(0), | |
81 | fMaxDDL(20), | |
82 | fPayload(new AliMUONPayloadTracker()), | |
83 | fCurrentDDL(0L), | |
84 | fCurrentDDLIndex(fMaxDDL), | |
85 | fCurrentBlockHeader(0), | |
86 | fCurrentBlockHeaderIndex(0), | |
87 | fCurrentDspHeader(0), | |
88 | fCurrentDspHeaderIndex(0), | |
89 | fCurrentBusStruct(0), | |
90 | fCurrentBusStructIndex(0), | |
91 | fCurrentDataIndex(0) | |
c0751163 | 92 | { |
00e86732 | 93 | /// |
94 | /// ctor with AliRawReader as argument | |
95 | /// for reconstruction purpose | |
96 | /// | |
33434f31 | 97 | |
98 | ||
c0751163 | 99 | } |
100 | ||
c0751163 | 101 | //___________________________________ |
102 | AliMUONRawStreamTracker::~AliMUONRawStreamTracker() | |
103 | { | |
00e86732 | 104 | /// |
105 | /// clean up | |
106 | /// | |
313a427d | 107 | delete fPayload; |
c0751163 | 108 | } |
109 | ||
110 | //_____________________________________________________________ | |
33434f31 | 111 | Bool_t |
112 | AliMUONRawStreamTracker::Next(Int_t& busPatchId, | |
113 | UShort_t& manuId, UChar_t& manuChannel, | |
114 | UShort_t& adc) | |
c0751163 | 115 | { |
00e86732 | 116 | /// |
117 | /// read the next raw digit (buspatch structure) | |
118 | /// returns kFALSE if there is no digit left | |
33434f31 | 119 | /// |
120 | ||
121 | if ( IsDone() ) return kFALSE; | |
122 | ||
123 | if ( fCurrentDataIndex >= fCurrentBusStruct->GetLength()-1 ) | |
124 | { | |
125 | Bool_t ok = GetNextBusStruct(); | |
126 | if (!ok) | |
127 | { | |
128 | // this is the end | |
129 | return kFALSE; | |
130 | } | |
131 | } | |
132 | ||
133 | ++fCurrentDataIndex; | |
134 | ||
135 | busPatchId = fCurrentBusStruct->GetBusPatchId(); | |
136 | manuId = fCurrentBusStruct->GetManuId(fCurrentDataIndex); | |
137 | manuChannel = fCurrentBusStruct->GetChannelId(fCurrentDataIndex); | |
138 | adc = fCurrentBusStruct->GetCharge(fCurrentDataIndex); | |
139 | ||
140 | return kTRUE; | |
c0751163 | 141 | } |
142 | ||
143 | //______________________________________________________ | |
33434f31 | 144 | Bool_t |
145 | AliMUONRawStreamTracker::IsDone() const | |
c0751163 | 146 | { |
33434f31 | 147 | /// Whether the iteration is finished or not |
148 | return (fCurrentBusStruct==0); | |
149 | } | |
c0751163 | 150 | |
33434f31 | 151 | //______________________________________________________ |
152 | void | |
153 | AliMUONRawStreamTracker::First() | |
154 | { | |
155 | /// Initialize the iteration process | |
156 | ||
157 | fCurrentDDLIndex = -1; | |
158 | fCurrentDspHeaderIndex = -1; | |
159 | fCurrentBusStructIndex = -1; | |
160 | ||
161 | fCurrentDspHeader = 0; | |
162 | fCurrentBusStruct = 0; | |
163 | ||
164 | // Find the first non-empty structure | |
165 | GetNextDDL(); | |
166 | GetNextBlockHeader(); | |
167 | GetNextDspHeader(); | |
168 | GetNextBusStruct(); | |
169 | } | |
c0751163 | 170 | |
33434f31 | 171 | //______________________________________________________ |
172 | Bool_t | |
173 | AliMUONRawStreamTracker::GetNextDDL() | |
174 | { | |
175 | /// Returns the next DDL present | |
176 | ||
177 | Bool_t kFound(kFALSE); | |
178 | ||
179 | while ( fCurrentDDLIndex < fMaxDDL-1 && !kFound ) | |
180 | { | |
181 | ++fCurrentDDLIndex; | |
182 | fRawReader->Reset(); | |
183 | fRawReader->Select("MUONTRK",fCurrentDDLIndex,fCurrentDDLIndex); | |
184 | if ( fRawReader->ReadHeader() ) | |
185 | { | |
186 | kFound = kTRUE; | |
187 | } | |
188 | } | |
189 | ||
190 | if ( !kFound ) | |
191 | { | |
192 | fCurrentDDLIndex = fMaxDDL; | |
c0751163 | 193 | return kFALSE; |
194 | } | |
33434f31 | 195 | |
313a427d | 196 | Int_t totalDataWord = fRawReader->GetDataSize(); // in bytes |
33434f31 | 197 | |
198 | AliDebug(3, Form("DDL Number %d totalDataWord %d\n", fCurrentDDLIndex, | |
199 | totalDataWord)); | |
200 | ||
313a427d | 201 | UInt_t *buffer = new UInt_t[totalDataWord/4]; |
33434f31 | 202 | |
203 | if ( !fRawReader->ReadNext((UChar_t*)buffer, totalDataWord) ) | |
204 | { | |
205 | fCurrentDDL = 0; | |
206 | return kFALSE; | |
207 | } | |
208 | fPayload->ResetDDL(); | |
209 | ||
210 | Bool_t ok = fPayload->Decode(buffer, totalDataWord/4); | |
211 | ||
ea59383d | 212 | AddErrorMessage(); |
213 | ||
33434f31 | 214 | delete[] buffer; |
215 | ||
216 | fCurrentDDL = fPayload->GetDDLTracker(); | |
217 | ||
218 | fCurrentBlockHeaderIndex = -1; | |
219 | ||
220 | return ok; | |
221 | } | |
c0751163 | 222 | |
33434f31 | 223 | //______________________________________________________ |
224 | Bool_t | |
225 | AliMUONRawStreamTracker::GetNextBlockHeader() | |
226 | { | |
227 | /// Returns the next block Header present | |
c0751163 | 228 | |
33434f31 | 229 | fCurrentBlockHeader = 0; |
c0751163 | 230 | |
33434f31 | 231 | Int_t i(fCurrentBlockHeaderIndex); |
232 | ||
233 | while ( fCurrentBlockHeader == 0 && i < fCurrentDDL->GetBlkHeaderEntries()-1 ) | |
234 | { | |
235 | ++i; | |
236 | fCurrentBlockHeader = fCurrentDDL->GetBlkHeaderEntry(i); | |
237 | } | |
238 | ||
239 | if ( !fCurrentBlockHeader ) | |
240 | { | |
241 | Bool_t ok = GetNextDDL(); | |
242 | if (!ok) | |
243 | { | |
244 | return kFALSE; | |
245 | } | |
246 | else | |
247 | { | |
248 | return GetNextBlockHeader(); | |
249 | } | |
250 | } | |
251 | ||
252 | fCurrentBlockHeaderIndex = i; | |
253 | ||
254 | fCurrentDspHeaderIndex = -1; | |
255 | ||
256 | return kTRUE; | |
257 | } | |
c0751163 | 258 | |
33434f31 | 259 | //______________________________________________________ |
260 | Bool_t | |
261 | AliMUONRawStreamTracker::GetNextDspHeader() | |
262 | { | |
263 | /// Returns the next Dsp Header present | |
264 | ||
265 | fCurrentDspHeader = 0; | |
266 | ||
267 | Int_t i(fCurrentDspHeaderIndex); | |
268 | ||
269 | while ( fCurrentDspHeader == 0 && i < fCurrentBlockHeader->GetDspHeaderEntries()-1 ) | |
270 | { | |
271 | ++i; | |
272 | fCurrentDspHeader = fCurrentBlockHeader->GetDspHeaderEntry(i); | |
273 | } | |
274 | ||
275 | if ( !fCurrentDspHeader ) | |
276 | { | |
277 | Bool_t ok = GetNextBlockHeader(); | |
278 | if (!ok) | |
279 | { | |
280 | return kFALSE; | |
281 | } | |
282 | else | |
283 | { | |
284 | return GetNextDspHeader(); | |
285 | } | |
286 | } | |
287 | ||
288 | fCurrentDspHeaderIndex = i; | |
289 | ||
290 | fCurrentBusStructIndex = -1; | |
291 | ||
292 | return kTRUE; | |
293 | } | |
c0751163 | 294 | |
33434f31 | 295 | //______________________________________________________ |
296 | Bool_t | |
297 | AliMUONRawStreamTracker::GetNextBusStruct() | |
298 | { | |
299 | /// Find the next non-empty busPatch structure | |
300 | ||
301 | fCurrentBusStruct = 0; | |
302 | ||
303 | Int_t i(fCurrentBusStructIndex); | |
304 | ||
305 | while ( fCurrentBusStruct == 0 && i < fCurrentDspHeader->GetBusPatchEntries()-1 ) | |
306 | { | |
307 | ++i; | |
308 | fCurrentBusStruct = fCurrentDspHeader->GetBusPatchEntry(i); | |
309 | } | |
310 | ||
311 | if ( !fCurrentBusStruct ) | |
312 | { | |
313 | Bool_t ok = GetNextDspHeader(); | |
314 | if (!ok) | |
315 | { | |
316 | return kFALSE; | |
317 | } | |
318 | else | |
319 | { | |
320 | return GetNextBusStruct(); | |
321 | } | |
322 | } | |
323 | ||
324 | fCurrentBusStructIndex = i; | |
325 | ||
326 | fCurrentDataIndex = -1; | |
327 | ||
c0751163 | 328 | return kTRUE; |
329 | } | |
c0751163 | 330 | |
33434f31 | 331 | //______________________________________________________ |
332 | Bool_t AliMUONRawStreamTracker::NextDDL() | |
333 | { | |
334 | /// reading tracker DDL | |
335 | ||
336 | fPayload->ResetDDL(); | |
337 | ||
338 | while ( fDDL < 20 ) | |
339 | { | |
340 | fRawReader->Reset(); | |
341 | fRawReader->Select("MUONTRK", fDDL, fDDL); //Select the DDL file to be read | |
342 | if (fRawReader->ReadHeader()) break; | |
343 | AliDebug(3,Form("Skipping DDL %d which does not seem to be there",fDDL)); | |
344 | ++fDDL; | |
345 | } | |
346 | ||
347 | if ( fDDL == 20 ) | |
348 | { | |
349 | fDDL = 0; | |
350 | return kFALSE; | |
351 | } | |
352 | ||
353 | AliDebug(3, Form("DDL Number %d\n", fDDL )); | |
354 | ||
355 | Int_t totalDataWord = fRawReader->GetDataSize(); // in bytes | |
356 | ||
357 | UInt_t *buffer = new UInt_t[totalDataWord/4]; | |
358 | ||
359 | if(!fRawReader->ReadNext((UChar_t*)buffer, totalDataWord)) | |
360 | { | |
ea59383d | 361 | delete[] buffer; |
33434f31 | 362 | return kFALSE; |
363 | } | |
364 | ||
365 | Bool_t ok = fPayload->Decode(buffer, totalDataWord/4); | |
ea59383d | 366 | |
367 | AddErrorMessage(); | |
368 | ||
33434f31 | 369 | delete[] buffer; |
370 | ||
371 | fDDL++; | |
372 | ||
373 | return ok; | |
374 | } | |
375 | ||
c0751163 | 376 | //______________________________________________________ |
377 | void AliMUONRawStreamTracker::SetMaxDDL(Int_t ddl) | |
378 | { | |
00e86732 | 379 | /// set DDL number |
c0751163 | 380 | if (ddl > 20) ddl = 20; |
381 | fMaxDDL = ddl; | |
382 | } | |
383 | ||
384 | //______________________________________________________ | |
385 | void AliMUONRawStreamTracker::SetMaxBlock(Int_t blk) | |
386 | { | |
00e86732 | 387 | /// set regional card number |
313a427d | 388 | fPayload->SetMaxBlock(blk); |
c0751163 | 389 | } |
ea59383d | 390 | |
391 | //______________________________________________________ | |
392 | void AliMUONRawStreamTracker::AddErrorMessage() | |
393 | { | |
394 | /// add message into logger of AliRawReader per event | |
395 | ||
396 | for (Int_t i = 0; i < fPayload->GetParityErrors(); ++i) | |
397 | fRawReader->AddMinorErrorLog(kParityErr, Form("Parity error for buspatch %s", | |
398 | fPayload->GetParityErrBus()[i])); | |
399 | ||
400 | for (Int_t i = 0; i < fPayload->GetGlitchErrors(); ++i) | |
401 | fRawReader->AddMajorErrorLog(kGlitchErr, "Glitch error occurs skip event"); | |
402 | ||
403 | for (Int_t i = 0; i < fPayload->GetPaddingErrors(); ++i) | |
404 | fRawReader->AddMinorErrorLog(kPaddingWordErr, "Padding word error"); | |
405 | ||
406 | } |