]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RAW/AliAltroBuffer.h
AliMDC and DB classes moved from library to alimdc executable
[u/mrichter/AliRoot.git] / RAW / AliAltroBuffer.h
1 /* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
2  * See cxx source for full Copyright notice                               */
3
4 /////////////////////////////////////////////////////
5 // Class used for read-write the ALTRO data format //
6 /////////////////////////////////////////////////////
7
8 /*This class is an interface between the altro format file and the 
9   user, and can be used in write or read mode
10   In the write mode a new altro file is created and filled using the method FillBuffer().
11   The name of the file is specified as parameter in the constructor as well as the type mode.
12   In the Read mode the specified file is open and the values can be read using the
13   methods GetNext() and GetNextBackWord().
14   The first method is used to read the file forward while the second is used to read backward 
15 */
16
17 #ifndef AliALTROBUFFER_H
18 #define AliALTROBUFFER_H
19
20 #include <TObject.h>
21 #ifdef __CINT__
22 class fstream;
23 #else
24 #include "Riostream.h"
25 #endif
26
27
28 class AliAltroBuffer: public TObject {
29  public:
30   AliAltroBuffer(const char* fileName, Int_t flag);
31   virtual ~AliAltroBuffer();
32
33   void  FillBuffer(Int_t val);
34   //this method stores a word into the buffer
35   Int_t GetFreeCellNumber()const {return fFreeCellBuffer;}
36   //this method returns the number of free cells of the internal buffer
37   Int_t GetNextBackWord();
38   //this method returns the next word of 10 bit (reading the file backward) if it exists -1 otherwise
39   Int_t GetNext();
40   //this method returns the next word of 10 bit (reading the file forward) if it exists -1 otherwise
41
42   void  WriteTrailer(Int_t wordsNumber, Int_t padNumber, 
43                      Int_t rowNumber, Int_t secNumber);
44   //this method is used to write the trailer
45   Bool_t ReadTrailer(Int_t& wordsNumber, Int_t& padNumber, 
46                      Int_t& rowNumber, Int_t &secNumber);
47   //this method is used to read the trailer when the file is read forward
48   Bool_t ReadTrailerBackward(Int_t& wordsNumber, Int_t& padNumber, 
49                              Int_t& rowNumber, Int_t& secNumber);
50   //this method is used to read the trailer when the file is read backward
51
52   void  WriteChannel(Int_t padNumber, Int_t rowNumber, Int_t secNumber,
53                      Int_t nTimeBins, const Int_t* adcValues, 
54                      Int_t threshold = 0);
55   //this method is used to write all ADC values and the trailer of a channel
56
57   void  WriteDataHeader(Bool_t dummy, Bool_t compressed);
58   //this method is used to write the data header
59   Bool_t ReadDataHeader();
60   //this method is used to read the data header
61   void  SetVerbose(Int_t val) {fVerbose = val;}
62   //this method is used to set the verbose level 
63   //level  0 no output messages
64   //level !=0 some messages are displayed during the run
65   void  Flush();
66   //this method is used to fill the buffer with 2AA hexadecimal value and save it into the output file
67   Int_t GetFillWordsNum() const {return fEndingFillWords;}
68
69  private:
70   AliAltroBuffer(const AliAltroBuffer& source);
71   AliAltroBuffer& operator = (const AliAltroBuffer& source);
72
73   UInt_t fBuffer[5];    //Buffer dimension is 32*5=160 bits and it contains 16 values
74                         //A value is never splitted in two Buffer
75
76
77   Int_t fShift;         //This variable contains the number of free bits in the current cell of
78                         //the Buffer after that the value Val is been inserted.
79                         //size of Int_t is 32 bit that is the same size of a cell of Buffer so 
80                         //the shift operation are performed only on value Val.
81   Int_t fCurrentCell;   //This variable contains the cell number of the cell currently used 
82   Int_t fFreeCellBuffer;//number of free cells of the buffer
83   Int_t fFlag;          //0 read  1 write
84   Int_t fVerbose;       //verbose level
85   fstream* fFile;       //logical name of the I/O file
86   Int_t fMaskBackward;  //bit mask for backward reading of a file
87   UInt_t fFilePosition;//'pointer' to the actual position in the file
88   UInt_t fFileEnd;     //position of the last element of the file (File dimension)
89   UInt_t fDataHeaderPos;//Data header position
90   Int_t  fEndingFillWords;//Few words at the end of the stream
91
92   ClassDef(AliAltroBuffer,0)  // Interface to the Altro format
93 };
94
95 #endif