Error messages stored in the global raw-reader error log (Cvetan, Chiara)
[u/mrichter/AliRoot.git] / TOF / AliTOFDecoder.cxx
CommitLineData
2531be5d 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$Log$
856d92f7 18Revision 1.1 2007/04/27 11:00:32 arcelli
19TOF Raw Data decoder
20
2531be5d 21 author: Roberto Preghenella (R+), preghenella@bo.infn.it
22*/
23
24
682baa04 25/*********************************************************************
26 * *
27 * *
28 * Class for raw data decoding *
29 * *
30 * *
31 ********************************************************************/
2531be5d 32
33
34
35#include "AliLog.h"
36#include "AliTOFHitData.h"
37#include "AliTOFDecoder.h"
38
39ClassImp(AliTOFDecoder)
40
41//_________________________________________________________________
42
43AliTOFDecoder::AliTOFDecoder() :
44 TObject(),
45 fVerbose(0),
46 fV2718Patch(kFALSE),
47 fDataBuffer(0x0),
48 fPackedDataBuffer(0x0),
49 fTRMGlobalHeader(0x0),
50 fTRMGlobalTrailer(0x0),
51 fTRMChainHeader(0x0),
52 fTRMChainTrailer(0x0),
53 fTDCPackedHit(0x0),
54 fTDCUnpackedHit(0x0),
55 fTRMTDCError(0x0),
56 fTRMDiagnosticErrorWord1(0x0),
57 fTRMDiagnosticErrorWord2(0x0),
58 fSpiderCurrentSlotID(-1),
59 fSpiderCurrentChain(-1),
60 fSpiderCurrentTDC(-1)
61{
62 //default constructor
63}
64
65//_________________________________________________________________
66
67AliTOFDecoder::AliTOFDecoder(AliTOFHitDataBuffer *DataBuffer, AliTOFHitDataBuffer *PackedDataBuffer) :
68 TObject(),
69 fVerbose(0),
70 fV2718Patch(kFALSE),
71 fDataBuffer(DataBuffer),
72 fPackedDataBuffer(PackedDataBuffer),
73 fTRMGlobalHeader(0x0),
74 fTRMGlobalTrailer(0x0),
75 fTRMChainHeader(0x0),
76 fTRMChainTrailer(0x0),
77 fTDCPackedHit(0x0),
78 fTDCUnpackedHit(0x0),
79 fTRMTDCError(0x0),
80 fTRMDiagnosticErrorWord1(0x0),
81 fTRMDiagnosticErrorWord2(0x0),
82 fSpiderCurrentSlotID(-1),
83 fSpiderCurrentChain(-1),
84 fSpiderCurrentTDC(-1)
85{
86 //another constructor
87}
88
89//_________________________________________________________________
90
91AliTOFDecoder::AliTOFDecoder(const AliTOFDecoder &source) :
92 TObject(),
93 fVerbose(0),
94 fV2718Patch(kFALSE),
95 fDataBuffer(0x0),
96 fPackedDataBuffer(0x0),
97 fTRMGlobalHeader(0x0),
98 fTRMGlobalTrailer(0x0),
99 fTRMChainHeader(0x0),
100 fTRMChainTrailer(0x0),
101 fTDCPackedHit(0x0),
102 fTDCUnpackedHit(0x0),
103 fTRMTDCError(0x0),
104 fTRMDiagnosticErrorWord1(0x0),
105 fTRMDiagnosticErrorWord2(0x0),
106 fSpiderCurrentSlotID(-1),
107 fSpiderCurrentChain(-1),
108 fSpiderCurrentTDC(-1)
109{
110 //copy constructor
111
112 this->fVerbose = source.fVerbose;
113 this->fV2718Patch = source.fV2718Patch;
114 this->fDataBuffer = source.fDataBuffer;
115 this->fPackedDataBuffer = source.fPackedDataBuffer;
116 this->fTRMGlobalHeader = source.fTRMGlobalHeader;
117 this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
118 this->fTRMChainHeader = source.fTRMChainHeader;
119 this->fTRMChainTrailer = source.fTRMChainTrailer;
120 this->fTDCPackedHit = source.fTDCPackedHit;
121 this->fTDCUnpackedHit = source.fTDCUnpackedHit;
122 this->fTRMTDCError = source.fTRMTDCError;
123 this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
124 this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
125 this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
126 this->fSpiderCurrentChain = source.fSpiderCurrentChain;
127 this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
128}
129
130//_________________________________________________________________
131
132AliTOFDecoder &
133AliTOFDecoder::operator = (const AliTOFDecoder &source)
134{
135 //operator =
136
137 this->fVerbose = source.fVerbose;
138 this->fV2718Patch = source.fV2718Patch;
139 this->fDataBuffer = source.fDataBuffer;
140 this->fPackedDataBuffer = source.fPackedDataBuffer;
141 this->fTRMGlobalHeader = source.fTRMGlobalHeader;
142 this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
143 this->fTRMChainHeader = source.fTRMChainHeader;
144 this->fTRMChainTrailer = source.fTRMChainTrailer;
145 this->fTDCPackedHit = source.fTDCPackedHit;
146 this->fTDCUnpackedHit = source.fTDCUnpackedHit;
147 this->fTRMTDCError = source.fTRMTDCError;
148 this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
149 this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
150 this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
151 this->fSpiderCurrentChain = source.fSpiderCurrentChain;
152 this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
153 return *this;
154}
155
156AliTOFDecoder::~AliTOFDecoder()
157{}
158
159//_________________________________________________________________
160
161Bool_t
162AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords)
163{
164 /* main decoding routine.
165 * it loops over nWords 32-bit words
166 * starting at *rawData and decodes them.
167 * it also fills some buffers in order to
168 * have the decoded data available for other
169 * classes.
170 */
171
172 AliTOFHitData hitData;
173
174 //useful variables
175 Int_t status;
176 Short_t tempPS;
177 Float_t tempTOT; //ns
178 Int_t tempTOTBin; //TOT_BIN_WIDTH
179
180 //decoder variables
181 UShort_t decodeStatus = 0x0;
182 Short_t currentDDL = -1;
183 Short_t currentSlotID = -1;
184 Short_t currentACQ = -1;
185 Short_t currentChain = -1;
186 Short_t currentBunchID = -1;
187
188 /*** V2718 patch ***/
189 if (fV2718Patch){
190 decodeStatus = decodeStatus | DRM_BIT;
191 if (fVerbose)
192 AliInfo("DRM not present: - V2718 patch decoding -");
193 }
194 /*** V2718 patch ***/
195
196 if (fVerbose==2)
197 AliInfo("Initialize SPIDER function");
198 status = InitializeSpider();
199
200 if (fVerbose)
201 AliInfo("Start decoding");
202
203 if (fVerbose)
204 AliInfo("Loop over the data and decode");
205
206 if (fVerbose)
207 AliInfo(" St Hex Word \t Decoded Word");
208
209 //loop over raw data
210 for (Int_t iWord = 0; iWord < nWords; iWord++, rawData++){
211
212 //switch word type
213 switch (*rawData & WORD_TYPE_MASK){
214
215 case GLOBAL_HEADER:
216
217 //switch slot ID
218 switch (*rawData & SLOT_ID_MASK){
219
220 //DRM global header (slotID=1)
221 case 1:
222 //check decode status
223 if ( decodeStatus != DRM_HEADER_STATUS ){
224 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global header",decodeStatus,*rawData));
225 return kTRUE;
226 }
227 //decode status ok
228 if (fVerbose)
229 AliInfo(Form(" %02x - 0x%08x \t DRM global header",decodeStatus,*rawData));
230 //change decode status
231 decodeStatus = decodeStatus | DRM_BIT;
232
233 //skip DRM data
234 for (Int_t i = 0; i < DRM_DATA_WORDS; i++, iWord++, rawData++){
235 if (fVerbose)
236 AliInfo(Form(" %02x - 0x%08x \t DRM data",decodeStatus,*rawData));
237 }
238 break;
239
240 //LTM global header (slotID=2)
241 case 2:
242 //check decode status
243 if ( decodeStatus != LTM_HEADER_STATUS ){
244 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global header",decodeStatus,*rawData));
245 return kTRUE;
246 }
247 //decode status ok
248 if (fVerbose)
249 AliInfo(Form(" %02x - 0x%08x \t LTM global header",decodeStatus,*rawData));
250 //change decode status
251 decodeStatus = decodeStatus | LTM_BIT;
252
253 //skip LTM data
254 for (Int_t i = 0; i < LTM_DATA_WORDS; i++, iWord++, rawData++){
255 if (fVerbose)
256 AliInfo(Form(" %02x - 0x%08x \t LTM data",decodeStatus,*rawData));
257 }
258 break;
259
260 //TRM global header (slotID=3-12)
261 case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12:
262 //check decode status
263 if ( decodeStatus != TRM_HEADER_STATUS ){
264 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global header",decodeStatus,*rawData));
265 return kTRUE;
266 }
267 //decode status ok
268 //set TRM global header
269 fTRMGlobalHeader = (AliTOFTRMGlobalHeader *)rawData;
270 //set current TRM
271 currentSlotID = fTRMGlobalHeader->GetSlotID();
272 currentACQ = fTRMGlobalHeader->GetACQBits();
273 if (fVerbose)
274 AliInfo(Form(" %02x - 0x%08x \t TRM global header \t slotID=%02d ACQ=%01d L=%01d",decodeStatus,*rawData,fTRMGlobalHeader->GetSlotID(),fTRMGlobalHeader->GetACQBits(),fTRMGlobalHeader->GetLBit()));
275 //change decode status
276 decodeStatus = decodeStatus | TRM_BIT;
277 break;
278
279 default:
682baa04 280 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID in global header",decodeStatus,*rawData));
2531be5d 281 return kTRUE;
282 break;
283
284 }
285 //end switch slotID
286 break;
287
288 case GLOBAL_TRAILER:
289
290 //switch slot ID
291 switch (*rawData & SLOT_ID_MASK){
292
293 //DRM global trailer (slotID=1)
294 case 1:
295 //check decode status
296 if ( decodeStatus != DRM_TRAILER_STATUS ){
297 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global trailer",decodeStatus,*rawData));
298 return kTRUE;
299 }
300 //decode status ok
301 if (fVerbose)
302 AliInfo(Form(" %02x - 0x%08x \t DRM global trailer",decodeStatus,*rawData));
303 //change decode status
304 decodeStatus = decodeStatus & ~DRM_BIT;
305 break;
306
307 //LTM global trailer (slotID=2)
308 case 2:
309 //check decode status
310 if ( decodeStatus != LTM_TRAILER_STATUS ){
311 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global trailer",decodeStatus,*rawData));
312 return kTRUE;
313 }
314 //decode status ok
315 if (fVerbose)
316 AliInfo(Form(" %02x - 0x%08x \t LTM global trailer",decodeStatus,*rawData));
317 //change decode status
318 decodeStatus = decodeStatus & ~LTM_BIT;
319 break;
320
321 //TRM global trailer (slotID=15)
322 case 15:
323 //check decode status
324 if ( decodeStatus != TRM_TRAILER_STATUS ){
325 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global trailer",decodeStatus,*rawData));
326 return kTRUE;
327 }
328 //decode status ok
329 //set TRM global trailer
330 fTRMGlobalTrailer = (AliTOFTRMGlobalTrailer *)rawData;
331 if (fVerbose)
332 AliInfo(Form(" %02x - 0x%08x \t TRM global trailer \t CRC=%04d eventCounter=%04d",decodeStatus,*rawData,fTRMGlobalTrailer->GetEventCRC(),fTRMGlobalTrailer->GetEventCounter()));
333 //change decode status
334 decodeStatus = decodeStatus & ~TRM_BIT;
335 break;
336
337 default:
682baa04 338 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID/pattern in global trailer",decodeStatus,*rawData));
2531be5d 339 return kTRUE;
340 break;
341 }
342 break;
343
344 case CHAIN_A_HEADER:
345 //check decode status
346 if ( (decodeStatus != CHAIN_A_HEADER_STATUS) ){
347 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A header",decodeStatus,*rawData));
348 return kTRUE;
349 }
350 //decode status ok
351 fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
352 currentChain = 0;
353 currentBunchID = fTRMChainHeader->GetBunchID();
354 if (fVerbose)
355 AliInfo(Form(" %02x - 0x%08x \t TRM chain A header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
356 //change decode status
357 decodeStatus = decodeStatus | CHAIN_A_BIT;
358 break;
359
360 case CHAIN_A_TRAILER:
361 //check decode status
362 if ( decodeStatus != CHAIN_A_TRAILER_STATUS ){
363 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A trailer",decodeStatus,*rawData));
364 return kTRUE;
365 }
366 //decode status ok
367 if (fVerbose)
368 AliInfo(Form(" %02x - 0x%08x \t TRM chain A trailer",decodeStatus,*rawData));
369 //change decode status
370 decodeStatus = decodeStatus & ~CHAIN_A_BIT;
371 break;
372
373 case CHAIN_B_HEADER:
374 //check decode status
375 if ( decodeStatus != CHAIN_B_HEADER_STATUS ){
376 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B header",decodeStatus,*rawData));
377 return kTRUE;
378 }
379 //decode status ok
380 fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
381 currentChain = 1;
382 currentBunchID = fTRMChainHeader->GetBunchID();
383 if (fVerbose)
384 AliInfo(Form(" %02x - 0x%08x \t TRM chain B header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
385 //change decode status
386 decodeStatus = decodeStatus | CHAIN_B_BIT;
387 break;
388
389 case CHAIN_B_TRAILER:
390 //check decode status
391 if ( decodeStatus != CHAIN_B_TRAILER_STATUS ){
392 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B trailer",decodeStatus,*rawData));
393 return kTRUE;
394 }
395 //decode status ok
396 if (fVerbose)
397 AliInfo(Form(" %02x - 0x%08x \t TRM chain B trailer",decodeStatus,*rawData));
398 //change decode status
399 decodeStatus = decodeStatus & ~CHAIN_B_BIT;
400 break;
401
402 case ERROR:
403 if (fVerbose)
404 AliInfo(Form(" %02x - 0x%08x \t TDC error",decodeStatus,*rawData));
405 break;
406
407 case FILLER:
408 if (fVerbose)
409 AliInfo(Form(" %02x - 0x%08x \t Filler",decodeStatus,*rawData));
410 break;
411
412 default:
413 //check decode status
414 if ( decodeStatus != CHAIN_A_TDC_HIT_STATUS &&
415 decodeStatus != CHAIN_B_TDC_HIT_STATUS ){
416 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected or unknown word",decodeStatus,*rawData));
417 return kTRUE;
418 }
419 //decode status ok
420
421 //switch TRM ACQ
422 switch (currentACQ){
423
424 case PACKING_ENABLED_ACQ:
425 //decode TDC packed hit
426 fTDCPackedHit = (AliTOFTDCPackedHit *)rawData;
427 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
428 //set hit in the equipment data
429 hitData.SetDDLID(currentDDL);
430 hitData.SetSlotID(currentSlotID);
431 hitData.SetACQ(currentACQ);
432 hitData.SetChain(currentChain);
433 hitData.SetPS(fTDCPackedHit->GetPSBits());
434 hitData.SetTDC(fTDCPackedHit->GetTDCID());
435 hitData.SetChan(fTDCPackedHit->GetChan());
436 hitData.SetTime((float)fTDCPackedHit->GetHitTime() * TIME_BIN_WIDTH);
437 hitData.SetTimeBin(fTDCPackedHit->GetHitTime());
438 hitData.SetTOT((float)fTDCPackedHit->GetTOTWidth() * TOT_BIN_WIDTH);
439 hitData.SetTOTBin(fTDCPackedHit->GetTOTWidth());
440 //orphane leading hit
441 if (hitData.GetPS()==LEADING_HIT_PS){
442 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
443 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
444 //set TOT to zero
445 hitData.SetTOT(0);
446 hitData.SetTOTBin(0);
447 //push hit data in packed data buffer
448 if (fPackedDataBuffer != 0x0)
449 fPackedDataBuffer->Add(hitData);
450 //set TOT to not measured
451 hitData.SetTOT(-1);
452 hitData.SetTOTBin(-1);
453 //push hit data in packed data buffer
454 if (fDataBuffer != 0x0)
455 fDataBuffer->Add(hitData);
456 }
457 //orphane trailing hit
458 else if (hitData.GetPS()==TRAILING_HIT_PS){
459 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
460 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
461 //set TOT to not measured
462 hitData.SetTOT(-1);
463 hitData.SetTOTBin(-1);
464 //push hit data in data buffer
465 if (fDataBuffer != 0x0)
466 fDataBuffer->Add(hitData);
467 }
468 //packed hit and OVF
469 else{
470 //push hit data in packed data buffer
471 if (fPackedDataBuffer != 0x0)
472 fPackedDataBuffer->Add(hitData);
473 //save PS temporary
474 tempPS = hitData.GetPS();
475 //save TOT temporary
476 tempTOT = hitData.GetTOT();
477 tempTOTBin = hitData.GetTOTBin();
478 //unpack the hit: leading hit
479 hitData.SetPS(LEADING_HIT_PS);
480 //set TOT to not measured
481 hitData.SetTOT(-1);
482 hitData.SetTOTBin(-1);
483 //push leading hit data in data buffer
484 if (fDataBuffer != 0x0)
485 fDataBuffer->Add(hitData);
486 //unpack the hit: trailing hit
487 hitData.SetPS(TRAILING_HIT_PS);
488 hitData.SetTime(hitData.GetTime() + tempTOT);
489 hitData.SetTimeBin(hitData.GetTimeBin() + (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
490 //push trailing hit data in data buffer
491 if (fDataBuffer != 0x0)
492 fDataBuffer->Add(hitData);
493 //restore packed hit
494 hitData.SetPS(tempPS);
495 hitData.SetTime(hitData.GetTime() - tempTOT);
496 hitData.SetTimeBin(hitData.GetTimeBin() - (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
497 hitData.SetTOT(tempTOT);
498 hitData.SetTOTBin(tempTOTBin);
499 }
500
501 if (fVerbose)
502 switch (hitData.GetPS()){
503 case PACKED_HIT_PS:
504 AliInfo(Form(" %02x - 0x%08x \t TDC hit [packed] \t PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTOT(),hitData.GetTOTBin(),hitData.GetTime(),hitData.GetTimeBin()));
505 break;
506 case LEADING_HIT_PS:
507 AliInfo(Form(" %02x - 0x%08x \t TDC hit [orp.lead] \t PS=%01d TDC=%01d chan=%01d time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTime(),hitData.GetTimeBin()));
508 break;
509 case TRAILING_HIT_PS:
510 AliInfo(Form(" %02x - 0x%08x \t TDC hit [orp.trai] \t PS=%01d TDC=%01d chan=%01d time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTime(),hitData.GetTimeBin()));
511 break;
512 case TOT_OVF_HIT_PS:
513 AliInfo(Form(" %02x - 0x%08x \t TDC hit [TOT ovfl] \t PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTOT(),hitData.GetTOTBin(),hitData.GetTime(),hitData.GetTimeBin()));
514 break;
515 }
516 break;
517
518 case LEADING_ONLY_ACQ: case TRAILING_ONLY_ACQ:
519 //decode TDC unpacked hit
520 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
521 //set hit in the equipment data
522 hitData.SetDDLID(currentDDL);
523 hitData.SetSlotID(currentSlotID);
524 hitData.SetACQ(currentACQ);
525 hitData.SetChain(currentChain);
526 hitData.SetPS(fTDCUnpackedHit->GetPSBits());
527 hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
528 hitData.SetChan(fTDCUnpackedHit->GetChan());
529 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
530 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
531 hitData.SetTOT(-1.);
532 hitData.SetTOTBin(-1);
533 //push hit data in data buffer
534 if (fDataBuffer != 0x0)
535 fDataBuffer->Add(hitData);
536
537 if (fVerbose)
538 switch (hitData.GetPS()){
539 case PACKED_HIT_PS:
540 AliInfo(Form(" %02x - 0x%08x \t TDC hit [packed] \t PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTOT(),hitData.GetTOTBin(),hitData.GetTime(),hitData.GetTimeBin()));
541 break;
542 case LEADING_HIT_PS:
543 AliInfo(Form(" %02x - 0x%08x \t TDC hit [leading] \t PS=%01d TDC=%01d chan=%01d time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTime(),hitData.GetTimeBin()));
544 break;
545 case TRAILING_HIT_PS:
546 AliInfo(Form(" %02x - 0x%08x \t TDC hit [trailing] \t PS=%01d TDC=%01d chan=%01d time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTime(),hitData.GetTimeBin()));
547 break;
548 case TOT_OVF_HIT_PS:
549 AliInfo(Form(" %02x - 0x%08x \t TDC hit [TOT ovfl] \t PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTOT(),hitData.GetTOTBin(),hitData.GetTime(),hitData.GetTimeBin()));
550 break;
551 }
552 break;
553
554 case PACKING_DISABLED_ACQ:
555 //decode TDC unpacked hit
556 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
557 //set hit in the equipment data
558 hitData.SetDDLID(currentDDL);
559 hitData.SetSlotID(currentSlotID);
560 hitData.SetACQ(currentACQ);
561 hitData.SetChain(currentChain);
562 hitData.SetPS(fTDCUnpackedHit->GetPSBits());
563 hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
564 hitData.SetChan(fTDCUnpackedHit->GetChan());
565 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
566 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
567 hitData.SetTOT(-1.);
568 hitData.SetTOTBin(-1);
569 //push hit data in data buffer
570 if (fDataBuffer != 0x0)
571 fDataBuffer->Add(hitData);
572
573 if (fVerbose)
574 switch (hitData.GetPS()){
575 case PACKED_HIT_PS:
576 AliInfo(Form(" %02x - 0x%08x \t TDC hit [packed] \t PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTOT(),hitData.GetTOTBin(),hitData.GetTime(),hitData.GetTimeBin()));
577 break;
578 case LEADING_HIT_PS:
579 AliInfo(Form(" %02x - 0x%08x \t TDC hit [leading] \t PS=%01d TDC=%01d chan=%01d time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTime(),hitData.GetTimeBin()));
580 break;
581 case TRAILING_HIT_PS:
582 AliInfo(Form(" %02x - 0x%08x \t TDC hit [trailing] \t PS=%01d TDC=%01d chan=%01d time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTime(),hitData.GetTimeBin()));
583 break;
584 case TOT_OVF_HIT_PS:
585 AliInfo(Form(" %02x - 0x%08x \t TDC hit [TOT ovfl] \t PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTOT(),hitData.GetTOTBin(),hitData.GetTime(),hitData.GetTimeBin()));
586 break;
587 }
588 //call spider function
589 if (fVerbose==2)
590 AliInfo("Calling SPIDER function");
591 Spider(hitData);
592 break;
593 }
594 //end switch TRM ACQ
595
596
597 }
598 //end switch word type
599
600 }
601 //end equipment data loop
602
603 if (fVerbose)
604 AliInfo("End of data loop");
605
606 if (fVerbose==2)
607 AliInfo("Reset SPIDER function");
608 status = ResetSpider();
609
610 if (fVerbose)
611 AliInfo("Decoder is exiting succesfully.");
612
613 return kFALSE;
614}
615
616//_________________________________________________________________
617
618Bool_t
619AliTOFDecoder::InitializeSpider(){
620
621 /* SPIDER initialization routine.
622 it initializes SPIDER variables in order
623 to have SPIDER ready to pack tof data
624 in packed data objects
625 */
626
627 if (fVerbose==2)
628 AliInfo("Initializing SPIDER");
629
630 fSpiderCurrentSlotID=-1;
631 fSpiderCurrentChain=-1;
632 fSpiderCurrentTDC=-1;
633
634 for (Int_t chan=0;chan<N_CHANNEL;chan++)
635 fSpiderLeadingFlag[chan] = kFALSE;
636
637 return kFALSE;
638}
639
640//_________________________________________________________________
641
642Bool_t
643AliTOFDecoder::ResetSpider(){
644
645 /* SPIDER reset routine.
646 it resets SPIDER buffers and
647 variables in order to empty full
648 buffers a set up SIPDER for new
649 HPTDC data
650 */
651
652 if (fVerbose==2)
653 AliInfo("Resetting SPIDER buffers");
654
655 for (Int_t chan=0;chan<N_CHANNEL;chan++){
656 if (fSpiderLeadingFlag[chan]){
657 if (fVerbose==2)
658 AliInfo("Buffer non empty: put leading hit into buffer as orphane");
659 //set TOT to zero
660 fSpiderLeadingHit[chan].SetACQ(4);
661 fSpiderLeadingHit[chan].SetPS(1);
662 fSpiderLeadingHit[chan].SetTOT(0);
663 fSpiderLeadingHit[chan].SetTOTBin(0);
664 //push hit into packed buffer
665 if (fPackedDataBuffer != 0x0)
666 fPackedDataBuffer->Add(fSpiderLeadingHit[chan]);
667 if (fVerbose==2)
668 AliInfo(Form("Packed hit: slotID=%d chain=%d PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",fSpiderLeadingHit[chan].GetSlotID(),fSpiderLeadingHit[chan].GetChain(),fSpiderLeadingHit[chan].GetPS(),fSpiderLeadingHit[chan].GetTDC(),fSpiderLeadingHit[chan].GetChan(),fSpiderLeadingHit[chan].GetTOT(),fSpiderLeadingHit[chan].GetTOTBin(),fSpiderLeadingHit[chan].GetTime(),fSpiderLeadingHit[chan].GetTimeBin()));
669
670 }
671 fSpiderLeadingFlag[chan]=kFALSE;
672 }
673
674 return kFALSE;
675}
676
677//_________________________________________________________________
678
679Bool_t
680AliTOFDecoder::Spider(AliTOFHitData hitData){
681
682 /* main SPIDER routine.
683 it receives, reads, stores and packs
684 unpacked HPTDC data in packed data
685 object. it also fills buffers.
686 */
687
688 Int_t status;
689
690 if (fVerbose==2)
691 AliInfo("Hit data received");
692
693 //check if TDC is changed (slotID,chain,TDC triplet)
694 if (fSpiderCurrentSlotID!=hitData.GetSlotID() ||
695 fSpiderCurrentChain!=hitData.GetChain() ||
696 fSpiderCurrentTDC!=hitData.GetTDC() ){
697 if (fVerbose==2)
698 AliInfo("Data coming from a new TDC: reset buffers");
699 //reset spider
700 status = ResetSpider();
701 //set current TDC
702 fSpiderCurrentSlotID=hitData.GetSlotID();
703 fSpiderCurrentChain=hitData.GetChain();
704 fSpiderCurrentTDC=hitData.GetTDC();
705 }
706
707 //switch PS bits
708 switch (hitData.GetPS()){
709
710 case LEADING_HIT_PS:
711 if (fVerbose==2)
712 AliInfo(Form("Leading hit: slotID=%d chain=%d PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",hitData.GetSlotID(),hitData.GetChain(),hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTOT(),hitData.GetTOTBin(),hitData.GetTime(),hitData.GetTimeBin()));
713 //check spider leading flag
714 if (fSpiderLeadingFlag[hitData.GetChan()]){
715 if (fVerbose==2)
716 AliInfo("Leading hit: buffer full, put previous in buffers as orphane and keep current");
717 //set TOT at zero for previous hit
718 fSpiderLeadingHit[hitData.GetChan()].SetACQ(4);
719 fSpiderLeadingHit[hitData.GetChan()].SetPS(1);
720 fSpiderLeadingHit[hitData.GetChan()].SetTOT(0);
721 fSpiderLeadingHit[hitData.GetChan()].SetTOTBin(0);
722 //push previous hit into packed buffer
723 if (fPackedDataBuffer != 0x0)
724 fPackedDataBuffer->Add(fSpiderLeadingHit[hitData.GetChan()]);
725 //set current hit
726 fSpiderLeadingHit[hitData.GetChan()]=hitData;
727 if (fVerbose==2)
728 AliInfo(Form("Packed hit: slotID=%d chain=%d PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",fSpiderLeadingHit[hitData.GetChan()].GetSlotID(),fSpiderLeadingHit[hitData.GetChan()].GetChain(),fSpiderLeadingHit[hitData.GetChan()].GetPS(),fSpiderLeadingHit[hitData.GetChan()].GetTDC(),fSpiderLeadingHit[hitData.GetChan()].GetChan(),fSpiderLeadingHit[hitData.GetChan()].GetTOT(),fSpiderLeadingHit[hitData.GetChan()].GetTOTBin(),fSpiderLeadingHit[hitData.GetChan()].GetTime(),fSpiderLeadingHit[hitData.GetChan()].GetTimeBin()));
729 }
730 else{
731 if (fVerbose==2)
732 AliInfo("Leading hit: buffer empty, keep current hit and set flag");
733 fSpiderLeadingHit[hitData.GetChan()]=hitData;
734 //set spider leading flag
735 fSpiderLeadingFlag[hitData.GetChan()]=kTRUE;
736 }
737 break;
738
739 case TRAILING_HIT_PS:
740 if (fVerbose==2)
741 AliInfo(Form("Trailing hit: slotID=%d chain=%d PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",hitData.GetSlotID(),hitData.GetChain(),hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTOT(),hitData.GetTOTBin(),hitData.GetTime(),hitData.GetTimeBin()));
742 //check spider leading flag
743 if (fSpiderLeadingFlag[hitData.GetChan()]){
744 if (fVerbose==2)
745 AliInfo("Trailing hit: buffer full, pack leading and trailing");
746 hitData.SetACQ(4);
747 hitData.SetPS(0);
748 hitData.SetTOT(hitData.GetTime()-fSpiderLeadingHit[hitData.GetChan()].GetTime());
749 hitData.SetTOTBin((Int_t)((hitData.GetTimeBin()-fSpiderLeadingHit[hitData.GetChan()].GetTimeBin())*TIME_TO_TOT_BIN_WIDTH));
750 hitData.SetTime(fSpiderLeadingHit[hitData.GetChan()].GetTime());
751 hitData.SetTimeBin(fSpiderLeadingHit[hitData.GetChan()].GetTimeBin());
752 //check TOT and set TOT overflow if TOT < 0
753 if (hitData.GetTOT() < 0){
754 hitData.SetPS(3);
755 hitData.SetTOT(0);
756 hitData.SetTOTBin(0);
757 }
758 if (fPackedDataBuffer != 0x0)
759 fPackedDataBuffer->Add(hitData);
760 if (fVerbose==2)
761 AliInfo(Form("Packed hit: slotID=%d chain=%d PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",hitData.GetSlotID(),hitData.GetChain(),hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTOT(),hitData.GetTOTBin(),hitData.GetTime(),hitData.GetTimeBin()));
762 //unset spider leading flag
763 fSpiderLeadingFlag[hitData.GetChan()]=kFALSE;
764 }
765 else{
766 if (fVerbose==2)
767 AliInfo("Trailing hit: buffer empty, throw hit away");
768 }
769 break;
770 }
771 //end switch PS bits
772
773 return kFALSE;
774}