]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFDecoder.cxx
add un-use functionality to clusters
[u/mrichter/AliRoot.git] / TOF / AliTOFDecoder.cxx
index 47fd50ff0c23c172e97c6685ee78f76fb7d5f544..68146d367e608890bb4b26f73cd4187fc4cc2692 100644 (file)
 
 /*
 $Log$
+Revision 1.5  2007/11/24 14:58:34  zampolli
+New Method implemented (#DDL <-> TOF channels)
+
+Revision 1.4  2007/05/18 13:08:57  decaro
+Coding convention: RS1 violation -> suppression
+
+Revision 1.3  2007/05/08 11:56:05  arcelli
+improved verbosity in verbose mode (R.Preghenella)
+
+Revision 1.2  2007/05/03 11:34:43  decaro
+Coding convention: RS1 violation -> suppression
+
+Revision 1.1  2007/04/27 11:00:32  arcelli
+TOF Raw Data decoder
+
   author: Roberto Preghenella (R+), preghenella@bo.infn.it
 */
 
 
-/*********************************************************************
- *                                                                   *
- *                                                                   *
- *   Class for raw data decoding                                     *
- *                                                                   *
- *                                                                   *
- ********************************************************************/
+//////////////////////////////////////////////////////////////////////
+//                                                                  //
+//                                                                  //
+//   Class for raw data decoding                                    //
+//                                                                  //
+//                                                                  //
+//////////////////////////////////////////////////////////////////////
                                
 
 
 #include "AliLog.h"
 #include "AliTOFHitData.h"
+#include "AliTOFHitDataBuffer.h"
 #include "AliTOFDecoder.h"
+#include "AliTOFGeometry.h"
+#include "AliRawDataHeader.h"
+#include "AliTOFRawDataFormat.h"
 
 ClassImp(AliTOFDecoder)
 
@@ -43,15 +62,15 @@ AliTOFDecoder::AliTOFDecoder() :
   fV2718Patch(kFALSE),
   fDataBuffer(0x0),
   fPackedDataBuffer(0x0),
-  fTRMGlobalHeader(0x0),
-  fTRMGlobalTrailer(0x0),
-  fTRMChainHeader(0x0),
-  fTRMChainTrailer(0x0),
-  fTDCPackedHit(0x0),
-  fTDCUnpackedHit(0x0),
-  fTRMTDCError(0x0),
-  fTRMDiagnosticErrorWord1(0x0),
-  fTRMDiagnosticErrorWord2(0x0),
+  //fTRMGlobalHeader(0x0),
+  //fTRMGlobalTrailer(0x0),
+  //fTRMChainHeader(0x0),
+  //fTRMChainTrailer(0x0),
+  //fTDCPackedHit(0x0),
+  //fTDCUnpackedHit(0x0),
+  //fTRMTDCError(0x0),
+  //fTRMDiagnosticErrorWord1(0x0),
+  //fTRMDiagnosticErrorWord2(0x0),
   fSpiderCurrentSlotID(-1),
   fSpiderCurrentChain(-1),
   fSpiderCurrentTDC(-1)
