]>
Commit | Line | Data |
---|---|---|
a6c02c85 | 1 | // @(#) $Id$ |
4aa41877 | 2 | // Original: AliHLTMemHandler.h,v 1.30 2004/10/06 08:51:20 cvetan |
a6c02c85 | 3 | #ifndef ALIHLTTPC_MEMHANDLER_H |
4 | #define ALIHLTTPC_MEMHANDLER_H | |
297174de | 5 | //* This file is property of and copyright by the ALICE HLT Project * |
6 | //* ALICE Experiment at CERN, All rights reserved. * | |
7 | //* See cxx source for full Copyright notice * | |
5578cf60 | 8 | |
9 | /** @file AliHLTTPCMemHandler.h | |
10 | @author U. Frankenfeld, A. Vestbo, C. Loizides, maintained by | |
11 | Matthias Richter | |
12 | @date | |
13 | @brief input interface base class for the TPC tracking code before | |
14 | migration to the HLT component framework | |
297174de | 15 | */ |
a6c02c85 | 16 | |
17 | class AliHLTTPCDigitData; | |
18 | class AliHLTTPCSpacePointData; | |
19 | class AliHLTTPCDigitRowData; | |
20 | class AliHLTTPCTrackSegmentData; | |
21 | class AliHLTTPCTrackArray; | |
22 | class AliHLTTPCRandomPointData; | |
23 | class AliHLTTPCRandomDigitData; | |
24 | ||
a6c02c85 | 25 | class AliRunLoader; |
26 | class AliRawEvent; | |
e419b223 | 27 | #include "AliTPCRawStream.h" |
a6c02c85 | 28 | |
297174de | 29 | /** |
30 | * @class AliHLTTPCMemHandler | |
31 | * The HLT Binary File handler | |
32 | * | |
33 | * This class is the old memory I/O handler of HLT binary files. | |
34 | * Some functionality is still used in the current code, mainly | |
35 | * conversion of TPC digits into the format understandable by the | |
36 | * components. | |
37 | * <pre> | |
38 | * Examples: | |
39 | * --------- | |
40 | * | |
41 | * 1) Reading a binary file: | |
42 | * | |
43 | * AliHLTTPCMemHandler file; | |
44 | * file.SetBinaryInput(filename); | |
45 | * file.Init(slice,patch); | |
46 | * | |
47 | * UInt_t nrowss; | |
48 | * AliHLTTPCDigitRowData *data = file.CompBinary2Memory(nrows); | |
49 | * | |
50 | * for(int i=0; i<nrows; i++) | |
51 | * { | |
52 | * | |
53 | * AliHLTTPCDigitData *dataPt = (AliHLTTPCDigitData*)data->fDigitData; | |
54 | * for(int j=0; j<data->fNDigit; j++) | |
55 | * { | |
56 | * pad = dataPt[j].fPad; | |
57 | * time = dataPt[j].fTime; | |
58 | * charge = dataPt[j].fCharge; | |
59 | * } | |
60 | * | |
61 | * file.UpdateRowPointer(data); | |
62 | * | |
63 | * } | |
64 | * file.CloseBinaryInput(); | |
65 | * ________________________ | |
66 | * | |
67 | * 2) Writing a binary file: | |
68 | * | |
69 | * //First of all you need to store the data in memory, | |
70 | * //and have a pointer to it of type AliHLTTPCDigitRowData. | |
71 | * //E.g. if you just want to write the data you read in example 1) | |
72 | * //into a new file, you can do the following: | |
73 | * | |
74 | * AliHLTTPCMemHandler newfile; | |
75 | * newfile.Init(slice,patch); | |
76 | * newfile.SetBinaryOutput(newfilename); | |
77 | * newfile.Memory2CompBinary((UInt_t)NumberOfRowsInPatch,(AliHLTTPCDigitRowData*)data); | |
78 | * newfile.CloseBinaryOutput(); | |
79 | * | |
80 | * | |
81 | * Compressed file format: | |
82 | * ----------------------- | |
83 | * | |
84 | * The data is RLE encoded and currently using _10_ bit range for the ADC-values. | |
85 | * </pre> | |
86 | * | |
87 | * @ingroup alihlt_tpc | |
88 | */ | |
a6c02c85 | 89 | class AliHLTTPCMemHandler { |
90 | ||
91 | public: | |
92 | AliHLTTPCMemHandler(); | |
93 | virtual ~AliHLTTPCMemHandler(); | |
a6c02c85 | 94 | |
95 | void Reset(){CloseBinaryInput();CloseBinaryOutput();Free();} | |
96 | void Init(Int_t s,Int_t p, Int_t *r=0); | |
97 | ||
98 | Bool_t SetBinaryInput(char *name); | |
99 | Bool_t SetBinaryInput(FILE *file); | |
100 | void CloseBinaryInput(); | |
101 | ||
102 | Bool_t SetBinaryOutput(char *name); | |
103 | Bool_t SetBinaryOutput(FILE *file); | |
104 | void CloseBinaryOutput(); | |
105 | ||
106 | //Random cluster | |
107 | void SetRandomCluster(Int_t maxnumber); | |
108 | void SetRandomSeed(UInt_t seed){srand(seed);} | |
109 | void SetRandomSeed(); | |
110 | ||
111 | void ResetRandom(){fNDigits = 0; fNUsed = 0;} | |
112 | void Generate(Int_t row); | |
113 | void SetNGenerate(Int_t number){(number>fNRandom)?fNGenerate=fNRandom:fNGenerate = number;} | |
114 | ||
115 | void SetROI(Float_t *eta,Int_t *slice); | |
116 | void ResetROI(); | |
117 | ||
5578cf60 | 118 | //////////////////////////////////////////////////////////////////////////////////// |
119 | // | |
120 | // Digit IO | |
121 | ||
122 | /** | |
123 | * Write digit data to binary file. | |
124 | * The function loops over the rows and dumps all data of the | |
125 | * AliHLTTPCDigitRowData in binary format to the file. | |
126 | * @param nrow size of the array | |
127 | * @param data data array | |
128 | * @return kTRUE if succeeded, kFALSE if error | |
129 | */ | |
130 | Bool_t Memory2BinaryFile(UInt_t nrow,AliHLTTPCDigitRowData *data); | |
131 | ||
132 | /** | |
133 | * Read digit data from binary file. | |
134 | * @param nrow size of the array | |
135 | * @param data data buffer to receive the data | |
136 | * @param sz [IN] buffer size [OUT] total output size | |
137 | * @return kTRUE if succeeded, kFALSE if error | |
138 | */ | |
a38a7850 | 139 | Bool_t Binary2Memory(UInt_t & nrow,AliHLTTPCDigitRowData *data, UInt_t& sz); |
5578cf60 | 140 | |
141 | // Matthias 18.09.2007 | |
142 | // this function is highly error prone, no size check for data buffer | |
143 | // depricated | |
144 | //Bool_t Binary2Memory(UInt_t & nrow,AliHLTTPCDigitRowData *data){UInt_t tmp;return Binary2Memory(nrow,data,tmp);}; | |
a6c02c85 | 145 | |
146 | Int_t Memory2CompMemory(UInt_t nrow,AliHLTTPCDigitRowData *data,UInt_t *comp); | |
a38a7850 | 147 | Int_t CompMemory2Memory(UInt_t nrow,AliHLTTPCDigitRowData *data,UInt_t *comp,UInt_t& sz); |
148 | Int_t CompMemory2Memory(UInt_t nrow,AliHLTTPCDigitRowData *data,UInt_t *comp) {UInt_t tmp;return CompMemory2Memory(nrow,data,comp,tmp);}; | |
a6c02c85 | 149 | Bool_t CompMemory2CompBinary(UInt_t nrow,UInt_t *comp, UInt_t size=0); |
150 | Bool_t CompBinary2CompMemory(UInt_t & nrow,UInt_t *comp); | |
151 | ||
a38a7850 | 152 | virtual AliHLTTPCDigitRowData *CompBinary2Memory(UInt_t & nrow, UInt_t& sz); |
153 | virtual AliHLTTPCDigitRowData *CompBinary2Memory(UInt_t & nrow){UInt_t tmp;return CompBinary2Memory(nrow,tmp);}; | |
a6c02c85 | 154 | virtual Bool_t Memory2CompBinary(UInt_t nrow,AliHLTTPCDigitRowData *data); |
155 | ||
156 | UInt_t GetNRow(UInt_t *comp,UInt_t size); | |
157 | ||
158 | //Point IO | |
159 | Bool_t Memory2Binary(UInt_t npoint,AliHLTTPCSpacePointData *data); | |
a38a7850 | 160 | Bool_t Binary2Memory(UInt_t & npoint,AliHLTTPCSpacePointData *data, UInt_t& sz); |
161 | Bool_t Binary2Memory(UInt_t & npoint,AliHLTTPCSpacePointData *data) {UInt_t tmp; return Binary2Memory(npoint,data,tmp);}; | |
a6c02c85 | 162 | Bool_t Transform(UInt_t npoint,AliHLTTPCSpacePointData *data,Int_t slice); |
163 | static void UpdateRowPointer(AliHLTTPCDigitRowData *&tempPt); | |
164 | ||
165 | //Track IO | |
166 | Bool_t Memory2Binary(UInt_t ntrack,AliHLTTPCTrackSegmentData *data); | |
167 | Bool_t Binary2Memory(UInt_t & ntrack,AliHLTTPCTrackSegmentData *data); | |
168 | Bool_t TrackArray2Binary(AliHLTTPCTrackArray *array); | |
169 | Bool_t Binary2TrackArray(AliHLTTPCTrackArray *array); | |
170 | Bool_t TrackArray2Memory(UInt_t & ntrack,AliHLTTPCTrackSegmentData *data,AliHLTTPCTrackArray *array) const; | |
171 | Bool_t Memory2TrackArray(UInt_t ntrack,AliHLTTPCTrackSegmentData *data,AliHLTTPCTrackArray *array) const; | |
172 | Bool_t Memory2TrackArray(UInt_t ntrack,AliHLTTPCTrackSegmentData *data,AliHLTTPCTrackArray *array,Int_t slice) const; | |
173 | ||
174 | //Memory Allocation | |
175 | UInt_t GetAllocatedSize() const {return fSize;} | |
176 | UInt_t GetFileSize(); | |
177 | UInt_t GetMemorySize(UInt_t nrow,UInt_t *comp) const; | |
178 | UInt_t GetCompMemorySize(UInt_t nrow,AliHLTTPCDigitRowData *data) const; | |
179 | UInt_t GetRandomSize() const; | |
180 | ||
181 | Byte_t *Allocate(UInt_t size); | |
182 | Byte_t *Allocate(); // allocate size of Binary Input File | |
183 | Byte_t *Allocate(AliHLTTPCTrackArray *array); | |
184 | Byte_t *GetDataPointer(UInt_t &size) {size = fSize; return fPt;} | |
185 | FILE *GetFilePointer() {return fInBinary;} | |
186 | void Free(); | |
187 | ||
188 | //Getters: | |
189 | Int_t GetRowMin() const {return fRowMin;} | |
190 | Int_t GetRowMax() const {return fRowMax;} | |
191 | Int_t GetSlice() const {return fSlice;} | |
192 | Int_t GetPatch() const {return fPatch;} | |
193 | ||
194 | //virtual functions: | |
195 | virtual void FreeDigitsTree() {fDummy=0; return;} | |
196 | virtual Bool_t SetAliInput(char */*name*/){fDummy=0; return 0;} | |
a6c02c85 | 197 | virtual Bool_t SetAliInput(AliRunLoader */*runloader*/){fDummy=0; return 0;} |
a6c02c85 | 198 | virtual void CloseAliInput(){fDummy=0; return;} |
199 | virtual Bool_t IsDigit(Int_t /*i*/=0){fDummy=0; return 0;} | |
200 | virtual Bool_t SetMCOutput(char */*name*/){fDummy=0; return 0;} | |
201 | virtual Bool_t SetMCOutput(FILE */*file*/){fDummy=0; return 0;} | |
202 | virtual void CloseMCOutput(){fDummy=0; return;} | |
203 | virtual Bool_t AliDigits2Binary(Int_t /*event*/=0,Bool_t /*altro*/=kFALSE){fDummy=0; return 0;} | |
204 | virtual Bool_t AliDigits2CompBinary(Int_t /*event*/=0,Bool_t /*altro*/=kFALSE){fDummy=0; return 0;} | |
205 | virtual AliHLTTPCDigitRowData *AliDigits2Memory(UInt_t & /*nrow*/,Int_t /*event*/=0){fDummy=0; return 0;} | |
206 | virtual AliHLTTPCDigitRowData *AliAltroDigits2Memory(UInt_t & /*nrow*/,Int_t /*event*/=0,Bool_t /*eventmerge*/=kFALSE){fDummy=0; return 0;} | |
207 | virtual void AliDigits2RootFile(AliHLTTPCDigitRowData */*rowPt*/,Char_t */*new_digitsfile*/){fDummy=0; return;} | |
208 | virtual Bool_t AliPoints2Binary(Int_t /*eventn*/=0){fDummy=0; return 0;} | |
209 | virtual AliHLTTPCSpacePointData *AliPoints2Memory(UInt_t & /*npoint*/,Int_t /*eventn*/=0){fDummy=0; return 0;} | |
210 | ||
211 | //AliHLTTPCRawDataFileHandler | |
212 | virtual Bool_t SetRawInput(Char_t */*name*/){fDummy=0; return 0;} | |
213 | virtual Bool_t SetRawInput(ifstream */*file*/){fDummy=0; return 0;} | |
214 | virtual void CloseRawInput(){} | |
215 | virtual Int_t ReadRawInput(){fDummy=0; return 0;} | |
216 | virtual Short_t** GetRawData(Int_t &/*channels*/, Int_t & /*timebins*/){fDummy=0; return 0;} | |
217 | ||
218 | virtual Bool_t SetRawOutput(Char_t */*name*/){fDummy=0; return 0;} | |
219 | virtual Bool_t SetRawOutput(ofstream */*file*/){fDummy=0; return 0;} | |
220 | virtual void CloseRawOutput(){} | |
221 | virtual Bool_t SaveRawOutput(){fDummy=0; return 0;} | |
222 | ||
223 | virtual Bool_t SetMappingFile(Char_t */*name*/){fDummy=0; return 0;} | |
224 | virtual Bool_t SetMappingFile(FILE */*file*/){fDummy=0; return 0;} | |
225 | virtual void CloseMappingFile(){} | |
226 | virtual Int_t ReadMappingFile(){fDummy=0; return 0;} | |
227 | ||
228 | virtual Bool_t SetRawPedestalsInput(Char_t */*name*/){fDummy=0; return 0;} | |
229 | virtual Bool_t SetRawPedestalsInput(ifstream */*file*/){fDummy=0; return 0;} | |
230 | virtual void CloseRawPedestalsInput(){} | |
231 | virtual Int_t ReadRawPedestalsInput(){fDummy=0; return 0;} | |
232 | ||
233 | virtual AliHLTTPCDigitRowData* RawData2Memory(UInt_t &/*nrow*/,Int_t /*event*/=-1){fDummy=0; return 0;} | |
234 | virtual Bool_t RawData2CompMemory(Int_t /*event*/=-1){fDummy=0; return 0;} | |
235 | ||
236 | //AliHLTTPCDDLDataFileHandler | |
a6c02c85 | 237 | virtual Bool_t SetReaderInput(AliRawEvent */*rawevent*/){fDummy=0; return 0;} |
238 | virtual Bool_t SetReaderInput(Char_t */*name*/,Int_t /*event*/=0){fDummy=0; return 0;} | |
a6c02c85 | 239 | virtual void CloseReaderInput(){}; |
240 | ||
241 | virtual AliHLTTPCDigitRowData* DDLData2Memory(UInt_t &/*nrow*/,Int_t /*event*/=-1){fDummy=0; return 0;} | |
242 | virtual Bool_t DDLData2CompBinary(Int_t /*event*/=-1){fDummy=0; return 0;} | |
243 | ||
244 | virtual AliTPCRawStream* GetTPCRawStream(){fDummy=0; return 0;} | |
245 | ||
246 | protected: | |
247 | Int_t fRowMin; //min row | |
248 | Int_t fRowMax; //max row | |
249 | Int_t fSlice; //slice | |
250 | Int_t fPatch; //patch | |
251 | ||
0ba35c53 | 252 | static const Int_t fgkNSlice = 36; //! |
253 | static const Int_t fgkNRow = 159; //! | |
254 | ||
255 | Int_t fEtaMinTimeBin[fgkNRow]; //for ROI in eta only | |
256 | Int_t fEtaMaxTimeBin[fgkNRow]; //for ROI in eta only | |
a6c02c85 | 257 | |
258 | FILE *fInBinary;//! | |
259 | FILE *fOutBinary;//! | |
260 | ||
261 | private: | |
5578cf60 | 262 | /** copy constructor prohibited */ |
263 | AliHLTTPCMemHandler(const AliHLTTPCMemHandler& src); | |
264 | /** assignment operator prohibited */ | |
265 | AliHLTTPCMemHandler& operator=(const AliHLTTPCMemHandler& src); | |
a6c02c85 | 266 | |
267 | Byte_t *fPt;//! | |
268 | UInt_t fSize; //size of allocated data structure | |
269 | ||
270 | Bool_t fIsRandom; //random data generated | |
271 | Int_t fNRandom; //count random digits | |
272 | Int_t fNGenerate; //count generated digits | |
273 | Int_t fNUsed; //count used digits | |
274 | Int_t fNDigits; //count digits from digitstree | |
275 | ||
276 | AliHLTTPCRandomDigitData **fDPt;//! | |
277 | AliHLTTPCRandomDigitData *fRandomDigits;//! | |
278 | ||
279 | Int_t fDummy; // to fool the virtual const problem | |
280 | // of the coding conventions tool | |
281 | ||
282 | void Write(UInt_t *comp, UInt_t & index, UInt_t & subindex, UShort_t value) const; | |
283 | UShort_t Read(UInt_t *comp, UInt_t & index, UInt_t & subindex) const; | |
284 | UShort_t Test(UInt_t *comp, UInt_t index, UInt_t subindex) const; | |
285 | ||
286 | void DigitizePoint(Int_t row,Int_t pad, Int_t time,Int_t charge); | |
287 | void QSort(AliHLTTPCRandomDigitData **a, Int_t first, Int_t last); | |
288 | Int_t ComparePoints(UInt_t row,UShort_t pad,UShort_t time) const ; | |
289 | Int_t CompareDigits(AliHLTTPCRandomDigitData *a,AliHLTTPCRandomDigitData *b) const; | |
290 | void AddData(AliHLTTPCDigitData *data,UInt_t & ndata, | |
291 | UInt_t row,UShort_t pad,UShort_t time,UShort_t charge) const; | |
292 | void AddRandom(AliHLTTPCDigitData *data,UInt_t & ndata); | |
293 | void MergeDataRandom(AliHLTTPCDigitData *data,UInt_t & ndata, | |
294 | UInt_t row,UShort_t pad,UShort_t time,UShort_t charge); | |
295 | void AddDataRandom(AliHLTTPCDigitData *data,UInt_t & ndata, | |
296 | UInt_t row,UShort_t pad,UShort_t time,UShort_t charge); | |
297 | ||
298 | ||
299 | ClassDef(AliHLTTPCMemHandler,1) // Memory handler class | |
300 | }; | |
301 | #endif |