]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDdigitsManager.cxx
Decoding of TRAP info
[u/mrichter/AliRoot.git] / TRD / AliTRDdigitsManager.cxx
index 724985827665d789f1644d390ddf55692d5f49ea..e33dd16637c376b00afc5c4469734b097efbd1ce 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.17  2002/03/28 14:59:07  cblume
-Coding conventions
-
-Revision 1.16  2002/02/12 11:42:08  cblume
-Remove fTree from destructor
-
-Revision 1.15  2002/02/11 14:27:54  cblume
-Geometry and hit structure update
-
-Revision 1.14  2001/11/14 10:50:46  cblume
-Changes in digits IO. Add merging of summable digits
-
-Revision 1.13  2001/11/06 17:19:41  cblume
-Add detailed geometry and simple simulator
-
-Revision 1.12  2001/05/16 14:57:28  alibrary
-New files for folders and Stack
-
-Revision 1.11  2001/03/13 09:30:35  cblume
-Update of digitization. Moved digit branch definition to AliTRD
-
-Revision 1.10  2001/01/26 19:56:57  hristov
-Major upgrade of AliRoot code
-
-Revision 1.9  2000/11/02 09:25:53  cblume
-Change also the dictionary to AliTRDdataArray
-
-Revision 1.8  2000/11/01 15:20:13  cblume
-Change AliTRDdataArrayI to AliTRDdataArray in MakeBranch()
-
-Revision 1.7  2000/11/01 14:53:20  cblume
-Merge with TRD-develop
-
-Revision 1.1.2.5  2000/10/17 02:27:34  cblume
-Get rid of global constants
-
-Revision 1.1.2.4  2000/10/15 23:40:01  cblume
-Remove AliTRDconst
-
-Revision 1.1.2.3  2000/10/06 16:49:46  cblume
-Made Getters const
-
-Revision 1.1.2.2  2000/10/04 16:34:58  cblume
-Replace include files by forward declarations
-
-Revision 1.5  2000/06/09 11:10:07  cblume
-Compiler warnings and coding conventions, next round
-
-Revision 1.4  2000/06/08 18:32:58  cblume
-Make code compliant to coding conventions
-
-Revision 1.3  2000/06/07 16:27:01  cblume
-Try to remove compiler warnings on Sun and HP
-
-Revision 1.2  2000/05/08 16:17:27  cblume
-Merge TRD-develop
-
-Revision 1.1.2.1  2000/05/08 14:44:01  cblume
-Add new class AliTRDdigitsManager
-
-*/
+/* $Id$ */
 
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
@@ -84,20 +22,25 @@ Add new class AliTRDdigitsManager
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#include <iostream.h>
+#include <Riostream.h>
  
 #include <TROOT.h>
 #include <TTree.h>                                                              
 #include <TFile.h>
 
 #include "AliRun.h"
+#include "AliLog.h"
 
 #include "AliTRDdigitsManager.h"
 #include "AliTRDsegmentArray.h"
+#include "AliTRDdataArray.h"
 #include "AliTRDdataArrayI.h"
+#include "AliTRDdataArrayS.h"
+#include "AliTRDdataArrayDigits.h"
 #include "AliTRDdigit.h"
 #include "AliTRDgeometry.h"
-#include "AliTRD.h"
+
+#include "AliTRDSignalIndex.h"
 
 ClassImp(AliTRDdigitsManager)
 
@@ -107,35 +50,41 @@ ClassImp(AliTRDdigitsManager)
   const Int_t AliTRDdigitsManager::fgkNDict = kNDict;
 
 //_____________________________________________________________________________
-AliTRDdigitsManager::AliTRDdigitsManager():TObject()
+AliTRDdigitsManager::AliTRDdigitsManager()
+  :TObject()
+  ,fEvent(0)
+  ,fTree(0)
+  ,fDigits(0)
+  ,fHasSDigits(0)
+  ,fSignalIndexes(NULL)
+  ,fUseDictionaries(kTRUE)
 {
   //
   // Default constructor
   //
 
-  fIsRaw   = kFALSE;
-  fEvent   = 0;
-  fDebug   = 0;
-  fSDigits = 0;
-
-  fFile    = NULL;
-  fTree    = NULL;
-  fDigits  = NULL;
   for (Int_t iDict = 0; iDict < kNDict; iDict++) {
     fDictionary[iDict] = NULL;
   }
-
+  
+  fSignalIndexes = new TObjArray(AliTRDgeometry::Ndet());
+  
 }
 
 //_____________________________________________________________________________
 AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m)
