code rearrangement (R.Preghenella)
[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
856d92f7 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:
280 if (fVerbose)
281 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID in global header",decodeStatus,*rawData));
282 return kTRUE;
283 break;
284
285 }
286 //end switch slotID
287 break;
288
289 case GLOBAL_TRAILER:
290
291 //switch slot ID
292 switch (*rawData & SLOT_ID_MASK){
293
294 //DRM global trailer (slotID=1)
295 case 1:
296 //check decode status
297 if ( decodeStatus != DRM_TRAILER_STATUS ){
298 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global trailer",decodeStatus,*rawData));
299 return kTRUE;
300 }
301 //decode status ok
302 if (fVerbose)
303 AliInfo(Form(" %02x - 0x%08x \t DRM global trailer",decodeStatus,*rawData));
304 //change decode status
305 decodeStatus = decodeStatus & ~DRM_BIT;
306 break;
307
308 //LTM global trailer (slotID=2)
309 case 2:
310 //check decode status
311 if ( decodeStatus != LTM_TRAILER_STATUS ){
312 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global trailer",decodeStatus,*rawData));
313 return kTRUE;
314 }
315 //decode status ok
316 if (fVerbose)
317 AliInfo(Form(" %02x - 0x%08x \t LTM global trailer",decodeStatus,*rawData));
318 //change decode status
319 decodeStatus = decodeStatus & ~LTM_BIT;
320 break;
321
322 //TRM global trailer (slotID=15)
323 case 15:
324 //check decode status
325 if ( decodeStatus != TRM_TRAILER_STATUS ){
326 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global trailer",decodeStatus,*rawData));
327 return kTRUE;
328 }
329 //decode status ok
330 //set TRM global trailer
331 fTRMGlobalTrailer = (AliTOFTRMGlobalTrailer *)rawData;
332 if (fVerbose)
333 AliInfo(Form(" %02x - 0x%08x \t TRM global trailer \t CRC=%04d eventCounter=%04d",decodeStatus,*rawData,fTRMGlobalTrailer->GetEventCRC(),fTRMGlobalTrailer->GetEventCounter()));
334 //change decode status
335 decodeStatus = decodeStatus & ~TRM_BIT;
336 break;
337
338 default:
339 if (fVerbose)
340 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID/pattern in global trailer",decodeStatus,*rawData));
341 return kTRUE;
342 break;
343 }
344 break;
345
346 case CHAIN_A_HEADER:
347 //check decode status
348 if ( (decodeStatus != CHAIN_A_HEADER_STATUS) ){
349 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A header",decodeStatus,*rawData));
350 return kTRUE;
351 }
352 //decode status ok
353 fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
354 currentChain = 0;
355 currentBunchID = fTRMChainHeader->GetBunchID();
356 if (fVerbose)
357 AliInfo(Form(" %02x - 0x%08x \t TRM chain A header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
358 //change decode status
359 decodeStatus = decodeStatus | CHAIN_A_BIT;
360 break;
361
362 case CHAIN_A_TRAILER:
363 //check decode status
364 if ( decodeStatus != CHAIN_A_TRAILER_STATUS ){
365 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A trailer",decodeStatus,*rawData));
366 return kTRUE;
367 }
368 //decode status ok
369 if (fVerbose)
370 AliInfo(Form(" %02x - 0x%08x \t TRM chain A trailer",decodeStatus,*rawData));
371 //change decode status
372 decodeStatus = decodeStatus & ~CHAIN_A_BIT;
373 break;
374
375 case CHAIN_B_HEADER:
376 //check decode status
377 if ( decodeStatus != CHAIN_B_HEADER_STATUS ){
378 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B header",decodeStatus,*rawData));
379 return kTRUE;
380 }
381 //decode status ok
382 fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
383 currentChain = 1;
384 currentBunchID = fTRMChainHeader->GetBunchID();
385 if (fVerbose)
386 AliInfo(Form(" %02x - 0x%08x \t TRM chain B header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
387 //change decode status
388 decodeStatus = decodeStatus | CHAIN_B_BIT;
389 break;
390
391 case CHAIN_B_TRAILER:
392 //check decode status
393 if ( decodeStatus != CHAIN_B_TRAILER_STATUS ){
394 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B trailer",decodeStatus,*rawData));
395 return kTRUE;
396 }
397 //decode status ok
398 if (fVerbose)
399 AliInfo(Form(" %02x - 0x%08x \t TRM chain B trailer",decodeStatus,*rawData));
400 //change decode status
401 decodeStatus = decodeStatus & ~CHAIN_B_BIT;
402 break;
403
404 case ERROR:
405 if (fVerbose)
406 AliInfo(Form(" %02x - 0x%08x \t TDC error",decodeStatus,*rawData));
407 break;
408
409 case FILLER:
410 if (fVerbose)
411 AliInfo(Form(" %02x - 0x%08x \t Filler",decodeStatus,*rawData));
412 break;
413
414 default:
415 //check decode status
416 if ( decodeStatus != CHAIN_A_TDC_HIT_STATUS &&
417 decodeStatus != CHAIN_B_TDC_HIT_STATUS ){
418 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected or unknown word",decodeStatus,*rawData));
419 return kTRUE;
420 }
421 //decode status ok
422
423 //switch TRM ACQ
424 switch (currentACQ){
425
426 case PACKING_ENABLED_ACQ:
427 //decode TDC packed hit
428 fTDCPackedHit = (AliTOFTDCPackedHit *)rawData;
429 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
430 //set hit in the equipment data
431 hitData.SetDDLID(currentDDL);
432 hitData.SetSlotID(currentSlotID);
433 hitData.SetACQ(currentACQ);
434 hitData.SetChain(currentChain);
435 hitData.SetPS(fTDCPackedHit->GetPSBits());
436 hitData.SetTDC(fTDCPackedHit->GetTDCID());
437 hitData.SetChan(fTDCPackedHit->GetChan());
438 hitData.SetTime((float)fTDCPackedHit->GetHitTime() * TIME_BIN_WIDTH);
439 hitData.SetTimeBin(fTDCPackedHit->GetHitTime());
440 hitData.SetTOT((float)fTDCPackedHit->GetTOTWidth() * TOT_BIN_WIDTH);
441 hitData.SetTOTBin(fTDCPackedHit->GetTOTWidth());
442 //orphane leading hit
443 if (hitData.GetPS()==LEADING_HIT_PS){
444 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
445 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
446 //set TOT to zero
447 hitData.SetTOT(0);
448 hitData.SetTOTBin(0);
449 //push hit data in packed data buffer
450 if (fPackedDataBuffer != 0x0)
451 fPackedDataBuffer->Add(hitData);
452 //set TOT to not measured
453 hitData.SetTOT(-1);
454 hitData.SetTOTBin(-1);
455 //push hit data in packed data buffer
456 if (fDataBuffer != 0x0)
457 fDataBuffer->Add(hitData);
458 }
459 //orphane trailing hit
460 else if (hitData.GetPS()==TRAILING_HIT_PS){
461 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
462 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
463 //set TOT to not measured
464 hitData.SetTOT(-1);
465 hitData.SetTOTBin(-1);
466 //push hit data in data buffer
467 if (fDataBuffer != 0x0)
468 fDataBuffer->Add(hitData);
469 }
470 //packed hit and OVF
471 else{
472 //push hit data in packed data buffer
473 if (fPackedDataBuffer != 0x0)
474 fPackedDataBuffer->Add(hitData);
475 //save PS temporary
476 tempPS = hitData.GetPS();
477 //save TOT temporary
478 tempTOT = hitData.GetTOT();
479 tempTOTBin = hitData.GetTOTBin();
480 //unpack the hit: leading hit
481 hitData.SetPS(LEADING_HIT_PS);
482 //set TOT to not measured
483 hitData.SetTOT(-1);
484 hitData.SetTOTBin(-1);
485 //push leading hit data in data buffer
486 if (fDataBuffer != 0x0)
487 fDataBuffer->Add(hitData);
488 //unpack the hit: trailing hit
489 hitData.SetPS(TRAILING_HIT_PS);
490 hitData.SetTime(hitData.GetTime() + tempTOT);
491 hitData.SetTimeBin(hitData.GetTimeBin() + (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
492 //push trailing hit data in data buffer
493 if (fDataBuffer != 0x0)
494 fDataBuffer->Add(hitData);
495 //restore packed hit
496 hitData.SetPS(tempPS);
497 hitData.SetTime(hitData.GetTime() - tempTOT);
498 hitData.SetTimeBin(hitData.GetTimeBin() - (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
499 hitData.SetTOT(tempTOT);
500 hitData.SetTOTBin(tempTOTBin);
501 }
502
503 if (fVerbose)
504 switch (hitData.GetPS()){
505 case PACKED_HIT_PS:
506 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()));
507 break;
508 case LEADING_HIT_PS:
509 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()));
510 break;
511 case TRAILING_HIT_PS:
512 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()));
513 break;
514 case TOT_OVF_HIT_PS:
515 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()));
516 break;
517 }
518 break;
519
520 case LEADING_ONLY_ACQ: case TRAILING_ONLY_ACQ:
521 //decode TDC unpacked hit
522 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
523 //set hit in the equipment data
524 hitData.SetDDLID(currentDDL);
525 hitData.SetSlotID(currentSlotID);
526 hitData.SetACQ(currentACQ);
527 hitData.SetChain(currentChain);
528 hitData.SetPS(fTDCUnpackedHit->GetPSBits());
529 hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
530 hitData.SetChan(fTDCUnpackedHit->GetChan());
531 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
532 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
533 hitData.SetTOT(-1.);
534 hitData.SetTOTBin(-1);
535 //push hit data in data buffer
536 if (fDataBuffer != 0x0)
537 fDataBuffer->Add(hitData);
538
539 if (fVerbose)
540 switch (hitData.GetPS()){
541 case PACKED_HIT_PS:
542 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()));
543 break;
544 case LEADING_HIT_PS:
545 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()));
546 break;
547 case TRAILING_HIT_PS:
548 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()));
549 break;
550 case TOT_OVF_HIT_PS:
551 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()));
552 break;
553 }
554 break;
555
556 case PACKING_DISABLED_ACQ:
557 //decode TDC unpacked hit
558 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
559 //set hit in the equipment data
560 hitData.SetDDLID(currentDDL);
561 hitData.SetSlotID(currentSlotID);
562 hitData.SetACQ(currentACQ);
563 hitData.SetChain(currentChain);
564 hitData.SetPS(fTDCUnpackedHit->GetPSBits());
565 hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
566 hitData.SetChan(fTDCUnpackedHit->GetChan());
567 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
568 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
569 hitData.SetTOT(-1.);
570 hitData.SetTOTBin(-1);
571 //push hit data in data buffer
572 if (fDataBuffer != 0x0)
573 fDataBuffer->Add(hitData);
574
575 if (fVerbose)
576 switch (hitData.GetPS()){
577 case PACKED_HIT_PS:
578 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()));
579 break;
580 case LEADING_HIT_PS:
581 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()));
582 break;
583 case TRAILING_HIT_PS:
584 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()));
585 break;
586 case TOT_OVF_HIT_PS:
587 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()));
588 break;
589 }
590 //call spider function
591 if (fVerbose==2)
592 AliInfo("Calling SPIDER function");
593 Spider(hitData);
594 break;
595 }
596 //end switch TRM ACQ
597
598
599 }
600 //end switch word type
601
602 }
603 //end equipment data loop
604
605 if (fVerbose)
606 AliInfo("End of data loop");
607
608 if (fVerbose==2)
609 AliInfo("Reset SPIDER function");
610 status = ResetSpider();
611
612 if (fVerbose)
613 AliInfo("Decoder is exiting succesfully.");
614
615 return kFALSE;
616}
617
618//_________________________________________________________________
619
620Bool_t
621AliTOFDecoder::InitializeSpider(){
622
623 /* SPIDER initialization routine.
624 it initializes SPIDER variables in order
625 to have SPIDER ready to pack tof data
626 in packed data objects
627 */
628
629 if (fVerbose==2)
630 AliInfo("Initializing SPIDER");
631
632 fSpiderCurrentSlotID=-1;
633 fSpiderCurrentChain=-1;
634 fSpiderCurrentTDC=-1;
635
636 for (Int_t chan=0;chan<N_CHANNEL;chan++)
637 fSpiderLeadingFlag[chan] = kFALSE;
638
639 return kFALSE;
640}
641
642//_________________________________________________________________
643
644Bool_t
645AliTOFDecoder::ResetSpider(){
646
647 /* SPIDER reset routine.
648 it resets SPIDER buffers and
649 variables in order to empty full
650 buffers a set up SIPDER for new
651 HPTDC data
652 */
653
654 if (fVerbose==2)
655 AliInfo("Resetting SPIDER buffers");
656
657 for (Int_t chan=0;chan<N_CHANNEL;chan++){
658 if (fSpiderLeadingFlag[chan]){
659 if (fVerbose==2)
660 AliInfo("Buffer non empty: put leading hit into buffer as orphane");
661 //set TOT to zero
662 fSpiderLeadingHit[chan].SetACQ(4);
663 fSpiderLeadingHit[chan].SetPS(1);
664 fSpiderLeadingHit[chan].SetTOT(0);
665 fSpiderLeadingHit[chan].SetTOTBin(0);
666 //push hit into packed buffer
667 if (fPackedDataBuffer != 0x0)
668 fPackedDataBuffer->Add(fSpiderLeadingHit[chan]);
669 if (fVerbose==2)
670 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()));
671
672 }
673 fSpiderLeadingFlag[chan]=kFALSE;
674 }
675
676 return kFALSE;
677}
678
679//_________________________________________________________________
680
681Bool_t
682AliTOFDecoder::Spider(AliTOFHitData hitData){
683
684 /* main SPIDER routine.
685 it receives, reads, stores and packs
686 unpacked HPTDC data in packed data
687 object. it also fills buffers.
688 */
689
690 Int_t status;
691
692 if (fVerbose==2)
693 AliInfo("Hit data received");
694
695 //check if TDC is changed (slotID,chain,TDC triplet)
696 if (fSpiderCurrentSlotID!=hitData.GetSlotID() ||
697 fSpiderCurrentChain!=hitData.GetChain() ||
698 fSpiderCurrentTDC!=hitData.GetTDC() ){
699 if (fVerbose==2)
700 AliInfo("Data coming from a new TDC: reset buffers");
701 //reset spider
702 status = ResetSpider();
703 //set current TDC
704 fSpiderCurrentSlotID=hitData.GetSlotID();
705 fSpiderCurrentChain=hitData.GetChain();
706 fSpiderCurrentTDC=hitData.GetTDC();
707 }
708
709 //switch PS bits
710 switch (hitData.GetPS()){
711
712 case LEADING_HIT_PS:
713 if (fVerbose==2)
714 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()));
715 //check spider leading flag
716 if (fSpiderLeadingFlag[hitData.GetChan()]){
717 if (fVerbose==2)
718 AliInfo("Leading hit: buffer full, put previous in buffers as orphane and keep current");
719 //set TOT at zero for previous hit
720 fSpiderLeadingHit[hitData.GetChan()].SetACQ(4);
721 fSpiderLeadingHit[hitData.GetChan()].SetPS(1);
722 fSpiderLeadingHit[hitData.GetChan()].SetTOT(0);
723 fSpiderLeadingHit[hitData.GetChan()].SetTOTBin(0);
724 //push previous hit into packed buffer
725 if (fPackedDataBuffer != 0x0)
726 fPackedDataBuffer->Add(fSpiderLeadingHit[hitData.GetChan()]);
727 //set current hit
728 fSpiderLeadingHit[hitData.GetChan()]=hitData;
729 if (fVerbose==2)
730 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()));
731 }
732 else{
733 if (fVerbose==2)
734 AliInfo("Leading hit: buffer empty, keep current hit and set flag");
735 fSpiderLeadingHit[hitData.GetChan()]=hitData;
736 //set spider leading flag
737 fSpiderLeadingFlag[hitData.GetChan()]=kTRUE;
738 }
739 break;
740
741 case TRAILING_HIT_PS:
742 if (fVerbose==2)
743 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()));
744 //check spider leading flag
745 if (fSpiderLeadingFlag[hitData.GetChan()]){
746 if (fVerbose==2)
747 AliInfo("Trailing hit: buffer full, pack leading and trailing");
748 hitData.SetACQ(4);
749 hitData.SetPS(0);
750 hitData.SetTOT(hitData.GetTime()-fSpiderLeadingHit[hitData.GetChan()].GetTime());
751 hitData.SetTOTBin((Int_t)((hitData.GetTimeBin()-fSpiderLeadingHit[hitData.GetChan()].GetTimeBin())*TIME_TO_TOT_BIN_WIDTH));
752 hitData.SetTime(fSpiderLeadingHit[hitData.GetChan()].GetTime());
753 hitData.SetTimeBin(fSpiderLeadingHit[hitData.GetChan()].GetTimeBin());
754 //check TOT and set TOT overflow if TOT < 0
755 if (hitData.GetTOT() < 0){
756 hitData.SetPS(3);
757 hitData.SetTOT(0);
758 hitData.SetTOTBin(0);
759 }
760 if (fPackedDataBuffer != 0x0)
761 fPackedDataBuffer->Add(hitData);
762 if (fVerbose==2)
763 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()));
764 //unset spider leading flag
765 fSpiderLeadingFlag[hitData.GetChan()]=kFALSE;
766 }
767 else{
768 if (fVerbose==2)
769 AliInfo("Trailing hit: buffer empty, throw hit away");
770 }
771 break;
772 }
773 //end switch PS bits
774
775 return kFALSE;
776}