]>
Commit | Line | Data |
---|---|---|
0508ca31 | 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 | //////////////////////////////////////////////////////////////////////////// | |
17 | // // | |
18 | // Decoding data from the TRD raw stream // | |
9cb9c409 | 19 | // and translation into ADC values, on-line tracklets and tracks // |
0508ca31 | 20 | // // |
21 | // Author: J. Klein (jochen.klein@cern.ch) // | |
22 | // // | |
23 | //////////////////////////////////////////////////////////////////////////// | |
24 | ||
92223bf6 | 25 | #include <cstdio> |
26 | #include <cstdarg> | |
27 | ||
d60fe037 | 28 | #include "TClonesArray.h" |
29 | #include "TTree.h" | |
30 | ||
31 | #include "AliLog.h" | |
32 | #include "AliRawReader.h" | |
33 | #include "AliTRDdigitsManager.h" | |
34 | #include "AliTRDdigitsParam.h" | |
35 | #include "AliTRDtrapConfig.h" | |
36 | #include "AliTRDarrayADC.h" | |
37 | #include "AliTRDarrayDictionary.h" | |
38 | #include "AliTRDSignalIndex.h" | |
39 | #include "AliTRDtrackletWord.h" | |
5fdfc9e4 | 40 | #include "AliESDTrdTrack.h" |
cc26f39c | 41 | #include "AliTreeLoader.h" |
c93255fe | 42 | #include "AliLoader.h" |
d60fe037 | 43 | |
44 | #include "AliTRDrawStream.h" | |
45 | ||
46 | // temporary | |
47 | #include "AliRunLoader.h" | |
48 | ||
49 | ClassImp(AliTRDrawStream) | |
50 | ||
9cb9c409 | 51 | // some static information |
52 | Int_t AliTRDrawStream::fgMcmOrder[] = {12, 13, 14, 15, | |
53 | 8, 9, 10, 11, | |
54 | 4, 5, 6, 7, | |
55 | 0, 1, 2, 3}; | |
56 | Int_t AliTRDrawStream::fgRobOrder [] = {0, 1, 2, 3}; | |
d60fe037 | 57 | const Int_t AliTRDrawStream::fgkNlinks = 12; |
58 | const Int_t AliTRDrawStream::fgkNstacks = 5; | |
9cb9c409 | 59 | const Int_t AliTRDrawStream::fgkNsectors = 18; |
60 | const Int_t AliTRDrawStream::fgkNtriggers = 12; | |
d60fe037 | 61 | const UInt_t AliTRDrawStream::fgkDataEndmarker = 0x00000000; |
62 | const UInt_t AliTRDrawStream::fgkTrackletEndmarker = 0x10001000; | |
63 | ||
92305359 | 64 | const char* AliTRDrawStream::fgkErrorMessages[] = { |
d60fe037 | 65 | "Unknown error", |
66 | "Link monitor active", | |
67 | "Pretrigger counter mismatch", | |
68 | "not a TRD equipment (1024-1041)", | |
69 | "Invalid Stack header", | |
70 | "Invalid detector number", | |
71 | "No digits could be retrieved from the digitsmanager", | |
72 | "HC header mismatch", | |
73 | "HC check bits wrong", | |
74 | "Unexpected position in readout stream", | |
75 | "Invalid testpattern mode", | |
76 | "Testpattern mismatch", | |
77 | "Number of timebins changed", | |
78 | "ADC mask inconsistent", | |
79 | "ADC check bits invalid", | |
80 | "Missing ADC data", | |
81 | "Missing expected ADC channels", | |
82 | "Missing MCM headers" | |
83 | }; | |
84 | ||
92305359 | 85 | Int_t AliTRDrawStream::fgErrorDebugLevel[] = { |
92223bf6 | 86 | 0, |
87 | 0, | |
88 | 2, | |
89 | 1, | |
90 | 0, | |
91 | 1, | |
92 | 1, | |
93 | 1, | |
94 | 1, | |
95 | 2, | |
96 | 1, | |
97 | 1, | |
98 | 1, | |
99 | 1, | |
100 | 2, | |
101 | 1, | |
102 | 1, | |
103 | 1 | |
104 | }; | |
105 | ||
106 | AliTRDrawStream::ErrorBehav_t AliTRDrawStream::fgErrorBehav[] = { | |
107 | AliTRDrawStream::kTolerate, | |
108 | AliTRDrawStream::kDiscardHC, | |
109 | AliTRDrawStream::kTolerate, | |
110 | AliTRDrawStream::kAbort, | |
111 | AliTRDrawStream::kAbort, | |
112 | AliTRDrawStream::kAbort, | |
113 | AliTRDrawStream::kAbort, | |
114 | AliTRDrawStream::kDiscardHC, | |
115 | AliTRDrawStream::kDiscardHC, | |
116 | AliTRDrawStream::kTolerate, | |
117 | AliTRDrawStream::kTolerate, | |
118 | AliTRDrawStream::kTolerate, | |
119 | AliTRDrawStream::kTolerate, | |
120 | AliTRDrawStream::kTolerate, | |
121 | AliTRDrawStream::kTolerate, | |
122 | AliTRDrawStream::kTolerate, | |
123 | AliTRDrawStream::kTolerate, | |
124 | AliTRDrawStream::kTolerate | |
125 | }; | |
126 | ||
d60fe037 | 127 | AliTRDrawStream::AliTRDrawStream(AliRawReader *rawReader) : |
cc26f39c | 128 | fStats(), |
f0a345a7 | 129 | fStoreError(&AliTRDrawStream::ForgetError), |
d60fe037 | 130 | fRawReader(rawReader), |
131 | fDigitsManager(0x0), | |
132 | fDigitsParam(0x0), | |
133 | fErrors(0x0), | |
134 | fLastError(), | |
92223bf6 | 135 | fErrorFlags(0), |
d60fe037 | 136 | fPayloadStart(0x0), |
137 | fPayloadCurr(0x0), | |
138 | fPayloadSize(0), | |
139 | fNtimebins(-1), | |
140 | fLastEvId(-1), | |
141 | fCurrSlot(-1), | |
142 | fCurrLink(-1), | |
143 | fCurrRobPos(-1), | |
144 | fCurrMcmPos(-1), | |
145 | fCurrEquipmentId(0), | |
9cb9c409 | 146 | fCurrSmHeaderSize(0), |
147 | fCurrSmHeaderVersion(0), | |
148 | fCurrTrailerReadout(0), | |
149 | fCurrTrgHeaderAvail(0), | |
150 | fCurrTrgHeaderReadout(0), | |
151 | fCurrTrkHeaderAvail(0), | |
152 | fCurrEvType(0), | |
153 | fCurrTriggerEnable(0), | |
154 | fCurrTriggerFired(0), | |
d60fe037 | 155 | fCurrTrackEnable(0), |
156 | fCurrTrackletEnable(0), | |
157 | fCurrStackMask(0), | |
9cb9c409 | 158 | fCurrTrkHeaderIndexWord(0x0), |
159 | fCurrTrkHeaderSize(0x0), | |
160 | fCurrTrgHeaderIndexWord(0x0), | |
161 | fCurrTrgHeaderSize(0x0), | |
d60fe037 | 162 | fCurrStackIndexWord(0x0), |
163 | fCurrStackHeaderSize(0x0), | |
164 | fCurrStackHeaderVersion(0x0), | |
165 | fCurrLinkMask(0x0), | |
166 | fCurrCleanCheckout(0x0), | |
167 | fCurrBoardId(0x0), | |
9cb9c409 | 168 | fCurrHwRev(-1), |
169 | fCurrHwRevTMU(0x0), | |
d60fe037 | 170 | fCurrLinkMonitorFlags(0x0), |
171 | fCurrLinkDataTypeFlags(0x0), | |
172 | fCurrLinkDebugFlags(0x0), | |
173 | fCurrSpecial(-1), | |
174 | fCurrMajor(-1), | |
175 | fCurrMinor(-1), | |
176 | fCurrAddHcWords(-1), | |
177 | fCurrSm(-1), | |
178 | fCurrStack(-1), | |
179 | fCurrLayer(-1), | |
180 | fCurrSide(-1), | |
181 | fCurrHC(-1), | |
182 | fCurrCheck(-1), | |
183 | fCurrNtimebins(-1), | |
184 | fCurrBC(-1), | |
185 | fCurrPtrgCnt(-1), | |
186 | fCurrPtrgPhase(-1), | |
cc26f39c | 187 | fNDumpMCMs(0), |
d60fe037 | 188 | fTrackletArray(0x0), |
189 | fAdcArray(0x0), | |
190 | fSignalIndex(0x0), | |
5fdfc9e4 | 191 | fTrackletTree(0x0), |
192 | fTracklets(0x0), | |
193 | fTracks(0x0), | |
194 | fMarkers(0x0) | |
d60fe037 | 195 | { |
196 | // default constructor | |
197 | ||
9cb9c409 | 198 | fCurrTrkHeaderIndexWord = new UInt_t[fgkNstacks]; |
199 | fCurrTrkHeaderSize = new UInt_t[fgkNstacks]; | |
200 | fCurrTrgHeaderIndexWord = new UInt_t[fgkNtriggers]; | |
201 | fCurrTrgHeaderSize = new UInt_t[fgkNtriggers]; | |
d60fe037 | 202 | fCurrStackIndexWord = new UInt_t[fgkNstacks]; |
203 | fCurrStackHeaderSize = new UInt_t[fgkNstacks]; | |
204 | fCurrStackHeaderVersion = new UInt_t[fgkNstacks]; | |
205 | fCurrLinkMask = new UInt_t[fgkNstacks]; | |
206 | fCurrCleanCheckout = new UInt_t[fgkNstacks]; | |
207 | fCurrBoardId = new UInt_t[fgkNstacks]; | |
9cb9c409 | 208 | fCurrHwRevTMU = new UInt_t[fgkNstacks]; |
d60fe037 | 209 | fCurrLinkMonitorFlags = new UInt_t[fgkNstacks * fgkNlinks]; |
210 | fCurrLinkDataTypeFlags = new UInt_t[fgkNstacks * fgkNlinks]; | |
211 | fCurrLinkDebugFlags = new UInt_t[fgkNstacks * fgkNlinks]; | |
5fdfc9e4 | 212 | for (Int_t i = 0; i < 100; i++) |
213 | fDumpMCM[i] = 0; | |
d60fe037 | 214 | |
215 | // preparing TClonesArray | |
216 | fTrackletArray = new TClonesArray("AliTRDtrackletWord", 256); | |
217 | ||
218 | // setting up the error tree | |
219 | fErrors = new TTree("errorStats", "Error statistics"); | |
220 | fErrors->SetDirectory(0x0); | |
5fdfc9e4 | 221 | fErrors->Branch("error", &fLastError); |
d60fe037 | 222 | fErrors->SetCircular(1000); |
2f9bdd85 | 223 | for (Int_t i = 0; i < 100; i++) { |
224 | fErrorBuffer[i] = 0; | |
225 | } | |
226 | ||
d60fe037 | 227 | } |
228 | ||
229 | AliTRDrawStream::~AliTRDrawStream() | |
230 | { | |
231 | // destructor | |
232 | ||
233 | delete fErrors; | |
234 | ||
9cb9c409 | 235 | delete [] fCurrTrkHeaderIndexWord; |
236 | delete [] fCurrTrkHeaderSize; | |
237 | delete [] fCurrTrgHeaderIndexWord; | |
238 | delete [] fCurrTrgHeaderSize; | |
d60fe037 | 239 | delete [] fCurrStackIndexWord; |
240 | delete [] fCurrStackHeaderSize; | |
241 | delete [] fCurrStackHeaderVersion; | |
242 | delete [] fCurrLinkMask; | |
243 | delete [] fCurrCleanCheckout; | |
244 | delete [] fCurrBoardId; | |
9cb9c409 | 245 | delete [] fCurrHwRevTMU; |
d60fe037 | 246 | delete [] fCurrLinkMonitorFlags; |
247 | delete [] fCurrLinkDataTypeFlags; | |
248 | delete [] fCurrLinkDebugFlags; | |
249 | } | |
250 | ||
251 | Bool_t AliTRDrawStream::ReadEvent(TTree *trackletTree) | |
252 | { | |
253 | // read the current event from the raw reader and fill it to the digits manager | |
254 | ||
255 | if (!fRawReader) { | |
256 | AliError("No raw reader available"); | |
257 | return kFALSE; | |
258 | } | |
259 | ||
260 | // tracklet output | |
67271412 | 261 | ConnectTracklets(trackletTree); |
d60fe037 | 262 | |
263 | // some preparations | |
264 | fDigitsParam = 0x0; | |
265 | ||
266 | // loop over all DDLs | |
9cb9c409 | 267 | // data starts with GTU payload, i.e. SM index word |
d60fe037 | 268 | UChar_t *buffer = 0x0; |
269 | ||
270 | while (fRawReader->ReadNextData(buffer)) { | |
271 | ||
272 | fCurrEquipmentId = fRawReader->GetEquipmentId(); | |
273 | AliDebug(2, Form("equipment: %i", fCurrEquipmentId)); | |
274 | ||
9cb9c409 | 275 | if (fCurrEquipmentId < kDDLOffset || fCurrEquipmentId > kDDLMax) { |
92223bf6 | 276 | EquipmentError(kNonTrdEq, "Skipping"); |
d60fe037 | 277 | continue; |
278 | } | |
279 | ||
8df9496c | 280 | if (fMarkers) |
281 | new ((*fMarkers)[fMarkers->GetEntriesFast()]) | |
9cb9c409 | 282 | AliTRDrawStreamError(-kSecactive, fCurrEquipmentId - kDDLOffset); |
8df9496c | 283 | |
9cb9c409 | 284 | ReadGTUHeaders((UInt_t*) buffer); |
d60fe037 | 285 | |
9cb9c409 | 286 | if (fCurrTrailerReadout) |
287 | ReadGTUTrailer(); | |
d60fe037 | 288 | |
9cb9c409 | 289 | // loop over all active links |
290 | AliDebug(2, Form("Stack mask 0x%02x", fCurrStackMask)); | |
291 | for (Int_t iStack = 0; iStack < fgkNstacks; iStack++) { | |
d60fe037 | 292 | fCurrSlot = iStack; |
9cb9c409 | 293 | if ((fCurrStackMask & (1 << fCurrSlot)) == 0) |
d60fe037 | 294 | continue; |
295 | ||
296 | AliDebug(2, Form("Stack %i, Link mask: 0x%02x", fCurrSlot, fCurrLinkMask[fCurrSlot])); | |
9cb9c409 | 297 | for (Int_t iLink = 0; iLink < fgkNlinks; iLink++) { |
d60fe037 | 298 | fCurrLink = iLink; |
9cb9c409 | 299 | fCurrHC = (fCurrEquipmentId - kDDLOffset) * fgkNstacks * fgkNlinks + |
300 | fCurrSlot * fgkNlinks + iLink; | |
d60fe037 | 301 | if ((fCurrLinkMask[fCurrSlot] & (1 << fCurrLink)) == 0) |
302 | continue; | |
9cb9c409 | 303 | |
92223bf6 | 304 | fErrorFlags = 0; |
305 | // check for link monitor error flag | |
d60fe037 | 306 | if (fCurrLinkMonitorFlags[fCurrSlot*fgkNlinks + fCurrLink] != 0) |
307 | LinkError(kLinkMonitor); | |
7534e6db | 308 | else |
309 | // read the data from one HC | |
310 | ReadLinkData(); | |
d60fe037 | 311 | |
312 | // read all data endmarkers | |
92223bf6 | 313 | SeekNextLink(); |
d60fe037 | 314 | } |
315 | } | |
316 | } | |
9cb9c409 | 317 | |
d60fe037 | 318 | return kTRUE; |
319 | } | |
320 | ||
321 | ||
322 | Bool_t AliTRDrawStream::NextDDL() | |
323 | { | |
0508ca31 | 324 | // continue reading with the next equipment |
325 | ||
d60fe037 | 326 | if (!fRawReader) |
327 | return kFALSE; | |
328 | ||
329 | fCurrEquipmentId = 0; | |
330 | fCurrSlot = 0; | |
331 | fCurrLink = 0; | |
332 | ||
333 | UChar_t *buffer = 0x0; | |
334 | ||
335 | while (fRawReader->ReadNextData(buffer)) { | |
336 | ||
337 | fCurrEquipmentId = fRawReader->GetEquipmentId(); | |
338 | AliDebug(2, Form("equipment: %i", fCurrEquipmentId)); | |
339 | ||
9cb9c409 | 340 | if (fCurrEquipmentId < kDDLOffset || fCurrEquipmentId > kDDLMax) { |
92223bf6 | 341 | EquipmentError(kNonTrdEq, "Skipping"); |
d60fe037 | 342 | continue; |
343 | } | |
344 | ||
8df9496c | 345 | if (fMarkers) |
346 | new ((*fMarkers)[fMarkers->GetEntriesFast()]) | |
9cb9c409 | 347 | AliTRDrawStreamError(-kSecactive, fCurrEquipmentId - kDDLOffset); |
8df9496c | 348 | |
9cb9c409 | 349 | ReadGTUHeaders((UInt_t*) buffer); |
350 | ||
351 | if (fCurrTrailerReadout) | |
352 | ReadGTUTrailer(); | |
d60fe037 | 353 | |
d60fe037 | 354 | return kTRUE; |
355 | } | |
356 | ||
357 | return kFALSE; | |
358 | } | |
359 | ||
360 | ||
9cb9c409 | 361 | Int_t AliTRDrawStream::NextChamber(AliTRDdigitsManager *digMgr) |
d60fe037 | 362 | { |
0508ca31 | 363 | // read the data for the next chamber |
364 | // in case you only want to read the data of a single chamber | |
365 | // to read all data ReadEvent(...) is recommended | |
366 | ||
d60fe037 | 367 | fDigitsManager = digMgr; |
368 | fDigitsParam = 0x0; | |
369 | ||
92223bf6 | 370 | fErrorFlags = 0; |
371 | ||
d60fe037 | 372 | // tracklet output preparation |
67271412 | 373 | TTree *trklTree = 0x0; |
374 | AliRunLoader *rl = AliRunLoader::Instance(); | |
44ac5cbf | 375 | AliLoader* trdLoader = rl ? rl->GetLoader("TRDLoader") : NULL; |
376 | AliDataLoader *trklLoader = trdLoader ? trdLoader->GetDataLoader("tracklets") : NULL; | |
377 | if (trklLoader) { | |
cc26f39c | 378 | AliTreeLoader *trklTreeLoader = (AliTreeLoader*) trklLoader->GetBaseLoader("tracklets-raw"); |
379 | if (trklTreeLoader) | |
380 | trklTree = trklTreeLoader->Tree(); | |
381 | else | |
382 | trklTree = trklLoader->Tree(); | |
67271412 | 383 | } |
384 | ||
385 | if (fTrackletTree != trklTree) | |
386 | ConnectTracklets(trklTree); | |
d60fe037 | 387 | |
388 | if (!fRawReader) { | |
389 | AliError("No raw reader available"); | |
390 | return -1; | |
391 | } | |
392 | ||
9cb9c409 | 393 | while (fCurrSlot < 0 || fCurrSlot >= fgkNstacks) { |
d60fe037 | 394 | if (!NextDDL()) { |
395 | fCurrSlot = -1; | |
396 | return -1; | |
397 | } | |
9cb9c409 | 398 | while ((fCurrSlot < fgkNstacks) && |
9e07aeda | 399 | (((fCurrStackMask & (1 << fCurrSlot)) == 0) || |
400 | ((fCurrLinkMask[fCurrSlot] & (1 << fCurrLink))) == 0)) { | |
401 | fCurrLink++; | |
9cb9c409 | 402 | if (fCurrLink >= fgkNlinks) { |
9e07aeda | 403 | fCurrLink = 0; |
404 | fCurrSlot++; | |
405 | } | |
406 | } | |
d60fe037 | 407 | } |
408 | ||
409 | AliDebug(2, Form("Stack %i, Link %i, mask: 0x%02x", fCurrSlot, fCurrLink, fCurrLinkMask[fCurrSlot])); | |
9cb9c409 | 410 | fCurrHC = (fCurrEquipmentId - kDDLOffset) * fgkNlinks * fgkNstacks + |
411 | fCurrSlot * fgkNlinks + fCurrLink; | |
d60fe037 | 412 | |
413 | if (fCurrLinkMonitorFlags[fCurrSlot*fgkNlinks + fCurrLink] != 0) | |
414 | LinkError(kLinkMonitor); | |
7534e6db | 415 | else |
416 | // read the data from one HC | |
417 | ReadLinkData(); | |
d60fe037 | 418 | |
419 | // read all data endmarkers | |
92223bf6 | 420 | SeekNextLink(); |
d60fe037 | 421 | |
422 | if (fCurrLink % 2 == 0) { | |
423 | // if we just read the A-side HC then also check the B-side | |
424 | fCurrLink++; | |
1e7466b5 | 425 | fCurrHC++; |
d60fe037 | 426 | if (fCurrLinkMask[fCurrSlot] & (1 << fCurrLink)) { |
427 | ReadLinkData(); | |
92223bf6 | 428 | SeekNextLink(); |
d60fe037 | 429 | } |
430 | } | |
431 | ||
432 | //??? to check | |
433 | do { | |
434 | fCurrLink++; | |
9cb9c409 | 435 | if (fCurrLink >= fgkNlinks) { |
d60fe037 | 436 | fCurrLink = 0; |
437 | fCurrSlot++; | |
438 | } | |
9cb9c409 | 439 | } while ((fCurrSlot < fgkNstacks) && |
67271412 | 440 | (((fCurrStackMask & (1 << fCurrSlot)) == 0) || |
441 | ((fCurrLinkMask[fCurrSlot] & (1 << fCurrLink))) == 0)); | |
d60fe037 | 442 | |
25671e69 | 443 | // return chamber information from HC if it is valid |
444 | // otherwise return information from link position | |
9cb9c409 | 445 | if (fCurrSm < 0 || fCurrSm >= fgkNsectors || fCurrStack < 0 || fCurrStack >= fgkNstacks || fCurrLayer < 0 || fCurrLayer >= fgkNlinks/2) |
446 | return ((fCurrEquipmentId-kDDLOffset) + fCurrSlot * fgkNlinks/2 + fCurrLink/2); | |
25671e69 | 447 | else |
9cb9c409 | 448 | return (fCurrSm * fgkNstacks*fgkNlinks/2 + fCurrStack * fgkNlinks/2 + fCurrLayer); |
d60fe037 | 449 | } |
450 | ||
451 | ||
9cb9c409 | 452 | Int_t AliTRDrawStream::ReadGTUHeaders(UInt_t *buffer) |
453 | { | |
454 | // check the data source and read the headers | |
455 | ||
456 | if (fCurrEquipmentId >= kDDLOffset && fCurrEquipmentId <= kDDLMax) { | |
457 | // this is ROC data | |
458 | ||
459 | // setting the pointer to data and current reading position | |
460 | fPayloadCurr = fPayloadStart = buffer; | |
461 | fPayloadSize = fRawReader->GetDataSize() / sizeof(UInt_t); | |
462 | fStats.fStatsSector[fCurrEquipmentId - kDDLOffset].fBytes = fRawReader->GetDataSize(); | |
463 | AliDebug(2, Form("Read buffer of size: %i", fRawReader->GetDataSize())); | |
464 | ||
465 | AliDebug(1, DumpRaw("raw data", fPayloadCurr, TMath::Min(fPayloadSize, 1000))); | |
466 | ||
467 | // read SM header | |
468 | if (ReadSmHeader() < 0) { | |
469 | AliError(Form("Reading SM header failed, skipping this DDL %i", fCurrEquipmentId)); | |
470 | return -1; | |
471 | } | |
472 | ||
473 | // read tracking headers (if available) | |
474 | if (fCurrTrkHeaderAvail) { | |
475 | for (Int_t iStack = 0; iStack < fgkNstacks; iStack++) { | |
476 | if ((fCurrStackMask & (1 << iStack)) != 0) | |
477 | ReadTrackingHeader(iStack); | |
478 | } | |
479 | } | |
480 | ||
481 | // read trigger header(s) (if available) | |
482 | if (fCurrTrgHeaderAvail) | |
483 | ReadTriggerHeaders(); | |
484 | ||
485 | // read stack header | |
486 | for (Int_t iStack = 0; iStack < fgkNstacks; iStack++) { | |
487 | if ((fCurrStackMask & (1 << iStack)) != 0) | |
488 | ReadStackHeader(iStack); | |
489 | } | |
490 | ||
491 | return 0; | |
492 | } | |
493 | else | |
494 | return -1; | |
495 | } | |
496 | ||
d60fe037 | 497 | Int_t AliTRDrawStream::ReadSmHeader() |
498 | { | |
499 | // read the SMU index header at the current reading position | |
500 | // and store the information in the corresponding variables | |
501 | ||
502 | if (fPayloadCurr - fPayloadStart >= fPayloadSize - 1) { | |
92223bf6 | 503 | EquipmentError(kUnknown, "SM Header incomplete"); |
d60fe037 | 504 | return -1; |
505 | } | |
506 | ||
9cb9c409 | 507 | fCurrSmHeaderSize = ((*fPayloadCurr) >> 16) & 0xffff; |
508 | fCurrSmHeaderVersion = ((*fPayloadCurr) >> 12) & 0xf; | |
d60fe037 | 509 | fCurrTrackEnable = ((*fPayloadCurr) >> 6) & 0x1; |
510 | fCurrTrackletEnable = ((*fPayloadCurr) >> 5) & 0x1; | |
511 | fCurrStackMask = ((*fPayloadCurr) ) & 0x1f; | |
9cb9c409 | 512 | fCurrHwRev = (fPayloadCurr[1] >> 12) & 0xffff; |
513 | ||
514 | switch (fCurrSmHeaderVersion) { | |
515 | case 0xb: | |
516 | fCurrTrailerReadout = 0; | |
517 | fCurrTrgHeaderAvail = 0; | |
518 | fCurrEvType = 0; | |
519 | fCurrTrkHeaderAvail = 0; | |
520 | ||
521 | DecodeGTUtracks(); | |
522 | break; | |
523 | ||
524 | case 0xc: | |
525 | fCurrTrailerReadout = ((*fPayloadCurr) >> 10) & 0x1; | |
526 | fCurrTrgHeaderAvail = 1; | |
527 | fCurrTrgHeaderReadout = ((*fPayloadCurr) >> 9) & 0x1; | |
528 | fCurrEvType = ((*fPayloadCurr) >> 7) & 0x3; | |
529 | fCurrTrkHeaderAvail = fCurrTrackEnable; | |
530 | fCurrTriggerEnable = (fPayloadCurr[2] >> 8) & 0xfff; | |
531 | fCurrTriggerFired = (fPayloadCurr[2] >> 20) & 0xfff; | |
532 | break; | |
d60fe037 | 533 | |
9cb9c409 | 534 | default: |
535 | AliError(Form("unknown SM header version: 0x%x", fCurrSmHeaderVersion)); | |
536 | } | |
537 | ||
538 | AliDebug(5, Form("SM header: size: %i, version: %i, track enable: %i, tracklet enable: %i, stack mask: %2x, trailer: %i, trgheader: %i, trkheader: %i", | |
539 | fCurrSmHeaderSize, | |
540 | fCurrSmHeaderVersion, | |
541 | fCurrTrackEnable, | |
d60fe037 | 542 | fCurrTrackletEnable, |
9cb9c409 | 543 | fCurrStackMask, |
544 | fCurrTrailerReadout, | |
545 | fCurrTrgHeaderAvail, | |
546 | fCurrTrkHeaderAvail )); | |
547 | ||
548 | // jump to the first word after the SM header | |
549 | fPayloadCurr += fCurrSmHeaderSize + 1; | |
550 | ||
551 | return fCurrSmHeaderSize + 1; | |
552 | } | |
5fdfc9e4 | 553 | |
9cb9c409 | 554 | Int_t AliTRDrawStream::DecodeGTUtracks() |
555 | { | |
5fdfc9e4 | 556 | // decode GTU track words |
9cb9c409 | 557 | // this depends on the hardware revision of the SMU |
558 | ||
559 | AliDebug(1, DumpRaw(Form("GTU tracks (hw rev %i)", fCurrHwRev), | |
560 | fPayloadCurr + 4, 10, 0xffe0ffff)); | |
561 | ||
562 | if (fCurrHwRev < 1772) { | |
563 | UInt_t trackWord[2] = { 0, 0 }; | |
564 | Int_t stack = 0; | |
565 | Int_t idx = 0; | |
566 | for (UInt_t iWord = 4; iWord < fCurrSmHeaderSize; iWord++) { | |
567 | if (fPayloadCurr[iWord] == 0x10000000) { | |
568 | stack++; | |
569 | idx = 0; | |
570 | } | |
571 | else { | |
572 | if ((idx == 0) && | |
573 | ((fPayloadCurr[iWord] & 0xfffff0f0) == 0x13370000)) { | |
574 | AliDebug(1, Form("stack %i: fast trigger word: 0x%08x", stack, fPayloadCurr[iWord])); | |
575 | continue; | |
576 | } | |
577 | else if ((idx & 0x1) == 0x1) { | |
578 | trackWord[1] = fPayloadCurr[iWord]; | |
579 | AliDebug(1,Form("track debug word: 0x%08x%08x", trackWord[1], trackWord[0])); | |
580 | // if (fTracks) | |
581 | // new ((*fTracks)[fTracks->GetEntriesFast()]) AliESDTrdTrack(0, 0, trackWord[0], trackWord[1], fCurrEquipmentId-kDDLOffset); | |
582 | } | |
583 | else { | |
584 | trackWord[0] = fPayloadCurr[iWord]; | |
585 | } | |
586 | idx++; | |
587 | } | |
5fdfc9e4 | 588 | } |
9cb9c409 | 589 | } |
590 | else if (fCurrHwRev < 1804) { | |
591 | UInt_t trackWord[2] = { 0, 0 }; | |
592 | Int_t stack = 0; | |
593 | Int_t idx = 0; | |
594 | for (UInt_t iWord = 4; iWord < fCurrSmHeaderSize; iWord++) { | |
595 | if (fPayloadCurr[iWord] == 0xffe0ffff) { | |
596 | stack++; | |
597 | idx = 0; | |
598 | } | |
599 | else { | |
600 | if ((idx == 0) && | |
601 | ((fPayloadCurr[iWord] & 0xfffff0f0) == 0x13370000)) { | |
602 | AliDebug(1, Form("stack %i: fast trigger word: 0x%08x", stack, fPayloadCurr[iWord])); | |
603 | continue; | |
604 | } | |
605 | else if ((idx & 0x1) == 0x1) { | |
606 | trackWord[1] = fPayloadCurr[iWord]; | |
607 | AliDebug(1, Form("track debug word: 0x%08x%08x", trackWord[1], trackWord[0])); | |
608 | Float_t pt = (trackWord[0] & 0x8000) ? -1. * ((~(trackWord[0] & 0xffff)&0xffff) + 1)/128. : (trackWord[0] & 0xffff)/128.; | |
609 | AliDebug(1, Form("pt = %f", pt)); | |
610 | // if (fTracks) { | |
611 | // AliESDTrdTrack *trk = new ((*fTracks)[fTracks->GetEntriesFast()]) AliESDTrdTrack(0, 0, trackWord[0], trackWord[1], fCurrEquipmentId-kDDLOffset); | |
612 | // if (TMath::Abs(pt) > 0.1) { | |
613 | // trk->SetA((Int_t) (0.15*51625./100./pt / 160e-4 * 2)); | |
614 | // } | |
615 | // trk->SetStack((trackWord[1] >> 28) & 0x7); | |
616 | // } | |
617 | } | |
618 | else { | |
619 | trackWord[0] = fPayloadCurr[iWord]; | |
620 | } | |
621 | idx++; | |
622 | } | |
623 | } | |
624 | } | |
625 | else if (fCurrHwRev < 1819) { | |
626 | UInt_t trackWord[2]; | |
627 | Int_t stack = 0; | |
628 | Int_t idx = 0; | |
629 | for (UInt_t iWord = 4; iWord < fCurrSmHeaderSize; iWord++) { | |
630 | if (fPayloadCurr[iWord] == 0xffe0ffff) { | |
631 | stack++; | |
632 | idx = 0; | |
633 | } | |
634 | else { | |
635 | if ((idx == 0) && | |
636 | ((fPayloadCurr[iWord] & 0xfffff0f0) == 0x13370000)) { | |
637 | AliDebug(1, Form("stack %i: fast trigger word: 0x%08x", stack, fPayloadCurr[iWord])); | |
638 | continue; | |
639 | } | |
640 | else if ((idx & 0x1) == 0x1) { | |
641 | trackWord[idx&0x1] = fPayloadCurr[iWord]; | |
642 | AliDebug(1, Form("track debug word: 0x%08x%08x", trackWord[1], trackWord[0])); | |
643 | printf("%4i %2i %i ", | |
644 | fRawReader->GetEventIndex(), | |
645 | fCurrEquipmentId-kDDLOffset, (trackWord[1] >> 28) & 0x7); | |
646 | Float_t pt = (trackWord[0] & 0x8000) ? -1. * ((~(trackWord[0] & 0xffff)&0xffff) + 1)/128. : (trackWord[0] & 0xffff)/128.; | |
647 | printf("%+7.2f ", pt); | |
648 | printf("%i%i%i%i%i%i ", ((trackWord[0] >> 21) & 0x1), | |
649 | ((trackWord[0] >> 20) & 0x1), | |
650 | ((trackWord[0] >> 19) & 0x1), | |
651 | ((trackWord[0] >> 18) & 0x1), | |
652 | ((trackWord[0] >> 17) & 0x1), | |
653 | ((trackWord[0] >> 16) & 0x1)); | |
654 | printf("0x%08x%08x\n", trackWord[1], trackWord[0]); | |
655 | // if (fTracks) { | |
656 | // AliESDTrdTrack *trk = new ((*fTracks)[fTracks->GetEntriesFast()]) AliESDTrdTrack(0, 0, trackWord[0], trackWord[1], fCurrEquipmentId-kDDLOffset); | |
657 | // if (TMath::Abs(pt) > 0.1) { | |
658 | // trk->SetA((Int_t) (0.15*51625./100./pt / 160e-4 * 2)); | |
659 | // } | |
660 | // trk->SetStack((trackWord[1] >> 28) & 0x7); | |
661 | // } | |
662 | } | |
663 | else { | |
664 | trackWord[idx&0x1] = fPayloadCurr[iWord]; | |
665 | } | |
666 | idx++; | |
5fdfc9e4 | 667 | } |
9cb9c409 | 668 | } |
669 | } | |
670 | else if (fCurrHwRev < 1860) { | |
671 | AliError(Form("unsupported hardware rev %i", fCurrHwRev)); | |
672 | } | |
673 | else { | |
674 | UInt_t trackWord[2] = { 0, 0 }; | |
675 | Int_t stack = 0; | |
676 | Int_t idx = 0; | |
677 | Bool_t upperWord = kFALSE; | |
678 | Int_t word = 0; | |
679 | for (UInt_t iWord = 4; iWord < fCurrSmHeaderSize; iWord++) { | |
680 | if (fPayloadCurr[iWord] == 0xffe0ffff) { | |
681 | stack++; | |
682 | idx = 0; | |
683 | upperWord = kFALSE; | |
5fdfc9e4 | 684 | } |
685 | else { | |
9cb9c409 | 686 | // assemble the 32-bit words out of 16-bit blocks |
687 | if (upperWord) { | |
688 | word |= (fPayloadCurr[iWord] & 0xffff0000); | |
689 | upperWord = kFALSE; | |
690 | } | |
691 | else { | |
692 | // lower word is read first | |
693 | word = (fPayloadCurr[iWord] & 0xffff0000) >> 16; | |
694 | upperWord = kTRUE; | |
695 | continue; | |
696 | } | |
697 | ||
698 | if ((word & 0xffff0008) == 0x13370008) { | |
699 | AliDebug(1, Form("stack %i: fast track word: 0x%08x", stack, word)); | |
700 | continue; | |
701 | } | |
702 | else if ((word & 0xffff0010) == 0x13370010) { | |
703 | AliDebug(1, Form("stack %i: tracking done word: 0x%08x", stack, word)); | |
704 | continue; | |
705 | } | |
706 | else if ((idx & 0x1) == 0x1) { | |
707 | trackWord[1] = word; | |
708 | AliDebug(1, Form("track debug word: 0x%08x%08x", trackWord[1], trackWord[0])); | |
709 | // if (fTracks) { | |
710 | // AliESDTrdTrack *trk = new ((*fTracks)[fTracks->GetEntriesFast()]) AliESDTrdTrack(0, 0, trackWord[0], trackWord[1], fCurrEquipmentId-kDDLOffset); | |
711 | // if (TMath::Abs(trk->GetPt()) > 0.1) { | |
712 | // trk->SetA((Int_t) (0.15*51625./100./trk->GetPt() / 160e-4 * 2)); | |
713 | // } | |
714 | // trk->SetStack((trackWord[1] >> 28) & 0x7); | |
715 | // } | |
716 | } | |
717 | else { | |
718 | trackWord[0] = word; | |
719 | } | |
720 | idx++; | |
5fdfc9e4 | 721 | } |
5fdfc9e4 | 722 | } |
723 | } | |
9cb9c409 | 724 | return 0; |
725 | } | |
726 | ||
727 | Int_t AliTRDrawStream::ReadTrackingHeader(Int_t stack) | |
728 | { | |
729 | // read the tracking information and store it for the given stack | |
730 | ||
731 | // index word | |
732 | ||
733 | fCurrTrkHeaderIndexWord[stack] = *fPayloadCurr; | |
734 | fCurrTrkHeaderSize[stack] = ((*fPayloadCurr) >> 16) & 0x3ff; | |
735 | fPayloadCurr++; | |
736 | ||
737 | AliDebug(1, Form("tracking header index word: 0x%08x, size: %i\n", | |
738 | fCurrTrkHeaderIndexWord[stack], fCurrTrkHeaderSize[stack])); | |
739 | ||
740 | // data words | |
741 | UInt_t trackWord[2] = { 0, 0 }; | |
742 | Int_t idx = 0; | |
743 | Bool_t upperWord = kFALSE; | |
744 | Int_t word = 0; | |
745 | for (UInt_t iWord = 0; iWord < fCurrTrkHeaderSize[stack]; iWord++) { | |
746 | // assemble the 32-bit words out of 16-bit blocks | |
747 | if (upperWord) { | |
748 | word |= (fPayloadCurr[iWord] & 0xffff0000); | |
749 | upperWord = kFALSE; | |
750 | } | |
751 | else { | |
752 | // lower word is read first | |
753 | word = (fPayloadCurr[iWord] & 0xffff0000) >> 16; | |
754 | upperWord = kTRUE; | |
755 | continue; | |
756 | } | |
757 | ||
758 | if ((word & 0xffff0008) == 0x13370008) { | |
759 | AliDebug(1, Form("stack %i: fast track word: 0x%08x", stack, word)); | |
760 | continue; | |
761 | } | |
762 | else if ((word & 0xffff0010) == 0x13370010) { | |
763 | AliDebug(1, Form("stack %i: tracking done word: 0x%08x", stack, word)); | |
764 | continue; | |
765 | } | |
766 | else if ((idx & 0x1) == 0x1) { | |
767 | trackWord[1] = word; | |
768 | AliDebug(1, Form("track debug word: 0x%08x%08x", trackWord[1], trackWord[0])); | |
769 | // if (fTracks) { | |
770 | // AliESDTrdTrack *trk = new ((*fTracks)[fTracks->GetEntriesFast()]) AliESDTrdTrack(0, 0, trackWord[0], trackWord[1], fCurrEquipmentId-kDDLOffset); | |
771 | // if (TMath::Abs(trk->GetPt()) > 0.1) { | |
772 | // trk->SetA((Int_t) (0.15*51625./100./trk->GetPt() / 160e-4 * 2)); | |
773 | // } | |
774 | // trk->SetStack((trackWord[1] >> 28) & 0x7); | |
775 | // } | |
776 | } | |
777 | else { | |
778 | trackWord[0] = word; | |
779 | } | |
780 | idx++; | |
781 | } | |
782 | ||
783 | fPayloadCurr += fCurrTrkHeaderSize[stack]; | |
784 | ||
785 | return fCurrTrkHeaderSize[stack]; | |
786 | } | |
5fdfc9e4 | 787 | |
9cb9c409 | 788 | Int_t AliTRDrawStream::ReadTriggerHeaders() |
789 | { | |
790 | // read all trigger headers present | |
791 | ||
792 | AliDebug(1, Form("trigger mask: 0x%03x, fired: 0x%03x\n", | |
793 | fCurrTriggerEnable, fCurrTriggerFired)); | |
794 | // loop over potential trigger blocks | |
795 | for (Int_t iTrigger = 0; iTrigger < fgkNtriggers; iTrigger++) { | |
796 | // check for trigger enable | |
797 | if (fCurrTriggerEnable & (1 << iTrigger)) { | |
798 | // check for readout mode and trigger fired | |
799 | if ((fCurrTrgHeaderReadout == 0) || (fCurrTriggerFired & (1 << iTrigger))) { | |
800 | // index word | |
801 | AliDebug(1, Form("trigger index word %i: 0x%08x\n", iTrigger, *fPayloadCurr)); | |
802 | fCurrTrgHeaderIndexWord[iTrigger] = *fPayloadCurr; | |
a11bb3f3 | 803 | fCurrTrgHeaderSize[iTrigger] = ((*fPayloadCurr) >> 16) & 0x3ff; |
9cb9c409 | 804 | fPayloadCurr++; |
805 | // data words | |
806 | fPayloadCurr += fCurrTrgHeaderSize[iTrigger]; | |
807 | } | |
808 | } | |
809 | } | |
d60fe037 | 810 | |
9cb9c409 | 811 | return 0; |
d60fe037 | 812 | } |
813 | ||
9cb9c409 | 814 | Int_t AliTRDrawStream::ReadStackHeader(Int_t stack) |
d60fe037 | 815 | { |
9cb9c409 | 816 | // read the stack header |
d60fe037 | 817 | // and store the information in the corresponding variables |
818 | ||
819 | fCurrStackIndexWord[stack] = *fPayloadCurr; | |
820 | fCurrStackHeaderSize[stack] = (((*fPayloadCurr) >> 16) & 0xffff) + 1; | |
821 | fCurrStackHeaderVersion[stack] = ((*fPayloadCurr) >> 12) & 0xf; | |
822 | fCurrLinkMask[stack] = (*fPayloadCurr) & 0xfff; | |
823 | ||
9cb9c409 | 824 | // dumping stack header |
825 | AliDebug(1, DumpRaw(Form("stack %i header", stack), fPayloadCurr, fCurrStackHeaderSize[stack])); | |
826 | ||
67271412 | 827 | if (fPayloadCurr - fPayloadStart >= fPayloadSize - (Int_t) fCurrStackHeaderSize[stack]) { |
9cb9c409 | 828 | LinkError(kStackHeaderInvalid, "Stack index header aborted"); |
d60fe037 | 829 | return -1; |
830 | } | |
831 | ||
832 | switch (fCurrStackHeaderVersion[stack]) { | |
9cb9c409 | 833 | case 0xa: |
d60fe037 | 834 | if (fCurrStackHeaderSize[stack] < 8) { |
9cb9c409 | 835 | LinkError(kStackHeaderInvalid, "Stack header smaller than expected!"); |
d60fe037 | 836 | return -1; |
837 | } | |
9cb9c409 | 838 | |
d60fe037 | 839 | fCurrCleanCheckout[stack] = fPayloadCurr[1] & 0x1; |
840 | fCurrBoardId[stack] = (fPayloadCurr[1] >> 8) & 0xff; | |
9cb9c409 | 841 | fCurrHwRevTMU[stack] = (fPayloadCurr[1] >> 16) & 0xffff; |
842 | ||
d60fe037 | 843 | for (Int_t iLayer = 0; iLayer < 6; iLayer++) { |
844 | // A side | |
845 | fCurrLinkMonitorFlags [stack*fgkNlinks + iLayer*2] = fPayloadCurr[iLayer+2] & 0xf; | |
846 | fCurrLinkDataTypeFlags [stack*fgkNlinks + iLayer*2] = (fPayloadCurr[iLayer+2] >> 4) & 0x3; | |
847 | fCurrLinkDebugFlags [stack*fgkNlinks + iLayer*2] = (fPayloadCurr[iLayer+2] >> 12) & 0xf; | |
848 | // B side | |
849 | fCurrLinkMonitorFlags [stack*fgkNlinks + iLayer*2 + 1] = (fPayloadCurr[iLayer+2] >> 16) & 0xf; | |
850 | fCurrLinkDataTypeFlags [stack*fgkNlinks + iLayer*2 + 1] = (fPayloadCurr[iLayer+2] >> 20) & 0x3; | |
851 | fCurrLinkDebugFlags [stack*fgkNlinks + iLayer*2 + 1] = (fPayloadCurr[iLayer+2] >> 28) & 0xf; | |
852 | } | |
853 | break; | |
9cb9c409 | 854 | |
d60fe037 | 855 | default: |
9cb9c409 | 856 | LinkError(kStackHeaderInvalid, "Invalid Stack Header version %x", fCurrStackHeaderVersion[stack]); |
d60fe037 | 857 | } |
9cb9c409 | 858 | |
d60fe037 | 859 | fPayloadCurr += fCurrStackHeaderSize[stack]; |
860 | ||
861 | return fCurrStackHeaderSize[stack]; | |
862 | } | |
863 | ||
9cb9c409 | 864 | Int_t AliTRDrawStream::ReadGTUTrailer() |
865 | { | |
866 | // read the SM trailer containing CRCs from various stages | |
867 | ||
868 | UInt_t* trailer = fPayloadStart + fPayloadSize -1; | |
869 | ||
870 | // look for the trailer index word from the end | |
871 | for (Int_t iWord = 0; iWord < fPayloadSize; iWord++) { | |
872 | if ((fPayloadStart[fPayloadSize-1-iWord] & 0xffff) == 0x1f51) { | |
873 | trailer = fPayloadStart + fPayloadSize - 1 - iWord; | |
874 | break; | |
875 | } | |
876 | } | |
877 | ||
878 | if (((*trailer) & 0xffff) == 0x1f51) { | |
879 | UInt_t trailerIndexWord = (*trailer); | |
880 | Int_t trailerSize = (trailerIndexWord >> 16) & 0xffff; | |
881 | AliDebug(2, DumpRaw("GTU trailer", trailer, trailerSize+1)); | |
882 | // parse the trailer | |
883 | } | |
884 | else | |
885 | EquipmentError(kUnknown, "trailer index marker mismatch"); | |
886 | ||
887 | return 0; | |
888 | } | |
889 | ||
d60fe037 | 890 | Int_t AliTRDrawStream::ReadLinkData() |
891 | { | |
892 | // read the data in one link (one HC) until the data endmarker is reached | |
cc26f39c | 893 | // returns the number of words read! |
d60fe037 | 894 | |
895 | Int_t count = 0; | |
cc26f39c | 896 | UInt_t* startPosLink = fPayloadCurr; |
897 | ||
9cb9c409 | 898 | AliDebug(1, DumpRaw(Form("link data from seg %2i slot %i link %2i", fCurrEquipmentId-kDDLOffset, fCurrSlot, fCurrLink), |
899 | fPayloadCurr, TMath::Min((Int_t) (fPayloadSize - (fPayloadCurr-fPayloadStart)), 100), 0x00000000)); | |
d60fe037 | 900 | |
5fdfc9e4 | 901 | if (fMarkers) |
902 | new ((*fMarkers)[fMarkers->GetEntriesFast()]) | |
9cb9c409 | 903 | AliTRDrawStreamError(-kHCactive, fCurrEquipmentId-kDDLOffset, fCurrStack, fCurrLink); |
5fdfc9e4 | 904 | |
92223bf6 | 905 | if (fErrorFlags & kDiscardHC) |
906 | return count; | |
907 | ||
9cb9c409 | 908 | //??? add check whether tracklets are enabled |
d60fe037 | 909 | count += ReadTracklets(); |
92223bf6 | 910 | if (fErrorFlags & kDiscardHC) |
911 | return count; | |
d60fe037 | 912 | |
9cb9c409 | 913 | AliDebug(1, DumpRaw("HC header", fPayloadCurr, 4, 0x00000000)); |
d60fe037 | 914 | count += ReadHcHeader(); |
92223bf6 | 915 | if (fErrorFlags & kDiscardHC) |
916 | return count; | |
d60fe037 | 917 | |
918 | Int_t det = fCurrSm * 30 + fCurrStack * 6 + fCurrLayer; | |
919 | ||
920 | if (det > -1 && det < 540) { | |
921 | ||
922 | if ((fAdcArray = fDigitsManager->GetDigits(det))) { | |
923 | //fAdcArray->Expand(); | |
924 | if (fAdcArray->GetNtime() != fCurrNtimebins) | |
925 | fAdcArray->Allocate(16, 144, fCurrNtimebins); | |
926 | } | |
927 | else { | |
92223bf6 | 928 | LinkError(kNoDigits); |
d60fe037 | 929 | } |
930 | ||
931 | if (!fDigitsParam) { | |
932 | fDigitsParam = fDigitsManager->GetDigitsParam(); | |
933 | } | |
934 | if (fDigitsParam) { | |
935 | fDigitsParam->SetPretriggerPhase(det, fCurrPtrgPhase); | |
936 | fDigitsParam->SetNTimeBins(det, fCurrNtimebins); | |
937 | fDigitsParam->SetADCbaseline(det, 10); | |
938 | } | |
939 | ||
940 | if (fDigitsManager->UsesDictionaries()) { | |
941 | fDigitsManager->GetDictionary(det, 0)->Reset(); | |
942 | fDigitsManager->GetDictionary(det, 1)->Reset(); | |
943 | fDigitsManager->GetDictionary(det, 2)->Reset(); | |
944 | } | |
945 | ||
946 | if ((fSignalIndex = fDigitsManager->GetIndexes(det))) { | |
947 | fSignalIndex->SetSM(fCurrSm); | |
948 | fSignalIndex->SetStack(fCurrStack); | |
949 | fSignalIndex->SetLayer(fCurrLayer); | |
950 | fSignalIndex->SetDetNumber(det); | |
951 | if (!fSignalIndex->IsAllocated()) | |
952 | fSignalIndex->Allocate(16, 144, fCurrNtimebins); | |
953 | } | |
954 | ||
955 | // ----- check which kind of data ----- | |
956 | if (fCurrMajor & 0x40) { | |
957 | if ((fCurrMajor & 0x7) == 0x7) { | |
958 | AliDebug(1, "This is a config event"); | |
959 | UInt_t *startPos = fPayloadCurr; | |
960 | while (fPayloadCurr - fPayloadStart < fPayloadSize && | |
961 | *fPayloadCurr != fgkDataEndmarker) | |
962 | fPayloadCurr++; | |
963 | count += fPayloadCurr - startPos; | |
964 | ||
965 | // feeding TRAP config | |
966 | AliTRDtrapConfig *trapcfg = AliTRDtrapConfig::Instance(); | |
0508ca31 | 967 | trapcfg->ReadPackedConfig(fCurrHC, startPos, fPayloadCurr - startPos); |
d60fe037 | 968 | } |
969 | else { | |
970 | Int_t tpmode = fCurrMajor & 0x7; | |
971 | AliDebug(1, Form("Checking testpattern (mode %i) data", tpmode)); | |
972 | ReadTPData(tpmode); | |
973 | } | |
974 | } | |
975 | else if (fCurrMajor & 0x20) { | |
976 | AliDebug(1, "This is a zs event"); | |
977 | count += ReadZSData(); | |
978 | } | |
979 | else { | |
980 | AliDebug(1, "This is a nozs event"); | |
981 | count += ReadNonZSData(); | |
982 | } | |
983 | } | |
984 | else { | |
92223bf6 | 985 | LinkError(kInvalidDetector, "%i", det); |
d60fe037 | 986 | while (fPayloadCurr - fPayloadStart < fPayloadSize && |
987 | *fPayloadCurr != fgkDataEndmarker) | |
988 | fPayloadCurr++; | |
d60fe037 | 989 | } |
637666cd | 990 | |
991 | if (fCurrSm > -1 && fCurrSm < 18) { | |
992 | fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fBytes += (fPayloadCurr - startPosLink) * sizeof(UInt_t); | |
993 | fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fBytesRead += count * sizeof(UInt_t); | |
994 | fStats.fStatsSector[fCurrSm].fBytesRead += count * sizeof(UInt_t); | |
995 | fStats.fBytesRead += count * sizeof(UInt_t); | |
996 | } | |
cc26f39c | 997 | |
d60fe037 | 998 | return count; |
999 | } | |
1000 | ||
1001 | Int_t AliTRDrawStream::ReadTracklets() | |
1002 | { | |
1003 | // read the tracklets from one HC | |
1004 | ||
1005 | fTrackletArray->Clear(); | |
1006 | ||
1007 | UInt_t *start = fPayloadCurr; | |
1008 | while (*(fPayloadCurr) != fgkTrackletEndmarker && | |
1009 | fPayloadCurr - fPayloadStart < fPayloadSize) { | |
5fdfc9e4 | 1010 | new ((*fTrackletArray)[fTrackletArray->GetEntriesFast()]) AliTRDtrackletWord(*(fPayloadCurr), fCurrHC); |
d60fe037 | 1011 | |
1012 | fPayloadCurr++; | |
1013 | } | |
1014 | ||
1015 | if (fTrackletArray->GetEntriesFast() > 0) { | |
1016 | AliDebug(1, Form("Found %i tracklets in %i %i %i (ev. %i)", fTrackletArray->GetEntriesFast(), | |
9cb9c409 | 1017 | (fCurrEquipmentId-kDDLOffset), fCurrSlot, fCurrLink, fRawReader->GetEventIndex())); |
5fdfc9e4 | 1018 | if (fCurrSm > -1 && fCurrSm < 18) { |
1019 | fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fNTracklets += fTrackletArray->GetEntriesFast(); | |
1020 | fStats.fStatsSector[fCurrSm].fNTracklets += fTrackletArray->GetEntriesFast(); | |
1021 | } | |
d60fe037 | 1022 | if (fTrackletTree) |
1023 | fTrackletTree->Fill(); | |
5fdfc9e4 | 1024 | if (fTracklets) |
1025 | for (Int_t iTracklet = 0; iTracklet < fTrackletArray->GetEntriesFast(); iTracklet++) { | |
1026 | new ((*fTracklets)[fTracklets->GetEntriesFast()]) AliTRDtrackletWord(*((AliTRDtrackletWord*)(*fTrackletArray)[iTracklet])); | |
1027 | } | |
d60fe037 | 1028 | } |
1029 | ||
1030 | // loop over remaining tracklet endmarkers | |
1031 | while ((*(fPayloadCurr) == fgkTrackletEndmarker && | |
1032 | fPayloadCurr - fPayloadStart < fPayloadSize)) | |
1033 | fPayloadCurr++; | |
1034 | ||
cc26f39c | 1035 | return fPayloadCurr - start; |
d60fe037 | 1036 | } |
1037 | ||
1038 | Int_t AliTRDrawStream::ReadHcHeader() | |
1039 | { | |
1040 | // read and parse the HC header of one HC | |
1041 | // and store the information in the corresponding variables | |
1042 | ||
9cb9c409 | 1043 | AliDebug(1, Form("HC header: 0x%08x", *fPayloadCurr)); |
d60fe037 | 1044 | UInt_t *start = fPayloadCurr; |
1045 | // check not to be at the data endmarker | |
1046 | if (*fPayloadCurr == fgkDataEndmarker) | |
1047 | return 0; | |
1048 | ||
1049 | fCurrSpecial = (*fPayloadCurr >> 31) & 0x1; | |
1050 | fCurrMajor = (*fPayloadCurr >> 24) & 0x7f; | |
1051 | fCurrMinor = (*fPayloadCurr >> 17) & 0x7f; | |
1052 | fCurrAddHcWords = (*fPayloadCurr >> 14) & 0x7; | |
1053 | fCurrSm = (*fPayloadCurr >> 9) & 0x1f; | |
1054 | fCurrLayer = (*fPayloadCurr >> 6) & 0x7; | |
1055 | fCurrStack = (*fPayloadCurr >> 3) & 0x7; | |
1056 | fCurrSide = (*fPayloadCurr >> 2) & 0x1; | |
1057 | fCurrCheck = (*fPayloadCurr) & 0x3; | |
1058 | ||
9cb9c409 | 1059 | if ((fCurrSm != (((Int_t) fCurrEquipmentId) - kDDLOffset)) || |
1060 | (fCurrStack != fCurrSlot) || | |
1061 | (fCurrLayer != fCurrLink / 2) || | |
1062 | (fCurrSide != fCurrLink % 2)) { | |
92223bf6 | 1063 | LinkError(kHCmismatch, |
1064 | "HC: %i, %i, %i, %i\n 0x%08x 0x%08x 0x%08x 0x%08x", | |
1065 | fCurrSm, fCurrStack, fCurrLayer, fCurrSide, | |
9cb9c409 | 1066 | fPayloadCurr[0], fPayloadCurr[1], fPayloadCurr[2], fPayloadCurr[3]); |
d60fe037 | 1067 | } |
1068 | if (fCurrCheck != 0x1) { | |
92223bf6 | 1069 | LinkError(kHCcheckFailed); |
d60fe037 | 1070 | } |
1071 | ||
1072 | if (fCurrAddHcWords > 0) { | |
1073 | fCurrNtimebins = (fPayloadCurr[1] >> 26) & 0x3f; | |
1074 | fCurrBC = (fPayloadCurr[1] >> 10) & 0xffff; | |
1075 | fCurrPtrgCnt = (fPayloadCurr[1] >> 6) & 0xf; | |
1076 | fCurrPtrgPhase = (fPayloadCurr[1] >> 2) & 0xf; | |
1077 | } | |
1078 | ||
1079 | fPayloadCurr += 1 + fCurrAddHcWords; | |
1080 | ||
5fdfc9e4 | 1081 | return (fPayloadCurr - start); |
d60fe037 | 1082 | } |
1083 | ||
1084 | Int_t AliTRDrawStream::ReadTPData(Int_t mode) | |
1085 | { | |
1086 | // testing of testpattern 1 to 3 (hardcoded), 0 missing | |
1087 | // evcnt checking missing | |
1088 | Int_t cpu = 0; | |
1089 | Int_t cpufromchannel[] = {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3}; | |
1090 | Int_t evcnt = 0; | |
1091 | Int_t count = 0; | |
1092 | Int_t mcmcount = -1; | |
1093 | Int_t wordcount = 0; | |
1094 | Int_t channelcount = 0; | |
1095 | UInt_t expword = 0; | |
1096 | UInt_t expadcval = 0; | |
1097 | UInt_t diff = 0; | |
1098 | Int_t lastmcmpos = -1; | |
1099 | Int_t lastrobpos = -1; | |
1100 | ||
1101 | UInt_t* start = fPayloadCurr; | |
1102 | ||
1103 | while (*(fPayloadCurr) != fgkDataEndmarker && | |
1104 | fPayloadCurr - fPayloadStart < fPayloadSize - 1) { | |
1105 | ||
1106 | // ----- Checking MCM Header ----- | |
1107 | AliDebug(2, Form("MCM header: 0x%08x", *fPayloadCurr)); | |
1108 | mcmcount++; | |
1109 | ||
1110 | // ----- checking for proper readout order - ROB ----- | |
1111 | if (GetROBReadoutPos(ROB(*fPayloadCurr) / 2) >= lastrobpos) { | |
1112 | lastrobpos = GetROBReadoutPos(ROB(*fPayloadCurr) / 2); | |
1113 | } | |
1114 | else { | |
9cb9c409 | 1115 | ROBError(kPosUnexp, Form("#%i after #%i in readout order", GetROBReadoutPos(ROB(*fPayloadCurr) / 2), lastrobpos)); |
d60fe037 | 1116 | } |
1117 | fCurrRobPos = ROB(*fPayloadCurr); | |
1118 | ||
1119 | // ----- checking for proper readout order - MCM ----- | |
1120 | if (GetMCMReadoutPos(MCM(*fPayloadCurr)) >= (lastmcmpos + 1) % 16) { | |
1121 | lastmcmpos = GetMCMReadoutPos(MCM(*fPayloadCurr)); | |
1122 | } | |
1123 | else { | |
9cb9c409 | 1124 | MCMError(kPosUnexp, Form("#%i after #%i in readout order", GetMCMReadoutPos(MCM(*fPayloadCurr)), lastmcmpos)); |
d60fe037 | 1125 | } |
1126 | fCurrMcmPos = MCM(*fPayloadCurr); | |
1127 | ||
1128 | ||
1129 | fPayloadCurr++; | |
1130 | ||
1131 | evcnt = 0x3f & *fPayloadCurr >> 26; | |
1132 | cpu = -1; | |
1133 | channelcount = 0; | |
1134 | while (channelcount < 21) { | |
1135 | count = 0; | |
1136 | if (cpu != cpufromchannel[channelcount]) { | |
1137 | cpu = cpufromchannel[channelcount]; | |
1138 | expadcval = (1 << 9) | (fCurrRobPos << 6) | (fCurrMcmPos << 2) | cpu; | |
1139 | wordcount = 0; | |
1140 | } | |
1141 | ||
1142 | while (count < 10) { | |
1143 | if (channelcount % 2 == 0) | |
1144 | expword = 0x3; | |
1145 | else | |
1146 | expword = 0x2; | |
1147 | ||
1148 | if (mode == 1) { | |
1149 | // ----- TP 1 ----- | |
1150 | expword |= expadcval << 2; | |
1151 | expadcval = ( (expadcval << 1) | ( ( (expadcval >> 9) ^ (expadcval >> 6) ) & 1) ) & 0x3FF; | |
1152 | expword |= expadcval << 12; | |
1153 | expadcval = ( (expadcval << 1) | ( ( (expadcval >> 9) ^ (expadcval >> 6) ) & 1) ) & 0x3FF; | |
1154 | expword |= expadcval << 22; | |
1155 | expadcval = ( (expadcval << 1) | ( ( (expadcval >> 9) ^ (expadcval >> 6) ) & 1) ) & 0x3FF; | |
1156 | } | |
1157 | else if (mode == 2) { | |
1158 | // ----- TP 2 ------ | |
1159 | expword = ((0x3f & evcnt) << 26) | ((fCurrSm + 1) << 21) | ((fCurrLayer + 1) << 18) | | |
1160 | ((fCurrStack + 1) << 15) | | |
1161 | (fCurrRobPos << 12) | (fCurrMcmPos << 8) | (cpu << 6) | (wordcount + 1); | |
1162 | } | |
1163 | else if (mode == 3) { | |
1164 | // ----- TP 3 ----- | |
1165 | expword = ((0xfff & evcnt) << 20) | (fCurrSm << 15) | (fCurrLink/2 << 12) | (fCurrStack << 9) | | |
1166 | (fCurrRobPos << 6) | (fCurrMcmPos << 2) | (cpu << 0); | |
1167 | } | |
1168 | else { | |
1169 | expword = 0; | |
92223bf6 | 1170 | LinkError(kTPmodeInvalid, "Just reading"); |
d60fe037 | 1171 | } |
1172 | ||
1173 | diff = *fPayloadCurr ^ expword; | |
1174 | if (diff != 0) { | |
92223bf6 | 1175 | MCMError(kTPmismatch, |
1176 | "Seen 0x%08x, expected 0x%08x, diff: 0x%08x (0x%02x)", | |
1177 | *fPayloadCurr, expword, diff, 0xff & (diff | diff >> 8 | diff >> 16 | diff >> 24));; | |
d60fe037 | 1178 | } |
1179 | fPayloadCurr++; | |
1180 | count++; | |
1181 | wordcount++; | |
1182 | } | |
1183 | channelcount++; | |
1184 | } | |
1185 | // continue with next MCM | |
1186 | } | |
1187 | return fPayloadCurr - start; | |
1188 | } | |
1189 | ||
1190 | ||
1191 | Int_t AliTRDrawStream::ReadZSData() | |
1192 | { | |
1193 | // read the zs data from one link from the current reading position | |
1194 | ||
1195 | UInt_t *start = fPayloadCurr; | |
1196 | ||
1197 | Int_t mcmcount = 0; | |
0508ca31 | 1198 | Int_t mcmcountExp = fCurrStack == 2 ? 48 : 64; |
d60fe037 | 1199 | Int_t channelcount = 0; |
0508ca31 | 1200 | Int_t channelcountExp = 0; |
1201 | Int_t channelcountMax = 0; | |
d60fe037 | 1202 | Int_t timebins; |
1203 | Int_t currentTimebin = 0; | |
1204 | Int_t adcwc = 0; | |
1205 | Int_t evno = -1; | |
1206 | Int_t lastmcmpos = -1; | |
1207 | Int_t lastrobpos = -1; | |
1208 | ||
1209 | if (fCurrNtimebins != fNtimebins) { | |
1210 | if (fNtimebins > 0) | |
92223bf6 | 1211 | LinkError(kNtimebinsChanged, |
1212 | "No. of timebins changed from %i to %i", fNtimebins, fCurrNtimebins); | |
d60fe037 | 1213 | fNtimebins = fCurrNtimebins; |
1214 | } | |
1215 | ||
1216 | timebins = fNtimebins; | |
1217 | ||
1218 | while (*(fPayloadCurr) != fgkDataEndmarker && | |
1219 | fPayloadCurr - fPayloadStart < fPayloadSize) { | |
1220 | ||
1221 | // ----- Checking MCM Header ----- | |
9cb9c409 | 1222 | AliDebug(2, DumpMcmHeader("MCM header: ", *fPayloadCurr)); |
cc26f39c | 1223 | UInt_t *startPosMCM = fPayloadCurr; |
d60fe037 | 1224 | |
1225 | // ----- checking for proper readout order - ROB ----- | |
1226 | if (GetROBReadoutPos(ROB(*fPayloadCurr) / 2) >= lastrobpos) { | |
9cb9c409 | 1227 | if (GetROBReadoutPos(ROB(*fPayloadCurr) / 2) > lastrobpos) |
1228 | lastmcmpos = -1; | |
d60fe037 | 1229 | lastrobpos = GetROBReadoutPos(ROB(*fPayloadCurr) / 2); |
1230 | } | |
1231 | else { | |
9cb9c409 | 1232 | ROBError(kPosUnexp, Form("#%i after #%i and #%i in readout order", |
1233 | GetROBReadoutPos(ROB(*fPayloadCurr) / 2), lastrobpos, GetROBReadoutPos(fCurrRobPos))); | |
d60fe037 | 1234 | } |
1235 | fCurrRobPos = ROB(*fPayloadCurr); | |
1236 | ||
1237 | // ----- checking for proper readout order - MCM ----- | |
1238 | if (GetMCMReadoutPos(MCM(*fPayloadCurr)) > lastmcmpos) { | |
9cb9c409 | 1239 | lastmcmpos = GetMCMReadoutPos(MCM(*fPayloadCurr)); |
d60fe037 | 1240 | } |
1241 | else { | |
9cb9c409 | 1242 | MCMError(kPosUnexp, Form("#%i after #%i and #%i in readout order", |
1243 | GetMCMReadoutPos(MCM(*fPayloadCurr)), lastmcmpos, GetMCMReadoutPos(fCurrMcmPos))); | |
d60fe037 | 1244 | } |
1245 | fCurrMcmPos = MCM(*fPayloadCurr); | |
1246 | ||
1247 | if (EvNo(*fPayloadCurr) != evno) { | |
1248 | if (evno == -1) | |
1249 | evno = EvNo(*fPayloadCurr); | |
1250 | else { | |
92223bf6 | 1251 | MCMError(kPtrgCntMismatch, "%i <-> %i", evno, EvNo(*fPayloadCurr)); |
d60fe037 | 1252 | } |
1253 | } | |
1254 | Int_t adccoloff = AdcColOffset(*fPayloadCurr); | |
1255 | Int_t padcoloff = PadColOffset(*fPayloadCurr); | |
1256 | Int_t row = Row(*fPayloadCurr); | |
1257 | fPayloadCurr++; | |
1258 | ||
1259 | // ----- Reading ADC channels ----- | |
9cb9c409 | 1260 | AliDebug(2, DumpAdcMask("ADC mask: ", *fPayloadCurr)); |
d60fe037 | 1261 | |
1262 | // ----- analysing the ADC mask ----- | |
1263 | channelcount = 0; | |
0508ca31 | 1264 | channelcountExp = GetNActiveChannelsFromMask(*fPayloadCurr); |
1265 | channelcountMax = GetNActiveChannels(*fPayloadCurr); | |
d60fe037 | 1266 | Int_t channelmask = GetActiveChannels(*fPayloadCurr); |
1267 | Int_t channelno = -1; | |
1268 | fPayloadCurr++; | |
1269 | ||
0508ca31 | 1270 | if (channelcountExp != channelcountMax) { |
1271 | if (channelcountExp > channelcountMax) { | |
1272 | Int_t temp = channelcountExp; | |
1273 | channelcountExp = channelcountMax; | |
1274 | channelcountMax = temp; | |
d60fe037 | 1275 | } |
0508ca31 | 1276 | while (channelcountExp < channelcountMax && channelcountExp < 21 && |
1277 | fPayloadCurr - fPayloadStart < fPayloadSize - 10 * channelcountExp - 1) { | |
92223bf6 | 1278 | MCMError(kAdcMaskInconsistent, |
1279 | "Possible MCM-H: 0x%08x, possible ADC-mask: 0x%08x", | |
1280 | *(fPayloadCurr + 10 * channelcountExp), | |
1281 | *(fPayloadCurr + 10 * channelcountExp + 1) ); | |
0508ca31 | 1282 | if (!CouldBeMCMhdr( *(fPayloadCurr + 10 * channelcountExp)) && !CouldBeADCmask( *(fPayloadCurr + 10 * channelcountExp + 1))) |
1283 | channelcountExp++; | |
d60fe037 | 1284 | else { |
1285 | break; | |
1286 | } | |
1287 | } | |
92223bf6 | 1288 | MCMError(kAdcMaskInconsistent, |
1289 | "Inconsistency in no. of active channels: Counter: %i, Mask: %i, chosen: %i!", | |
1290 | GetNActiveChannels(fPayloadCurr[-1]), GetNActiveChannelsFromMask(fPayloadCurr[-1]), channelcountExp); | |
d60fe037 | 1291 | } |
9cb9c409 | 1292 | AliDebug(2, Form("expecting %i active channels, %i timebins", channelcountExp, fCurrNtimebins)); |
d60fe037 | 1293 | |
1294 | // ----- reading marked ADC channels ----- | |
0508ca31 | 1295 | while (channelcount < channelcountExp && *(fPayloadCurr) != fgkDataEndmarker) { |
e29e514c | 1296 | if (channelno < 20) |
d60fe037 | 1297 | channelno++; |
e29e514c | 1298 | while (channelno < 20 && (channelmask & 1 << channelno) == 0) |
d60fe037 | 1299 | channelno++; |
1300 | ||
1301 | if (fCurrNtimebins > 30) { | |
1302 | currentTimebin = ((*fPayloadCurr >> 2) & 0x3f); | |
1303 | timebins = ((*fPayloadCurr >> 8) & 0xf) * 3; | |
1304 | } | |
1305 | else { | |
1306 | currentTimebin = 0; | |
1307 | } | |
1308 | ||
1309 | adcwc = 0; | |
9cb9c409 | 1310 | AliDebug(3, Form("Now reading %i words for channel %2i", timebins / 3, channelno)); |
d60fe037 | 1311 | Int_t adccol = adccoloff - channelno; |
1312 | Int_t padcol = padcoloff - channelno; | |
cc26f39c | 1313 | // if (adccol < 3 || adccol > 165) |
1314 | // AliInfo(Form("writing channel %i of det %3i %i:%2i to adcrow/-col: %i/%i padcol: %i", | |
1315 | // channelno, fCurrHC/2, fCurrRobPos, fCurrMcmPos, row, adccol, padcol)); | |
1316 | ||
d60fe037 | 1317 | while (adcwc < timebins / 3 && |
1318 | *(fPayloadCurr) != fgkDataEndmarker && | |
1319 | fPayloadCurr - fPayloadStart < fPayloadSize) { | |
1320 | int check = 0x3 & *fPayloadCurr; | |
1321 | if (channelno % 2 != 0) { // odd channel | |
1322 | if (check != 0x2 && channelno < 21) { | |
92223bf6 | 1323 | MCMError(kAdcCheckInvalid, |
1324 | "%i for %2i. ADC word in odd channel %i", | |
1325 | check, adcwc+1, channelno); | |
d60fe037 | 1326 | } |
1327 | } | |
1328 | else { // even channel | |
1329 | if (check != 0x3 && channelno < 21) { | |
92223bf6 | 1330 | MCMError(kAdcCheckInvalid, |
1331 | "%i for %2i. ADC word in even channel %i", | |
1332 | check, adcwc+1, channelno); | |
d60fe037 | 1333 | } |
1334 | } | |
1335 | ||
1336 | // filling the actual timebin data | |
1337 | int tb2 = 0x3ff & *fPayloadCurr >> 22; | |
1338 | int tb1 = 0x3ff & *fPayloadCurr >> 12; | |
1339 | int tb0 = 0x3ff & *fPayloadCurr >> 2; | |
1340 | if (adcwc != 0 || fCurrNtimebins <= 30) | |
1341 | fAdcArray->SetDataByAdcCol(row, adccol, currentTimebin++, tb0); | |
1342 | else | |
1343 | tb0 = -1; | |
1344 | fAdcArray->SetDataByAdcCol(row, adccol, currentTimebin++, tb1); | |
1345 | fAdcArray->SetDataByAdcCol(row, adccol, currentTimebin++, tb2); | |
1346 | ||
1347 | adcwc++; | |
1348 | fPayloadCurr++; | |
1349 | } | |
1350 | ||
1351 | if (adcwc != timebins / 3) | |
92223bf6 | 1352 | MCMError(kAdcDataAbort); |
d60fe037 | 1353 | |
1354 | // adding index | |
1355 | if (padcol > 0 && padcol < 144) { | |
1356 | fSignalIndex->AddIndexRC(row, padcol); | |
1357 | } | |
1358 | ||
1359 | channelcount++; | |
1360 | } | |
cc26f39c | 1361 | |
637666cd | 1362 | if (fCurrSm > -1 && fCurrSm < 18) { |
1363 | fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fNChannels += channelcount; | |
1364 | fStats.fStatsSector[fCurrSm].fNChannels += channelcount; | |
1365 | } | |
0508ca31 | 1366 | if (channelcount != channelcountExp) |
92223bf6 | 1367 | MCMError(kAdcChannelsMiss); |
d60fe037 | 1368 | |
1369 | mcmcount++; | |
637666cd | 1370 | if (fCurrSm > -1 && fCurrSm < 18) { |
1371 | fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fNMCMs++; | |
1372 | fStats.fStatsSector[fCurrSm].fNMCMs++; | |
1373 | } | |
cc26f39c | 1374 | |
1375 | if (IsDumping() && DumpingMCM(fCurrHC/2, fCurrRobPos, fCurrMcmPos)) { | |
9cb9c409 | 1376 | AliInfo(DumpRaw(Form("Event %i: Det %3i ROB %i MCM %2i", fRawReader->GetEventIndex(), fCurrHC/2, fCurrRobPos, fCurrMcmPos), |
1377 | startPosMCM, fPayloadCurr - startPosMCM)); | |
cc26f39c | 1378 | } |
1379 | ||
d60fe037 | 1380 | // continue with next MCM |
1381 | } | |
1382 | ||
1383 | // check for missing MCMs (if header suppression is inactive) | |
67271412 | 1384 | if (((fCurrMajor & 0x1) == 0) && (mcmcount != mcmcountExp)) { |
92223bf6 | 1385 | LinkError(kMissMcmHeaders, |
1386 | "No. of MCM headers %i not as expected: %i", | |
1387 | mcmcount, mcmcountExp); | |
d60fe037 | 1388 | } |
1389 | ||
1390 | return (fPayloadCurr - start); | |
1391 | } | |
1392 | ||
1393 | Int_t AliTRDrawStream::ReadNonZSData() | |
1394 | { | |
1395 | // read the non-zs data from one link from the current reading position | |
1396 | ||
1397 | UInt_t *start = fPayloadCurr; | |
1398 | ||
1399 | Int_t mcmcount = 0; | |
0508ca31 | 1400 | Int_t mcmcountExp = fCurrStack == 2 ? 48 : 64; |
d60fe037 | 1401 | Int_t channelcount = 0; |
0508ca31 | 1402 | Int_t channelcountExp = 0; |
d60fe037 | 1403 | Int_t timebins; |
1404 | Int_t currentTimebin = 0; | |
1405 | Int_t adcwc = 0; | |
1406 | Int_t evno = -1; | |
1407 | Int_t lastmcmpos = -1; | |
1408 | Int_t lastrobpos = -1; | |
1409 | ||
1410 | if (fCurrNtimebins != fNtimebins) { | |
1411 | if (fNtimebins > 0) | |
92223bf6 | 1412 | LinkError(kNtimebinsChanged, |
1413 | "No. of timebins changed from %i to %i", fNtimebins, fCurrNtimebins); | |
d60fe037 | 1414 | fNtimebins = fCurrNtimebins; |
1415 | } | |
1416 | ||
1417 | timebins = fNtimebins; | |
1418 | ||
1419 | while (*(fPayloadCurr) != fgkDataEndmarker && | |
1420 | fPayloadCurr - fPayloadStart < fPayloadSize - 2) { | |
1421 | ||
1422 | // ----- Checking MCM Header ----- | |
1423 | AliDebug(2, Form("MCM header: 0x%08x", *fPayloadCurr)); | |
1424 | ||
1425 | // ----- checking for proper readout order - ROB ----- | |
1426 | if (GetROBReadoutPos(ROB(*fPayloadCurr) / 2) >= lastrobpos) { | |
1427 | lastrobpos = GetROBReadoutPos(ROB(*fPayloadCurr) / 2); | |
1428 | } | |
1429 | else { | |
9cb9c409 | 1430 | ROBError(kPosUnexp, Form("#%i after #%i in readout order", GetROBReadoutPos(ROB(*fPayloadCurr) / 2), lastrobpos)); |
d60fe037 | 1431 | } |
1432 | fCurrRobPos = ROB(*fPayloadCurr); | |
1433 | ||
1434 | // ----- checking for proper readout order - MCM ----- | |
1435 | if (GetMCMReadoutPos(MCM(*fPayloadCurr)) >= (lastmcmpos + 1) % 16) { | |
9cb9c409 | 1436 | lastmcmpos = GetMCMReadoutPos(MCM(*fPayloadCurr)); |
d60fe037 | 1437 | } |
1438 | else { | |
9cb9c409 | 1439 | MCMError(kPosUnexp, Form("#%i after #%i in readout order", GetMCMReadoutPos(MCM(*fPayloadCurr)), lastmcmpos)); |
d60fe037 | 1440 | } |
1441 | fCurrMcmPos = MCM(*fPayloadCurr); | |
1442 | ||
1443 | if (EvNo(*fPayloadCurr) != evno) { | |
1444 | if (evno == -1) | |
1445 | evno = EvNo(*fPayloadCurr); | |
1446 | else { | |
92223bf6 | 1447 | MCMError(kPtrgCntMismatch, "%i <-> %i", evno, EvNo(*fPayloadCurr)); |
d60fe037 | 1448 | } |
1449 | } | |
1450 | ||
1451 | channelcount = 0; | |
0508ca31 | 1452 | channelcountExp = 21; |
d60fe037 | 1453 | int channelno = -1; |
1454 | ||
1455 | Int_t adccoloff = AdcColOffset(*fPayloadCurr); | |
1456 | Int_t padcoloff = PadColOffset(*fPayloadCurr); | |
1457 | Int_t row = Row(*fPayloadCurr); | |
1458 | ||
1459 | fPayloadCurr++; | |
1460 | ||
1461 | // ----- reading marked ADC channels ----- | |
0508ca31 | 1462 | while (channelcount < channelcountExp && |
d60fe037 | 1463 | *(fPayloadCurr) != fgkDataEndmarker) { |
e29e514c | 1464 | if (channelno < 20) |
d60fe037 | 1465 | channelno++; |
1466 | ||
1467 | currentTimebin = 0; | |
1468 | ||
1469 | adcwc = 0; | |
1470 | AliDebug(2, Form("Now looking %i words", timebins / 3)); | |
1471 | Int_t adccol = adccoloff - channelno; | |
1472 | Int_t padcol = padcoloff - channelno; | |
1473 | while (adcwc < timebins / 3 && | |
1474 | *(fPayloadCurr) != fgkDataEndmarker && | |
1475 | fPayloadCurr - fPayloadStart < fPayloadSize) { | |
1476 | int check = 0x3 & *fPayloadCurr; | |
1477 | if (channelno % 2 != 0) { // odd channel | |
1478 | if (check != 0x2 && channelno < 21) { | |
92223bf6 | 1479 | MCMError(kAdcCheckInvalid, |
1480 | "%i for %2i. ADC word in odd channel %i", | |
1481 | check, adcwc+1, channelno); | |
d60fe037 | 1482 | } |
1483 | } | |
1484 | else { // even channel | |
1485 | if (check != 0x3 && channelno < 21) { | |
92223bf6 | 1486 | MCMError(kAdcCheckInvalid, |
1487 | "%i for %2i. ADC word in even channel %i", | |
1488 | check, adcwc+1, channelno); | |
d60fe037 | 1489 | } |
1490 | } | |
1491 | ||
1492 | // filling the actual timebin data | |
1493 | int tb2 = 0x3ff & *fPayloadCurr >> 22; | |
1494 | int tb1 = 0x3ff & *fPayloadCurr >> 12; | |
1495 | int tb0 = 0x3ff & *fPayloadCurr >> 2; | |
1496 | if (adcwc != 0 || fCurrNtimebins <= 30) | |
1497 | fAdcArray->SetDataByAdcCol(row, adccol, currentTimebin++, tb0); | |
1498 | else | |
1499 | tb0 = -1; | |
1500 | fAdcArray->SetDataByAdcCol(row, adccol, currentTimebin++, tb1); | |
1501 | fAdcArray->SetDataByAdcCol(row, adccol, currentTimebin++, tb2); | |
1502 | ||
1503 | adcwc++; | |
1504 | fPayloadCurr++; | |
1505 | } | |
1506 | ||
1507 | if (adcwc != timebins / 3) | |
92223bf6 | 1508 | MCMError(kAdcDataAbort); |
d60fe037 | 1509 | |
1510 | // adding index | |
1511 | if (padcol > 0 && padcol < 144) { | |
1512 | fSignalIndex->AddIndexRC(row, padcol); | |
1513 | } | |
1514 | ||
1515 | channelcount++; | |
1516 | } | |
1517 | ||
0508ca31 | 1518 | if (channelcount != channelcountExp) |
92223bf6 | 1519 | MCMError(kAdcChannelsMiss); |
d60fe037 | 1520 | mcmcount++; |
1521 | // continue with next MCM | |
1522 | } | |
1523 | ||
1524 | // check for missing MCMs (if header suppression is inactive) | |
0508ca31 | 1525 | if (mcmcount != mcmcountExp) { |
92223bf6 | 1526 | LinkError(kMissMcmHeaders, |
1527 | "%i not as expected: %i", mcmcount, mcmcountExp); | |
d60fe037 | 1528 | } |
1529 | ||
1530 | return (fPayloadCurr - start); | |
1531 | } | |
1532 | ||
92223bf6 | 1533 | Int_t AliTRDrawStream::SeekNextLink() |
1534 | { | |
92305359 | 1535 | // proceed in raw data stream till the next link |
1536 | ||
92223bf6 | 1537 | UInt_t *start = fPayloadCurr; |
1538 | ||
1539 | // read until data endmarkers | |
1540 | while (fPayloadCurr - fPayloadStart < fPayloadSize && | |
1541 | *fPayloadCurr != fgkDataEndmarker) | |
1542 | fPayloadCurr++; | |
1543 | ||
1544 | // read all data endmarkers | |
1545 | while (fPayloadCurr - fPayloadStart < fPayloadSize && | |
1546 | *fPayloadCurr == fgkDataEndmarker) | |
1547 | fPayloadCurr++; | |
1548 | ||
1549 | return (fPayloadCurr - start); | |
1550 | } | |
1551 | ||
67271412 | 1552 | Bool_t AliTRDrawStream::ConnectTracklets(TTree *trklTree) |
1553 | { | |
92305359 | 1554 | // connect the tracklet tree used to store the tracklet output |
1555 | ||
67271412 | 1556 | fTrackletTree = trklTree; |
1557 | if (!fTrackletTree) | |
1558 | return kTRUE; | |
1559 | ||
cc26f39c | 1560 | if (!fTrackletTree->GetBranch("hc")) |
67271412 | 1561 | fTrackletTree->Branch("hc", &fCurrHC, "hc/I"); |
cc26f39c | 1562 | else |
67271412 | 1563 | fTrackletTree->SetBranchAddress("hc", &fCurrHC); |
cc26f39c | 1564 | |
1565 | if (!fTrackletTree->GetBranch("trkl")) | |
1566 | fTrackletTree->Branch("trkl", &fTrackletArray); | |
1567 | else | |
67271412 | 1568 | fTrackletTree->SetBranchAddress("trkl", &fTrackletArray); |
cc26f39c | 1569 | |
67271412 | 1570 | return kTRUE; |
1571 | } | |
1572 | ||
1573 | ||
1d62be37 | 1574 | void AliTRDrawStream::EquipmentError(ErrorCode_t err, const char *const msg, ...) |
d60fe037 | 1575 | { |
0508ca31 | 1576 | // register error according to error code on equipment level |
1577 | // and return the corresponding error message | |
1578 | ||
9cb9c409 | 1579 | fLastError.fSector = fCurrEquipmentId - kDDLOffset; |
d60fe037 | 1580 | fLastError.fStack = -1; |
1581 | fLastError.fLink = -1; | |
1582 | fLastError.fRob = -1; | |
1583 | fLastError.fMcm = -1; | |
1584 | fLastError.fError = err; | |
f4b3235e | 1585 | (this->*fStoreError)(); |
d60fe037 | 1586 | |
92223bf6 | 1587 | va_list ap; |
1588 | if (fgErrorDebugLevel[err] > 10) | |
1589 | AliDebug(fgErrorDebugLevel[err], | |
1590 | Form("Event %6i: Eq. %2d - %s : %s", | |
92305359 | 1591 | fRawReader->GetEventIndex(), fCurrEquipmentId, fgkErrorMessages[err], |
1d62be37 | 1592 | (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) )); |
92223bf6 | 1593 | else |
1594 | AliError(Form("Event %6i: Eq. %2d - %s : %s", | |
92305359 | 1595 | fRawReader->GetEventIndex(), fCurrEquipmentId, fgkErrorMessages[err], |
1d62be37 | 1596 | (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) )); |
92223bf6 | 1597 | fErrorFlags |= fgErrorBehav[err]; |
d60fe037 | 1598 | } |
1599 | ||
1600 | ||
1d62be37 | 1601 | void AliTRDrawStream::StackError(ErrorCode_t err, const char *const msg, ...) |
d60fe037 | 1602 | { |
0508ca31 | 1603 | // register error according to error code on stack level |
1604 | // and return the corresponding error message | |
1605 | ||
9cb9c409 | 1606 | fLastError.fSector = fCurrEquipmentId - kDDLOffset; |
d60fe037 | 1607 | fLastError.fStack = fCurrSlot; |
1608 | fLastError.fLink = -1; | |
1609 | fLastError.fRob = -1; | |
1610 | fLastError.fMcm = -1; | |
1611 | fLastError.fError = err; | |
f4b3235e | 1612 | (this->*fStoreError)(); |
d60fe037 | 1613 | |
92223bf6 | 1614 | va_list ap; |
e29e514c | 1615 | if (fgErrorDebugLevel[err] > 0) |
92223bf6 | 1616 | AliDebug(fgErrorDebugLevel[err], |
1617 | Form("Event %6i: Eq. %2d S %i - %s : %s", | |
92305359 | 1618 | fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fgkErrorMessages[err], |
1d62be37 | 1619 | (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) )); |
92223bf6 | 1620 | else |
1621 | AliError(Form("Event %6i: Eq. %2d S %i - %s : %s", | |
92305359 | 1622 | fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fgkErrorMessages[err], |
1d62be37 | 1623 | (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) )); |
92223bf6 | 1624 | fErrorFlags |= fgErrorBehav[err]; |
d60fe037 | 1625 | } |
1626 | ||
1627 | ||
1d62be37 | 1628 | void AliTRDrawStream::LinkError(ErrorCode_t err, const char *const msg, ...) |
d60fe037 | 1629 | { |
0508ca31 | 1630 | // register error according to error code on link level |
1631 | // and return the corresponding error message | |
1632 | ||
9cb9c409 | 1633 | fLastError.fSector = fCurrEquipmentId - kDDLOffset; |
d60fe037 | 1634 | fLastError.fStack = fCurrSlot; |
1635 | fLastError.fLink = fCurrLink; | |
1636 | fLastError.fRob = -1; | |
1637 | fLastError.fMcm = -1; | |
1638 | fLastError.fError = err; | |
f4b3235e | 1639 | (this->*fStoreError)(); |
d60fe037 | 1640 | |
92223bf6 | 1641 | va_list ap; |
e29e514c | 1642 | if (fgErrorDebugLevel[err] > 0) |
92223bf6 | 1643 | AliDebug(fgErrorDebugLevel[err], |
1644 | Form("Event %6i: Eq. %2d S %i l %2i - %s : %s", | |
92305359 | 1645 | fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fCurrLink, fgkErrorMessages[err], |
1d62be37 | 1646 | (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) )); |
92223bf6 | 1647 | else |
1648 | AliError(Form("Event %6i: Eq. %2d S %i l %2i - %s : %s", | |
92305359 | 1649 | fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fCurrLink, fgkErrorMessages[err], |
1d62be37 | 1650 | (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) )); |
92223bf6 | 1651 | fErrorFlags |= fgErrorBehav[err]; |
d60fe037 | 1652 | } |
1653 | ||
1654 | ||
1d62be37 | 1655 | void AliTRDrawStream::ROBError(ErrorCode_t err, const char *const msg, ...) |
d60fe037 | 1656 | { |
0508ca31 | 1657 | // register error according to error code on ROB level |
1658 | // and return the corresponding error message | |
1659 | ||
9cb9c409 | 1660 | fLastError.fSector = fCurrEquipmentId - kDDLOffset; |
d60fe037 | 1661 | fLastError.fStack = fCurrSlot; |
1662 | fLastError.fLink = fCurrLink; | |
1663 | fLastError.fRob = fCurrRobPos; | |
1664 | fLastError.fMcm = -1; | |
1665 | fLastError.fError = err; | |
f4b3235e | 1666 | (this->*fStoreError)(); |
d60fe037 | 1667 | |
92223bf6 | 1668 | va_list ap; |
e29e514c | 1669 | if (fgErrorDebugLevel[err] > 0) |
92223bf6 | 1670 | AliDebug(fgErrorDebugLevel[err], |
1671 | Form("Event %6i: Eq. %2d S %i l %2i ROB %i - %s : %s", | |
92305359 | 1672 | fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fCurrLink, fCurrRobPos, fgkErrorMessages[err], |
1d62be37 | 1673 | (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) )); |
92223bf6 | 1674 | else |
1675 | AliError(Form("Event %6i: Eq. %2d S %i l %2i ROB %i - %s : %s", | |
92305359 | 1676 | fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fCurrLink, fCurrRobPos, fgkErrorMessages[err], |
1d62be37 | 1677 | (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) )); |
92223bf6 | 1678 | fErrorFlags |= fgErrorBehav[err]; |
d60fe037 | 1679 | } |
1680 | ||
1681 | ||
1d62be37 | 1682 | void AliTRDrawStream::MCMError(ErrorCode_t err, const char *const msg, ...) |
d60fe037 | 1683 | { |
0508ca31 | 1684 | // register error according to error code on MCM level |
1685 | // and return the corresponding error message | |
1686 | ||
9cb9c409 | 1687 | fLastError.fSector = fCurrEquipmentId - kDDLOffset; |
d60fe037 | 1688 | fLastError.fStack = fCurrSlot; |
1689 | fLastError.fLink = fCurrLink; | |
1690 | fLastError.fRob = fCurrRobPos; | |
1691 | fLastError.fMcm = fCurrMcmPos; | |
1692 | fLastError.fError = err; | |
f4b3235e | 1693 | (this->*fStoreError)(); |
d60fe037 | 1694 | |
92223bf6 | 1695 | va_list ap; |
e29e514c | 1696 | if (fgErrorDebugLevel[err] > 0) |
92223bf6 | 1697 | AliDebug(fgErrorDebugLevel[err], |
1698 | Form("Event %6i: Eq. %2d S %i l %2i ROB %i MCM %2i - %s : %s", | |
92305359 | 1699 | fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fCurrLink, fCurrRobPos, fCurrMcmPos, fgkErrorMessages[err], |
1d62be37 | 1700 | (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) )); |
92223bf6 | 1701 | else |
1702 | AliError(Form("Event %6i: Eq. %2d S %i l %2i ROB %i MCM %2i - %s : %s", | |
92305359 | 1703 | fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fCurrLink, fCurrRobPos, fCurrMcmPos, fgkErrorMessages[err], |
1d62be37 | 1704 | (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) )); |
92223bf6 | 1705 | fErrorFlags |= fgErrorBehav[err]; |
d60fe037 | 1706 | } |
1707 | ||
1708 | const char* AliTRDrawStream::GetErrorMessage(ErrorCode_t errCode) | |
1709 | { | |
0508ca31 | 1710 | // return the error message for the given error code |
1711 | ||
d60fe037 | 1712 | if (errCode > 0 && errCode < kLastErrorCode) |
92305359 | 1713 | return fgkErrorMessages[errCode]; |
d60fe037 | 1714 | else |
1715 | return ""; | |
1716 | } | |
cc26f39c | 1717 | |
1718 | void AliTRDrawStream::AliTRDrawStats::ClearStats() | |
1719 | { | |
1720 | // clear statistics (includes clearing sector-wise statistics) | |
1721 | ||
1722 | fBytesRead = 0; | |
1723 | for (Int_t iSector = 0; iSector < 18; iSector++) { | |
1724 | fStatsSector[iSector].ClearStats(); | |
1725 | } | |
1726 | ||
1727 | } | |
1728 | ||
1729 | void AliTRDrawStream::AliTRDrawStats::AliTRDrawStatsSector::ClearStats() | |
1730 | { | |
1731 | // clear statistics (includes clearing HC-wise statistics) | |
1732 | ||
1733 | fBytes = 0; | |
1734 | fBytesRead = 0; | |
1735 | fNTracklets = 0; | |
1736 | fNMCMs = 0; | |
1737 | fNChannels = 0; | |
1738 | ||
1739 | for (Int_t iHC = 0; iHC < 60; iHC++) { | |
1740 | fStatsHC[iHC].ClearStats(); | |
1741 | } | |
1742 | } | |
1743 | ||
1744 | void AliTRDrawStream::AliTRDrawStats::AliTRDrawStatsSector::AliTRDrawStatsHC::ClearStats() | |
1745 | { | |
1746 | // clear statistics | |
1747 | ||
1748 | fBytes = 0; | |
1749 | fBytesRead = 0; | |
1750 | fNTracklets = 0; | |
1751 | fNMCMs = 0; | |
1752 | fNChannels = 0; | |
1753 | } | |
1754 | ||
1755 | void AliTRDrawStream::SetDumpMCM(Int_t det, Int_t rob, Int_t mcm, Bool_t dump) | |
1756 | { | |
1757 | // mark MCM for dumping of raw data | |
1758 | ||
1759 | if (dump) { | |
1760 | fDumpMCM[fNDumpMCMs++] = (det << 7) | (rob << 4) | mcm; | |
1761 | } | |
1762 | else { | |
1763 | Int_t iMCM; | |
1764 | for (iMCM = 0; iMCM < fNDumpMCMs; iMCM++) { | |
1765 | if (fDumpMCM[iMCM] == ((det << 7) | (rob << 4) | mcm)) { | |
1766 | fNDumpMCMs--; | |
1767 | break; | |
1768 | } | |
1769 | } | |
1770 | for ( ; iMCM < fNDumpMCMs; iMCM++) { | |
1771 | fDumpMCM[iMCM] = fDumpMCM[iMCM+1]; | |
1772 | } | |
1773 | } | |
1774 | } | |
1775 | ||
92305359 | 1776 | Bool_t AliTRDrawStream::DumpingMCM(Int_t det, Int_t rob, Int_t mcm) const |
cc26f39c | 1777 | { |
1778 | // check if MCM data should be dumped | |
1779 | ||
1780 | for (Int_t iMCM = 0; iMCM < fNDumpMCMs; iMCM++) { | |
1781 | if (fDumpMCM[iMCM] == ((det << 7) | (rob << 4) | mcm)) { | |
1782 | return kTRUE; | |
1783 | } | |
1784 | } | |
1785 | return kFALSE; | |
1786 | } | |
1787 | ||
9cb9c409 | 1788 | TString AliTRDrawStream::DumpRaw(TString title, UInt_t *start, Int_t length, UInt_t endmarker) |
cc26f39c | 1789 | { |
1790 | // dump raw data | |
1791 | ||
1792 | title += "\n"; | |
9cb9c409 | 1793 | for (Int_t pos = 0; pos < length; pos += 4) { |
1794 | if ((start[pos+0] != endmarker) && pos+0 < length) | |
1795 | if ((start[pos+1] != endmarker && pos+1 < length)) | |
1796 | if ((start[pos+2] != endmarker && pos+2 < length)) | |
1797 | if ((start[pos+3] != endmarker && pos+3 < length)) | |
1798 | title += Form(" 0x%08x 0x%08x 0x%08x 0x%08x\n", | |
1799 | start[pos+0], start[pos+1], start[pos+2], start[pos+3]); | |
1800 | else { | |
1801 | title += Form(" 0x%08x 0x%08x 0x%08x 0x%08x\n", | |
1802 | start[pos+0], start[pos+1], start[pos+2], start[pos+3]); | |
1803 | return title; | |
1804 | } | |
1805 | else { | |
1806 | title += Form(" 0x%08x 0x%08x 0x%08x\n", | |
1807 | start[pos+0], start[pos+1], start[pos+2]); | |
1808 | return title; | |
1809 | } | |
1810 | else { | |
1811 | title += Form(" 0x%08x 0x%08x\n", | |
1812 | start[pos+0], start[pos+1]); | |
1813 | return title; | |
1814 | } | |
1815 | else { | |
1816 | title += Form(" 0x%08x\n", | |
1817 | start[pos+0]); | |
1818 | return title; | |
1819 | } | |
cc26f39c | 1820 | } |
9cb9c409 | 1821 | return title; |
1822 | } | |
1823 | ||
1824 | TString AliTRDrawStream::DumpMcmHeader(TString title, UInt_t word) | |
1825 | { | |
1826 | title += Form("0x%08x -> ROB: %i, MCM: %2i", | |
1827 | word, ROB(word), MCM(word)); | |
1828 | return title; | |
1829 | } | |
1830 | ||
1831 | TString AliTRDrawStream::DumpAdcMask(TString title, UInt_t word) | |
1832 | { | |
1833 | title += Form("0x%08x -> #ch : %2i, 0x%06x (%2i ch)", | |
1834 | word, GetNActiveChannels(word), GetActiveChannels(word), GetNActiveChannelsFromMask(word)); | |
1835 | return title; | |
cc26f39c | 1836 | } |
f4b3235e | 1837 | |
1838 | AliTRDrawStream::AliTRDrawStreamError::AliTRDrawStreamError(Int_t error, Int_t sector, Int_t stack, Int_t link, Int_t rob, Int_t mcm) : | |
1839 | fError(error), | |
1840 | fSector(sector), | |
1841 | fStack(stack), | |
1842 | fLink(link), | |
1843 | fRob(rob), | |
1844 | fMcm(mcm) | |
1845 | { | |
1846 | // ctor | |
1847 | ||
1848 | } |