+  :TObject(m)
+  ,fEvent(m.fEvent)
+  ,fTree(0)
+  ,fDigits(0)
+  ,fHasSDigits(m.fHasSDigits)
+  ,fSignalIndexes(NULL)
+  ,fUseDictionaries(kTRUE)
 {
   //
   // AliTRDdigitsManager copy constructor
   //
 
-  ((AliTRDdigitsManager &) m).Copy(*this);
-
 }
 
 //_____________________________________________________________________________
@@ -145,16 +94,10 @@ AliTRDdigitsManager::~AliTRDdigitsManager()
   // AliTRDdigitsManager destructor
   //
 
-  if (fFile) {
-    fFile->Close();
-    delete fFile;
-    fFile = NULL;
-  }
-
   if (fDigits) {
     fDigits->Delete();
     delete fDigits;
-    fDigits = NULL;
+    fDigits            = NULL;
   }
 
   for (Int_t iDict = 0; iDict < kNDict; iDict++) {
@@ -163,137 +106,143 @@ AliTRDdigitsManager::~AliTRDdigitsManager()
     fDictionary[iDict] = NULL;
   }
 
+  if (fSignalIndexes) {
+    fSignalIndexes->Delete();
+    delete fSignalIndexes;
+    fSignalIndexes     = NULL;
+  }
+
 }
 
 //_____________________________________________________________________________
-void AliTRDdigitsManager::Copy(TObject &m)
+AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
 {
   //
-  // Copy function
+  // Assignment operator
   //
 
-  ((AliTRDdigitsManager &) m).fIsRaw   = fIsRaw;
-  ((AliTRDdigitsManager &) m).fEvent   = fEvent;
-  ((AliTRDdigitsManager &) m).fDebug   = fDebug;
-  ((AliTRDdigitsManager &) m).fSDigits = fSDigits;
+  if (this != &m) {
+    ((AliTRDdigitsManager &) m).Copy(*this);
+  }
 
-  TObject::Copy(m);
+  return *this;
 
 }
 
 //_____________________________________________________________________________
-void AliTRDdigitsManager::CreateArrays()
+void AliTRDdigitsManager::Copy(TObject &m) const
 {
   //
-  // Create the data arrays
+  // Copy function
   //
 
-  fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
+  ((AliTRDdigitsManager &) m).fEvent           = fEvent;
+  ((AliTRDdigitsManager &) m).fHasSDigits      = fHasSDigits;
+  
+  ((AliTRDdigitsManager &) m).fSignalIndexes   = fSignalIndexes;
+  ((AliTRDdigitsManager &) m).fUseDictionaries = fUseDictionaries;
 
-  for (Int_t iDict = 0; iDict < kNDict; iDict++) {
-    fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
-                                               ,AliTRDgeometry::Ndet());
-  }
+  TObject::Copy(m);
 
 }
 
 //_____________________________________________________________________________
-void AliTRDdigitsManager::SetRaw()
+void AliTRDdigitsManager::CreateArrays()
 {
   //
-  // Switch on the raw digits flag
+  // Create the data arrays
   //
 
-  fIsRaw = kTRUE;
-
-  fDigits->SetBit(AliTRDdigit::RawDigit());
-  
-}
+  if (fHasSDigits) {
+    fDigits = new AliTRDsegmentArray("AliTRDdataArrayF",AliTRDgeometry::Ndet());
+  }
+  else {
+    fDigits = new AliTRDsegmentArray("AliTRDdataArrayDigits",AliTRDgeometry::Ndet());
+  }
 
-//_____________________________________________________________________________
-Short_t AliTRDdigitsManager::GetDigitAmp(Int_t row, Int_t col,Int_t time
-                                       , Int_t det) const
-{
-  //
-  // Returns the amplitude of a digit
-  //
+  if (fUseDictionaries) {
+    for (Int_t iDict = 0; iDict < kNDict; iDict++) {
+      fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
+                                                 ,AliTRDgeometry::Ndet());
+    }
+  }
 
