]>
Commit | Line | Data |
---|---|---|
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$ | |
18 | Revision 1.19 2007/05/18 13:07:53 decaro | |
19 | Error messages stored in the global raw-reader error log (Cvetan, Chiara) | |
20 | ||
21 | Revision 1.18 2007/05/08 11:53:29 arcelli | |
22 | Improved class flexibility for further use (R.Preghenella) | |
23 | ||
24 | Revision 1.17 2007/05/03 08:53:50 decaro | |
25 | Coding convention: RS3 violation -> suppression | |
26 | ||
27 | Revision 1.16 2007/05/03 08:22:22 decaro | |
28 | Coding convention: RN17 violation -> suppression | |
29 | ||
30 | Revision 1.15 2007/04/30 15:22:06 arcelli | |
31 | Change TOF digit Time, Tot etc to int type | |
32 | ||
33 | Revision 1.14 2007/04/27 11:11:53 arcelli | |
34 | updates for the new decoder | |
35 | ||
36 | Revision 1.13 2007/03/16 11:46:35 decaro | |
37 | Coding convention: RN17 rule violation -> suppression | |
38 | ||
39 | Revision 1.12 2007/02/22 09:43:45 decaro | |
40 | Added AliTOFRawStream::GetIndex method for online calibration (C.Zampolli) | |
41 | ||
42 | Revision 1.11 2007/02/20 15:57:00 decaro | |
43 | Raw data update: to read the TOF raw data defined in UNPACKED mode | |
44 | ||
45 | Revision 1.10 2006/12/15 14:01:38 cvetan | |
46 | Memory leak fixed | |
47 | ||
48 | Revision 1.9 2006/10/13 11:22:27 arcelli | |
49 | remove warnings due to uninitialized AliTOFtdcDigit data members | |
50 | ||
51 | Revision 1.8 2006/08/22 13:30:17 arcelli | |
52 | removal of effective c++ warnings (C.Zampolli) | |
53 | ||
54 | Revision 1.7 2006/08/10 14:46:54 decaro | |
55 | TOF raw data format: updated version | |
56 | ||
57 | Revision 1.6.1 2006/06/28 A. De Caro, R. Preghenella: | |
58 | Update TOF raw data format | |
59 | according to the final version | |
60 | (see the ALICE internal note in preparation | |
61 | 'ALICE TOF raw data format') | |
62 | Added the methods for the correspoonding numbering | |
63 | between the equipment IDs and the volume IDs: | |
64 | Equip2VolNPlate(...) | |
65 | Equip2VolNStrip(...) | |
66 | Equip2VolNPad(...) | |
67 | ||
68 | Revision 0.02 2005/07/28 A. De Caro: | |
69 | Update format TOF raw data | |
70 | (temporary solution) | |
71 | Correction of few wrong corrispondences | |
72 | between 'software' and 'hardware' numberings | |
73 | ||
74 | Revision 0.01 2005/07/22 A. De Caro | |
75 | Implement methods Next() | |
76 | GetSector(), | |
77 | GetPlate(), | |
78 | GetStrip(), | |
79 | GetPadZ(), | |
80 | GetPadX() | |
81 | */ | |
82 | ||
83 | //////////////////////////////////////////////////////////////////////// | |
84 | // // | |
85 | // This class provides access to TOF raw data in DDL files. // | |
86 | // // | |
87 | // It loops over all TOF raw data given by the AliRawReader. // | |
88 | // // | |
89 | //////////////////////////////////////////////////////////////////////// | |
90 | ||
91 | ||
92 | #include "Riostream.h" | |
93 | ||
94 | #include "TClonesArray.h" | |
95 | ||
96 | #include "AliDAQ.h" | |
97 | #include "AliLog.h" | |
98 | #include "AliRawReader.h" | |
99 | ||
100 | #include "AliTOFGeometry.h" | |
101 | #include "AliTOFrawData.h" | |
102 | #include "AliTOFRawMap.h" | |
103 | #include "AliTOFRawStream.h" | |
104 | ||
105 | #include "AliTOFHitData.h" | |
106 | ||
107 | ClassImp(AliTOFRawStream) | |
108 | ||
109 | ||
110 | //_____________________________________________________________________________ | |
111 | AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader): | |
112 | fRawReader(rawReader), | |
113 | fTOFrawData(0x0), | |
114 | fDecoder(new AliTOFDecoder()), | |
115 | fDDL(-1), | |
116 | fTRM(-1), | |
117 | fTRMchain(-1), | |
118 | fTDC(-1), | |
119 | fTDCchannel(-1), | |
120 | fTime(-1), | |
121 | fToT(-1), | |
122 | fLeadingEdge(-1), | |
123 | fTrailingEdge(-1), | |
124 | fErrorFlag(-1), | |
125 | fSector(-1), | |
126 | fPlate(-1), | |
127 | fStrip(-1), | |
128 | fPadX(-1), | |
129 | fPadZ(-1), | |
130 | fPackedDigits(0), | |
131 | fWordType(-1), | |
132 | fSlotID(-1), | |
133 | fACQ(-1), | |
134 | fPSbit(-1), | |
135 | fTDCerrorFlag(-1), | |
136 | fInsideDRM(kFALSE), | |
137 | fInsideTRM(kFALSE), | |
138 | fInsideLTM(kFALSE), | |
139 | fInsideTRMchain0(kFALSE), | |
140 | fInsideTRMchain1(kFALSE) | |
141 | { | |
142 | // | |
143 | // create an object to read TOF raw digits | |
144 | // | |
145 | ||
146 | for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){ | |
147 | fDataBuffer[i]=new AliTOFHitDataBuffer(); | |
148 | fPackedDataBuffer[i]=new AliTOFHitDataBuffer(); | |
149 | } | |
150 | ||
151 | fTOFrawData = new TClonesArray("AliTOFrawData",1000); | |
152 | fTOFrawData->SetOwner(); | |
153 | ||
154 | fRawReader->Reset(); | |
155 | fRawReader->Select("TOF"); | |
156 | } | |
157 | ||
158 | //_____________________________________________________________________________ | |
159 | AliTOFRawStream::AliTOFRawStream(): | |
160 | fRawReader(0x0), | |
161 | fTOFrawData(0x0), | |
162 | fDecoder(new AliTOFDecoder()), | |
163 | fDDL(-1), | |
164 | fTRM(-1), | |
165 | fTRMchain(-1), | |
166 | fTDC(-1), | |
167 | fTDCchannel(-1), | |
168 | fTime(-1), | |
169 | fToT(-1), | |
170 | fLeadingEdge(-1), | |
171 | fTrailingEdge(-1), | |
172 | fErrorFlag(-1), | |
173 | fSector(-1), | |
174 | fPlate(-1), | |
175 | fStrip(-1), | |
176 | fPadX(-1), | |
177 | fPadZ(-1), | |
178 | fPackedDigits(0), | |
179 | fWordType(-1), | |
180 | fSlotID(-1), | |
181 | fACQ(-1), | |
182 | fPSbit(-1), | |
183 | fTDCerrorFlag(-1), | |
184 | fInsideDRM(kFALSE), | |
185 | fInsideTRM(kFALSE), | |
186 | fInsideLTM(kFALSE), | |
187 | fInsideTRMchain0(kFALSE), | |
188 | fInsideTRMchain1(kFALSE) | |
189 | { | |
190 | // | |
191 | // default ctr | |
192 | // | |
193 | for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){ | |
194 | fDataBuffer[i]=new AliTOFHitDataBuffer(); | |
195 | fPackedDataBuffer[i]=new AliTOFHitDataBuffer(); | |
196 | } | |
197 | ||
198 | fTOFrawData = new TClonesArray("AliTOFrawData",1000); | |
199 | fTOFrawData->SetOwner(); | |
200 | } | |
201 | ||
202 | //_____________________________________________________________________________ | |
203 | AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) : | |
204 | TObject(stream), | |
205 | fRawReader(0x0), | |
206 | fTOFrawData(0x0), | |
207 | fDecoder(new AliTOFDecoder()), | |
208 | fDDL(-1), | |
209 | fTRM(-1), | |
210 | fTRMchain(-1), | |
211 | fTDC(-1), | |
212 | fTDCchannel(-1), | |
213 | fTime(-1), | |
214 | fToT(-1), | |
215 | fLeadingEdge(-1), | |
216 | fTrailingEdge(-1), | |
217 | fErrorFlag(-1), | |
218 | fSector(-1), | |
219 | fPlate(-1), | |
220 | fStrip(-1), | |
221 | fPadX(-1), | |
222 | fPadZ(-1), | |
223 | fPackedDigits(0), | |
224 | fWordType(-1), | |
225 | fSlotID(-1), | |
226 | fACQ(-1), | |
227 | fPSbit(-1), | |
228 | fTDCerrorFlag(-1), | |
229 | fInsideDRM(kFALSE), | |
230 | fInsideTRM(kFALSE), | |
231 | fInsideLTM(kFALSE), | |
232 | fInsideTRMchain0(kFALSE), | |
233 | fInsideTRMchain1(kFALSE) | |
234 | { | |
235 | // | |
236 | // copy constructor | |
237 | // | |
238 | ||
239 | fRawReader = stream.fRawReader; | |
240 | ||
241 | fTOFrawData = stream.fTOFrawData; | |
242 | ||
243 | fDDL = stream.fDDL; | |
244 | fTRM = stream.fTRM; | |
245 | fTRMchain = stream.fTRMchain; | |
246 | fTDC = stream.fTDC; | |
247 | fTDCchannel = stream.fTDCchannel; | |
248 | fTime = stream.fTime; | |
249 | fToT = stream.fToT; | |
250 | fLeadingEdge = stream.fLeadingEdge; | |
251 | fTrailingEdge = stream.fTrailingEdge; | |
252 | ||
253 | fErrorFlag = stream.fErrorFlag; | |
254 | ||
255 | fSector = stream.fSector; | |
256 | fPlate = stream.fPlate; | |
257 | fStrip = stream.fStrip; | |
258 | fPadX = stream.fPadX; | |
259 | fPadZ = stream.fPadZ; | |
260 | ||
261 | fPackedDigits = stream.fPackedDigits; | |
262 | ||
263 | fWordType = stream.fWordType; | |
264 | fSlotID = stream.fSlotID; | |
265 | fACQ = stream.fACQ; | |
266 | fPSbit = stream.fPSbit; | |
267 | fTDCerrorFlag = stream.fTDCerrorFlag; | |
268 | fInsideDRM = stream.fInsideDRM; | |
269 | fInsideTRM = stream.fInsideTRM; | |
270 | fInsideLTM = stream.fInsideLTM; | |
271 | fInsideTRMchain0 = stream.fInsideTRMchain0; | |
272 | fInsideTRMchain1 = stream.fInsideTRMchain1; | |
273 | ||
274 | for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){ | |
275 | fDataBuffer[i]= new AliTOFHitDataBuffer(*stream.fDataBuffer[i]); | |
276 | fPackedDataBuffer[i]= new AliTOFHitDataBuffer(*stream.fPackedDataBuffer[i]); | |
277 | } | |
278 | ||
279 | fTOFrawData = new TClonesArray(*stream.fTOFrawData); | |
280 | ||
281 | } | |
282 | ||
283 | //_____________________________________________________________________________ | |
284 | AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream) | |
285 | { | |
286 | // | |
287 | // assignment operator | |
288 | // | |
289 | ||
290 | fRawReader = stream.fRawReader; | |
291 | ||
292 | fTOFrawData = stream.fTOFrawData; | |
293 | ||
294 | fDDL = stream.fDDL; | |
295 | fTRM = stream.fTRM; | |
296 | fTRMchain = stream.fTRMchain; | |
297 | fTDC = stream.fTDC; | |
298 | fTDCchannel = stream.fTDCchannel; | |
299 | fTime = stream.fTime; | |
300 | fToT = stream.fToT; | |
301 | fLeadingEdge = stream.fLeadingEdge; | |
302 | fTrailingEdge = stream.fTrailingEdge; | |
303 | fErrorFlag = stream.fErrorFlag; | |
304 | ||
305 | fSector = stream.fSector; | |
306 | fPlate = stream.fPlate; | |
307 | fStrip = stream.fStrip; | |
308 | fPadX = stream.fPadX; | |
309 | fPadZ = stream.fPadZ; | |
310 | ||
311 | fPackedDigits = stream.fPackedDigits; | |
312 | ||
313 | fWordType = stream.fWordType; | |
314 | fSlotID = stream.fSlotID; | |
315 | fACQ = stream.fACQ; | |
316 | fPSbit = stream.fPSbit; | |
317 | fTDCerrorFlag = stream.fTDCerrorFlag; | |
318 | fInsideDRM = stream.fInsideDRM; | |
319 | fInsideTRM = stream.fInsideTRM; | |
320 | fInsideLTM = stream.fInsideLTM; | |
321 | fInsideTRMchain0 = stream.fInsideTRMchain0; | |
322 | fInsideTRMchain1 = stream.fInsideTRMchain1; | |
323 | ||
324 | for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){ | |
325 | fDataBuffer[i] = stream.fDataBuffer[i]; | |
326 | fPackedDataBuffer[i] = stream.fPackedDataBuffer[i]; | |
327 | } | |
328 | ||
329 | fTOFrawData = stream.fTOFrawData; | |
330 | ||
331 | return *this; | |
332 | ||
333 | } | |
334 | ||
335 | //_____________________________________________________________________________ | |
336 | AliTOFRawStream::~AliTOFRawStream() | |
337 | { | |
338 | // destructor | |
339 | ||
340 | fPackedDigits = 0; | |
341 | ||
342 | for (Int_t i=0;i<72;i++){ | |
343 | delete fDataBuffer[i]; | |
344 | delete fPackedDataBuffer[i]; | |
345 | } | |
346 | ||
347 | delete fDecoder; | |
348 | ||
349 | fTOFrawData->Clear(); | |
350 | delete fTOFrawData; | |
351 | } | |
352 | ||
353 | ||
354 | //_____________________________________________________________________________ | |
355 | ||
356 | void AliTOFRawStream::LoadRawData(Int_t indexDDL) | |
357 | { | |
358 | // | |
359 | // To load raw data | |
360 | // | |
361 | ||
362 | fTOFrawData->Clear(); | |
363 | ||
364 | TClonesArray &arrayTofRawData = *fTOFrawData; | |
365 | ||
366 | fPackedDigits = 0; | |
367 | ||
368 | // create raw data map | |
369 | AliTOFRawMap *rawMap = new AliTOFRawMap(fTOFrawData); | |
370 | rawMap->Clear(); | |
371 | ||
372 | Int_t slot[4] = {-1, -1, -1, -1}; | |
373 | ||
374 | fRawReader->Reset(); | |
375 | fRawReader->Select("TOF", indexDDL, indexDDL); | |
376 | ||
377 | Bool_t signal = kFALSE; | |
378 | ||
379 | AliTOFrawData *rawDigit = NULL; | |
380 | ||
381 | while(Next()) { | |
382 | ||
383 | signal = (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1); | |
384 | if (signal) { | |
385 | AliDebug(2,Form(" %2i %1i %2i %1i %2i \n", fSector, fPlate, fStrip, fPadZ, fPadX)); | |
386 | ||
387 | slot[0] = fTRM; | |
388 | slot[1] = fTRMchain; | |
389 | slot[2] = fTDC; | |
390 | slot[3] = fTDCchannel; | |
391 | ||
392 | if (rawMap->TestHit(slot) != kEmpty) { | |
393 | ||
394 | rawDigit = static_cast<AliTOFrawData*>(rawMap->GetHit(slot)); | |
395 | ||
396 | if (rawDigit->GetLeading()!=-1 && rawDigit->GetTrailing()==-1 && | |
397 | fLeadingEdge==-1 && fTrailingEdge!=-1) { | |
398 | ||
399 | rawDigit->Update(fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag); | |
400 | } | |
401 | else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) && | |
402 | (fLeadingEdge!=-1 || fTrailingEdge!=-1 || fTime!=-1) ) | |
403 | ||
404 | ) | |
405 | { | |
406 | ||
407 | new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag); | |
408 | ||
409 | rawMap->SetHit(slot); | |
410 | ||
411 | } | |
412 | ||
413 | ||
414 | } | |
415 | else { | |
416 | ||
417 | new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag); | |
418 | ||
419 | rawMap->SetHit(slot); | |
420 | ||
421 | } // else if (rawMap->TestHit(slot) == kEmpty) | |
422 | ||
423 | } // if (signal) | |
424 | ||
425 | } // closed -> while (Next()) | |
426 | ||
427 | rawMap->Delete(); | |
428 | ||
429 | } | |
430 | ||
431 | //_____________________________________________________________________________ | |
432 | Bool_t AliTOFRawStream::Next() | |
433 | { | |
434 | // | |
435 | // Read next 32-bit word in TOF raw data files | |
436 | // returns kFALSE if there is no word left | |
437 | // | |
438 | ||
439 | UInt_t data; | |
440 | ||
441 | if (!fRawReader->ReadNextInt(data)) return kFALSE; | |
442 | ||
443 | if (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1) { | |
444 | fSector = -1; | |
445 | fPlate = -1; | |
446 | fStrip = -1; | |
447 | fPadZ = -1; | |
448 | fPadX = -1; | |
449 | fTime = -1; | |
450 | fToT = -1; | |
451 | fLeadingEdge = -1; | |
452 | fTrailingEdge = -1; | |
453 | } | |
454 | ||
455 | fDDL = fRawReader->GetDDLID(); | |
456 | ||
457 | fWordType = GetField(data,WORD_TYPE_MASK,WORD_TYPE_POSITION); | |
458 | ||
459 | switch (fWordType) { // switch word type | |
460 | ||
461 | case GLOBAL_HEADER_TYPE: // global header | |
462 | fSlotID = GetField(data, HEADER_SLOT_ID_MASK, HEADER_SLOT_ID_POSITION); | |
463 | fTRM = fSlotID; | |
464 | ||
465 | ||
466 | switch (fSlotID) { // switch global header slot ID | |
467 | ||
468 | case DRM_ID_NUMBER: //DRM global header | |
469 | if (fInsideDRM) { // unexpected DRM global headers -> exit | |
470 | break; | |
471 | } | |
472 | fInsideDRM = kTRUE; // DRM global header accepted | |
473 | break; | |
474 | ||
475 | case LTM_ID_NUMBER: // LTM global header | |
476 | if (fInsideLTM) { // unexpected LTM global headers -> exit | |
477 | break; | |
478 | } | |
479 | fInsideLTM = kTRUE; // LTM global header accepted | |
480 | break; | |
481 | ||
482 | case 3: //TRM header | |
483 | case 4: //TRM header | |
484 | case 5: //TRM header | |
485 | case 6: //TRM header | |
486 | case 7: //TRM header | |
487 | case 8: //TRM header | |
488 | case 9: //TRM header | |
489 | case 10: //TRM header | |
490 | case 11: //TRM header | |
491 | case 12: //TRM header | |
492 | if (fInsideTRM) { // unexpected TRM global headers -> exit | |
493 | break; | |
494 | } | |
495 | fInsideTRM = kTRUE; // TRM global header accepted | |
496 | fACQ = GetField(data,TRM_ACQ_BITS_MASK,TRM_ACQ_BITS_POSITION); | |
497 | break; | |
498 | ||
499 | default: // unexpected global header slot ID | |
500 | break; | |
501 | ||
502 | } //end switch global header slot id | |
503 | ||
504 | break; | |
505 | ||
506 | ||
507 | case GLOBAL_TRAILER_TYPE: // global trailer | |
508 | fSlotID = GetField(data,HEADER_SLOT_ID_MASK,HEADER_SLOT_ID_POSITION); | |
509 | ||
510 | ||
511 | switch (fSlotID) { // switch global trailer slot ID | |
512 | ||
513 | case DRM_ID_NUMBER: // DRM global trailer | |
514 | if (!fInsideDRM) { // unexpected DRM global trailers -> exit | |
515 | break; | |
516 | } | |
517 | fInsideDRM = kFALSE; // DRM global trailer accepted | |
518 | fInsideTRM = kFALSE; | |
519 | fInsideLTM = kFALSE; | |
520 | fInsideTRMchain0 = kFALSE; | |
521 | fInsideTRMchain1 = kFALSE; | |
522 | fSector = -1; | |
523 | fPlate = -1; | |
524 | fStrip = -1; | |
525 | fPadZ = -1; | |
526 | fPadX = -1; | |
527 | fDDL = -1; | |
528 | fTRM = -1; | |
529 | fTDC = -1; | |
530 | fTRMchain = -1; | |
531 | fTDCchannel = -1; | |
532 | fTime = -1; | |
533 | fToT = -1; | |
534 | fLeadingEdge = -1; | |
535 | fTrailingEdge = -1; | |
536 | fErrorFlag = -1; | |
537 | fACQ = -1; | |
538 | fPSbit = -1; | |
539 | fTDCerrorFlag = -1; | |
540 | break; | |
541 | case LTM_ID_NUMBER: // LTM global trailer | |
542 | if (!fInsideLTM) { // unexpected LTM global trailer -> exit | |
543 | break; | |
544 | } | |
545 | fInsideLTM = kFALSE; // LTM global trailer accepted | |
546 | break; | |
547 | case 15: //TRM global trailer | |
548 | if (!fInsideTRM) { // unexpected TRM global trailers -> exit | |
549 | break; | |
550 | } | |
551 | fInsideTRM = kFALSE; // TRM global trailer accepted | |
552 | break; | |
553 | default: // unexpected global trailer slot ID | |
554 | break; | |
555 | } //end switch global trailer slot id | |
556 | ||
557 | ||
558 | break; | |
559 | ||
560 | ||
561 | case ERROR_TYPE: // TDC error | |
562 | fTDC = GetField(data,TRM_TDC_ERROR_TDC_ID_MASK,TRM_TDC_ERROR_TDC_ID_POSITION); | |
563 | fTDCerrorFlag = GetField(data,TRM_TDC_ERROR_FLAGS_MASK,TRM_TDC_ERROR_FLAGS_POSITION); | |
564 | break; | |
565 | ||
566 | ||
567 | case FILLER_TYPE: // filler | |
568 | break; | |
569 | ||
570 | ||
571 | default: // other word types | |
572 | ||
573 | if (fInsideTRM) { // inside TRM | |
574 | ||
575 | switch (fWordType) { // switch word type inside TRM | |
576 | case TRM_CHAIN0_HEADER_TYPE: // TRM chain0 header | |
577 | if (fInsideTRMchain0) { // unexpected TRM chain0 header | |
578 | break; | |
579 | } | |
580 | fInsideTRMchain0 = kTRUE; | |
581 | fTRMchain = 0; | |
582 | break; | |
583 | case TRM_CHAIN0_TRAILER_TYPE: // TRM chain0 trailer | |
584 | if (!fInsideTRMchain0) { // unexpected TRM chain0 trailer | |
585 | break; | |
586 | } | |
587 | fInsideTRMchain0 = kFALSE; | |
588 | fTRMchain = -1; | |
589 | break; | |
590 | case TRM_CHAIN1_HEADER_TYPE: // TRM chain1 header | |
591 | if (fInsideTRMchain1) { // unexpected TRM chain1 header | |
592 | break; | |
593 | } | |
594 | fInsideTRMchain1 = kTRUE; | |
595 | fTRMchain = 1; | |
596 | break; | |
597 | case TRM_CHAIN1_TRAILER_TYPE: // TRM chain1 trailer | |
598 | if (!fInsideTRMchain1) { // unexpected TRM chain1 trailer | |
599 | break; | |
600 | } | |
601 | fInsideTRMchain1 = kFALSE; | |
602 | fTRMchain = -1; | |
603 | break; | |
604 | } // end switch word type inside TRM | |
605 | ||
606 | } // end if (fInsideTRM) | |
607 | ||
608 | ||
609 | if ( | |
610 | ((fInsideTRMchain0&&!fInsideTRMchain1) || (!fInsideTRMchain0&&fInsideTRMchain1)) | |
611 | && fWordType!=TRM_CHAIN0_HEADER_TYPE && fWordType!=TRM_CHAIN0_TRAILER_TYPE | |
612 | && fWordType!=TRM_CHAIN1_HEADER_TYPE && fWordType!=TRM_CHAIN1_TRAILER_TYPE | |
613 | ){ // inside TRM chains | |
614 | ||
615 | fPSbit = GetField(data,TRM_PS_BITS_MASK,TRM_PS_BITS_POSITION); | |
616 | fTDC = GetField(data,TRM_TDC_ID_MASK,TRM_TDC_ID_POSITION); | |
617 | fTDCchannel = GetField(data,TRM_CHAN_MASK,TRM_CHAN_POSITION); | |
618 | fErrorFlag = GetField(data,TRM_E_BIT_MASK,TRM_E_BIT_POSITION); | |
619 | ||
620 | SetSector(); | |
621 | SetPlate(); | |
622 | SetStrip(); | |
623 | SetPadZ(); | |
624 | SetPadX(); | |
625 | ||
626 | ||
627 | switch (fPSbit) { // switch fPSbit bits inside TRM chains | |
628 | ||
629 | case 0: // packing ok, digit time and TOT | |
630 | fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION); | |
631 | fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION); | |
632 | break; | |
633 | ||
634 | case 1: // leading edge digit, long digit time, no TOT | |
635 | //fToT = -1; | |
636 | //fTime = -1; | |
637 | fLeadingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION); | |
638 | break; | |
639 | ||
640 | case 2: // trailing edge digit, long digit time, no TOT | |
641 | //fToT = -1; | |
642 | //fTime = -1; | |
643 | fTrailingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION); | |
644 | break; | |
645 | ||
646 | case 3: // TOT overflow | |
647 | fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION); | |
648 | fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION); | |
649 | break; | |
650 | ||
651 | } // end switch PS bits inside TRM chains | |
652 | ||
653 | } // end if is inside TRM chains | |
654 | ||
655 | } // end switch on fWordType | |
656 | ||
657 | ||
658 | return kTRUE; | |
659 | ||
660 | } | |
661 | //_____________________________________________________________________________ | |
662 | ||
663 | void AliTOFRawStream::SetSector() | |
664 | { | |
665 | // | |
666 | // Evaluate the TOF sector number -> [ 0;17] | |
667 | // corresponding to the TOF equipment IDs: | |
668 | // fDDL -> [ 0;71] | |
669 | // fTRM -> [ 3;12] | |
670 | // fTRMchain -> [ 0; 1] | |
671 | // fTDC -> [ 0;14] | |
672 | // fTDCchannel -> [ 0; 7] | |
673 | // | |
674 | ||
675 | Int_t iSector = -1; | |
676 | ||
677 | if (!(fDDL==-1)) iSector = Int_t((Float_t)(fDDL)/AliTOFGeometry::NDDL()); | |
678 | ||
679 | fSector = iSector; | |
680 | ||
681 | } | |
682 | //_____________________________________________________________________________ | |
683 | ||
684 | ||
685 | void AliTOFRawStream::SetPlate() | |
686 | { | |
687 | // | |
688 | // Evaluate the TOF plate number ->[ 0; 4] | |
689 | // corresponding to the TOF equipment IDs: | |
690 | // fDDL -> [ 0;71] | |
691 | // fTRM -> [ 3;12] | |
692 | // fTRMchain -> [ 0; 1] | |
693 | // fTDC -> [ 0;14] | |
694 | // fTDCchannel -> [ 0; 7] | |
695 | // | |
696 | ||
697 | Int_t iPlate = -1; | |
698 | if (!(fDDL==-1 || fTRM==-1 || fTDC==-1 | |
699 | || fSector==-1)) | |
700 | iPlate = Equip2VolNplate(GetDDLnumberPerSector(fDDL), fTRM, fTDC); | |
701 | ||
702 | fPlate = iPlate; | |
703 | ||
704 | } | |
705 | //_____________________________________________________________________________ | |
706 | ||
707 | void AliTOFRawStream::SetStrip() | |
708 | { | |
709 | // | |
710 | // Evaluate the TOF strip number per module -> [ 0; 14/18] | |
711 | // corresponding to the TOF equipment IDs: | |
712 | // fDDL -> [ 0;71] | |
713 | // fTRM -> [ 3;12] | |
714 | // fTRMchain -> [ 0; 1] | |
715 | // fTDC -> [ 0;14] | |
716 | // fTDCchannel -> [ 0; 7] | |
717 | // | |
718 | ||
719 | Int_t iStrip = -1; | |
720 | ||
721 | if (!(fDDL==-1 || fTRM==-1 || fTDC==-1 | |
722 | || fSector==-1 || fPlate==-1)) | |
723 | iStrip = Equip2VolNstrip(GetDDLnumberPerSector(fDDL), fTRM, fTDC); | |
724 | ||
725 | fStrip = iStrip; | |
726 | ||
727 | } | |
728 | //_____________________________________________________________________________ | |
729 | ||
730 | void AliTOFRawStream::SetPadZ() | |
731 | { | |
732 | // | |
733 | // Evaluate the TOF padRow number per strip -> [ 0; 1] | |
734 | // corresponding to the TOF equipment IDs: | |
735 | // fDDL -> [ 0;71] | |
736 | // fTRM -> [ 3;12] | |
737 | // fTRMchain -> [ 0; 1] | |
738 | // fTDC -> [ 0;14] | |
739 | // fTDCchannel -> [ 0; 7] | |
740 | // | |
741 | ||
742 | Int_t iPadZ = -1; | |
743 | ||
744 | if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1 | |
745 | || fSector==-1 || fPlate==-1 || fStrip==-1)) | |
746 | { | |
747 | Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel); | |
748 | if (iPadAlongTheStrip!=-1) | |
749 | iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ(); | |
750 | } | |
751 | ||
752 | fPadZ = iPadZ; | |
753 | ||
754 | } | |
755 | //_____________________________________________________________________________ | |
756 | ||
757 | void AliTOFRawStream::SetPadX() | |
758 | { | |
759 | // | |
760 | // Evaluate the TOF pad number per strip padRow -> [ 0;47] | |
761 | // corresponding to the TOF equipment IDs: | |
762 | // fDDL -> [ 0;71] | |
763 | // fTRM -> [ 3;12] | |
764 | // fTRMchain -> [ 0; 1] | |
765 | // fTDC -> [ 0;14] | |
766 | // fTDCchannel -> [ 0; 7] | |
767 | // | |
768 | ||
769 | Int_t iPadX = -1; | |
770 | ||
771 | if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1 | |
772 | || fSector==-1 || fPlate==-1 || fStrip==-1)) | |
773 | { | |
774 | Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel); | |
775 | if (iPadAlongTheStrip!=-1) | |
776 | iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ()))); | |
777 | } | |
778 | ||
779 | fPadX = iPadX; | |
780 | ||
781 | } | |
782 | ||
783 | //---------------------------------------------------------------------------- | |
784 | Int_t AliTOFRawStream::GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const | |
785 | { | |
786 | // | |
787 | // | |
788 | // | |
789 | ||
790 | return ((word & fieldMask) >> fieldPosition); | |
791 | } | |
792 | ||
793 | //---------------------------------------------------------------------------- | |
794 | Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC) | |
795 | { | |
796 | // | |
797 | // Returns the TOF plate number [0;4] | |
798 | // corresponding to the TOF equipment ID numbers: | |
799 | // iDDL -> DDL number per sector [0;3] | |
800 | // nTRM -> TRM number [3;12] | |
801 | // nTDC -> TDC number [0;14] | |
802 | // | |
803 | ||
804 | Int_t iPlate = -1; | |
805 | if (iDDL==0) { | |
806 | ||
807 | if (nTRM>=4 && nTRM<7) { | |
808 | iPlate = 0; | |
809 | } else if (nTRM==7) { | |
810 | if (nTDC<12) iPlate = 0; | |
811 | else iPlate = 1; | |
812 | } else if (nTRM>=8 && nTRM<11) { | |
813 | iPlate = 1; | |
814 | } else if (nTRM==11) { | |
815 | if (nTDC<9) iPlate = 1; | |
816 | else iPlate = 2; | |
817 | }else if (nTRM==12) { | |
818 | iPlate = 2; | |
819 | } | |
820 | ||
821 | } else if (iDDL==1) { | |
822 | ||
823 | if (nTRM==3) { | |
824 | if (nTDC<3) iPlate = 0; | |
825 | } else if (nTRM>=4 && nTRM<7) { | |
826 | iPlate = 0; | |
827 | } else if (nTRM==7) { | |
828 | if (nTDC<6) iPlate = 1; | |
829 | else iPlate = 0; | |
830 | } else if (nTRM>=8 && nTRM<11) { | |
831 | iPlate = 1; | |
832 | } else if (nTRM==11) { | |
833 | if (nTDC<9) iPlate = 2; | |
834 | else iPlate = 1; | |
835 | } else if (nTRM==12) { | |
836 | iPlate = 2; | |
837 | } | |
838 | ||
839 | } else if (iDDL==2) { | |
840 | ||
841 | if (nTRM>=4 && nTRM<7) { | |
842 | iPlate = 4; | |
843 | } else if (nTRM==7) { | |
844 | if (nTDC<12) iPlate = 4; | |
845 | else iPlate = 3; | |
846 | } else if (nTRM>=8 && nTRM<11) { | |
847 | iPlate = 3; | |
848 | } else if (nTRM==11) { | |
849 | if (nTDC<9) iPlate = 3; | |
850 | else iPlate = 2; | |
851 | }else if (nTRM==12) { | |
852 | iPlate = 2; | |
853 | } | |
854 | ||
855 | } else if (iDDL==3) { | |
856 | ||
857 | if (nTRM==3) { | |
858 | if (nTDC<3) iPlate = 4; | |
859 | } else if (nTRM>=4 && nTRM<7) { | |
860 | iPlate = 4; | |
861 | } else if (nTRM==7) { | |
862 | if (nTDC<6) iPlate = 3; | |
863 | else iPlate = 4; | |
864 | } else if (nTRM>=8 && nTRM<11) { | |
865 | iPlate = 3; | |
866 | } else if (nTRM==11) { | |
867 | if (nTDC<9) iPlate = 2; | |
868 | else iPlate = 3; | |
869 | } else if (nTRM==12) { | |
870 | iPlate = 2; | |
871 | } | |
872 | ||
873 | } | |
874 | ||
875 | return iPlate; | |
876 | ||
877 | } | |
878 | ||
879 | //---------------------------------------------------------------------------- | |
880 | Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC) | |
881 | { | |
882 | // | |
883 | // Returns the TOF strip number per module: | |
884 | // [0;14], in the central plates, | |
885 | // [0;18], in the intermediate and external plates | |
886 | // corresponding to the TOF equipment ID numbers: | |
887 | // iDDL -> DDL number per sector [0;3] | |
888 | // nTRM -> TRM number [3;12] | |
889 | // nTDC -> TDC number [0;14] | |
890 | // | |
891 | ||
892 | Int_t iStrip = -1; | |
893 | ||
894 | if (iDDL==0) { | |
895 | ||
896 | if (nTRM== 4) iStrip = (Int_t)(nTDC/3.); | |
897 | else if (nTRM== 5) iStrip = 5 + (Int_t)(nTDC/3.); | |
898 | else if (nTRM== 6) iStrip = 10 + (Int_t)(nTDC/3.); | |
899 | else if (nTRM== 7) { | |
900 | if (nTDC<12) iStrip = 15 + (Int_t)(nTDC/3.); | |
901 | else iStrip = (Int_t)(nTDC/3.) - 4; | |
902 | } | |
903 | else if (nTRM== 8) iStrip = 1 + (Int_t)(nTDC/3.); | |
904 | else if (nTRM== 9) iStrip = 6 + (Int_t)(nTDC/3.); | |
905 | else if (nTRM==10) iStrip = 11 + (Int_t)(nTDC/3.); | |
906 | else if (nTRM==11) { | |
907 | if (nTDC<9) iStrip = 16 + (Int_t)(nTDC/3.); | |
908 | else iStrip = (Int_t)(nTDC/3.) - 3; | |
909 | } | |
910 | else if (nTRM==12) iStrip = 2 + (Int_t)(nTDC/3.); | |
911 | ||
912 | } else if (iDDL==1) { | |
913 | ||
914 | if (nTRM==3 && nTDC<3) iStrip = (Int_t)(nTDC/3.); | |
915 | else if (nTRM== 4) iStrip = 5 - (Int_t)(nTDC/3.); | |
916 | else if (nTRM== 5) iStrip = 10 - (Int_t)(nTDC/3.); | |
917 | else if (nTRM== 6) iStrip = 15 - (Int_t)(nTDC/3.); | |
918 | else if (nTRM== 7) { | |
919 | if (nTDC<6) iStrip = 1 - (Int_t)(nTDC/3.); | |
920 | else iStrip = 20 - (Int_t)(nTDC/3.); | |
921 | } | |
922 | else if (nTRM== 8) iStrip = 6 - (Int_t)(nTDC/3.); | |
923 | else if (nTRM== 9) iStrip = 11 - (Int_t)(nTDC/3.); | |
924 | else if (nTRM==10) iStrip = 16 - (Int_t)(nTDC/3.); | |
925 | else if (nTRM==11) { | |
926 | if (nTDC<9) iStrip = 2 - (Int_t)(nTDC/3.); | |
927 | else iStrip = 21 - (Int_t)(nTDC/3.); | |
928 | } | |
929 | else if (nTRM==12) iStrip = 7 - (Int_t)(nTDC/3.); | |
930 | ||
931 | } else if (iDDL==2) { | |
932 | ||
933 | if (nTRM== 4) iStrip = 18 - (Int_t)(nTDC/3.); | |
934 | else if (nTRM== 5) iStrip = 18 - ( 5 + (Int_t)(nTDC/3.)); | |
935 | else if (nTRM== 6) iStrip = 18 - (10 + (Int_t)(nTDC/3.)); | |
936 | else if (nTRM== 7) { | |
937 | if (nTDC<12) iStrip = 18 - (15 + (Int_t)(nTDC/3.)); | |
938 | else iStrip = 18 - ((Int_t)(nTDC/3.) - 4); | |
939 | } | |
940 | else if (nTRM== 8) iStrip = 18 - ( 1 + (Int_t)(nTDC/3.)); | |
941 | else if (nTRM== 9) iStrip = 18 - ( 6 + (Int_t)(nTDC/3.)); | |
942 | else if (nTRM==10) iStrip = 18 - (11 + (Int_t)(nTDC/3.)); | |
943 | else if (nTRM==11) { | |
944 | if (nTDC<9) iStrip = 18 - (16 + (Int_t)(nTDC/3.)); | |
945 | else iStrip = 14 - ((Int_t)(nTDC/3.) - 3); | |
946 | } | |
947 | else if (nTRM==12) iStrip = 14 - ( 2 + (Int_t)(nTDC/3.)); | |
948 | ||
949 | } else if (iDDL==3) { | |
950 | ||
951 | if (nTRM==3 && nTDC<3) iStrip = 18 - (Int_t)(nTDC/3.); | |
952 | else if (nTRM== 4) iStrip = 18 - ( 5 - (Int_t)(nTDC/3.)); | |
953 | else if (nTRM== 5) iStrip = 18 - (10 - (Int_t)(nTDC/3.)); | |
954 | else if (nTRM== 6) iStrip = 18 - (15 - (Int_t)(nTDC/3.)); | |
955 | else if (nTRM== 7) { | |
956 | if (nTDC<6) iStrip = 18 - (1 - (Int_t)(nTDC/3.)); | |
957 | else iStrip = 18 - (20 - (Int_t)(nTDC/3.)); | |
958 | } | |
959 | else if (nTRM== 8) iStrip = 18 - ( 6 - (Int_t)(nTDC/3.)); | |
960 | else if (nTRM== 9) iStrip = 18 - (11 - (Int_t)(nTDC/3.)); | |
961 | else if (nTRM==10) iStrip = 18 - (16 - (Int_t)(nTDC/3.)); | |
962 | else if (nTRM==11) { | |
963 | if (nTDC<9) iStrip = 14 - ( 2 - (Int_t)(nTDC/3.)); | |
964 | else iStrip = 18 - (21 - (Int_t)(nTDC/3.)); | |
965 | } | |
966 | else if (nTRM==12) iStrip = 14 - ( 7 - (Int_t)(nTDC/3.)); | |
967 | ||
968 | } | |
969 | ||
970 | return iStrip; | |
971 | ||
972 | } | |
973 | ||
974 | //---------------------------------------------------------------------------- | |
975 | Int_t AliTOFRawStream::Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC, | |
976 | Int_t iCH) | |
977 | { | |
978 | // | |
979 | // Returns the TOF pad number per strip [0;95] | |
980 | // corresponding to the TOF equipment ID numbers: | |
981 | // iDDL -> DDL number per sector [0;3] | |
982 | // iChain -> TRM chain number [0;1] | |
983 | // nTDC -> TDC number [0;14] | |
984 | // iCH -> TDC channel number [0;7] | |
985 | // | |
986 | ||
987 | Int_t iPadAlongTheStrip = -1; | |
988 | ||
989 | Int_t iTDClocal = nTDC%3 + (1-iChain)*3; | |
990 | ||
991 | if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal; | |
992 | else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal); | |
993 | ||
994 | Int_t iCHlocal = iCH; | |
995 | if (iDDL==0 || iDDL==3) iCHlocal = 7 - iCH; | |
996 | ||
997 | iPadAlongTheStrip = iTDClocal*AliTOFGeometry::NCh() + iCHlocal; | |
998 | ||
999 | if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) || | |
1000 | ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX())) { | |
1001 | std::cerr << "Problems with the padX number!" << endl; | |
1002 | //AliWarning("Problems with the padX number!"); | |
1003 | } | |
1004 | return iPadAlongTheStrip; | |
1005 | ||
1006 | } | |
1007 | ||
1008 | //---------------------------------------------------------------------------- | |
1009 | Int_t AliTOFRawStream::GetSectorNumber(Int_t nDDL) const | |
1010 | { | |
1011 | // | |
1012 | // Returns the sector number [0;17] | |
1013 | // corresponing to the assigned DRM/DDL number [0;71] | |
1014 | // | |
1015 | ||
1016 | Int_t iSector = Int_t((Float_t)(nDDL)/AliTOFGeometry::NDDL()); | |
1017 | ||
1018 | return iSector; | |
1019 | ||
1020 | } | |
1021 | //---------------------------------------------------------------------------- | |
1022 | Int_t AliTOFRawStream::GetDDLnumberPerSector(Int_t nDDL) const | |
1023 | { | |
1024 | // | |
1025 | // Return the DRM/DDL number per sector [0;3] | |
1026 | // corresponing to the assigned DRM/DDL number [0;71] | |
1027 | // | |
1028 | ||
1029 | Int_t iDDL = nDDL%AliTOFGeometry::NDDL(); | |
1030 | ||
1031 | return iDDL; | |
1032 | ||
1033 | } | |
1034 | ||
1035 | //---------------------------------------------------------------------------- | |
1036 | void AliTOFRawStream::EquipmentId2VolumeId(AliTOFHitData *hitData, Int_t *volume) const | |
1037 | { | |
1038 | EquipmentId2VolumeId(hitData->GetDDLID(),hitData->GetSlotID(),hitData->GetChain(),hitData->GetTDC(),hitData->GetChan(),volume); | |
1039 | } | |
1040 | //---------------------------------------------------------------------------- | |
1041 | void AliTOFRawStream::EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain, | |
1042 | Int_t nTDC, Int_t iCH, | |
1043 | Int_t *volume) const | |
1044 | { | |
1045 | // | |
1046 | // To convert: | |
1047 | // nDDL (variable in [0;71]) -> number of the DDL file | |
1048 | // nTRM (variable in [3;12]) -> number of the TRM slot | |
1049 | // iChain (variable in [0; 1]) -> number of the TRM chain | |
1050 | // nTDC (variable in [0;14]) -> number of the TDC | |
1051 | // iCH (variable in [0; 7]) -> number of the TDC channel | |
1052 | // | |
1053 | // in: | |
1054 | // sector number, i.e. volume[0] (variable in [0,17]) | |
1055 | // plate number, i.e. volume[1] (variable in [0, 5]) | |
1056 | // strip number, i.e. volume[2] (variable in [0,14/18]) | |
1057 | // padX number, i.e. volume[3] (variable in [0,47]) | |
1058 | // padZ number, i.e. volume[4] (variable in [0, 1]) | |
1059 | // | |
1060 | ||
1061 | Int_t iDDL = GetDDLnumberPerSector(nDDL); | |
1062 | ||
1063 | Int_t iSector = GetSectorNumber(nDDL); | |
1064 | ||
1065 | Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC); | |
1066 | if (iPlate==-1) { | |
1067 | if (fRawReader) | |
1068 | fRawReader->AddMajorErrorLog(kPlateError,"plate = -1"); | |
1069 | AliWarning("Problems with the plate number!"); | |
1070 | } | |
1071 | ||
1072 | Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC); | |
1073 | if (iStrip==-1) { | |
1074 | if (fRawReader) | |
1075 | fRawReader->AddMajorErrorLog(kStripError,"strip = -1"); | |
1076 | AliWarning("Problems with the strip number!"); | |
1077 | } | |
1078 | ||
1079 | Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH); | |
1080 | if (iPadAlongTheStrip==-1){ | |
1081 | if (fRawReader) | |
1082 | fRawReader->AddMajorErrorLog(kPadAlongStripError,"pad = -1"); | |
1083 | AliWarning("Problems with the pad number along the strip!"); | |
1084 | } | |
1085 | ||
1086 | Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ()))); | |
1087 | Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ(); | |
1088 | ||
1089 | volume[0] = iSector; | |
1090 | volume[1] = iPlate; | |
1091 | volume[2] = iStrip; | |
1092 | volume[3] = iPadX; | |
1093 | volume[4] = iPadZ; | |
1094 | ||
1095 | } | |
1096 | //----------------------------------------------------------------------------- | |
1097 | Bool_t AliTOFRawStream::DecodeDDL(Int_t nDDLMin, Int_t nDDLMax, Int_t verbose = 0) { | |
1098 | // | |
1099 | // To decode raw data for DDL number in [nDDLmin; nDDLmax] | |
1100 | // | |
1101 | ||
1102 | //check and fix valid DDL range | |
1103 | if (nDDLMin < 0){ | |
1104 | nDDLMin = 0; | |
1105 | fRawReader->AddMinorErrorLog(kDDLMinError); | |
1106 | AliWarning("Wrong DDL range: setting first DDL ID to 0"); | |
1107 | } | |
1108 | if (nDDLMax > 71){ | |
1109 | nDDLMax = 71; | |
1110 | fRawReader->AddMinorErrorLog(kDDLMaxError); | |
1111 | AliWarning("Wrong DDL range: setting last DDL ID to 71"); | |
1112 | } | |
1113 | ||
1114 | //select required DDLs | |
1115 | fRawReader->Select("TOF", nDDLMin, nDDLMax); | |
1116 | ||
1117 | if (verbose) | |
1118 | AliInfo(Form("Selected TOF DDL range: %d-%d", nDDLMin, nDDLMax)); | |
1119 | ||
1120 | return(Decode(verbose)); | |
1121 | } | |
1122 | //----------------------------------------------------------------------------- | |
1123 | Bool_t AliTOFRawStream::Decode(Int_t verbose = 0) { | |
1124 | // | |
1125 | // New decoder method | |
1126 | // | |
1127 | ||
1128 | Int_t currentEquipment; | |
1129 | Int_t currentDDL; | |
1130 | ||
1131 | //pointers | |
1132 | UChar_t *data = 0x0; | |
1133 | ||
1134 | //loop and read DDL headers | |
1135 | while(fRawReader->ReadHeader()){ | |
1136 | ||
1137 | //memory leak prevention (actually data should be always 0x0 here) | |
1138 | if (data != 0x0) | |
1139 | delete [] data; | |
1140 | ||
1141 | //get equipment infos | |
1142 | currentEquipment = fRawReader->GetEquipmentId(); | |
1143 | currentDDL = fRawReader->GetDDLID(); | |
1144 | const Int_t kDataSize = fRawReader->GetDataSize(); | |
1145 | const Int_t kDataWords = kDataSize / 4; | |
1146 | data = new UChar_t[kDataSize]; | |
1147 | ||
1148 | if (verbose) | |
1149 | AliInfo(Form("Found equipment # %d header (DDL # %d): %d bytes (%d words)", currentEquipment, currentDDL, kDataSize, kDataWords)); | |
1150 | ||
1151 | if (verbose) | |
1152 | AliInfo(Form("Reading equipment #%d (DDL # %d) data...", currentEquipment, currentDDL)); | |
1153 | ||
1154 | //read equipment payload | |
1155 | if (!fRawReader->ReadNext(data, kDataSize)) | |
1156 | { | |
1157 | fRawReader->AddMajorErrorLog(kDDLdataReading); | |
1158 | if (verbose) | |
1159 | AliWarning("Error while reading DDL data. Go to next equipment"); | |
1160 | delete [] data; | |
1161 | data = 0x0; | |
1162 | continue; | |
1163 | } | |
1164 | ||
1165 | if (verbose) | |
1166 | AliInfo(Form("Equipment # %d (DDL # %d) data has been readed", currentEquipment, currentDDL)); | |
1167 | ||
1168 | ||
1169 | //set up the decoder | |
1170 | fDecoder->SetVerbose(verbose); | |
1171 | fDecoder->SetDataBuffer(fDataBuffer[currentDDL]); | |
1172 | fDecoder->SetPackedDataBuffer(fPackedDataBuffer[currentDDL]); | |
1173 | ||
1174 | //start decoding | |
1175 | if (fDecoder->Decode((UInt_t *)data, kDataWords) == kTRUE) { | |
1176 | fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",currentDDL)); | |
1177 | AliWarning(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL)); | |
1178 | } | |
1179 | ||
1180 | delete [] data; | |
1181 | data = 0x0; | |
1182 | } | |
1183 | ||
1184 | //reset reader | |
1185 | fRawReader->Reset(); | |
1186 | ||
1187 | if (verbose) | |
1188 | AliInfo("All done"); | |
1189 | ||
1190 | return kFALSE; | |
1191 | ||
1192 | } | |
1193 | //--------------------------------------------------------------------------- | |
1194 | void | |
1195 | AliTOFRawStream::ResetBuffers() | |
1196 | { | |
1197 | // | |
1198 | // To reset the buffers | |
1199 | // | |
1200 | ||
1201 | for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls("TOF"); iDDL++){ | |
1202 | ResetDataBuffer(iDDL); | |
1203 | ResetPackedDataBuffer(iDDL); | |
1204 | } | |
1205 | } | |
1206 | ||
1207 | //--------------------------------------------------------------------------- | |
1208 | Bool_t | |
1209 | AliTOFRawStream::LoadRawDataBuffers(Int_t indexDDL, Int_t verbose) | |
1210 | { | |
1211 | // | |
1212 | // To load the buffers | |
1213 | // | |
1214 | ||
1215 | fTOFrawData->Clear(); | |
1216 | fPackedDigits = 0; | |
1217 | ||
1218 | if (verbose > 0) | |
1219 | AliInfo(Form("Decoding raw data for DDL # %d ...", indexDDL)); | |
1220 | ||
1221 | if (DecodeDDL(indexDDL, indexDDL, verbose) != 0){ //decode DDL | |
1222 | fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",indexDDL)); | |
1223 | AliWarning(Form("Error while decoding DDL # %d", indexDDL)); | |
1224 | return kTRUE; | |
1225 | } | |
1226 | ||
1227 | if (verbose > 0) | |
1228 | AliInfo(Form("Done. %d packed %s been found.", fPackedDataBuffer[indexDDL]->GetEntries(), fPackedDataBuffer[indexDDL]->GetEntries() > 1 ? "hits have" : "hit has")); | |
1229 | ||
1230 | AliTOFHitData *hitData; //hit data pointer | |
1231 | ||
1232 | if (verbose > 0) | |
1233 | AliInfo("Filling TClonesArray ..."); | |
1234 | ||
1235 | //loop over DDL packed hits | |
1236 | for (Int_t iHit = 0; iHit < fPackedDataBuffer[indexDDL]->GetEntries(); iHit++){ | |
1237 | hitData = fPackedDataBuffer[indexDDL]->GetHit(iHit); //get hit data | |
1238 | Int_t hitACQ = hitData->GetACQ(); | |
1239 | Int_t hitPS = hitData->GetPS(); | |
1240 | Int_t hitSlotID = hitData->GetSlotID(); | |
1241 | Int_t hitChain = hitData->GetChain(); | |
1242 | Int_t hitTDC = hitData->GetTDC(); | |
1243 | Int_t hitChan = hitData->GetChan(); | |
1244 | Int_t hitTimeBin = hitData->GetTimeBin(); | |
1245 | Int_t hitTOTBin = hitData->GetTOTBin(); | |
1246 | ||
1247 | Int_t hitLeading = hitData->GetTimeBin();//-1; // adc | |
1248 | Int_t hitTrailing = -1; | |
1249 | Int_t hitError = -1; | |
1250 | ||
1251 | TClonesArray &arrayTofRawData = *fTOFrawData; | |
1252 | new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(hitSlotID, hitChain, hitTDC, hitChan, hitTimeBin, hitTOTBin, hitLeading, hitTrailing, hitPS, hitACQ, hitError); | |
1253 | } | |
1254 | ||
1255 | if (verbose > 0) | |
1256 | AliInfo("Done."); | |
1257 | ||
1258 | if (verbose > 0) | |
1259 | AliInfo("Resetting buffers ..."); | |
1260 | ||
1261 | fDataBuffer[indexDDL]->Reset(); | |
1262 | fPackedDataBuffer[indexDDL]->Reset(); | |
1263 | ||
1264 | if (verbose > 0) | |
1265 | AliInfo("Done."); | |
1266 | ||
1267 | return kFALSE; | |
1268 | } | |
1269 |