]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDSignalIndex.h
Fixing warnings
[u/mrichter/AliRoot.git] / TRD / AliTRDSignalIndex.h
index 6b5b85f25e046e1adafc09e221e0e4f6651a2916..62456dc737657c8196d2dfbe548a8eeaedf251e0 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef AliTRDSIGNALINDEX_H
-#define AliTRDSIGNALINDEX_H
+#ifndef ALITRDSIGNALINDEX_H
+#define ALITRDSIGNALINDEX_H
 
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
  
 #include "TObject.h"
 
-/////////////////////////////////////////////////////////////
-//  General container for data from TRD detector segments  //
-//  Adapted from AliDigits, origin M.Ivanov                //
-/////////////////////////////////////////////////////////////
-
-//class TArrayI;
-#include "TArrayI.h"
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+//  General container for data from TRD detector segments                 //
+//  Adapted from AliDigits, origin M.Ivanov                               //
+//                                                                        //
+//  Author:                                                               //
+//    Mateusz Ploskon (ploskon@ikf.uni-frankfurt.de)                      //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
 
 class AliTRDSignalIndex : public TObject
 {
- public:
+protected:
+
+  union RowCol{
+    Short_t rc;
+    struct{
+      UChar_t col;
+      Char_t row;
+    }s;
+  };
+
+public:
 
   AliTRDSignalIndex(); 
   AliTRDSignalIndex(Int_t nrow, Int_t ncol,Int_t ntime);
   AliTRDSignalIndex(const AliTRDSignalIndex &d);
-  virtual ~AliTRDSignalIndex(); // destructor
+  virtual ~AliTRDSignalIndex();
   AliTRDSignalIndex &operator=(const AliTRDSignalIndex &d); 
-  virtual void   Copy(TObject &d) const; 
-  virtual void   Allocate(Int_t nrow, Int_t ncol,Int_t ntime);
-  virtual void   Reset();
-
-  virtual void   ResetContentConditional(Int_t nrow, Int_t ncol,Int_t ntime);
-  virtual void   ResetContent();
-
-  virtual void   ResetCounters()
-  {
-    // reset the counters/iterators
-    fPositionRow = 0;
-    fPositionCol = fPositionRow + 1;
-    fPositionTbin = 1;
-    
-    fLastRow = -1;
-    fLastCol = -1;
-    fLastTbin = -1;
-
-    fResetCounters = kTRUE;
-  }
-
-  virtual void   ResetTbinCounter()
-  {
-    // reset the time bin counter
-    
-    fPositionTbin = 1;
-  }
-
-  virtual void   AddIndexTBin(Int_t row, Int_t col, Int_t tbin);
-
-  Bool_t  NextRCIndex(Int_t &row, Int_t &col); // get the next pad (row and column) and return kTRUE on success
-  Bool_t  NextRCTbinIndex(Int_t &row, Int_t &col, Int_t &tbin); // get the next timebin of a pad (row and column) and return kTRUE on success
-  Bool_t  NextTbinIndex(Int_t &tbin); // get the next active timebin and return kTRUE on success
-
-  Int_t   GetCurrentRow() {return (*fIndex)[fPositionRow];} // current row
-  Int_t   GetCurrentCol() {return (*fIndex)[fPositionCol];} // current col
-  Int_t   GetCurtentTbin() {return (*fIndex)[fPositionCol + fPositionTbin];} //current tbin
-  
-  void    ClearAll(); // clear the array, actually destroy and recreate w/o allocating
-  
-  //void    Dump(); // printf content - one way of iterating demo
-  //void    Dump2(); // printf content - another way of iterating demo
-
-  //Bool_t  IsAllocated() const {if (fIndex) return kTRUE; else return kFALSE;}
-  Bool_t  IsAllocated() const 
-  {
-    // return kTRUE if array allocated and there is no need to call allocate
-    if (!fIndex) 
-      return kFALSE; 
-    if (fIndex->GetSize() <= 0) 
-      return kFALSE; 
-    else return kTRUE;
-  }
-
-  void SetSM(Int_t ix) 
-  { 
-    // Set which SM
-    fSM = ix;
-  };
 
-  void SetStack(Int_t ix) 
-  { 
-    // Set which stack
-    fStack = ix;
+  void     Copy(TObject &d) const;
+  void     Allocate(const Int_t nrow, const Int_t ncol, const Int_t ntime);
+
+  void     Reset();
+  void     ResetContentConditional(const Int_t nrow, const Int_t ncol, const Int_t ntime);
+  void     ResetContent();
+  void     ResetCounters();
+  void     ResetTbinCounter() const { };
+
+  void     ResetArrays();
+
+  // Store the index row-column as an interesting one
+  void     AddIndexRC(const Int_t row, const Int_t col){
+    Int_t num=row*fNcols+col;
+    if(fBoolIndex[num])return;
+    fBoolIndex[num]=kTRUE;
+    fSortedIndex[fCountRC].s.col=col;
+    fSortedIndex[fCountRC].s.row=row;
+    fCountRC++;
   };
 
-  void SetChamber(Int_t ix) 
-  {
-    // aka set stack
-    SetStack(ix);
-  }
+  // Get the next pad (row and column) and return kTRUE on success
+  Bool_t   NextRCIndex(Int_t &row, Int_t &col); 
+  // Get the next timebin of a pad (row and column) and return kTRUE on success
+  Bool_t   NextRCTbinIndex(Int_t &row, Int_t &col, Int_t &tbin); 
+  // Get the next active timebin and return kTRUE on success
+  Bool_t   NextTbinIndex(Int_t &tbin); 
+
+  Int_t    GetCurrentRow() const  { return fCurrRow; }
+  Int_t    GetCurrentCol() const  { return fCurrCol; }
+  Int_t    GetCurrentTbin() const { return fCurrTbin; }
+
+  Bool_t   IsBoolIndex(Int_t row, Int_t col) const {return fBoolIndex[row*fNcols+col];};
+  void     InitSortedIndex();
+
+  // Clear the array, actually destroy and recreate w/o allocating
+  void     ClearAll(); 
+  // Return kTRUE if array allocated and there is no need to call allocate
+  Bool_t   IsAllocated() const    { if (!fBoolIndex)    return kFALSE; 
+                                    if (fMaxLimit <= 0) return kFALSE; 
+                                    else                return kTRUE;}
+
+  void     SetSM(const Int_t ix)        { fSM      =    ix; }
+  void     SetStack(const Int_t ix)     { fStack   =    ix; }
+  void     SetLayer(const Int_t ix)     { fLayer   =    ix; }
+  void     SetDetNumber(const Int_t ix) { fDet     =    ix; }
+  
+  Int_t    GetDetNumber() const   { return fDet;      } // Get Det number
+  Int_t    GetLayer() const       { return fLayer;    } // Layer position of the chamber in TRD
+  Int_t    GetStack() const       { return fStack;    } // Stack position of the chamber in TRD
+  Int_t    GetSM() const          { return fSM;       } // Super module of the TRD
+  Short_t *GetArray() const       { return (Short_t*)fSortedIndex; } // Get the array pointer for god knows what reason
+  Int_t    GetNoOfIndexes() const { return fCountRC-1;  }
 
-  void SetLayer(Int_t ix) 
-  { 
-    // Set which layer
-    fLayer = ix;
-  };
+  Bool_t   HasEntry() const       { return fCountRC > 1 ? kTRUE : kFALSE; } // Return status if has an entry
+
+  Int_t    GetNrow() const        { return fNrows;    } // Get Nrows
+  Int_t    GetNcol() const        { return fNcols;    } // Get Ncols
+  Int_t    GetNtime() const       { return fNtbins;   } // Get Ntbins
+
+ private:
 
-  void SetPlane(Int_t ix) 
-  {
-    // aka set plane
-    SetLayer(ix);
-  }
-
-  void SetDetNumber(Int_t ix)
-  {
-    // Set Det Number
-    fDet = ix;
-  }
+  Int_t     fDet;                //  Detector number
+  Int_t     fLayer;              //  Layer position in the full TRD
+  Int_t     fStack;              //  Stack position in the full TRD
+  Int_t     fSM;                 //  Super module - position in the full TRD
+
+  Bool_t   *fBoolIndex;          //  Indices
+  RowCol   *fSortedIndex;        //  Sorted indices
+  Int_t     fMaxLimit;           //  Max number of things in the array
+  Int_t     fPositionRC;         //  Position in the SortedIndex
+  Int_t     fCountRC;            //  the number of added rc combinations
+  Bool_t    fSortedWasInit;      //  Was SortedIndex initialized?
+
+  Int_t     fCurrRow;            //  Last Row read out of SortedIndex
+  Int_t     fCurrCol;            //  Last Col read out of SortedIndex
+  Int_t     fCurrTbin;           //  Last outgiven Tbin
   
-  virtual Int_t GetDetNumber() const {return fDet;} // Get Det number
-  virtual Int_t GetLayer() const     {return fLayer;} // Layer = Plane = position of the chamber in TRD
-  virtual Int_t GetPlane() const     {return fLayer;} // Layer = Plane = position of the chamber in TRD
-  virtual Int_t GetStack() const     {return fStack;} // Stack = Chameber = position of the chamber in TRD
-  virtual Int_t GetChamber() const   {return fStack;} // Stack = Chameber = position of the chamber in TRD
-  virtual Int_t GetSM() const        {return fSM;} // Super module of the TRD
+  Int_t     fNrows;              //  Number of rows in the chamber
+  Int_t     fNcols;              //  Number of cols in the chamber
+  Int_t     fNtbins;             //  Number of tbins in the chamber 
 
-  virtual Bool_t HasEntry() const    {return fHasEntry;} // Return status if has an entry
+  ClassDef(AliTRDSignalIndex,2)  //  Data container for one TRD detector segment
 
-          TArrayI *GetArray() const  {return fIndex;} // Get the tarrayi pointer for god knows what reason
+};
+#endif
 
-  virtual Int_t GetNrow() const      {return fNrows;} // Get Nrows
-  virtual Int_t GetNcol() const      {return fNcols;} // Get Ncols
-  virtual Int_t GetNtime() const     {return fNtbins;} // Get Ntbins
+/*
+Comment from 22 Dec 2008
 
-  //enum { kMaxRows = 16, kMaxTbins = 24, kMaxCols = 144};
+The structure of the Index was changed. Now no Tbin is saved anymore,
+only RC combination are saved! (reasons see below)
 
- private:
+For the readout, all tbins for a RC combination must be read out to find 
+the time bin of signal > 0.
 
-  Int_t   fDet;  // det number
-  Int_t   fLayer; // aka plane - position in the full TRD
-  Int_t   fStack; // aka chamber - position in the full TRD
-  Int_t   fSM; // super module - position in the full TRD
+THE WRITING PROCEDURE:
+AddIndexTBin is now obsolate, use AddIndexRC instead as AddIndexTBin will
+be deleted in future.
 
- protected:
+example that gives exactely the same output as before:
+as it was: 
+           AliTRDSignalIndexes *indexes;
+           AliTRDarrayADC *Signal; //or AliTRDarraySignal *Signal;
+          if(Signal->GetDataB(row, col, time)>0)
+               indexes->AddIndexTBin(row, col, time);
 
-  TArrayI  *fIndex; //! monitor active pads and tbins
+as it should be from no on: 
+           AliTRDSignalIndexes *indexes;
+           AliTRDarrayADC *Signal; //or AliTRDarraySignal *Signal;
+          if(Signal->GetDataB(row, col, time)>0)
+               indexes->AddIndexRC(row, col);
 
-  Int_t    fPositionRow; // position in the index - jumps by 1 + 1 + fNtbins
-  Int_t    fPositionCol; // position in the index - jumps by 1 + 1 + fNtbins
-  Int_t    fPositionTbin; // position in the tbin - goes from 0 to fNtbins
 
-  Int_t    fLastRow; // to keep track what is the RC combination
-  Int_t    fLastCol; // to keep track what is the RC combination
-  Int_t    fLastTbin; // to keep track what is the Tbin - will catch if raw data bogus
 
-  Int_t    fNrows; // number of rows in the chamber
-  Int_t    fNcols; // number of cols in the chamber
-  Int_t    fNtbins; // number of tbins in the chamber
+THE READING PROCEDURE:
+In most cases you can leave anything as it is.
+See more in the example.
 
-  Int_t    fMaxLimit; // max number of things in the array  = nrow * ncol * ntime + nrow * ncol * 2
+example:
+as it was: 
+           AliTRDSignalIndexes *indexes;
+           AliTRDarraySignal *Signal;
+           while(indexes->NextRCTbinIndex(row, col, time)) 
+           {...}
 
-  Bool_t   fResetCounters; // reset counter status
+as it should be from no on to get the exactely the same output as before: 
+           AliTRDSignalIndexes *indexes;
+           AliTRDarraySignal *Signal;
+           while(indexes->NextRCTbinIndex(row, col, time)) 
+              if(Signal->GetData(row, col, time)>0)
+                 {...}
 
-  Bool_t   fHasEntry; // kTRUE flag if we have an entry 
+as it should be idealy:
+           AliTRDSignalIndexes *indexes;
+           AliTRDarraySignal *Signal;
+           for(time = 0; time < Ntime; time++)
+              while(indexes->NextRCIndex(row, col, time)) 
+                 if(Signal->GetData(row, col, time)>0)
+                    {...}
 
-  ClassDef(AliTRDSignalIndex,1)      // Data container for one TRD detector segment
 
-};
-#endif
+REASON OF THE CHANGES:
+
+The array saved the information nicely, but it turned out that sorting 
+the array by column would have many benefits.
+I.e. it is crucial for fivePadClusters and it if much faster to allocate.
+But the sorting is not fast if the tbin is also saved.
+Moreover the tbin information was alsmost useless because, 
+whenever an RC index existed, many of the possible tbins where used.
+
+Theodor Rascanu
+
+*/