-  return ((Short_t) GetDigits(det)->GetData(row,col,time));
+  for (Int_t i = 0; i < AliTRDgeometry::Ndet(); i++) {
+    fSignalIndexes->AddLast(new AliTRDSignalIndex());
+  }
 
 }
+
 //_____________________________________________________________________________
-Bool_t AliTRDdigitsManager::Open(const Char_t *file)
+void AliTRDdigitsManager::ResetArrays()
 {
   //
-  // Opens the file for the TRD digits
+  // Reset the data arrays
   //
 
-  fFile = (TFile*) gROOT->GetListOfFiles()->FindObject(file);
-  if (!fFile) {
-    if (fDebug > 0) {
-      printf("<AliTRDdigitsManager::Open> ");
-      printf("Open the AliROOT-file %s.\n",file);
-    }
-    fFile = new TFile(file,"UPDATE");
-    if (!fFile) return kFALSE;
+  if (fDigits) {
+    fDigits->Delete();
+    delete fDigits;
+  }
+  if (fHasSDigits) {
+    fDigits = new AliTRDsegmentArray("AliTRDdataArrayF",AliTRDgeometry::Ndet());
   }
   else {
-    if (fDebug > 0) {
-      printf("<AliTRDdigitsManager::Open> ");
-      printf("%s is already open.\n",file);
+    fDigits = new AliTRDsegmentArray("AliTRDdataArrayS",AliTRDgeometry::Ndet());
+  }
+
+  if (fUseDictionaries) {
+    for (Int_t iDict = 0; iDict < kNDict; iDict++) {
+      if (fDictionary[iDict]) { 
+       fDictionary[iDict]->Delete();
+        delete fDictionary[iDict];
+      }
+      fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
+                                                ,AliTRDgeometry::Ndet());
     }
   }
 
-  return kTRUE;
+  for (Int_t i = 0; i < AliTRDgeometry::Ndet(); i++) {
+    AliTRDSignalIndex *idx = (AliTRDSignalIndex *)fSignalIndexes->At(i);
+    if (idx) idx->Reset();
+  }
 
 }
 
 //_____________________________________________________________________________
-void AliTRDdigitsManager::MakeTreeAndBranches(TFile *file, Int_t iEvent)
+Short_t AliTRDdigitsManager::GetDigitAmp(Int_t row, Int_t col,Int_t time
+                                       , Int_t det) const
 {
   //
-  // Creates tree for (s)digits in the specified file
+  // Returns the amplitude of a digit
   //
 
-  fEvent = iEvent;
-  TDirectory *wd = gDirectory;
-  file->cd();
-  MakeBranch();
-  wd->cd();
+  if (!GetDigits(det)) {
+    return 0;
+  }
 
-}
+  return ((Short_t) ((AliTRDdataArrayDigits *) GetDigits(det))->GetData(row,col,time));
 
+}
 //_____________________________________________________________________________
