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