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