]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/TPCLib/AliHLTTPCMemHandler.h
test if I have commit rights
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCMemHandler.h
index ee3faf6447fd05347f612d241bacda127aa36998..c8e7f3a13b6d557bd55d6d3fd87ec94366a164a1 100644 (file)
@@ -1,42 +1,94 @@
-// @(#) $Id$
-
-#ifndef ALIHLTTPC_MEMHANDLER_H
-#define ALIHLTTPC_MEMHANDLER_H
-
-//_____________________________________________________________
-// AliHLTTPCMemHandler
-//
-// The HLT Binary File handler 
-//
-//  This class does all the memory I/O handling of HLT binary files.
-//  
-// Author: Uli Frankenfeld <mailto:franken@fi.uib.no>, 
-//         Anders Vestbo <mailto:vestbo$fi.uib.no>, 
-//         Constantin Loizides <mailto:loizides@ikf.uni-frankfurt.de>
-// *-- Copyright &copy ALICE HLT Group 
-
-class AliHLTTPCDigitData;
-class AliHLTTPCSpacePointData;
-class AliHLTTPCDigitRowData;
-class AliHLTTPCTrackSegmentData;
-class AliHLTTPCTrackArray;
+// -*- Mode: C++ -*-
+// $Id$
+// Original: AliHLTMemHandler.h,v 1.30 2004/10/06 08:51:20 cvetan 
+#ifndef ALIHLTTPCMEMHANDLER_H
+#define ALIHLTTPCMEMHANDLER_H
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//* See cxx source for full Copyright notice                               *
+
+//  @file   AliHLTTPCMemHandler.h
+//  @author U. Frankenfeld, A. Vestbo, C. Loizides, maintained by
+//          Matthias Richter
+//  @date   
+//  @brief  input interface base class for the TPC tracking code before
+//          migration to the HLT component framework
+
+struct AliHLTTPCDigitData;
+struct AliHLTTPCSpacePointData;
+struct AliHLTTPCDigitRowData;
 class AliHLTTPCRandomPointData;
 class AliHLTTPCRandomDigitData;
 
-#ifdef use_newio
 class AliRunLoader;
 class AliRawEvent;
-#endif
 class AliTPCRawStream;
 
