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