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