@@ -67,15 +86,15 @@ AliTOFDecoder::AliTOFDecoder(AliTOFHitDataBuffer *DataBuffer, AliTOFHitDataBuffe
   fV2718Patch(kFALSE),
   fDataBuffer(DataBuffer),
   fPackedDataBuffer(PackedDataBuffer),
-  fTRMGlobalHeader(0x0),
-  fTRMGlobalTrailer(0x0),
-  fTRMChainHeader(0x0),
-  fTRMChainTrailer(0x0),
-  fTDCPackedHit(0x0),
-  fTDCUnpackedHit(0x0),
-  fTRMTDCError(0x0),
-  fTRMDiagnosticErrorWord1(0x0),
-  fTRMDiagnosticErrorWord2(0x0),
+  //fTRMGlobalHeader(0x0),
+  //fTRMGlobalTrailer(0x0),
+  //fTRMChainHeader(0x0),
+  //fTRMChainTrailer(0x0),
+  //fTDCPackedHit(0x0),
+  //fTDCUnpackedHit(0x0),
+  //fTRMTDCError(0x0),
+  //fTRMDiagnosticErrorWord1(0x0),
+  //fTRMDiagnosticErrorWord2(0x0),
   fSpiderCurrentSlotID(-1),
   fSpiderCurrentChain(-1),
   fSpiderCurrentTDC(-1)
@@ -86,42 +105,26 @@ AliTOFDecoder::AliTOFDecoder(AliTOFHitDataBuffer *DataBuffer, AliTOFHitDataBuffe
 //_________________________________________________________________
 
 AliTOFDecoder::AliTOFDecoder(const AliTOFDecoder &source) : 
-  TObject(),
-  fVerbose(0),
-  fV2718Patch(kFALSE),
-  fDataBuffer(0x0),
-  fPackedDataBuffer(0x0),
-  fTRMGlobalHeader(0x0),
-  fTRMGlobalTrailer(0x0),
-  fTRMChainHeader(0x0),
-  fTRMChainTrailer(0x0),
-  fTDCPackedHit(0x0),
-  fTDCUnpackedHit(0x0),
-  fTRMTDCError(0x0),
-  fTRMDiagnosticErrorWord1(0x0),
-  fTRMDiagnosticErrorWord2(0x0),
-  fSpiderCurrentSlotID(-1),
-  fSpiderCurrentChain(-1),
-  fSpiderCurrentTDC(-1)
+  TObject(source),
+  fVerbose(source.fVerbose),
+  fV2718Patch(source.fV2718Patch),
+  fDataBuffer(source.fDataBuffer),
+  fPackedDataBuffer(source.fPackedDataBuffer),
+  //fTRMGlobalHeader(source.fTRMGlobalHeader),
+  //fTRMGlobalTrailer(source.fTRMGlobalTrailer),
+  //fTRMChainHeader(source.fTRMChainHeader),
+  //fTRMChainTrailer(source.fTRMChainTrailer),
+  //fTDCPackedHit(source.fTDCPackedHit),
+  //fTDCUnpackedHit(source.fTDCUnpackedHit),
+  //fTRMTDCError(source.fTRMTDCError),
+  //fTRMDiagnosticErrorWord1(source.fTRMDiagnosticErrorWord1),
+  //fTRMDiagnosticErrorWord2(source.fTRMDiagnosticErrorWord2),
+  fSpiderCurrentSlotID(source.fSpiderCurrentSlotID),
+  fSpiderCurrentChain(source.fSpiderCurrentChain),
+  fSpiderCurrentTDC(source.fSpiderCurrentTDC)
 {
   //copy constructor
   
-  this->fVerbose = source.fVerbose;
-  this->fV2718Patch = source.fV2718Patch;
-  this->fDataBuffer = source.fDataBuffer;
-  this->fPackedDataBuffer = source.fPackedDataBuffer;
-  this->fTRMGlobalHeader = source.fTRMGlobalHeader;
-  this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
-  this->fTRMChainHeader = source.fTRMChainHeader;
-  this->fTRMChainTrailer = source.fTRMChainTrailer;
-  this->fTDCPackedHit = source.fTDCPackedHit;
-  this->fTDCUnpackedHit = source.fTDCUnpackedHit;
-  this->fTRMTDCError = source.fTRMTDCError;
-  this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
-  this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
-  this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
-  this->fSpiderCurrentChain = source.fSpiderCurrentChain;
-  this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
 }
 
 //_________________________________________________________________
@@ -131,22 +134,26 @@ AliTOFDecoder::operator = (const AliTOFDecoder &source)
 {
   //operator =
 
-  this->fVerbose = source.fVerbose;
-  this->fV2718Patch = source.fV2718Patch;
-  this->fDataBuffer = source.fDataBuffer;
-  this->fPackedDataBuffer = source.fPackedDataBuffer;
-  this->fTRMGlobalHeader = source.fTRMGlobalHeader;
-  this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
-  this->fTRMChainHeader = source.fTRMChainHeader;
-  this->fTRMChainTrailer = source.fTRMChainTrailer;
-  this->fTDCPackedHit = source.fTDCPackedHit;
-  this->fTDCUnpackedHit = source.fTDCUnpackedHit;
-  this->fTRMTDCError = source.fTRMTDCError;
-  this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
-  this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
-  this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
-  this->fSpiderCurrentChain = source.fSpiderCurrentChain;
-  this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
+  if (this == &source)
+    return *this;
+
+  TObject::operator=(source);
+  fVerbose = source.fVerbose;
+  fV2718Patch = source.fV2718Patch;
+  fDataBuffer = source.fDataBuffer;
+  fPackedDataBuffer = source.fPackedDataBuffer;
+  //fTRMGlobalHeader = source.fTRMGlobalHeader;
+  //fTRMGlobalTrailer = source.fTRMGlobalTrailer;
+  //fTRMChainHeader = source.fTRMChainHeader;
+  //fTRMChainTrailer = source.fTRMChainTrailer;
+  //fTDCPackedHit = source.fTDCPackedHit;
+  //fTDCUnpackedHit = source.fTDCUnpackedHit;
+  //fTRMTDCError = source.fTRMTDCError;
+  //fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
+  //fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
+  fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
+  fSpiderCurrentChain = source.fSpiderCurrentChain;
+  fSpiderCurrentTDC = source.fSpiderCurrentTDC;
   return *this;
 }
 
@@ -156,7 +163,7 @@ AliTOFDecoder::~AliTOFDecoder()
 //_________________________________________________________________
 
 Bool_t
-AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords)
+AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh)
 {
   /* main decoding routine.
    * it loops over nWords 32-bit words 
@@ -166,6 +173,17 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords)
    * classes.
    */
 
+  AliTOFTRMGlobalHeader          *lTRMGlobalHeader; //TRM global header
+  AliTOFTRMGlobalTrailer         *lTRMGlobalTrailer; //TRM global trailer
+  AliTOFTRMChainHeader           *lTRMChainHeader; //TRM chain header
+  //AliTOFTRMChainTrailer          *lTRMChainTrailer; //TRM chain trailer
+  AliTOFTDCPackedHit             *lTDCPackedHit; //TDC packed hit
+  AliTOFTDCUnpackedHit           *lTDCUnpackedHit; //TDC unpacked hit
+  //AliTOFTRMTDCError              *lTRMTDCError; //TRM TDC error
+  //AliTOFTRMDiagnosticErrorWord1  *lTRMDiagnosticErrorWord1; //TRM diagnostic error word 1
+  //AliTOFTRMDiagnosticErrorWord2  *lTRMDiagnosticErrorWord2; //TRM diagnostica error word 2
+
+
   AliTOFHitData hitData;
   
   //useful variables
@@ -181,6 +199,11 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords)
   Short_t  currentACQ = -1;
   Short_t  currentChain = -1;
   Short_t  currentBunchID = -1;
