ROOT logo
/* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

/////////////////////////////////////////////////////
// Class used for read-write the ALTRO data format //
/////////////////////////////////////////////////////

/*This class is an interface between the altro format file and the 
  user, and can be used in write or read mode
  In the write mode a new altro file is created and filled using the method FillBuffer().
  The name of the file is specified as parameter in the constructor as well as the type mode.
  In the Read mode the specified file is open and the values can be read using the
  methods GetNext() and GetNextBackWord().
  The first method is used to read the file forward while the second is used to read backward 
*/

#ifndef AliALTROBUFFER_H
#define AliALTROBUFFER_H

#include <TObject.h>

class AliFstream;

class AliAltroMapping;

class AliAltroBuffer: public TObject {
 public:
  AliAltroBuffer(const char* fileName, AliAltroMapping *mapping = NULL);
  virtual ~AliAltroBuffer();

  virtual void  FillBuffer(Int_t val);
  //this method stores a word into the buffer

  void  WriteTrailer(Int_t wordsNumber, Int_t padNumber, 
		     Int_t rowNumber, Int_t secNumber);
  //this method is used to write the trailer
  virtual void  WriteTrailer(Int_t wordsNumber, Short_t hwAddress); 
  //this method is used to write the trailer

  void  WriteChannel(Int_t padNumber, Int_t rowNumber, Int_t secNumber,
		     Int_t nTimeBins, const Int_t* adcValues, 
		     Int_t threshold = 0);
  //this method is used to write all ADC values and the trailer of a channel
  void  WriteChannel(Short_t hwAddress,
		     Int_t nTimeBins, const Int_t* adcValues, 
		     Int_t threshold = 0);
  //this method is used to write all ADC values and the trailer of a channel
  Int_t WriteBunch(Int_t nTimeBins, const Int_t* adcValues,
		   Int_t threshold = 0);
  //this method is used to write all ADC values

  void  WriteDataHeader(Bool_t dummy, Bool_t compressed);
  //this method is used to write the data header

  virtual UChar_t WriteRCUTrailer(Int_t rcuId);
  //this method is used to write the RCU trailer

  void  SetVerbose(Int_t val) {fVerbose = val;}
  //this method is used to set the verbose level 
  //level  0 no output messages
  //level !=0 some messages are displayed during the run
  void  Flush();
  //this method is used to fill the buffer with 2AA hexadecimal value and save it into the output file

  void  SetMapping(AliAltroMapping *mapping) { fMapping = mapping; }

 protected:
  AliAltroBuffer(const AliAltroBuffer& source);
  AliAltroBuffer& operator = (const AliAltroBuffer& source);

  UInt_t fBuffer[5];    //Buffer dimension is 32*5=160 bits and it contains 16 values
                        //A value is never splitted in two Buffer


  Int_t fShift;         //This variable contains the number of free bits in the current cell of
                        //the Buffer after that the value Val is been inserted.
                        //size of Int_t is 32 bit that is the same size of a cell of Buffer so 
                        //the shift operation are performed only on value Val.
  Int_t fCurrentCell;   //This variable contains the cell number of the cell currently used 
  Int_t fFreeCellBuffer;//number of free cells of the buffer
  Int_t fVerbose;       //verbose level
  AliFstream* fFile;    //logical name of the I/O file
  UInt_t fDataHeaderPos;//Data header position

  // Now the parameters for the mapping
  AliAltroMapping*    fMapping;      // Pointer to the mapping handler

  ClassDef(AliAltroBuffer,0)  // Interface to the Altro format
};

#endif
 AliAltroBuffer.h:1
 AliAltroBuffer.h:2
 AliAltroBuffer.h:3
 AliAltroBuffer.h:4
 AliAltroBuffer.h:5
 AliAltroBuffer.h:6
 AliAltroBuffer.h:7
 AliAltroBuffer.h:8
 AliAltroBuffer.h:9
 AliAltroBuffer.h:10
 AliAltroBuffer.h:11
 AliAltroBuffer.h:12
 AliAltroBuffer.h:13
 AliAltroBuffer.h:14
 AliAltroBuffer.h:15
 AliAltroBuffer.h:16
 AliAltroBuffer.h:17
 AliAltroBuffer.h:18
 AliAltroBuffer.h:19
 AliAltroBuffer.h:20
 AliAltroBuffer.h:21
 AliAltroBuffer.h:22
 AliAltroBuffer.h:23
 AliAltroBuffer.h:24
 AliAltroBuffer.h:25
 AliAltroBuffer.h:26
 AliAltroBuffer.h:27
 AliAltroBuffer.h:28
 AliAltroBuffer.h:29
 AliAltroBuffer.h:30
 AliAltroBuffer.h:31
 AliAltroBuffer.h:32
 AliAltroBuffer.h:33
 AliAltroBuffer.h:34
 AliAltroBuffer.h:35
 AliAltroBuffer.h:36
 AliAltroBuffer.h:37
 AliAltroBuffer.h:38
 AliAltroBuffer.h:39
 AliAltroBuffer.h:40
 AliAltroBuffer.h:41
 AliAltroBuffer.h:42
 AliAltroBuffer.h:43
 AliAltroBuffer.h:44
 AliAltroBuffer.h:45
 AliAltroBuffer.h:46
 AliAltroBuffer.h:47
 AliAltroBuffer.h:48
 AliAltroBuffer.h:49
 AliAltroBuffer.h:50
 AliAltroBuffer.h:51
 AliAltroBuffer.h:52
 AliAltroBuffer.h:53
 AliAltroBuffer.h:54
 AliAltroBuffer.h:55
 AliAltroBuffer.h:56
 AliAltroBuffer.h:57
 AliAltroBuffer.h:58
 AliAltroBuffer.h:59
 AliAltroBuffer.h:60
 AliAltroBuffer.h:61
 AliAltroBuffer.h:62
 AliAltroBuffer.h:63
 AliAltroBuffer.h:64
 AliAltroBuffer.h:65
 AliAltroBuffer.h:66
 AliAltroBuffer.h:67
 AliAltroBuffer.h:68
 AliAltroBuffer.h:69
 AliAltroBuffer.h:70
 AliAltroBuffer.h:71
 AliAltroBuffer.h:72
 AliAltroBuffer.h:73
 AliAltroBuffer.h:74
 AliAltroBuffer.h:75
 AliAltroBuffer.h:76
 AliAltroBuffer.h:77
 AliAltroBuffer.h:78
 AliAltroBuffer.h:79
 AliAltroBuffer.h:80
 AliAltroBuffer.h:81
 AliAltroBuffer.h:82
 AliAltroBuffer.h:83
 AliAltroBuffer.h:84
 AliAltroBuffer.h:85
 AliAltroBuffer.h:86
 AliAltroBuffer.h:87
 AliAltroBuffer.h:88
 AliAltroBuffer.h:89
 AliAltroBuffer.h:90
 AliAltroBuffer.h:91