+/**
+ * @class AliHLTTPCMemHandler
+ * The HLT Binary File handler 
+ *
+ * This class is the old memory I/O handler of HLT binary files.
+ * Some functionality is still used in the current code, mainly
+ * conversion of TPC digits into the format understandable by the
+ * components.
+ * <pre>
+ *  Examples:
+ *  ---------
+ *
+ *  1) Reading a binary file:
+ *  
+ *  AliHLTTPCMemHandler file;
+ *  file.SetBinaryInput(filename);
+ *  file.Init(slice,patch);
+ *
+ *  UInt_t nrowss;
+ *  AliHLTTPCDigitRowData *data = file.CompBinary2Memory(nrows);
+ *  
+ *  for(int i=0; i<nrows; i++) 
+ *    {
+ *    
+ *    AliHLTTPCDigitData *dataPt = (AliHLTTPCDigitData*)data->fDigitData;
+ *    for(int j=0; j<data->fNDigit; j++) 
+ *      {
+ *        pad = dataPt[j].fPad;
+ *        time = dataPt[j].fTime;
+ *        charge = dataPt[j].fCharge;
+ *      }
+ *     
+ *    file.UpdateRowPointer(data);
+ *  
+ *    }
+ *  file.CloseBinaryInput();
+ *  ________________________
+ *  
+ *  2) Writing a binary file:
+ *  
+ *  //First of all you need to store the data in memory,
+ *  //and have a pointer to it of type AliHLTTPCDigitRowData.
+ *  //E.g. if you just want to write the data you read in example 1)
+ *  //into a new file, you can do the following:
+ *  
+ *  AliHLTTPCMemHandler newfile;
+ *  newfile.Init(slice,patch);
+ *  newfile.SetBinaryOutput(newfilename);
+ *  newfile.Memory2CompBinary((UInt_t)NumberOfRowsInPatch,(AliHLTTPCDigitRowData*)data);
+ *  newfile.CloseBinaryOutput();
+ *
+ *
+ * Compressed file format:
+ * -----------------------
+ *
+ * The data is RLE encoded and currently using _10_ bit range for the ADC-values.
+ * </pre>
+ *  
+ * @ingroup alihlt_tpc
+ */
 class AliHLTTPCMemHandler { 
 
  public:
   AliHLTTPCMemHandler();
   virtual ~AliHLTTPCMemHandler();
-  AliHLTTPCMemHandler(const AliHLTTPCMemHandler& /*m*/){};
-  AliHLTTPCMemHandler& operator=(const AliHLTTPCMemHandler& /*&m*/)
-    {return (*this);}
    
   void Reset(){CloseBinaryInput();CloseBinaryOutput();Free();}  
   void Init(Int_t s,Int_t p, Int_t *r=0);
@@ -55,45 +107,37 @@ class AliHLTTPCMemHandler {
   void SetRandomSeed();
 
   void ResetRandom(){fNDigits = 0; fNUsed = 0;}
-  void Generate(Int_t row);
   void SetNGenerate(Int_t number){(number>fNRandom)?fNGenerate=fNRandom:fNGenerate = number;}
 
-  void SetROI(Float_t *eta,Int_t *slice);
+  void SetROI(const Float_t *eta,Int_t *slice);
   void ResetROI();
 
-  //Digit IO
-  Bool_t Memory2Binary(UInt_t nrow,AliHLTTPCDigitRowData *data);
-  Bool_t Binary2Memory(UInt_t & nrow,AliHLTTPCDigitRowData *data, UInt_t& sz);
-  Bool_t Binary2Memory(UInt_t & nrow,AliHLTTPCDigitRowData *data){UInt_t tmp;return Binary2Memory(nrow,data,tmp);};
+  ////////////////////////////////////////////////////////////////////////////////////
+  //
+  // Digit IO
+
+  /**
+   * Write digit data to binary file.
+   * The function loops over the rows and dumps all data of the
+   * AliHLTTPCDigitRowData in binary format to the file.
+   * @param nrow    size of the array
+   * @param data    data array
+   * @return kTRUE if succeeded, kFALSE if error
+   */
+  Bool_t Memory2BinaryFile(UInt_t nrow,AliHLTTPCDigitRowData *data);
 
   Int_t Memory2CompMemory(UInt_t nrow,AliHLTTPCDigitRowData *data,UInt_t *comp);
-  Int_t CompMemory2Memory(UInt_t nrow,AliHLTTPCDigitRowData *data,UInt_t *comp,UInt_t& sz);
-  Int_t CompMemory2Memory(UInt_t nrow,AliHLTTPCDigitRowData *data,UInt_t *comp) {UInt_t tmp;return CompMemory2Memory(nrow,data,comp,tmp);};
   Bool_t CompMemory2CompBinary(UInt_t nrow,UInt_t *comp, UInt_t size=0);
-  Bool_t CompBinary2CompMemory(UInt_t & nrow,UInt_t *comp);
 
-  virtual AliHLTTPCDigitRowData *CompBinary2Memory(UInt_t & nrow, UInt_t& sz);
-  virtual AliHLTTPCDigitRowData *CompBinary2Memory(UInt_t & nrow){UInt_t tmp;return CompBinary2Memory(nrow,tmp);};
   virtual Bool_t Memory2CompBinary(UInt_t nrow,AliHLTTPCDigitRowData *data);
   
   UInt_t GetNRow(UInt_t *comp,UInt_t size);
 
   //Point IO
   Bool_t Memory2Binary(UInt_t npoint,AliHLTTPCSpacePointData *data);
-  Bool_t Binary2Memory(UInt_t & npoint,AliHLTTPCSpacePointData *data, UInt_t& sz);
-  Bool_t Binary2Memory(UInt_t & npoint,AliHLTTPCSpacePointData *data) {UInt_t tmp; return Binary2Memory(npoint,data,tmp);};
   Bool_t Transform(UInt_t npoint,AliHLTTPCSpacePointData *data,Int_t slice);
   static void UpdateRowPointer(AliHLTTPCDigitRowData *&tempPt);
   
-  //Track IO
-  Bool_t Memory2Binary(UInt_t ntrack,AliHLTTPCTrackSegmentData *data);
-  Bool_t Binary2Memory(UInt_t & ntrack,AliHLTTPCTrackSegmentData *data);
-  Bool_t TrackArray2Binary(AliHLTTPCTrackArray *array);
-  Bool_t Binary2TrackArray(AliHLTTPCTrackArray *array);
-  Bool_t TrackArray2Memory(UInt_t & ntrack,AliHLTTPCTrackSegmentData *data,AliHLTTPCTrackArray *array) const;
-  Bool_t Memory2TrackArray(UInt_t ntrack,AliHLTTPCTrackSegmentData *data,AliHLTTPCTrackArray *array) const;
-  Bool_t Memory2TrackArray(UInt_t ntrack,AliHLTTPCTrackSegmentData *data,AliHLTTPCTrackArray *array,Int_t slice) const;
-    
   //Memory Allocation
   UInt_t GetAllocatedSize() const {return fSize;}  
   UInt_t GetFileSize();
@@ -103,9 +147,8 @@ class AliHLTTPCMemHandler {
 
   Byte_t *Allocate(UInt_t size);
   Byte_t *Allocate();  // allocate size of Binary Input File
-  Byte_t *Allocate(AliHLTTPCTrackArray *array);
-  Byte_t *GetDataPointer(UInt_t &size) {size = fSize; return fPt;}
-  FILE *GetFilePointer() {return fInBinary;}
+  Byte_t *GetDataPointer(UInt_t &size) const {size = fSize; return fPt;}
+  FILE *GetFilePointer() const {return fInBinary;}
   void   Free();
   
   //Getters:
@@ -117,9 +160,7 @@ class AliHLTTPCMemHandler {
   //virtual functions:
   virtual void FreeDigitsTree() {fDummy=0; return;}
   virtual Bool_t SetAliInput(char */*name*/){fDummy=0; return 0;}
-#ifdef use_newio
   virtual Bool_t SetAliInput(AliRunLoader */*runloader*/){fDummy=0; return 0;}
-#endif
   virtual void CloseAliInput(){fDummy=0; return;} 
   virtual Bool_t IsDigit(Int_t /*i*/=0){fDummy=0; return 0;}
   virtual Bool_t SetMCOutput(char */*name*/){fDummy=0; return 0;}
@@ -159,12 +200,8 @@ class AliHLTTPCMemHandler {
   virtual Bool_t RawData2CompMemory(Int_t /*event*/=-1){fDummy=0; return 0;}
 
   //AliHLTTPCDDLDataFileHandler
-#ifdef use_newio
   virtual Bool_t SetReaderInput(AliRawEvent */*rawevent*/){fDummy=0; return 0;}
   virtual Bool_t SetReaderInput(Char_t */*name*/,Int_t /*event*/=0){fDummy=0; return 0;}
-#else
-  virtual Bool_t SetReaderInput(Char_t */*name*/,Bool_t /*add*/=kTRUE){fDummy=0; return 0;}
-#endif
   virtual void CloseReaderInput(){};
 
   virtual AliHLTTPCDigitRowData* DDLData2Memory(UInt_t &/*nrow*/,Int_t /*event*/=-1){fDummy=0; return 0;}
@@ -178,13 +215,20 @@ class AliHLTTPCMemHandler {
   Int_t fSlice;  //slice
   Int_t fPatch;  //patch
 
-  Int_t fEtaMinTimeBin[159]; //for ROI in eta only
-  Int_t fEtaMaxTimeBin[159]; //for ROI in eta only
+  static const Int_t fgkNSlice = 36; //!
+  static const Int_t fgkNRow = 159; //!
+
+  Int_t fEtaMinTimeBin[fgkNRow]; //for ROI in eta only
+  Int_t fEtaMaxTimeBin[fgkNRow]; //for ROI in eta only
   
   FILE *fInBinary;//!
   FILE *fOutBinary;//!
 
  private:
+  /** copy constructor prohibited */
+  AliHLTTPCMemHandler(const AliHLTTPCMemHandler& src);
+  /** assignment operator prohibited */
+  AliHLTTPCMemHandler& operator=(const AliHLTTPCMemHandler& src);
   
   Byte_t *fPt;//!
   UInt_t fSize; //size of allocated data structure
@@ -203,12 +247,12 @@ class AliHLTTPCMemHandler {
 
   void Write(UInt_t *comp, UInt_t & index, UInt_t & subindex, UShort_t value) const;
   UShort_t Read(UInt_t *comp, UInt_t & index, UInt_t & subindex) const;
-  UShort_t Test(UInt_t *comp, UInt_t index, UInt_t subindex) const; 
+  UShort_t Test(const UInt_t *comp, UInt_t index, UInt_t subindex) const; 
   
   void DigitizePoint(Int_t row,Int_t pad, Int_t time,Int_t charge);
   void QSort(AliHLTTPCRandomDigitData **a, Int_t first, Int_t last);
   Int_t ComparePoints(UInt_t row,UShort_t pad,UShort_t time) const ;
-  Int_t CompareDigits(AliHLTTPCRandomDigitData *a,AliHLTTPCRandomDigitData *b) const;
+  Int_t CompareDigits(const AliHLTTPCRandomDigitData *a, const AliHLTTPCRandomDigitData *b) const;
   void AddData(AliHLTTPCDigitData *data,UInt_t & ndata,
                       UInt_t row,UShort_t pad,UShort_t time,UShort_t charge) const;
   void AddRandom(AliHLTTPCDigitData *data,UInt_t & ndata);
@@ -218,6 +262,6 @@ class AliHLTTPCMemHandler {
                       UInt_t row,UShort_t pad,UShort_t time,UShort_t charge);
 
 
-  ClassDef(AliHLTTPCMemHandler,1) // Memory handler class
+  ClassDef(AliHLTTPCMemHandler,0) // Memory handler class
 };
 #endif