+  Short_t  currentMiniEventID = cdh ? cdh->GetMiniEventID() : (Short_t)-1;
+  Short_t  currentEventID1 = cdh ? cdh->GetEventID1() : (Short_t)-1;
+  AliDebug(1, Form("EvID1 = %d, EvID2 = %d, currentMiniEventID = %d", currentEventID1, cdh->GetEventID2(), currentMiniEventID));
+  if (!cdh)
+    AliWarning("CDH not valid: deltaBunchID not reliable ");
 
   /*** V2718 patch ***/
   if (fV2718Patch){
@@ -263,19 +286,18 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords)
        }
        //decode status ok
        //set TRM global header
-       fTRMGlobalHeader = (AliTOFTRMGlobalHeader *)rawData;    
+       lTRMGlobalHeader = (AliTOFTRMGlobalHeader*)rawData;     
        //set current TRM
-       currentSlotID = fTRMGlobalHeader->GetSlotID();
-       currentACQ = fTRMGlobalHeader->GetACQBits();
+       currentSlotID = lTRMGlobalHeader->GetSlotID();
+       currentACQ = lTRMGlobalHeader->GetACQBits();
        if (fVerbose)
-         AliInfo(Form("  %02x - 0x%08x \t  TRM global header \t slotID=%02d ACQ=%01d L=%01d",decodeStatus,*rawData,fTRMGlobalHeader->GetSlotID(),fTRMGlobalHeader->GetACQBits(),fTRMGlobalHeader->GetLBit()));
+         AliInfo(Form("  %02x - 0x%08x \t  TRM global header \t slotID=%02d ACQ=%01d L=%01d",decodeStatus,*rawData,lTRMGlobalHeader->GetSlotID(),lTRMGlobalHeader->GetACQBits(),lTRMGlobalHeader->GetLBit()));
        //change decode status
        decodeStatus = decodeStatus | TRM_BIT;
        break;
        
       default:
