]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFRawStream.cxx
Random seed for the ref. histo selection set to the current machine clock
[u/mrichter/AliRoot.git] / TOF / AliTOFRawStream.cxx
CommitLineData
571dda3d 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/*
d0eb8f39 17$Log$
740f0695 18Revision 1.11 2007/02/20 15:57:00 decaro
19Raw data update: to read the TOF raw data defined in UNPACKED mode
20
15ec34b9 21Revision 1.10 2006/12/15 14:01:38 cvetan
22Memory leak fixed
23
f1aa96cc 24Revision 1.9 2006/10/13 11:22:27 arcelli
25remove warnings due to uninitialized AliTOFtdcDigit data members
26
36f66fad 27Revision 1.8 2006/08/22 13:30:17 arcelli
28removal of effective c++ warnings (C.Zampolli)
29
655e379f 30Revision 1.7 2006/08/10 14:46:54 decaro
31TOF raw data format: updated version
32
d0eb8f39 33Revision 1.6.1 2006/06/28 A. De Caro, R. Preghenella:
34 Update TOF raw data format
35 according to the final version
36 (see the ALICE internal note in preparation
37 'ALICE TOF raw data format')
38 Added the methods for the correspoonding numbering
39 between the equipment IDs and the volume IDs:
40 Equip2VolNPlate(...)
41 Equip2VolNStrip(...)
42 Equip2VolNPad(...)
43
571dda3d 44Revision 0.02 2005/07/28 A. De Caro:
45 Update format TOF raw data
46 (temporary solution)
47 Correction of few wrong corrispondences
48 between 'software' and 'hardware' numberings
49
50Revision 0.01 2005/07/22 A. De Caro
51 Implement methods Next()
52 GetSector(),
53 GetPlate(),
54 GetStrip(),
55 GetPadZ(),
56 GetPadX()
57*/
58
0e46b9ae 59////////////////////////////////////////////////////////////////////////
60// //
61// This class provides access to TOF raw data in DDL files. //
62// //
63// It loops over all TOF raw data given by the AliRawReader. //
64// //
65////////////////////////////////////////////////////////////////////////
571dda3d 66
15ec34b9 67
68#include "TClonesArray.h"
69
70#include "AliDAQ.h"
d0eb8f39 71#include "AliLog.h"
571dda3d 72#include "AliRawReader.h"
73
74#include "AliTOFGeometry.h"
303e152f 75#include "AliTOFGeometryV5.h"
15ec34b9 76#include "AliTOFrawData.h"
77#include "AliTOFRawMap.h"
571dda3d 78#include "AliTOFRawStream.h"
79
d0eb8f39 80
81/******************************************
82GENERAL DATA FORMAT
83******************************************/
84
85//filler
86#define FILLER 0x70000000
87
88//word type mask/position
89#define WORD_TYPE_MASK 0xf0000000
90#define WORD_TYPE_POSITION 28
91
92//global header word required bit pattern
93#define GLOBAL_HEADER 0x40000000
94
95//global trailer word required bit pattern
96#define GLOBAL_TRAILER 0x50000000
97
98//error word required bit pattern
99#define ERROR 0x30000000
100
101//header slot ID mask/position
102#define HEADER_SLOT_ID_MASK 0x0000000f
103#define HEADER_SLOT_ID_POSITION 0
104
105//word types
106#define GLOBAL_HEADER_TYPE 4
107#define GLOBAL_TRAILER_TYPE 5
108#define ERROR_TYPE 6
109#define FILLER_TYPE 7
110#define TRM_CHAIN0_HEADER_TYPE 0
111#define TRM_CHAIN0_TRAILER_TYPE 1
112#define TRM_CHAIN1_HEADER_TYPE 2
113#define TRM_CHAIN1_TRAILER_TYPE 3
114
115//slot types
116#define DRM_ID_NUMBER 1
117#define LTM_ID_NUMBER 2
118
119
120/******************************************
121DRM DATA FORMAT
122******************************************/
123
124//DRM global header word required bit pattern
125#define DRM_GLOBAL_HEADER 0x40000001
126
127//DRM event words mask/position
128#define DRM_EVENT_WORDS_MASK 0x001ffff0
129#define DRM_EVENT_WORDS_POSITION 4
130
131//DRM DRM ID mask/position
132#define DRM_DRM_ID_MASK 0x0fe00000
133#define DRM_DRM_ID_POSITION 21
134
135//DRM status header 1 word required bit pattern
136#define DRM_STATUS_HEADER_1 0x40000001
137
138//DRM slot ID mask/position
139#define DRM_SLOT_ID_MASK 0x00007ff0
140#define DRM_SLOT_ID_POSITION 4
141
142//DRM C-bit mask/position
143#define DRM_C_BIT_MASK 0x00008000
144#define DRM_C_BIT_POSITION 15
145
146//DRM status header 2 word required bit pattern
147#define DRM_STATUS_HEADER_2 0x40000001
148
149//DRM enable ID mask/position
150#define DRM_ENABLE_ID_MASK 0x00007ff0
151#define DRM_ENABLE_ID_POSITION 4
152
153//DRM fault ID mask/position
154#define DRM_FAULT_ID_MASK 0x07ff0000
155#define DRM_FAULT_ID_POSITION 16
156
157//DRM status header 3 word required bit pattern
158#define DRM_STATUS_HEADER_3 0x40000001
159
160//DRM TTC event counter mask/position
161#define DRM_TTC_EVENT_COUNTER_MASK 0x0ffffff0
162#define DRM_TTC_EVENT_COUNTER_POSITION 4
163
164//DRM event CRC mask/position
165//#define DRM_EVENT_CRC_MASK 0x001ffff0
166#define DRM_EVENT_CRC_MASK 0x000ffff0
167#define DRM_EVENT_CRC_POSITION 4
168
169//DRM global trailer word required bit pattern
170#define DRM_GLOBAL_TRAILER 0x50000001
171
172//DRM local event counter mask/position
173#define DRM_LOCAL_EVENT_COUNTER_MASK 0x0000fff0
174#define DRM_LOCAL_EVENT_COUNTER_POSITION 4
175
176
177/******************************************
178TRM DATA FORMAT
179******************************************/
180
181//TRM global header word required bit pattern
182#define TRM_GLOBAL_HEADER 0x40000000
183
184//TRM slot ID mask/position
185#define TRM_SLOT_ID_MASK 0x0000000f
186#define TRM_SLOT_ID_POSITION 0
187
188//TRM event words mask/position
189#define TRM_EVENT_WORDS_MASK 0x0001fff0
190#define TRM_EVENT_WORDS_POSITION 4
191
192//TRM ACQ-bits mask/position
193#define TRM_ACQ_BITS_MASK 0x00060000
194#define TRM_ACQ_BITS_POSITION 17
195
196//TRM L-bit mask/position
197#define TRM_L_BIT_MASK 0x00080000
198#define TRM_L_BIT_POSITION 19
199
200//TRM chain-0 header word required bit pattern
201#define TRM_CHAIN_0_HEADER 0x00000000
202
203//TRM chain-1 header word required bit pattern
204#define TRM_CHAIN_1_HEADER 0x20000000
205
206//TRM bunch ID mask/position
207#define TRM_BUNCH_ID_MASK 0x0000fff0
208#define TRM_BUNCH_ID_POSITION 4
209
210//TRM PB24 temp mask/position
211#define TRM_PB24_TEMP_MASK 0x00ff0000
212#define TRM_PB24_TEMP_POSITION 16
213
214//TRM PB24 ID mask/position
215#define TRM_PB24_ID_MASK 0x07000000
216#define TRM_PB24_ID_POSITION 24
217
218//TRM TS-bit mask/position
219#define TRM_TS_BIT_MASK 0x08000000
220#define TRM_TS_BIT_POSITION 27
221
222//TRM chain-0 trailer word required bit pattern
223#define TRM_CHAIN_0_TRAILER 0x10000000
224
225//TRM chain-1 trailer word required bit pattern
226#define TRM_CHAIN_1_TRAILER 0x30000000
227
228//TRM status mask/position
229#define TRM_STATUS_MASK 0x0000000f
230#define TRM_STATUS_POSITION 0
231
232
233//TDC digit
234
235//TRM TDC digit word required bit pattern
236#define TRM_TDC_DIGIT 0x8000000
237
238//TRM digit time mask/position
239#define TRM_DIGIT_TIME_MASK 0x00001fff
240#define TRM_DIGIT_TIME_POSITION 0
241
242//TRM long digit time mask/position
243#define TRM_LONG_DIGIT_TIME_MASK 0x001fffff
244#define TRM_LONG_DIGIT_TIME_POSITION 0
245
246//TRM TOT width mask/position
247#define TRM_TOT_WIDTH_MASK 0x001fe000
248#define TRM_TOT_WIDTH_POSITION 13
249
250//TRM chan mask/position
251#define TRM_CHAN_MASK 0x00e00000
252#define TRM_CHAN_POSITION 21
253
254//TRM TDC ID mask/position
255#define TRM_TDC_ID_MASK 0x0f000000
256#define TRM_TDC_ID_POSITION 24
257
258//TRM E-bit mask/position
259#define TRM_E_BIT_MASK 0x10000000
260#define TRM_E_BIT_POSITION 28
261
262//TRM PS-bits mask/position
263#define TRM_PS_BITS_MASK 0x60000000
264#define TRM_PS_BITS_POSITION 29
265
15ec34b9 266#define TRM_FIRST_SLOT_ID 3
267
268//define hptdc time bin width
269#define TIME_BIN_WIDTH 24.4e-3 //ns
270
271//define hptdc tot bin width
272#define TOT_BIN_WIDTH 48.4e-3 //ns
d0eb8f39 273
274//TRM errors
275
276//TRM TDC error word required bit pattern
277#define TRM_TDC_ERROR 0x6000000
278
279//TRM TDC diagnostic error word required bit pattern
280#define TRM_TDC_DIAGNOSTIC_ERROR 0x6f00000
281
282//TRM TDC error flags mask/position
283#define TRM_TDC_ERROR_FLAGS_MASK 0x00007fff
284#define TRM_TDC_ERROR_FLAGS_POSITION 0
285
286//TRM TDC error TDC ID mask/position
287#define TRM_TDC_ERROR_TDC_ID_MASK 0x0f00000
288#define TRM_TDC_ERROR_TDC_ID_POSITION 24
289
290//TRM TDC fault chip flag ID mask/position
291#define TRM_TDC_ERROR_FAULT_CHIP_FLAG_ID_MASK 0x00007fff
292#define TRM_TDC_ERROR_FAULT_CHIP_FLAG_ID_POSITION 0
293
294//TRM TDC error C-bit mask/position
295#define TRM_TDC_ERROR_C_BIT_MASK 0x00008000
296#define TRM_TDC_ERROR_C_BIT_POSITION 15
297
298//TRM TDC JTAG error code mask/position
299#define TRM_TDC_ERROR_JTAG_ERROR_CODE_MASK 0x000007ff
300#define TRM_TDC_ERROR_JTAG_ERROR_CODE_POSITION 0
301
302//TRM TDC disgnostic error TDC ID mask/position
303#define TRM_TDC_DIAGNOSTIC_ERROR_TDC_ID_MASK 0x00007800
304#define TRM_TDC_DIAGNOSTIC_ERROR_TDC_ID_POSITION 11
305
306//TRM global trailer word required bit pattern
307//#define TRM_GLOBAL_TRAILER 0x50000000
308#define TRM_GLOBAL_TRAILER 0x5000000f
309
310//TRM event CRC mask/position
311#define TRM_EVENT_CRC_MASK 0x0000fff0
312#define TRM_EVENT_CRC_POSITION 4
313
314//TRM event counter mask/position
315#define TRM_EVENT_COUNTER_MASK 0x0fff0000
316#define TRM_EVENT_COUNTER_POSITION 16
317
318
319/******************************************
320LTM DATA FORMAT
321******************************************/
322
323//LTM global header word required bit pattern
324#define LTM_GLOBAL_HEADER 0x40000002
325
326//LTM event words mask/position
327#define LTM_EVENT_WORDS_MASK 0x0001fff0
328#define LTM_EVENT_WORDS_POSITION 4
329
330//LTM C-bit mask/position
331#define LTM_C_BIT_MASK 0x00020000
332#define LTM_C_BIT_POSITION 17
333
334//LTM fault mask/position
335#define LTM_FAULT_MASK 0x00fc0000
336#define LTM_FAULT_POSITION 18
337
338//PDL data
339
340//PDL value 1 mask/position
341#define LTM_PDL_VALUE_1_MASK 0x000000ff
342#define LTM_PDL_VALUE_1_POSITION 0
343
344//PDL value 2 mask/position
345#define LTM_PDL_VALUE_2_MASK 0x0000ff00
346#define LTM_PDL_VALUE_2_POSITION 8
347
348//PDL value 3 mask/position
349#define LTM_PDL_VALUE_3_MASK 0x00ff0000
350#define LTM_PDL_VALUE_3_POSITION 16
351
352//PDL value 4 mask/position
353#define LTM_PDL_VALUE_4_MASK 0xff000000
354#define LTM_PDL_VALUE_4_POSITION 24
355
356//ADC data
357
358//ADC value 1 mask/position
359#define LTM_ADC_VALUE_1_MASK 0x000003ff
360#define LTM_ADC_VALUE_1_POSITION 0
361
362//ADC value 2 mask/position
363#define LTM_ADC_VALUE_2_MASK 0x000ffc00
364#define LTM_ADC_VALUE_2_POSITION 10
365
366//ADC value 3 mask/position
367#define LTM_ADC_VALUE_3_MASK 0x3ff00000
368#define LTM_ADC_VALUE_3_POSITION 20
369
370//LTM global trailer word required bit pattern
371#define LTM_GLOBAL_TRAILER 0x50000002
372
373//LTM event CRC mask/position
374#define LTM_EVENT_CRC_MASK 0x0000fff0
375#define LTM_EVENT_CRC_POSITION 4
376
377//LTM event number mask/position
378#define LTM_EVENT_NUMBER_MASK 0x0fff0000
379#define LTM_EVENT_NUMBER_POSITION 16
380
381
571dda3d 382ClassImp(AliTOFRawStream)
383
384
385//_____________________________________________________________________________
655e379f 386AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader):
15ec34b9 387 fRawReader(rawReader),
388 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
655e379f 389 fDDL(-1),
390 fTRM(-1),
655e379f 391 fTRMchain(-1),
15ec34b9 392 fTDC(-1),
655e379f 393 fTDCchannel(-1),
15ec34b9 394 fTime(-1),
655e379f 395 fToT(-1),
15ec34b9 396 fLeadingEdge(-1),
397 fTrailingEdge(-1),
655e379f 398 fErrorFlag(-1),
655e379f 399 fSector(-1),
400 fPlate(-1),
401 fStrip(-1),
402 fPadX(-1),
403 fPadZ(-1),
404 fTOFGeometry(new AliTOFGeometryV5()),
15ec34b9 405 fPackedDigits(0),
655e379f 406 fWordType(-1),
407 fSlotID(-1),
408 fACQ(-1),
409 fPSbit(-1),
655e379f 410 fTDCerrorFlag(-1),
411 fInsideDRM(kFALSE),
412 fInsideTRM(kFALSE),
413 fInsideLTM(kFALSE),
414 fInsideTRMchain0(kFALSE),
15ec34b9 415 fInsideTRMchain1(kFALSE)
571dda3d 416{
417 //
418 // create an object to read TOF raw digits
419 //
420
15ec34b9 421 fRawReader->Reset();
362c9d61 422 fRawReader->Select("TOF");
15ec34b9 423
571dda3d 424}
425
426//_____________________________________________________________________________
655e379f 427AliTOFRawStream::AliTOFRawStream():
428 fRawReader(0x0),
15ec34b9 429 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
655e379f 430 fDDL(-1),
431 fTRM(-1),
655e379f 432 fTRMchain(-1),
15ec34b9 433 fTDC(-1),
655e379f 434 fTDCchannel(-1),
15ec34b9 435 fTime(-1),
655e379f 436 fToT(-1),
15ec34b9 437 fLeadingEdge(-1),
438 fTrailingEdge(-1),
655e379f 439 fErrorFlag(-1),
655e379f 440 fSector(-1),
441 fPlate(-1),
442 fStrip(-1),
443 fPadX(-1),
444 fPadZ(-1),
445 fTOFGeometry(new AliTOFGeometryV5()),
15ec34b9 446 fPackedDigits(0),
655e379f 447 fWordType(-1),
448 fSlotID(-1),
449 fACQ(-1),
450 fPSbit(-1),
655e379f 451 fTDCerrorFlag(-1),
452 fInsideDRM(kFALSE),
453 fInsideTRM(kFALSE),
454 fInsideLTM(kFALSE),
455 fInsideTRMchain0(kFALSE),
15ec34b9 456 fInsideTRMchain1(kFALSE)
571dda3d 457{
458 //
d0eb8f39 459 // default ctr
571dda3d 460 //
15ec34b9 461
d0eb8f39 462}
463
464//_____________________________________________________________________________
465AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
655e379f 466 TObject(stream),
467 fRawReader(0x0),
15ec34b9 468 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
655e379f 469 fDDL(-1),
470 fTRM(-1),
655e379f 471 fTRMchain(-1),
15ec34b9 472 fTDC(-1),
655e379f 473 fTDCchannel(-1),
15ec34b9 474 fTime(-1),
655e379f 475 fToT(-1),
15ec34b9 476 fLeadingEdge(-1),
477 fTrailingEdge(-1),
655e379f 478 fErrorFlag(-1),
655e379f 479 fSector(-1),
480 fPlate(-1),
481 fStrip(-1),
482 fPadX(-1),
483 fPadZ(-1),
484 fTOFGeometry(new AliTOFGeometryV5()),
15ec34b9 485 fPackedDigits(0),
655e379f 486 fWordType(-1),
487 fSlotID(-1),
488 fACQ(-1),
489 fPSbit(-1),
655e379f 490 fTDCerrorFlag(-1),
491 fInsideDRM(kFALSE),
492 fInsideTRM(kFALSE),
493 fInsideLTM(kFALSE),
494 fInsideTRMchain0(kFALSE),
15ec34b9 495 fInsideTRMchain1(kFALSE)
d0eb8f39 496{
497 //
498 // copy constructor
499 //
500
501 fRawReader = stream.fRawReader;
15ec34b9 502
503 fTOFrawData = stream.fTOFrawData;
504
d0eb8f39 505 fDDL = stream.fDDL;
506 fTRM = stream.fTRM;
d0eb8f39 507 fTRMchain = stream.fTRMchain;
15ec34b9 508 fTDC = stream.fTDC;
d0eb8f39 509 fTDCchannel = stream.fTDCchannel;
15ec34b9 510 fTime = stream.fTime;
d0eb8f39 511 fToT = stream.fToT;
15ec34b9 512 fLeadingEdge = stream.fLeadingEdge;
513 fTrailingEdge = stream.fTrailingEdge;
514
d0eb8f39 515 fErrorFlag = stream.fErrorFlag;
516
517 fSector = stream.fSector;
518 fPlate = stream.fPlate;
519 fStrip = stream.fStrip;
520 fPadX = stream.fPadX;
521 fPadZ = stream.fPadZ;
522
523 fTOFGeometry = stream.fTOFGeometry;
524
15ec34b9 525 fPackedDigits = stream.fPackedDigits;
526
d0eb8f39 527 fWordType = stream.fWordType;
528 fSlotID = stream.fSlotID;
529 fACQ = stream.fACQ;
530 fPSbit = stream.fPSbit;
d0eb8f39 531 fTDCerrorFlag = stream.fTDCerrorFlag;
532 fInsideDRM = stream.fInsideDRM;
533 fInsideTRM = stream.fInsideTRM;
534 fInsideLTM = stream.fInsideLTM;
535 fInsideTRMchain0 = stream.fInsideTRMchain0;
536 fInsideTRMchain1 = stream.fInsideTRMchain1;
d0eb8f39 537
571dda3d 538}
539
540//_____________________________________________________________________________
541AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
542{
543 //
544 // assignment operator
545 //
546
547 fRawReader = stream.fRawReader;
15ec34b9 548
549 fTOFrawData = stream.fTOFrawData;
550
571dda3d 551 fDDL = stream.fDDL;
552 fTRM = stream.fTRM;
d0eb8f39 553 fTRMchain = stream.fTRMchain;
15ec34b9 554 fTDC = stream.fTDC;
d0eb8f39 555 fTDCchannel = stream.fTDCchannel;
15ec34b9 556 fTime = stream.fTime;
d0eb8f39 557 fToT = stream.fToT;
15ec34b9 558 fLeadingEdge = stream.fLeadingEdge;
559 fTrailingEdge = stream.fTrailingEdge;
571dda3d 560 fErrorFlag = stream.fErrorFlag;
d0eb8f39 561
562 fSector = stream.fSector;
563 fPlate = stream.fPlate;
564 fStrip = stream.fStrip;
565 fPadX = stream.fPadX;
566 fPadZ = stream.fPadZ;
571dda3d 567
d3c7bfac 568 fTOFGeometry = stream.fTOFGeometry;
569
15ec34b9 570 fPackedDigits = stream.fPackedDigits;
571
d0eb8f39 572 fWordType = stream.fWordType;
573 fSlotID = stream.fSlotID;
574 fACQ = stream.fACQ;
575 fPSbit = stream.fPSbit;
d0eb8f39 576 fTDCerrorFlag = stream.fTDCerrorFlag;
577 fInsideDRM = stream.fInsideDRM;
578 fInsideTRM = stream.fInsideTRM;
579 fInsideLTM = stream.fInsideLTM;
580 fInsideTRMchain0 = stream.fInsideTRMchain0;
581 fInsideTRMchain1 = stream.fInsideTRMchain1;
d0eb8f39 582
571dda3d 583 return *this;
584
585}
586
587//_____________________________________________________________________________
588AliTOFRawStream::~AliTOFRawStream()
589{
590// destructor
591
15ec34b9 592 fPackedDigits = 0;
593
f1aa96cc 594 delete fTOFGeometry;
d3c7bfac 595
15ec34b9 596 delete fTOFrawData;
597
571dda3d 598}
599
600
15ec34b9 601//_____________________________________________________________________________
602
603void AliTOFRawStream::LoadRawData(Int_t indexDDL)
604{
605
606 /*
607 for (Int_t indexDDL = 0;
608 indexDDL < AliDAQ::NumberOfDdls("TOF");
609 indexDDL++) {
610 */
611
612 fTOFrawData->Clear();
613 fPackedDigits = 0;
614
615 // create raw data map
616 AliTOFRawMap *rawMap = new AliTOFRawMap(fTOFrawData);
617 rawMap->Clear();
618
619 Int_t slot[4] = {-1, -1, -1, -1};
620
621 fRawReader->Reset();
622 fRawReader->Select("TOF", indexDDL, indexDDL);
623
624 Bool_t signal = kFALSE;
625
626 while(Next()) {
627
628 signal = (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1);
629 if (signal) {
630 //printf(" %2i %1i %2i %1i %2i \n", fSector, fPlate, fStrip, fPadZ, fPadX);
631
632 slot[0] = fTRM;
633 slot[1] = fTRMchain;
634 slot[2] = fTDC;
635 slot[3] = fTDCchannel;
636
637 if (rawMap->TestHit(slot) != kEmpty) {
638
639 AliTOFrawData *rawDigit = static_cast<AliTOFrawData*>(rawMap->GetHit(slot));
640
641 if (rawDigit->GetLeading()!=-1 && rawDigit->GetTrailing()==-1 &&
642 fLeadingEdge==-1 && fTrailingEdge!=-1) {
643
644 rawDigit->Update(fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
645 }
646 else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) &&
647 (fLeadingEdge!=-1 || fTrailingEdge!=-1 || fTime!=-1) )
648
649/* else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) &&
650 (fTime!=-1 || fLeadingEdge!=-1 || fTrailingEdge!=-1))*/ /*||
651 (rawDigit->GetLeading()==-1 && rawDigit->GetTrailing()!=-1 &&
652 fLeadingEdge!=-1 && fTrailingEdge==-1) */)
653 {
654
655 TClonesArray &arrayTofRawData = *fTOFrawData;
656 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
657
658 rawMap->SetHit(slot);
659
660 }
661
662
663 }
664 else {
665
666 TClonesArray &arrayTofRawData = *fTOFrawData;
667 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
668
669 rawMap->SetHit(slot);
670
671 } // else if (rawMap->TestHit(slot) == kEmpty)
672
673 } // if (signal)
674
675 } // closed -> while (Next())
676
677 /*
678 fDDL = fRawReader->GetDDLID();
679
680 for (Int_t ii=0; ii<fTOFrawData->GetEntriesFast(); ii++) {
681
682 AliTOFrawData *dummy = (AliTOFrawData*)fTOFrawData->UncheckedAt(ii);
683
684 fTRM = dummy->GetTRM();
685 fTRMchain = dummy->GetTRMchain();
686 fTDC = dummy->GetTDC();
687 fTDCchannel = dummy->GetTDCchannel();
688
689 SetSector();
690 SetPlate();
691 SetStrip();
692 SetPadZ();
693 SetPadX();
694
695 printf(" %2i, %2i %1i, %2i, %1i --> %2i, %1i, %2i, %1i, %2i \n",
696 fDDL, fTRM, fTRMchain, fTDC, fTDCchannel,
697 fSector, fPlate, fStrip, fPadZ, fPadX);
698
699 } // closed loop on TOF raw data TClonesArray
700 */
701
702 //} // closed loop on indexDDL
703
704}
705
571dda3d 706//_____________________________________________________________________________
707Bool_t AliTOFRawStream::Next()
708{
d0eb8f39 709 //
710 // Read next 32-bit word in TOF raw data files
711 // returns kFALSE if there is no word left
712 //
571dda3d 713
714 UInt_t data;
715
571dda3d 716 if (!fRawReader->ReadNextInt(data)) return kFALSE;
717
d0eb8f39 718 if (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1) {
719 fSector = -1;
15ec34b9 720 fPlate = -1;
721 fStrip = -1;
722 fPadZ = -1;
723 fPadX = -1;
724 fTime = -1;
725 fToT = -1;
726 fLeadingEdge = -1;
727 fTrailingEdge = -1;
d0eb8f39 728 }
571dda3d 729
571dda3d 730 fDDL = fRawReader->GetDDLID();
731
d0eb8f39 732 fWordType = GetField(data,WORD_TYPE_MASK,WORD_TYPE_POSITION);
733
734 switch (fWordType) { // switch word type
735
736 case GLOBAL_HEADER_TYPE: // global header
737 fSlotID = GetField(data, HEADER_SLOT_ID_MASK, HEADER_SLOT_ID_POSITION);
738 fTRM = fSlotID;
739
740
741 switch (fSlotID) { // switch global header slot ID
742
743 case DRM_ID_NUMBER: //DRM global header
744 if (fInsideDRM) { // unexpected DRM global headers -> exit
745 break;
746 }
747 fInsideDRM = kTRUE; // DRM global header accepted
748 break;
749
750 case LTM_ID_NUMBER: // LTM global header
751 if (fInsideLTM) { // unexpected LTM global headers -> exit
752 break;
753 }
754 fInsideLTM = kTRUE; // LTM global header accepted
755 break;
756
757 case 3: //TRM header
758 case 4: //TRM header
759 case 5: //TRM header
760 case 6: //TRM header
761 case 7: //TRM header
762 case 8: //TRM header
763 case 9: //TRM header
764 case 10: //TRM header
765 case 11: //TRM header
766 case 12: //TRM header
767 if (fInsideTRM) { // unexpected TRM global headers -> exit
768 break;
769 }
770 fInsideTRM = kTRUE; // TRM global header accepted
771 fACQ = GetField(data,TRM_ACQ_BITS_MASK,TRM_ACQ_BITS_POSITION);
772 break;
773
774 default: // unexpected global header slot ID
775 break;
776
777 } //end switch global header slot id
778
779 break;
780
781
782 case GLOBAL_TRAILER_TYPE: // global trailer
783 fSlotID = GetField(data,HEADER_SLOT_ID_MASK,HEADER_SLOT_ID_POSITION);
784
785
786 switch (fSlotID) { // switch global trailer slot ID
787
788 case DRM_ID_NUMBER: // DRM global trailer
789 if (!fInsideDRM) { // unexpected DRM global trailers -> exit
790 break;
791 }
792 fInsideDRM = kFALSE; // DRM global trailer accepted
793 fInsideTRM = kFALSE;
794 fInsideLTM = kFALSE;
795 fInsideTRMchain0 = kFALSE;
796 fInsideTRMchain1 = kFALSE;
d0eb8f39 797 fSector = -1;
15ec34b9 798 fPlate = -1;
799 fStrip = -1;
800 fPadZ = -1;
801 fPadX = -1;
802 fDDL = -1;
803 fTRM = -1;
804 fTDC = -1;
805 fTRMchain = -1;
d0eb8f39 806 fTDCchannel = -1;
15ec34b9 807 fTime = -1;
808 fToT = -1;
809 fLeadingEdge = -1;
810 fTrailingEdge = -1;
d0eb8f39 811 fErrorFlag = -1;
15ec34b9 812 fACQ = -1;
d0eb8f39 813 fPSbit = -1;
d0eb8f39 814 fTDCerrorFlag = -1;
815 break;
816 case LTM_ID_NUMBER: // LTM global trailer
817 if (!fInsideLTM) { // unexpected LTM global trailer -> exit
818 break;
819 }
820 fInsideLTM = kFALSE; // LTM global trailer accepted
821 break;
822 case 15: //TRM global trailer
823 if (!fInsideTRM) { // unexpected TRM global trailers -> exit
824 break;
825 }
826 fInsideTRM = kFALSE; // TRM global trailer accepted
827 break;
828 default: // unexpected global trailer slot ID
829 break;
830 } //end switch global trailer slot id
831
832
833 break;
834
835
836 case ERROR_TYPE: // TDC error
15ec34b9 837 fTDC = GetField(data,TRM_TDC_ERROR_TDC_ID_MASK,TRM_TDC_ERROR_TDC_ID_POSITION);
d0eb8f39 838 fTDCerrorFlag = GetField(data,TRM_TDC_ERROR_FLAGS_MASK,TRM_TDC_ERROR_FLAGS_POSITION);
839 break;
840
841
842 case FILLER_TYPE: // filler
843 break;
844
845
846 default: // other word types
847
848 if (fInsideTRM) { // inside TRM
849
850 switch (fWordType) { // switch word type inside TRM
851 case TRM_CHAIN0_HEADER_TYPE: // TRM chain0 header
852 if (fInsideTRMchain0) { // unexpected TRM chain0 header
853 break;
854 }
855 fInsideTRMchain0 = kTRUE;
856 fTRMchain = 0;
857 break;
858 case TRM_CHAIN0_TRAILER_TYPE: // TRM chain0 trailer
859 if (!fInsideTRMchain0) { // unexpected TRM chain0 trailer
860 break;
861 }
862 fInsideTRMchain0 = kFALSE;
863 fTRMchain = -1;
864 break;
865 case TRM_CHAIN1_HEADER_TYPE: // TRM chain1 header
866 if (fInsideTRMchain1) { // unexpected TRM chain1 header
867 break;
868 }
869 fInsideTRMchain1 = kTRUE;
870 fTRMchain = 1;
871 break;
872 case TRM_CHAIN1_TRAILER_TYPE: // TRM chain1 trailer
873 if (!fInsideTRMchain1) { // unexpected TRM chain1 trailer
874 break;
875 }
876 fInsideTRMchain1 = kFALSE;
877 fTRMchain = -1;
878 break;
879 } // end switch word type inside TRM
880
881 } // end if (fInsideTRM)
882
883
884 if (
885 ((fInsideTRMchain0&&!fInsideTRMchain1) || (!fInsideTRMchain0&&fInsideTRMchain1))
886 && fWordType!=TRM_CHAIN0_HEADER_TYPE && fWordType!=TRM_CHAIN0_TRAILER_TYPE
887 && fWordType!=TRM_CHAIN1_HEADER_TYPE && fWordType!=TRM_CHAIN1_TRAILER_TYPE
888 ){ // inside TRM chains
15ec34b9 889
890 fPSbit = GetField(data,TRM_PS_BITS_MASK,TRM_PS_BITS_POSITION);
891 fTDC = GetField(data,TRM_TDC_ID_MASK,TRM_TDC_ID_POSITION);
d0eb8f39 892 fTDCchannel = GetField(data,TRM_CHAN_MASK,TRM_CHAN_POSITION);
15ec34b9 893 fErrorFlag = GetField(data,TRM_E_BIT_MASK,TRM_E_BIT_POSITION);
894
895 SetSector();
896 SetPlate();
897 SetStrip();
898 SetPadZ();
899 SetPadX();
900
d0eb8f39 901
902 switch (fPSbit) { // switch fPSbit bits inside TRM chains
15ec34b9 903
904 case 0: // packing ok, digit time and TOT
905 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
d0eb8f39 906 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION);
d0eb8f39 907 break;
908
909 case 1: // leading edge digit, long digit time, no TOT
15ec34b9 910 //fToT = -1;
911 //fTime = -1;
912 fLeadingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION);
d0eb8f39 913 break;
914
915 case 2: // trailing edge digit, long digit time, no TOT
15ec34b9 916 //fToT = -1;
917 //fTime = -1;
918 fTrailingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION);
d0eb8f39 919 break;
15ec34b9 920
d0eb8f39 921 case 3: // TOT overflow
15ec34b9 922 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
d0eb8f39 923 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION);
d0eb8f39 924 break;
d0eb8f39 925
15ec34b9 926 } // end switch PS bits inside TRM chains
d0eb8f39 927
928 } // end if is inside TRM chains
929
930 } // end switch on fWordType
571dda3d 931
15ec34b9 932
571dda3d 933 return kTRUE;
d0eb8f39 934
571dda3d 935}
936//_____________________________________________________________________________
937
d0eb8f39 938void AliTOFRawStream::SetSector()
571dda3d 939{
940 //
d0eb8f39 941 // Evaluate the TOF sector number -> [ 0;17]
942 // corresponding to the TOF equipment IDs:
943 // fDDL -> [ 0;71]
944 // fTRM -> [ 3;12]
15ec34b9 945 // fTRMchain -> [ 0; 1]
d0eb8f39 946 // fTDC -> [ 0;14]
947 // fTDCchannel -> [ 0; 7]
571dda3d 948 //
949
950 Int_t iSector = -1;
571dda3d 951
d0eb8f39 952 if (!(fDDL==-1)) iSector = Int_t((Float_t)(fDDL)/AliTOFGeometry::NDDL());
953
954 fSector = iSector;
571dda3d 955
956}
957//_____________________________________________________________________________
958
d0eb8f39 959
960void AliTOFRawStream::SetPlate()
571dda3d 961{
962 //
d0eb8f39 963 // Evaluate the TOF plate number ->[ 0; 4]
964 // corresponding to the TOF equipment IDs:
965 // fDDL -> [ 0;71]
966 // fTRM -> [ 3;12]
15ec34b9 967 // fTRMchain -> [ 0; 1]
d0eb8f39 968 // fTDC -> [ 0;14]
969 // fTDCchannel -> [ 0; 7]
571dda3d 970 //
971
972 Int_t iPlate = -1;
d0eb8f39 973 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
974 || fSector==-1))
975 iPlate = Equip2VolNplate(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
571dda3d 976
d0eb8f39 977 fPlate = iPlate;
571dda3d 978
979}
980//_____________________________________________________________________________
981
d0eb8f39 982void AliTOFRawStream::SetStrip()
571dda3d 983{
984 //
d0eb8f39 985 // Evaluate the TOF strip number per module -> [ 0; 14/18]
986 // corresponding to the TOF equipment IDs:
987 // fDDL -> [ 0;71]
988 // fTRM -> [ 3;12]
15ec34b9 989 // fTRMchain -> [ 0; 1]
d0eb8f39 990 // fTDC -> [ 0;14]
991 // fTDCchannel -> [ 0; 7]
571dda3d 992 //
993
994 Int_t iStrip = -1;
995
d0eb8f39 996 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
997 || fSector==-1 || fPlate==-1))
998 iStrip = Equip2VolNstrip(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
571dda3d 999
d0eb8f39 1000 fStrip = iStrip;
571dda3d 1001
1002}
1003//_____________________________________________________________________________
1004
d0eb8f39 1005void AliTOFRawStream::SetPadZ()
571dda3d 1006{
1007 //
d0eb8f39 1008 // Evaluate the TOF padRow number per strip -> [ 0; 1]
1009 // corresponding to the TOF equipment IDs:
1010 // fDDL -> [ 0;71]
1011 // fTRM -> [ 3;12]
15ec34b9 1012 // fTRMchain -> [ 0; 1]
d0eb8f39 1013 // fTDC -> [ 0;14]
1014 // fTDCchannel -> [ 0; 7]
571dda3d 1015 //
1016
1017 Int_t iPadZ = -1;
1018
d0eb8f39 1019 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
1020 || fSector==-1 || fPlate==-1 || fStrip==-1))
1021 {
1022 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
1023 if (iPadAlongTheStrip!=-1)
1024 iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
1025 }
571dda3d 1026
d0eb8f39 1027 fPadZ = iPadZ;
571dda3d 1028
d0eb8f39 1029}
1030//_____________________________________________________________________________
1031
1032void AliTOFRawStream::SetPadX()
1033{
1034 //
1035 // Evaluate the TOF pad number per strip padRow -> [ 0;47]
1036 // corresponding to the TOF equipment IDs:
1037 // fDDL -> [ 0;71]
1038 // fTRM -> [ 3;12]
15ec34b9 1039 // fTRMchain -> [ 0; 1]
d0eb8f39 1040 // fTDC -> [ 0;14]
1041 // fTDCchannel -> [ 0; 7]
1042 //
571dda3d 1043
d0eb8f39 1044 Int_t iPadX = -1;
571dda3d 1045
d0eb8f39 1046 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
1047 || fSector==-1 || fPlate==-1 || fStrip==-1))
1048 {
1049 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
1050 if (iPadAlongTheStrip!=-1)
1051 iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1052 }
1053
1054 fPadX = iPadX;
571dda3d 1055
1056}
571dda3d 1057
d0eb8f39 1058//----------------------------------------------------------------------------
1059Int_t AliTOFRawStream::GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const
1060{
1061 //
1062 //
1063 //
1064
1065 return ((word & fieldMask) >> fieldPosition);
1066}
1067
1068//----------------------------------------------------------------------------
1069Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC) const
571dda3d 1070{
1071 //
d0eb8f39 1072 // Returns the TOF plate number [0;4]
1073 // corresponding to the TOF equipment ID numbers:
1074 // iDDL -> DDL number per sector [0;3]
1075 // nTRM -> TRM number [3;12]
1076 // nTDC -> TDC number [0;14]
571dda3d 1077 //
1078
d0eb8f39 1079 Int_t iPlate = -1;
1080 if (iDDL==0) {
1081
1082 if (nTRM>=4 && nTRM<7) {
1083 iPlate = 0;
1084 } else if (nTRM==7) {
1085 if (nTDC<12) iPlate = 0;
1086 else iPlate = 1;
1087 } else if (nTRM>=8 && nTRM<11) {
1088 iPlate = 1;
1089 } else if (nTRM==11) {
1090 if (nTDC<9) iPlate = 1;
1091 else iPlate = 2;
1092 }else if (nTRM==12) {
1093 iPlate = 2;
1094 }
1095
1096 } else if (iDDL==1) {
1097
1098 if (nTRM==3) {
1099 if (nTDC<3) iPlate = 0;
1100 } else if (nTRM>=4 && nTRM<7) {
1101 iPlate = 0;
1102 } else if (nTRM==7) {
1103 if (nTDC<6) iPlate = 1;
1104 else iPlate = 0;
1105 } else if (nTRM>=8 && nTRM<11) {
1106 iPlate = 1;
1107 } else if (nTRM==11) {
1108 if (nTDC<9) iPlate = 2;
1109 else iPlate = 1;
1110 } else if (nTRM==12) {
1111 iPlate = 2;
1112 }
1113
1114 } else if (iDDL==2) {
1115
1116 if (nTRM>=4 && nTRM<7) {
1117 iPlate = 4;
1118 } else if (nTRM==7) {
1119 if (nTDC<12) iPlate = 4;
1120 else iPlate = 3;
1121 } else if (nTRM>=8 && nTRM<11) {
1122 iPlate = 3;
1123 } else if (nTRM==11) {
1124 if (nTDC<9) iPlate = 3;
1125 else iPlate = 2;
1126 }else if (nTRM==12) {
1127 iPlate = 2;
1128 }
1129
1130 } else if (iDDL==3) {
1131
1132 if (nTRM==3) {
1133 if (nTDC<3) iPlate = 4;
1134 } else if (nTRM>=4 && nTRM<7) {
1135 iPlate = 4;
1136 } else if (nTRM==7) {
1137 if (nTDC<6) iPlate = 3;
1138 else iPlate = 4;
1139 } else if (nTRM>=8 && nTRM<11) {
1140 iPlate = 3;
1141 } else if (nTRM==11) {
1142 if (nTDC<9) iPlate = 2;
1143 else iPlate = 3;
1144 } else if (nTRM==12) {
1145 iPlate = 2;
1146 }
571dda3d 1147
d0eb8f39 1148 }
571dda3d 1149
d0eb8f39 1150 return iPlate;
571dda3d 1151
d0eb8f39 1152}
571dda3d 1153
d0eb8f39 1154//----------------------------------------------------------------------------
1155Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC) const
1156{
1157 //
1158 // Returns the TOF strip number per module:
1159 // [0;14], in the central plates,
1160 // [0;18], in the intermediate and external plates
1161 // corresponding to the TOF equipment ID numbers:
1162 // iDDL -> DDL number per sector [0;3]
1163 // nTRM -> TRM number [3;12]
1164 // nTDC -> TDC number [0;14]
1165 //
571dda3d 1166
d0eb8f39 1167 Int_t iStrip = -1;
571dda3d 1168
d0eb8f39 1169 if (iDDL==0) {
1170
1171 if (nTRM== 4) iStrip = (Int_t)(nTDC/3.);
1172 else if (nTRM== 5) iStrip = 5 + (Int_t)(nTDC/3.);
1173 else if (nTRM== 6) iStrip = 10 + (Int_t)(nTDC/3.);
1174 else if (nTRM== 7) {
1175 if (nTDC<12) iStrip = 15 + (Int_t)(nTDC/3.);
1176 else iStrip = (Int_t)(nTDC/3.) - 4;
1177 }
1178 else if (nTRM== 8) iStrip = 1 + (Int_t)(nTDC/3.);
1179 else if (nTRM== 9) iStrip = 6 + (Int_t)(nTDC/3.);
1180 else if (nTRM==10) iStrip = 11 + (Int_t)(nTDC/3.);
1181 else if (nTRM==11) {
1182 if (nTDC<9) iStrip = 16 + (Int_t)(nTDC/3.);
1183 else iStrip = (Int_t)(nTDC/3.) - 3;
1184 }
1185 else if (nTRM==12) iStrip = 2 + (Int_t)(nTDC/3.);
1186
1187 } else if (iDDL==1) {
1188
1189 if (nTRM==3 && nTDC<3) iStrip = (Int_t)(nTDC/3.);
1190 else if (nTRM== 4) iStrip = 5 - (Int_t)(nTDC/3.);
1191 else if (nTRM== 5) iStrip = 10 - (Int_t)(nTDC/3.);
1192 else if (nTRM== 6) iStrip = 15 - (Int_t)(nTDC/3.);
1193 else if (nTRM== 7) {
1194 if (nTDC<6) iStrip = 1 - (Int_t)(nTDC/3.);
1195 else iStrip = 20 - (Int_t)(nTDC/3.);
1196 }
1197 else if (nTRM== 8) iStrip = 6 - (Int_t)(nTDC/3.);
1198 else if (nTRM== 9) iStrip = 11 - (Int_t)(nTDC/3.);
1199 else if (nTRM==10) iStrip = 16 - (Int_t)(nTDC/3.);
1200 else if (nTRM==11) {
1201 if (nTDC<9) iStrip = 2 - (Int_t)(nTDC/3.);
1202 else iStrip = 21 - (Int_t)(nTDC/3.);
1203 }
1204 else if (nTRM==12) iStrip = 7 - (Int_t)(nTDC/3.);
1205
1206 } else if (iDDL==2) {
1207
1208 if (nTRM== 4) iStrip = 18 - (Int_t)(nTDC/3.);
1209 else if (nTRM== 5) iStrip = 18 - ( 5 + (Int_t)(nTDC/3.));
1210 else if (nTRM== 6) iStrip = 18 - (10 + (Int_t)(nTDC/3.));
1211 else if (nTRM== 7) {
1212 if (nTDC<12) iStrip = 18 - (15 + (Int_t)(nTDC/3.));
1213 else iStrip = 18 - ((Int_t)(nTDC/3.) - 4);
1214 }
1215 else if (nTRM== 8) iStrip = 18 - ( 1 + (Int_t)(nTDC/3.));
1216 else if (nTRM== 9) iStrip = 18 - ( 6 + (Int_t)(nTDC/3.));
1217 else if (nTRM==10) iStrip = 18 - (11 + (Int_t)(nTDC/3.));
1218 else if (nTRM==11) {
1219 if (nTDC<9) iStrip = 18 - (16 + (Int_t)(nTDC/3.));
1220 else iStrip = 14 - ((Int_t)(nTDC/3.) - 3);
1221 }
1222 else if (nTRM==12) iStrip = 14 - ( 2 + (Int_t)(nTDC/3.));
1223
1224 } else if (iDDL==3) {
1225
1226 if (nTRM==3 && nTDC<3) iStrip = 18 - (Int_t)(nTDC/3.);
1227 else if (nTRM== 4) iStrip = 18 - ( 5 - (Int_t)(nTDC/3.));
1228 else if (nTRM== 5) iStrip = 18 - (10 - (Int_t)(nTDC/3.));
1229 else if (nTRM== 6) iStrip = 18 - (15 - (Int_t)(nTDC/3.));
1230 else if (nTRM== 7) {
1231 if (nTDC<6) iStrip = 18 - (1 - (Int_t)(nTDC/3.));
1232 else iStrip = 18 - (20 - (Int_t)(nTDC/3.));
1233 }
1234 else if (nTRM== 8) iStrip = 18 - ( 6 - (Int_t)(nTDC/3.));
1235 else if (nTRM== 9) iStrip = 18 - (11 - (Int_t)(nTDC/3.));
1236 else if (nTRM==10) iStrip = 18 - (16 - (Int_t)(nTDC/3.));
1237 else if (nTRM==11) {
1238 if (nTDC<9) iStrip = 14 - ( 2 - (Int_t)(nTDC/3.));
1239 else iStrip = 18 - (21 - (Int_t)(nTDC/3.));
1240 }
1241 else if (nTRM==12) iStrip = 14 - ( 7 - (Int_t)(nTDC/3.));
1242
1243 }
1244
1245 return iStrip;
1246
1247}
1248
1249//----------------------------------------------------------------------------
1250Int_t AliTOFRawStream::Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC,
1251 Int_t iCH) const
1252{
1253 //
1254 // Returns the TOF pad number per strip [0;95]
1255 // corresponding to the TOF equipment ID numbers:
1256 // iDDL -> DDL number per sector [0;3]
1257 // iChain -> TRM chain number [0;1]
1258 // nTDC -> TDC number [0;14]
1259 // iCH -> TDC channel number [0;7]
1260 //
1261
1262 Int_t iPadAlongTheStrip = -1;
1263
1264 Int_t iTDClocal = nTDC%3 + (1-iChain)*3;
1265
1266 if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal;
1267 else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal);
1268
1269 Int_t iCHlocal = iCH;
1270 if (iDDL==0 || iDDL==3) iCHlocal = 7 - iCH;
1271
1272 iPadAlongTheStrip = iTDClocal*AliTOFGeometry::NCh() + iCHlocal;
1273
1274 if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) ||
1275 ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX()))
1276 AliError("Problems with the padX number!");
1277
1278 return iPadAlongTheStrip;
1279
1280}
1281
1282//----------------------------------------------------------------------------
1283Int_t AliTOFRawStream::GetSectorNumber(Int_t nDDL) const
1284{
1285 //
1286 // Returns the sector number [0;17]
1287 // corresponing to the assigned DRM/DDL number [0;71]
1288 //
1289
1290 Int_t iSector = Int_t((Float_t)(nDDL)/AliTOFGeometry::NDDL());
1291
1292 return iSector;
1293
1294}
1295//----------------------------------------------------------------------------
1296Int_t AliTOFRawStream::GetDDLnumberPerSector(Int_t nDDL) const
1297{
1298 //
1299 // Return the DRM/DDL number per sector [0;3]
1300 // corresponing to the assigned DRM/DDL number [0;71]
1301 //
1302
1303 Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
1304
1305 return iDDL;
1306
1307}
1308
1309//----------------------------------------------------------------------------
1310void AliTOFRawStream::EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
1311 Int_t nTDC, Int_t iCH,
1312 Int_t *volume) const
1313{
1314 //
1315 // To convert:
1316 // nDDL (variable in [0;71]) -> number of the DDL file
1317 // nTRM (variable in [3;12]) -> number of the TRM slot
1318 // iChain (variable in [0; 1]) -> number of the TRM chain
1319 // nTDC (variable in [0;14]) -> number of the TDC
1320 // iCH (variable in [0; 7]) -> number of the TDC channel
1321 //
1322 // in:
1323 // sector number, i.e. volume[0] (variable in [0,17])
1324 // plate number, i.e. volume[1] (variable in [0, 5])
1325 // strip number, i.e. volume[2] (variable in [0,14/18])
1326 // padX number, i.e. volume[3] (variable in [0,47])
1327 // padZ number, i.e. volume[4] (variable in [0, 1])
1328 //
1329
1330 Int_t iDDL = GetDDLnumberPerSector(nDDL);
1331
1332 Int_t iSector = GetSectorNumber(nDDL);
1333
1334 Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
1335 if (iPlate==-1) AliError("Problems with the plate number!");
1336
1337 Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
1338 if (iStrip==-1) AliError("Problems with the strip number!");
1339
1340 Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
1341 if (iPadAlongTheStrip==-1)
1342 AliError("Problems with the pad number along the strip!");
1343
1344 Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1345 Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
1346
1347 volume[0] = iSector;
1348 volume[1] = iPlate;
1349 volume[2] = iStrip;
1350 volume[3] = iPadX;
1351 volume[4] = iPadZ;
571dda3d 1352
1353}
740f0695 1354//_____________________________________________________________________________
1355
1356Int_t AliTOFRawStream::GetIndex(Int_t *detId)
1357{
1358 //Retrieve calibration channel index
1359 const Int_t nSectors = fTOFGeometry->NSectors();
1360 const Int_t nPlates = fTOFGeometry->NPlates();
1361 const Int_t nStripA = fTOFGeometry->NStripA();
1362 const Int_t nStripB = fTOFGeometry->NStripB();
1363 const Int_t nStripC = fTOFGeometry->NStripC();
1364 const Int_t nPadX = fTOFGeometry->NpadX();
1365 const Int_t nPadZ = fTOFGeometry->NpadZ();
1366
1367
1368 Int_t isector = detId[0];
1369 if (isector >= nSectors)
1370 AliError(Form("Wrong sector number in TOF (%d) !",isector));
1371 Int_t iplate = detId[1];
1372 if (iplate >= nPlates)
1373 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
1374 Int_t istrip = detId[2];
1375 Int_t ipadz = detId[3];
1376 Int_t ipadx = detId[4];
1377 Int_t stripOffset = 0;
1378 switch (iplate) {
1379 case 0:
1380 stripOffset = 0;
1381 break;
1382 case 1:
1383 stripOffset = nStripC;
1384 break;
1385 case 2:
1386 stripOffset = nStripC+nStripB;
1387 break;
1388 case 3:
1389 stripOffset = nStripC+nStripB+nStripA;
1390 break;
1391 case 4:
1392 stripOffset = nStripC+nStripB+nStripA+nStripB;
1393 break;
1394 default:
1395 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
1396 break;
1397 };
1398
1399 Int_t idet = ((2*(nStripC+nStripB)+nStripA)*nPadZ*nPadX)*isector +
1400 (stripOffset*nPadZ*nPadX)+
1401 (nPadZ*nPadX)*istrip+
1402 (nPadX)*ipadz+
1403 ipadx;
1404 return idet;
1405}