-Bool_t AliTRDdigitsManager::MakeBranch(const Char_t *file)
+UChar_t AliTRDdigitsManager::GetPadStatus(Int_t row, Int_t col, Int_t time
+                                             , Int_t det) const
 {
   //
-  // Creates the tree and branches for the digits and the dictionary
+  // Returns the pad status for the requested pad
   //
-
-  // Create the TRD digits tree
-  TTree *tree;
-  Char_t treeName[12];
-  if (fSDigits) {
-    sprintf(treeName,"TreeS%d_TRD",fEvent);
-    tree = new TTree(treeName,"TRD SDigits");
-  }
-  else {
-    sprintf(treeName,"TreeD%d_TRD",fEvent);
-    tree = new TTree(treeName,"TRD Digits");
-  }
-
-  if (fDebug > 0) {
-    printf("<AliTRDdigitsManager::MakeBranch> ");
-    printf("Creating tree %s\n",treeName);
+       
+  if (!GetDigits(det)) {
+    return 0;
   }
 
-  return MakeBranch(tree,file);
+  return ((UChar_t) ((AliTRDdataArrayDigits *) GetDigits(det))->GetPadStatus(row,col,time));
 
 }
 
 //_____________________________________________________________________________
-Bool_t AliTRDdigitsManager::MakeBranch(TTree *tree, const Char_t *file)
+Bool_t AliTRDdigitsManager::MakeBranch(TTree *tree)
 {
   //
   // Creates the tree and branches for the digits and the dictionary
@@ -303,8 +252,6 @@ Bool_t AliTRDdigitsManager::MakeBranch(TTree *tree, const Char_t *file)
 
   Bool_t status = kTRUE;
 
-  AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD") ;
-
   if (tree) {
     fTree = tree;
   }
@@ -313,12 +260,11 @@ Bool_t AliTRDdigitsManager::MakeBranch(TTree *tree, const Char_t *file)
   if (fDigits) {
     const AliTRDdataArray *kDigits = (AliTRDdataArray *) fDigits->At(0);
     if (kDigits) {
-      trd->MakeBranchInTree(fTree,"TRDdigits",kDigits->IsA()->GetName()
-                                 ,&kDigits,buffersize,99,file);
-      if (fDebug > 0) {
-        printf("<AliTRDdigitsManager::MakeBranch> ");
-        printf("Making branch TRDdigits\n");
-      }
+      if (!fTree) return kFALSE;
+      TBranch* branch = fTree->GetBranch("TRDdigits");
+      if (!branch) fTree->Branch("TRDdigits",kDigits->IsA()->GetName()
+                                ,&kDigits,buffersize,99);
+      AliDebug(1,"Making branch TRDdigits\n");
     }
     else {
       status = kFALSE;
@@ -328,28 +274,29 @@ Bool_t AliTRDdigitsManager::MakeBranch(TTree *tree, const Char_t *file)
     status = kFALSE;
   }
 
-  // Make the branches for the dictionaries
-  for (Int_t iDict = 0; iDict < kNDict; iDict++) {
-    Char_t branchname[15];
-    sprintf(branchname,"TRDdictionary%d",iDict);
-    if (fDictionary[iDict]) {
-      const AliTRDdataArray *kDictionary = 
-              (AliTRDdataArray *) fDictionary[iDict]->At(0);
-      if (kDictionary) {
-        trd->MakeBranchInTree(fTree,branchname,kDictionary->IsA()->GetName()
-                             ,&kDictionary,buffersize,99,file);
-        if (fDebug > 0) {
-          printf("<AliTRDdigitsManager::MakeBranch> ");
-          printf("Making branch %s\n",branchname);
+  if (fUseDictionaries) {
+    // Make the branches for the dictionaries
+    for (Int_t iDict = 0; iDict < kNDict; iDict++) {
+      Char_t branchname[15];
+      sprintf(branchname,"TRDdictionary%d",iDict);
+      if (fDictionary[iDict]) {
+       const AliTRDdataArray *kDictionary = 
+                              (AliTRDdataArray *) fDictionary[iDict]->At(0);
+       if (kDictionary) {
+         if (!fTree) return kFALSE;
+         TBranch* branch = fTree->GetBranch(branchname);
+         if (!branch) fTree->Branch(branchname,kDictionary->IsA()->GetName()
+                                   ,&kDictionary,buffersize,99);
+         AliDebug(1,Form("Making branch %s\n",branchname));
+       }
+       else {
+         status = kFALSE;
        }
       }
       else {
-        status = kFALSE;
+       status = kFALSE;
       }
     }
-    else {
-      status = kFALSE;
-    }
   }
 
   return status;
@@ -366,58 +313,27 @@ Bool_t AliTRDdigitsManager::ReadDigits(TTree *tree)
   Bool_t status = kTRUE;
 
   if (tree) {
-
     fTree = tree;
-
-  }
-  else {
-
-    // Get the digits tree
-    Char_t treeName[12];
-    if (fSDigits) {
-      sprintf(treeName,"TreeS%d_TRD",fEvent);
-    }
-    else {
-      sprintf(treeName,"TreeD%d_TRD",fEvent);
-    }
-    if (fFile) {
-      fTree = (TTree *) fFile->Get(treeName);
-    }
-    else {
-      fTree = (TTree *) gDirectory->Get(treeName);
-    }
-
-    if (!fTree) {
-      if (fDebug > 0) {
-        printf("<AliTRDdigitsManager::ReadDigits> ");
-        printf("Could not find tree %s.\n",treeName);
-      }
-      return kFALSE;
-    }
-
   }
 
   if (!fDigits) {
-    if (fDebug > 0) {
-      printf("<AliTRDdigitsManager::ReadDigits> ");
-      printf("Create the data arrays.\n");
-    }
+    AliDebug(1,"Create the data arrays.\n");
     CreateArrays();
   }
 
   status = fDigits->LoadArray("TRDdigits",fTree);
 
-  for (Int_t iDict = 0; iDict < kNDict; iDict++) {
-    Char_t branchname[15];
-    sprintf(branchname,"TRDdictionary%d",iDict);
-    status = fDictionary[iDict]->LoadArray(branchname,fTree);
-  }  
-
-  if (fDigits->TestBit(AliTRDdigit::RawDigit())) {
-    fIsRaw = kTRUE;
-  }
-  else {
-    fIsRaw = kFALSE;
+  if (fUseDictionaries) {
+    for (Int_t iDict = 0; iDict < kNDict; iDict++) {
+      Char_t branchname[15];
+      sprintf(branchname,"TRDdictionary%d",iDict);
+      status = fDictionary[iDict]->LoadArray(branchname,fTree);
+      if (status == kFALSE) {
+       fUseDictionaries = kFALSE;
+       AliWarning("Unable to load dict arrays. Will not use them.\n");
+        break;
+      }
+    }  
   }
 
   return kTRUE;
@@ -433,22 +349,22 @@ Bool_t AliTRDdigitsManager::WriteDigits()
 
   // Store the contents of the segment array in the tree
   if (!fDigits->StoreArray("TRDdigits",fTree)) {
-    printf("<AliTRDdigitsManager::WriteDigits> ");
-    printf("Error while storing digits in branch TRDdigits\n");
+    AliError("Error while storing digits in branch TRDdigits\n");
     return kFALSE;
   }
-  for (Int_t iDict = 0; iDict < kNDict; iDict++) {
-    Char_t branchname[15];
-    sprintf(branchname,"TRDdictionary%d",iDict);
-    if (!fDictionary[iDict]->StoreArray(branchname,fTree)) {
-      printf("<AliTRDdigitsManager::WriteDigits> ");
-      printf("Error while storing dictionary in branch %s\n",branchname);
-      return kFALSE;
+
+  if (fUseDictionaries) {
+    for (Int_t iDict = 0; iDict < kNDict; iDict++) {
+      Char_t branchname[15];
+      sprintf(branchname,"TRDdictionary%d",iDict);
+      if (!fDictionary[iDict]->StoreArray(branchname,fTree)) {
+       AliError(Form("Error while storing dictionary in branch %s\n",branchname));
+        return kFALSE;
+      }
     }
   }
 
   // Write the new tree to the output file
-  //fTree->Write();
   fTree->AutoSave();  // Modification by Jiri
 
   return kTRUE;
@@ -471,9 +387,9 @@ AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
   digits[2] = col;
   digits[3] = time;
 
-  amp[0]    = GetDigits(det)->GetData(row,col,time);
+  amp[0]    = ((AliTRDdataArrayDigits *) GetDigits(det))->GetData(row,col,time);
   
-  return (new AliTRDdigit(fIsRaw,digits,amp));
+  return (new AliTRDdigit(digits,amp));
 
 }
 
@@ -487,36 +403,47 @@ Int_t AliTRDdigitsManager::GetTrack(Int_t track
   //
 
   if ((track < 0) || (track >= kNDict)) {
-    TObject::Error("GetTracks"
-                  ,"track %d out of bounds (size: %d, this: 0x%08x)"
-                  ,track,kNDict,this);
+    AliError(Form("track %d out of bounds (size: %d, this: 0x%08x)"
+                 ,track,kNDict,this));
+    return -1;
+  }
+
+  if (fUseDictionaries == kFALSE) {
     return -1;
   }
 
   // Array contains index+1 to allow data compression
-  return (GetDictionary(det,track)->GetData(row,col,time) - 1);
+  return (((AliTRDdataArrayI *) GetDictionary(det,track))->GetData(row,col,time) - 1);
 
 }
 
 //_____________________________________________________________________________
-AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const
+AliTRDdataArrayDigits *AliTRDdigitsManager::GetDigits(Int_t det) const
 {
   //
   // Returns the digits array for one detector
   //
 
-  return (AliTRDdataArrayI *) fDigits->At(det);
+  if (!fDigits) {
+    return 0x0;
+  }
+
+  return (AliTRDdataArrayDigits *) fDigits->At(det);
 
 }
 
 //_____________________________________________________________________________
-AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const
+AliTRDdataArray *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const
 {
   //
   // Returns the dictionary for one detector
   //
 
-  return (AliTRDdataArrayI *) fDictionary[i]->At(det);
+  if (fUseDictionaries == kFALSE) {
+    return 0x0;
+  }
+
+  return (AliTRDdataArray *) fDictionary[i]->At(det);
 
 }
 
@@ -537,13 +464,111 @@ Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const
 }
 
 //_____________________________________________________________________________
-AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
+AliTRDSignalIndex *AliTRDdigitsManager::GetIndexes(Int_t det) 
 {
+  // 
+  // Returns indexes of active pads
   //
-  // Assignment operator
+
+  return (AliTRDSignalIndex *) fSignalIndexes->At(det);
+
+}
+
+//_____________________________________________________________________________
+void AliTRDdigitsManager::RemoveDigits(Int_t det) 
+{
+  // 
+  // Clear memory
   //
 
-  if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this);
-  return *this;
+  fDigits->ClearSegment(det);
+
+}
+
+//_____________________________________________________________________________
+void AliTRDdigitsManager::RemoveDictionaries(Int_t det) 
+{
+  // 
+  // Clear memory
+  //
+
+  if (fUseDictionaries == kFALSE) {
+    return;
+  }
+
+  for (Int_t i = 0; i < kNDict; i++) {
+    fDictionary[i]->ClearSegment(det);
+  }
+
+}
+
+//_____________________________________________________________________________
+void AliTRDdigitsManager::ClearIndexes(Int_t det) 
+{
+  // 
+  // Clear memory
+  //
+
+  ((AliTRDSignalIndex *) fSignalIndexes->At(det))->ClearAll();  
+
+}
+
+//_____________________________________________________________________________
+Bool_t AliTRDdigitsManager::BuildIndexes(Int_t det)
+{
+  //
+  // Build the list of indices
+  //
+
+  Int_t nRows = 0;
+  Int_t nCols = 0;
+  Int_t nTbins = 0;
+
+  AliTRDgeometry    geom;
+  AliTRDdataArrayDigits *digits = 0x0;
+
+  if (fHasSDigits) {
+    return kFALSE;
+  }
+  else {
+    digits = (AliTRDdataArrayDigits *) GetDigits(det);
+  }
+
+  //digits should be expanded by now!!!
+  if (digits->GetNtime() > 0) {
+
+    digits->Expand();
+    nRows  = digits->GetNrow();
+    nCols  = digits->GetNcol();
+    nTbins = digits->GetNtime();
+
+    AliTRDSignalIndex *indexes = GetIndexes(det);
+    indexes->SetSM(geom.GetSector(det));
+    indexes->SetStack(geom.GetStack(det));
+    indexes->SetLayer(geom.GetLayer(det));
+    indexes->SetDetNumber(det);
+
+    if (indexes->IsAllocated() == kFALSE) {
+      indexes->Allocate(nRows,nCols,nTbins);
+    }
+
+    for (Int_t ir = 0; ir < nRows; ir++) {
+      for (Int_t ic = 0; ic < nCols; ic++) {
+       for (Int_t it = 0; it < nTbins; it++) {   
+  
+         Int_t isig = digits->GetDataUnchecked(ir,ic,it);
+         if (isig > 0) {
+           indexes->AddIndexTBin(ir,ic,it);        
+         }
+       } // tbins
+      } // cols
+    } // rows
+
+  } // if GetNtime
+  else {
+    return kFALSE;
+  }
+
+  return kTRUE;
 
 }