1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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.19.1 2008/09/19 preghenella
19 Decode method updated:
20 it reads the CDH from the rawReader and sends it to the decoder;
21 LoadRawDataBuffers modified:
22 it corrects tof hit infos per ddlBC and deltaBC offsets
23 (in case of the static member fgApplyBCCorrections
24 has been setted to kTRUE);
25 Added static member fgApplyBCCorrections (kTRUE by default)
26 and the related static method ApplyBCCorrections;
28 Revision 1.19 2007/05/18 13:07:53 decaro
29 Error messages stored in the global raw-reader error log (Cvetan, Chiara)
31 Revision 1.18 2007/05/08 11:53:29 arcelli
32 Improved class flexibility for further use (R.Preghenella)
34 Revision 1.17 2007/05/03 08:53:50 decaro
35 Coding convention: RS3 violation -> suppression
37 Revision 1.16 2007/05/03 08:22:22 decaro
38 Coding convention: RN17 violation -> suppression
40 Revision 1.15 2007/04/30 15:22:06 arcelli
41 Change TOF digit Time, Tot etc to int type
43 Revision 1.14 2007/04/27 11:11:53 arcelli
44 updates for the new decoder
46 Revision 1.13 2007/03/16 11:46:35 decaro
47 Coding convention: RN17 rule violation -> suppression
49 Revision 1.12 2007/02/22 09:43:45 decaro
50 Added AliTOFRawStream::GetIndex method for online calibration (C.Zampolli)
52 Revision 1.11 2007/02/20 15:57:00 decaro
53 Raw data update: to read the TOF raw data defined in UNPACKED mode
55 Revision 1.10 2006/12/15 14:01:38 cvetan
58 Revision 1.9 2006/10/13 11:22:27 arcelli
59 remove warnings due to uninitialized AliTOFtdcDigit data members
61 Revision 1.8 2006/08/22 13:30:17 arcelli
62 removal of effective c++ warnings (C.Zampolli)
64 Revision 1.7 2006/08/10 14:46:54 decaro
65 TOF raw data format: updated version
67 Revision 1.6.1 2006/06/28 A. De Caro, R. Preghenella:
68 Update TOF raw data format
69 according to the final version
70 (see the ALICE internal note in preparation
71 'ALICE TOF raw data format')
72 Added the methods for the correspoonding numbering
73 between the equipment IDs and the volume IDs:
78 Revision 0.02 2005/07/28 A. De Caro:
79 Update format TOF raw data
81 Correction of few wrong corrispondences
82 between 'software' and 'hardware' numberings
84 Revision 0.01 2005/07/22 A. De Caro
85 Implement methods Next()
93 ////////////////////////////////////////////////////////////////////////
95 // This class provides access to TOF raw data in DDL files. //
97 // It loops over all TOF raw data given by the AliRawReader. //
99 ////////////////////////////////////////////////////////////////////////
102 #include "Riostream.h"
104 #include "TClonesArray.h"
108 #include "AliRawReader.h"
110 #include "AliTOFGeometry.h"
111 #include "AliTOFrawData.h"
112 #include "AliTOFRawMap.h"
113 #include "AliTOFRawStream.h"
114 //#include "AliTOFCableLengthMap.h"
116 #include "AliTOFHitData.h"
118 #include "AliRawEventHeaderBase.h"
119 #include "AliRawDataHeader.h"
121 ClassImp(AliTOFRawStream)
123 const Int_t AliTOFRawStream::fgkddlBCshift[72] =
145 Bool_t AliTOFRawStream::fgApplyBCCorrections = kTRUE;
146 //_____________________________________________________________________________
147 AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader):
148 fRawReader(rawReader),
150 fDecoder(new AliTOFDecoder()),
175 fInsideTRMchain0(kFALSE),
176 fInsideTRMchain1(kFALSE),
179 fLocalEventCounterDRM(-1),
180 fLocalEventCounterLTM(-1),
181 fLocalEventCounterTRM(0x0),
182 fLocalEventCounterChain(0x0),
184 fCableLengthMap(0x0),
188 // create an object to read TOF raw digits
191 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
193 ResetPackedDataBuffer(i);
196 fTOFrawData = new TClonesArray("AliTOFrawData",1000);
197 fTOFrawData->SetOwner();
200 fRawReader->Select("TOF");
202 fLocalEventCounterTRM = new Int_t[13];
203 fLocalEventCounterChain = new Int_t*[13];
204 fChainBunchID = new Int_t*[13];
205 for (Int_t j=0;j<13;j++){
206 fLocalEventCounterTRM[j] = -1;
207 fLocalEventCounterChain[j] = new Int_t[2];
208 fChainBunchID[j] = new Int_t[2];
209 for (Int_t k=0;k<2;k++){
210 fLocalEventCounterChain[j][k] = -1;
211 fChainBunchID[j][k] = -1;
215 fCableLengthMap = new AliTOFCableLengthMap();
217 fEventID = (Int_t)fRawReader->GetBCID(); //bunch crossing
221 //_____________________________________________________________________________
222 AliTOFRawStream::AliTOFRawStream():
225 fDecoder(new AliTOFDecoder()),
250 fInsideTRMchain0(kFALSE),
251 fInsideTRMchain1(kFALSE),
254 fLocalEventCounterDRM(-1),
255 fLocalEventCounterLTM(-1),
256 fLocalEventCounterTRM(0x0),
257 fLocalEventCounterChain(0x0),
259 fCableLengthMap(0x0),
265 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
267 ResetPackedDataBuffer(i);
270 fTOFrawData = new TClonesArray("AliTOFrawData",1000);
271 fTOFrawData->SetOwner();
273 fLocalEventCounterTRM = new Int_t[13];
274 fLocalEventCounterChain = new Int_t*[13];
275 fChainBunchID = new Int_t*[13];
276 for (Int_t j=0;j<13;j++){
277 fLocalEventCounterTRM[j] = -1;
278 fLocalEventCounterChain[j] = new Int_t[2];
279 fChainBunchID[j] = new Int_t[2];
280 for (Int_t k=0;k<2;k++){
281 fLocalEventCounterChain[j][k] = -1;
282 fChainBunchID[j][k] = -1;
286 fCableLengthMap = new AliTOFCableLengthMap();
290 //_____________________________________________________________________________
291 AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
293 fRawReader(stream.fRawReader),
294 fTOFrawData(stream.fTOFrawData),
295 fDecoder(new AliTOFDecoder()),
298 fTRMchain(stream.fTRMchain),
300 fTDCchannel(stream.fTDCchannel),
303 fLeadingEdge(stream.fLeadingEdge),
304 fTrailingEdge(stream.fTrailingEdge),
305 fErrorFlag(stream.fErrorFlag),
306 fSector(stream.fSector),
307 fPlate(stream.fPlate),
308 fStrip(stream.fStrip),
311 fPackedDigits(stream.fPackedDigits),
312 fWordType(stream.fWordType),
313 fSlotID(stream.fSlotID),
315 fPSbit(stream.fPSbit),
316 fTDCerrorFlag(stream.fTDCerrorFlag),
317 fInsideDRM(stream.fInsideDRM),
318 fInsideTRM(stream.fInsideTRM),
319 fInsideLTM(stream.fInsideLTM),
320 fInsideTRMchain0(stream.fInsideTRMchain0),
321 fInsideTRMchain1(stream.fInsideTRMchain1),
324 fLocalEventCounterDRM(stream.fLocalEventCounterDRM),
325 fLocalEventCounterLTM(stream.fLocalEventCounterLTM),
326 fLocalEventCounterTRM(0x0),
327 fLocalEventCounterChain(0x0),
329 fCableLengthMap(stream.fCableLengthMap),
330 fEventID(stream.fEventID)
336 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
337 fDataBuffer[i] = stream.fDataBuffer[i];
338 fPackedDataBuffer[i] = stream.fPackedDataBuffer[i];
341 fTOFrawData = new TClonesArray(*stream.fTOFrawData);
343 for (Int_t j=0;j<13;j++){
344 fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j];
345 for (Int_t k=0;k<2;k++){
346 fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k];
347 fChainBunchID[j][k] = stream.fChainBunchID[j][k];
353 //_____________________________________________________________________________
354 AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
357 // assignment operator
363 TObject::operator=(stream);
365 fRawReader = stream.fRawReader;
367 fTOFrawData = stream.fTOFrawData;
371 fTRMchain = stream.fTRMchain;
373 fTDCchannel = stream.fTDCchannel;
374 fTime = stream.fTime;
376 fLeadingEdge = stream.fLeadingEdge;
377 fTrailingEdge = stream.fTrailingEdge;
378 fErrorFlag = stream.fErrorFlag;
380 fSector = stream.fSector;
381 fPlate = stream.fPlate;
382 fStrip = stream.fStrip;
383 fPadX = stream.fPadX;
384 fPadZ = stream.fPadZ;
386 fPackedDigits = stream.fPackedDigits;
388 fWordType = stream.fWordType;
389 fSlotID = stream.fSlotID;
391 fPSbit = stream.fPSbit;
392 fTDCerrorFlag = stream.fTDCerrorFlag;
393 fInsideDRM = stream.fInsideDRM;
394 fInsideTRM = stream.fInsideTRM;
395 fInsideLTM = stream.fInsideLTM;
396 fInsideTRMchain0 = stream.fInsideTRMchain0;
397 fInsideTRMchain1 = stream.fInsideTRMchain1;
399 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
400 fDataBuffer[i] = stream.fDataBuffer[i];
401 fPackedDataBuffer[i] = stream.fPackedDataBuffer[i];
404 fTOFrawData = stream.fTOFrawData;
406 fLocalEventCounterDRM = stream.fLocalEventCounterDRM;
407 fLocalEventCounterLTM = stream.fLocalEventCounterLTM;
408 for (Int_t j=0;j<13;j++){
409 fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j];
410 for (Int_t k=0;k<2;k++){
411 fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k];
412 fChainBunchID[j][k] = stream.fChainBunchID[j][k];
416 fCableLengthMap = stream.fCableLengthMap;
418 fEventID = stream.fEventID;
424 //_____________________________________________________________________________
425 AliTOFRawStream::~AliTOFRawStream()
433 fTOFrawData->Clear();
436 delete [] fLocalEventCounterTRM;
437 for (Int_t ii=0; ii<2; ii++) {
438 delete [] fLocalEventCounterChain[ii];
439 delete [] fChainBunchID[ii];
441 delete fCableLengthMap;
446 //_____________________________________________________________________________
448 void AliTOFRawStream::LoadRawData(Int_t indexDDL)
454 fTOFrawData->Clear();
456 TClonesArray &arrayTofRawData = *fTOFrawData;
460 // create raw data map
461 AliTOFRawMap *rawMap = new AliTOFRawMap(fTOFrawData);
464 Int_t slot[4] = {-1, -1, -1, -1};
466 fLocalEventCounterDRM = -1;
467 fLocalEventCounterLTM = -1;
468 for (Int_t ii=0; ii<13; ii++)
469 fLocalEventCounterTRM[ii] = -1;
470 for (Int_t ii=0; ii<13; ii++)
471 for (Int_t jj=0; jj<2; jj++)
472 fLocalEventCounterChain[ii][jj] = -1;
475 fRawReader->Select("TOF", indexDDL, indexDDL);
477 Bool_t signal = kFALSE;
479 AliTOFrawData *rawDigit = NULL;
483 signal = (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1);
485 AliDebug(2,Form(" %2i %1i %2i %1i %2i", fSector, fPlate, fStrip, fPadZ, fPadX));
490 slot[3] = fTDCchannel;
492 if (rawMap->TestHit(slot) != kEmpty) {
494 rawDigit = static_cast<AliTOFrawData*>(rawMap->GetHit(slot));
496 if (rawDigit->GetLeading()!=-1 && rawDigit->GetTrailing()==-1 &&
497 fLeadingEdge==-1 && fTrailingEdge!=-1) {
499 rawDigit->Update(fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
501 else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) &&
502 (fLeadingEdge!=-1 || fTrailingEdge!=-1 || fTime!=-1) )
507 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
509 rawMap->SetHit(slot);
517 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
519 rawMap->SetHit(slot);
521 } // else if (rawMap->TestHit(slot) == kEmpty)
525 } // closed -> while (Next())
531 //_____________________________________________________________________________
532 Bool_t AliTOFRawStream::Next()
535 // Read next 32-bit word in TOF raw data files
536 // returns kFALSE if there is no word left
543 if (!fRawReader->ReadNextInt(data)) return kFALSE;
545 if (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1) {
557 fDDL = fRawReader->GetDDLID();
559 fWordType = GetField(data,WORD_TYPE_MASK,WORD_TYPE_POSITION);
561 switch (fWordType) { // switch word type
563 case GLOBAL_HEADER_TYPE: // global header
564 fSlotID = GetField(data, HEADER_SLOT_ID_MASK, HEADER_SLOT_ID_POSITION);
568 switch (fSlotID) { // switch global header slot ID
570 case DRM_ID_NUMBER: //DRM global header
571 if (fInsideDRM) { // unexpected DRM global headers -> exit
574 fInsideDRM = kTRUE; // DRM global header accepted
577 case LTM_ID_NUMBER: // LTM global header
578 if (fInsideLTM) { // unexpected LTM global headers -> exit
581 fInsideLTM = kTRUE; // LTM global header accepted
591 case 10: //TRM header
592 case 11: //TRM header
593 case 12: //TRM header
594 if (fInsideTRM) { // unexpected TRM global headers -> exit
597 fInsideTRM = kTRUE; // TRM global header accepted
598 fACQ = GetField(data,TRM_ACQ_BITS_MASK,TRM_ACQ_BITS_POSITION);
601 default: // unexpected global header slot ID
604 } //end switch global header slot id
609 case GLOBAL_TRAILER_TYPE: // global trailer
610 fSlotID = GetField(data,HEADER_SLOT_ID_MASK,HEADER_SLOT_ID_POSITION);
612 switch (fSlotID) { // switch global trailer slot ID
614 case DRM_ID_NUMBER: // DRM global trailer
615 if (!fInsideDRM) { // unexpected DRM global trailers -> exit
619 //AliInfo(Form(" DRM local event counter = %i", GetField(data,dummy,4)));
620 fLocalEventCounterDRM = GetField(data,dummy,4);
621 fInsideDRM = kFALSE; // DRM global trailer accepted
624 fInsideTRMchain0 = kFALSE;
625 fInsideTRMchain1 = kFALSE;
645 case LTM_ID_NUMBER: // LTM global trailer
646 if (!fInsideLTM) { // unexpected LTM global trailer -> exit
650 //AliInfo(Form(" LTM local event counter = %i", GetField(data,dummy,16)));
651 fLocalEventCounterLTM = GetField(data,dummy,16);
652 fInsideLTM = kFALSE; // LTM global trailer accepted
654 case 15: //TRM global trailer
655 if (!fInsideTRM) { // unexpected TRM global trailers -> exit
659 //AliInfo(Form(" TRM local event counter = %i", GetField(data,dummy,16)));
660 fLocalEventCounterTRM[fTRM] = GetField(data,dummy,16);
661 fInsideTRM = kFALSE; // TRM global trailer accepted
663 default: // unexpected global trailer slot ID
665 } //end switch global trailer slot id
671 case ERROR_TYPE: // TDC error
672 fTDC = GetField(data,TRM_TDC_ERROR_TDC_ID_MASK,TRM_TDC_ERROR_TDC_ID_POSITION);
673 fTDCerrorFlag = GetField(data,TRM_TDC_ERROR_FLAGS_MASK,TRM_TDC_ERROR_FLAGS_POSITION);
677 case FILLER_TYPE: // filler
681 default: // other word types
683 if (fInsideTRM) { // inside TRM
685 switch (fWordType) { // switch word type inside TRM
686 case TRM_CHAIN0_HEADER_TYPE: // TRM chain0 header
687 if (fInsideTRMchain0) { // unexpected TRM chain0 header
690 fInsideTRMchain0 = kTRUE;
693 //AliInfo(Form(" chain bunch ID = %i", GetField(data,dummy,4)));
694 fChainBunchID[fTRM][fTRMchain] = GetField(data,dummy,4);
696 case TRM_CHAIN0_TRAILER_TYPE: // TRM chain0 trailer
697 if (!fInsideTRMchain0) { // unexpected TRM chain0 trailer
701 //AliInfo(Form(" chain local event counter = %i", GetField(data,dummy,16)));
702 fLocalEventCounterChain[fTRM][fTRMchain] = GetField(data,dummy,16);
703 fInsideTRMchain0 = kFALSE;
706 case TRM_CHAIN1_HEADER_TYPE: // TRM chain1 header
707 if (fInsideTRMchain1) { // unexpected TRM chain1 header
710 fInsideTRMchain1 = kTRUE;
713 //AliInfo(Form(" chain bunch ID = %i", GetField(data,dummy,4)));
714 fChainBunchID[fTRM][fTRMchain] = GetField(data,dummy,4);
716 case TRM_CHAIN1_TRAILER_TYPE: // TRM chain1 trailer
717 if (!fInsideTRMchain1) { // unexpected TRM chain1 trailer
721 //AliInfo(Form(" chain local event counter = %i", GetField(data,dummy,16)));
722 fLocalEventCounterChain[fTRM][fTRMchain] = GetField(data,dummy,16);
723 fInsideTRMchain1 = kFALSE;
726 } // end switch word type inside TRM
728 } // end if (fInsideTRM)
732 ((fInsideTRMchain0&&!fInsideTRMchain1) || (!fInsideTRMchain0&&fInsideTRMchain1))
733 && fWordType!=TRM_CHAIN0_HEADER_TYPE && fWordType!=TRM_CHAIN0_TRAILER_TYPE
734 && fWordType!=TRM_CHAIN1_HEADER_TYPE && fWordType!=TRM_CHAIN1_TRAILER_TYPE
735 ){ // inside TRM chains
737 fPSbit = GetField(data,TRM_PS_BITS_MASK,TRM_PS_BITS_POSITION);
738 fTDC = GetField(data,TRM_TDC_ID_MASK,TRM_TDC_ID_POSITION);
739 fTDCchannel = GetField(data,TRM_CHAN_MASK,TRM_CHAN_POSITION);
740 fErrorFlag = GetField(data,TRM_E_BIT_MASK,TRM_E_BIT_POSITION);
749 switch (fPSbit) { // switch fPSbit bits inside TRM chains
751 case 0: // packing ok, digit time and TOT
752 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
753 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION)
755 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
757 if (fgApplyBCCorrections) {
758 AliDebug(2,"Apply nominal DDL BC time-shift correction");
759 AliDebug(2,"Apply deltaBC time-shift correction");
760 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
762 (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03)
764 (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03);
768 case 1: // leading edge digit, long digit time, no TOT
771 fLeadingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION)
773 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
775 if (fgApplyBCCorrections) {
776 AliDebug(2,"Apply nominal DDL BC time-shift correction");
777 AliDebug(2,"Apply deltaBC time-shift correction");
778 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
780 (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03)
782 (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03);
786 case 2: // trailing edge digit, long digit time, no TOT
789 fTrailingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION)
791 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
793 if (fgApplyBCCorrections) {
794 AliDebug(2,"Apply nominal DDL BC time-shift correction");
795 AliDebug(2,"Apply deltaBC time-shift correction");
796 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
798 (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03)
800 (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03);
804 case 3: // TOT overflow
805 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
806 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION)
808 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
810 if (fgApplyBCCorrections) {
811 AliDebug(2,"Apply nominal DDL BC time-shift correction");
812 AliDebug(2,"Apply deltaBC time-shift correction");
813 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
815 (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03)
817 (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03);
821 } // end switch PS bits inside TRM chains
823 } // end if is inside TRM chains
825 } // end switch on fWordType
831 //_____________________________________________________________________________
833 void AliTOFRawStream::SetSector()
836 // Evaluate the TOF sector number -> [ 0;17]
837 // corresponding to the TOF equipment IDs:
840 // fTRMchain -> [ 0; 1]
842 // fTDCchannel -> [ 0; 7]
847 if (!(fDDL==-1)) iSector = Int_t((Float_t)(fDDL)/AliTOFGeometry::NDDL());
852 //_____________________________________________________________________________
855 void AliTOFRawStream::SetPlate()
858 // Evaluate the TOF plate number ->[ 0; 4]
859 // corresponding to the TOF equipment IDs:
862 // fTRMchain -> [ 0; 1]
864 // fTDCchannel -> [ 0; 7]
868 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
870 iPlate = Equip2VolNplate(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
875 //_____________________________________________________________________________
877 void AliTOFRawStream::SetStrip()
880 // Evaluate the TOF strip number per module -> [ 0; 14/18]
881 // corresponding to the TOF equipment IDs:
884 // fTRMchain -> [ 0; 1]
886 // fTDCchannel -> [ 0; 7]
891 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
892 || fSector==-1 || fPlate==-1))
893 iStrip = Equip2VolNstrip(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
898 //_____________________________________________________________________________
900 void AliTOFRawStream::SetPadZ()
903 // Evaluate the TOF padRow number per strip -> [ 0; 1]
904 // corresponding to the TOF equipment IDs:
907 // fTRMchain -> [ 0; 1]
909 // fTDCchannel -> [ 0; 7]
914 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
915 || fSector==-1 || fPlate==-1 || fStrip==-1))
917 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
918 if (iPadAlongTheStrip!=-1)
919 iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
922 //iPadZ = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)%AliTOFGeometry::NpadZ();
923 //iPadZ = Equip2VolNpadZ(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
928 //_____________________________________________________________________________
930 void AliTOFRawStream::SetPadX()
933 // Evaluate the TOF pad number per strip padRow -> [ 0;47]
934 // corresponding to the TOF equipment IDs:
937 // fTRMchain -> [ 0; 1]
939 // fTDCchannel -> [ 0; 7]
944 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
945 || fSector==-1 || fPlate==-1 || fStrip==-1))
947 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
948 if (iPadAlongTheStrip!=-1)
949 iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
952 //iPadX = (Int_t)(Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)/(Float_t(AliTOFGeometry::NpadZ())));
953 //iPadX = Equip2VolNpadX(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
959 //----------------------------------------------------------------------------
960 Int_t AliTOFRawStream::GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const
966 return ((word & fieldMask) >> fieldPosition);
969 //----------------------------------------------------------------------------
970 Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC)
973 // Returns the TOF plate number [0;4]
974 // corresponding to the TOF equipment ID numbers:
975 // iDDL -> DDL number per sector [0;3]
976 // nTRM -> TRM number [3;12]
977 // nTDC -> TDC number [0;14]
984 if (nTRM>=4 && nTRM<7) {
986 } else if (nTRM==7) {
987 if (nTDC<12) iPlate = 0;
989 } else if (nTRM>=8 && nTRM<11) {
991 } else if (nTRM==11) {
992 if (nTDC<9) iPlate = 1;
994 }else if (nTRM==12) {
998 } else if (iDDL==1) {
1001 if (nTDC<3) iPlate = 0;
1002 } else if (nTRM>=4 && nTRM<7) {
1004 } else if (nTRM==7) {
1005 if (nTDC<6) iPlate = 1;
1007 } else if (nTRM>=8 && nTRM<11) {
1009 } else if (nTRM==11) {
1010 if (nTDC<9) iPlate = 2;
1012 } else if (nTRM==12) {
1016 } else if (iDDL==2) {
1018 if (nTRM>=4 && nTRM<7) {
1020 } else if (nTRM==7) {
1021 if (nTDC<12) iPlate = 4;
1023 } else if (nTRM>=8 && nTRM<11) {
1025 } else if (nTRM==11) {
1026 if (nTDC<9) iPlate = 3;
1028 }else if (nTRM==12) {
1032 } else if (iDDL==3) {
1035 if (nTDC<3) iPlate = 4;
1036 } else if (nTRM>=4 && nTRM<7) {
1038 } else if (nTRM==7) {
1039 if (nTDC<6) iPlate = 3;
1041 } else if (nTRM>=8 && nTRM<11) {
1043 } else if (nTRM==11) {
1044 if (nTDC<9) iPlate = 2;
1046 } else if (nTRM==12) {
1056 //----------------------------------------------------------------------------
1057 Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC)
1060 // Returns the TOF strip number per module:
1061 // [0;14], in the central plates,
1062 // [0;18], in the intermediate and external plates
1063 // corresponding to the TOF equipment ID numbers:
1064 // iDDL -> DDL number per sector [0;3]
1065 // nTRM -> TRM number [3;12]
1066 // nTDC -> TDC number [0;14]
1073 if (nTRM== 4) iStrip = (Int_t)(nTDC/3.);
1074 else if (nTRM== 5) iStrip = 5 + (Int_t)(nTDC/3.);
1075 else if (nTRM== 6) iStrip = 10 + (Int_t)(nTDC/3.);
1076 else if (nTRM== 7) {
1077 if (nTDC<12) iStrip = 15 + (Int_t)(nTDC/3.);
1078 else iStrip = (Int_t)(nTDC/3.) - 4;
1080 else if (nTRM== 8) iStrip = 1 + (Int_t)(nTDC/3.);
1081 else if (nTRM== 9) iStrip = 6 + (Int_t)(nTDC/3.);
1082 else if (nTRM==10) iStrip = 11 + (Int_t)(nTDC/3.);
1083 else if (nTRM==11) {
1084 if (nTDC<9) iStrip = 16 + (Int_t)(nTDC/3.);
1085 else iStrip = (Int_t)(nTDC/3.) - 3;
1087 else if (nTRM==12) iStrip = 2 + (Int_t)(nTDC/3.);
1089 } else if (iDDL==1) {
1091 if (nTRM==3 && nTDC<3) iStrip = (Int_t)(nTDC/3.);
1092 else if (nTRM== 4) iStrip = 5 - (Int_t)(nTDC/3.);
1093 else if (nTRM== 5) iStrip = 10 - (Int_t)(nTDC/3.);
1094 else if (nTRM== 6) iStrip = 15 - (Int_t)(nTDC/3.);
1095 else if (nTRM== 7) {
1096 if (nTDC<6) iStrip = 1 - (Int_t)(nTDC/3.);
1097 else iStrip = 20 - (Int_t)(nTDC/3.);
1099 else if (nTRM== 8) iStrip = 6 - (Int_t)(nTDC/3.);
1100 else if (nTRM== 9) iStrip = 11 - (Int_t)(nTDC/3.);
1101 else if (nTRM==10) iStrip = 16 - (Int_t)(nTDC/3.);
1102 else if (nTRM==11) {
1103 if (nTDC<9) iStrip = 2 - (Int_t)(nTDC/3.);
1104 else iStrip = 21 - (Int_t)(nTDC/3.);
1106 else if (nTRM==12) iStrip = 7 - (Int_t)(nTDC/3.);
1108 } else if (iDDL==2) {
1110 if (nTRM== 4) iStrip = 18 - (Int_t)(nTDC/3.);
1111 else if (nTRM== 5) iStrip = 18 - ( 5 + (Int_t)(nTDC/3.));
1112 else if (nTRM== 6) iStrip = 18 - (10 + (Int_t)(nTDC/3.));
1113 else if (nTRM== 7) {
1114 if (nTDC<12) iStrip = 18 - (15 + (Int_t)(nTDC/3.));
1115 else iStrip = 18 - ((Int_t)(nTDC/3.) - 4);
1117 else if (nTRM== 8) iStrip = 18 - ( 1 + (Int_t)(nTDC/3.));
1118 else if (nTRM== 9) iStrip = 18 - ( 6 + (Int_t)(nTDC/3.));
1119 else if (nTRM==10) iStrip = 18 - (11 + (Int_t)(nTDC/3.));
1120 else if (nTRM==11) {
1121 if (nTDC<9) iStrip = 18 - (16 + (Int_t)(nTDC/3.));
1122 else iStrip = 14 - ((Int_t)(nTDC/3.) - 3);
1124 else if (nTRM==12) iStrip = 14 - ( 2 + (Int_t)(nTDC/3.));
1126 } else if (iDDL==3) {
1128 if (nTRM==3 && nTDC<3) iStrip = 18 - (Int_t)(nTDC/3.);
1129 else if (nTRM== 4) iStrip = 18 - ( 5 - (Int_t)(nTDC/3.));
1130 else if (nTRM== 5) iStrip = 18 - (10 - (Int_t)(nTDC/3.));
1131 else if (nTRM== 6) iStrip = 18 - (15 - (Int_t)(nTDC/3.));
1132 else if (nTRM== 7) {
1133 if (nTDC<6) iStrip = 18 - (1 - (Int_t)(nTDC/3.));
1134 else iStrip = 18 - (20 - (Int_t)(nTDC/3.));
1136 else if (nTRM== 8) iStrip = 18 - ( 6 - (Int_t)(nTDC/3.));
1137 else if (nTRM== 9) iStrip = 18 - (11 - (Int_t)(nTDC/3.));
1138 else if (nTRM==10) iStrip = 18 - (16 - (Int_t)(nTDC/3.));
1139 else if (nTRM==11) {
1140 if (nTDC<9) iStrip = 14 - ( 2 - (Int_t)(nTDC/3.));
1141 else iStrip = 18 - (21 - (Int_t)(nTDC/3.));
1143 else if (nTRM==12) iStrip = 14 - ( 7 - (Int_t)(nTDC/3.));
1151 //----------------------------------------------------------------------------
1152 Int_t AliTOFRawStream::Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC,
1156 // Returns the TOF pad number per strip [0;95]
1157 // corresponding to the TOF equipment ID numbers:
1158 // iDDL -> DDL number per sector [0;3]
1159 // iChain -> TRM chain number [0;1]
1160 // nTDC -> TDC number [0;14]
1161 // iCH -> TDC channel number [0;7]
1164 Int_t iPadAlongTheStrip = -1;
1167 //Int_t iTDClocal = nTDC%3 + (1-iChain)*3;
1168 //if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal;
1169 //else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal);
1172 Int_t iTDClocal = -1;
1173 Int_t iTDClocal03 = nTDC%3 + (1-iChain)*3;
1174 Int_t iTDClocal12 = 2-nTDC%3 + iChain*3;
1175 if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal03;
1176 else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal12);
1178 Int_t iCHlocal = iCH;
1179 if (iDDL==0 || iDDL==3) iCHlocal = 7 - iCH;
1181 iPadAlongTheStrip = iTDClocal*AliTOFGeometry::NCh() + iCHlocal;
1183 if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) ||
1184 ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX())) {
1185 std::cerr << "Problems with the padX number!" << endl;
1186 //AliWarning("Problems with the padX number!");
1188 return iPadAlongTheStrip;
1192 //----------------------------------------------------------------------------
1193 Int_t AliTOFRawStream::Equip2VolNpadX(Int_t iDDL, Int_t iChain, Int_t nTDC,
1197 // Returns the TOF padX number [0;47]
1198 // corresponding to the TOF equipment ID numbers:
1199 // iDDL -> DDL number per sector [0;3]
1200 // iChain -> TRM chain number [0;1]
1201 // nTDC -> TDC number [0;14]
1202 // iCH -> TDC channel number [0;7]
1205 Int_t iPadX = (Int_t)(AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)/
1206 (Float_t(AliTOFGeometry::NpadZ())));
1212 //----------------------------------------------------------------------------
1213 Int_t AliTOFRawStream::Equip2VolNpadZ(Int_t iDDL, Int_t iChain, Int_t nTDC,
1217 // Returns the TOF padZ number [0;1]
1218 // corresponding to the TOF equipment ID numbers:
1219 // iDDL -> DDL number per sector [0;3]
1220 // iChain -> TRM chain number [0;1]
1221 // nTDC -> TDC number [0;14]
1222 // iCH -> TDC channel number [0;7]
1225 Int_t iPadZ = AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1231 //----------------------------------------------------------------------------
1232 Int_t AliTOFRawStream::GetSectorNumber(Int_t nDDL)
1235 // Returns the sector number [0;17]
1236 // corresponing to the assigned DRM/DDL number [0;71]
1239 Int_t iSector = Int_t((Float_t)(nDDL)/AliTOFGeometry::NDDL());
1244 //----------------------------------------------------------------------------
1245 Int_t AliTOFRawStream::GetDDLnumberPerSector(Int_t nDDL)
1248 // Return the DRM/DDL number per sector [0;3]
1249 // corresponing to the assigned DRM/DDL number [0;71]
1252 Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
1258 //----------------------------------------------------------------------------
1259 void AliTOFRawStream::EquipmentId2VolumeId(AliTOFHitData *hitData, Int_t *volume) const
1261 EquipmentId2VolumeId(hitData->GetDDLID(),hitData->GetSlotID(),hitData->GetChain(),hitData->GetTDC(),hitData->GetChan(),volume);
1263 //----------------------------------------------------------------------------
1264 void AliTOFRawStream::EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
1265 Int_t nTDC, Int_t iCH,
1266 Int_t *volume) const
1270 // nDDL (variable in [0;71]) -> number of the DDL file
1271 // nTRM (variable in [3;12]) -> number of the TRM slot
1272 // iChain (variable in [0; 1]) -> number of the TRM chain
1273 // nTDC (variable in [0;14]) -> number of the TDC
1274 // iCH (variable in [0; 7]) -> number of the TDC channel
1277 // sector number, i.e. volume[0] (variable in [0,17])
1278 // plate number, i.e. volume[1] (variable in [0, 5])
1279 // strip number, i.e. volume[2] (variable in [0,14/18])
1280 // padX number, i.e. volume[3] (variable in [0,47])
1281 // padZ number, i.e. volume[4] (variable in [0, 1])
1284 Int_t iDDL = GetDDLnumberPerSector(nDDL);
1286 Int_t iSector = GetSectorNumber(nDDL);
1288 Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
1291 fRawReader->AddMajorErrorLog(kPlateError,"plate = -1");
1292 AliWarning("Problems with the plate number!");
1295 Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
1298 fRawReader->AddMajorErrorLog(kStripError,"strip = -1");
1299 AliWarning("Problems with the strip number!");
1302 Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
1303 if (iPadAlongTheStrip==-1){
1305 fRawReader->AddMajorErrorLog(kPadAlongStripError,"pad = -1");
1306 AliWarning("Problems with the pad number along the strip!");
1309 Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1310 Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
1312 //Int_t iPadX = (Int_t)(Equip2VolNpad(iDDL, iChain, nTDC, iCH)/(Float_t(AliTOFGeometry::NpadZ())));
1313 //Int_t iPadZ = Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1315 //Int_t iPadX = Equip2VolNpadX(iDDL, iChain, nTDC, iCH);
1316 //Int_t iPadZ = Equip2VolNpadZ(iDDL, iChain, nTDC, iCH);
1318 volume[0] = iSector;
1325 //-----------------------------------------------------------------------------
1326 Bool_t AliTOFRawStream::DecodeDDL(Int_t nDDLMin, Int_t nDDLMax, Int_t verbose = 0) {
1328 // To decode raw data for DDL number in [nDDLmin; nDDLmax]
1331 //check and fix valid DDL range
1334 fRawReader->AddMinorErrorLog(kDDLMinError);
1335 AliWarning("Wrong DDL range: setting first DDL ID to 0");
1339 fRawReader->AddMinorErrorLog(kDDLMaxError);
1340 AliWarning("Wrong DDL range: setting last DDL ID to 71");
1343 //select required DDLs
1344 fRawReader->Select("TOF", nDDLMin, nDDLMax);
1347 AliInfo(Form("Selected TOF DDL range: %d-%d", nDDLMin, nDDLMax));
1349 return(Decode(verbose));
1351 //-----------------------------------------------------------------------------
1352 Bool_t AliTOFRawStream::Decode(Int_t verbose = 0) {
1354 // New decoder method
1357 Int_t currentEquipment;
1359 const AliRawDataHeader *currentCDH;
1362 UChar_t *data = 0x0;
1364 //loop and read DDL headers
1365 while(fRawReader->ReadHeader()){
1367 //memory leak prevention (actually data should be always 0x0 here)
1371 //get equipment infos
1372 currentEquipment = fRawReader->GetEquipmentId();
1373 currentDDL = fRawReader->GetDDLID();
1374 currentCDH = fRawReader->GetDataHeader();
1375 const Int_t kDataSize = fRawReader->GetDataSize();
1376 const Int_t kDataWords = kDataSize / 4;
1377 data = new UChar_t[kDataSize];
1380 AliInfo(Form("Found equipment # %d header (DDL # %d): %d bytes (%d words)", currentEquipment, currentDDL, kDataSize, kDataWords));
1383 AliInfo(Form("Reading equipment #%d (DDL # %d) data...", currentEquipment, currentDDL));
1385 //read equipment payload
1386 if (!fRawReader->ReadNext(data, kDataSize))
1388 fRawReader->AddMajorErrorLog(kDDLdataReading);
1390 AliWarning("Error while reading DDL data. Go to next equipment");
1397 AliInfo(Form("Equipment # %d (DDL # %d) data has been readed", currentEquipment, currentDDL));
1400 //set up the decoder
1401 fDecoder->SetVerbose(verbose);
1402 fDecoder->SetDataBuffer(&fDataBuffer[currentDDL]);
1403 fDecoder->SetPackedDataBuffer(&fPackedDataBuffer[currentDDL]);
1406 if (fDecoder->Decode((UInt_t *)data, kDataWords, currentCDH) == kTRUE) {
1407 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",currentDDL));
1408 AliWarning(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL));
1416 fRawReader->Reset();
1419 AliInfo("All done");
1424 //---------------------------------------------------------------------------
1426 AliTOFRawStream::ResetBuffers()
1429 // To reset the buffers
1432 for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls("TOF"); iDDL++){
1433 ResetDataBuffer(iDDL);
1434 ResetPackedDataBuffer(iDDL);
1438 //---------------------------------------------------------------------------
1440 AliTOFRawStream::LoadRawDataBuffers(Int_t indexDDL, Int_t verbose)
1443 // To load the buffers
1446 fTOFrawData->Clear();
1450 AliInfo(Form("Decoding raw data for DDL # %d ...", indexDDL));
1452 if (DecodeDDL(indexDDL, indexDDL, verbose) != 0){ //decode DDL
1453 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",indexDDL));
1454 AliWarning(Form("Error while decoding DDL # %d", indexDDL));
1459 AliInfo(Form("Done. %d packed %s been found.", fPackedDataBuffer[indexDDL].GetEntries(), fPackedDataBuffer[indexDDL].GetEntries() > 1 ? "hits have" : "hit has"));
1461 AliTOFHitData *hitData; //hit data pointer
1464 AliInfo("Filling TClonesArray ...");
1467 if (fgApplyBCCorrections) {
1468 AliInfo("Apply nominal DDL BC time-shift correction");
1469 AliInfo("Apply deltaBC time-shift correction");
1472 //loop over DDL packed hits
1473 for (Int_t iHit = 0; iHit < fPackedDataBuffer[indexDDL].GetEntries(); iHit++){
1474 hitData = fPackedDataBuffer[indexDDL].GetHit(iHit); //get hit data
1475 Int_t hitACQ = hitData->GetACQ();
1476 Int_t hitPS = hitData->GetPS();
1477 Int_t hitSlotID = hitData->GetSlotID();
1478 Int_t hitChain = hitData->GetChain();
1479 Int_t hitTDC = hitData->GetTDC();
1480 Int_t hitChan = hitData->GetChan();
1481 Int_t hitTimeBin = hitData->GetTimeBin();
1482 Int_t hitTOTBin = hitData->GetTOTBin();
1484 if (fgApplyBCCorrections) {
1485 /* DDL BC shift time correction */
1486 hitTimeBin += fgkddlBCshift[indexDDL];
1487 /* deltaBC shift time correction */
1488 hitTimeBin += hitData->GetDeltaBunchID();
1491 Int_t hitLeading = hitData->GetTimeBin();
1492 Int_t hitTrailing = -1;
1493 Int_t hitError = -1;
1495 TClonesArray &arrayTofRawData = *fTOFrawData;
1496 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(hitSlotID, hitChain, hitTDC, hitChan, hitTimeBin, hitTOTBin, hitLeading, hitTrailing, hitPS, hitACQ, hitError);
1503 AliInfo("Resetting buffers ...");
1505 fDataBuffer[indexDDL].Reset();
1506 fPackedDataBuffer[indexDDL].Reset();
1514 //---------------------------------------------------------------------------
1515 void AliTOFRawStream::Geant2EquipmentId(Int_t vol[], Int_t eqId[])
1519 // nSector number -vol[0]- (variable in [0,17])
1520 // nPlate number -vol[1]- (variable in [0, 5])
1521 // nStrip number -vol[2]- (variable in [0,14/18])
1522 // nPadZ number -vol[3]- (variable in [0, 1])
1523 // nPadX number -vol[4]- (variable in [0,47])
1525 // nDDL -eqId[0]- (variable in [0;71]) -> number of the DDL file
1526 // nTRM -eqId[1]- (variable in [3;12]) -> number of the TRM file
1527 // nTDC -eqId[2]- (variable in [0;14]) -> number of the TDC file
1528 // nChain -eqId[3]- (variable in [0; 1]) -> number of the chain file
1529 // nChannel -eqId[4]- (variable in [0; 8]) -> number of the channel file
1532 eqId[0] = Geant2DDL(vol);
1533 eqId[1] = Geant2TRM(vol);
1534 eqId[2] = Geant2TDC(vol);
1535 eqId[3] = Geant2Chain(vol);
1536 eqId[4] = Geant2Channel(vol);
1540 //---------------------------------------------------------------------------
1541 Int_t AliTOFRawStream::Geant2DDL(Int_t vol[])
1545 // nSector number -vol[0]- (variable in [0,17])
1546 // nPlate number -vol[1]- (variable in [0, 5])
1547 // nStrip number -vol[2]- (variable in [0,14/18])
1548 // nPadZ number -vol[3]- (variable in [0, 1])
1549 // nPadX number -vol[4]- (variable in [0,47])
1551 // nDDL (variable in [0;71]) -> number of the DDL file
1557 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1558 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1561 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1562 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1565 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1566 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1569 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1570 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1571 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1572 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1573 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1574 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1578 Int_t nSector = vol[0];
1579 Int_t nPlate = vol[1];
1580 Int_t nStrip = vol[2];
1581 Int_t nPadX = vol[4];
1583 if ( nPadX<24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<7) ) )
1585 else if ( nPadX>=24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<8) ) )
1587 else if ( nPadX>=24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>7) ) )
1589 else if ( nPadX<24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>6) ) )
1592 return 4*nSector+iDDL;
1596 //---------------------------------------------------------------------------
1597 Int_t AliTOFRawStream::Geant2TRM(Int_t vol[])
1601 // nSector number -vol[0]- (variable in [0,17])
1602 // nPlate number -vol[1]- (variable in [0, 5])
1603 // nStrip number -vol[2]- (variable in [0,14/18])
1604 // nPadZ number -vol[3]- (variable in [0, 1])
1605 // nPadX number -vol[4]- (variable in [0,47])
1607 // nTRM (variable in [3;12]) -> number of the TRM slot
1612 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1613 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1616 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1617 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1620 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1621 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1624 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ()) {
1625 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1628 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX()) {
1629 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1633 if ( vol[3]>=AliTOFGeometry::NpadZ() )
1635 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1639 Int_t nPlate = vol[1];
1640 Int_t nStrip = vol[2];
1642 Int_t iDDL = Geant2DDL(vol)%4;
1649 if (nStrip<= 4) nTRM = 4;
1650 else if (nStrip> 4 && nStrip<= 9) nTRM = 5;
1651 else if (nStrip> 9 && nStrip<=14) nTRM = 6;
1652 else if (nStrip>14) nTRM = 7;
1654 else if (nPlate==1) {
1655 if (nStrip== 0) nTRM = 7;
1656 else if (nStrip> 0 && nStrip<= 5) nTRM = 8;
1657 else if (nStrip> 5 && nStrip<=10) nTRM = 9;
1658 else if (nStrip>10 && nStrip<=15) nTRM = 10;
1659 else if (nStrip>15) nTRM = 11;
1661 else if (nPlate==2) {
1662 if (nStrip<= 1) nTRM = 11;
1663 else if (nStrip> 1 && nStrip< 7) nTRM = 12;
1670 if (nStrip== 0) nTRM = 3;
1671 else if (nStrip> 0 && nStrip<= 5) nTRM = 4;
1672 else if (nStrip> 5 && nStrip<=10) nTRM = 5;
1673 else if (nStrip>10 && nStrip<=15) nTRM = 6;
1674 else if (nStrip>15) nTRM = 7;
1676 else if (nPlate==1) {
1677 if (nStrip<=1) nTRM = 7;
1678 else if (nStrip> 1 && nStrip<= 6) nTRM = 8;
1679 else if (nStrip> 6 && nStrip<=11) nTRM = 9;
1680 else if (nStrip>11 && nStrip<=16) nTRM = 10;
1681 else if (nStrip>16) nTRM = 11;
1683 else if (nPlate==2) {
1684 if (nStrip<= 2) nTRM = 11;
1685 else if (nStrip> 2 && nStrip<= 7) nTRM = 12;
1692 if (nStrip>=14) nTRM = 4;
1693 else if (nStrip<14 && nStrip>= 9) nTRM = 5;
1694 else if (nStrip< 9 && nStrip>= 4) nTRM = 6;
1695 else if (nStrip< 4) nTRM = 7;
1697 else if (nPlate==3) {
1698 if (nStrip==18) nTRM = 7;
1699 else if (nStrip<18 && nStrip>=13) nTRM = 8;
1700 else if (nStrip<13 && nStrip>= 8) nTRM = 9;
1701 else if (nStrip< 8 && nStrip>= 3) nTRM = 10;
1702 else if (nStrip< 3) nTRM = 11;
1704 else if (nPlate==2) {
1705 if (nStrip>=13) nTRM = 11;
1706 else if (nStrip<13 && nStrip>= 8) nTRM = 12;
1713 if (nStrip==18) nTRM = 3;
1714 else if (nStrip<18 && nStrip>=13) nTRM = 4;
1715 else if (nStrip<13 && nStrip>= 8) nTRM = 5;
1716 else if (nStrip< 8 && nStrip>= 3) nTRM = 6;
1717 else if (nStrip< 3) nTRM = 7;
1719 else if (nPlate==3) {
1720 if (nStrip>=17) nTRM = 7;
1721 else if (nStrip<17 && nStrip>=12) nTRM = 8;
1722 else if (nStrip<12 && nStrip>= 7) nTRM = 9;
1723 else if (nStrip< 7 && nStrip>= 2) nTRM = 10;
1724 else if (nStrip< 2) nTRM = 11;
1726 else if (nPlate==2) {
1727 if (nStrip>=12) nTRM = 11;
1728 else if (nStrip <12 && nStrip>= 7) nTRM = 12;
1739 //---------------------------------------------------------------------------
1740 Int_t AliTOFRawStream::Geant2TDC(Int_t vol[])
1744 // nSector number -vol[0]- (variable in [0,17])
1745 // nPlate number -vol[1]- (variable in [0, 5])
1746 // nStrip number -vol[2]- (variable in [0,14/18])
1747 // nPadZ number -vol[3]- (variable in [0, 1])
1748 // nPadX number -vol[4]- (variable in [0,47])
1750 // nTDC (variable in [0;14]) -> number of the TDC
1755 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1756 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1759 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1760 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1763 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1764 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1767 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1768 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1769 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1770 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1771 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1772 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1776 Int_t nPlate = vol[1];
1777 Int_t nStrip = vol[2];
1778 Int_t iPadX = vol[4];
1780 Int_t iDDL = Geant2DDL(vol)%4;
1787 if (nStrip<= 4) nTDC = (3*(nStrip)+2-(iPadX/4)%3);
1788 else if (nStrip> 4 && nStrip<= 9) nTDC = (3*(nStrip- 5)+2-(iPadX/4)%3);
1789 else if (nStrip> 9 && nStrip<=14) nTDC = (3*(nStrip-10)+2-(iPadX/4)%3);
1790 else if (nStrip>14) nTDC = (3*(nStrip-15)+2-(iPadX/4)%3);
1792 else if (nPlate==1) {
1793 if (nStrip== 0) nTDC = (3*(nStrip+ 4)+2-(iPadX/4)%3);
1794 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*(nStrip- 1)+2-(iPadX/4)%3);
1795 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(nStrip- 6)+2-(iPadX/4)%3);
1796 else if (nStrip>10 && nStrip<=15) nTDC = (3*(nStrip-11)+2-(iPadX/4)%3);
1797 else if (nStrip>15) nTDC = (3*(nStrip-16)+2-(iPadX/4)%3);
1799 else if (nPlate==2) {
1800 if (nStrip<= 1) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
1801 else if (nStrip> 1 && nStrip< 7) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
1808 if (nStrip== 0) nTDC = (3*(nStrip)+(iPadX/4)%3);
1809 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*( 5-nStrip)+(iPadX/4)%3);
1810 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(10-nStrip)+(iPadX/4)%3);
1811 else if (nStrip>10 && nStrip<=15) nTDC = (3*(15-nStrip)+(iPadX/4)%3);
1812 else if (nStrip>15) nTDC = (3*(20-nStrip)+(iPadX/4)%3);
1814 else if (nPlate==1) {
1815 if (nStrip<= 1) nTDC = (3*( 1-nStrip)+(iPadX/4)%3);
1816 else if (nStrip> 1 && nStrip<= 6) nTDC = (3*( 6-nStrip)+(iPadX/4)%3);
1817 else if (nStrip> 6 && nStrip<=11) nTDC = (3*(11-nStrip)+(iPadX/4)%3);
1818 else if (nStrip>11 && nStrip<=16) nTDC = (3*(16-nStrip)+(iPadX/4)%3);
1819 else if (nStrip>16) nTDC = (3*(21-nStrip)+(iPadX/4)%3);
1821 else if (nPlate==2) {
1822 if (nStrip<= 2) nTDC = (3*( 2-nStrip)+(iPadX/4)%3);
1823 else if (nStrip> 2 && nStrip<= 7) nTDC = (3*( 7-nStrip)+(iPadX/4)%3);
1830 if (nStrip>=14) nTDC = (3*(18-nStrip)+((iPadX/4)%3));
1831 else if (nStrip<14 && nStrip>= 9) nTDC = (3*(13-nStrip)+((iPadX/4)%3));
1832 else if (nStrip< 9 && nStrip>= 4) nTDC = (3*( 8-nStrip)+((iPadX/4)%3));
1833 else if (nStrip< 4) nTDC = (3*( 3-nStrip)+((iPadX/4)%3));
1835 else if (nPlate==3) {
1836 if (nStrip==18) nTDC = (3*(22-nStrip)+((iPadX/4)%3));
1837 else if (nStrip<18 && nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
1838 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
1839 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*( 7-nStrip)+((iPadX/4)%3));
1840 else if (nStrip< 3) nTDC = (3*( 2-nStrip)+((iPadX/4)%3));
1842 else if (nPlate==2) {
1843 if (nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
1844 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
1851 if (nStrip==18) nTDC = (3*(nStrip-18)+2-(iPadX/4)%3);
1852 else if (nStrip<18 && nStrip>=13) nTDC = (3*(nStrip-13)+2-(iPadX/4)%3);
1853 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(nStrip- 8)+2-(iPadX/4)%3);
1854 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*(nStrip- 3)+2-(iPadX/4)%3);
1855 else if (nStrip< 3) nTDC = (3*(nStrip+ 2)+2-(iPadX/4)%3);
1857 else if (nPlate==3) {
1858 if (nStrip>=17) nTDC = (3*(nStrip-17)+2-(iPadX/4)%3);
1859 else if (nStrip<17 && nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
1860 else if (nStrip<12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
1861 else if (nStrip< 7 && nStrip>= 2) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
1862 else if (nStrip< 2) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
1864 else if (nPlate==2) {
1865 if (nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
1866 else if (nStrip <12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
1877 //---------------------------------------------------------------------------
1878 Int_t AliTOFRawStream::Geant2Chain(Int_t vol[])
1882 // nSector number -vol[0]- (variable in [0,17])
1883 // nPlate number -vol[1]- (variable in [0, 5])
1884 // nStrip number -vol[2]- (variable in [0,14/18])
1885 // nPadZ number -vol[3]- (variable in [0, 1])
1886 // nPadX number -vol[4]- variable in [0,47])
1888 // nChain (variable in [0; 1]) -> number of the TRM chain
1893 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1894 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1897 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1898 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1901 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1902 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1905 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1906 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1907 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1908 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1909 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1910 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1914 Int_t iPadX = vol[4];
1916 if (iPadX<12 || iPadX>=36) nChain = 0;
1923 //---------------------------------------------------------------------------
1924 Int_t AliTOFRawStream::Geant2Channel(Int_t vol[])
1928 // nSector number -vol[0]- (variable in [0,17])
1929 // nPlate number -vol[1]- (variable in [0, 5])
1930 // nStrip number -vol[2]- (variable in [0,14/18])
1931 // nPadZ number -vol[3]- (variable in [0, 1])
1932 // nPadX number -vol[4]- (variable in [0,47])
1934 // nChannel (variable in [0; 7]) -> number of the TDC channel
1937 Int_t nChannel = -1;
1939 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1940 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1943 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1944 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1947 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1948 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1951 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1952 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1953 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1954 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1955 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1956 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1960 Int_t iPadZ = vol[3];
1961 Int_t iPadX = vol[4];
1963 Int_t iDDL = Geant2DDL(vol)%4;
1968 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
1971 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
1974 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
1977 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;