Alice dependencies removed.
[u/mrichter/AliRoot.git] / HLT / src / AliL3MemHandler.h
CommitLineData
3e87ef69 1// @(#) $Id$
2
a8ffd46b 3#ifndef ALIL3_MEMHANDLER_H
4#define ALIL3_MEMHANDLER_H
108615fc 5
159a9e4e 6//_____________________________________________________________
7// AliL3MemHandler
8//
9// The HLT Binary File handler
10//
11// This class does all the memory I/O handling of HLT binary files.
12//
13// Author: Uli Frankenfeld <mailto:franken@fi.uib.no>,
14// Anders Vestbo <mailto:vestbo$fi.uib.no>,
15// Constantin Loizides <mailto:loizides@ikf.uni-frankfurt.de>
01c72956 16// *-- Copyright &copy ALICE HLT Group
494fad94 17
14e76e91 18class AliL3DigitData;
108615fc 19class AliL3SpacePointData;
20class AliL3DigitRowData;
21class AliL3TrackSegmentData;
22class AliL3TrackArray;
23class AliL3RandomPointData;
14e76e91 24class AliL3RandomDigitData;
108615fc 25
de3c3890 26#ifdef use_newio
27class AliRunLoader;
28#endif
a8ffd46b 29class AliTPCRawStream;
de3c3890 30
b1ed0288 31class AliL3MemHandler {
108615fc 32
108615fc 33 public:
34 AliL3MemHandler();
35 virtual ~AliL3MemHandler();
a8ffd46b 36 AliL3MemHandler(const AliL3MemHandler& /*m*/){};
37 AliL3MemHandler& operator=(const AliL3MemHandler& /*&m*/)
38 {return (*this);}
01c72956 39
108615fc 40 void Reset(){CloseBinaryInput();CloseBinaryOutput();Free();}
eeddc64d 41 void Init(Int_t s,Int_t p, Int_t *r=0);
108615fc 42
a8ffd46b 43 Bool_t SetBinaryInput(char *name);
108615fc 44 Bool_t SetBinaryInput(FILE *file);
45 void CloseBinaryInput();
46
a8ffd46b 47 Bool_t SetBinaryOutput(char *name);
108615fc 48 Bool_t SetBinaryOutput(FILE *file);
49 void CloseBinaryOutput();
50
51 //Random cluster
52 void SetRandomCluster(Int_t maxnumber);
53 void SetRandomSeed(UInt_t seed){srand(seed);}
54 void SetRandomSeed();
55
56 void ResetRandom(){fNDigits = 0; fNUsed = 0;}
57 void Generate(Int_t row);
58 void SetNGenerate(Int_t number){(number>fNRandom)?fNGenerate=fNRandom:fNGenerate = number;}
59
60 void SetROI(Float_t *eta,Int_t *slice);
61 void ResetROI();
62
63 //Digit IO
64 Bool_t Memory2Binary(UInt_t nrow,AliL3DigitRowData *data);
65 Bool_t Binary2Memory(UInt_t & nrow,AliL3DigitRowData *data);
66
67 Int_t Memory2CompMemory(UInt_t nrow,AliL3DigitRowData *data,UInt_t *comp);
68 Int_t CompMemory2Memory(UInt_t nrow,AliL3DigitRowData *data,UInt_t *comp);
69 Bool_t CompMemory2CompBinary(UInt_t nrow,UInt_t *comp, UInt_t size=0);
70 Bool_t CompBinary2CompMemory(UInt_t & nrow,UInt_t *comp);
71
256c7399 72 virtual AliL3DigitRowData *CompBinary2Memory(UInt_t & nrow);
73 virtual Bool_t Memory2CompBinary(UInt_t nrow,AliL3DigitRowData *data);
74
108615fc 75 UInt_t GetNRow(UInt_t *comp,UInt_t size);
76
77 //Point IO
78 Bool_t Memory2Binary(UInt_t npoint,AliL3SpacePointData *data);
79 Bool_t Binary2Memory(UInt_t & npoint,AliL3SpacePointData *data);
c51c6aaa 80 Bool_t Transform(UInt_t npoint,AliL3SpacePointData *data,Int_t slice);
a830c5a6 81 static void UpdateRowPointer(AliL3DigitRowData *&tempPt);
9bd4d591 82
108615fc 83 //Track IO
84 Bool_t Memory2Binary(UInt_t ntrack,AliL3TrackSegmentData *data);
85 Bool_t Binary2Memory(UInt_t & ntrack,AliL3TrackSegmentData *data);
86 Bool_t TrackArray2Binary(AliL3TrackArray *array);
87 Bool_t Binary2TrackArray(AliL3TrackArray *array);
b1ed0288 88 Bool_t TrackArray2Memory(UInt_t & ntrack,AliL3TrackSegmentData *data,AliL3TrackArray *array) const;
89 Bool_t Memory2TrackArray(UInt_t ntrack,AliL3TrackSegmentData *data,AliL3TrackArray *array) const;
90 Bool_t Memory2TrackArray(UInt_t ntrack,AliL3TrackSegmentData *data,AliL3TrackArray *array,Int_t slice) const;
4499ed26 91
108615fc 92 //Memory Allocation
b1ed0288 93 UInt_t GetAllocatedSize() const {return fSize;}
108615fc 94 UInt_t GetFileSize();
b1ed0288 95 UInt_t GetMemorySize(UInt_t nrow,UInt_t *comp) const;
96 UInt_t GetCompMemorySize(UInt_t nrow,AliL3DigitRowData *data) const;
97 UInt_t GetRandomSize() const;
108615fc 98
99 Byte_t *Allocate(UInt_t size);
100 Byte_t *Allocate(); // allocate size of Binary Input File
101 Byte_t *Allocate(AliL3TrackArray *array);
b661165c 102 Byte_t *GetDataPointer(UInt_t &size) {size = fSize; return fPt;}
3e87ef69 103 FILE *GetFilePointer() {return fInBinary;}
108615fc 104 void Free();
105
f8bc0cc9 106 //Getters:
b1ed0288 107 Int_t GetRowMin() const {return fRowMin;}
108 Int_t GetRowMax() const {return fRowMax;}
109 Int_t GetSlice() const {return fSlice;}
110 Int_t GetPatch() const {return fPatch;}
f8bc0cc9 111
112 //virtual functions:
01c72956 113 virtual void FreeDigitsTree() {fDummy=0; return;}
a8ffd46b 114 virtual Bool_t SetAliInput(char */*name*/){fDummy=0; return 0;}
de3c3890 115#ifdef use_newio
01c72956 116 virtual Bool_t SetAliInput(AliRunLoader */*runloader*/){fDummy=0; return 0;}
de3c3890 117#endif
01c72956 118 virtual void CloseAliInput(){fDummy=0; return;}
119 virtual Bool_t IsDigit(Int_t /*i*/=0){fDummy=0; return 0;}
a8ffd46b 120 virtual Bool_t SetMCOutput(char */*name*/){fDummy=0; return 0;}
01c72956 121 virtual Bool_t SetMCOutput(FILE */*file*/){fDummy=0; return 0;}
122 virtual void CloseMCOutput(){fDummy=0; return;}
123 virtual Bool_t AliDigits2Binary(Int_t /*event*/=0,Bool_t /*altro*/=kFALSE){fDummy=0; return 0;}
124 virtual Bool_t AliDigits2CompBinary(Int_t /*event*/=0,Bool_t /*altro*/=kFALSE){fDummy=0; return 0;}
125 virtual AliL3DigitRowData *AliDigits2Memory(UInt_t & /*nrow*/,Int_t /*event*/=0){fDummy=0; return 0;}
126 virtual AliL3DigitRowData *AliAltroDigits2Memory(UInt_t & /*nrow*/,Int_t /*event*/=0,Bool_t /*eventmerge*/=kFALSE){fDummy=0; return 0;}
127 virtual void AliDigits2RootFile(AliL3DigitRowData */*rowPt*/,Char_t */*new_digitsfile*/){fDummy=0; return;}
128 virtual Bool_t AliPoints2Binary(Int_t /*eventn*/=0){fDummy=0; return 0;}
129 virtual AliL3SpacePointData *AliPoints2Memory(UInt_t & /*npoint*/,Int_t /*eventn*/=0){fDummy=0; return 0;}
3e87ef69 130
131 //AliL3RawDataFileHandler
01c72956 132 virtual Bool_t SetRawInput(Char_t */*name*/){fDummy=0; return 0;}
133 virtual Bool_t SetRawInput(ifstream */*file*/){fDummy=0; return 0;}
3e87ef69 134 virtual void CloseRawInput(){}
01c72956 135 virtual Int_t ReadRawInput(){fDummy=0; return 0;}
136 virtual Short_t** GetRawData(Int_t &/*channels*/, Int_t & /*timebins*/){fDummy=0; return 0;}
3e87ef69 137
01c72956 138 virtual Bool_t SetRawOutput(Char_t */*name*/){fDummy=0; return 0;}
139 virtual Bool_t SetRawOutput(ofstream */*file*/){fDummy=0; return 0;}
3e87ef69 140 virtual void CloseRawOutput(){}
01c72956 141 virtual Bool_t SaveRawOutput(){fDummy=0; return 0;}
3e87ef69 142
01c72956 143 virtual Bool_t SetMappingFile(Char_t */*name*/){fDummy=0; return 0;}
144 virtual Bool_t SetMappingFile(FILE */*file*/){fDummy=0; return 0;}
3e87ef69 145 virtual void CloseMappingFile(){}
01c72956 146 virtual Int_t ReadMappingFile(){fDummy=0; return 0;}
3e87ef69 147
01c72956 148 virtual Bool_t SetRawPedestalsInput(Char_t */*name*/){fDummy=0; return 0;}
149 virtual Bool_t SetRawPedestalsInput(ifstream */*file*/){fDummy=0; return 0;}
3e87ef69 150 virtual void CloseRawPedestalsInput(){}
01c72956 151 virtual Int_t ReadRawPedestalsInput(){fDummy=0; return 0;}
3e87ef69 152
01c72956 153 virtual AliL3DigitRowData* RawData2Memory(UInt_t &/*nrow*/,Int_t /*event*/=-1){fDummy=0; return 0;}
154 virtual Bool_t RawData2CompMemory(Int_t /*event*/=-1){fDummy=0; return 0;}
240d63be 155
156 //AliL3DDLDataFileHandler
b2a02bce 157#ifdef use_newio
01c72956 158 virtual Bool_t SetReaderInput(Char_t */*name*/,Int_t /*event*/=0){fDummy=0; return 0;}
b2a02bce 159#else
01c72956 160 virtual Bool_t SetReaderInput(Char_t */*name*/,Bool_t /*add*/=kTRUE){fDummy=0; return 0;}
b2a02bce 161#endif
240d63be 162 virtual void CloseReaderInput(){};
163
01c72956 164 virtual AliL3DigitRowData* DDLData2Memory(UInt_t &/*nrow*/,Int_t /*event*/=-1){fDummy=0; return 0;}
165 virtual Bool_t DDLData2CompBinary(Int_t /*event*/=-1){fDummy=0; return 0;}
f8bc0cc9 166
a8ffd46b 167 virtual AliTPCRawStream* GetTPCRawStream(){fDummy=0; return 0;}
168
159a9e4e 169 protected:
170 Int_t fRowMin; //min row
171 Int_t fRowMax; //max row
172 Int_t fSlice; //slice
173 Int_t fPatch; //patch
174
175 Int_t fEtaMinTimeBin[159]; //for ROI in eta only
176 Int_t fEtaMaxTimeBin[159]; //for ROI in eta only
177
178 FILE *fInBinary;//!
179 FILE *fOutBinary;//!
180
181 private:
182
183 Byte_t *fPt;//!
184 UInt_t fSize; //size of allocated data structure
185
159a9e4e 186 Bool_t fIsRandom; //random data generated
187 Int_t fNRandom; //count random digits
188 Int_t fNGenerate; //count generated digits
189 Int_t fNUsed; //count used digits
190 Int_t fNDigits; //count digits from digitstree
191
01c72956 192 AliL3RandomDigitData **fDPt;//!
193 AliL3RandomDigitData *fRandomDigits;//!
194
195 Int_t fDummy; // to fool the virtual const problem
196 // of the coding conventions tool
197
159a9e4e 198 void Write(UInt_t *comp, UInt_t & index, UInt_t & subindex, UShort_t value) const;
199 UShort_t Read(UInt_t *comp, UInt_t & index, UInt_t & subindex) const;
200 UShort_t Test(UInt_t *comp, UInt_t index, UInt_t subindex) const;
201
202 void DigitizePoint(Int_t row,Int_t pad, Int_t time,Int_t charge);
203 void QSort(AliL3RandomDigitData **a, Int_t first, Int_t last);
204 Int_t ComparePoints(UInt_t row,UShort_t pad,UShort_t time) const ;
205 Int_t CompareDigits(AliL3RandomDigitData *a,AliL3RandomDigitData *b) const;
206 void AddData(AliL3DigitData *data,UInt_t & ndata,
207 UInt_t row,UShort_t pad,UShort_t time,UShort_t charge) const;
208 void AddRandom(AliL3DigitData *data,UInt_t & ndata);
209 void MergeDataRandom(AliL3DigitData *data,UInt_t & ndata,
210 UInt_t row,UShort_t pad,UShort_t time,UShort_t charge);
211 void AddDataRandom(AliL3DigitData *data,UInt_t & ndata,
212 UInt_t row,UShort_t pad,UShort_t time,UShort_t charge);
213
214
b661165c 215 ClassDef(AliL3MemHandler,1) // Memory handler class
108615fc 216};
108615fc 217#endif