Crrected versions of AliAltroBuffer, AliAltroMapping and AliTPCRawStream
[u/mrichter/AliRoot.git] / RAW / AliAltroBuffer.h
CommitLineData
3ea47630 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__
22class fstream;
23#else
24#include "Riostream.h"
25#endif
26
5802cf2d 27class AliAltroMapping;
3ea47630 28
29class AliAltroBuffer: public TObject {
30 public:
5802cf2d 31 AliAltroBuffer(const char* fileName, Int_t flag, const AliAltroMapping *mapping = NULL);
3ea47630 32 virtual ~AliAltroBuffer();
33
34 void FillBuffer(Int_t val);
35 //this method stores a word into the buffer
36 Int_t GetFreeCellNumber()const {return fFreeCellBuffer;}
37 //this method returns the number of free cells of the internal buffer
38 Int_t GetNextBackWord();
39 //this method returns the next word of 10 bit (reading the file backward) if it exists -1 otherwise
40 Int_t GetNext();
41 //this method returns the next word of 10 bit (reading the file forward) if it exists -1 otherwise
42
43 void WriteTrailer(Int_t wordsNumber, Int_t padNumber,
44 Int_t rowNumber, Int_t secNumber);
45 //this method is used to write the trailer
cc934096 46 void WriteTrailer(Int_t wordsNumber, Short_t hwAddress);
20daa34d 47 //this method is used to write the trailer
5802cf2d 48 void WriteDummyTrailer(Int_t wordsNumber, Int_t padNumber,
49 Int_t rowNumber, Int_t secNumber);
50 //this method is used to write a dummy trailer
3ea47630 51 Bool_t ReadTrailer(Int_t& wordsNumber, Int_t& padNumber,
52 Int_t& rowNumber, Int_t &secNumber);
53 //this method is used to read the trailer when the file is read forward
cc934096 54 Bool_t ReadTrailer(Int_t& wordsNumber, Short_t& hwAddress);
20daa34d 55 //this method is used to read the trailer when the file is read forward
16e29964 56 Bool_t ReadDummyTrailer(Int_t& wordsNumber, Int_t& padNumber,
57 Int_t& rowNumber, Int_t &secNumber);
58 //this method is used to read the trailer when the file is read forward
3ea47630 59 Bool_t ReadTrailerBackward(Int_t& wordsNumber, Int_t& padNumber,
60 Int_t& rowNumber, Int_t& secNumber);
61 //this method is used to read the trailer when the file is read backward
cc934096 62 Bool_t ReadTrailerBackward(Int_t& wordsNumber, Short_t& hwAddress);
20daa34d 63 //this method is used to read the trailer when the file is read backward
64 Bool_t ReadDummyTrailerBackward(Int_t& wordsNumber, Int_t& padNumber,
65 Int_t& rowNumber, Int_t& secNumber);
66 //this method is used to read the trailer when the file is read backward
3ea47630 67
68 void WriteChannel(Int_t padNumber, Int_t rowNumber, Int_t secNumber,
69 Int_t nTimeBins, const Int_t* adcValues,
70 Int_t threshold = 0);
71 //this method is used to write all ADC values and the trailer of a channel
cc934096 72 void WriteChannel(Short_t hwAddress,
73 Int_t nTimeBins, const Int_t* adcValues,
74 Int_t threshold = 0);
75 //this method is used to write all ADC values and the trailer of a channel
76 Int_t WriteBunch(Int_t nTimeBins, const Int_t* adcValues,
77 Int_t threshold = 0);
78 //this method is used to write all ADC values
79 void ReadChannelBackward(Int_t& padNumber, Int_t& rowNumber, Int_t& secNumber,
80 Int_t& nTimeBins, Int_t* adcValues);
81 //this method is used to read all ADC values and the trailer of a channel
82 void ReadChannelBackward(Short_t& hwAddress,
83 Int_t& nTimeBins, Int_t* adcValues);
20daa34d 84 //this method is used to read all ADC values and the trailer of a channel
cc934096 85 void ReadBunchBackward(Int_t wordsNumber,
86 Int_t& nTimeBins, Int_t* adcValues);
87 //this method is used to read all ADC values
3ea47630 88
89 void WriteDataHeader(Bool_t dummy, Bool_t compressed);
90 //this method is used to write the data header
b0aef454 91 Bool_t ReadDataHeader();
92 //this method is used to read the data header
3ea47630 93 void SetVerbose(Int_t val) {fVerbose = val;}
94 //this method is used to set the verbose level
95 //level 0 no output messages
96 //level !=0 some messages are displayed during the run
97 void Flush();
98 //this method is used to fill the buffer with 2AA hexadecimal value and save it into the output file
99 Int_t GetFillWordsNum() const {return fEndingFillWords;}
100
16e29964 101 void SetMapping(AliAltroMapping *mapping) { fMapping = mapping; }
102
20daa34d 103 protected:
3ea47630 104 AliAltroBuffer(const AliAltroBuffer& source);
105 AliAltroBuffer& operator = (const AliAltroBuffer& source);
106
107 UInt_t fBuffer[5]; //Buffer dimension is 32*5=160 bits and it contains 16 values
108 //A value is never splitted in two Buffer
109
110
111 Int_t fShift; //This variable contains the number of free bits in the current cell of
112 //the Buffer after that the value Val is been inserted.
113 //size of Int_t is 32 bit that is the same size of a cell of Buffer so
114 //the shift operation are performed only on value Val.
115 Int_t fCurrentCell; //This variable contains the cell number of the cell currently used
116 Int_t fFreeCellBuffer;//number of free cells of the buffer
117 Int_t fFlag; //0 read 1 write
118 Int_t fVerbose; //verbose level
119 fstream* fFile; //logical name of the I/O file
120 Int_t fMaskBackward; //bit mask for backward reading of a file
121 UInt_t fFilePosition;//'pointer' to the actual position in the file
122 UInt_t fFileEnd; //position of the last element of the file (File dimension)
123 UInt_t fDataHeaderPos;//Data header position
124 Int_t fEndingFillWords;//Few words at the end of the stream
125
5802cf2d 126 // Now the parameters for the mapping
127 const AliAltroMapping* fMapping; // Pointer to the mapping handler
128
3ea47630 129 ClassDef(AliAltroBuffer,0) // Interface to the Altro format
130};
131
132#endif