1 /**************************************************************************
2 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.11 2006/08/10 14:46:54 decaro
19 TOF raw data format: updated version
21 Revision 1.10.1 2006/06/28 A.De Caro
22 Update TOF raw data format
23 according to the final version
24 (see ALICE internal note in preparation
25 'ALICE TOF raw data format')
27 Revision 0.02 2005/7/25 A.De Caro
28 Update number of bits allocated for time-of-flight
29 and 'charge' measurements
31 Revision 0.01 2004/6/11 A.De Caro, S.B.Sellitto, R.Silvestri
32 First implementation: global methods RawDataTOF
36 ////////////////////////////////////////////////////////////////////
38 // This class contains the methods to create the Raw Data files //
39 // for the TOF detector starting from the Digits. //
40 // In this implementation, we defined the structure //
41 // of the ALICE-TOF raw data (according to the //
42 // ALICE technical note, in preparation) //
43 // starting from the TOF digit format. //
45 ////////////////////////////////////////////////////////////////////
47 #include "Riostream.h"
50 #include "TClonesArray.h"
54 #include "AliBitPacking.h"
57 //#include "AliRawDataHeader.h"
58 #include "AliRawDataHeaderSim.h"
60 #include "AliTOFDDLRawData.h"
61 #include "AliTOFDigitMap.h"
62 #include "AliTOFdigit.h"
63 #include "AliTOFGeometry.h"
64 #include "AliTOFRawStream.h"
66 extern TRandom *gRandom;
68 ClassImp(AliTOFDDLRawData)
70 //---------------------------------------------------------------------------
71 AliTOFDDLRawData::AliTOFDDLRawData():
75 fTOFdigitMap(new AliTOFDigitMap()),
77 fTOFrawStream(new AliTOFRawStream())
82 //----------------------------------------------------------------------------
83 AliTOFDDLRawData::AliTOFDDLRawData(AliTOFGeometry *tofGeom):
86 fTOFgeometry(tofGeom),
87 fTOFdigitMap(new AliTOFDigitMap()),
89 fTOFrawStream(new AliTOFRawStream())
95 //----------------------------------------------------------------------------
96 AliTOFDDLRawData::AliTOFDDLRawData(const AliTOFDDLRawData &source) :
101 fTOFdigitMap(new AliTOFDigitMap()),
103 fTOFrawStream(new AliTOFRawStream())
106 this->fIndex=source.fIndex;
107 this->fVerbose=source.fVerbose;
108 this->fTOFgeometry=source.fTOFgeometry;
109 this->fTOFdigitMap=source.fTOFdigitMap;
110 this->fTOFdigitArray=source.fTOFdigitArray;
111 this->fTOFrawStream=source.fTOFrawStream;
115 //----------------------------------------------------------------------------
116 AliTOFDDLRawData& AliTOFDDLRawData::operator=(const AliTOFDDLRawData &source) {
118 this->fIndex=source.fIndex;
119 this->fVerbose=source.fVerbose;
120 this->fTOFgeometry=source.fTOFgeometry;
121 this->fTOFdigitMap=source.fTOFdigitMap;
122 this->fTOFdigitArray=source.fTOFdigitArray;
123 this->fTOFrawStream=source.fTOFrawStream;
127 //----------------------------------------------------------------------------
128 Int_t AliTOFDDLRawData::RawDataTOF(TBranch* branch)
131 // This method creates the Raw data files for TOF detector
134 const Int_t kSize = 5000; //max number of digits per DDL file times 2
140 fTOFdigitArray = * (TClonesArray**) branch->GetAddress();
143 ofstream outfile; // logical name of the output file
145 //AliRawDataHeader header;
146 AliRawDataHeaderSim header;
148 UInt_t sizeRawData = 0;
160 UInt_t nWordsPerTRM = 0;
162 //loop over TOF DDL files
163 for (nDDL=0; nDDL<AliDAQ::NumberOfDdls("TOF"); nDDL++) {
165 strcpy(fileName,AliDAQ::DdlFileName("TOF",nDDL)); //The name of the output file
167 outfile.open(fileName,ios::binary);
169 outfile.open(fileName);
172 iDDL = fTOFrawStream->GetDDLnumberPerSector(nDDL);
174 // write Dummy DATA HEADER
175 UInt_t dataHeaderPosition = outfile.tellp();
176 outfile.write((char*)(&header),sizeof(header));
178 // DRM section: trailer
183 buf[fIndex] = MakeFiller();
188 // loop on TRM number per DRM
189 for (nTRM=AliTOFGeometry::NTRM(); nTRM>=3; nTRM--) {
193 // the slot number 3 of the even DRM (i.e. right) doesn't contain TDC digit data
194 if (iDDL%2==0 && nTRM==3) continue;
196 // TRM global trailer
199 // loop on TRM chain number per TRM
200 for (iChain=AliTOFGeometry::NChain()-1; iChain>=0; iChain--) {
203 MakeTRMchainTrailer(iChain, buf);
207 MakeTDCdigits(nDDL, nTRM, iChain, buf, nWordsPerTRM);
210 MakeTRMchainHeader(nTRM, iChain, buf);
213 } // end loop on iChain
216 MakeTRMheader(nTRM, buf);
218 // TRM filler in case where TRM data number is odd
219 if (nWordsPerTRM%2!=0) MakeTRMfiller(buf, nWordsPerTRM);
221 } // end loop on nTRM
224 MakeDRMheader(nDDL, buf);
226 ReverseArray(buf, fIndex+1);
228 outfile.write((char *)buf,((fIndex+1)*sizeof(UInt_t)));
230 for (jj=0; jj<(fIndex+1); jj++) buf[jj]=0;
233 //Write REAL DATA HEADER
234 UInt_t currentFilePosition = outfile.tellp();
235 sizeRawData = currentFilePosition - dataHeaderPosition - sizeof(header);
236 header.fSize = currentFilePosition - dataHeaderPosition;
237 header.SetAttribute(0); // valid data
238 outfile.seekp(dataHeaderPosition);
239 outfile.write((char*)(&header),sizeof(header));
240 outfile.seekp(currentFilePosition);
244 } //end loop on DDL file number
250 //----------------------------------------------------------------------------
251 void AliTOFDDLRawData::GetDigits()
254 // Fill the TOF volumes' map with the TOF digit indices
257 Int_t vol[5] = {-1,-1,-1,-1,-1};
260 Int_t ndigits = fTOFdigitArray->GetEntries();
264 // loop on TOF digits
265 for (digit=0; digit<ndigits; digit++) {
266 digs = (AliTOFdigit*)fTOFdigitArray->UncheckedAt(digit);
268 vol[0] = digs->GetSector(); // Sector Number (0-17)
269 vol[1] = digs->GetPlate(); // Plate Number (0-4)
270 vol[2] = digs->GetStrip(); // Strip Number (0-14/18)
271 vol[3] = digs->GetPadx(); // Pad Number in x direction (0-47)
272 vol[4] = digs->GetPadz(); // Pad Number in z direction (0-1)
274 fTOFdigitMap->AddDigit(vol, digit);
276 } // close loop on digit del TOF
280 //----------------------------------------------------------------------------
281 void AliTOFDDLRawData::MakeDRMheader(Int_t nDDL, UInt_t *buf)
287 Int_t iDDL = fTOFrawStream->GetDDLnumberPerSector(nDDL);
289 Int_t iSector = fTOFrawStream->GetSectorNumber(nDDL);
296 word = 1; // 0001 -> DRM data are coming from the VME slot number 1
297 AliBitPacking::PackWord(word,baseWord, 0, 3);
298 word = 0; // event CRC
299 AliBitPacking::PackWord(word,baseWord, 4,19);
300 word = 0; // reserved for future use
301 AliBitPacking::PackWord(word,baseWord,20,27);
302 word = 4; // 0100 -> DRM header ID
303 AliBitPacking::PackWord(word,baseWord,28,31);
305 buf[fIndex]=baseWord;
307 // DRM status header 3
309 word = 1; // 0001 -> DRM data are coming from the VME slot number 1
310 AliBitPacking::PackWord(word,baseWord, 0, 3);
311 word = 0; // TTC event counter
312 AliBitPacking::PackWord(word,baseWord, 4,27);
313 word = 4; // 0100 -> DRM header ID
314 AliBitPacking::PackWord(word,baseWord,28,31);
316 buf[fIndex]=baseWord;
318 // DRM status header 2
320 word = 1; // 0001 -> DRM data are coming from the VME slot number 1
321 AliBitPacking::PackWord(word,baseWord, 0, 3);
324 word = 2047; // enable ID: [00000000000;11111111111] for odd
325 // (i.e. right) crates
326 AliBitPacking::PackWord(word,baseWord, 4,14);
328 word = 2045; // enable ID: [00000000000;11111111101] for even
329 // (i.e. left) crates
330 AliBitPacking::PackWord(word,baseWord, 4,14);
334 AliBitPacking::PackWord(word,baseWord,15,15);
335 word = 0; // fault ID
336 AliBitPacking::PackWord(word,baseWord,16,27);
337 word = 4; // 0100 -> DRM header ID
338 AliBitPacking::PackWord(word,baseWord,28,31);
340 buf[fIndex]=baseWord;
342 // DRM status header 1
344 word = 1; // 0001 -> DRM data are coming from the VME slot number 1
345 AliBitPacking::PackWord(word,baseWord, 0, 3);
348 word = 2047; // slot ID: [00000000000;11111111111] for odd
349 // (i.e. right) crates
350 AliBitPacking::PackWord(word,baseWord, 4,14);
352 word = 2045; // slot ID: [00000000000;11111111101] for even
353 // (i.e. left) crates
354 AliBitPacking::PackWord(word,baseWord, 4,14);
357 word = 1; // LHC clock status: 1/0
358 AliBitPacking::PackWord(word,baseWord,15,15);
359 word = 0; // reserved for future use
360 AliBitPacking::PackWord(word,baseWord,16,27);
361 word = 4; // 0100 -> DRM header ID
362 AliBitPacking::PackWord(word,baseWord,28,31);
364 buf[fIndex]=baseWord;
368 word = 1; // 0001 -> DRM data are coming from the VME slot number 1
369 AliBitPacking::PackWord(word,baseWord, 0, 3);
370 word = fIndex+1 + 1; // event words
371 AliBitPacking::PackWord(word,baseWord, 4,20);
372 word = iDDL; // crate ID [0;3]
373 AliBitPacking::PackWord(word,baseWord,21,22);
374 word = iSector; // sector ID [0;17]
375 AliBitPacking::PackWord(word,baseWord,23,27);
376 word = 4; // 0100 -> DRM header ID
377 AliBitPacking::PackWord(word,baseWord,28,31);
379 buf[fIndex]=baseWord;
383 //----------------------------------------------------------------------------
384 void AliTOFDDLRawData::MakeDRMtrailer(UInt_t *buf)
387 // DRM global trailer
394 word = 1; // 0001 -> DRM data are coming from the VME slot number 1
395 AliBitPacking::PackWord(word,baseWord, 0, 3);
396 word = 0; // local event counter
397 AliBitPacking::PackWord(word,baseWord, 4,15);
398 word = 0; // reserved for future use
399 AliBitPacking::PackWord(word,baseWord,16,27);
400 word = 5; // 0101 -> DRM trailer ID
401 AliBitPacking::PackWord(word,baseWord,28,31);
403 buf[fIndex]=baseWord;
407 //----------------------------------------------------------------------------
408 void AliTOFDDLRawData::MakeLTMheader(UInt_t *buf)
418 word = 2; // 0010 -> LTM data are coming from the VME slot number 2
419 AliBitPacking::PackWord(word,baseWord, 0, 3);
420 word = 35; // event words
421 AliBitPacking::PackWord(word,baseWord, 4,16);
422 word = 0; // crc error
423 AliBitPacking::PackWord(word,baseWord,17,17);
425 AliBitPacking::PackWord(word,baseWord,18,23);
427 AliBitPacking::PackWord(word,baseWord,24,27);
428 word = 4; // 0100 -> LTM header ID
429 AliBitPacking::PackWord(word,baseWord,28,31);
431 buf[fIndex]=baseWord;
435 //----------------------------------------------------------------------------
436 void AliTOFDDLRawData::MakeLTMdata(UInt_t *buf)
446 word = 100; // Local temperature in LTM5 -> 4 X 25 degree (environment temperature)
447 AliBitPacking::PackWord(word,baseWord, 0, 9);
448 word = 100; // Local temperature in LTM6 -> 4 X 25 degree (environment temperature)
449 AliBitPacking::PackWord(word,baseWord,10,19);
450 word = 100; // Local temperature in LTM7 -> 4 X 25 degree (environment temperature)
451 AliBitPacking::PackWord(word,baseWord,20,29);
453 AliBitPacking::PackWord(word,baseWord,30,31);
456 buf[fIndex]=baseWord;
458 // Local temperature in LTM2, LMT3, LTM4 -> 4 X 25 degree (environment temperature)
460 buf[fIndex]=baseWord;
462 // Local temperature in FEAC7, FEAC8, LTM1 -> 4 X 25 degree (environment temperature)
464 buf[fIndex]=baseWord;
466 // Local temperature in FEAC4, FEAC5, FEAC6 -> 4 X 25 degree (environment temperature)
468 buf[fIndex]=baseWord;
470 // Local temperature in FEAC1, FEAC2, FEAC3 -> 4 X 25 degree (environment temperature)
472 buf[fIndex]=baseWord;
475 word = 0; // GND-FEAC15 -> Voltage drop between GND and FEAC15
476 AliBitPacking::PackWord(word,baseWord, 0, 9);
477 word = 0; // VTH16 -> Thereshould voltage for FEAC16
478 AliBitPacking::PackWord(word,baseWord,10,19);
479 word = 0; // GND-FEAC16 -> Voltage drop between GND and FEAC16
480 AliBitPacking::PackWord(word,baseWord,20,29);
482 AliBitPacking::PackWord(word,baseWord,30,31);
485 buf[fIndex]=baseWord;
487 // VTH14 -> Thereshould voltage for FEAC14
488 // GND-FEAC14 -> Voltage drop between GND and FEAC14
489 // VTH15 -> Thereshould voltage for FEAC15
491 buf[fIndex]=baseWord;
493 // GND-FEAC12 -> Voltage drop between GND and FEAC12
494 // VTH13 -> Thereshould voltage for FEAC13
495 // GND-FEAC13 -> Voltage drop between GND and FEAC13
497 buf[fIndex]=baseWord;
499 // VTH11 -> Thereshould voltage for FEAC11
500 // GND-FEAC11 -> Voltage drop between GND and FEAC11
501 // VTH12 -> Thereshould voltage for FEAC12
503 buf[fIndex]=baseWord;
505 // GND-FEAC9 -> Voltage drop between GND and FEAC9
506 // VTH10 -> Thereshould voltage for FEAC10
507 // GND-FEAC10 -> Voltage drop between GND and FEAC10
509 buf[fIndex]=baseWord;
511 // VTH8 -> Thereshould voltage for FEAC8
512 // GND-FEAC8 -> Voltage drop between GND and FEAC8
513 // VTH9 -> Thereshould voltage for FEAC9
515 buf[fIndex]=baseWord;
517 // GND-FEAC6 -> Voltage drop between GND and FEAC6
518 // VTH7 -> Thereshould voltage for FEAC7
519 // GND-FEAC7 -> Voltage drop between GND and FEAC7
521 buf[fIndex]=baseWord;
523 // VTH5 -> Thereshould voltage for FEAC5
524 // GND-FEAC5 -> Voltage drop between GND and FEAC5
525 // VTH6 -> Thereshould voltage for FEAC6
527 buf[fIndex]=baseWord;
529 // GND-FEAC3 -> Voltage drop between GND and FEAC3
530 // VTH4 -> Thereshould voltage for FEAC4
531 // GND-FEAC4 -> Voltage drop between GND and FEAC4
533 buf[fIndex]=baseWord;
535 // VTH2 -> Thereshould voltage for FEAC2
536 // GND-FEAC2 -> Voltage drop between GND and FEAC2
537 // VTH3 -> Thereshould voltage for FEAC3
539 buf[fIndex]=baseWord;
541 // LV16 -> Low Voltage measured by FEAC16
542 // GND-FEAC1 -> Voltage drop between GND and FEAC1
543 // VTH1 -> Thereshould voltage for FEAC1
545 buf[fIndex]=baseWord;
547 // Low Voltage measured by FEAC13, FEAC14, FEAC15
549 buf[fIndex]=baseWord;
551 // Low Voltage measured by FEAC10, FEAC11, FEAC12
553 buf[fIndex]=baseWord;
555 // Low Voltage measured by FEAC7, FEAC8, FEAC9
557 buf[fIndex]=baseWord;
559 // Low Voltage measured by FEAC4, FEAC5, FEAC6
561 buf[fIndex]=baseWord;
563 // Low Voltage measured by FEAC1, FEAC2, FEAC3
565 buf[fIndex]=baseWord;
569 word = 0; // PDL45 -> Delay Line setting for PDL45
570 AliBitPacking::PackWord(word,baseWord, 0, 7);
571 word = 0; // PDL46 -> Delay Line setting for PDL46
572 AliBitPacking::PackWord(word,baseWord, 8,15);
573 word = 0; // PDL47 -> Delay Line setting for PDL47
574 AliBitPacking::PackWord(word,baseWord,16,23);
575 word = 0; // PDL48 -> Delay Line setting for PDL48
576 AliBitPacking::PackWord(word,baseWord,24,31);
578 buf[fIndex]=baseWord;
580 // Delay Line setting for PDL41, PDL42, PDL43, PDL44
582 buf[fIndex]=baseWord;
584 // Delay Line setting for PDL37, PDL38, PDL39, PDL40
586 buf[fIndex]=baseWord;
588 // Delay Line setting for PDL33, PDL34, PDL35, PDL36
590 buf[fIndex]=baseWord;
592 // Delay Line setting for PDL29, PDL30, PDL31, PDL32
594 buf[fIndex]=baseWord;
596 // Delay Line setting for PDL25, PDL26, PDL27, PDL28
598 buf[fIndex]=baseWord;
600 // Delay Line setting for PDL21, PDL22, PDL23, PDL24
602 buf[fIndex]=baseWord;
604 // Delay Line setting for PDL17, PDL18, PDL19, PDL20
606 buf[fIndex]=baseWord;
608 // Delay Line setting for PDL13, PDL14, PDL15, PDL16
610 buf[fIndex]=baseWord;
612 // Delay Line setting for PDL9, PDL10, PDL11, PDL12
614 buf[fIndex]=baseWord;
616 // Delay Line setting for PDL5, PDL6, PDL7, PDL8
618 buf[fIndex]=baseWord;
620 // Delay Line setting for PDL1, PDL2, PDL3, PDL4
622 buf[fIndex]=baseWord;
626 //----------------------------------------------------------------------------
627 void AliTOFDDLRawData::MakeLTMtrailer(UInt_t *buf)
637 word = 2; // 0010 -> LTM data are coming from the VME slot number 2
638 AliBitPacking::PackWord(word,baseWord, 0, 3);
639 word = 0; // event crc
640 AliBitPacking::PackWord(word,baseWord, 4,15);
641 word = 0; // event number
642 AliBitPacking::PackWord(word,baseWord,16,27);
643 word = 5; // 0101 -> LTM trailer ID
644 AliBitPacking::PackWord(word,baseWord,28,31);
646 buf[fIndex]=baseWord;
650 //----------------------------------------------------------------------------
651 void AliTOFDDLRawData::MakeTRMheader(Int_t nTRM, UInt_t *buf)
654 // TRM header for the TRM number nTRM [ 3;12]
657 if (nTRM<3 || nTRM>12) {
658 AliWarning(Form(" TRM number is out of the right range [3;12] (nTRM = %3i",nTRM));
666 word = nTRM; // TRM data coming from the VME slot number nTRM
667 AliBitPacking::PackWord(word,baseWord, 0, 3);
668 word = 0; // event words
669 AliBitPacking::PackWord(word,baseWord, 4,16);
670 word = 0; // ACQuisition mode: [0;3] see document
671 AliBitPacking::PackWord(word,baseWord,17,18);
672 word = 0; // description of a SEU inside LUT tables for INL compensation;
673 // the data are unaffected
674 AliBitPacking::PackWord(word,baseWord,19,19);
675 word = 0; // Must Be Zero (MBZ)
676 AliBitPacking::PackWord(word,baseWord,20,27);
677 word = 4; // 0100 -> TRM header ID
678 AliBitPacking::PackWord(word,baseWord,28,31);
680 buf[fIndex]=baseWord;
684 //----------------------------------------------------------------------------
685 void AliTOFDDLRawData::MakeTRMtrailer(UInt_t *buf)
695 word = 15; // 1111 -> TRM trailer ID 1
696 AliBitPacking::PackWord(word,baseWord, 0, 3);
697 word = 0; // event CRC
698 AliBitPacking::PackWord(word,baseWord, 4,15);
699 word = 0; // local event counter == DRM local event counter
700 AliBitPacking::PackWord(word,baseWord,16,27);
701 word = 5; // 0101 -> TRM trailer ID 2
702 AliBitPacking::PackWord(word,baseWord,28,31);
704 buf[fIndex]=baseWord;
708 //----------------------------------------------------------------------------
709 void AliTOFDDLRawData::MakeTRMchainHeader(Int_t nTRM, Int_t iChain,
719 if (nTRM<3 || nTRM>12) {
720 AliWarning(Form(" TRM number is out of the right range [3;12] (nTRM = %3i", nTRM));
724 if (iChain<0 || iChain>1) {
725 AliWarning(Form(" Chain number is out of the right range [0;1] (iChain = %3i", iChain));
730 word = nTRM; // TRM data coming from the VME slot ID nTRM
731 AliBitPacking::PackWord(word,baseWord, 0, 3);
732 word = 0; // bunch ID
733 AliBitPacking::PackWord(word,baseWord, 4,15);
734 word = 100; // PB24 temperature -> 4 X 25 degree (environment temperature)
735 AliBitPacking::PackWord(word,baseWord,16,23);
736 word = (Int_t)(5 * gRandom->Rndm()); // PB24 ID [0;4]
737 AliBitPacking::PackWord(word,baseWord,24,26);
739 AliBitPacking::PackWord(word,baseWord,27,27);
742 word = 0; // 0000 -> TRM chain 0 ID
745 word = 2; // 0010 -> TRM chain 1 ID
748 AliBitPacking::PackWord(word,baseWord,28,31);
750 buf[fIndex]=baseWord;
754 //----------------------------------------------------------------------------
755 void AliTOFDDLRawData::MakeTRMfiller(UInt_t *buf, UInt_t nWordsPerTRM)
764 for (jj=fIndex; jj>fIndex-(Int_t)nWordsPerTRM; jj--) {
768 buf[fIndex-nWordsPerTRM] = MakeFiller();
772 //----------------------------------------------------------------------------
773 UInt_t AliTOFDDLRawData::MakeFiller()
776 // Filler word definition: to make even the number of words per TRM/LTM
783 word = 0; // 0000 -> filler ID 1
784 AliBitPacking::PackWord(word,baseWord, 0, 3);
786 AliBitPacking::PackWord(word,baseWord, 4,27);
787 word = 7; // 0111 -> filler ID 2
788 AliBitPacking::PackWord(word,baseWord, 28,31);
794 //----------------------------------------------------------------------------
795 void AliTOFDDLRawData::MakeTRMchainTrailer(Int_t iChain, UInt_t *buf)
801 if (iChain<0 || iChain>1) {
802 AliWarning(Form(" Chain number is out of the right range [0;1] (iChain = %3i", iChain));
811 AliBitPacking::PackWord(word,baseWord, 0, 3);
813 AliBitPacking::PackWord(word,baseWord, 4,15);
814 word = 0; // event counter
815 AliBitPacking::PackWord(word,baseWord,16,27);
818 word = 1; // 0001 -> TRM chain 0 trailer ID
821 word = 3; // 0011 -> TRM chain 1 trailer ID
824 AliBitPacking::PackWord(word,baseWord,28,31);
826 buf[fIndex]=baseWord;
830 //----------------------------------------------------------------------------
831 void AliTOFDDLRawData::MakeTDCdigits(Int_t nDDL, Int_t nTRM, Int_t iChain,
832 UInt_t *buf, UInt_t &nWordsPerTRM)
838 if (nDDL<0 || nDDL>71) {
839 AliWarning(Form(" DDL number is out of the right range [0;71] (nDDL = %3i", nDDL));
843 if (nTRM<3 || nTRM>12) {
844 AliWarning(Form(" TRM number is out of the right range [3;12] (nTRM = %3i", nTRM));
848 if (iChain<0 || iChain>1) {
849 AliWarning(Form(" Chain number is out of the right range [0;1] (iChain = %3i", iChain));
853 Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
855 Int_t volume[5] = {-1, -1, -1, -1, -1};
856 Int_t indexDigit[3] = {-1, -1, -1};
858 Int_t totCharge = -1;
859 Int_t timeOfFlight = -1;
872 if (fVerbose==2) ftxt.open("TOFdigits.txt",ios::app);
874 for (jj=0; jj<5; jj++) volume[jj] = -1;
876 // loop on TDC number
877 for (nTDC=AliTOFGeometry::NTdc()-1; nTDC>=0; nTDC--) {
879 // the DRM odd (i.e. left) slot number 3 doesn't contain TDC digit data
880 // for TDC numbers 3-14
881 if (iDDL%2==1 && nTRM==3 && (Int_t)(nTDC/3.)!=0) continue;
883 // loop on TDC channel number
884 for (iCH=AliTOFGeometry::NCh()-1; iCH>=0; iCH--) {
886 fTOFrawStream->EquipmentId2VolumeId(nDDL, nTRM, iChain, nTDC, iCH, volume);
888 if (volume[0]==-1 || volume[1]==-1 || volume[2]==-1 ||
889 volume[3]==-1 || volume[4]==-1) continue;
890 //AliInfo(Form(" sector = %2i plate = %1i strip = %2i
891 //padX = %2i padZ = %1i", volume[0], volume[1], volume[2],
892 //volume[3], volume[4]));
894 for (jj=0; jj<3; jj++) indexDigit[jj] = -1;
896 fTOFdigitMap->GetDigitIndex(volume, indexDigit);
898 for (jj=0; jj<3;jj++) {
900 if (indexDigit[jj]<0) continue;
901 digs = (AliTOFdigit*)fTOFdigitArray->UncheckedAt(indexDigit[jj]);
903 if (digs->GetSector()!=volume[0] ||
904 digs->GetPlate() !=volume[1] ||
905 digs->GetStrip() !=volume[2] ||
906 digs->GetPadx() !=volume[3] ||
907 digs->GetPadz() !=volume[4]) AliWarning(" --- ERROR --- ");
909 timeOfFlight = (Int_t)(digs->GetTdc())%8192;
910 totCharge = (Int_t)(digs->GetToT());//digs->GetAdc();
912 if (totCharge<0) totCharge = TMath::Abs(totCharge);
913 if (totCharge>=256) totCharge = 255;
916 if (nDDL<10) ftxt << " " << nDDL;
917 else ftxt << " " << nDDL;
918 if (nTRM<10) ftxt << " " << nTRM;
919 else ftxt << " " << nTRM;
920 ftxt << " " << iChain;
921 if (nTDC<10) ftxt << " " << nTDC;
922 else ftxt << " " << nTDC;
924 if (volume[0]<10) ftxt << " -> " << volume[0];
925 else ftxt << " -> " << volume[0];
926 ftxt << " " << volume[1];
927 if (volume[2]<10) ftxt << " " << volume[2];
928 else ftxt << " " << volume[2];
929 ftxt << " " << volume[4];
930 if (volume[3]<10) ftxt << " " << volume[3];
931 else ftxt << " " << volume[3];
932 if (totCharge<10) ftxt << " " << totCharge;
933 else if (totCharge>=10 && totCharge<100) ftxt << " " << totCharge;
934 else ftxt << " " << totCharge;
935 if (timeOfFlight<10) ftxt << " " << timeOfFlight << endl;
936 else if (timeOfFlight>=10 && timeOfFlight<100) ftxt << " " << timeOfFlight << endl;
937 else if (timeOfFlight>=100 && timeOfFlight<1000) ftxt << " " << timeOfFlight << endl;
938 else ftxt << " " << timeOfFlight << endl;
941 word = timeOfFlight; // time-of-fligth measurement
942 AliBitPacking::PackWord(word,baseWord, 0,12);
944 word = totCharge; // time-over-threshould measurement
945 AliBitPacking::PackWord(word,baseWord,13,20);
947 word = iCH; // TDC channel ID [0;7]
948 AliBitPacking::PackWord(word,baseWord,21,23);
949 word = nTDC; // TDC ID [0;14]
950 AliBitPacking::PackWord(word,baseWord,24,27);
951 word = 0; // error flag
952 AliBitPacking::PackWord(word,baseWord,28,28);
953 word = 0; // Packing Status [0;5]
954 AliBitPacking::PackWord(word,baseWord,29,30);
955 word = 1; // TRM TDC digit ID
956 AliBitPacking::PackWord(word,baseWord,31,31);
958 buf[fIndex]=baseWord;
963 } //end loop on digits in the same volume
965 } // end loop on TDC channel number
967 } // end loop on TDC number
970 if (fVerbose==2) ftxt.close();
974 //----------------------------------------------------------------------------
975 void AliTOFDDLRawData::ReverseArray(UInt_t a[], Int_t n) const
978 // Reverses the n elements of array a
983 for (ii=0; ii<n/2; ii++) {