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