-       if (fVerbose)
-         AliError(Form("  %02x - 0x%08x [ERROR] Not valid slotID in global header",decodeStatus,*rawData));
+       AliError(Form("  %02x - 0x%08x [ERROR] Not valid slotID in global header",decodeStatus,*rawData));
        return kTRUE;
        break;
        
@@ -325,16 +347,15 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords)
        }
        //decode status ok
        //set TRM global trailer
-       fTRMGlobalTrailer = (AliTOFTRMGlobalTrailer *)rawData;  
+       lTRMGlobalTrailer = (AliTOFTRMGlobalTrailer *)rawData;  
        if (fVerbose)
-         AliInfo(Form("  %02x - 0x%08x \t  TRM global trailer \t CRC=%04d eventCounter=%04d",decodeStatus,*rawData,fTRMGlobalTrailer->GetEventCRC(),fTRMGlobalTrailer->GetEventCounter()));
+         AliInfo(Form("  %02x - 0x%08x \t  TRM global trailer \t CRC=%04d eventCounter=%04d",decodeStatus,*rawData,lTRMGlobalTrailer->GetEventCRC(),lTRMGlobalTrailer->GetEventCounter()));
        //change decode status
        decodeStatus = decodeStatus & ~TRM_BIT;
        break; 
        
       default:
-       if (fVerbose)
-         AliError(Form("  %02x - 0x%08x [ERROR] Not valid slotID/pattern in global trailer",decodeStatus,*rawData));
+       AliError(Form("  %02x - 0x%08x [ERROR] Not valid slotID/pattern in global trailer",decodeStatus,*rawData));
        return kTRUE;
        break;
       }
@@ -347,9 +368,9 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords)
        return kTRUE;
       }
       //decode status ok
-      fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
+      lTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
       currentChain = 0;
-      currentBunchID = fTRMChainHeader->GetBunchID();
+      currentBunchID = lTRMChainHeader->GetBunchID();
       if (fVerbose)
        AliInfo(Form("  %02x - 0x%08x \t  TRM chain A header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
       //change decode status
@@ -376,9 +397,9 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords)
        return kTRUE;
       }
       //decode status ok
-      fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
+      lTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
       currentChain = 1;
