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