-      currentBunchID = fTRMChainHeader->GetBunchID();
+      currentBunchID = lTRMChainHeader->GetBunchID();
       if (fVerbose)
        AliInfo(Form("  %02x - 0x%08x \t  TRM chain B header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
       //change decode status
@@ -422,24 +443,25 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords)
        
       case PACKING_ENABLED_ACQ:
        //decode TDC packed hit
-       fTDCPackedHit = (AliTOFTDCPackedHit *)rawData;
-       fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
+       lTDCPackedHit = (AliTOFTDCPackedHit *)rawData;
+       lTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
        //set hit in the equipment data
        hitData.SetDDLID(currentDDL);
        hitData.SetSlotID(currentSlotID);
        hitData.SetACQ(currentACQ);
        hitData.SetChain(currentChain);
-       hitData.SetPS(fTDCPackedHit->GetPSBits());
-       hitData.SetTDC(fTDCPackedHit->GetTDCID());
-       hitData.SetChan(fTDCPackedHit->GetChan());
-       hitData.SetTime((float)fTDCPackedHit->GetHitTime() * TIME_BIN_WIDTH);
-       hitData.SetTimeBin(fTDCPackedHit->GetHitTime());
-       hitData.SetTOT((float)fTDCPackedHit->GetTOTWidth() * TOT_BIN_WIDTH);
-       hitData.SetTOTBin(fTDCPackedHit->GetTOTWidth());
+       hitData.SetPS(lTDCPackedHit->GetPSBits());
+       hitData.SetTDC(lTDCPackedHit->GetTDCID());
+       hitData.SetChan(lTDCPackedHit->GetChan());
+       hitData.SetTime((float)lTDCPackedHit->GetHitTime() * TIME_BIN_WIDTH);
+       hitData.SetTimeBin(lTDCPackedHit->GetHitTime());
+       hitData.SetTOT((float)lTDCPackedHit->GetTOTWidth() * TOT_BIN_WIDTH);
+       hitData.SetTOTBin(lTDCPackedHit->GetTOTWidth());
+       hitData.SetDeltaBunchID(currentBunchID - currentEventID1);
        //orphane leading hit
        if (hitData.GetPS()==LEADING_HIT_PS){
-         hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
-         hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
+         hitData.SetTime((float)lTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
+         hitData.SetTimeBin(lTDCUnpackedHit->GetHitTime());
          //set TOT to zero
          hitData.SetTOT(0);
          hitData.SetTOTBin(0);
@@ -455,8 +477,8 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords)
        }
        //orphane trailing hit
        else if (hitData.GetPS()==TRAILING_HIT_PS){
-         hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
-         hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
+         hitData.SetTime((float)lTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
+         hitData.SetTimeBin(lTDCUnpackedHit->GetHitTime());
          //set TOT to not measured
          hitData.SetTOT(-1);
          hitData.SetTOTBin(-1);
@@ -516,19 +538,20 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords)
        
       case LEADING_ONLY_ACQ: case TRAILING_ONLY_ACQ:
        //decode TDC unpacked hit
-       fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
+       lTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
        //set hit in the equipment data
        hitData.SetDDLID(currentDDL);
        hitData.SetSlotID(currentSlotID);
        hitData.SetACQ(currentACQ);
        hitData.SetChain(currentChain);
-       hitData.SetPS(fTDCUnpackedHit->GetPSBits());
-       hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
-       hitData.SetChan(fTDCUnpackedHit->GetChan());
-       hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
-       hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
+       hitData.SetPS(lTDCUnpackedHit->GetPSBits());
+       hitData.SetTDC(lTDCUnpackedHit->GetTDCID());
+       hitData.SetChan(lTDCUnpackedHit->GetChan());
+       hitData.SetTime((float)lTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
+       hitData.SetTimeBin(lTDCUnpackedHit->GetHitTime());
        hitData.SetTOT(-1.);
        hitData.SetTOTBin(-1);
+       hitData.SetDeltaBunchID(currentBunchID - currentEventID1);
        //push hit data in data buffer
          if (fDataBuffer != 0x0)
            fDataBuffer->Add(hitData);
@@ -552,19 +575,20 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords)
        
       case PACKING_DISABLED_ACQ:
        //decode TDC unpacked hit
-       fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
+       lTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
        //set hit in the equipment data
        hitData.SetDDLID(currentDDL);
        hitData.SetSlotID(currentSlotID);
        hitData.SetACQ(currentACQ);
        hitData.SetChain(currentChain);
-       hitData.SetPS(fTDCUnpackedHit->GetPSBits());
-       hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
-       hitData.SetChan(fTDCUnpackedHit->GetChan());
-       hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
-       hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
+       hitData.SetPS(lTDCUnpackedHit->GetPSBits());
+       hitData.SetTDC(lTDCUnpackedHit->GetTDCID());
+       hitData.SetChan(lTDCUnpackedHit->GetChan());
+       hitData.SetTime((float)lTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
+       hitData.SetTimeBin(lTDCUnpackedHit->GetHitTime());
        hitData.SetTOT(-1.);
        hitData.SetTOTBin(-1);
+       hitData.SetDeltaBunchID(currentBunchID - currentEventID1);
        //push hit data in data buffer
          if (fDataBuffer != 0x0)
            fDataBuffer->Add(hitData);
@@ -676,7 +700,7 @@ AliTOFDecoder::ResetSpider(){
 //_________________________________________________________________
 
 Bool_t 
-AliTOFDecoder::Spider(AliTOFHitData hitData){
+AliTOFDecoder::Spider(AliTOFHitData &hitData){
 
   /* main SPIDER routine.
      it receives, reads, stores and packs
@@ -771,3 +795,111 @@ AliTOFDecoder::Spider(AliTOFHitData hitData){
 
   return kFALSE;
 }
+//_____________________________________________________________________________
+void AliTOFDecoder::GetArrayDDL(Int_t* array, Int_t ddl){
+
+  // method that fills array with the
+  // TOF channels indexes corresponding
+  // to DDL iDDL
+
+  AliTOFGeometry *geom = new AliTOFGeometry();
+  Int_t indexDDL = ddl%4;
+  Int_t iSector = Int_t(ddl/4);
+  if (fVerbose)
+    AliInfo(Form(" Sector = %i, DDL within sector = %i",iSector, indexDDL));
+
+  Int_t volume[5];
+  volume[0]=iSector;
+  Int_t minPlate=0, maxPlate=0, minStrip2=0, maxStrip2=0, minPadz=0, maxPadz=0, minPadx=0, maxPadx=0;
+
+  if (indexDDL==0){
+    minPlate=kMinPlate0;
+    maxPlate=kMaxPlate0;
+    minStrip2=kMinStrip0;
+    maxStrip2=kMaxStrip0;
+    minPadz=kMinPadz0;
+    maxPadz=kMaxPadz0;
+    minPadx=kMinPadx0;
+    maxPadx=kMaxPadx0;
+  }
+
+  else if (indexDDL==1){
+    minPlate=kMinPlate1;
+    maxPlate=kMaxPlate1;
+    minStrip2=kMinStrip1;
+    maxStrip2=kMaxStrip1;
+    minPadz=kMinPadz1;
+    maxPadz=kMaxPadz1;
+    minPadx=kMinPadx1;
+    maxPadx=kMaxPadx1;
+  }
+
+  else if (indexDDL==2){
+    minPlate=kMinPlate2;
+    maxPlate=kMaxPlate2;
+    minStrip2=kMinStrip2;
+    maxStrip2=kMaxStrip2;
+    minPadz=kMinPadz2;
+    maxPadz=kMaxPadz2;
+    minPadx=kMinPadx2;
+    maxPadx=kMaxPadx2;
+  }
+
+  else if (indexDDL==3){
+    minPlate=kMinPlate3;
+    maxPlate=kMaxPlate3;
+    minStrip2=kMinStrip3;
+    maxStrip2=kMaxStrip3;
+    minPadz=kMinPadz3;
+    maxPadz=kMaxPadz3;
+    minPadx=kMinPadx3;
+    maxPadx=kMaxPadx3;
+  }
+
+  Int_t ichTOF=0;
+
+  Int_t minStrip=0;
+  Int_t maxStrip=18;  
+  for (Int_t iPlate=minPlate;iPlate<=maxPlate;iPlate++){
+    if (iPlate==2) {
+      maxStrip = maxStrip2;
+      minStrip = minStrip2;
+    }
+    else {
+      maxStrip = 18;
+      minStrip = 0;
+    }
+    for (Int_t iStrip=minStrip;iStrip<=maxStrip;iStrip++){
+      for (Int_t iPadz=minPadz;iPadz<=maxPadz;iPadz++){
+       for (Int_t iPadx=minPadx;iPadx<=maxPadx;iPadx++){
+         volume[1]=iPlate;
+         volume[2]=iStrip;
+         volume[3]=iPadz;
+         volume[4]=iPadx;
+         if (fVerbose)
+           AliInfo(Form(" volume[0] = %i, volume[1] = %i, volume[2] = %i, volume[3] = %i, volume[4] = %i",volume[0],volume[1],volume[2],volume[3],volume[4]));
+
+         if (indexDDL==0 || indexDDL==2){
+           array[ichTOF]=geom->GetIndex(volume);
+           if (fVerbose)
+             AliInfo(Form(" ichTOF = %i, TOFChannel = %i",ichTOF,array[ichTOF]));
+
+         }
+         else {
+           array[ichTOF]=geom->GetIndex(volume);
+           if (fVerbose)
+             AliInfo(Form(" ichTOF = %i, TOFChannel = %i",ichTOF,array[ichTOF]));
+
+         }
+         ichTOF++;
+       }
+      }
+    }
+  }
+  //AliInfo(Form("ichTOF = %i",ichTOF));
+  if ((indexDDL%2==0 && ichTOF!=2160) ||
+      (indexDDL%2==1 && ichTOF!=2208)) {
+    AliWarning(Form("Something strange occurred, number of entries in array different from expected! Please, check! ichTOF = %i",ichTOF));
+  }
+  return;
+}